Skip to content

Commit

Permalink
CARDS-2558 / CARDS-2559: Visit page view for clinicians
Browse files Browse the repository at this point in the history
Separate clinician forms and patient surveys on visit page
  • Loading branch information
marta- authored and sdumitriu committed Aug 1, 2024
1 parent 8ae04e0 commit ea391f6
Showing 1 changed file with 40 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ import {
AlertTitle,
Avatar,
CircularProgress,
Divider,
Grid,
List,
ListItem,
ListItemAvatar,
ListItemButton,
ListItemText,
Typography,
} from "@mui/material";

import DoneIcon from '@mui/icons-material/Done';
Expand Down Expand Up @@ -163,7 +165,7 @@ function Visit(props) {
.forEach(([key, value]) => {
data[value.questionnaire['@name']] = {
'title': value.questionnaire?.title || key,
'alias': key,
'targetUserType': value.targetUserType,
'@path': value.questionnaire?.['@path'],
}
});
Expand All @@ -183,7 +185,7 @@ function Visit(props) {
let data = {};
questionnaireSetIds.forEach(q => {
if (visit[questionnaireSet?.[q]?.title]?.[0]?.['jcr:primaryType'] == "cards:Form") {
data[q] = visit[questionnaireSet?.[q]?.title][0];
data[q] = {...visit[questionnaireSet?.[q]?.title][0], targetUserType: questionnaireSet?.[q]?.targetUserType};
ids.push(q);
}
});
Expand Down Expand Up @@ -279,11 +281,44 @@ function Visit(props) {
.join(", ")
);

// ----------------------------------------------------------------------------------------------------------------_
// Prepare the display of the forms for this visit

const clinicQIds = questionnaireIds.filter(q => surveyData[q].targetUserType == "clinician");
const patientQIds = questionnaireIds.filter(q => surveyData[q].targetUserType != "clinician");

const listForms = (qIds, title, withAction) => (qIds.length > 0 &&
<>
<Divider><Typography variant="h6">{title}</Typography></Divider>
<List>
{ qIds.map((q, i) => (
<ListItem
key={q}
disablePadding
secondaryAction={withAction && !isFormLocked(q) && <EditButton entryPath={surveyData?.[q]?.["@path"]}/>}
>
<ListItemButton onClick={() => history.push(`/content.html${surveyData?.[q]?.["@path"]}`)}>
<ListItemAvatar>
{ isFormLocked(q) ? lockedIndicator : (
isFormComplete(q) ? doneIndicator : (
isFormSubmitted(q) ? incompleteIndicator : surveyIndicator
)
)
}
</ListItemAvatar>
<ListItemText primary={questionnaires[q]?.title} secondary={displayFlags(q)} />
</ListItemButton>
</ListItem>
))}
</List>
</>
);

// -----------------------------------------------------------------------------------------------------------------
// Render the visit:
// * Resource header (sticky to the top) with a simplified menu
// * Visit information
// * List of firms for this visit, as specified by the associated QuestionnaireSet
// * List of forms for this visit, as specified by the associated QuestionnaireSet

return (
<Grid container {...FORM_ENTRY_CONTAINER_PROPS}>
Expand All @@ -307,27 +342,8 @@ function Visit(props) {
/>
<Grid item>{ displayVisitInfo() }</Grid>
<Grid item>
<List>
{ (questionnaireIds || []).map((q, i) => (
<ListItem
key={q}
disablePadding
secondaryAction={!isFormSubmitted(q) && !isFormLocked(q) && <EditButton entryPath={surveyData?.[q]?.["@path"]}/>}
>
<ListItemButton onClick={() => history.push(`/content.html${surveyData?.[q]?.["@path"]}`)}>
<ListItemAvatar>
{ isFormLocked(q) ? lockedIndicator : (
isFormComplete(q) ? doneIndicator : (
isFormSubmitted(q) ? incompleteIndicator : surveyIndicator
)
)
}
</ListItemAvatar>
<ListItemText primary={questionnaires[q]?.title} secondary={displayFlags(q)} />
</ListItemButton>
</ListItem>
))}
</List>
{ listForms(clinicQIds, "Clinical examination", true) }
{ listForms(patientQIds, "Patient surveys") }
</Grid>
</Grid>
);
Expand Down

0 comments on commit ea391f6

Please sign in to comment.