Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clinician portal for proms/sparc #1792

Draft
wants to merge 16 commits into
base: CARDS-2514
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 99 additions & 78 deletions modules/data-entry/src/main/frontend/src/questionnaire/Form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import SessionExpiryWarningModal from "./SessionExpiryWarningModal.jsx";
*/
function Form (props) {
let { classes, id, contentOffset } = props;
let { mode, className, disableHeader, disableButton, doneButtonStyle, doneIcon, doneLabel, onDone, questionnaireAddons, paginationProps } = props;
let { mode, className, actionSwitches, disableHeader, disableButton, doneButtonStyle, doneIcon, doneLabel, onDone, questionnaireAddons, paginationProps } = props;
// Record if the form was already checked out before opening it, which may indicate that another user is editing, or it is being edited in a different tab
let [ wasCheckedOut, setWasCheckedOut ] = useState(false);
// This holds the full form JSON, once it is received from the server
Expand Down Expand Up @@ -435,87 +435,108 @@ function Form (props) {
);
}

let isActionEnabled = (action) => (!!!actionSwitches || !!(actionSwitches[action]?.(data)));

let isDropdnEnabled = () => (
(isEdit && isActionEnabled("subject"))
|| (!isEdit && isActionEnabled("text"))
|| isActionEnabled("delete")
);

let dropdownList = (
<List>
{ isEdit ?
<ListItem className={classes.actionsMenuItem}>
<Button onClick={() => {setSelectorDialogOpen(true); setActionsMenu(null)}}>
Change subject
</Button>
</ListItem>
: <>
<ListItem className={classes.actionsMenuItem}>
<PrintButton
variant="text"
size="medium"
resourcePath={formURL}
resourceData={data}
breadcrumb={getTextHierarchy(data?.subject, true)}
date={DateTime.fromISO(data['jcr:created']).toLocaleString(DateTime.DATE_MED)}
onClose={() => { setActionsMenu(null); }}
/>
</ListItem>
<ListItem className={classes.actionsMenuItem}>
<Button
size="medium"
onClick={() => {
window.open(formURL + ".txt");
setActionsMenu(null);
}}>
Export as text
</Button>
</ListItem>
</> }
<ListItem className={classes.actionsMenuItem}>
<DeleteButton
entryPath={data ? data["@path"] : formURL}
entryName={getEntityIdentifier(data)}
entryType="Form"
onComplete={onDelete}
variant="text"
size="medium"
/>
</ListItem>
</List>
<List>
{ isEdit ?
( isActionEnabled("subject") &&
<ListItem className={classes.actionsMenuItem}>
<Button onClick={() => {setSelectorDialogOpen(true); setActionsMenu(null)}}>
Change subject
</Button>
</ListItem>
)
:
( isActionEnabled("text") &&
<ListItem className={classes.actionsMenuItem}>
<Button
size="medium"
onClick={() => {
window.open(formURL + ".txt");
setActionsMenu(null);
}}>
Export as text
</Button>
</ListItem>
)
}
{ isActionEnabled("delete") &&
<ListItem className={classes.actionsMenuItem}>
<DeleteButton
entryPath={data ? data["@path"] : formURL}
entryName={getEntityIdentifier(data)}
entryType="Form"
onComplete={onDelete}
variant="text"
size="medium"
/>
</ListItem>
}
</List>
)

let formMenu = (
<div className={classes.actionsMenu}>
{isEdit ?
<Tooltip title="Save and view" onClick={onClose}>
<IconButton color="primary" size="large">
<DoneIcon />
</IconButton>
</Tooltip>
:
<Tooltip title="Edit">
<IconButton color="primary" onClick={onEdit} size="large">
<EditIcon />
</IconButton>
</Tooltip>
}
<Tooltip title="More actions" onClick={(event) => {setActionsMenu(event.currentTarget)}}>
<IconButton size="large">
<MoreIcon fontSize="small" />
</IconButton>
</Tooltip>
{ !actionsMenu && <div style={{display: "none"}}>{ dropdownList }</div> }
<Popover
open={Boolean(actionsMenu)}
anchorEl={actionsMenu}
onClose={() => {setActionsMenu(null)}}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'right',
}}
>
{ dropdownList }
</Popover>
</div>
<div className={classes.actionsMenu}>
{ isEdit ?
( isActionEnabled("save") &&
<Tooltip title="Save and view" onClick={onClose}>
<IconButton color="primary" size="large">
<DoneIcon />
</IconButton>
</Tooltip>
)
:
( isActionEnabled("edit") &&
<Tooltip title="Edit">
<IconButton color="primary" onClick={onEdit} size="large">
<EditIcon />
</IconButton>
</Tooltip>
)
}
{ !isEdit && isActionEnabled("print") &&
<PrintButton
variant="icon"
size="large"
resourcePath={formURL}
resourceData={data}
breadcrumb={getTextHierarchy(data?.subject, true)}
date={DateTime.fromISO(data['jcr:created']).toLocaleString(DateTime.DATE_MED)}
/>
}
{ isDropdnEnabled() &&
<>
<Tooltip title="More actions" onClick={(event) => {setActionsMenu(event.currentTarget)}}>
<IconButton size="large">
<MoreIcon fontSize="small" />
</IconButton>
</Tooltip>
{ !actionsMenu && <div style={{display: "none"}}>{ dropdownList }</div> }
<Popover
open={Boolean(actionsMenu)}
anchorEl={actionsMenu}
onClose={() => {setActionsMenu(null)}}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'right',
}}
>
{ dropdownList }
</Popover>
</>
}
</div>
)

let getTimestampString = (timestamp) => {
Expand Down
1 change: 1 addition & 0 deletions modules/patient-portal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
SLING-INF/content/libs/cards/PatientHomepage/;path:=/libs/cards/PatientHomepage/;overwrite:=true,
SLING-INF/content/libs/cards/resources/assetDependencies.json;path:=/libs/cards/resources/assetDependencies;overwriteProperties:=true,
SLING-INF/content/apps/cards/ExtensionPoints/;path:=/apps/cards/ExtensionPoints/;overwriteProperties:=true;uninstall:=true,
SLING-INF/content/apps/cards/config/CopyAnswers;path:=/apps/cards/config/CopyAnswers;overwriteProperties:=true;uninstall:=true,
SLING-INF/content/Extensions/;path:=/Extensions/;overwriteProperties:=true;uninstall:=true,
SLING-INF/content/Extensions/AdminDashboard/;path:=/Extensions/AdminDashboard/;overwriteProperties:=true;uninstall:=true,
SLING-INF/content/Extensions/Views/;path:=/Extensions/Views/;overwriteProperties:=true;uninstall:=true,
Expand Down
2 changes: 2 additions & 0 deletions modules/patient-portal/src/main/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@
"@mui/icons-material": "5.11.0",
"@mui/material": "5.11.3",
"@mui/styles": "5.11.2",
"@mui/x-data-grid": "7.11.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "5.2.0",
"prop-types": "15.8.1",
"history": "4.10.1",
"luxon": "3.2.1",
"react-copy-to-clipboard": "5.1.0",
"semantic-ui-css": "2.5.0",
"semantic-ui-react": "2.1.4"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
import React from "react";

import DefaultForm from "../questionnaire/Form.jsx";

function Form(props) {

const actionSwitches = {
edit: data => (!["SUBMITTED", "LOCKED"].some(f => data.statusFlags.includes(f))),
save: () => true,
print: () => true,
lock: () => true,
}

return (
<DefaultForm id={props.match.params.formId.replace(/\..*/, '')} key={props.match.params.formId} actionSwitches={actionSwitches} />
);
}

export default Form;
Loading