diff --git a/clients/internal/platform/epic_legacy.go b/clients/internal/platform/epic_legacy.go new file mode 100644 index 000000000..33bf443ab --- /dev/null +++ b/clients/internal/platform/epic_legacy.go @@ -0,0 +1,43 @@ +// Copyright (C) Fasten Health, Inc. - All Rights Reserved. +// +// THIS FILE IS GENERATED BY https://github.com/fastenhealth/fasten-sources-gen +// PLEASE DO NOT EDIT BY HAND + +package platform + +import ( + "context" + base "github.com/fastenhealth/fasten-sources/clients/internal/base" + models "github.com/fastenhealth/fasten-sources/clients/models" + pkg "github.com/fastenhealth/fasten-sources/pkg" + logrus "github.com/sirupsen/logrus" + "net/http" +) + +type sourceClientEpicLegacy struct { + models.SourceClient +} + +/* +This client is used for Epic/MyChart installations that do not support dynamic client registration: +*/ +// https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/.well-known/smart-configuration +// https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/metadata +// https://fhir.epic.com/Documentation?docId=testpatients +func GetSourceClientEpicLegacy(env pkg.FastenLighthouseEnvType, ctx context.Context, globalLogger logrus.FieldLogger, sourceCreds models.SourceCredential, testHttpClient ...*http.Client) (models.SourceClient, error) { + baseClient, err := base.GetSourceClientFHIR401(env, ctx, globalLogger, sourceCreds, testHttpClient...) + if err != nil { + return nil, err + } + // API requires the following headers for every request + baseClient.Headers["Accept"] = "application/json+fhir" + + return sourceClientEpicLegacy{baseClient}, err +} + +// Operation-PatientEverything is not supported - https://build.fhir.org/operation-patient-everything.html +// Manually processing individual resources +func (c sourceClientEpicLegacy) SyncAll(db models.DatabaseRepository) (models.UpsertSummary, error) { + supportedResources := append(c.GetUsCoreResources(), []string{"Account", "Appointment", "Consent", "FamilyMemberHistory", "InsurancePlan", "MedicationRequest", "NutritionOrder", "Person", "Provenance", "Questionnaire", "QuestionnaireResponse", "RelatedPerson", "Schedule", "ServiceRequest", "Slot"}...) + return c.SyncAllByResourceName(db, supportedResources) +} diff --git a/definitions/internal/platform/epic_legacy.go b/definitions/internal/platform/epic_legacy.go new file mode 100644 index 000000000..0b2facffd --- /dev/null +++ b/definitions/internal/platform/epic_legacy.go @@ -0,0 +1,49 @@ +// Copyright (C) Fasten Health, Inc. - All Rights Reserved. +// +// THIS FILE IS GENERATED BY https://github.com/fastenhealth/fasten-sources-gen +// PLEASE DO NOT EDIT BY HAND + +package platform + +import ( + models "github.com/fastenhealth/fasten-sources/definitions/models" + pkg "github.com/fastenhealth/fasten-sources/pkg" +) + +/* +This client is used for Epic/MyChart installations that do not support dynamic client registration: +*/ +// https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/.well-known/smart-configuration +// https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/metadata +// https://fhir.epic.com/Documentation?docId=testpatients +func GetSourceEpicLegacy(env pkg.FastenLighthouseEnvType, clientIdLookup map[pkg.SourceType]string) (models.LighthouseSourceDefinition, error) { + sourceDef := models.LighthouseSourceDefinition{} + sourceDef.AuthorizationEndpoint = "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/authorize" + sourceDef.TokenEndpoint = "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token" + sourceDef.IntrospectionEndpoint = "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/introspect" + sourceDef.RegistrationEndpoint = "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/register" + + sourceDef.Issuer = "https://fhir.epic.com" + sourceDef.Scopes = []string{"fhirUser", "openid", "profile"} + sourceDef.GrantTypesSupported = []string{"authorization_code"} + sourceDef.ResponseType = []string{"code"} + sourceDef.ResponseModesSupported = []string{"fragment", "query"} + sourceDef.Audience = "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4" + sourceDef.CodeChallengeMethodsSupported = []string{"S256"} + + sourceDef.ApiEndpointBaseUrl = "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4" + // retrieve client-id, if available + if clientId, clientIdOk := clientIdLookup[pkg.SourceTypeEpicLegacy]; clientIdOk { + sourceDef.ClientId = clientId + } + sourceDef.RedirectUri = pkg.GetCallbackEndpoint(string(pkg.SourceTypeEpic)) + + sourceDef.Display = "Epic Legacy (Sandbox)" + sourceDef.PlatformType = pkg.SourceTypeEpicLegacy + sourceDef.SourceType = pkg.SourceTypeEpicLegacy + sourceDef.Category = []string{"Sandbox"} + sourceDef.Aliases = []string{} + sourceDef.PatientAccessUrl = "www.epic.com" + + return sourceDef, nil +}