Skip to content

Commit 4e95146

Browse files
authored
Merge pull request #106 from mcode/dev
Dev
2 parents c237342 + bb1b6b3 commit 4e95146

40 files changed

+2581
-990
lines changed

src/components/App.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
import { ThemeProvider } from '@mui/styles';
2-
import React from 'react';
2+
import React, { useEffect } from 'react';
33
import { BrowserRouter, HashRouter, Route, Routes } from 'react-router-dom';
44
import Gateway from '../containers/Gateway/Gateway';
55
import Index from '../containers/Index';
66
import Launch from '../containers/Launch';
77
import PatientPortal from '../containers/PatientPortal';
88
import RegisterPage from '../containers/register/RegisterPage';
99
import theme from '../containers/styles/theme';
10+
import { SettingsContext } from '../containers/ContextProvider/SettingsProvider';
11+
import { actionTypes } from '../containers/ContextProvider/reducer';
12+
1013
const isGhPages = process.env.REACT_APP_GH_PAGES === 'true';
1114
const Router = isGhPages ? HashRouter : BrowserRouter;
1215
const redirect = isGhPages ? '/request-generator/#/index' : '/index';
1316
const App = () => {
17+
const [state, dispatch] = React.useContext(SettingsContext);
18+
useEffect(() => {
19+
dispatch({
20+
type: actionTypes.updateSetting,
21+
settingId: 'redirect',
22+
value: redirect
23+
});
24+
}, []);
1425
return (
1526
<Router>
1627
<Routes>

src/components/Auth/Login.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const Login = props => {
1111
const [username, _setUsername] = useState('');
1212
const [password, _setPassword] = useState('');
1313
const handleClose = () => setMessage(null);
14+
document.title = 'EHR | Patient Portal';
1415

1516
const onSubmit = useCallback(() => {
1617
if (username && password) {

src/components/Dashboard/Dashboard.jsx

Lines changed: 34 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import React, { memo, useState, useEffect } from 'react';
22
import useStyles from './styles';
3-
import DashboardElement from './DashboardElement';
4-
import FormControlLabel from '@mui/material/FormControlLabel';
5-
import Checkbox from '@mui/material/Checkbox';
63
import Box from '@mui/material/Box';
74
import Drawer from '@mui/material/Drawer';
85
import CssBaseline from '@mui/material/CssBaseline';
96
import Toolbar from '@mui/material/Toolbar';
107
import List from '@mui/material/List';
118
import Divider from '@mui/material/Divider';
129
import AssignmentIcon from '@mui/icons-material/Assignment';
10+
import ListAltIcon from '@mui/icons-material/ListAlt';
1311
import MedicationIcon from '@mui/icons-material/Medication';
1412
import BiotechIcon from '@mui/icons-material/Biotech';
1513
import LogoutIcon from '@mui/icons-material/Logout';
@@ -21,34 +19,28 @@ import NotificationsIcon from '@mui/icons-material/Notifications';
2119
import AlarmIcon from '@mui/icons-material/Alarm';
2220
import SettingsIcon from '@mui/icons-material/Settings';
2321
import MedicalInformationIcon from '@mui/icons-material/MedicalInformation';
24-
import { Paper } from '@mui/material';
22+
import FormsSection from './ListSelections/FormsSection';
23+
import EmptySection from './ListSelections/EmptySection';
24+
import PatientTaskSection from './ListSelections/PatientTaskSection';
2525

2626
const Dashboard = props => {
2727
const classes = useStyles();
28-
const [resources, setResources] = useState([]);
29-
const [message, setMessage] = useState('Loading...');
30-
const [checked, setChecked] = useState(true);
31-
const drawerWidth = '340px';
32-
const handleChange = event => {
33-
setChecked(event.target.checked);
34-
};
28+
const [selectedIndex, setSelectedIndex] = useState(3);
3529

36-
const addResources = bundle => {
37-
if (bundle.entry) {
38-
bundle.entry.forEach(e => {
39-
const resource = e.resource;
40-
setResources(resources => [...resources, resource]);
41-
});
42-
}
30+
const handleListItemClick = (event, index) => {
31+
setSelectedIndex(index);
4332
};
33+
34+
const drawerWidth = '340px';
35+
4436
const createIcons = () => {
4537
const icons = [];
4638
const style = { fontSize: '40px' };
4739
const itemStyle = { height: '80px' };
48-
const qStyle = { height: '80px', backgroundColor: '#f5f5fa' };
4940
icons.push(['Notifications', <NotificationsIcon sx={style} />, itemStyle]);
5041
icons.push(['Appointments', <AlarmIcon sx={style} />, itemStyle]);
51-
icons.push(['Questionnaire Forms', <AssignmentIcon sx={style} />, qStyle]);
42+
icons.push(['Tasks', <AssignmentIcon sx={style} />, itemStyle]);
43+
icons.push(['Questionnaire Forms', <ListAltIcon sx={style} />, itemStyle]);
5244
icons.push(['Health Data', <MedicalInformationIcon sx={style} />, itemStyle]);
5345
icons.push(['Medications', <MedicationIcon sx={style} />, itemStyle]);
5446
icons.push(['Tests and Results', <BiotechIcon sx={style} />, itemStyle]);
@@ -57,32 +49,25 @@ const Dashboard = props => {
5749

5850
return icons;
5951
};
52+
6053
useEffect(() => {
61-
if (props.client.patient.id) {
62-
props.client.patient
63-
.request('QuestionnaireResponse', { pageLimit: 0, onPage: addResources })
64-
.then(() => {
65-
setMessage(
66-
'No QuestionnaireResponses Found for user with patientId: ' + props.client.patient.id
67-
);
68-
});
69-
} else {
70-
setMessage('Invalid patient: No patientId provided');
54+
if (selectedIndex === 8) {
55+
// logout - set client to null to display login page
56+
props.logout();
7157
}
72-
}, [props.client.patient]);
58+
}, [selectedIndex]);
7359

74-
const renderElements = () => {
75-
let resourcesToRender = [];
76-
if (checked) {
77-
resourcesToRender = resources.filter(e => {
78-
return e.status === 'in-progress';
79-
});
80-
} else {
81-
resourcesToRender = resources;
60+
const renderBody = () => {
61+
switch (selectedIndex) {
62+
case 2:
63+
return <PatientTaskSection client={props.client} />;
64+
case 3:
65+
return <FormsSection client={props.client} />;
66+
default:
67+
return <EmptySection />;
8268
}
83-
resourcesToRender.reverse();
84-
return resourcesToRender;
8569
};
70+
8671
return (
8772
<div>
8873
<Box sx={{ display: 'flex' }}>
@@ -102,8 +87,13 @@ const Dashboard = props => {
10287
<List>
10388
{createIcons().map((option, index) => (
10489
<div key={`icon-${index}`}>
105-
<ListItem key={option[0]} style={option[2]} disablePadding>
106-
<ListItemButton>
90+
<ListItem
91+
key={option[0]}
92+
style={option[2]}
93+
selected={selectedIndex === index}
94+
disablePadding
95+
>
96+
<ListItemButton onClick={event => handleListItemClick(event, index)}>
10797
<ListItemIcon>{option[1]}</ListItemIcon>
10898
<ListItemText
10999
primaryTypographyProps={{ fontSize: '18px' }}
@@ -119,28 +109,7 @@ const Dashboard = props => {
119109
</Drawer>
120110
<Box component="main" sx={{ flexGrow: 1, p: 3 }}>
121111
<Toolbar />
122-
<div className={classes.dashboardArea}>
123-
<h2 className={classes.elementHeader}>Available Forms</h2>
124-
<FormControlLabel
125-
style={{ float: 'right' }}
126-
control={<Checkbox checked={checked} onChange={handleChange} />}
127-
label="Only show in-progress forms"
128-
/>
129-
{resources.length > 0 ? (
130-
renderElements().map(e => {
131-
return (
132-
<DashboardElement
133-
key={e.id}
134-
status={e.status}
135-
resource={e}
136-
client={props.client}
137-
/>
138-
);
139-
})
140-
) : (
141-
<Paper className={classes.dashboardElement}>{message}</Paper>
142-
)}
143-
</div>
112+
{renderBody()}
144113
</Box>
145114
</Box>
146115
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React, { memo } from 'react';
2+
import useStyles from '../styles';
3+
4+
const EmptySection = () => {
5+
const classes = useStyles();
6+
return (
7+
<div className={classes.dashboardArea}>
8+
<h2 className={classes.elementHeader}>Not available</h2>
9+
</div>
10+
);
11+
};
12+
13+
export default memo(EmptySection);
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import React, { memo, useState, useEffect } from 'react';
2+
import { Paper } from '@mui/material';
3+
import DashboardElement from '../DashboardElement';
4+
import FormControlLabel from '@mui/material/FormControlLabel';
5+
import Checkbox from '@mui/material/Checkbox';
6+
import useStyles from '../styles';
7+
8+
const FormsSection = props => {
9+
const classes = useStyles();
10+
const [resources, setResources] = useState([]);
11+
const [message, setMessage] = useState('Loading...');
12+
const [checked, setChecked] = useState(true);
13+
14+
useEffect(() => {
15+
if (props.client.patient.id) {
16+
props.client.patient
17+
.request('QuestionnaireResponse', { pageLimit: 0, onPage: addResources })
18+
.then(() => {
19+
setMessage(
20+
'No QuestionnaireResponses Found for user with patientId: ' + props.client.patient.id
21+
);
22+
});
23+
} else {
24+
setMessage('Invalid patient: No patientId provided');
25+
}
26+
}, [props.client.patient]);
27+
28+
const handleChange = event => {
29+
setChecked(event.target.checked);
30+
};
31+
32+
const addResources = bundle => {
33+
if (bundle.entry) {
34+
bundle.entry.forEach(e => {
35+
const resource = e.resource;
36+
setResources(resources => [...resources, resource]);
37+
});
38+
}
39+
};
40+
41+
const renderElements = () => {
42+
let resourcesToRender = [];
43+
if (checked) {
44+
resourcesToRender = resources.filter(e => {
45+
return e.status === 'in-progress';
46+
});
47+
} else {
48+
resourcesToRender = resources;
49+
}
50+
resourcesToRender.reverse();
51+
return resourcesToRender;
52+
};
53+
54+
return (
55+
<div className={classes.dashboardArea}>
56+
<h2 className={classes.elementHeader}>Available Forms</h2>
57+
<FormControlLabel
58+
style={{ float: 'right' }}
59+
control={<Checkbox checked={checked} onChange={handleChange} />}
60+
label="Only show in-progress forms"
61+
/>
62+
{resources.length > 0 ? (
63+
renderElements().map(e => {
64+
return (
65+
<DashboardElement key={e.id} status={e.status} resource={e} client={props.client} />
66+
);
67+
})
68+
) : (
69+
<Paper className={classes.dashboardElement}>{message}</Paper>
70+
)}
71+
</div>
72+
);
73+
};
74+
75+
export default memo(FormsSection);

0 commit comments

Comments
 (0)