-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update SourceCredential interaface with additional GetEndpoint/Brand/Portal methods.
- Loading branch information
Showing
45 changed files
with
246 additions
and
1,035 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
clients/internal/platform/allscripts_test.go → clients/internal/allscripts_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package platform | ||
package internal | ||
|
||
// | ||
//func TestGetSourceClientAllscripts_SyncAll(t *testing.T) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package internal | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
base "github.com/fastenhealth/fasten-sources/clients/internal/base" | ||
models "github.com/fastenhealth/fasten-sources/clients/models" | ||
"github.com/fastenhealth/fasten-sources/definitions" | ||
definitionsModels "github.com/fastenhealth/fasten-sources/definitions/models" | ||
pkg "github.com/fastenhealth/fasten-sources/pkg" | ||
logrus "github.com/sirupsen/logrus" | ||
"net/http" | ||
) | ||
|
||
type dynamicSourceClient struct { | ||
models.SourceClient | ||
EndpointDefinition *definitionsModels.LighthouseSourceDefinition | ||
} | ||
|
||
func GetDynamicSourceClient(env pkg.FastenLighthouseEnvType, ctx context.Context, globalLogger logrus.FieldLogger, sourceCreds models.SourceCredential, testHttpClient ...*http.Client) (models.SourceClient, error) { | ||
|
||
//get the endpoint definition | ||
endpointDefinition, err := definitions.GetSourceDefinition(env, map[pkg.PlatformType]string{}, definitions.GetSourceConfigOptions{ | ||
EndpointId: sourceCreds.GetEndpointId(), | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if endpointDefinition == nil { | ||
return nil, fmt.Errorf("error retrieving endpoint definition (%s)", sourceCreds.GetEndpointId()) | ||
} | ||
|
||
baseClient, err := base.GetSourceClientFHIR401(env, ctx, globalLogger, sourceCreds, endpointDefinition, testHttpClient...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// API requires the following headers for every request | ||
if len(endpointDefinition.ClientHeaders) > 0 { | ||
for k, v := range endpointDefinition.ClientHeaders { | ||
baseClient.Headers[k] = v | ||
} | ||
} | ||
|
||
return dynamicSourceClient{SourceClient: baseClient, EndpointDefinition: endpointDefinition}, err | ||
} | ||
|
||
func (c dynamicSourceClient) SyncAll(db models.DatabaseRepository) (models.UpsertSummary, error) { | ||
|
||
if c.EndpointDefinition.MissingOpPatientEverything { | ||
//Operation-PatientEverything is not supported - https://build.fhir.org/operation-patient-everything.html | ||
//Manually processing individual resources | ||
|
||
supportedResources := c.GetUsCoreResources() | ||
if c.EndpointDefinition.ClientSupportedResources != nil { | ||
supportedResources = append(supportedResources, c.EndpointDefinition.ClientSupportedResources...) | ||
} | ||
return c.SyncAllByResourceName(db, supportedResources) | ||
} else if len(c.EndpointDefinition.CustomOpPatientEverything) > 0 { | ||
//Operation-PatientEverything uses non-standard endpoint - https://build.fhir.org/operation-patient-everything.html | ||
|
||
bundle, err := c.GetResourceBundle(c.EndpointDefinition.CustomOpPatientEverything) | ||
if err != nil { | ||
return models.UpsertSummary{UpdatedResources: []string{}}, err | ||
} | ||
return c.SyncAllByPatientEverythingBundle(db, bundle) | ||
} else { | ||
//Standard Operation-PatientEverything | ||
|
||
return c.SourceClient.SyncAll(db) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.