Skip to content

Commit

Permalink
cerner; multi-server config; launch and patient/launch contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
Abigail Watson authored and Abigail Watson committed Jun 27, 2021
1 parent 2cc562c commit fef4f63
Show file tree
Hide file tree
Showing 410 changed files with 460,082 additions and 126 deletions.
4 changes: 4 additions & 0 deletions app/FhirClientContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ export const FhirClientContext = React.createContext({
client: null,
setClient: function(client) {
context.client = client;
},
patientId: null,
setPatientId: function(client) {
context.client = client;
}
});

Expand Down
27 changes: 0 additions & 27 deletions app/core/AppLoadingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,6 @@ function AppLoadingPage(props) {
logger.verbose('client.app.layout.AppLoadingPage');
}

// let searchParams = new URLSearchParams(useLocation().search);

// if(searchParams){
// console.log("Storing state received by Loading page into Session variable.", searchParams.state);

// searchParams.forEach(function(value, key){
// console.log(key + ': ' + value);
// });

// if(searchParams.get('iss')){
// Session.set('smartOnFhir_iss', searchParams.get('iss'));
// }
// if(searchParams.get('launch')){
// Session.set('smartOnFhir_launch', searchParams.get('launch'));
// }
// if(searchParams.get('code')){
// Session.set('smartOnFhir_code', searchParams.get('code'));
// }
// if(searchParams.get('scope')){
// Session.set('smartOnFhir_scope', searchParams.get('scope'));
// }

// if(searchParams.state){
// Session.set('smartOnFhir_state', searchParams.state);
// }
// }

//--------------------------------------------------------------------------------
// Props

