@aehrc/smart-forms-renderer 0.30.2 → 0.31.0

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 (255) hide show
  1. package/README.md +6 -6
  2. package/lib/components/FormComponents/BooleanItem/BooleanField.js +5 -4
  3. package/lib/components/FormComponents/BooleanItem/BooleanField.js.map +1 -1
  4. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js +5 -4
  5. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js.map +1 -1
  6. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js +5 -4
  7. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js.map +1 -1
  8. package/lib/components/FormComponents/DateTimeItems/index.d.ts +1 -1
  9. package/lib/components/FormComponents/DateTimeItems/index.js +1 -1
  10. package/lib/components/FormComponents/DateTimeItems/index.js.map +1 -1
  11. package/lib/components/FormComponents/DateTimeItems/utils/parseDate.d.ts +5 -0
  12. package/lib/components/FormComponents/DateTimeItems/utils/parseDate.js +5 -0
  13. package/lib/components/FormComponents/DateTimeItems/utils/parseDate.js.map +1 -1
  14. package/lib/components/FormComponents/GridGroup/GridGroup.d.ts +6 -0
  15. package/lib/components/FormComponents/GridGroup/GridGroup.js +6 -0
  16. package/lib/components/FormComponents/GridGroup/GridGroup.js.map +1 -1
  17. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.d.ts +6 -0
  18. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +6 -0
  19. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
  20. package/lib/components/FormComponents/RepeatItem/RepeatItem.d.ts +5 -0
  21. package/lib/components/FormComponents/RepeatItem/RepeatItem.js +5 -0
  22. package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
  23. package/lib/components/FormComponents/SingleItem/SingleItem.d.ts +6 -0
  24. package/lib/components/FormComponents/SingleItem/SingleItem.js +6 -0
  25. package/lib/components/FormComponents/SingleItem/SingleItem.js.map +1 -1
  26. package/lib/components/FormComponents/Tables/GroupTable.d.ts +6 -0
  27. package/lib/components/FormComponents/Tables/GroupTable.js +6 -0
  28. package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -1
  29. package/lib/components/FormComponents/index.d.ts +6 -6
  30. package/lib/components/FormComponents/index.js +6 -6
  31. package/lib/components/FormComponents/index.js.map +1 -1
  32. package/lib/components/Renderer/BaseRenderer.d.ts +7 -0
  33. package/lib/components/Renderer/BaseRenderer.js +7 -0
  34. package/lib/components/Renderer/BaseRenderer.js.map +1 -1
  35. package/lib/components/Renderer/SmartFormsRenderer.d.ts +22 -1
  36. package/lib/components/Renderer/SmartFormsRenderer.js +16 -6
  37. package/lib/components/Renderer/SmartFormsRenderer.js.map +1 -1
  38. package/lib/components/Renderer/index.d.ts +1 -0
  39. package/lib/components/Renderer/index.js.map +1 -1
  40. package/lib/components/index.d.ts +3 -2
  41. package/lib/components/index.js +2 -2
  42. package/lib/components/index.js.map +1 -1
  43. package/lib/hooks/index.d.ts +2 -0
  44. package/lib/hooks/index.js +2 -0
  45. package/lib/hooks/index.js.map +1 -1
  46. package/lib/hooks/useBuildForm.d.ts +15 -0
  47. package/lib/hooks/useBuildForm.js +41 -0
  48. package/lib/hooks/useBuildForm.js.map +1 -0
  49. package/lib/hooks/useHidden.d.ts +6 -0
  50. package/lib/hooks/useHidden.js +6 -0
  51. package/lib/hooks/useHidden.js.map +1 -1
  52. package/lib/hooks/useInitaliseFhirClient.d.ts +1 -0
  53. package/lib/hooks/useInitaliseFhirClient.js +55 -0
  54. package/lib/hooks/useInitaliseFhirClient.js.map +1 -0
  55. package/lib/hooks/useInitialiseForm.d.ts +20 -0
  56. package/lib/hooks/useInitialiseForm.js +72 -0
  57. package/lib/hooks/useInitialiseForm.js.map +1 -0
  58. package/lib/hooks/useInitialiseRenderer.d.ts +1 -1
  59. package/lib/hooks/useInitialiseRenderer.js +8 -31
  60. package/lib/hooks/useInitialiseRenderer.js.map +1 -1
  61. package/lib/hooks/useRendererQueryClient.d.ts +10 -0
  62. package/lib/hooks/useRendererQueryClient.js +36 -0
  63. package/lib/hooks/useRendererQueryClient.js.map +1 -0
  64. package/lib/hooks/useValueSetCodings.js +1 -0
  65. package/lib/hooks/useValueSetCodings.js.map +1 -1
  66. package/lib/index.d.ts +10 -40
  67. package/lib/index.js +8 -77
  68. package/lib/index.js.map +1 -1
  69. package/lib/interfaces/calculatedExpression.interface.d.ts +7 -0
  70. package/lib/interfaces/calculatedExpression.interface.js +16 -0
  71. package/lib/interfaces/calculatedExpression.interface.js.map +1 -1
  72. package/lib/interfaces/enableWhen.interface.d.ts +12 -0
  73. package/lib/interfaces/index.d.ts +4 -1
  74. package/lib/interfaces/index.js +16 -0
  75. package/lib/interfaces/index.js.map +1 -1
  76. package/lib/interfaces/populate.interface.d.ts +6 -0
  77. package/lib/interfaces/repopulateItems.interface.d.ts +0 -0
  78. package/lib/interfaces/repopulateItems.interface.js +2 -0
  79. package/lib/interfaces/repopulateItems.interface.js.map +1 -0
  80. package/lib/interfaces/tab.interface.d.ts +10 -0
  81. package/lib/interfaces/tab.interface.js +16 -0
  82. package/lib/interfaces/tab.interface.js.map +1 -1
  83. package/lib/interfaces/variables.interface.d.ts +12 -0
  84. package/lib/stores/index.d.ts +4 -0
  85. package/lib/stores/index.js.map +1 -1
  86. package/lib/stores/questionnaireResponseStore.d.ts +37 -2
  87. package/lib/stores/questionnaireResponseStore.js +72 -22
  88. package/lib/stores/questionnaireResponseStore.js.map +1 -1
  89. package/lib/stores/questionnaireStore.d.ts +59 -3
  90. package/lib/stores/questionnaireStore.js +18 -0
  91. package/lib/stores/questionnaireStore.js.map +1 -1
  92. package/lib/stores/smartConfigStore.d.ts +37 -0
  93. package/lib/stores/smartConfigStore.js +21 -0
  94. package/lib/stores/smartConfigStore.js.map +1 -1
  95. package/lib/stores/terminologyServerStore.d.ts +28 -2
  96. package/lib/stores/terminologyServerStore.js +16 -0
  97. package/lib/stores/terminologyServerStore.js.map +1 -1
  98. package/lib/stories/InitialiseFormWrapperForStorybook.d.ts +29 -0
  99. package/lib/stories/InitialiseFormWrapperForStorybook.js +65 -0
  100. package/lib/stories/InitialiseFormWrapperForStorybook.js.map +1 -0
  101. package/lib/stories/StorybookWrappers/BuildFormButtonForStorybook.d.ts +8 -0
  102. package/lib/stories/StorybookWrappers/BuildFormButtonForStorybook.js +44 -0
  103. package/lib/stories/StorybookWrappers/BuildFormButtonForStorybook.js.map +1 -0
  104. package/lib/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.d.ts +18 -0
  105. package/lib/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.js +48 -0
  106. package/lib/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.js.map +1 -0
  107. package/lib/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.d.ts +31 -0
  108. package/lib/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.js +67 -0
  109. package/lib/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.js.map +1 -0
  110. package/lib/stories/StorybookWrappers/PrePopButtonForStorybook.d.ts +7 -0
  111. package/lib/stories/StorybookWrappers/PrePopButtonForStorybook.js +32 -0
  112. package/lib/stories/StorybookWrappers/PrePopButtonForStorybook.js.map +1 -0
  113. package/lib/stories/StorybookWrappers/PrePopWrapperForStorybook.d.ts +21 -0
  114. package/lib/stories/StorybookWrappers/PrePopWrapperForStorybook.js +83 -0
  115. package/lib/stories/StorybookWrappers/PrePopWrapperForStorybook.js.map +1 -0
  116. package/lib/stories/StorybookWrappers/index.d.ts +3 -0
  117. package/lib/stories/StorybookWrappers/index.js +20 -0
  118. package/lib/stories/StorybookWrappers/index.js.map +1 -0
  119. package/lib/stories/StorybookWrappers/populateCallbackForStorybook.d.ts +8 -0
  120. package/lib/stories/StorybookWrappers/populateCallbackForStorybook.js +46 -0
  121. package/lib/stories/StorybookWrappers/populateCallbackForStorybook.js.map +1 -0
  122. package/lib/stories/index.d.ts +1 -0
  123. package/lib/stories/index.js +18 -0
  124. package/lib/stories/index.js.map +1 -0
  125. package/lib/theme/Theme.d.ts +8 -2
  126. package/lib/theme/Theme.js +8 -2
  127. package/lib/theme/Theme.js.map +1 -1
  128. package/lib/theme/index.d.ts +1 -0
  129. package/lib/theme/index.js +2 -0
  130. package/lib/theme/index.js.map +1 -0
  131. package/lib/utils/enableWhen.d.ts +1 -1
  132. package/lib/utils/enableWhenExpression.d.ts +1 -1
  133. package/lib/utils/fhirpath.d.ts +1 -1
  134. package/lib/utils/index.d.ts +5 -3
  135. package/lib/utils/index.js +4 -3
  136. package/lib/utils/index.js.map +1 -1
  137. package/lib/utils/initialise.d.ts +2 -2
  138. package/lib/utils/initialise.js +1 -1
  139. package/lib/utils/manageForm.d.ts +45 -0
  140. package/lib/utils/manageForm.js +101 -0
  141. package/lib/utils/manageForm.js.map +1 -0
  142. package/lib/utils/qItem.d.ts +1 -1
  143. package/lib/utils/questionnaireStoreUtils/extractOtherExtensions.d.ts +1 -1
  144. package/lib/utils/removeEmptyAnswers.d.ts +1 -1
  145. package/lib/utils/repopulateIntoResponse.d.ts +6 -0
  146. package/lib/utils/repopulateIntoResponse.js +11 -0
  147. package/lib/utils/repopulateIntoResponse.js.map +1 -1
  148. package/lib/utils/repopulateItems.d.ts +19 -1
  149. package/lib/utils/repopulateItems.js +23 -0
  150. package/lib/utils/repopulateItems.js.map +1 -1
  151. package/lib/utils/tabs.d.ts +2 -2
  152. package/lib/utils/tabs.js +1 -1
  153. package/lib/utils/validateQuestionnaire.d.ts +0 -4
  154. package/lib/utils/validateQuestionnaire.js +9 -5
  155. package/lib/utils/validateQuestionnaire.js.map +1 -1
  156. package/package.json +1 -1
  157. package/src/components/FormComponents/BooleanItem/BooleanField.tsx +11 -9
  158. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.tsx +11 -9
  159. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx +11 -9
  160. package/src/components/FormComponents/DateTimeItems/index.ts +1 -1
  161. package/src/components/FormComponents/DateTimeItems/utils/parseDate.ts +5 -0
  162. package/src/components/FormComponents/GridGroup/GridGroup.tsx +6 -0
  163. package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +6 -0
  164. package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +5 -0
  165. package/src/components/FormComponents/SingleItem/SingleItem.tsx +6 -0
  166. package/src/components/FormComponents/Tables/GroupTable.tsx +6 -0
  167. package/src/components/FormComponents/index.ts +6 -6
  168. package/src/components/Renderer/BaseRenderer.tsx +7 -0
  169. package/src/components/Renderer/SmartFormsRenderer.tsx +34 -11
  170. package/src/components/Renderer/index.ts +1 -0
  171. package/src/components/index.ts +10 -2
  172. package/src/hooks/index.ts +2 -0
  173. package/src/hooks/useBuildForm.ts +58 -0
  174. package/src/hooks/useHidden.ts +6 -0
  175. package/src/hooks/useInitialiseForm.ts +93 -0
  176. package/src/hooks/{useQueryClient.ts → useRendererQueryClient.ts} +9 -2
  177. package/src/hooks/useValueSetCodings.ts +1 -0
  178. package/src/index.ts +59 -96
  179. package/src/interfaces/calculatedExpression.interface.ts +24 -0
  180. package/src/interfaces/enableWhen.interface.ts +12 -0
  181. package/src/interfaces/index.ts +21 -10
  182. package/src/interfaces/populate.interface.ts +6 -0
  183. package/src/interfaces/tab.interface.ts +12 -0
  184. package/src/interfaces/variables.interface.ts +12 -0
  185. package/src/stores/index.ts +7 -0
  186. package/src/stores/questionnaireResponseStore.ts +90 -19
  187. package/src/stores/questionnaireStore.ts +62 -2
  188. package/src/stores/smartConfigStore.ts +37 -0
  189. package/src/stores/terminologyServerStore.ts +28 -1
  190. package/src/stories/{BuildFormButtonForStorybook.tsx → StorybookWrappers/BuildFormButtonForStorybook.tsx} +12 -5
  191. package/src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx +70 -0
  192. package/src/stories/{BuildFormWrapper.tsx → StorybookWrappers/BuildFormWrapperForStorybook.tsx} +11 -12
  193. package/src/stories/{BuildFormButtonTesterWrapper.tsx → StorybookWrappers/FormValidationTesterWrapperForStorybook.tsx} +22 -19
  194. package/src/stories/{useBuildFormForStorybook.ts → StorybookWrappers/FormValidationViewerForStorybook.tsx} +7 -16
  195. package/src/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.tsx +105 -0
  196. package/src/stories/{PrePopButtonForStorybook.tsx → StorybookWrappers/PrePopButtonForStorybook.tsx} +12 -10
  197. package/src/stories/{PrePopWrapper.tsx → StorybookWrappers/PrePopWrapperForStorybook.tsx} +22 -14
  198. package/src/stories/StorybookWrappers/ValidateFormButtonForStorybook.tsx +41 -0
  199. package/src/stories/StorybookWrappers/index.ts +20 -0
  200. package/src/stories/{populateCallbackForStorybook.ts → StorybookWrappers/populateCallbackForStorybook.ts} +8 -2
  201. package/src/stories/assets/questionnaires/QButtonTester.ts +380 -0
  202. package/src/stories/assets/questionnaires/QValidateTester.ts +118 -0
  203. package/src/stories/itemTypes/Attachment.stories.tsx +3 -3
  204. package/src/stories/itemTypes/Boolean.stories.tsx +3 -3
  205. package/src/stories/itemTypes/Choice.stories.tsx +3 -3
  206. package/src/stories/itemTypes/Date.stories.tsx +3 -3
  207. package/src/stories/itemTypes/DateTime.stories.tsx +3 -3
  208. package/src/stories/itemTypes/Decimal.stories.tsx +3 -3
  209. package/src/stories/itemTypes/Display.stories.tsx +3 -3
  210. package/src/stories/itemTypes/Group.stories.tsx +3 -3
  211. package/src/stories/itemTypes/Integer.stories.tsx +3 -3
  212. package/src/stories/itemTypes/OpenChoice.stories.tsx +3 -3
  213. package/src/stories/itemTypes/Quantity.stories.tsx +3 -3
  214. package/src/stories/itemTypes/Reference.stories.tsx +3 -3
  215. package/src/stories/itemTypes/String.stories.tsx +3 -3
  216. package/src/stories/itemTypes/Text.stories.tsx +3 -3
  217. package/src/stories/itemTypes/Time.stories.tsx +3 -3
  218. package/src/stories/itemTypes/Url.stories.tsx +3 -3
  219. package/src/stories/sdc/AdvancedAdditionalDisplayContent.stories.tsx +3 -3
  220. package/src/stories/sdc/AdvancedControlAppearance.stories.tsx +3 -3
  221. package/src/stories/sdc/AdvancedOther.stories.tsx +3 -3
  222. package/src/stories/sdc/AdvancedTextAppearance.stories.tsx +3 -3
  223. package/src/stories/sdc/BehaviorCalculations.stories.tsx +3 -3
  224. package/src/stories/sdc/BehaviorChoiceRestriction.stories.tsx +3 -3
  225. package/src/stories/sdc/BehaviorOther.stories.tsx +3 -3
  226. package/src/stories/sdc/BehaviorValueConstraints.stories.tsx +3 -3
  227. package/src/stories/sdc/FormPopulation.stories.tsx +3 -3
  228. package/src/stories/sdc/ItemControlDisplay.stories.tsx +3 -3
  229. package/src/stories/sdc/ItemControlGroup.stories.tsx +3 -3
  230. package/src/stories/sdc/ItemControlQuestion.stories.tsx +3 -3
  231. package/src/stories/{rebuildForm/BuildFormTesterWrapper.stories.tsx → testing/BuildFormButtonTesterWrapper.stories.tsx} +6 -9
  232. package/src/stories/testing/PrePopButtonTesterWrapper.stories.tsx +45 -0
  233. package/src/stories/testing/ValidateFormTesterWrapper.stories.tsx +39 -0
  234. package/src/tests/enableWhen.test.ts +6 -2
  235. package/src/theme/Theme.tsx +8 -2
  236. package/src/theme/index.ts +1 -0
  237. package/src/utils/enableWhen.ts +1 -1
  238. package/src/utils/enableWhenExpression.ts +1 -1
  239. package/src/utils/fhirpath.ts +1 -1
  240. package/src/utils/index.ts +5 -7
  241. package/src/utils/initialise.ts +2 -2
  242. package/src/utils/manageForm.ts +110 -0
  243. package/src/utils/qItem.ts +1 -1
  244. package/src/utils/questionnaireStoreUtils/extractOtherExtensions.ts +1 -1
  245. package/src/utils/removeEmptyAnswers.ts +1 -1
  246. package/src/utils/repopulateIntoResponse.ts +17 -0
  247. package/src/utils/repopulateItems.ts +38 -1
  248. package/src/utils/tabs.ts +2 -2
  249. package/src/utils/validateQuestionnaire.ts +12 -17
  250. package/vite.config.ts +1 -1
  251. package/src/hooks/useInitialiseRenderer.ts +0 -114
  252. package/src/stories/assets/questionnaires/QBuildFormButtonTester.ts +0 -270
  253. package/src/stories/populateUtilsForStorybook.ts +0 -545
  254. package/src/utils/buildForm.ts +0 -23
  255. /package/.storybook/{preview.ts → preview.tsx} +0 -0
