Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/uwcirg/patient-summary into…
Browse files Browse the repository at this point in the history
… feature/updates-for-epic-2
  • Loading branch information
Amy Chen authored and Amy Chen committed Jul 30, 2024
2 parents 9f0a2e3 + 703b07e commit 957e408
Show file tree
Hide file tree
Showing 29 changed files with 75 additions and 106 deletions.
6 changes: 2 additions & 4 deletions src/components/Summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ export default function Summary(props) {
);
const renderTitle = () => {
let questionnaireTitle = questionnaireId;
if (data) {
const qo = new Questionnaire(data.questionnaire, questionnaireId);
questionnaireTitle = qo.displayName;
}
const qo = new Questionnaire(data?.questionnaire, questionnaireId);
questionnaireTitle = qo.displayName;
return (
<Typography
variant="h6"
Expand Down
2 changes: 1 addition & 1 deletion src/components/sections/MedicalHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function MedicalHistory(props) {
field: "status",
emptyText: "--",
render: (rowData) =>
rowData.status === "confirmed" ? (
String(rowData.status).toLowerCase() === "confirmed" ? (
<span className="text-success">{rowData.status}</span>
) : (
<span className="text-error">{rowData.status}</span>
Expand Down
3 changes: 1 addition & 2 deletions src/components/sections/ScoringSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ export default function ScoringSummary(props) {
? summaryData[id].questionnaire
: null;
const qo = new Questionnaire(matchedQuestionnaire, id);
const displayName = qo.displayName;
return qo.shortName ?? (displayName??id);
return qo.shortName ?? qo.displayName;
};
const hasList = () =>
summaryData &&
Expand Down
1 change: 1 addition & 0 deletions src/config/chart_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const CHART_CONFIG = {
//specific graph config for each questionnaire here
minicog: {
id: "minicog",
keys: ["CIRG-MINICOG", "MINICOG"],
title: "Scores by Date",
type: "linechart",
// applicable only to line graph
Expand Down
53 changes: 0 additions & 53 deletions src/config/questionnaire_config.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
43 changes: 28 additions & 15 deletions src/cql/InterventionLogic_Common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1166,22 +1166,35 @@
"then" : {
"type" : "As",
"operand" : {
"type" : "ToString",
"operand" : {
"strict" : false,
"type" : "As",
"operand" : {
"path" : "value",
"type" : "Property",
"source" : {
"name" : "value",
"type" : "QueryLetRef"
"type" : "If",
"condition" : {
"type" : "Equal",
"operand" : [ {
"asType" : "{urn:hl7-org:elm-types:r1}Boolean",
"type" : "As",
"operand" : {
"path" : "value",
"type" : "Property",
"source" : {
"name" : "value",
"type" : "QueryLetRef"
}
}
},
"asTypeSpecifier" : {
"name" : "{urn:hl7-org:elm-types:r1}Boolean",
"type" : "NamedTypeSpecifier"
}
}, {
"valueType" : "{urn:hl7-org:elm-types:r1}Boolean",
"value" : "true",
"type" : "Literal"
} ]
},
"then" : {
"valueType" : "{urn:hl7-org:elm-types:r1}String",
"value" : "true",
"type" : "Literal"
},
"else" : {
"valueType" : "{urn:hl7-org:elm-types:r1}String",
"value" : "false",
"type" : "Literal"
}
},
"asTypeSpecifier" : {
Expand Down
26 changes: 17 additions & 9 deletions src/hooks/useFetchResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,18 @@ export default function useFetchResources() {
patientBundle,
"Questionnaire"
);
console.log("patient Bundle ", patientBundle);
console.log("questionnaireResources ", questionnaireResources);
console.log(
`questionnaireResources for ${questionnaireId}`,
questionnaireResources
);
const returnResult = questionnaireResources
? questionnaireResources.filter((resource) => {
? questionnaireResources.find((resource) => {
if (!exactMatch) {
const arrMatches = [String(resource.name).toLowerCase()];
const toMatch = String(questionnaireId).toLowerCase();
const arrMatches = [
String(resource.name).toLowerCase(),
String(resource.id).toLowerCase(),
];
return (
String(resource.id).toLowerCase() === toMatch ||
arrMatches.find((key) => key.includes(toMatch))
Expand All @@ -136,9 +141,9 @@ export default function useFetchResources() {
return resource.id === questionnaireId;
})
: null;
if (returnResult && returnResult.length) {
sessionStorage.setItem(storageKey, JSON.stringify(returnResult[0]));
return returnResult[0];
if (returnResult) {
sessionStorage.setItem(storageKey, JSON.stringify(returnResult));
return returnResult;
}
return null;
};
Expand All @@ -150,7 +155,7 @@ export default function useFetchResources() {
initialzieCqlWorker(cqlWorker);
const questionnaireObject = new Questionnaire(questionnaireJson);
const interventionLibId = questionnaireObject.interventionLibId;
const chartConfig = getChartConfig(interventionLibId);
const chartConfig = getChartConfig(questionnaireObject.id);
/* get CQL expressions */
const [elmJson, valueSetJson] = await getInterventionLogicLib(
interventionLibId
Expand Down Expand Up @@ -204,7 +209,10 @@ export default function useFetchResources() {
const scoringData = !isEmptyArray(cqlData)
? cqlData.filter((item) => {
return (
item && item.responses && isNumber(item.score) && item.date
item &&
!isEmptyArray(item.responses) &&
isNumber(item.score) &&
item.date
);
})
: null;
Expand Down
23 changes: 7 additions & 16 deletions src/models/Questionnaire.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import questionnaireConfig from "../config/questionnaire_config";
import { getDisplayQTitle, isEmptyArray } from "../util/util";
class Questionnaire {
constructor(dataObj = null, key) {
Expand All @@ -12,19 +11,19 @@ class Questionnaire {
return this.data.name;
}
get shortName() {
if (!this.key) return "";
if (!this.key) return this.id;
const key = getDisplayQTitle(this.key).toUpperCase();
if (questionnaireConfig[key] && questionnaireConfig[key].shortTitle) {
return questionnaireConfig[key].shortTitle;
}
return String(key).toUpperCase();
if (key) return String(key).toUpperCase();
return this.key;
}
get displayName() {
if (!this.data) return this.shortName();
const { id, title, name } = this.data;
if (title) return title;
if (name) return name;
return `Questionnaire ${getDisplayQTitle(id)}`;
return `Questionnaire ${
id ? getDisplayQTitle(id) : String(this.key).toUpperCase()
}`;
}
get introText() {
if (!this.data) return "";
Expand Down Expand Up @@ -53,15 +52,7 @@ class Questionnaire {
return "";
}
get interventionLibId() {
const match = questionnaireConfig.find((o) => {
return o.keys.find(
(key) =>
String(this.data?.id).toLowerCase() === key ||
String(this.data?.name).toLowerCase().includes(key)
//String(this.data?.name).toLowerCase().includes(key)
);
});
return match ? match.interventionLibId : "";
return this.id;
}
}
export default Questionnaire;
24 changes: 18 additions & 6 deletions src/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export function getCorrectedISODate(dateString) {
}

export async function getInterventionLogicLib(interventionId) {
let fileName = "InterventionLogicLibrary.json";
const DEFAULT_FILENAME = "InterventionLogicLibrary.json";
let fileName = DEFAULT_FILENAME;
if (interventionId) {
// load questionnaire specific CQL
fileName = `${interventionId.toUpperCase()}_InterventionLogicLibrary.json`;
Expand All @@ -33,7 +34,10 @@ export async function getInterventionLogicLib(interventionId) {
if (interventionId && elmJson)
sessionStorage.setItem(`lib_${fileName}`, JSON.stringify(elmJson));
} catch (e) {
throw new Error("Error loading Cql ELM library " + e);
elmJson = await import(`../cql/${DEFAULT_FILENAME}`).then(
(module) => module.default
);
console.log("Error loading Cql ELM library " + e);
}
}
return [elmJson, valueSetJson];
Expand All @@ -52,10 +56,18 @@ export function isValidDate(date) {
);
}

export function getChartConfig(questionnaireKey) {
if (!questionnaireKey) return ChartConfig["default"];
const qChartConfig = ChartConfig[questionnaireKey.toLowerCase()] || {};
return { ...ChartConfig["default"], ...qChartConfig };
export function getChartConfig(questionnaireId) {
const qChartConfig = ChartConfig[questionnaireId.toLowerCase()];
if (qChartConfig) return { ...ChartConfig["default"], ...qChartConfig };
const matchItems = Object.values(ChartConfig);
const matchConfig = matchItems.find((item) => {
if (!item.keys || isEmptyArray(item.keys)) return false;
const arrMatches = item.keys.map((key) => key.toLowerCase());
console.log("arr matches ", arrMatches);
return arrMatches.indexOf(questionnaireId.toLowerCase()) !== -1;
});
if (matchConfig) return { ...ChartConfig["default"], ...matchConfig };
return ChartConfig["default"];
}

export function getEnvQuestionnaireList() {
Expand Down

0 comments on commit 957e408

Please sign in to comment.