Skip to content

Commit

Permalink
Handle errors and update insurance clientIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellrgn committed Jan 10, 2025
1 parent 55ff17c commit c3ff28d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
7 changes: 7 additions & 0 deletions default.env
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,16 @@ VITE_VERSION_STRING=

# SMART on FHIR client id configurations:
# Ensure that your development client is registered with the proper redirect uris
#EHRs
VITE_EPIC_CLIENT_ID=
VITE_CERNER_CLIENT_ID=

#Insurance
VITE_AETNA_CLIENT_ID=
VITE_CAREFIRST_CLIENT_ID=
VITE_HUMANA_CLIENT_ID=
VITE_ACENTRA_CLIENT_ID=

# SOF for HIMSS 2024 only:
#VITE_EPIC_HIMSS_CLIENT_ID=
#VITE_ECW_HIMSS_CLIENT_ID=
Expand Down
4 changes: 4 additions & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ interface ImportMetaEnv {
readonly VITE_ECW_HIMSS_CLIENT_ID: string
readonly VITE_EPIC_CLIENT_ID: string
readonly VITE_CERNER_CLIENT_ID: string
readonly VITE_AETNA_CLIENT_ID: string
readonly VITE_CAREFIRST_CLIENT_ID: string
readonly VITE_HUMANA_CLIENT_ID: string
readonly VITE_ACENTRA_CLIENT_ID: string
readonly VITE_MEDITECH_BEARER_TOKEN: string
readonly VITE_API_BASE: string
readonly VITE_VIEWER_BASE: string
Expand Down
10 changes: 6 additions & 4 deletions src/lib/components/app/FetchSoF.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
try {
if (sofHost) {
try {
authorize(sofHost.url, sofHost.clientId, sofHost.clientSecret ?? undefined);
authDispatch('sof-auth-init');
authorize(sofHost.url, sofHost.clientId);// , sofHost.clientSecret);
authDispatch('sof-auth-init', { data: true });
} catch (e) {
authDispatch('sof-auth-fail')
authDispatch('sof-auth-fail', { data: false });
}
}
} catch (e) {
Expand Down Expand Up @@ -86,7 +86,9 @@
console.log(resources)
processing = false;
return resourceDispatch('update-resources', result);
} catch (e) {
} catch (e: any) {
console.log(e.message);
fetchError = e.message;
processing = false;
endSession();
}
Expand Down
13 changes: 6 additions & 7 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,19 @@ export const SOF_HOSTS = [
id: "aetna",
name: "AETNA Insurance Sandbox",
url: "https://vteapif1.aetna.com/fhirdemo/v1/patientaccess",
clientId: "09cbb76344009c25a2ec587b39ebc303",
clientSecret: "4fe39eccbfc586647407ea19f408521f",
clientId: import.meta.env.VITE_AETNA_CLIENT_ID,
note: "VTETestUser01 / FHIRdemo2020"
},
{
id: "c4bb",
name: "CARIN Blue Button",
// url: "https://chpdc-api-sita.carefirst.com/v1/fhir/patientaccess",
id: "carefirst",
name: "CareFirst",
url: "https://chpdc-api-sita.carefirst.com/v1/fhir/patientaccess",
// url: "https://chpmd-api-sita.carefirst.com/v1/fhir/patientaccess",
// url: "https://dsnp-api-sita.carefirst.com/v1/fhir/patientaccess",
// url: "https://mapd-api-sita.carefirst.com/v1/fhir/patientaccess",
// url: "https://mhbe-api-sita.carefirst.com/v1/fhir/patientaccess",
url: "https://egwp-api-sita.carefirst.com/v1/fhir/patientaccess",
clientId: "0oaf5w78xfWspNqeA1d7",
// url: "https://egwp-api-sita.carefirst.com/v1/fhir/patientaccess",
clientId: import.meta.env.VITE_CAREFIRST_CLIENT_ID,
note: "Credentials provided"
},
];
Expand Down
9 changes: 6 additions & 3 deletions src/lib/utils/sofClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ async function activePatient() {
}

async function getResources() {
client = await FHIR.oauth2.ready();
try {
client = await FHIR.oauth2.ready();
} catch (e) {
throw Error('SMART authorization failed. The service you selected may be unavailable.')
}
let pid = client.getPatientId();
if (!pid) {
console.error("No patient ID found");
return undefined;
throw Error('The service you selected did not return an ID for the authorized patient. Please try a different service.')
}
// Establish resource display methods
let resources;
Expand All @@ -94,7 +98,6 @@ async function getResources() {
return requestResources(client, resourceType);
}))).filter(x => x.status == "fulfilled").map(x => x.value);
}


return resources;
}
Expand Down

0 comments on commit c3ff28d

Please sign in to comment.