From 4e332cc68f58668ea02fbb46374c8d6d1236c335 Mon Sep 17 00:00:00 2001 From: Ariel Virgulto Date: Wed, 17 Apr 2024 11:24:16 -0400 Subject: [PATCH 1/3] Setup toggle in settings for encounter start --- .env | 3 ++- .../RequestDashboard/SettingsSection.jsx | 23 ++++++++++++++++++- src/containers/RequestBuilder.jsx | 2 +- src/util/data.js | 17 ++++++++++---- src/util/util.js | 2 +- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/.env b/.env index 75e6c54..2b9c27f 100644 --- a/.env +++ b/.env @@ -24,5 +24,6 @@ VITE_RESPONSE_EXPIRATION_DAYS = 30 VITE_SERVER = http://localhost:8090 VITE_SMART_LAUNCH_URL = http://localhost:4040/ VITE_URL = http://localhost:3000 -VITE_URL_FILTER = http://localhost:3000/* VITE_USER = alice +VITE_HOOK_TO_SEND = patient-view +VITE_URL_FILTER = http://localhost:3000/* diff --git a/src/components/RequestDashboard/SettingsSection.jsx b/src/components/RequestDashboard/SettingsSection.jsx index 0c8b010..36e6b88 100644 --- a/src/components/RequestDashboard/SettingsSection.jsx +++ b/src/components/RequestDashboard/SettingsSection.jsx @@ -15,6 +15,8 @@ import { TableContainer, TableHead, TableRow, + ToggleButton, + ToggleButtonGroup, Tooltip, TextField } from '@mui/material'; @@ -28,7 +30,7 @@ import { headerDefinitions, medicationRequestToRemsAdmins } from '../../util/dat import { actionTypes, initialState } from '../../containers/ContextProvider/reducer'; import { SettingsContext } from '../../containers/ContextProvider/SettingsProvider'; -const CDS_HOOKS = ['order-sign', 'order-select', 'patient-view']; +const CDS_HOOKS = ['order-sign', 'order-select', 'patient-view', 'encounter-start']; const SettingsSection = props => { const [state, dispatch] = React.useContext(SettingsContext); @@ -251,6 +253,25 @@ const SettingsSection = props => { ); + case 'toggle': + return ( + + +

Hook to send when selecting a patient:

+ updateSetting(key, event.target.value)} + aria-label="hook" + > + patient-view + encounter-start + +
+
+ + ) default: return (
diff --git a/src/containers/RequestBuilder.jsx b/src/containers/RequestBuilder.jsx index ca53471..375bbc1 100644 --- a/src/containers/RequestBuilder.jsx +++ b/src/containers/RequestBuilder.jsx @@ -117,7 +117,7 @@ const RequestBuilder = props => { useEffect(() => { - const hook = 'patient-view'; + const hook = globalState.hookToSend; let remsAdminUrls = []; // get all the remsAdminUrl for each MedicationRequest diff --git a/src/util/data.js b/src/util/data.js index d308619..018b40a 100644 --- a/src/util/data.js +++ b/src/util/data.js @@ -75,6 +75,11 @@ const headerDefinitions = { display: 'REMS Admin Server', type: 'input', default: env.get('VITE_SERVER').asString() + }, + hookToSend: { + display: 'Send hook on patient select', + type: 'toggle', + default: env.get('VITE_HOOK_TO_SEND').asString() } }; @@ -85,7 +90,8 @@ const medicationRequestToRemsAdmins = Object.freeze([ 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: 'patient-view', remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' }, + { hook: 'encounter-start', remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' } ] }, { @@ -94,7 +100,8 @@ const medicationRequestToRemsAdmins = Object.freeze([ 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: 'patient-view', remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' }, + { hook: 'encounter-start', remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' } ] }, { @@ -103,7 +110,8 @@ const medicationRequestToRemsAdmins = Object.freeze([ 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: 'patient-view', remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' }, + { hook: 'encounter-start', remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' } ] }, { @@ -112,7 +120,8 @@ const medicationRequestToRemsAdmins = Object.freeze([ 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: 'patient-view', remsAdmin: 'http://localhost:8090/cds-services/rems-patient-view' }, + { hook: 'encounter-start', remsAdmin: 'http://localhost:8090/cds-services/rems-encounter-start' } ] } ]); diff --git a/src/util/util.js b/src/util/util.js index f494e61..663c039 100644 --- a/src/util/util.js +++ b/src/util/util.js @@ -104,7 +104,7 @@ const getMedicationSpecificRemsAdminUrl = (request, globalState, hook) => { return undefined; } - if (!(hook === 'patient-view' || hook === 'order-sign' || hook === 'order-select')) { + if (!(hook === 'patient-view' || hook === 'order-sign' || hook === 'order-select' || hook === 'encounter-start')) { console.log(`ERROR: unknown hook type: ${hook}`); return undefined; } From bd9fb2e5c3c661c703d5a7764dc54c0c3c9a257c Mon Sep 17 00:00:00 2001 From: Ariel Virgulto Date: Mon, 22 Apr 2024 21:59:04 -0400 Subject: [PATCH 2/3] Update to a dropdown --- .../RequestDashboard/SettingsSection.jsx | 42 +++++++++++-------- src/util/data.js | 2 +- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/components/RequestDashboard/SettingsSection.jsx b/src/components/RequestDashboard/SettingsSection.jsx index 36e6b88..8956ccb 100644 --- a/src/components/RequestDashboard/SettingsSection.jsx +++ b/src/components/RequestDashboard/SettingsSection.jsx @@ -1,11 +1,12 @@ -import React, { memo, useState, useEffect } from 'react'; +import React, { memo, useEffect } from 'react'; import { - Box, Button, Checkbox, FormControlLabel, + FormControl, Grid, IconButton, + InputLabel, Paper, Select, MenuItem, @@ -15,8 +16,6 @@ import { TableContainer, TableHead, TableRow, - ToggleButton, - ToggleButtonGroup, Tooltip, TextField } from '@mui/material'; @@ -253,22 +252,29 @@ const SettingsSection = props => { ); - case 'toggle': + case 'dropdown': return ( - -

Hook to send when selecting a patient:

- updateSetting(key, event.target.value)} - aria-label="hook" - > - patient-view - encounter-start - -
+ + + Hook to send when selecting a patient + + + +
) diff --git a/src/util/data.js b/src/util/data.js index 018b40a..708cd46 100644 --- a/src/util/data.js +++ b/src/util/data.js @@ -78,7 +78,7 @@ const headerDefinitions = { }, hookToSend: { display: 'Send hook on patient select', - type: 'toggle', + type: 'dropdown', default: env.get('VITE_HOOK_TO_SEND').asString() } }; From cf8ff6005b96d2f50b97c0ad3db7a7efd66b9a6f Mon Sep 17 00:00:00 2001 From: Ariel Virgulto Date: Tue, 23 Apr 2024 10:29:29 -0400 Subject: [PATCH 3/3] Fix label to be more visible --- src/components/RequestDashboard/SettingsSection.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/RequestDashboard/SettingsSection.jsx b/src/components/RequestDashboard/SettingsSection.jsx index 8956ccb..46058a4 100644 --- a/src/components/RequestDashboard/SettingsSection.jsx +++ b/src/components/RequestDashboard/SettingsSection.jsx @@ -262,6 +262,7 @@ const SettingsSection = props => { labelId="dropdown-label" id="dropdown" value={state[key]} + label="Hook to send when selecting a patient" onChange={event => updateSetting(key, event.target.value)} sx={{ width: '100%' }} >