@aehrc/smart-forms-renderer 0.27.2 → 0.27.4

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 (179) hide show
  1. package/.storybook/main.ts +2 -1
  2. package/.storybook/preview.ts +6 -1
  3. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.d.ts +3 -2
  4. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js +9 -17
  5. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js.map +1 -1
  6. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js +12 -9
  7. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js.map +1 -1
  8. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.d.ts +2 -2
  9. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js +7 -9
  10. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js.map +1 -1
  11. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +12 -8
  12. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -1
  13. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.d.ts +2 -1
  14. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js +3 -3
  15. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js.map +1 -1
  16. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js +6 -4
  17. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js.map +1 -1
  18. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.d.ts +2 -1
  19. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.js +3 -3
  20. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.js.map +1 -1
  21. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.d.ts +2 -2
  22. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js +5 -7
  23. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js.map +1 -1
  24. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js +4 -4
  25. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js.map +1 -1
  26. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.d.ts +2 -1
  27. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js +2 -3
  28. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js.map +1 -1
  29. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js +5 -3
  30. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js.map +1 -1
  31. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.d.ts +2 -1
  32. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.js +3 -3
  33. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.js.map +1 -1
  34. package/lib/components/FormComponents/DecimalItem/DecimalItem.js +1 -1
  35. package/lib/components/FormComponents/GroupItem/TabButtonsWrapper.js +20 -20
  36. package/lib/components/FormComponents/GroupItem/TabButtonsWrapper.js.map +1 -1
  37. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.d.ts +3 -2
  38. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js +7 -19
  39. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js.map +1 -1
  40. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js +40 -40
  41. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js.map +1 -1
  42. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js +15 -3
  43. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js.map +1 -1
  44. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.d.ts +2 -1
  45. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js +3 -3
  46. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js.map +1 -1
  47. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js +27 -26
  48. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js.map +1 -1
  49. package/lib/components/FormComponents/StringItem/StringField.js +1 -1
  50. package/lib/components/FormComponents/StringItem/StringField.js.map +1 -1
  51. package/lib/hooks/useInitialiseRenderer.js +1 -1
  52. package/lib/hooks/useInitialiseRenderer.js.map +1 -1
  53. package/lib/hooks/useNextAndPreviousVisibleTabs.d.ts +7 -0
  54. package/lib/hooks/useNextAndPreviousVisibleTabs.js +63 -0
  55. package/lib/hooks/useNextAndPreviousVisibleTabs.js.map +1 -0
  56. package/lib/hooks/useNextPreviousVisibleTabs.d.ts +6 -0
  57. package/lib/hooks/useNextPreviousVisibleTabs.js +63 -0
  58. package/lib/hooks/useNextPreviousVisibleTabs.js.map +1 -0
  59. package/lib/index.d.ts +0 -7
  60. package/lib/index.js +0 -24
  61. package/lib/index.js.map +1 -1
  62. package/lib/utils/choice.d.ts +1 -7
  63. package/lib/utils/choice.js +10 -20
  64. package/lib/utils/choice.js.map +1 -1
  65. package/lib/utils/enableWhen.js +5 -7
  66. package/lib/utils/enableWhen.js.map +1 -1
  67. package/lib/utils/index.d.ts +1 -0
  68. package/lib/utils/index.js +1 -0
  69. package/lib/utils/index.js.map +1 -1
  70. package/lib/utils/openChoice.d.ts +9 -4
  71. package/lib/utils/openChoice.js +47 -78
  72. package/lib/utils/openChoice.js.map +1 -1
  73. package/lib/utils/tabs.d.ts +0 -21
  74. package/lib/utils/tabs.js +0 -51
  75. package/lib/utils/tabs.js.map +1 -1
  76. package/package.json +4 -4
  77. package/src/components/FormComponents/ChoiceItems/CheckboxOptionList.tsx +82 -0
  78. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.tsx +23 -52
  79. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.tsx +15 -9
  80. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.tsx +17 -19
  81. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx +13 -8
  82. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.tsx +5 -4
  83. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx +6 -2
  84. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.tsx +5 -1
  85. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx +9 -16
  86. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +4 -4
  87. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.tsx +4 -3
  88. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx +5 -2
  89. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.tsx +5 -1
  90. package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +1 -1
  91. package/src/components/FormComponents/GroupItem/TabButtonsWrapper.tsx +28 -25
  92. package/src/components/FormComponents/ItemParts/{RadioAnswerOptionButtons.tsx → RadioOptionList.tsx} +7 -7
  93. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.tsx +18 -50
  94. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx +70 -68
  95. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.tsx +110 -0
  96. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.tsx +188 -0
  97. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.tsx +46 -19
  98. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.tsx +5 -3
  99. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.tsx +37 -29
  100. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.tsx +104 -0
  101. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetItem.tsx +156 -0
  102. package/src/components/FormComponents/StringItem/StringField.tsx +1 -1
  103. package/src/hooks/useInitialiseRenderer.ts +1 -1
  104. package/src/hooks/useNextAndPreviousVisibleTabs.ts +86 -0
  105. package/src/hooks/useOpenLabel.ts +43 -0
  106. package/src/index.ts +0 -21
  107. package/src/stories/BuildFormWrapper.tsx +57 -0
  108. package/src/stories/assets/questionnaires/QAdvancedAdditionalDisplayContent.ts +83 -0
  109. package/src/stories/assets/questionnaires/QAdvancedControlAppearance.ts +294 -0
  110. package/src/stories/assets/questionnaires/QAdvancedOther.ts +495 -0
  111. package/src/stories/assets/questionnaires/QAdvancedTextApperance.ts +188 -0
  112. package/src/stories/assets/questionnaires/QAttachment.ts +38 -0
  113. package/src/stories/assets/questionnaires/QBehaviorCalculations.ts +645 -0
  114. package/src/stories/assets/questionnaires/QBehaviorChoiceRestriction.ts +281 -0
  115. package/src/stories/assets/questionnaires/QBehaviorOther.ts +1149 -0
  116. package/src/stories/assets/questionnaires/QBehaviorValueConstraints.ts +508 -0
  117. package/src/stories/assets/questionnaires/QBoolean.ts +130 -0
  118. package/src/stories/assets/questionnaires/QChoice.ts +137 -0
  119. package/src/stories/assets/questionnaires/QDate.ts +56 -0
  120. package/src/stories/assets/questionnaires/QDateTime.ts +56 -0
  121. package/src/stories/assets/questionnaires/QDecimal.ts +56 -0
  122. package/src/stories/assets/questionnaires/QDisplay.ts +38 -0
  123. package/src/stories/assets/questionnaires/QGroup.ts +52 -0
  124. package/src/stories/assets/questionnaires/QInteger.ts +119 -0
  125. package/src/stories/assets/questionnaires/QItemControlDisplay.ts +114 -0
  126. package/src/stories/assets/questionnaires/QItemControlGroup.ts +419 -0
  127. package/src/stories/assets/questionnaires/QItemControlQuestion.ts +1271 -0
  128. package/src/stories/assets/questionnaires/QOpenChoice.ts +151 -0
  129. package/src/stories/assets/questionnaires/QQuantity.ts +38 -0
  130. package/src/stories/assets/questionnaires/QReference.ts +38 -0
  131. package/src/stories/assets/questionnaires/QSingleItems.ts +251 -0
  132. package/src/stories/assets/questionnaires/QString.ts +131 -0
  133. package/src/stories/assets/questionnaires/QText.ts +169 -0
  134. package/src/stories/assets/questionnaires/QTime.ts +38 -0
  135. package/src/stories/assets/questionnaires/QUrl.ts +38 -0
  136. package/src/stories/assets/questionnaires/index.ts +44 -0
  137. package/src/stories/itemTypes/Attachment.stories.tsx +39 -0
  138. package/src/stories/itemTypes/Boolean.stories.tsx +72 -0
  139. package/src/stories/{MedicalHistoryTable.stories.tsx → itemTypes/Choice.stories.tsx} +32 -26
  140. package/src/stories/itemTypes/Date.stories.tsx +46 -0
  141. package/src/stories/itemTypes/DateTime.stories.tsx +45 -0
  142. package/src/stories/itemTypes/Decimal.stories.tsx +56 -0
  143. package/src/stories/itemTypes/Display.stories.tsx +39 -0
  144. package/src/stories/itemTypes/Group.stories.tsx +39 -0
  145. package/src/stories/itemTypes/Integer.stories.tsx +55 -0
  146. package/src/stories/itemTypes/OpenChoice.stories.tsx +64 -0
  147. package/src/stories/itemTypes/Quantity.stories.tsx +39 -0
  148. package/src/stories/itemTypes/Reference.stories.tsx +39 -0
  149. package/src/stories/itemTypes/String.stories.tsx +51 -0
  150. package/src/stories/itemTypes/Text.stories.tsx +51 -0
  151. package/src/stories/itemTypes/Time.stories.tsx +39 -0
  152. package/src/stories/itemTypes/Url.stories.tsx +39 -0
  153. package/src/stories/sdc/AdvancedAdditionalDisplayContent.stories.tsx +45 -0
  154. package/src/stories/sdc/AdvancedControlAppearance.stories.tsx +51 -0
  155. package/src/stories/sdc/AdvancedOther.stories.tsx +76 -0
  156. package/src/stories/sdc/AdvancedTextAppearance.stories.tsx +69 -0
  157. package/src/stories/sdc/BehaviorCalculations.stories.tsx +69 -0
  158. package/src/stories/sdc/BehaviorChoiceRestriction.stories.tsx +76 -0
  159. package/src/stories/sdc/BehaviorOther.stories.tsx +90 -0
  160. package/src/stories/sdc/BehaviorValueConstraints.stories.tsx +88 -0
  161. package/src/stories/sdc/ItemControlDisplay.stories.tsx +39 -0
  162. package/src/stories/sdc/ItemControlGroup.stories.tsx +55 -0
  163. package/src/stories/sdc/ItemControlQuestion.stories.tsx +118 -0
  164. package/src/utils/buildForm.ts +23 -0
  165. package/src/utils/choice.ts +16 -23
  166. package/src/utils/enableWhen.ts +5 -7
  167. package/src/utils/index.ts +1 -0
  168. package/src/utils/openChoice.ts +83 -98
  169. package/src/utils/tabs.ts +0 -75
  170. package/vite.config.ts +23 -0
  171. package/doctor-storybook.log +0 -18
  172. package/src/stories/SmartFormsRenderer.stories.ts +0 -139
  173. package/src/stories/assets/QItems-and-QRItems/QR_GTableMedicalHistory.json +0 -80
  174. package/src/stories/assets/QItems-and-QRItems/Q_GTableMedicalHistory.json +0 -109
  175. package/src/stories/assets/Qs-and-QRs/Q715.json +0 -15086
  176. package/src/stories/assets/Qs-and-QRs/QDev715.json +0 -16081
  177. package/src/stories/assets/Qs-and-QRs/QTestGrid.json +0 -411
  178. package/src/stories/assets/Qs-and-QRs/R715.json +0 -311
  179. package/src/stories/assets/Qs-and-QRs/RTestGrid.json +0 -34
