From 27d43356e266bdd0c884b50db128ae82c7ea3cce Mon Sep 17 00:00:00 2001 From: Amy Chen Date: Mon, 16 Dec 2024 09:28:25 -0800 Subject: [PATCH 1/3] handle error when survey has not associated ELM lib --- src/components/Summary.js | 3 +- src/config/report_config.js | 2 + src/styles/components/_Summary.scss | 3 +- src/utils/executeELM.js | 72 ++++++++++++++++------------- 4 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/components/Summary.js b/src/components/Summary.js index 5e3c4784d..d04200525 100644 --- a/src/components/Summary.js +++ b/src/components/Summary.js @@ -13,6 +13,7 @@ import { getErrorMessageString, isEmptyArray, isReportEnabled, + isNumber } from "../helpers/utility"; import ChartIcon from "../icons/ChartIcon"; @@ -353,7 +354,7 @@ export default class Summary extends Component { ...formatterArguments ); } - return value + return value || isNumber(value) ? value : headerKey.default ? headerKey.default diff --git a/src/config/report_config.js b/src/config/report_config.js index 251f2ef8f..4409a1c89 100644 --- a/src/config/report_config.js +++ b/src/config/report_config.js @@ -60,6 +60,7 @@ const reportConfig = [ { id: "CIRG-PainTracker-GE", key: GE_DATA_KEY, + useDefaultELMLib: true }, ], //status: "inactive", @@ -380,6 +381,7 @@ const reportConfig = [ { id: "CIRG-PainTracker-TRT", key: TRT_DATA_KEY, + useDefaultELMLib: true }, ], icon: (props) => ( diff --git a/src/styles/components/_Summary.scss b/src/styles/components/_Summary.scss index 23d076d16..9f2be193c 100644 --- a/src/styles/components/_Summary.scss +++ b/src/styles/components/_Summary.scss @@ -403,9 +403,10 @@ height: 100%; width: 100%; display: flex; - align-items: center; + align-items: flex-start; justify-content: center; font-size: 1.1em; + line-height: 1.35; } } @media (min-width: 992px) { diff --git a/src/utils/executeELM.js b/src/utils/executeELM.js index 6bfc052c8..4516f68e3 100644 --- a/src/utils/executeELM.js +++ b/src/utils/executeELM.js @@ -152,33 +152,34 @@ async function executeELM(collector, oResourceTypes) { if (!evalResults[PATIENT_SUMMARY_KEY]) { evalResults[PATIENT_SUMMARY_KEY] = {}; } - Promise.allSettled([ - executeELMForReport(patientBundle), - ...elmLibs, - ]).then( - (results) => { - evalResults[PATIENT_SUMMARY_KEY]["ReportSummary"] = - results[0].status !== "rejected" ? results[0].value : null; - const evaluatedSurveyResults = executeELMForInstruments( - results.slice(1), - patientBundle - ); - evalResults[PATIENT_SUMMARY_KEY]["SurveySummary"] = - evaluatedSurveyResults; - //debug - console.log( - "final evaluated CQL results including surveys ", - evalResults - ); - resolve(evalResults); - }, - (e) => { - console.log(e); - reject( - "Error occurred executing report library logics. See console for detail" - ); - } - ); + Promise.allSettled([executeELMForReport(patientBundle), ...elmLibs]) + .then( + (results) => { + evalResults[PATIENT_SUMMARY_KEY]["ReportSummary"] = + results[0].status !== "rejected" ? results[0].value : null; + const evaluatedSurveyResults = executeELMForInstruments( + results.slice(1), + patientBundle + ); + evalResults[PATIENT_SUMMARY_KEY]["SurveySummary"] = + evaluatedSurveyResults; + //debug + console.log( + "final evaluated CQL results including surveys ", + evalResults + ); + resolve(evalResults); + }, + (e) => { + console.log(e); + reject( + "Error occurred executing report library logics. See console for detail" + ); + } + ) + .catch((e) => { + console.log("Error processing instrument ELM ", e); + }); }); }); resolve(finalResults); @@ -193,12 +194,15 @@ async function executeELMForReport(bundle) { console.log("Issue occurred loading ELM lib for reoirt", e); r4ReportCommonELM = null; }); - + if (!r4ReportCommonELM) return null; - let reportLib = new cql.Library(r4ReportCommonELM, new cql.Repository({ - FHIRHelpers: r4HelpersELM, - })); + let reportLib = new cql.Library( + r4ReportCommonELM, + new cql.Repository({ + FHIRHelpers: r4HelpersELM, + }) + ); const reportExecutor = new cql.Executor( reportLib, new cql.CodeService(valueSetDB) @@ -274,8 +278,11 @@ function getLibraryForInstruments() { return INSTRUMENT_LIST.map((item) => (async () => { let elmJson = null; + const libPrefix = item.useDefaultELMLib + ? "Default" + : item.key.toUpperCase(); elmJson = await import( - `../cql/r4/survey_resources/${item.key.toUpperCase()}_LogicLibrary.json` + `../cql/r4/survey_resources/${libPrefix}_LogicLibrary.json` ) .then((module) => module.default) .catch((e) => { @@ -287,6 +294,7 @@ function getLibraryForInstruments() { ); elmJson = null; }); + if (!elmJson) { elmJson = await import( `../cql/r4/survey_resources/Default_LogicLibrary.json` From 3e134299cccc61a143898d35d40f643428a67daa Mon Sep 17 00:00:00 2001 From: Amy Chen Date: Mon, 16 Dec 2024 09:32:18 -0800 Subject: [PATCH 2/3] fix try catch code --- src/utils/executeELM.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/executeELM.js b/src/utils/executeELM.js index 4516f68e3..a9d78c6c6 100644 --- a/src/utils/executeELM.js +++ b/src/utils/executeELM.js @@ -178,7 +178,8 @@ async function executeELM(collector, oResourceTypes) { } ) .catch((e) => { - console.log("Error processing instrument ELM ", e); + console.log("Error processing instrument ELM: ", e); + reject("rror processing instrument ELM. See console for details."); }); }); }); From 85f0617c05f3665d6c892ba31c5a90d080f0e141 Mon Sep 17 00:00:00 2001 From: Amy Chen Date: Mon, 16 Dec 2024 09:42:29 -0800 Subject: [PATCH 3/3] fix typo per feedback --- src/utils/executeELM.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/executeELM.js b/src/utils/executeELM.js index a9d78c6c6..1aacb6a1f 100644 --- a/src/utils/executeELM.js +++ b/src/utils/executeELM.js @@ -179,7 +179,7 @@ async function executeELM(collector, oResourceTypes) { ) .catch((e) => { console.log("Error processing instrument ELM: ", e); - reject("rror processing instrument ELM. See console for details."); + reject("error processing instrument ELM. See console for details."); }); }); });