@@ -0,0 +1,380 @@
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, QuestionnaireResponse } from 'fhir/r4';
19
+
20
+ export const qButtonTester: Questionnaire = {
21
+ resourceType: 'Questionnaire',
22
+ id: 'ButtonTester',
23
+ name: 'ButtonTester',
24
+ title: 'Button Tester',
25
+ version: '0.1.0',
26
+ status: 'draft',
27
+ publisher: 'AEHRC CSIRO',
28
+ date: '2024-05-01',
29
+ url: 'https://smartforms.csiro.au/docs/tester/button',
30
+ extension: [
31
+ {
32
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
33
+ valueExpression: {
34
+ name: 'AllConditions',
35
+ language: 'application/x-fhir-query',
36
+ expression: 'Condition?patient={{%patient.id}}'
37
+ }
38
+ },
39
+ {
40
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
41
+ valueExpression: {
42
+ name: 'DecimalObsBodyWeight',
43
+ language: 'application/x-fhir-query',
44
+ expression: 'Observation?code=29463-7&_count=1&_sort=-date&patient={{%patient.id}}'
45
+ }
46
+ },
47
+ {
48
+ url: 'http://hl7.org/fhir/StructureDefinition/variable',
49
+ valueExpression: {
50
+ name: 'IntegerObsBloodPressure',
51
+ language: 'application/x-fhir-query',
52
+ expression: 'Observation?code=85354-9&_count=1&_sort=-date&patient={{%patient.id}}'
53
+ }
54
+ },
55
+ {
56
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-launchContext',
57
+ extension: [
58
+ {
59
+ url: 'name',
60
+ valueCoding: {
61
+ system: 'http://hl7.org/fhir/uv/sdc/CodeSystem/launchContext',
62
+ code: 'patient'
63
+ }
64
+ },
65
+ {
66
+ url: 'type',
67
+ valueCode: 'Patient'
68
+ },
69
+ {
70
+ url: 'description',
71
+ valueString: 'The patient that is to be used to pre-populate the form'
72
+ }
73
+ ]
74
+ }
75
+ ],
76
+ item: [
77
+ {
78
+ extension: [
79
+ {
80
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
81
+ valueExpression: {
82
+ language: 'text/fhirpath',
83
+ expression: '%DecimalObsBodyWeight.entry.resource.value.value'
84
+ }
85
+ }
86
+ ],
87
+ linkId: 'decimal',
88
+ type: 'decimal',
89
+ repeats: false,
90
+ text: 'Decimal Test'
91
+ },
92
+ {
93
+ extension: [
94
+ {
95
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
96
+ valueExpression: {
97
+ language: 'text/fhirpath',
98
+ expression:
99
+ "%IntegerObsBloodPressure.entry.resource.component.where(code.coding.exists(code='8480-6')).value.value"
100
+ }
101
+ }
102
+ ],
103
+ linkId: 'integer',
104
+ type: 'integer',
105
+ repeats: false,
106
+ text: 'Integer Test'
107
+ },
108
+ {
109
+ extension: [
110
+ {
111
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
112
+ valueExpression: {
113
+ language: 'text/fhirpath',
114
+ expression: "(%patient.name.where(use='official').select(family) | text).first()"
115
+ }
116
+ }
117
+ ],
118
+ linkId: 'string',
119
+ type: 'string',
120
+ repeats: false,
121
+ text: 'String Test'
122
+ },
123
+ {
124
+ extension: [
125
+ {
126
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
127
+ valueExpression: {
128
+ language: 'text/fhirpath',
129
+ expression:
130
+ "%patient.address.where(use='home' and (type.empty() or type!='postal')).select(line.join(', '))"
131
+ }
132
+ }
133
+ ],
134
+ linkId: 'text',
135
+ type: 'text',
136
+ repeats: false,
137
+ text: 'Text Test'
138
+ },
139
+ {
140
+ extension: [
141
+ {
142
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
143
+ valueExpression: {
144
+ language: 'text/fhirpath',
145
+ expression: '%patient.birthDate'
146
+ }
147
+ }
148
+ ],
149
+ linkId: 'date',
150
+ type: 'date',
151
+ repeats: false,
152
+ text: 'Date Test'
153
+ },
154
+ {
155
+ extension: [
156
+ {
157
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
158
+ valueExpression: {
159
+ language: 'text/fhirpath',
160
+ expression: '%patient.birthDate'
161
+ }
162
+ }
163
+ ],
164
+ linkId: 'dateTime',
165
+ type: 'dateTime',
166
+ repeats: false,
167
+ text: 'DateTime Test'
168
+ },
169
+ {
170
+ linkId: 'repeats-container',
171
+ type: 'group',
172
+ repeats: false,
173
+ text: '',
174
+ item: [
175
+ {
176
+ extension: [
177
+ {
178
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
179
+ valueExpression: {
180
+ language: 'text/fhirpath',
181
+ expression: "%patient.telecom.where(system = 'phone' and use = 'home').value"
182
+ }
183
+ }
184
+ ],
185
+ linkId: 'repeats-string',
186
+ type: 'string',
187
+ repeats: true,
188
+ text: 'Repeats Test (String)'
189
+ }
190
+ ]
191
+ },
192
+ {
193
+ extension: [
194
+ {
195
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext',
196
+ valueExpression: {
197
+ name: 'PostalAddressRepeat',
198
+ language: 'text/fhirpath',
199
+ expression: "%patient.address.where(type='postal')"
200
+ }
201
+ }
202
+ ],
203
+ linkId: 'repeats-group',
204
+ type: 'group',
205
+ repeats: true,
206
+ text: 'Repeats Group Test',
207
+ item: [
208
+ {
209
+ extension: [
210
+ {
211
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
212
+ valueExpression: {
213
+ language: 'text/fhirpath',
214
+ expression: '%PostalAddressRepeat.city'
215
+ }
216
+ }
217
+ ],
218
+ linkId: 'repeats-group-string',
219
+ text: 'String',
220
+ type: 'string',
221
+ repeats: false
222
+ },
223
+ {
224
+ extension: [
225
+ {
226
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
227
+ valueExpression: {
228
+ language: 'text/fhirpath',
229
+ expression: '%PostalAddressRepeat.state'
230
+ }
231
+ }
232
+ ],
233
+ linkId: 'repeats-group-choice',
234
+ text: 'Choice',
235
+ type: 'choice',
236
+ repeats: false,
237
+ answerValueSet:
238
+ 'https://healthterminologies.gov.au/fhir/ValueSet/australian-states-territories-2'
239
+ }
240
+ ]
241
+ }
242
+ ]
243
+ };
244
+
245
+ export const qrButtonTesterResponse: QuestionnaireResponse = {
246
+ resourceType: 'QuestionnaireResponse',
247
+ status: 'in-progress',
248
+ item: [
249
+ {
250
+ linkId: 'decimal',
251
+ text: 'Decimal Test',
252
+ answer: [
253
+ {
254
+ valueDecimal: 123.45
255
+ }
256
+ ]
257
+ },
258
+ {
259
+ linkId: 'integer',
260
+ text: 'Integer Test',
261
+ answer: [
262
+ {
263
+ valueInteger: 123
264
+ }
265
+ ]
266
+ },
267
+ {
268
+ linkId: 'string',
269
+ text: 'String Test',
270
+ answer: [
271
+ {
272
+ valueString: 'Sample String'
273
+ }
274
+ ]
275
+ },
276
+ {
277
+ linkId: 'text',
278
+ text: 'Text Test',
279
+ answer: [
280
+ {
281
+ valueString: 'Sample Text'
282
+ }
283
+ ]
284
+ },
285
+ {
286
+ linkId: 'date',
287
+ text: 'Date Test',
288
+ answer: [
289
+ {
290
+ valueDate: '2024-05-20'
291
+ }
292
+ ]
293
+ },
294
+ {
295
+ linkId: 'dateTime',
296
+ text: 'DateTime Test',
297
+ answer: [
298
+ {
299
+ valueDateTime: '2024-05-20T15:30:00Z'
300
+ }
301
+ ]
302
+ },
303
+ {
304
+ linkId: 'repeats-container',
305
+ text: '',
306
+ item: [
307
+ {
308
+ linkId: 'repeats-string',
309
+ text: 'Repeats Test (String)',
310
+ answer: [
311
+ {
312
+ valueString: 'First String'
313
+ },
314
+ {
315
+ valueString: 'Second String'
316
+ }
317
+ ]
318
+ }
319
+ ]
320
+ },
321
+ {
322
+ linkId: 'repeats-group',
323
+ text: 'Repeats Group Test',
324
+ item: [
325
+ {
326
+ linkId: 'repeats-group-string',
327
+ text: 'String',
328
+ answer: [
329
+ {
330
+ valueString: 'Nested String 1'
331
+ }
332
+ ]
333
+ },
334
+ {
335
+ linkId: 'repeats-group-choice',
336
+ text: 'Choice',
337
+ answer: [
338
+ {
339
+ valueCoding: {
340
+ system:
341
+ 'https://healthterminologies.gov.au/fhir/CodeSystem/australian-states-territories-1',
342
+ code: 'NSW'
343
+ }
344
+ }
345
+ ]
346
+ }
347
+ ]
348
+ },
349
+ {
350
+ linkId: 'repeats-group',
351
+ text: 'Repeats Group Test',
352
+ item: [
353
+ {
354
+ linkId: 'repeats-group-string',
355
+ text: 'String',
356
+ answer: [
357
+ {
358
+ valueString: 'Nested String 2'
359
+ }
360
+ ]
361
+ },
362
+ {
363
+ linkId: 'repeats-group-choice',
364
+ text: 'Choice',
365
+ answer: [
366
+ {
367
+ valueCoding: {
368
+ system:
369
+ 'https://healthterminologies.gov.au/fhir/CodeSystem/australian-states-territories-1',
370
+ code: 'SA'
371
+ }
372
+ }
373
+ ]
374
+ }
375
+ ]
376
+ }
377
+ ],
378
+
379
+ questionnaire: 'https://smartforms.csiro.au/docs/tester/button'
380
+ };
@@ -0,0 +1,118 @@
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 qValidateTester: Questionnaire = {
21
+ resourceType: 'Questionnaire',
22
+ id: 'ValidateTester',
23
+ name: 'ValidateTester',
24
+ title: 'Validate Tester',
25
+ version: '0.1.0',
26
+ status: 'draft',
27
+ publisher: 'AEHRC CSIRO',
28
+ date: '2024-05-01',
29
+ url: 'https://smartforms.csiro.au/docs/tester/validate',
30
+ item: [
31
+ {
32
+ linkId: 'required',
33
+ text: 'Required',
34
+ type: 'boolean',
35
+ repeats: false,
36
+ required: true
37
+ },
38
+ {
39
+ linkId: 'maxlength',
40
+ text: 'Max Length (10)',
41
+ type: 'string',
42
+ repeats: false,
43
+ maxLength: 10
44
+ },
45
+ {
46
+ extension: [
47
+ {
48
+ url: 'http://hl7.org/fhir/StructureDefinition/minLength',
49
+ valueInteger: 10
50
+ }
51
+ ],
52
+ linkId: 'minlength',
53
+ text: 'Min Length (10)',
54
+ type: 'string',
55
+ repeats: false
56
+ },
57
+ {
58
+ extension: [
59
+ {
60
+ url: 'http://hl7.org/fhir/StructureDefinition/regex',
61
+ valueString: "matches('^[0-9]{4}$')"
62
+ },
63
+ {
64
+ url: 'http://hl7.org/fhir/StructureDefinition/entryFormat',
65
+ valueString: '####'
66
+ }
67
+ ],
68
+ linkId: 'regex',
69
+ text: 'Regex (####)',
70
+ type: 'string',
71
+ repeats: false
72
+ },
73
+ {
74
+ extension: [
75
+ {
76
+ url: 'http://hl7.org/fhir/StructureDefinition/maxValue',
77
+ valueInteger: 65
78
+ }
79
+ ],
80
+ linkId: 'maxvalue',
81
+ text: 'Max Value (<=65)',
82
+ type: 'integer',
83
+ repeats: false
84
+ },
85
+ {
86
+ extension: [
87
+ {
88
+ url: 'http://hl7.org/fhir/StructureDefinition/minValue',
89
+ valueInteger: 18
90
+ }
91
+ ],
92
+ linkId: 'minvalue',
93
+ text: 'Min Value (>=18)',
94
+ type: 'integer',
95
+ repeats: false
96
+ },
97
+ {
98
+ extension: [
99
+ {
100
+ url: 'http://hl7.org/fhir/StructureDefinition/maxDecimalPlaces',
101
+ valueInteger: 2
102
+ },
103
+ {
104
+ url: 'http://hl7.org/fhir/StructureDefinition/questionnaire-unit',
105
+ valueCoding: {
106
+ system: 'http://unitsofmeasure.org',
107
+ code: 'kg',
108
+ display: 'kg'
109
+ }
110
+ }
111
+ ],
112
+ linkId: 'maxdecimalplaces',
113
+ text: 'Max Decimal Places (2)',
114
+ type: 'decimal',
115
+ repeats: false
116
+ }
117
+ ]
118
+ };
@@ -16,16 +16,16 @@
16
16
  */
