From c3ff28dc2935d1e2163846a11b48183117c606cf Mon Sep 17 00:00:00 2001 From: daniellrgn Date: Sun, 22 Sep 2024 10:59:03 -0700 Subject: [PATCH] Handle errors and update insurance clientIDs --- default.env | 7 +++++++ src/env.d.ts | 4 ++++ src/lib/components/app/FetchSoF.svelte | 10 ++++++---- src/lib/config.ts | 13 ++++++------- src/lib/utils/sofClient.js | 9 ++++++--- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/default.env b/default.env index e08637f0..ec94a2d6 100644 --- a/default.env +++ b/default.env @@ -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= diff --git a/src/env.d.ts b/src/env.d.ts index 49907d62..287fd7b7 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -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 diff --git a/src/lib/components/app/FetchSoF.svelte b/src/lib/components/app/FetchSoF.svelte index df20d52a..8fdc0938 100644 --- a/src/lib/components/app/FetchSoF.svelte +++ b/src/lib/components/app/FetchSoF.svelte @@ -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) { @@ -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(); } diff --git a/src/lib/config.ts b/src/lib/config.ts index 8abcd81a..1cf7b3cd 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -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" }, ]; diff --git a/src/lib/utils/sofClient.js b/src/lib/utils/sofClient.js index 991207e6..5a4223df 100644 --- a/src/lib/utils/sofClient.js +++ b/src/lib/utils/sofClient.js @@ -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; @@ -94,7 +98,6 @@ async function getResources() { return requestResources(client, resourceType); }))).filter(x => x.status == "fulfilled").map(x => x.value); } - return resources; }