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

handle error when survey has not associated ELM lib #220

Merged
merged 3 commits into from
Dec 16, 2024
Merged
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
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
73 changes: 41 additions & 32 deletions src/utils/executeELM.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,33 +152,35 @@ 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);
reject("error processing instrument ELM. See console for details.");
});
});
});
resolve(finalResults);
Expand All @@ -193,12 +195,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 +279,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 +295,7 @@ function getLibraryForInstruments() {
);
elmJson = null;
});

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