diff --git a/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts b/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts index 9df8aac4..3b753f28 100644 --- a/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts +++ b/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts @@ -155,8 +155,18 @@ export class MedicalSourcesConnectedComponent implements OnInit { //remove the "Patient/" or "https://example.com/fhir/Patient/" prefix if it exists payload.patient = payload.patient.split("Patient/")[1] } - } + //special case for flatiron id token. See https://github.com/fastenhealth/fasten-sources/issues/42 + if(!payload.patient && sourceMetadata.platform_type == 'flatiron'){ + // "pp.patient_id": "PD_05XXXXXXXXX3", + // "pp.group_id": "GH_CXXXXXXXXXXXX9_5", + // Becomes: PD--05XXXXXXXXX3.GH--CXXXXXXXXXXXX9--5 + + let decodedAccessToken = this.jwtDecode(payload.access_token) + let patientId = `${decodedAccessToken["pp.patient_id"]}.${decodedAccessToken["pp.group_id"]}`.replace(/_/g, '--') + payload.patient = patientId + } + //get the portal information const portalInfo = await this.lighthouseApi.getLighthouseCatalogPortal(expectedSourceStateInfo.portal_id) diff --git a/frontend/src/app/services/lighthouse.service.ts b/frontend/src/app/services/lighthouse.service.ts index 6c2f3ba1..9eaf42bc 100644 --- a/frontend/src/app/services/lighthouse.service.ts +++ b/frontend/src/app/services/lighthouse.service.ts @@ -120,6 +120,8 @@ export class LighthouseService { } + //DEPRECATED + // TODO: use the fasten-sources js library async generateSourceAuthorizeUrl(lighthouseSource: LighthouseSourceMetadata, reconnectSourceId?: string): Promise { const state = uuidV4() let sourceStateInfo = new SourceState()