Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/RequestBox/RequestBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect, useState } from 'react';
import buildNewRxRequest from '../../util/buildScript.2017071.js';
import MuiAlert from '@mui/material/Alert';
import Snackbar from '@mui/material/Snackbar';
import { shortNameMap } from '../../util/data.js';
import { shortNameMap, ORDER_SIGN, ORDER_SELECT, PATIENT_VIEW } from '../../util/data.js';
import { getAge, createMedicationDispenseFromMedicationRequest } from '../../util/fhir.js';
import { retrieveLaunchContext, prepPrefetch } from '../../util/util.js';
import './request.css';
Expand Down Expand Up @@ -36,18 +36,18 @@ const RequestBox = props => {
const emptyField = <span className="empty-field">empty</span>;

const submitPatientView = () => {
submitInfo(prepPrefetch(prefetchedResources), null, patient, 'patient-view');
submitInfo(prepPrefetch(prefetchedResources), null, patient, PATIENT_VIEW);
};

const _submitOrderSelect = () => {
if (!_.isEmpty(request)) {
submitInfo(prepPrefetch(prefetchedResources), request, patient, 'order-select');
submitInfo(prepPrefetch(prefetchedResources), request, patient, ORDER_SELECT);
}
};

const submitOrderSign = request => {
if (!_.isEmpty(request)) {
submitInfo(prepPrefetch(prefetchedResources), request, patient, 'order-sign');
submitInfo(prepPrefetch(prefetchedResources), request, patient, ORDER_SIGN);
}
};

Expand Down Expand Up @@ -264,7 +264,7 @@ const RequestBox = props => {
const disableSendToCRD = isOrderNotSelected() || loading;
const disableSendRx = isOrderNotSelected() || loading;
const disableLaunchSmartOnFhir = isPatientNotSelected();
const orderSignRemsAdmin = getRemsAdminUrl(request, 'order-sign');
const orderSignRemsAdmin = getRemsAdminUrl(request, ORDER_SIGN);

return (
<>
Expand Down
12 changes: 6 additions & 6 deletions src/components/RequestDashboard/SettingsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import AddIcon from '@mui/icons-material/Add';
import env from 'env-var';
import FHIR from 'fhirclient';

import { headerDefinitions, medicationRequestToRemsAdmins } from '../../util/data';
import { headerDefinitions, medicationRequestToRemsAdmins, ORDER_SIGN, ORDER_SELECT, PATIENT_VIEW, ENCOUNTER_START } from '../../util/data';
import { actionTypes, initialState } from '../../containers/ContextProvider/reducer';
import { SettingsContext } from '../../containers/ContextProvider/SettingsProvider';

const CDS_HOOKS = ['order-sign', 'order-select', 'patient-view', 'encounter-start'];
const CDS_HOOKS = [ORDER_SIGN, ORDER_SELECT, PATIENT_VIEW, ENCOUNTER_START];

const SettingsSection = props => {
const [state, dispatch] = React.useContext(SettingsContext);
Expand Down Expand Up @@ -266,11 +266,11 @@ const SettingsSection = props => {
onChange={event => updateSetting(key, event.target.value)}
sx={{ width: '100%' }}
>
<MenuItem key='paitent-view' value='patient-view'>
patient-view
<MenuItem key={PATIENT_VIEW} value={PATIENT_VIEW}>
{PATIENT_VIEW}
</MenuItem>
<MenuItem key='encounter-start' value='encounter-start'>
encounter-start
<MenuItem key={ENCOUNTER_START} value={ENCOUNTER_START}>
{ENCOUNTER_START}
</MenuItem>
</Select>
</FormControl>
Expand Down
4 changes: 2 additions & 2 deletions src/containers/ContextProvider/reducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { headerDefinitions, medicationRequestToRemsAdmins } from '../../util/data';
import { headerDefinitions, medicationRequestToRemsAdmins, ORDER_SIGN } from '../../util/data';
import { v4 as uuidv4 } from 'uuid';

export const actionTypes = Object.freeze({
Expand Down Expand Up @@ -43,7 +43,7 @@ const getNewStateWithNewCdsHookSetting = (state, settingId) => {
newState.medicationRequestToRemsAdmins[uuidv4()] = {
rxnorm: 'Fill out Medication RxNorm Code',
display: 'Fill out Medication Display Name',
hook: 'order-sign',
hook: ORDER_SIGN,
remsAdmin: 'REMS Admin URL for CDS Hook'
};

Expand Down
12 changes: 9 additions & 3 deletions src/containers/RequestBuilder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import DisplayBox from '../components/DisplayBox/DisplayBox.jsx';
import '../index.css';
import RequestBox from '../components/RequestBox/RequestBox.jsx';
import buildRequest from '../util/buildRequest.js';
import { types } from '../util/data.js';
import { types, PATIENT_VIEW } from '../util/data.js';
import { createJwt } from '../util/auth.js';
import { getMedicationSpecificRemsAdminUrl, prepPrefetch } from '../util/util.js';

Expand Down Expand Up @@ -133,7 +133,6 @@ const RequestBuilder = props => {

uniqueUrls?.forEach(url => {
sendHook(prepPrefetch(state.prefetchedResources), null, globalState.patient, hook, url);
//TODO: still need to handle multiple sends and multiple cards coming back
});

}, [state.medicationRequests]);
Expand Down Expand Up @@ -206,7 +205,14 @@ const RequestBuilder = props => {
);
console.log(fhirResponse.message);
} else {
setState(prevState => ({ ...prevState, response: fhirResponse }));
if (response?.url?.includes(PATIENT_VIEW)) {
// copy the cards from the old response into the new
setState(prevState => ({
...prevState, response: { cards: [...(prevState.response.cards || []), ...fhirResponse.cards] }
}));
} else {
setState(prevState => ({ ...prevState, response: fhirResponse }));
}
}
setState(prevState => ({ ...prevState, loading: false }));
});
Expand Down
8 changes: 5 additions & 3 deletions src/util/buildRequest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ORDER_SIGN, ORDER_SELECT } from "./data";

export default function buildRequest(
request,
user,
Expand Down Expand Up @@ -43,7 +45,7 @@ export default function buildRequest(
r4json.extension = extension;
}

if (hook === 'order-select') {
if (hook === ORDER_SELECT) {
r4json.context.draftOrders = {
resourceType: 'Bundle',
entry: [
Expand All @@ -53,7 +55,7 @@ export default function buildRequest(
]
};
r4json.context.selections = [request.resourceType + '/' + request.id];
} else if (hook === 'order-sign') {
} else if (hook === ORDER_SIGN) {
r4json.context.draftOrders = {
resourceType: 'Bundle',
entry: [
Expand All @@ -62,7 +64,7 @@ export default function buildRequest(
}
]
};
//} else if (hook === "patient-view") {
//} else if ((hook === PATIENT_VIEW) || (hook === ENCOUNTER_START)) {
}

if (includePrefetch) {
Expand Down
43 changes: 26 additions & 17 deletions src/util/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,45 +83,50 @@ const headerDefinitions = {
}
};

const ORDER_SIGN = 'order-sign';
const ORDER_SELECT = 'order-select';
const PATIENT_VIEW = 'patient-view';
const ENCOUNTER_START = 'encounter-start';

const medicationRequestToRemsAdmins = Object.freeze([
{
rxnorm: 2183126,
display: 'Turalio 200 MG Oral Capsule',
hookEndpoints: [
{ hook: 'order-sign', remsAdmin: 'http://localhost:8090/cds-services/rems-order-sign' },
{ hook: 'order-select', remsAdmin: 'http://localhost:8090/cds-services/rems-order-select' },
{ hook: 'patient-view', remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' },
{ hook: 'encounter-start', remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' }
{ hook: ORDER_SIGN, remsAdmin: 'http://localhost:8090/cds-services/rems-order-sign' },
{ hook: ORDER_SELECT, remsAdmin: 'http://localhost:8090/cds-services/rems-order-select' },
{ hook: PATIENT_VIEW, remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' },
{ hook: ENCOUNTER_START, remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' }
]
},
{
rxnorm: 6064,
display: 'Isotretinoin 20 MG Oral Capsule',
hookEndpoints: [
{ hook: 'order-sign', remsAdmin: 'http://localhost:8090/cds-services/rems-order-sign' },
{ hook: 'order-select', remsAdmin: 'http://localhost:8090/cds-services/rems-order-select' },
{ hook: 'patient-view', remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' },
{ hook: 'encounter-start', remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' }
{ hook: ORDER_SIGN, remsAdmin: 'http://localhost:8090/cds-services/rems-order-sign' },
{ hook: ORDER_SELECT, remsAdmin: 'http://localhost:8090/cds-services/rems-order-select' },
{ hook: PATIENT_VIEW, remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' },
{ hook: ENCOUNTER_START, remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' }
]
},
{
rxnorm: 1237051,
display: 'TIRF 200 UG Oral Transmucosal Lozenge',
hookEndpoints: [
{ hook: 'order-sign', remsAdmin: 'http://localhost:8090/cds-services/rems-order-sign' },
{ hook: 'order-select', remsAdmin: 'http://localhost:8090/cds-services/rems-order-select' },
{ hook: 'patient-view', remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' },
{ hook: 'encounter-start', remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' }
{ hook: ORDER_SIGN, remsAdmin: 'http://localhost:8090/cds-services/rems-order-sign' },
{ hook: ORDER_SELECT, remsAdmin: 'http://localhost:8090/cds-services/rems-order-select' },
{ hook: PATIENT_VIEW, remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' },
{ hook: ENCOUNTER_START, remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' }
]
},
{
rxnorm: 1666386,
display: 'Addyi 100 MG Oral Tablet',
hookEndpoints: [
{ hook: 'order-sign', remsAdmin: 'http://localhost:8090/cds-services/rems-order-sign' },
{ hook: 'order-select', remsAdmin: 'http://localhost:8090/cds-services/rems-order-select' },
{ hook: 'patient-view', remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' },
{ hook: 'encounter-start', remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' }
{ hook: ORDER_SIGN, remsAdmin: 'http://localhost:8090/cds-services/rems-order-sign' },
{ hook: ORDER_SELECT, remsAdmin: 'http://localhost:8090/cds-services/rems-order-select' },
{ hook: PATIENT_VIEW, remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' },
{ hook: ENCOUNTER_START, remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' }
]
}
]);
Expand Down Expand Up @@ -258,5 +263,9 @@ export {
shortNameMap,
stateOptions,
types,
medicationRequestToRemsAdmins
medicationRequestToRemsAdmins,
ORDER_SIGN,
ORDER_SELECT,
PATIENT_VIEW,
ENCOUNTER_START
};
4 changes: 2 additions & 2 deletions src/util/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';

import { ORDER_SIGN, ORDER_SELECT, PATIENT_VIEW, ENCOUNTER_START } from './data';
/**
* Retrieves a SMART launch context from an endpoint to append as a "launch" query parameter to a SMART app launch URL (see SMART docs for more about launch context).
* This applies mainly if a SMART app link on a card is to be launched. The link needs a "launch" query param with some opaque value from the SMART server entity.
Expand Down Expand Up @@ -104,7 +104,7 @@ const getMedicationSpecificRemsAdminUrl = (request, globalState, hook) => {
return undefined;
}

if (!(hook === 'patient-view' || hook === 'order-sign' || hook === 'order-select' || hook === 'encounter-start')) {
if (!(hook === PATIENT_VIEW || hook === ORDER_SIGN || hook === ORDER_SELECT || hook === ENCOUNTER_START)) {
console.log(`ERROR: unknown hook type: ${hook}`);
return undefined;
}
Expand Down