Skip to content

Commit

Permalink
handle error when survey has not associated ELM lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Amy Chen authored and Amy Chen committed Dec 16, 2024
1 parent 5360d12 commit 27d4335
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 34 deletions.
3 changes: 2 additions & 1 deletion src/components/Summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getErrorMessageString,
isEmptyArray,
isReportEnabled,
isNumber
} from "../helpers/utility";

import ChartIcon from "../icons/ChartIcon";
Expand Down Expand Up @@ -353,7 +354,7 @@ export default class Summary extends Component {
...formatterArguments
);
}
return value
return value || isNumber(value)
? value
: headerKey.default
? headerKey.default
Expand Down
2 changes: 2 additions & 0 deletions src/config/report_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const reportConfig = [
{
id: "CIRG-PainTracker-GE",
key: GE_DATA_KEY,
useDefaultELMLib: true
},
],
//status: "inactive",
Expand Down Expand Up @@ -380,6 +381,7 @@ const reportConfig = [
{
id: "CIRG-PainTracker-TRT",
key: TRT_DATA_KEY,
useDefaultELMLib: true
},
],
icon: (props) => (
Expand Down
3 changes: 2 additions & 1 deletion src/styles/components/_Summary.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
72 changes: 40 additions & 32 deletions src/utils/executeELM.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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) => {
Expand All @@ -287,6 +294,7 @@ function getLibraryForInstruments() {
);
elmJson = null;
});

if (!elmJson) {
elmJson = await import(
`../cql/r4/survey_resources/Default_LogicLibrary.json`
Expand Down

0 comments on commit 27d4335

Please sign in to comment.