@aehrc/smart-forms-renderer 0.35.4 → 0.35.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/lib/hooks/useStringCalculatedExpression.js +1 -0
  2. package/lib/hooks/useStringCalculatedExpression.js.map +1 -1
  3. package/lib/hooks/useValueSetCodings.js +5 -0
  4. package/lib/hooks/useValueSetCodings.js.map +1 -1
  5. package/lib/interfaces/questionnaireStore.interface.d.ts +2 -1
  6. package/lib/stores/questionnaireStore.js +4 -0
  7. package/lib/stores/questionnaireStore.js.map +1 -1
  8. package/lib/utils/fhirpathAsyncUtils/fhirpath-async.d.ts +15 -0
  9. package/lib/utils/fhirpathAsyncUtils/fhirpath-async.js +433 -0
  10. package/lib/utils/fhirpathAsyncUtils/fhirpath-async.js.map +1 -0
  11. package/lib/utils/fhirpathAsyncUtils/outcome-utils.d.ts +3 -0
  12. package/lib/utils/fhirpathAsyncUtils/outcome-utils.js +42 -0
  13. package/lib/utils/fhirpathAsyncUtils/outcome-utils.js.map +1 -0
  14. package/lib/utils/fhirpathAsyncUtils/test-questionnaire.d.ts +1 -0
  15. package/lib/utils/fhirpathAsyncUtils/test-questionnaire.js +379 -0
  16. package/lib/utils/fhirpathAsyncUtils/test-questionnaire.js.map +1 -0
  17. package/lib/utils/questionnaireStoreUtils/addDisplayToCodings.d.ts +2 -1
  18. package/lib/utils/questionnaireStoreUtils/addDisplayToCodings.js +35 -0
  19. package/lib/utils/questionnaireStoreUtils/addDisplayToCodings.js.map +1 -1
  20. package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js +6 -2
  21. package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js.map +1 -1
  22. package/lib/utils/questionnaireStoreUtils/extractOtherExtensions.d.ts +2 -1
  23. package/lib/utils/questionnaireStoreUtils/extractOtherExtensions.js +13 -3
  24. package/lib/utils/questionnaireStoreUtils/extractOtherExtensions.js.map +1 -1
  25. package/lib/utils/questionnaireStoreUtils/insertAnswerOptions.d.ts +7 -0
  26. package/lib/utils/questionnaireStoreUtils/insertAnswerOptions.js +44 -0
  27. package/lib/utils/questionnaireStoreUtils/insertAnswerOptions.js.map +1 -0
  28. package/package.json +3 -3
  29. package/src/hooks/useStringCalculatedExpression.ts +1 -0
  30. package/src/hooks/useValueSetCodings.ts +6 -0
  31. package/src/interfaces/questionnaireStore.interface.ts +2 -1
  32. package/src/stores/questionnaireStore.ts +8 -0
  33. package/src/stories/assets/questionnaires/QPrePopTester.ts +117 -0
  34. package/src/utils/fhirpathAsyncUtils/test-questionnaire.ts +383 -0
  35. package/src/utils/questionnaireStoreUtils/addDisplayToCodings.ts +40 -1
  36. package/src/utils/questionnaireStoreUtils/createQuestionaireModel.ts +16 -3
  37. package/src/utils/questionnaireStoreUtils/extractOtherExtensions.ts +15 -0
  38. package/src/utils/questionnaireStoreUtils/insertAnswerOptions.ts +56 -0
