Skip to content

Commit

Permalink
fixing missing Epic Legacy client and Definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Nov 5, 2023
1 parent 6cc6420 commit 17c530b
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
43 changes: 43 additions & 0 deletions clients/internal/platform/epic_legacy.go
Original file line number Diff line number Diff line change
@@ -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)
}
49 changes: 49 additions & 0 deletions definitions/internal/platform/epic_legacy.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 17c530b

Please sign in to comment.