Skip to content

Commit 0d12999

Browse files
Changes as per review
LF-2100
1 parent 187acf0 commit 0d12999

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

Diff for: src/sdc-ig-supplements.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,17 @@ engine.weight = function (coll) {
2323
const questionnaire = this.vars.questionnaire || this.processedVars.questionnaire?.data;
2424
coll.forEach((answer) => {
2525
if (answer?.data) {
26-
let value = answer.data.valueCoding;
26+
const valueCoding = answer.data.valueCoding;
27+
let value = valueCoding;
2728
if (!value) {
2829
const prop = Object.keys(answer.data).find(p => p.startsWith('value'));
29-
// if we found a child value[x] property
30-
value = prop
31-
// we use it to get a score extension
32-
? answer.data[prop]
33-
// otherwise, if the source item has a simple data type
34-
: answer._data?.extension
35-
// we get the extension from the adjacent property starting with an underscore
36-
? answer._data
37-
// otherwise we get the extension from the source item
38-
: answer.data;
30+
value = prop ? answer.data[prop] : null;
3931
}
4032
const score = value?.extension?.find(checkExtUrl)?.valueDecimal;
4133
if (score !== undefined) {
4234
// if we have a score extension in the source item, use it.
4335
res.push(score);
4436
} else if (questionnaire) {
45-
const valueCoding = answer.data.valueCoding;
4637
if (valueCoding) {
4738
const qItem = getQItemByLinkIds(
4839
questionnaire, getLinkIds(answer.parentResNode)
@@ -58,7 +49,10 @@ engine.weight = function (coll) {
5849
res.push(score);
5950
}
6051
} else {
61-
throw new Error('Questionnaire answerOption with this linkId was not found: ' + answer.parentResNode.data.linkId + '.');
52+
throw new Error(
53+
'Questionnaire answerOption with this linkId was not found: ' +
54+
answer.parentResNode.data.linkId +
55+
'. Looking upon the underlying CodeSystem is not supported yet.');
6256
}
6357
}
6458
} else {

0 commit comments

Comments
 (0)