@@ -0,0 +1,7 @@
1
+ import type { Questionnaire, QuestionnaireItemAnswerOption } from 'fhir/r4';
2
+ /**
3
+ * Filter x-fhir-query variables from questionnaire's extensions needed for population
4
+ *
5
+ * @author Sean Fong
6
+ */
7
+ export declare function insertCompleteAnswerOptionsIntoQuestionnaire(questionnaire: Questionnaire, completeAnswerOptions: Record<string, QuestionnaireItemAnswerOption[]>): Questionnaire;
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Copyright 2024 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Filter x-fhir-query variables from questionnaire's extensions needed for population
19
+ *
20
+ * @author Sean Fong
21
+ */
22
+ export function insertCompleteAnswerOptionsIntoQuestionnaire(questionnaire, completeAnswerOptions) {
23
+ if (questionnaire.item && questionnaire.item.length > 0) {
24
+ for (const qItem of questionnaire.item) {
25
+ insertCompleteAnswerOptionsRecursive(qItem, completeAnswerOptions);
26
+ }
27
+ }
28
+ return questionnaire;
29
+ }
30
+ function insertCompleteAnswerOptionsRecursive(qItem, completeAnswerOptions) {
31
+ if (qItem.item) {
32
+ for (const childItem of qItem.item) {
33
+ insertCompleteAnswerOptionsRecursive(childItem, completeAnswerOptions);
34
+ }
35
+ }
36
+ if (qItem.answerOption) {
37
+ const options = completeAnswerOptions[qItem.linkId];
38
+ if (options) {
39
+ qItem.answerOption = options;
40
+ }
41
+ }
42
+ return;
43
+ }
44
+ //# sourceMappingURL=insertAnswerOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insertAnswerOptions.js","sourceRoot":"","sources":["../../../src/utils/questionnaireStoreUtils/insertAnswerOptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;GAIG;AACH,MAAM,UAAU,4CAA4C,CAC1D,aAA4B,EAC5B,qBAAsE;IAEtE,IAAI,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACvD,KAAK,MAAM,KAAK,IAAI,aAAa,CAAC,IAAI,EAAE;YACtC,oCAAoC,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;SACpE;KACF;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,oCAAoC,CAC3C,KAAwB,EACxB,qBAAsE;IAEtE,IAAI,KAAK,CAAC,IAAI,EAAE;QACd,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE;YAClC,oCAAoC,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;SACxE;KACF;IAED,IAAI,KAAK,CAAC,YAAY,EAAE;QACtB,MAAM,OAAO,GAAG,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,OAAO,EAAE;YACX,KAAK,CAAC,YAAY,GAAG,OAAO,CAAC;SAC9B;KACF;IAED,OAAO;AACT,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aehrc/smart-forms-renderer",
3
- "version": "0.35.4",
3
+ "version": "0.35.6",
4
4
  "description": "FHIR Structured Data Captured (SDC) rendering engine for Smart Forms",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/aehrc/smart-forms#readme",
