Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Amy Chen authored and Amy Chen committed Jul 29, 2024
1 parent 4b24e3c commit ec0e2a8
Show file tree
Hide file tree
Showing 24 changed files with 6,201 additions and 1,969 deletions.
7,644 changes: 5,877 additions & 1,767 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
]
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/preset-env": "^7.20.2",
"@rescripts/cli": "0.0.16",
"@rescripts/utilities": "0.0.8",
Expand Down
3 changes: 2 additions & 1 deletion src/components/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Stack from "@mui/material/Stack";
import {
getAppHeight,
getSectionsToShow,
isEmptyArray,
} from "../util/util";
import ErrorComponent from "./ErrorComponent";
import ProgressIndicator from "./ProgressIndicator";
Expand All @@ -25,7 +26,7 @@ export default function Dashboard() {
const sectionsToShow = getSectionsToShow();

const renderSections = () => {
if (!sectionsToShow || !sectionsToShow.length)
if (isEmptyArray(sectionsToShow))
return <Alert severity="warning">No section to show.</Alert>;
return sectionsToShow.map((section) => {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/QuestionnaireInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export default function QuestionnaireInfo(props) {
const { questionnaireJson } = props;
const theme = useTheme();
const qo = new Questionnaire(questionnaireJson);
const questionnaireTitle = qo.displayName();
const introText = qo.introText();
const questionnaireTitle = qo.displayName;
const introText = qo.introText;
const [open, setOpen] = useState(false);

const handleDialogOpen = () => {
Expand Down
32 changes: 5 additions & 27 deletions src/components/Responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import OutlinedIcon from "@mui/icons-material/WysiwygOutlined";
import Score from "./Score";
import {
getLocaleDateStringFromDate,
isEmptyArray,
isNumber
} from "../util/util";
import Response from "../models/Response";
Expand All @@ -48,9 +49,9 @@ export default function Responses(props) {
theme.palette.lightest.main
? theme.palette.lightest.main
: "#FFF";
const questionnaireTitle = (new Questionnaire(questionnaireJson)).displayName();
const questionnaireTitle = (new Questionnaire(questionnaireJson)).displayName;
const getFormattedData = (data) => {
if (!data || !data.length) return null;
if (isEmptyArray(data)) return null;
let copyData = JSON.parse(JSON.stringify(data));
const maxResponsesLength = Math.max(
...copyData.map((d) => (d.responses ? d.responses.length : 0))
Expand Down Expand Up @@ -241,8 +242,8 @@ export default function Responses(props) {

const renderPrintOnlyResponseTable = () => {
if (!hasData()) return null;
const arrDates = dates.filter((item, index) => index < 2);
const arrData = data.filter((item, index) => index < 2);
const arrDates = dates.filter((item, index) => index === 0);
const arrData = data.filter((item, index) => index === 0);
// this will render the current and the previous response(s) for print
return (
<Box className="print-only" sx={{ marginTop: theme.spacing(2) }}>
Expand Down Expand Up @@ -342,36 +343,13 @@ export default function Responses(props) {
}}
columns={columns}
data={getData()}
// icons={{
// ViewColumn: forwardRef((props, ref) => {
// if (!hasData() || (hasData() && data.length <= 3)) return null;
// return (
// <Button
// variant="outlined"
// color="secondary"
// startIcon={<ListAltIcon />}
// {...props}
// ref={ref}
// className="print-hidden"
// >
// +/- Columns
// </Button>
// );
// }),
// }}
options={{
search: false,
showTitle: false,
padding: "dense",
toolbar: false,
// columnsButton: dates.length > 3,
// filtering: true,
paging: false,
thirdSortClick: false,
// filterCellStyle: {
// padding: theme.spacing(1),
// borderRadius: 0,
// },
headerStyle: {
backgroundColor: headerBgColor,
position: "sticky",
Expand Down
7 changes: 4 additions & 3 deletions src/components/SectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import ListItem from "@mui/material/ListItem";
import ListItemButton from "@mui/material/ListItemButton";
import ListItemIcon from "@mui/material/ListItemIcon";
import ListItemText from "@mui/material/ListItemText";
import { scrollToElement } from "../util/util";
import { isEmptyArray, scrollToElement } from "../util/util";

export default function SectionList(props) {
const theme = useTheme();
const { list, onClickEvent, expanded } = props;
const renderList = list && list.length ? list : null;
if (!renderList || !renderList.length) return false;
const renderList = !isEmptyArray(list) ? list : null;
if (isEmptyArray(renderList)) return false;
return (
<List className="sections-list" sx={{ marginTop: theme.spacing(3) }}>
{renderList.map((section) => (
Expand Down Expand Up @@ -46,6 +46,7 @@ export default function SectionList(props) {
sx: {
fontWeight: 500,
whiteSpace: "normal",
textWrap: "balance"
},
}}
/>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import Error from "./ErrorComponent";
import QuestionnaireInfo from "./QuestionnaireInfo";
import { hasData } from "../util/util";
import { hasData, isEmptyArray } from "../util/util";
import { QUESTIONNAIRE_ANCHOR_ID_PREFIX } from "../consts/consts";
import Responses from "./Responses";
import Chart from "./Chart";
Expand Down Expand Up @@ -54,7 +54,7 @@ export default function Summary(props) {
};

const getAnchorElementId = () => QUESTIONNAIRE_ANCHOR_ID_PREFIX;
const hasResponses = () => summary.responses && summary.responses.length > 0;
const hasResponses = () => !isEmptyArray(summary.responses);

const renderLoader = () =>
loading && (
Expand Down Expand Up @@ -83,7 +83,7 @@ export default function Summary(props) {
let questionnaireTitle = questionnaireId;
if (data) {
const qo = new Questionnaire(data.questionnaire, questionnaireId);
questionnaireTitle = qo.displayName();
questionnaireTitle = qo.displayName;
}
return (
<Typography
Expand Down
8 changes: 2 additions & 6 deletions src/components/sections/MedicalHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ export default function MedicalHistory(props) {
const goodData = Condition.getGoodData(data);
return goodData
.map((item, index) => {
item.id = item.id + "_" + index;
const o = new Condition(item);
item.condition = o.displayText || "--";
item.onsetDateTime = o.onsetDateTimeDisplayText;
item.recordedDate = o.recordedDateTimeDisplayText;
item.status = o.status ? String(o.status).toLowerCase() : "--";
return item;
return o.toObj();
})
.sort((a, b) => {
return (
Expand Down Expand Up @@ -58,6 +53,7 @@ export default function MedicalHistory(props) {
{
title: "Status",
field: "status",
emptyText: "--",
render: (rowData) =>
rowData.status === "confirmed" ? (
<span className="text-success">{rowData.status}</span>
Expand Down
29 changes: 17 additions & 12 deletions src/components/sections/Observations.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ export default function Observations(props) {
return goodData
.map((item, index) => {
const o = new Observation(item);
item.id = item.id + "_" + index;
item.category = o.category || "--";
item.text = o.displayText || "--";
item.date = o.dateText;
item.provider = o.providerText || "--";
item.value = o.valueText || "--";
item.status = o.status || "--"
return item;
// let newItem = Object.assign({}, item);
// newItem.id = o.id + "_" + index;
// newItem.category = o.category || "--";
// newItem.displayText = o.displayText || "--";
// newItem.dateText = o.dateText;
// newItem.providerText = o.providerText || "--";
// newItem.valueText = o.valueText || "--";
// newItem.status = o.status || "--"
return o.toObj();
})
.sort((a, b) => {
return new Date(b.issued).getTime() - new Date(a.issued).getTime();
Expand All @@ -44,23 +45,27 @@ export default function Observations(props) {
},
{
title: "Type",
field: "text",
field: "displayText",
emptyValue: "--"
},
{
title: "Result",
field: "value",
field: "valueText",
emptyValue: "--"
},
{
title: "Issued Date",
field: "date",
field: "dateText",
},
{
title: "Category",
field: "category",
emptyValue: "--"
},
{
title: "Status",
field: "status",
emptyValue: "--",
render: (rowData) =>
rowData.status === "final" ? (
<span className="text-success">{rowData.status}</span>
Expand All @@ -70,7 +75,7 @@ export default function Observations(props) {
}
// {
// title: "Provider",
// field: "provider",
// field: "providerText",
// },
];
const renderPrintView = (data) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/sections/ScoringSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export default function ScoringSummary(props) {
? summaryData[id].questionnaire
: null;
const qo = new Questionnaire(matchedQuestionnaire, id);
const displayName = qo.displayName();
return qo.shortName() ?? (displayName??id);
const displayName = qo.displayName;
return qo.shortName ?? (displayName??id);
};
const hasList = () =>
summaryData &&
Expand Down
53 changes: 32 additions & 21 deletions src/config/questionnaire_config.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,53 @@
const qConfig = {
"adl-iadl": {
const qConfig = [
{
shortTitle: "Functional Impairments (ADL/IADLs)",
customCQL: true,
keys: ["CIRG-ADL-IADL", "ADL-IADL"],
interventionLibId: "ADL-IADL"
},
behav5: {
{
shortTitle: "BEHAV+5",
customCQL: true,
keys: ["CIRG-BEHAV5"],
interventionLibId: "BEHAV5"
},
"c-idas": {
{
shortTitle: "Cornell Scale of Depression",
customCQL: true,
keys: ["CIRG-C-IDAS"],
interventionLibId: "C-IDAS"
},
"cp-ecog": {
{
shortTitle: "ECOG-12 (for Care Partner)",
customCQL: true,
keys: ["CIRG-ECOG12"],
interventionLibId: "CP-ECOG"
},
ecog12: {
{
shortTitle: "ECOG-12",
customCQL: true,
keys: ["CIRG-ECOG12"],
interventionLibId: "ECOG12"
},
gad7: {
{
shortTitle: "Anxiety (GAD-7)",
customCQL: true,
keys: ["CIRG-GAD7", "GAD7"],
interventionLibId: "GAD7"
},
gds: {
{
shortTitle: "Geriatric Depression Scale",
customCQL: true,
keys: ["CIRG-GDS"],
interventionLibId: "GDS"
},
minicog: {
{
shortTitle: "MINI COG",
customCQL: true,
keys: ["CIRG-MINICOG"],
interventionLibId: "MINICOG"
},
phq9: {
{
shortTitle: "Depression (PHQ-9)",
customCQL: true,
keys: ["phq9", "CIRG-PHQ9"],
interventionLibId: "PHQ9"
},
slums: {
{
customCQL: true,
keys: ["CIRG-SLUMS"],
interventionLibId: "SLUMS"
},
};
];
export default qConfig;
11 changes: 4 additions & 7 deletions src/context/QuestionnaireListProvider.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext, useEffect, useState } from "react";
import Stack from "@mui/material/Stack";
import CircularProgress from "@mui/material/CircularProgress";
import { getEnvQuestionnaireList, getEnv } from "../util/util";
import { getEnvQuestionnaireList, getEnv, isEmptyArray } from "../util/util";
import { QuestionnaireListContext } from "./QuestionnaireListContext";
import { FhirClientContext } from "../context/FhirClientContext";

Expand All @@ -27,7 +27,7 @@ export default function QuestionnaireListProvider({ children }) {
return;
}
if (loadComplete) return;
if (questionnaireList && questionnaireList.length) {
if (!isEmptyArray(questionnaireList)) {
console.log(
"questionnaire list to load from environment variable ",
questionnaireList
Expand All @@ -43,10 +43,7 @@ export default function QuestionnaireListProvider({ children }) {
)
.then((results) => {
const matchedResults =
results &&
results.entry &&
Array.isArray(results.entry) &&
results.entry.length
results && !isEmptyArray(results.entry)
? results.entry.filter(
(item) =>
item.resource &&
Expand All @@ -58,7 +55,7 @@ export default function QuestionnaireListProvider({ children }) {
"matched results for questionnaire from QuestionnaireResponse ",
matchedResults
);
if (!matchedResults || !matchedResults.length) {
if (isEmptyArray(matchedResults)) {
handleErrorCallback("No questionnaire list set");
return;
}
Expand Down
5 changes: 1 addition & 4 deletions src/cql/InterventionLogicLibrary.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"context" : "Patient",
"accessLevel" : "Public",
"expression" : {
"name" : "MatchedReponsesByQuestionnaire",
"name" : "MatchedReponsesByQuestionnaireId",
"libraryName" : "LogicHelpers",
"type" : "FunctionRef",
"operand" : [ {
Expand All @@ -152,9 +152,6 @@
}, {
"name" : "QuestionnaireID",
"type" : "ParameterRef"
}, {
"name" : "QuestionnaireName",
"type" : "ParameterRef"
} ]
}
}, {
Expand Down
Loading

0 comments on commit ec0e2a8

Please sign in to comment.