@@ -23,26 +23,17 @@ engine.weight = function (coll) {
23
23
const questionnaire = this . vars . questionnaire || this . processedVars . questionnaire ?. data ;
24
24
coll . forEach ( ( answer ) => {
25
25
if ( answer ?. data ) {
26
- let value = answer . data . valueCoding ;
26
+ const valueCoding = answer . data . valueCoding ;
27
+ let value = valueCoding ;
27
28
if ( ! value ) {
28
29
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 ;
39
31
}
40
32
const score = value ?. extension ?. find ( checkExtUrl ) ?. valueDecimal ;
41
33
if ( score !== undefined ) {
42
34
// if we have a score extension in the source item, use it.
43
35
res . push ( score ) ;
44
36
} else if ( questionnaire ) {
45
- const valueCoding = answer . data . valueCoding ;
46
37
if ( valueCoding ) {
47
38
const qItem = getQItemByLinkIds (
48
39
questionnaire , getLinkIds ( answer . parentResNode )
@@ -58,7 +49,10 @@ engine.weight = function (coll) {
58
49
res . push ( score ) ;
59
50
}
60
51
} 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.' ) ;
62
56
}
63
57
}
64
58
} else {
0 commit comments