17
17
 
18
18
  import type { Meta, StoryObj } from '@storybook/react';
19
- import BuildFormWrapper from '../BuildFormWrapper';
19
+ import BuildFormWrapperForStorybook from '../StorybookWrappers/BuildFormWrapperForStorybook';
20
20
  import { qAttachmentBasic } from '../assets/questionnaires';
21
21
 
22
22
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
23
23
  const meta = {
24
24
  title: 'Component/ItemType/Attachment',
25
- component: BuildFormWrapper,
25
+ component: BuildFormWrapperForStorybook,
26
26
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
27
27
  tags: []
28
- } satisfies Meta<typeof BuildFormWrapper>;
28
+ } satisfies Meta<typeof BuildFormWrapperForStorybook>;
29
29
 
30
30
  export default meta;
31
31
  type Story = StoryObj<typeof meta>;
@@ -21,15 +21,15 @@ import {
21
21
  qBooleanCalculation,
22
22
  qrBooleanBasicResponse
23
23
  } from '../assets/questionnaires';
24
- import BuildFormWrapper from '../BuildFormWrapper'; // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
24
+ import BuildFormWrapperForStorybook from '../StorybookWrappers/BuildFormWrapperForStorybook'; // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
25
25
 
26
26
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
27
27
  const meta = {
28
28
  title: 'Component/ItemType/Boolean',
29
- component: BuildFormWrapper,
29
+ component: BuildFormWrapperForStorybook,
30
30
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
31
31
  tags: []
32
- } satisfies Meta<typeof BuildFormWrapper>;
32
+ } satisfies Meta<typeof BuildFormWrapperForStorybook>;
33
33
 