Expand Down
28 changes: 19 additions & 9 deletions app/core/LaunchPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,45 @@ function LaunchPage(props) {
//--------------------------------------------------------------------------------
// Query Parameters

let searchParams = new URLSearchParams(useLocation().search);
let useLocationSearch = useLocation().search
let searchParams = new URLSearchParams(useLocationSearch);


//--------------------------------------------------------------------------------
// Component Life Cycle Functions

useEffect(function(){

let smartOnFhirConfig;
if(Array.isArray(get(Meteor, 'settings.public.smartOnFhir'))){
Meteor.settings.public.smartOnFhir.forEach(function(config){
if(useLocationSearch.includes(config.vendorKeyword) && (config.launchContext === "Provider")){
smartOnFhirConfig = config;
}
})
}

let smartConfig = {
clientId: get(Meteor, 'settings.public.smartOnFhir[0].client_id'),
scope: get(Meteor, 'settings.public.smartOnFhir[0].scope'),
redirectUri: get(Meteor, 'settings.public.smartOnFhir[0].redirect_uri') // ./fhir-quer
clientId: get(smartOnFhirConfig, 'client_id'),
scope: get(smartOnFhirConfig, 'scope'),
redirectUri: get(smartOnFhirConfig, 'redirect_uri') // ./fhir-quer
}

if(searchParams.get('iss')){
// we prefer using an ?iss parameter from the URL
// this is how we typically launch from the big EHR systems
smartConfig.iss = searchParams.get('iss')
//Session.set('smartOnFhir_iss', searchParams.get('iss'))
} else if (get(Meteor, 'settings.public.smartOnFhir[0].iss')){
} else if (get(smartOnFhirConfig, 'iss')){
// if we're testing how the launcher works, we can set the iss in the settings file
// this is marginally useful in blockchain and multi-tenant hosting environments
smartConfig.iss = get(Meteor, 'settings.public.smartOnFhir[0].iss');
//Session.set('smartOnFhir_iss', get(Meteor, 'settings.public.smartOnFhir[0].iss'))
smartConfig.iss = get(smartOnFhirConfig, 'iss');
//Session.set('smartOnFhir_iss', get(smartOnFhirConfig, 'iss'))
} else {
// otherwise, we resort to using a stand-alone app without launch context
// this is mostly used for HAPI test servers, not Cerner and Epic
smartConfig.fhirServiceUrl = get(Meteor, 'settings.public.smartOnFhir[0].fhirServiceUrl');
//Session.set('smartOnFhir_iss', get(Meteor, 'settings.public.smartOnFhir[0].fhirServiceUrl'))
smartConfig.fhirServiceUrl = get(smartOnFhirConfig, 'fhirServiceUrl');
//Session.set('smartOnFhir_iss', get(smartOnFhirConfig, 'settings.public.smartOnFhir[0].fhirServiceUrl'))
}

SMART.authorize(smartConfig);
Expand Down
29 changes: 0 additions & 29 deletions app/core/QrScannerPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,6 @@ if(Meteor.isClient){
Session.setDefault('adult_icu_bed_utilization', 0);
}

//==========================================================================================
// Dynamic Theme

import { HTTP } from 'meteor/http';

Meteor.startup(function(){

if(Meteor.isClient){
if(window.navigator){
window.navigator.geolocation.getCurrentPosition(function(position){
Session.set('myLatitude', get(position, 'coords.latitude'));
Session.set('myLongitude', get(position, 'coords.longitude'));

let icuCapacityUrl = "https://healthzones.symptomatic.us/icu-capacity-at-my-location?latitude=" + get(position, 'coords.latitude') + "&longitude=" + get(position, 'coords.longitude')
console.log('icuCapacityUrl', icuCapacityUrl);

HTTP.get(icuCapacityUrl, function(error, result){
if(error) console.log('error', error)
if(result) {
let parsedResults = JSON.parse(result.content);
console.log('QrScannerPage.parsedResults', parsedResults)

Session.set('adult_icu_bed_utilization', get(parsedResults, 'adult_icu_bed_utilization'))
}
})
})
}
}
})



Expand Down
2 changes: 2 additions & 0 deletions app/layout/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import AppLoadingPage from '../core/AppLoadingPage'
import PatientChart from '../patient/PatientChart'
import PatientQuickChart from '../patient/PatientQuickChart'
import LaunchPage from '../core/LaunchPage'
import SmartLauncher from '../layout/SmartLauncher'

import QrScannerPage from '../core/QrScannerPage';
import ConstructionZone from '../core/ConstructionZone';
Expand Down Expand Up @@ -588,6 +589,7 @@ export function App(props) {
ProjectPage

<Route name='ProjectPage' key='ProjectPage' path="/project-page" exact component={ ProjectPage } />
<Route name='SmartLauncher' key='SmartLauncher' path="/smart-launcher" exact component={ SmartLauncher } />
<Route name='patientChartRoute' key='patientChartPage' path="/patient-chart" exact component={ PatientChart } />
<Route name='patientIntakeRoute' key='patientIntakePage' path="/patient-intake" exact component={ PatientQuickChart } />
<Route name='quickChartRoute' key='quickChartPage' path="/patient-quickchart" exact component={ PatientQuickChart } />
Expand Down
104 changes: 55 additions & 49 deletions app/layout/FhirClientProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ import { Patients, Encounters, Procedures, Conditions, Immunizations, Immunizati



// Epic Provider R4 Launch Page
// http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) {

if(client){
Expand Down Expand Up @@ -72,12 +78,12 @@ function fetchPatientData(ehrLaunchCapabilities, client) {
if (code === "8480-6") {
bpMap.systolic.push({
x: new Date(observation.effectiveDateTime),
y: c.valueQuantity.value
y: get(c , 'valueQuantity.value')
});
} else if (code === "8462-4") {
bpMap.diastolic.push({
x: new Date(observation.effectiveDateTime),
y: c.valueQuantity.value
y: get(c , 'valueQuantity.value')
});
}
});
Expand Down Expand Up @@ -168,47 +174,47 @@ function fetchPatientData(ehrLaunchCapabilities, client) {
});
}

if(ehrLaunchCapabilities.MedicationOrder === true){
const medicationOrderQuery = new URLSearchParams();
medicationOrderQuery.set("patient", get(client, 'patient.id'));
console.log('MedicationOrder Query', medicationOrderQuery);

let medicationOrderUrl = 'MedicationOrder?' + medicationOrderQuery
console.log('medicationOrderUrl', medicationOrderUrl);

client.request(medicationOrderUrl, {
pageLimit: 0,
flat: true
}).then(medicationOrders => {
if(medicationOrders){
console.log('PatientAutoDashboard.medicationOrders', medicationOrders)
medicationOrders.forEach(procedure => {
MedicationOrders._collection.upsert({id: procedure.id}, {$set: procedure}, {validate: false, filter: false});
});
}
});
}

if(ehrLaunchCapabilities.MedicationRequest === true){
const medicationRequestQuery = new URLSearchParams();
medicationRequestQuery.set("patient", get(client, 'patient.id'));
console.log('MedicationRequest Query', medicationRequestQuery);

let medicationRequestUrl = 'MedicationRequest?' + medicationRequestQuery
console.log('medicationRequestUrl', medicationRequestUrl);

client.request(medicationRequestUrl, {
pageLimit: 0,
flat: true
}).then(medicationRequests => {
if(medicationRequests){
console.log('PatientAutoDashboard.medicationRequests', medicationRequests)
medicationRequests.forEach(procedure => {
MedicationRequests._collection.upsert({id: procedure.id}, {$set: procedure}, {validate: false, filter: false});
});
}
});
}
// if(ehrLaunchCapabilities.MedicationOrder === true){
// const medicationOrderQuery = new URLSearchParams();
// medicationOrderQuery.set("patient", get(client, 'patient.id'));
// console.log('MedicationOrder Query', medicationOrderQuery);

// let medicationOrderUrl = 'MedicationOrder?' + medicationOrderQuery
// console.log('medicationOrderUrl', medicationOrderUrl);

// client.request(medicationOrderUrl, {
// pageLimit: 0,
// flat: true
// }).then(medicationOrders => {
// if(medicationOrders){
// console.log('PatientAutoDashboard.medicationOrders', medicationOrders)
// medicationOrders.forEach(procedure => {
// MedicationOrders._collection.upsert({id: procedure.id}, {$set: procedure}, {validate: false, filter: false});
// });
// }
// });
// }

// if(ehrLaunchCapabilities.MedicationRequest === true){
// const medicationRequestQuery = new URLSearchParams();
// medicationRequestQuery.set("patient", get(client, 'patient.id'));
// console.log('MedicationRequest Query', medicationRequestQuery);

// let medicationRequestUrl = 'MedicationRequest?' + medicationRequestQuery
// console.log('medicationRequestUrl', medicationRequestUrl);

// client.request(medicationRequestUrl, {
// pageLimit: 0,
// flat: true
// }).then(medicationRequests => {
// if(medicationRequests){
// console.log('PatientAutoDashboard.medicationRequests', medicationRequests)
// medicationRequests.forEach(procedure => {
// MedicationRequests._collection.upsert({id: procedure.id}, {$set: procedure}, {validate: false, filter: false});
// });
// }
// });
// }

} catch (error) {
alert("We had an error fetching data.", error)
Expand All @@ -219,12 +225,12 @@ function fetchPatientData(ehrLaunchCapabilities, client) {

export class FhirClientProvider extends React.Component {
constructor(props) {
super(props);
this.state = {
client: null,
error: null
};
this.setClient = client => this.setState({ client });
super(props);
this.state = {
client: null,
error: null
};
this.setClient = client => this.setState({ client });
}

render() {
Expand Down
Loading

0 comments on commit fef4f63

Please sign in to comment.