diff --git a/backend/pkg/hub/factory.go b/backend/pkg/hub/factory.go index 11f41fae..30fe33b1 100644 --- a/backend/pkg/hub/factory.go +++ b/backend/pkg/hub/factory.go @@ -12,6 +12,8 @@ import ( "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/bluebutton" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/cerner" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/cigna" + "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/epic" + "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/healthit" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/logica" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/manual" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/models" @@ -37,6 +39,10 @@ func NewClient(sourceType pkg.SourceType, ctx context.Context, appConfig config. sourceClient, updatedSource, err = cerner.NewClient(ctx, appConfig, globalLogger, credentials, testHttpClient...) case pkg.SourceTypeCigna: sourceClient, updatedSource, err = cigna.NewClient(ctx, appConfig, globalLogger, credentials, testHttpClient...) + case pkg.SourceTypeEpic: + sourceClient, updatedSource, err = epic.NewClient(ctx, appConfig, globalLogger, credentials, testHttpClient...) + case pkg.SourceTypeHealthIT: + sourceClient, updatedSource, err = healthit.NewClient(ctx, appConfig, globalLogger, credentials, testHttpClient...) case pkg.SourceTypeLogica: sourceClient, updatedSource, err = logica.NewClient(ctx, appConfig, globalLogger, credentials, testHttpClient...) case pkg.SourceTypeManual: diff --git a/backend/pkg/hub/internal/fhir/base/fhir401_client.go b/backend/pkg/hub/internal/fhir/base/fhir401_client.go index b278e436..ee3b3889 100644 --- a/backend/pkg/hub/internal/fhir/base/fhir401_client.go +++ b/backend/pkg/hub/internal/fhir/base/fhir401_client.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config" + "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/database" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/models" "github.com/fastenhealth/gofhir-models/fhir401" fhirutils "github.com/fastenhealth/gofhir-models/fhir401/utils" @@ -24,6 +25,32 @@ func NewFHIR401Client(ctx context.Context, appConfig config.Interface, globalLog }, updatedSource, err } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Sync +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +func (c *FHIR401Client) SyncAll(db database.DatabaseRepository) error { + + bundle, err := c.GetPatientBundle(c.Source.PatientId) + if err != nil { + return err + } + + wrappedResourceModels, err := c.ProcessBundle(bundle) + if err != nil { + c.Logger.Infof("An error occurred while processing patient bundle %s", c.Source.PatientId) + return err + } + //todo, create the resources in dependency order + + for _, apiModel := range wrappedResourceModels { + err = db.UpsertResource(context.Background(), apiModel) + if err != nil { + return err + } + } + return nil +} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // FHIR //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/backend/pkg/hub/internal/fhir/bluebutton/client.go b/backend/pkg/hub/internal/fhir/bluebutton/client.go index 062b1de2..2a9cf94d 100644 --- a/backend/pkg/hub/internal/fhir/bluebutton/client.go +++ b/backend/pkg/hub/internal/fhir/bluebutton/client.go @@ -3,7 +3,6 @@ package bluebutton import ( "context" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config" - "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/database" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/base" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/models" "github.com/sirupsen/logrus" @@ -20,26 +19,3 @@ func NewClient(ctx context.Context, appConfig config.Interface, globalLogger log baseClient, }, updatedSource, err } - -func (c BlueButtonClient) SyncAll(db database.DatabaseRepository) error { - - bundle, err := c.GetPatientBundle(c.Source.PatientId) - if err != nil { - return err - } - - wrappedResourceModels, err := c.ProcessBundle(bundle) - if err != nil { - c.Logger.Infof("An error occurred while processing patient bundle %s", c.Source.PatientId) - return err - } - //todo, create the resources in dependency order - - for _, apiModel := range wrappedResourceModels { - err = db.UpsertResource(context.Background(), apiModel) - if err != nil { - return err - } - } - return nil -} diff --git a/backend/pkg/hub/internal/fhir/cerner/client.go b/backend/pkg/hub/internal/fhir/cerner/client.go index bf031f68..418d36ee 100644 --- a/backend/pkg/hub/internal/fhir/cerner/client.go +++ b/backend/pkg/hub/internal/fhir/cerner/client.go @@ -17,6 +17,7 @@ type CernerClient struct { func NewClient(ctx context.Context, appConfig config.Interface, globalLogger logrus.FieldLogger, source models.Source, testHttpClient ...*http.Client) (base.Client, *models.Source, error) { baseClient, updatedSource, err := base.NewFHIR401Client(ctx, appConfig, globalLogger, source, testHttpClient...) + baseClient.Headers["Accept"] = "application/json+fhir" return CernerClient{ baseClient, }, updatedSource, err diff --git a/backend/pkg/hub/internal/fhir/cigna/client.go b/backend/pkg/hub/internal/fhir/cigna/client.go index be560284..f7142f94 100644 --- a/backend/pkg/hub/internal/fhir/cigna/client.go +++ b/backend/pkg/hub/internal/fhir/cigna/client.go @@ -3,7 +3,6 @@ package cigna import ( "context" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config" - "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/database" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/base" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/models" "github.com/sirupsen/logrus" @@ -20,26 +19,3 @@ func NewClient(ctx context.Context, appConfig config.Interface, globalLogger log baseClient, }, updatedSource, err } - -func (c CignaClient) SyncAll(db database.DatabaseRepository) error { - - bundle, err := c.GetPatientBundle(c.Source.PatientId) - if err != nil { - return err - } - - wrappedResourceModels, err := c.ProcessBundle(bundle) - if err != nil { - c.Logger.Infof("An error occurred while processing patient bundle %s", c.Source.PatientId) - return err - } - //todo, create the resources in dependency order - - for _, apiModel := range wrappedResourceModels { - err = db.UpsertResource(context.Background(), apiModel) - if err != nil { - return err - } - } - return nil -} diff --git a/backend/pkg/hub/internal/fhir/epic/client.go b/backend/pkg/hub/internal/fhir/epic/client.go new file mode 100644 index 00000000..a68c3458 --- /dev/null +++ b/backend/pkg/hub/internal/fhir/epic/client.go @@ -0,0 +1,23 @@ +package epic + +import ( + "context" + "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config" + "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/base" + "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/models" + "github.com/sirupsen/logrus" + "net/http" +) + +type EpicClient struct { + *base.FHIR401Client +} + +func NewClient(ctx context.Context, appConfig config.Interface, globalLogger logrus.FieldLogger, source models.Source, testHttpClient ...*http.Client) (base.Client, *models.Source, error) { + baseClient, updatedSource, err := base.NewFHIR401Client(ctx, appConfig, globalLogger, source, testHttpClient...) + baseClient.Headers["Accept"] = "application/json+fhir" + + return EpicClient{ + baseClient, + }, updatedSource, err +} diff --git a/backend/pkg/hub/internal/fhir/healthit/client.go b/backend/pkg/hub/internal/fhir/healthit/client.go new file mode 100644 index 00000000..477e3081 --- /dev/null +++ b/backend/pkg/hub/internal/fhir/healthit/client.go @@ -0,0 +1,23 @@ +package healthit + +import ( + "context" + "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config" + "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/base" + "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/models" + "github.com/sirupsen/logrus" + "net/http" +) + +type HealthItClient struct { + *base.FHIR401Client +} + +func NewClient(ctx context.Context, appConfig config.Interface, globalLogger logrus.FieldLogger, source models.Source, testHttpClient ...*http.Client) (base.Client, *models.Source, error) { + baseClient, updatedSource, err := base.NewFHIR401Client(ctx, appConfig, globalLogger, source, testHttpClient...) + baseClient.Headers["Accept"] = "application/json+fhir" + + return HealthItClient{ + baseClient, + }, updatedSource, err +} diff --git a/backend/pkg/hub/internal/fhir/logica/client.go b/backend/pkg/hub/internal/fhir/logica/client.go index 6e978abf..e58d81af 100644 --- a/backend/pkg/hub/internal/fhir/logica/client.go +++ b/backend/pkg/hub/internal/fhir/logica/client.go @@ -3,7 +3,6 @@ package logica import ( "context" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config" - "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/database" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/hub/internal/fhir/base" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/models" "github.com/sirupsen/logrus" @@ -20,26 +19,3 @@ func NewClient(ctx context.Context, appConfig config.Interface, globalLogger log baseClient, }, updatedSource, err } - -func (c LogicaClient) SyncAll(db database.DatabaseRepository) error { - - bundle, err := c.GetPatientBundle(c.Source.PatientId) - if err != nil { - return err - } - - wrappedResourceModels, err := c.ProcessBundle(bundle) - if err != nil { - c.Logger.Infof("An error occurred while processing patient bundle %s", c.Source.PatientId) - return err - } - //todo, create the resources in dependency order - - for _, apiModel := range wrappedResourceModels { - err = db.UpsertResource(context.Background(), apiModel) - if err != nil { - return err - } - } - return nil -} diff --git a/backend/pkg/web/handler/metadata.go b/backend/pkg/web/handler/metadata.go index 40ff7b65..dbe0f59d 100644 --- a/backend/pkg/web/handler/metadata.go +++ b/backend/pkg/web/handler/metadata.go @@ -21,10 +21,10 @@ func GetMetadataSource(c *gin.Context) { //TODO: infinite pagination for Encounters?? string(pkg.SourceTypeCerner): {Display: "Cerner (Sandbox)", SourceType: pkg.SourceTypeCerner, Category: []string{"Sandbox"}, Supported: true}, - //does not support PKCE/Public Clients - string(pkg.SourceTypeBlueButtonMedicare): {Display: "Medicare/VA Health (BlueButton)", SourceType: pkg.SourceTypeBlueButtonMedicare, Category: []string{"Hospital"}, Supported: false}, - string(pkg.SourceTypeEpic): {Display: "Epic (Sandbox)", SourceType: pkg.SourceTypeEpic, Category: []string{"Sandbox"}, Supported: false}, - string(pkg.SourceTypeCareEvolution): {Display: "CareEvolution (Sandbox)", SourceType: pkg.SourceTypeCareEvolution, Category: []string{"Sandbox"}, Supported: false}, + //TODO: does not support $everything endpoint. + string(pkg.SourceTypeBlueButtonMedicare): {Display: "Medicare/VA Health (BlueButton)", SourceType: pkg.SourceTypeBlueButtonMedicare, Category: []string{"Hospital"}, Supported: true}, + string(pkg.SourceTypeEpic): {Display: "Epic (Sandbox)", SourceType: pkg.SourceTypeEpic, Category: []string{"Sandbox"}, Supported: true}, + string(pkg.SourceTypeCareEvolution): {Display: "CareEvolution (Sandbox)", SourceType: pkg.SourceTypeCareEvolution, Category: []string{"Sandbox"}, Supported: true}, // pending string(pkg.SourceTypeAnthem): {Display: "Anthem", SourceType: pkg.SourceTypeAnthem, Category: []string{"Insurance"}},