29
29
  "dependencies": {
30
- "@aehrc/sdc-populate": "^2.2.1",
30
+ "@aehrc/sdc-populate": "^2.2.2",
31
31
  "@iconify/react": "^4.1.1",
32
32
  "dayjs": "^1.11.10",
33
33
  "deep-diff": "^1.0.2",
@@ -68,7 +68,7 @@
68
68
  "@storybook/react-vite": "^8.0.10",
69
69
  "@storybook/test": "^8.0.10",
70
70
  "@swc/cli": "^0.1.63",
71
- "@swc/core": "^1.3.99",
71
+ "@swc/core": "^1.5.28",
72
72
  "@testing-library/jest-dom": "^6.1.2",
73
73
  "@testing-library/react": "^14.2.1",
74
74
  "@testing-library/react-hooks": "^7.0.2",
@@ -49,6 +49,7 @@ function useStringCalculatedExpression(
49
49
  return;
50
50
  }
51
51
 
52
+ console.log(calcExpression);
52
53
  // only update if calculated value is different from current value
53
54
  if (
54
55
  calcExpression.value !== inputValue &&
@@ -138,6 +138,12 @@ function useValueSetCodings(qItem: QuestionnaireItem): {
138
138
  const valueSetUrl = qItem.answerValueSet;
139
139
  if (!valueSetUrl || codings.length > 0) return;
140
140
 
141
+ //
142
+ if (valueSetUrl.startsWith('#')) {
143
+ // FIXME add expand here
144
+ }
145
+
146
+ // Assume answerValueSet is an expandable URL
141
147
  const terminologyServerUrl = getTerminologyServerUrl(qItem) ?? defaultTerminologyServerUrl;
142
148
  const promise = getValueSetPromise(valueSetUrl, terminologyServerUrl);
143
149
  if (promise) {
@@ -21,7 +21,7 @@ import type { LaunchContext } from './populate.interface';
21
21
  import type { EnableWhenExpressions, EnableWhenItems } from './enableWhen.interface';
22
22
  import type { CalculatedExpression } from './calculatedExpression.interface';
23
23
  import type { AnswerExpression } from './answerExpression.interface';
24
- import type { Coding } from 'fhir/r4';
24
+ import type { Coding, QuestionnaireItemAnswerOption } from 'fhir/r4';
25
25
 
26
26
  export interface QuestionnaireModel {
27
27
  itemTypes: Record<string, string>;
@@ -32,6 +32,7 @@ export interface QuestionnaireModel {
32
32
  enableWhenExpressions: EnableWhenExpressions;
33
33
  calculatedExpressions: Record<string, CalculatedExpression[]>;
34
34
  answerExpressions: Record<string, AnswerExpression>;
35
+ answerOptions: Record<string, QuestionnaireItemAnswerOption[]>;
35
36
  processedValueSetCodings: Record<string, Coding[]>;
36
37
  processedValueSetUrls: Record<string, string>;
37
38
  fhirPathContext: Record<string, any>;
@@ -46,6 +46,7 @@ import { createSelectors } from './selector';
46
46
  import { mutateRepeatEnableWhenExpressionInstances } from '../utils/enableWhenExpression';
47
47
  import { questionnaireResponseStore } from './questionnaireResponseStore';
48
48
  import { createQuestionnaireResponseItemMap } from '../utils/questionnaireResponseStoreUtils/updatableResponseItems';
49
+ import { insertCompleteAnswerOptionsIntoQuestionnaire } from '../utils/questionnaireStoreUtils/insertAnswerOptions';
49
50
 
50
51
  /**
51
52
  * QuestionnaireStore properties and methods
@@ -180,6 +181,13 @@ export const questionnaireStore = createStore<QuestionnaireStoreType>()((set, ge
180
181
  terminologyServerUrl
181
182
  );
182
183
 
184
+ // Insert answerOptions with displays into questionnaire
185
+ questionnaire = insertCompleteAnswerOptionsIntoQuestionnaire(
186
+ questionnaire,
187
+ questionnaireModel.answerOptions
188
+ );
189
+
190
+ // Initialise form with questionnaire response and properties in questionnaire model
183
191
  const {
184
192
  initialEnableWhenItems,
185
193
  initialEnableWhenLinkedQuestions,
@@ -127,9 +127,43 @@ export const qSelectivePrePopTester: Questionnaire = {
127
127
  }
128
128
  ]
129
129
  }
130
+ },
131
+ {
132
+ resourceType: 'ValueSet',
133
+ id: 'MedicalHistory',
134
+ url: 'https://smartforms.csiro.au/ig/ValueSet/MedicalHistory',
135
+ name: 'MedicalHistory',
136
+ title: 'Medical History',
137
+ status: 'draft',
138
+ experimental: false,
139
+ description:
140
+ 'The Medical History value set includes values that may be used to represent medical history, operations and hospital admissions.',
141
+ compose: {
142
+ include: [
143
+ {
144
+ system: 'http://snomed.info/sct',
145
+ filter: [
146
+ {
147
+ property: 'constraint',
148
+ op: '=',
149
+ value:
150
+ '^32570581000036105|Problem/Diagnosis reference set| OR ^32570141000036105|Procedure foundation reference set|'
151
+ }
152
+ ]
153
+ }
154
+ ]
155
+ }
130
156
  }
131
157
  ],
132
158
  extension: [
159
+ {
160
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
161
+ valueExpression: {
162
+ name: 'Condition',
163
+ language: 'application/x-fhir-query',
164
+ expression: 'Condition?patient={{%patient.id}}'
165
+ }
166
+ },
133
167
  {
134
168
  url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-launchContext',
135
169
  extension: [
@@ -196,6 +230,89 @@ export const qSelectivePrePopTester: Questionnaire = {
196
230
  type: 'choice',
197
231
  repeats: false,
198
232
  answerValueSet: 'http://hl7.org/fhir/ValueSet/administrative-gender'
233
+ },
234
+ {
235
+ extension: [
236
+ {
237
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
238
+ valueCodeableConcept: {
239
+ coding: [
240
+ {
241
+ system: 'http://hl7.org/fhir/questionnaire-item-control',
242
+ code: 'gtable'
243
+ }
244
+ ]
245
+ }
246
+ },
247
+ {
248
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext',
249
+ valueExpression: {
250
+ name: 'ConditionRepeat',
251
+ language: 'text/fhirpath',
252
+ expression:
253
+ "%Condition.entry.resource.where(category.coding.exists(code='problem-list-item'))"
254
+ }
255
+ }
256
+ ],
257
+ linkId: 'medical-history',
258
+ text: 'Medical history and current problems list',
259
+ type: 'group',
260
+ repeats: true,
261
+ item: [
262
+ {
263
+ extension: [
264
+ {
265
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
266
+ valueCodeableConcept: {
267
+ coding: [
268
+ {
269
+ system: 'http://hl7.org/fhir/questionnaire-item-control',
270
+ code: 'autocomplete'
271
+ }
272
+ ]
273
+ }
274
+ },
275
+ {
276
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
277
+ valueExpression: {
278
+ language: 'text/fhirpath',
279
+ expression:
280
+ "%ConditionRepeat.code.select((coding.where(system='http://snomed.info/sct') | coding.where(system!='http://snomed.info/sct').first() | text ).first())"
281
+ }
282
+ }
283
+ ],
284
+ linkId: 'medical-history-condition',
285
+ text: 'Condition',
286
+ type: 'open-choice',
287
+ answerValueSet: '#MedicalHistory'
288
+ },
289
+ {
290
+ extension: [
291
+ {
292
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
293
+ valueCodeableConcept: {
294
+ coding: [
295
+ {
296
+ system: 'http://hl7.org/fhir/questionnaire-item-control',
297
+ code: 'drop-down'
298
+ }
299
+ ]
300
+ }
301
+ },
302
+ {
303
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
304
+ valueExpression: {
305
+ language: 'text/fhirpath',
306
+ expression: '%ConditionRepeat.clinicalStatus.coding'
307
+ }
308
+ }
309
+ ],
310
+ linkId: 'medical-history-status',
311
+ text: 'Clinical Status',
312
+ type: 'choice',
313
+ answerValueSet: 'http://hl7.org/fhir/ValueSet/condition-clinical'
314
+ }
315
+ ]
199
316
  }
200
317
  ]
201
318
  };
@@ -0,0 +1,383 @@
1
+ import { Questionnaire } from 'fhir/r4';
2
+
3
+ const testQuestionnaire: Questionnaire = {
4
+ resourceType: 'Questionnaire',
5
+ id: 'CalculatedExpressionCvdRiskCalculatorPrepop',
6
+ meta: {
7
+ versionId: '1',
8
+ lastUpdated: '2024-06-11T10:15:22.026+00:00',
9
+ source: '#CwlqsoGwV8CY9l7l'
10
+ },
11
+ extension: [
12
+ {
13
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
14
+ valueExpression: {
15
+ name: 'Condition',
16
+ language: 'application/x-fhir-query',
17
+ expression: 'Condition?patient={{%patient.id}}'
18
+ }
19
+ },
20
+ {
21
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
22
+ valueExpression: {
23
+ name: 'ObsTobaccoSmokingStatus',
24
+ language: 'application/x-fhir-query',
25
+ expression: 'Observation?code=72166-2&_count=1&_sort=-date&patient={{%patient.id}}'
26
+ }
27
+ },
28
+ {
29
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
30
+ valueExpression: {
31
+ name: 'ObsBodyHeight',
32
+ language: 'application/x-fhir-query',
33
+ expression: 'Observation?code=8302-2&_count=1&_sort=-date&patient={{%patient.id}}'
34
+ }
35
+ },
36
+ {
37
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
38
+ valueExpression: {
39
+ name: 'ObsBodyWeight',
40
+ language: 'application/x-fhir-query',
41
+ expression: 'Observation?code=29463-7&_count=1&_sort=-date&patient={{%patient.id}}'
42
+ }
43
+ },
44
+ {
45
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
46
+ valueExpression: {
47
+ name: 'ObsHeadCircumference',
48
+ language: 'application/x-fhir-query',
49
+ expression: 'Observation?code=9843-4&_count=1&_sort=-date&patient={{%patient.id}}'
50
+ }
51
+ },
52
+ {
53
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
54
+ valueExpression: {
55
+ name: 'ObsWaistCircumference',
56
+ language: 'application/x-fhir-query',
57
+ expression: 'Observation?code=8280-0&_count=1&_sort=-date&patient={{%patient.id}}'
58
+ }
59
+ },
60
+ {
61
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
62
+ valueExpression: {
63
+ name: 'ObsBloodPressure',
64
+ language: 'application/x-fhir-query',
65
+ expression: 'Observation?code=85354-9&_count=1&_sort=-date&patient={{%patient.id}}'
66
+ }
67
+ },
68
+ {
69
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
70
+ valueExpression: {
71
+ name: 'ObsHeartRate',
72
+ language: 'application/x-fhir-query',
73
+ expression: 'Observation?code=8867-4&_count=1&_sort=-date&patient={{%patient.id}}'
74
+ }
75
+ },
76
+ {
77
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
78
+ valueExpression: {
79
+ name: 'ObsTotalCholesterol',
80
+ language: 'application/x-fhir-query',
81
+ expression: 'Observation?code=14647-2&_count=1&_sort=-date&patient={{%patient.id}}'
82
+ }
83
+ },
84
+ {
85
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
86
+ valueExpression: {
87
+ name: 'ObsHDLCholesterol',
88
+ language: 'application/x-fhir-query',
89
+ expression: 'Observation?code=14646-4&_count=1&_sort=-date&patient={{%patient.id}}'
90
+ }
91
+ },
92
+ {
93
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-launchContext',
94
+ extension: [
95
+ {
96
+ url: 'name',
97
+ valueCoding: {
98
+ system: 'http://hl7.org/fhir/uv/sdc/CodeSystem/launchContext',
99
+ code: 'patient'
100
+ }
101
+ },
102
+ {
103
+ url: 'type',
104
+ valueCode: 'Patient'
105
+ },
106
+ {
107
+ url: 'description',
108
+ valueString: 'The patient that is to be used to pre-populate the form'
109
+ }
110
+ ]
111
+ }
112
+ ],
113
+ contained: [
114
+ {
115
+ resourceType: 'ValueSet',
116
+ id: 'MedicalHistory',
117
+ url: 'https://smartforms.csiro.au/ig/ValueSet/MedicalHistory',
118
+ name: 'MedicalHistory',
119
+ title: 'Medical History',
120
+ status: 'draft',
121
+ experimental: false,
122
+ description:
123
+ 'The Medical History value set includes values that may be used to represent medical history, operations and hospital admissions.',
124
+ compose: {
125
+ include: [
126
+ {
127
+ system: 'http://snomed.info/sct',
128
+ filter: [
129
+ {
130
+ property: 'constraint',
131
+ op: '=',
132
+ value:
133
+ '^32570581000036105|Problem/Diagnosis reference set| OR ^32570141000036105|Procedure foundation reference set|'
134
+ }
135
+ ]
136
+ }
137
+ ]
138
+ }
139
+ }
140
+ ],
141
+ url: 'https://smartforms.csiro.au/docs/sdc/population/calculated-expression-2',
142
+ version: '0.1.0',
143
+ name: 'CalculatedExpressionCvdRiskCalculatorPrepop',
144
+ title: 'Calculated Expression CVD Risk Calculator - Pre-population',
145
+ status: 'draft',
146
+ date: '2024-05-01',
147
+ publisher: 'AEHRC CSIRO',
148
+ item: [
149
+ {
150
+ extension: [
151
+ {
152
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
153
+ valueExpression: {
154
+ name: 'female',
155
+ language: 'text/fhirpath',
156
+ expression: "iif(item.where(linkId='gender').answer.value.code='female', 1, 0)"
157
+ }
158
+ },
159
+ {
160
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
161
+ valueExpression: {
162
+ name: 'age',
163
+ language: 'text/fhirpath',
164
+ expression: "item.where(linkId='patient-age').answer.value"
165
+ }
166
+ },
167
+ {
168
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
169
+ valueExpression: {
170
+ name: 'cvdAge',
171
+ language: 'text/fhirpath',
172
+ expression: 'iif(%age > 74, 74, iif(%age < 35, 35, %age))'
173
+ }
174
+ },
175
+ {
176
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
177
+ valueExpression: {
178
+ name: 'systolicBP',
179
+ language: 'text/fhirpath',
180
+ expression: "item.where(linkId='systolic-blood-pressure').answer.value"
181
+ }
182
+ },
183
+ {
184
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
185
+ valueExpression: {
186
+ name: 'smoker',
187
+ language: 'text/fhirpath',
188
+ expression:
189
+ "iif(item.where(linkId='smoking-status').answer.value.code='77176002', 1, 0)"
190
+ }
191
+ },
192
+ {
193
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
194
+ valueExpression: {
195
+ name: 'totalCh',
196
+ language: 'text/fhirpath',
197
+ expression: "item.where(linkId='total-cholesterol').answer.value"
198
+ }
199
+ },
200
+ {
201
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
202
+ valueExpression: {
203
+ name: 'hdl',
204
+ language: 'text/fhirpath',
205
+ expression: "item.where(linkId='hdl-cholesterol').answer.value"
206
+ }
207
+ },
208
+ {
209
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
210
+ valueExpression: {
211
+ name: 'diabetes',
212
+ language: 'text/fhirpath',
213
+ expression: "iif(item.where(linkId='has-diabetes').answer.value = true,1,0)"
214
+ }
215
+ },
216
+ {
217
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
218
+ valueExpression: {
219
+ name: 'ecgLvh',
220
+ language: 'text/fhirpath',
221
+ expression: "iif(item.where(linkId='ecg-lvh').answer.value = true,1,0)"
222
+ }
223
+ },
224
+ {
225
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
226
+ valueExpression: {
227
+ name: 'cBase',
228
+ language: 'text/fhirpath',
229
+ expression: '18.8144'
230
+ }
231
+ },
232
+ {
233
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
234
+ valueExpression: {
235
+ name: 'cFemale',
236
+ language: 'text/fhirpath',
237
+ expression: '%female * -1.2146'
238
+ }
239
+ },
240
+ {
241
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
242
+ valueExpression: {
243
+ name: 'cAge',
244
+ language: 'text/fhirpath',
245
+ expression: '%cvdAge.ln() * -1.8443'
246
+ }
247
+ },
248
+ {
249
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
250
+ valueExpression: {
251
+ name: 'cAgeFemale',
252
+ language: 'text/fhirpath',
253
+ expression: '%female * %cvdAge.ln() * 0.3668'
254
+ }
255
+ },
256
+ {
257
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
258
+ valueExpression: {
259
+ name: 'cSBP',
260
+ language: 'text/fhirpath',
261
+ expression: '%systolicBP.ln() * -1.4032'
262
+ }
263
+ },
264
+ {
265
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
266
+ valueExpression: {
267
+ name: 'cSmoker',
268
+ language: 'text/fhirpath',
269
+ expression: '%smoker * -0.3899'
270
+ }
271
+ },
272
+ {
273
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
274
+ valueExpression: {
275
+ name: 'cTcHdl',
276
+ language: 'text/fhirpath',
277
+ expression: '(%totalCh / %hdl).ln() * -0.539'
278
+ }
279
+ },
280
+ {
281
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
282
+ valueExpression: {
283
+ name: 'cDiabetes',
284
+ language: 'text/fhirpath',
285
+ expression: '%diabetes * -0.3036'
286
+ }
287
+ },
288
+ {
289
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
290
+ valueExpression: {
291
+ name: 'cDiabetesFemale',
292
+ language: 'text/fhirpath',
293
+ expression: '%female * %diabetes * -0.1697'
294
+ }
295
+ },
296
+ {
297
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
298
+ valueExpression: {
299
+ name: 'cEcgLvh',
300
+ language: 'text/fhirpath',
301
+ expression: '%ecgLvh * -0.3362'
302
+ }
303
+ },
304
+ {
305
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
306
+ valueExpression: {
307
+ name: 'sumOfCoeffs',
308
+ language: 'text/fhirpath',
309
+ expression:
310
+ '%cBase + %cFemale + %cAge + %cAgeFemale + %cSBP + %cSmoker + %cTcHdl + %cDiabetes + %cDiabetesFemale + %cEcgLvh'
311
+ }
312
+ },
313
+ {
314
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
315
+ valueExpression: {
316
+ name: 'cvdScale',
317
+ language: 'text/fhirpath',
318
+ expression: '(0.6536 + (%sumOfCoeffs * -0.2402)).exp()'
319
+ }
320
+ },
321
+ {
322
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
323
+ valueExpression: {
324
+ name: 'cvdU',
325
+ language: 'text/fhirpath',
326
+ expression: '(5.ln()-%sumOfCoeffs)/%cvdScale'
327
+ }
328
+ },
329
+ {
330
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
331
+ valueExpression: {
332
+ name: 'cvdScore',
333
+ language: 'text/fhirpath',
334
+ expression: '(1 - (%cvdU.exp()*-1).exp()) * 100'
335
+ }
336
+ }
337
+ ],
338
+ linkId: 'scenario-2',
339
+ text: "Request for X-Ray Right Foot as 'Procedure + Laterality'",
340
+ type: 'group',
341
+ item: [
342
+ {
343
+ extension: [
344
+ {
345
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
346
+ valueCodeableConcept: {
347
+ coding: [
348
+ {
349
+ system: 'http://hl7.org/fhir/questionnaire-item-control',
350
+ code: 'autocomplete'
351
+ }
352
+ ]
353
+ }
354
+ }
355
+ ],
356
+ linkId: 'medical-history-condition',
357
+ text: 'Medical History Condition',
358
+ type: 'open-choice',
359
+ answerValueSet: '#MedicalHistory'
360
+ },
361
+ {
362
+ extension: [
363
+ {
364
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
365
+ valueCodeableConcept: {
366
+ coding: [
367
+ {
368
+ system: 'http://hl7.org/fhir/questionnaire-item-control',
369
+ code: 'autocomplete'
370
+ }
371
+ ]
372
+ }
373
+ }
374
+ ],
375
+ linkId: 'medical-history-condition',
376
+ text: 'Medical History Condition',
377
+ type: 'open-choice',
378
+ answerValueSet: '#MedicalHistory'
379
+ }
380
+ ]
381
+ }
382
+ ]
383
+ };