34
34
  export default meta;
35
35
  type Story = StoryObj<typeof meta>;
@@ -16,7 +16,7 @@
16
16
  */
17
17
 
18
18
  import type { Meta, StoryObj } from '@storybook/react';
19
- import BuildFormWrapper from '../BuildFormWrapper';
19
+ import BuildFormWrapperForStorybook from '../StorybookWrappers/BuildFormWrapperForStorybook';
20
20
  import {
21
21
  qChoiceAnswerOptionBasic,
22
22
  qChoiceAnswerOptionCalculation,
@@ -29,10 +29,10 @@ import {
29
29
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
30
30
  const meta = {
31
31
  title: 'Component/ItemType/Choice',
32
- component: BuildFormWrapper,
32
+ component: BuildFormWrapperForStorybook,
33
33
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
34
34
  tags: []
35
- } satisfies Meta<typeof BuildFormWrapper>;
35
+ } satisfies Meta<typeof BuildFormWrapperForStorybook>;
36
36
 
37
37
  export default meta;
38
38
  type Story = StoryObj<typeof meta>;
@@ -16,16 +16,16 @@
16
16
  */
17
17
 
18
18
  import type { Meta, StoryObj } from '@storybook/react';
19
- import BuildFormWrapper from '../BuildFormWrapper';
19
+ import BuildFormWrapperForStorybook from '../StorybookWrappers/BuildFormWrapperForStorybook';
20
20
  import { qDateBasic, qrDateBasicResponse } from '../assets/questionnaires';
21
21
 
22
22
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
23
23
  const meta = {
24
24
  title: 'Component/ItemType/Date',
25
- component: BuildFormWrapper,
25
+ component: BuildFormWrapperForStorybook,
26
26
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
27
27
  tags: []
28
- } satisfies Meta<typeof BuildFormWrapper>;
28
+ } satisfies Meta<typeof BuildFormWrapperForStorybook>;
29
29
 
