Skip to content

Commit

Permalink
Temporary change to get resources from dev hapi
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellrgn committed Jan 25, 2024
1 parent a9bb079 commit f9b7858
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 34 deletions.
8 changes: 0 additions & 8 deletions src/lib/FetchSoF.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@
}
});
function endSession() {
let key = sessionStorage.getItem('SMART_KEY');
if (key) {
sessionStorage.removeItem(JSON.parse(key));
sessionStorage.removeItem('SMART_KEY');
}
}
async function fetchData() {
processing = true;
let resources = await getResourcesWithReferences(1);
Expand Down
8 changes: 0 additions & 8 deletions src/lib/FetchSoFLTT.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@
}
});
function endSession() {
let key = sessionStorage.getItem('SMART_KEY');
if (key) {
sessionStorage.removeItem(JSON.parse(key));
sessionStorage.removeItem('SMART_KEY');
}
}
async function fetchData() {
processing = true;
let resources = await getResourcesWithReferences(1);
Expand Down
16 changes: 1 addition & 15 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@ export const API_BASE = import.meta.env.VITE_API_BASE;
export const INTERMEDIATE_FHIR_SERVER_BASE = import.meta.env.VITE_INTERMEDIATE_FHIR_SERVER_BASE;

export const SOF_HOSTS = [
{
id: "epic",
name: "EPIC Demo",
url: "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4",
clientId: import.meta.env.VITE_EPIC_CLIENT_ID,
note: "<a href='https://fhir.epic.com/Documentation?docId=testpatients' target='_blank' rel='noreferrer'>Test patient credentials <Icon name='box-arrow-up-right' /></a>"
},
{
id: "cerner",
name: "Oracle Cerner Demo",
url: "https://fhir-myrecord.cerner.com/r4/ec2458f2-1e24-41c8-b71b-0e701af7583d",
clientId: import.meta.env.VITE_CERNER_CLIENT_ID,
note: "<a href='https://docs.google.com/document/u/1/d/e/2PACX-1vQwyX3px4qi5t1O6_El6022zYt4ymKAWCrcgxcX5NvYGUJAkJ4WFwOnLoikow6rEccpFZzDWBdcBqsQ/pub' target='_blank' rel='noreferrer'>Test patient credentials <Icon name='box-arrow-up-right' /></a>"
},
{
id: "smit",
name: "SMART Health IT Demo",
Expand All @@ -28,7 +14,7 @@ export const SOF_HOSTS = [
note: "Credentials provided"
}
];
export const SOF_REDIRECT_URI = '/create';
export const SOF_REDIRECT_URI = '/authenticate';
export const SOF_RESOURCES = [
'Patient',
'AllergyIntolerance',
Expand Down
15 changes: 12 additions & 3 deletions src/lib/sofClient.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import FHIR from 'fhirclient';
import { SOF_REDIRECT_URI, SOF_PATIENT_RESOURCES, SOF_RESOURCES } from './config';
import { SOF_REDIRECT_URI, SOF_PATIENT_RESOURCES, SOF_RESOURCES } from './config.ts';

export { authorize, getResources, getResourcesWithReferences, activePatient };
export { authorize, getResources, getResourcesWithReferences, activePatient, endSession };

const patientResourceScope = SOF_PATIENT_RESOURCES.map(resourceType => `patient/${resourceType}.read`);
const resourceScope = patientResourceScope.join(" ");
Expand Down Expand Up @@ -44,7 +44,8 @@ function getReferences(obj, references) {
}

async function requestResources(client, resourceType) {
let endpoint = (resourceType == 'Patient' ? 'Patient/' : `${resourceType}?patient=`) + client.getPatientId();
// let endpoint = (resourceType == 'Patient' ? 'Patient/' : `${resourceType}?patient=`) + client.getPatientId();
let endpoint = "https://fhir.inform.dev.cirg.uw.edu/fhir/Patient";
return client.request(endpoint, { flat: true }).then((result) => {
let resourcesToPass = [];
if (Array.isArray(result)) {
Expand Down Expand Up @@ -111,6 +112,14 @@ async function getResourcesWithReferences(depth=1) {
return allResources;
}

function endSession() {
let key = sessionStorage.getItem('SMART_KEY');
if (key) {
sessionStorage.removeItem(JSON.parse(key));
sessionStorage.removeItem('SMART_KEY');
}
}

// Utility function to validate a URL
function isValidUrl(url) {
try {
Expand Down

0 comments on commit f9b7858

Please sign in to comment.