@@ -0,0 +1,38 @@
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
+ import type { Questionnaire } from 'fhir/r4';
19
+
20
+ export const qAttachmentBasic: Questionnaire = {
21
+ resourceType: 'Questionnaire',
22
+ id: 'AttachmentBasic',
23
+ name: 'AttachmentBasic',
24
+ title: 'Attachment Basic',
25
+ version: '0.1.0',
26
+ status: 'draft',
27
+ publisher: 'AEHRC CSIRO',
28
+ date: '2024-05-01',
29
+ url: 'https://smartforms.csiro.au/docs/components/attachment/basic',
30
+ item: [
31
+ {
32
+ linkId: 'file-attachment',
33
+ type: 'attachment',
34
+ repeats: false,
35
+ text: 'File Attachment'
36
+ }
37
+ ]
38
+ };
@@ -0,0 +1,645 @@
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
+ import type { Questionnaire } from 'fhir/r4';
19
+
20
+ // TODO Add docs on validation is exposed as operationOutcomes
21
+ export const qLaunchContext: Questionnaire = {
22
+ resourceType: 'Questionnaire',
23
+ id: 'LaunchContext',
24
+ name: 'LaunchContext',
25
+ title: 'Launch Context',
26
+ version: '0.1.0',
27
+ status: 'draft',
28
+ publisher: 'AEHRC CSIRO',
29
+ date: '2024-05-01',
30
+ url: 'https://smartforms.csiro.au/docs/behavior/calculations/launch-context',
31
+ item: [
32
+ {
33
+ linkId: 'launch-context-instructions',
34
+ _text: {
35
+ extension: [
36
+ {
37
+ url: 'http://hl7.org/fhir/StructureDefinition/rendering-xhtml',
38
+ valueString:
39
+ '<div xmlns="http://www.w3.org/1999/xhtml">\r\n <p style="font-size:0.875em"> Not defined yet.</p></div>'
40
+ }
41
+ ]
42
+ },
43
+ text: 'Not defined yet.',
44
+ type: 'display',
45
+ repeats: false
46
+ }
47
+ ]
48
+ };
49
+
50
+ export const qVariable: Questionnaire = {
51
+ resourceType: 'Questionnaire',
52
+ id: 'Variable',
53
+ name: 'Variable',
54
+ title: 'Variable',
55
+ version: '0.1.0',
56
+ status: 'draft',
57
+ publisher: 'AEHRC CSIRO',
58
+ date: '2024-05-01',
59
+ url: 'https://smartforms.csiro.au/docs/behavior/calculations/variable',
60
+ item: [
61
+ {
62
+ linkId: 'launch-context-instructions',
63
+ _text: {
64
+ extension: [
65
+ {
66
+ url: 'http://hl7.org/fhir/StructureDefinition/rendering-xhtml',
67
+ valueString:
68
+ '<div xmlns="http://www.w3.org/1999/xhtml">\r\n <p style="font-size:0.875em"> Please refer to the <strong>Calculated Expression</strong> examples below for the usage of variables.</p></div>'
69
+ }
70
+ ]
71
+ },
72
+ text: 'Please refer to the Calculated Expression examples below for the usage of variables.',
73
+ type: 'display',
74
+ repeats: false
75
+ }
76
+ ]
77
+ };
78
+
79
+ // FIXME need to connect to a real FHIR server
80
+ export const qInitialExpression: Questionnaire = {
81
+ resourceType: 'Questionnaire',
82
+ id: 'InitialExpression',
83
+ name: 'InitialExpression',
84
+ title: 'Initial Expression',
85
+ version: '0.1.0',
86
+ status: 'draft',
87
+ publisher: 'AEHRC CSIRO',
88
+ date: '2024-05-01',
89
+ url: 'https://smartforms.csiro.au/docs/behavior/choice-restrictions/initial-expression',
90
+ item: [
91
+ {
92
+ extension: [
93
+ {
94
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
95
+ valueExpression: {
96
+ description: 'deadline for submission',
97
+ language: 'text/fhirpath',
98
+ expression: 'today() + 7 days'
99
+ }
100
+ }
101
+ ],
102
+ linkId: '3.1',
103
+ text: 'Deadline for submission (7 days from now)',
104
+ type: 'date'
105
+ }
106
+ ]
107
+ };
108
+
109
+ export const qCalculatedExpressionBMICalculator: Questionnaire = {
110
+ resourceType: 'Questionnaire',
111
+ id: 'CalculatedExpressionBMICalculator',
112
+ name: 'CalculatedExpressionBMICalculator',
113
+ title: 'Calculated Expression BMI Calculator',
114
+ version: '0.1.0',
115
+ status: 'draft',
116
+ publisher: 'AEHRC CSIRO',
117
+ date: '2024-05-01',
118
+ url: 'https://smartforms.csiro.au/docs/behavior/choice-restrictions/calculated-expression-1',
119
+ item: [
120
+ {
121
+ linkId: 'bmi-calculation',
122
+ text: 'BMI Calculation',
123
+ type: 'group',
124
+ repeats: false,
125
+ extension: [
126
+ {
127
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
128
+ valueExpression: {
129
+ name: 'height',
130
+ language: 'text/fhirpath',
131
+ expression: "item.where(linkId='patient-height').answer.value"
132
+ }
133
+ },
134
+ {
135
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
136
+ valueExpression: {
137
+ name: 'weight',
138
+ language: 'text/fhirpath',
139
+ expression: "item.where(linkId='patient-weight').answer.value"
140
+ }
141
+ }
142
+ ],
143
+ item: [
144
+ {
145
+ extension: [
146
+ {
147
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-unit',
148
+ valueCoding: {
149
+ system: 'http://unitsofmeasure.org',
150
+ code: 'cm',
151
+ display: 'cm'
152
+ }
153
+ }
154
+ ],
155
+ linkId: 'patient-height',
156
+ text: 'Height',
157
+ type: 'decimal',
158
+ repeats: false,
159
+ readOnly: false
160
+ },
161
+ {
162
+ extension: [
163
+ {
164
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-unit',
165
+ valueCoding: {
166
+ system: 'http://unitsofmeasure.org',
167
+ code: 'kg',
168
+ display: 'kg'
169
+ }
170
+ }
171
+ ],
172
+ linkId: 'patient-weight',
173
+ text: 'Weight',
174
+ type: 'decimal',
175
+ repeats: false,
176
+ readOnly: false
177
+ },
178
+ {
179
+ extension: [
180
+ {
181
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression',
182
+ valueExpression: {
183
+ description: 'BMI calculation',
184
+ language: 'text/fhirpath',
185
+ expression: '(%weight/((%height/100).power(2))).round(1)'
186
+ }
187
+ },
188
+ {
189
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-unit',
190
+ valueCoding: {
191
+ system: 'http://unitsofmeasure.org',
192
+ code: 'kg/m2',
193
+ display: 'kg/m2'
194
+ }
195
+ }
196
+ ],
197
+ linkId: 'bmi-result',
198
+ text: 'Value',
199
+ type: 'decimal',
200
+ repeats: false,
201
+ readOnly: true
202
+ }
203
+ ]
204
+ }
205
+ ]
206
+ };
207
+
208
+ export const qCalculatedExpressionCvdRiskCalculator: Questionnaire = {
209
+ resourceType: 'Questionnaire',
210
+ id: 'CalculatedExpressionCvdRiskCalculator',
211
+ name: 'CalculatedExpressionCvdRiskCalculator',
212
+ title: 'Calculated Expression CVD Risk Calculator',
213
+ version: '0.1.0',
214
+ status: 'draft',
215
+ publisher: 'AEHRC CSIRO',
216
+ date: '2024-05-01',
217
+ url: 'https://smartforms.csiro.au/docs/behavior/choice-restrictions/calculated-expression-2',
218
+ item: [
219
+ {
220
+ extension: [
221
+ {
222
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
223
+ valueExpression: {
224
+ name: 'female',
225
+ language: 'text/fhirpath',
226
+ expression: "iif(item.where(linkId='gender').answer.value.code='female', 1, 0)"
227
+ }
228
+ },
229
+ {
230
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
231
+ valueExpression: {
232
+ name: 'age',
233
+ language: 'text/fhirpath',
234
+ expression: "item.where(linkId='patient-age').answer.value"
235
+ }
236
+ },
237
+ {
238
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
239
+ valueExpression: {
240
+ name: 'cvdAge',
241
+ language: 'text/fhirpath',
242
+ expression: 'iif(%age > 74, 74, iif(%age < 35, 35, %age))'
243
+ }
244
+ },
245
+ {
246
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
247
+ valueExpression: {
248
+ name: 'systolicBP',
249
+ language: 'text/fhirpath',
250
+ expression: "item.where(linkId='systolic-blood-pressure').answer.value"
251
+ }
252
+ },
253
+ {
254
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
255
+ valueExpression: {
256
+ name: 'smoker',
257
+ language: 'text/fhirpath',
258
+ expression:
259
+ "iif(item.where(linkId='smoking-status').answer.value.code='77176002', 1, 0)"
260
+ }
261
+ },
262
+ {
263
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
264
+ valueExpression: {
265
+ name: 'totalCh',
266
+ language: 'text/fhirpath',
267
+ expression: "item.where(linkId='total-cholesterol').answer.value"
268
+ }
269
+ },
270
+ {
271
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
272
+ valueExpression: {
273
+ name: 'hdl',
274
+ language: 'text/fhirpath',
275
+ expression: "item.where(linkId='hdl-cholesterol').answer.value"
276
+ }
277
+ },
278
+ {
279
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
280
+ valueExpression: {
281
+ name: 'diabetes',
282
+ language: 'text/fhirpath',
283
+ expression: "iif(item.where(linkId='has-diabetes').answer.value = true,1,0)"
284
+ }
285
+ },
286
+ {
287
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
288
+ valueExpression: {
289
+ name: 'ecgLvh',
290
+ language: 'text/fhirpath',
291
+ expression: "iif(item.where(linkId='ecg-lvh').answer.value = true,1,0)"
292
+ }
293
+ },
294
+ {
295
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
296
+ valueExpression: {
297
+ name: 'cBase',
298
+ language: 'text/fhirpath',
299
+ expression: '18.8144'
300
+ }
301
+ },
302
+ {
303
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
304
+ valueExpression: {
305
+ name: 'cFemale',
306
+ language: 'text/fhirpath',
307
+ expression: '%female * -1.2146'
308
+ }
309
+ },
310
+ {
311
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
312
+ valueExpression: {
313
+ name: 'cAge',
314
+ language: 'text/fhirpath',
315
+ expression: '%cvdAge.ln() * -1.8443'
316
+ }
317
+ },
318
+ {
319
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
320
+ valueExpression: {
321
+ name: 'cAgeFemale',
322
+ language: 'text/fhirpath',
323
+ expression: '%female * %cvdAge.ln() * 0.3668'
324
+ }
325
+ },
326
+ {
327
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
328
+ valueExpression: {
329
+ name: 'cSBP',
330
+ language: 'text/fhirpath',
331
+ expression: '%systolicBP.ln() * -1.4032'
332
+ }
333
+ },
334
+ {
335
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
336
+ valueExpression: {
337
+ name: 'cSmoker',
338
+ language: 'text/fhirpath',
339
+ expression: '%smoker * -0.3899'
340
+ }
341
+ },
342
+ {
343
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
344
+ valueExpression: {
345
+ name: 'cTcHdl',
346
+ language: 'text/fhirpath',
347
+ expression: '(%totalCh / %hdl).ln() * -0.539'
348
+ }
349
+ },
350
+ {
351
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
352
+ valueExpression: {
353
+ name: 'cDiabetes',
354
+ language: 'text/fhirpath',
355
+ expression: '%diabetes * -0.3036'
356
+ }
357
+ },
358
+ {
359
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
360
+ valueExpression: {
361
+ name: 'cDiabetesFemale',
362
+ language: 'text/fhirpath',
363
+ expression: '%female * %diabetes * -0.1697'
364
+ }
365
+ },
366
+ {
367
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
368
+ valueExpression: {
369
+ name: 'cEcgLvh',
370
+ language: 'text/fhirpath',
371
+ expression: '%ecgLvh * -0.3362'
372
+ }
373
+ },
374
+ {
375
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
376
+ valueExpression: {
377
+ name: 'sumOfCoeffs',
378
+ language: 'text/fhirpath',
379
+ expression:
380
+ '%cBase + %cFemale + %cAge + %cAgeFemale + %cSBP + %cSmoker + %cTcHdl + %cDiabetes + %cDiabetesFemale + %cEcgLvh'
381
+ }
382
+ },
383
+ {
384
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
385
+ valueExpression: {
386
+ name: 'cvdScale',
387
+ language: 'text/fhirpath',
388
+ expression: '(0.6536 + (%sumOfCoeffs * -0.2402)).exp()'
389
+ }
390
+ },
391
+ {
392
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
393
+ valueExpression: {
394
+ name: 'cvdU',
395
+ language: 'text/fhirpath',
396
+ expression: '(5.ln()-%sumOfCoeffs)/%cvdScale'
397
+ }
398
+ },
399
+ {
400
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
401
+ valueExpression: {
402
+ name: 'cvdScore',
403
+ language: 'text/fhirpath',
404
+ expression: '(1 - (%cvdU.exp()*-1).exp()) * 100'
405
+ }
406
+ }
407
+ ],
408
+ linkId: 'absolute-cvd-risk-calculation',
409
+ text: 'Absolute Cardiovascular Risk Calculation ',
410
+ type: 'group',
411
+ item: [
412
+ {
413
+ linkId: 'instruction-use-updated-cvd-risk-calculator',
414
+ _text: {
415
+ extension: [
416
+ {
417
+ url: 'http://hl7.org/fhir/StructureDefinition/rendering-xhtml',
418
+ valueString:
419
+ '<div xmlns="http://www.w3.org/1999/xhtml">\r\n <b><p style="font-size:0.875em">NOTE: The Australian guideline for assessing and managing cardiovascular disease risk recommends the use of the online <a href="https://www.cvdcheck.org.au/calculator" target="_blank">Australian CVD risk calculator</a>.</p></b>\r\n <p style="font-size:0.875em">The calculator below should only be used for technology demonstration purposes.</p>\r\n</div>'
420
+ }
421
+ ]
422
+ },
423
+ text: 'NOTE: The Australian guideline for assessing and managing cardiovascular disease risk recommends the use of the online Australian CVD risk calculator (https://www.cvdcheck.org.au/calculator). The calculator below should only be used for technology demonstration purposes.',
424
+ type: 'display',
425
+ repeats: false
426
+ },
427
+ {
428
+ linkId: 'patient-age',
429
+ text: 'Age',
430
+ type: 'integer',
431
+ repeats: false
432
+ },
433
+ {
434
+ extension: [
435
+ {
436
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
437
+ valueCodeableConcept: {
438
+ coding: [
439
+ {
440
+ system: 'http://hl7.org/fhir/questionnaire-item-control',
441
+ code: 'radio-button'
442
+ }
443
+ ]
444
+ }
445
+ }
446
+ ],
447
+ linkId: 'gender',
448
+ text: 'Gender',
449
+ type: 'choice',
450
+ repeats: false,
451
+ answerValueSet: 'http://hl7.org/fhir/ValueSet/administrative-gender'
452
+ },
453
+ {
454
+ extension: [
455
+ {
456
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
457
+ valueCodeableConcept: {
458
+ coding: [
459
+ {
460
+ system: 'http://hl7.org/fhir/questionnaire-item-control',
461
+ code: 'radio-button'
462
+ }
463
+ ]
464
+ }
465
+ }
466
+ ],
467
+ linkId: 'smoking-status',
468
+ text: 'Smoking status',
469
+ type: 'choice',
470
+ repeats: false,
471
+ answerOption: [
472
+ {
473
+ valueCoding: {
474
+ system: 'http://snomed.info/sct',
475
+ code: '266919005',
476
+ display: 'Never smoked'
477
+ }
478
+ },
479
+ {
480
+ valueCoding: {
481
+ system: 'http://snomed.info/sct',
482
+ code: '77176002',
483
+ display: 'Smoker'
484
+ }
485
+ },
486
+ {
487
+ valueCoding: {
488
+ system: 'http://snomed.info/sct',
489
+ code: '8517006',
490
+ display: 'Ex-Smoker'
491
+ }
492
+ },
493
+ {
494
+ valueCoding: {
495
+ system: 'http://snomed.info/sct',
496
+ code: '16090371000119103',
497
+ display: 'Environmental exposure to tobacco smoke (home, car, etc)'
498
+ }
499
+ },
500
+ {
501
+ valueString: 'Wants to quit'
502
+ },
503
+ {
504
+ valueString: 'Other tobacco use'
505
+ }
506
+ ]
507
+ },
508
+ {
509
+ extension: [
510
+ {
511
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-unit',
512
+ valueCoding: {
513
+ system: 'http://unitsofmeasure.org',
514
+ code: 'mm[Hg]',
515
+ display: 'mm Hg'
516
+ }
517
+ }
518
+ ],
519
+ linkId: 'systolic-blood-pressure',
520
+ text: 'Systolic Blood Pressure',
521
+ type: 'decimal',
522
+ item: [
523
+ {
524
+ extension: [
525
+ {
526
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
527
+ valueCodeableConcept: {
528
+ coding: [
529
+ {
530
+ system: 'http://hl7.org/fhir/questionnaire-item-control',
531
+ code: 'prompt'
532
+ }
533
+ ]
534
+ }
535
+ }
536
+ ],
537
+ linkId: 'systolic-blood-pressure-prompt',
538
+ text: '75 or more',
539
+ type: 'display'
540
+ }
541
+ ]
542
+ },
543
+ {
544
+ extension: [
545
+ {
546
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-unit',
547
+ valueCoding: {
548
+ system: 'http://unitsofmeasure.org',
549
+ code: 'mmol/L',
550
+ display: 'mmol/L'
551
+ }
552
+ }
553
+ ],
554
+ linkId: 'total-cholesterol',
555
+ text: 'Total Cholesterol',
556
+ type: 'decimal',
557
+ item: [
558
+ {
559
+ extension: [
560
+ {
561
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
562
+ valueCodeableConcept: {
563
+ coding: [
564
+ {
565
+ system: 'http://hl7.org/fhir/questionnaire-item-control',
566
+ code: 'prompt'
567
+ }
568
+ ]
569
+ }
570
+ }
571
+ ],
572
+ linkId: 'total-cholesterol-prompt',
573
+ text: '2 or more',
574
+ type: 'display'
575
+ }
576
+ ]
577
+ },
578
+ {
579
+ extension: [
580
+ {
581
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-unit',
582
+ valueCoding: {
583
+ system: 'http://unitsofmeasure.org',
584
+ code: 'mmol/L',
585
+ display: 'mmol/L'
586
+ }
587
+ }
588
+ ],
589
+ linkId: 'hdl-cholesterol',
590
+ text: 'HDL Cholesterol',
591
+ type: 'decimal',
592
+ item: [
593
+ {
594
+ extension: [
595
+ {
596
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
597
+ valueCodeableConcept: {
598
+ coding: [
599
+ {
600
+ system: 'http://hl7.org/fhir/questionnaire-item-control',
601
+ code: 'prompt'
602
+ }
603
+ ]
604
+ }
605
+ }
606
+ ],
607
+ linkId: 'hdl-cholesterol-prompt',
608
+ text: 'Between 0.2 - 5',
609
+ type: 'display'
610
+ }
611
+ ]
612
+ },
613
+ {
614
+ linkId: 'has-diabetes',
615
+ text: 'Diabetes',
616
+ type: 'boolean',
617
+ repeats: false
618
+ },
619
+ {
620
+ linkId: 'ecg-lvh',
621
+ text: 'ECG LVH',
622
+ type: 'boolean',
623
+ repeats: false
624
+ },
625
+ {
626
+ extension: [
627
+ {
628
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression',
629
+ valueExpression: {
630
+ description: 'CVD Risk Score',
631
+ language: 'text/fhirpath',
632
+ expression: '%cvdScore.round(0)'
633
+ }
634
+ }
635
+ ],
636
+ linkId: 'cvd-result',
637
+ text: 'Cardiovascular disease risk calculated result',
638
+ type: 'integer',
639
+ repeats: false,
640
+ readOnly: true
641
+ }
642
+ ]
643
+ }
644
+ ]
645
+ };