Skip to content

Commit 2874f62

Browse files
achen2401Amy Chen
andauthored
handle error when survey has not associated ELM lib (#220)
* handle error when survey has not associated ELM lib * fix try catch code * fix typo per feedback --------- Co-authored-by: Amy Chen <[email protected]>
1 parent 5360d12 commit 2874f62

File tree

4 files changed

+47
-34
lines changed

4 files changed

+47
-34
lines changed

src/components/Summary.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
getErrorMessageString,
1414
isEmptyArray,
1515
isReportEnabled,
16+
isNumber
1617
} from "../helpers/utility";
1718

1819
import ChartIcon from "../icons/ChartIcon";
@@ -353,7 +354,7 @@ export default class Summary extends Component {
353354
...formatterArguments
354355
);
355356
}
356-
return value
357+
return value || isNumber(value)
357358
? value
358359
: headerKey.default
359360
? headerKey.default

src/config/report_config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const reportConfig = [
6060
{
6161
id: "CIRG-PainTracker-GE",
6262
key: GE_DATA_KEY,
63+
useDefaultELMLib: true
6364
},
6465
],
6566
//status: "inactive",
@@ -380,6 +381,7 @@ const reportConfig = [
380381
{
381382
id: "CIRG-PainTracker-TRT",
382383
key: TRT_DATA_KEY,
384+
useDefaultELMLib: true
383385
},
384386
],
385387
icon: (props) => (

src/styles/components/_Summary.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,10 @@
403403
height: 100%;
404404
width: 100%;
405405
display: flex;
406-
align-items: center;
406+
align-items: flex-start;
407407
justify-content: center;
408408
font-size: 1.1em;
409+
line-height: 1.35;
409410
}
410411
}
411412
@media (min-width: 992px) {

src/utils/executeELM.js

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -152,33 +152,35 @@ async function executeELM(collector, oResourceTypes) {
152152
if (!evalResults[PATIENT_SUMMARY_KEY]) {
153153
evalResults[PATIENT_SUMMARY_KEY] = {};
154154
}
155-
Promise.allSettled([
156-
executeELMForReport(patientBundle),
157-
...elmLibs,
158-
]).then(
159-
(results) => {
160-
evalResults[PATIENT_SUMMARY_KEY]["ReportSummary"] =
161-
results[0].status !== "rejected" ? results[0].value : null;
162-
const evaluatedSurveyResults = executeELMForInstruments(
163-
results.slice(1),
164-
patientBundle
165-
);
166-
evalResults[PATIENT_SUMMARY_KEY]["SurveySummary"] =
167-
evaluatedSurveyResults;
168-
//debug
169-
console.log(
170-
"final evaluated CQL results including surveys ",
171-
evalResults
172-
);
173-
resolve(evalResults);
174-
},
175-
(e) => {
176-
console.log(e);
177-
reject(
178-
"Error occurred executing report library logics. See console for detail"
179-
);
180-
}
181-
);
155+
Promise.allSettled([executeELMForReport(patientBundle), ...elmLibs])
156+
.then(
157+
(results) => {
158+
evalResults[PATIENT_SUMMARY_KEY]["ReportSummary"] =
159+
results[0].status !== "rejected" ? results[0].value : null;
160+
const evaluatedSurveyResults = executeELMForInstruments(
161+
results.slice(1),
162+
patientBundle
163+
);
164+
evalResults[PATIENT_SUMMARY_KEY]["SurveySummary"] =
165+
evaluatedSurveyResults;
166+
//debug
167+
console.log(
168+
"final evaluated CQL results including surveys ",
169+
evalResults
170+
);
171+
resolve(evalResults);
172+
},
173+
(e) => {
174+
console.log(e);
175+
reject(
176+
"Error occurred executing report library logics. See console for detail"
177+
);
178+
}
179+
)
180+
.catch((e) => {
181+
console.log("Error processing instrument ELM: ", e);
182+
reject("error processing instrument ELM. See console for details.");
183+
});
182184
});
183185
});
184186
resolve(finalResults);
@@ -193,12 +195,15 @@ async function executeELMForReport(bundle) {
193195
console.log("Issue occurred loading ELM lib for reoirt", e);
194196
r4ReportCommonELM = null;
195197
});
196-
198+
197199
if (!r4ReportCommonELM) return null;
198200

199-
let reportLib = new cql.Library(r4ReportCommonELM, new cql.Repository({
200-
FHIRHelpers: r4HelpersELM,
201-
}));
201+
let reportLib = new cql.Library(
202+
r4ReportCommonELM,
203+
new cql.Repository({
204+
FHIRHelpers: r4HelpersELM,
205+
})
206+
);
202207
const reportExecutor = new cql.Executor(
203208
reportLib,
204209
new cql.CodeService(valueSetDB)
@@ -274,8 +279,11 @@ function getLibraryForInstruments() {
274279
return INSTRUMENT_LIST.map((item) =>
275280
(async () => {
276281
let elmJson = null;
282+
const libPrefix = item.useDefaultELMLib
283+
? "Default"
284+
: item.key.toUpperCase();
277285
elmJson = await import(
278-
`../cql/r4/survey_resources/${item.key.toUpperCase()}_LogicLibrary.json`
286+
`../cql/r4/survey_resources/${libPrefix}_LogicLibrary.json`
279287
)
280288
.then((module) => module.default)
281289
.catch((e) => {
@@ -287,6 +295,7 @@ function getLibraryForInstruments() {
287295
);
288296
elmJson = null;
289297
});
298+
290299
if (!elmJson) {
291300
elmJson = await import(
292301
`../cql/r4/survey_resources/Default_LogicLibrary.json`

0 commit comments

Comments
 (0)