30
30
  export default meta;
31
31
  type Story = StoryObj<typeof meta>;
@@ -16,16 +16,16 @@
16
16
  */
17
17
 
18
18
  import type { Meta, StoryObj } from '@storybook/react';
19
- import BuildFormWrapper from '../BuildFormWrapper';
19
+ import BuildFormWrapperForStorybook from '../StorybookWrappers/BuildFormWrapperForStorybook';
20
20
  import { qDateTimeBasic, qrDateTimeBasicResponse } from '../assets/questionnaires';
21
21
 
22
22
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
23
23
  const meta = {
24
24
  title: 'Component/ItemType/DateTime',
25
- component: BuildFormWrapper,
25
+ component: BuildFormWrapperForStorybook,
26
26
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
27
27
  tags: []
28
- } satisfies Meta<typeof BuildFormWrapper>;
28
+ } satisfies Meta<typeof BuildFormWrapperForStorybook>;
29
29
 
30
30
  export default meta;
31
31
  type Story = StoryObj<typeof meta>;
@@ -16,7 +16,7 @@
16
16
  */
17
17
 
18
18
  import type { Meta, StoryObj } from '@storybook/react';
19
- import BuildFormWrapper from '../BuildFormWrapper';
19
+ import BuildFormWrapperForStorybook from '../StorybookWrappers/BuildFormWrapperForStorybook';
20
20
  import {
21
21
  qCalculatedExpressionBMICalculator,
22
22
  qDecimalBasic,
@@ -26,10 +26,10 @@ import {
26
26
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
27
27
  const meta = {
28
28
  title: 'Component/ItemType/Decimal',
29
- component: BuildFormWrapper,
29
+ component: BuildFormWrapperForStorybook,
30
30
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
31
31
  tags: []
32
- } satisfies Meta<typeof BuildFormWrapper>;
32
+ } satisfies Meta<typeof BuildFormWrapperForStorybook>;
33
33
 
34
34
  export default meta;
35
35
  type Story = StoryObj<typeof meta>;
@@ -16,16 +16,16 @@
16
16
  */
17
17
 
18
18
  import type { Meta, StoryObj } from '@storybook/react';
19
- import BuildFormWrapper from '../BuildFormWrapper';
19
+ import BuildFormWrapperForStorybook from '../StorybookWrappers/BuildFormWrapperForStorybook';
20
20
  import { qDisplayBasic, qDisplayCalculation } from '../assets/questionnaires/QDisplay';
21
21
 
22
22
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
23
23
  const meta = {
24
24
  title: 'Component/ItemType/Display',
25
- component: BuildFormWrapper,
25
+ component: BuildFormWrapperForStorybook,
26
26
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
27
27
  tags: []
28
- } satisfies Meta<typeof BuildFormWrapper>;
28
+ } satisfies Meta<typeof BuildFormWrapperForStorybook>;
29
29
 
