forked from HL7-DaVinci/crd-request-generator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from mcode/dev
Dev
- Loading branch information
Showing
40 changed files
with
2,581 additions
and
990 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React, { memo } from 'react'; | ||
import useStyles from '../styles'; | ||
|
||
const EmptySection = () => { | ||
const classes = useStyles(); | ||
return ( | ||
<div className={classes.dashboardArea}> | ||
<h2 className={classes.elementHeader}>Not available</h2> | ||
</div> | ||
); | ||
}; | ||
|
||
export default memo(EmptySection); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React, { memo, useState, useEffect } from 'react'; | ||
import { Paper } from '@mui/material'; | ||
import DashboardElement from '../DashboardElement'; | ||
import FormControlLabel from '@mui/material/FormControlLabel'; | ||
import Checkbox from '@mui/material/Checkbox'; | ||
import useStyles from '../styles'; | ||
|
||
const FormsSection = props => { | ||
const classes = useStyles(); | ||
const [resources, setResources] = useState([]); | ||
const [message, setMessage] = useState('Loading...'); | ||
const [checked, setChecked] = useState(true); | ||
|
||
useEffect(() => { | ||
if (props.client.patient.id) { | ||
props.client.patient | ||
.request('QuestionnaireResponse', { pageLimit: 0, onPage: addResources }) | ||
.then(() => { | ||
setMessage( | ||
'No QuestionnaireResponses Found for user with patientId: ' + props.client.patient.id | ||
); | ||
}); | ||
} else { | ||
setMessage('Invalid patient: No patientId provided'); | ||
} | ||
}, [props.client.patient]); | ||
|
||
const handleChange = event => { | ||
setChecked(event.target.checked); | ||
}; | ||
|
||
const addResources = bundle => { | ||
if (bundle.entry) { | ||
bundle.entry.forEach(e => { | ||
const resource = e.resource; | ||
setResources(resources => [...resources, resource]); | ||
}); | ||
} | ||
}; | ||
|
||
const renderElements = () => { | ||
let resourcesToRender = []; | ||
if (checked) { | ||
resourcesToRender = resources.filter(e => { | ||
return e.status === 'in-progress'; | ||
}); | ||
} else { | ||
resourcesToRender = resources; | ||
} | ||
resourcesToRender.reverse(); | ||
return resourcesToRender; | ||
}; | ||
|
||
return ( | ||
<div className={classes.dashboardArea}> | ||
<h2 className={classes.elementHeader}>Available Forms</h2> | ||
<FormControlLabel | ||
style={{ float: 'right' }} | ||
control={<Checkbox checked={checked} onChange={handleChange} />} | ||
label="Only show in-progress forms" | ||
/> | ||
{resources.length > 0 ? ( | ||
renderElements().map(e => { | ||
return ( | ||
<DashboardElement key={e.id} status={e.status} resource={e} client={props.client} /> | ||
); | ||
}) | ||
) : ( | ||
<Paper className={classes.dashboardElement}>{message}</Paper> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default memo(FormsSection); |
Oops, something went wrong.