Skip to content

Commit bd688dd

Browse files
plarocque4KeeyanGhoreshiAriel Virgultosmalho01
authored
723 - Build workflow for back-office staff (#138)
* add ui for backoffice * Some updated UI to match design of others * Back office staff workflow updates * fix styling --------- Co-authored-by: KeeyanGhoreshi <[email protected]> Co-authored-by: Ariel Virgulto <[email protected]> Co-authored-by: Sahil Malhotra <[email protected]>
1 parent ffd1f7b commit bd688dd

File tree

26 files changed

+822
-161
lines changed

26 files changed

+822
-161
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ VITE_AUTH = http://localhost:8180
66
VITE_CDS_SERVICE = http://localhost:8090/etasu/reset
77
VITE_CLIENT = app-login
88
VITE_CLIENT_SCOPES = launch offline_access openid profile user/Patient.read patient/Patient.read user/Practitioner.read
9+
VITE_USE_DEFAULT_USER = false
910
VITE_DEFAULT_USER = pra1234
1011
VITE_EHR_BASE = http://localhost:8080/test-ehr/r4
1112
VITE_EHR_SERVER = http://localhost:8080/test-ehr/r4

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Following are a list of modifiable paths:
116116
| VITE_CDS_SERVICE | `http://localhost:8090/cds-services` | The base URL of the CDS Service. This will typically be the REMS Admin. |
117117
| VITE_CLIENT | `app-login` | The default client to use for the SMART launch. Can be modified directly when launching the app. |
118118
| VITE_CLIENT_SCOPES | `launch offline_access openid profile user/Patient.read patient/Patient.read user/Practitioner.read` | The default scopes to use for the SMART launch. Can be modified directly when launching the app. |
119+
| VITE_USE_DEFAULT_USER | `false` | When true, override the logged in user with the default user. |
119120
| VITE_DEFAULT_USER | `pra1234` | The default user to log in as when SMART launching. It should be the FHIR id of a practitioner resource. |
120121
| VITE_EHR_BASE | `http://localhost:8080/test-ehr/r4` | The default base url for the EHR. Can be modified directly when launching the app. |
121122
| VITE_EHR_SERVER | `http://localhost:8080/test-ehr/r4` | The default base url for the EHR FHIR Server. Generally, this should be the same as the EHR_BASE. |

src/components/App.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { ThemeProvider } from '@mui/styles';
1+
import { ThemeProvider } from '@mui/material';
2+
23
import React, { useEffect } from 'react';
34
import { BrowserRouter, HashRouter, Route, Routes } from 'react-router-dom';
45
import Gateway from '../containers/Gateway/Gateway';
@@ -26,8 +27,10 @@ const App = () => {
2627
<Router>
2728
<Routes>
2829
<Route path="/launch" element={<Launch redirect={redirect} />} />
29-
<Route path="/index" element={<Index />} />
30+
<Route path="/index" element={<ThemeProvider theme={theme}><Index/></ThemeProvider>} />
3031
<Route path="/register" element={<RegisterPage />} />
32+
{/* forcibly enter backoffice workflow */}
33+
<Route path="/index/backoffice" element={<ThemeProvider theme={theme}><Index backoffice={true}/></ThemeProvider> } />
3134
<Route
3235
path="/patient-portal"
3336
element={

src/components/Auth/Login.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const Login = props => {
2222
params.append('client_id', env.get('VITE_CLIENT').asString());
2323
axios
2424
.post(
25+
// this change breaks the patient portal login!
2526
`${env.get('VITE_AUTH').asString()}/realms/${env
2627
.get('VITE_REALM')
2728
.asString()}/protocol/openid-connect/token`,

src/components/Dashboard/Dashboard.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const Dashboard = props => {
102102
}}
103103
>
104104
<Toolbar />
105-
<Box sx={{ overflow: 'auto', marginTop: '31px' }}>
105+
<Box sx={{ overflow: 'auto', marginTop: '51px' }}>
106106
<List>
107107
{createIcons().map((option, index) => (
108108
<div key={`icon-${index}`}>

src/components/RequestBox/PatientSearchBar/PatientSearchBar.jsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { Autocomplete, Box, TextField, IconButton } from '@mui/material';
1+
import { Autocomplete, Box, TextField } from '@mui/material';
2+
import { Grid, Button } from '@mui/material';
3+
import PeopleIcon from '@mui/icons-material/People';
4+
25
import { useEffect, useState } from 'react';
36
import { PrefetchTemplate } from '../../../PrefetchTemplate';
47
import { defaultValues } from '../../../util/data';
@@ -32,9 +35,16 @@ const PatientSearchBar = props => {
3235
return filteredListOfPatients.length;
3336
}
3437

38+
const showAllPatients = () => {
39+
props.callback('patient', {});
40+
props.callback('expanded', false);
41+
};
42+
3543
function patientSearchBar() {
3644
return (
3745
<Box className="search-box-container">
46+
<Grid container>
47+
<Grid item xs={9}>
3848
<span className="search-header">
3949
<p>Filter patient list</p>
4050
<Autocomplete
@@ -52,6 +62,13 @@ const PatientSearchBar = props => {
5262
records
5363
</p>
5464
</span>
65+
</Grid>
66+
<Grid item xs={3}>
67+
<Button variant="contained" startIcon={<PeopleIcon />} onClick={() => { showAllPatients(); }} style={{padding:'10px','paddingLeft':'20px', 'paddingRight':'20px'}}>
68+
Select all Patients
69+
</Button>
70+
</Grid>
71+
</Grid>
5572
{displayFilteredPatientList(input, listOfPatients[0])}
5673
</Box>
5774
);
@@ -82,7 +99,8 @@ const PatientSearchBar = props => {
8299
clearCallback={props.clearCallback}
83100
options={options}
84101
responseExpirationDays={props.responseExpirationDays}
85-
defaultUser={props.defaultUser}
102+
user={props.user}
103+
showButtons={props.showButtons}
86104
/>
87105
</span>
88106
);

src/components/RequestBox/RequestBox.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const RequestBox = props => {
3838
code,
3939
codeSystem,
4040
display,
41-
defaultUser,
41+
user,
4242
smartAppUrl,
4343
client,
4444
pimsUrl,
@@ -183,9 +183,9 @@ const RequestBox = props => {
183183
let userId = prefetchedResources?.practitioner?.id;
184184
if (!userId) {
185185
console.log(
186-
'Practitioner not populated from prefetch, using default from config: ' + defaultUser
186+
'Practitioner not populated from prefetch, using user: ' + user
187187
);
188-
userId = defaultUser;
188+
userId = user;
189189
}
190190

191191
let link = {

src/components/RequestDashboard/Home.jsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ import { Button, Grid, Tooltip } from '@mui/material';
33
import PersonIcon from '@mui/icons-material/Person';
44
import AssignmentIcon from '@mui/icons-material/Assignment';
55
import SettingsIcon from '@mui/icons-material/Settings';
6+
import AccountBoxIcon from '@mui/icons-material/AccountBox';
7+
import MedicalServicesIcon from '@mui/icons-material/MedicalServices';
68

79
import useStyles from './styles';
810
import PatientSection from './PatientSection';
911
import SettingsSection from './SettingsSection';
1012
import TasksSection from './TasksSection';
1113

14+
import { logout } from '../../util/auth';
15+
1216
const Home = props => {
1317
const classes = useStyles();
18+
const { client, token } = props;
1419
const patientButton = 'Select a Patient';
1520
const taskButton = 'View Tasks';
1621
const settingsButton = 'Settings';
@@ -58,20 +63,38 @@ const Home = props => {
5863
gridClass = `${classes.mainDiv} ${classes.tabDivView}`;
5964
}
6065
return (
66+
<div>
6167
<Grid className={gridClass} item container justifyContent={'center'} alignItems={'center'}>
6268
{section ? '' : <Grid item xs={3}></Grid>} {/* spacer */}
6369
{renderMainButton(patientButton, <PersonIcon className={classes.mainIcon} />)}
6470
{renderMainButton(taskButton, <AssignmentIcon className={classes.mainIcon} />)}
6571
{renderMainButton(settingsButton, <SettingsIcon className={classes.mainIcon} />)}
6672
{section ? (
6773
<Grid className={classes.spacer} item xs={0}>
68-
<div></div>
74+
<span className={classes.titleIcon}>
75+
<MedicalServicesIcon sx={{ fontSize: 48, verticalAlign: 'middle' }} />&nbsp;&nbsp;<strong>EHR</strong> Request Generator
76+
</span>
6977
</Grid>
7078
) : (
7179
<Grid item xs={3}></Grid>
7280
)}
7381
{/* spacer */}
82+
{/** */}
83+
{section ? (
84+
<Grid className={classes.spacer} item xs={4}>
85+
<span className={classes.loginIcon}>
86+
<AccountBoxIcon sx={{ fontSize: 48, verticalAlign: 'middle' }} /> {token.name}
87+
<Button variant="outlined" className={classes.whiteButton} onClick={logout}>
88+
Logout
89+
</Button>
90+
</span>
91+
</Grid>
92+
) : (
93+
<Grid item xs={3}></Grid>
94+
)}
95+
{/**/}
7496
</Grid>
97+
</div>
7598
);
7699
};
77100

@@ -85,10 +108,10 @@ const Home = props => {
85108
return (
86109
<div className={classes.mainSectionView}>
87110
<div className={patientRenderClass}>
88-
<PatientSection client={props.client} />
111+
<PatientSection client={props.client} userId={token.userId} />
89112
</div>
90113
<div className={taskRenderClass}>
91-
<TasksSection client={props.client} />
114+
<TasksSection client={props.client} userName={token.name} userId={token.userId} />
92115
</div>
93116
<div className={settingsRenderClass}>
94117
<SettingsSection client={props.client} />

src/components/RequestDashboard/PatientSection.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const PatientSection = props => {
88
return (
99
<div>
1010
{state.startup ? (
11-
<RequestBuilder globalState={state} dispatch={dispatch} client={props.client} />
11+
<RequestBuilder globalState={state} dispatch={dispatch} client={props.client} userId={props.userId} />
1212
) : (
1313
<>Loading...</>
1414
)}

src/components/RequestDashboard/SettingsSection.jsx

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { SettingsContext } from '../../containers/ContextProvider/SettingsProvid
3939
const ENDPOINT = [ORDER_SIGN, ORDER_SELECT, PATIENT_VIEW, ENCOUNTER_START, REMS_ETASU];
4040

4141
const SettingsSection = props => {
42-
const [state, dispatch] = React.useContext(SettingsContext);
42+
const [state, dispatch, updateSetting, readSettings, saveSettings] = React.useContext(SettingsContext);
4343

4444
const fieldHeaders = Object.keys(headerDefinitions)
4545
.map(key => ({ ...headerDefinitions[key], key }))
@@ -51,35 +51,9 @@ const SettingsSection = props => {
5151
);
5252

5353
useEffect(() => {
54-
JSON.parse(localStorage.getItem('reqgenSettings') || '[]').forEach(([key, value]) => {
55-
try {
56-
updateSetting(key, value);
57-
} catch {
58-
if (!key) {
59-
console.log('Could not load setting:' + key);
60-
}
61-
}
62-
});
63-
64-
// indicate to the rest of the app that the settings have been loaded
65-
dispatch({
66-
type: actionTypes.flagStartup
67-
});
54+
readSettings();
6855
}, []);
6956

70-
const updateSetting = (key, value) => {
71-
dispatch({
72-
type: actionTypes.updateSetting,
73-
settingId: key,
74-
value: value
75-
});
76-
};
77-
78-
const saveSettings = () => {
79-
const headers = Object.keys(state).map(key => [key, state[key]]);
80-
localStorage.setItem('reqgenSettings', JSON.stringify(headers));
81-
};
82-
8357
const resetSettings = () => {
8458
dispatch({ type: actionTypes.resetSettings });
8559
};
@@ -201,6 +175,7 @@ const SettingsSection = props => {
201175

202176
let firstCheckbox = true;
203177
let showBreak = true;
178+
204179
return (
205180
<Grid container spacing={2} sx={{ padding: '20px' }}>
206181
<Grid container item xs={12} direction="row" spacing={2}>
@@ -209,6 +184,7 @@ const SettingsSection = props => {
209184
case 'input':
210185
return (
211186
<Grid key={key} item xs={6}>
187+
{ ( (state['useDefaultUser'] && key === 'defaultUser') || key != 'defaultUser' ) ? (
212188
<div>
213189
<TextField
214190
label={display}
@@ -218,6 +194,7 @@ const SettingsSection = props => {
218194
sx={{ width: '100%' }}
219195
/>
220196
</div>
197+
) : ('') }
221198
</Grid>
222199
);
223200
case 'check':

0 commit comments

Comments
 (0)