30
30
  export default meta;
31
31
  type Story = StoryObj<typeof meta>;
@@ -16,16 +16,16 @@
16
16
  */
17
17
 
18
18
  import type { Meta, StoryObj } from '@storybook/react';
19
- import BuildFormWrapper from '../BuildFormWrapper';
19
+ import BuildFormWrapperForStorybook from '../StorybookWrappers/BuildFormWrapperForStorybook';
20
20
  import { qGroupBasic } from '../assets/questionnaires/QGroup';
21
21
 
22
22
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
23
23
  const meta = {
24
24
  title: 'Component/ItemType/Group',
25
- component: BuildFormWrapper,
25
+ component: BuildFormWrapperForStorybook,
26
26
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
27
27
  tags: []
28
- } satisfies Meta<typeof BuildFormWrapper>;
28
+ } satisfies Meta<typeof BuildFormWrapperForStorybook>;
29
29
 
30
30
  export default meta;
31
31
  type Story = StoryObj<typeof meta>;
@@ -16,7 +16,7 @@
16
16
  */
17
17
 
18
18
  import type { Meta, StoryObj } from '@storybook/react';
19
- import BuildFormWrapper from '../BuildFormWrapper';
19
+ import BuildFormWrapperForStorybook from '../StorybookWrappers/BuildFormWrapperForStorybook';
20
20
  import {
21
21
  qIntegerBasic,
22
22
  qIntegerCalculation,
@@ -26,10 +26,10 @@ import {
26
26
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
27
27
  const meta = {
28
28
  title: 'Component/ItemType/Integer',
29
- component: BuildFormWrapper,
29
+ component: BuildFormWrapperForStorybook,
30
30
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
31
31
  tags: []
32
- } satisfies Meta<typeof BuildFormWrapper>;
32
+ } satisfies Meta<typeof BuildFormWrapperForStorybook>;
33
33
 
34
34
  export default meta;
35
35
  type Story = StoryObj<typeof meta>;