@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
@@ -14,6 +14,6 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- export * from './Renderer';
18
- export * from './FormComponents';
17
+ export { SmartFormsRenderer, BaseRenderer } from './Renderer';
18
+ export { SingleItem, RepeatItem, RepeatGroup, GroupTable, GridGroup, parseFhirDateToDisplayDate } from './FormComponents';
19
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EACL,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,0BAA0B,EAC3B,MAAM,kBAAkB,CAAC"}
@@ -1 +1,3 @@
1
1
  export { default as useHidden } from './useHidden';
2
+ export { default as useBuildForm } from './useBuildForm';
3
+ export { default as useRendererQueryClient } from './useRendererQueryClient';
@@ -1,2 +1,4 @@
1
1
  export { default as useHidden } from './useHidden';
2
+ export { default as useBuildForm } from './useBuildForm';
3
+ export { default as useRendererQueryClient } from './useRendererQueryClient';
2
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
2
+ /**
3
+ * React hook wrapping around the buildForm() function to build a form from a questionnaire and an optional QuestionnaireResponse.
4
+ * @see {buildForm} for more information.
5
+ *
6
+ * @param questionnaire - Questionnaire to be rendered
7
+ * @param questionnaireResponse - Pre-populated/draft/loaded QuestionnaireResponse to be rendered (optional)
8
+ * @param readOnly - Applies read-only mode to all items in the form view
9
+ * @param terminologyServerUrl - Terminology server url to fetch terminology. If not provided, the default terminology server will be used. (optional)
10
+ * @param additionalVariables - Additional key-value pair of SDC variables `Record<name, variable extension>` for testing (optional)
11
+ *
12
+ * @author Sean Fong
13
+ */
14
+ declare function useBuildForm(questionnaire: Questionnaire, questionnaireResponse?: QuestionnaireResponse, readOnly?: boolean, terminologyServerUrl?: string, additionalVariables?: Record<string, object>): boolean;
15
+ export default useBuildForm;
@@ -0,0 +1,41 @@
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
+ import { useLayoutEffect, useState } from 'react';
18
+ import { buildForm } from '../utils';
19
+ /**
20
+ * React hook wrapping around the buildForm() function to build a form from a questionnaire and an optional QuestionnaireResponse.
21
+ * @see {buildForm} for more information.
22
+ *
23
+ * @param questionnaire - Questionnaire to be rendered
24
+ * @param questionnaireResponse - Pre-populated/draft/loaded QuestionnaireResponse to be rendered (optional)
25
+ * @param readOnly - Applies read-only mode to all items in the form view
26
+ * @param terminologyServerUrl - Terminology server url to fetch terminology. If not provided, the default terminology server will be used. (optional)
27
+ * @param additionalVariables - Additional key-value pair of SDC variables `Record<name, variable extension>` for testing (optional)
28
+ *
29
+ * @author Sean Fong
30
+ */
31
+ function useBuildForm(questionnaire, questionnaireResponse, readOnly, terminologyServerUrl, additionalVariables) {
32
+ const [isBuilding, setIsBuilding] = useState(true);
33
+ useLayoutEffect(() => {
34
+ buildForm(questionnaire, questionnaireResponse, readOnly, terminologyServerUrl, additionalVariables).then(() => {
35
+ setIsBuilding(false);
36
+ });
37
+ }, [additionalVariables, questionnaire, questionnaireResponse, readOnly, terminologyServerUrl]);
38
+ return isBuilding;
39
+ }
40
+ export default useBuildForm;
41
+ //# sourceMappingURL=useBuildForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBuildForm.js","sourceRoot":"","sources":["../../src/hooks/useBuildForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC;;;;;;;;;;;GAWG;AACH,SAAS,YAAY,CACnB,aAA4B,EAC5B,qBAA6C,EAC7C,QAAkB,EAClB,oBAA6B,EAC7B,mBAA4C;IAE5C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEnD,eAAe,CAAC,GAAG,EAAE;QACnB,SAAS,CACP,aAAa,EACb,qBAAqB,EACrB,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,CACpB,CAAC,IAAI,CAAC,GAAG,EAAE;YACV,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,mBAAmB,EAAE,aAAa,EAAE,qBAAqB,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAEhG,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,eAAe,YAAY,CAAC"}
@@ -1,3 +1,9 @@
1
1
  import type { QuestionnaireItem } from 'fhir/r4';
2
+ /**
3
+ * React hook to determine if a QuestionnaireItem is hidden via item.hidden, enableWhens, enableWhenExpressions.
4
+ * When checking for repeating group enableWhen items, the parentRepeatGroupIndex should be provided.
5
+ *
6
+ * @author Sean Fong
7
+ */
2
8
  declare function useHidden(qItem: QuestionnaireItem, parentRepeatGroupIndex?: number): boolean;
3
9
  export default useHidden;
@@ -17,6 +17,12 @@
17
17
  import { useQuestionnaireStore } from '../stores';
18
18
  import { isHiddenByEnableWhen } from '../utils/qItem';
19
19
  import { structuredDataCapture } from 'fhir-sdc-helpers';
20
+ /**
21
+ * React hook to determine if a QuestionnaireItem is hidden via item.hidden, enableWhens, enableWhenExpressions.
22
+ * When checking for repeating group enableWhen items, the parentRepeatGroupIndex should be provided.
23
+ *
24
+ * @author Sean Fong
25
+ */
20
26
  function useHidden(qItem, parentRepeatGroupIndex) {
21
27
  const enableWhenIsActivated = useQuestionnaireStore.use.enableWhenIsActivated();
22
28
  const enableWhenItems = useQuestionnaireStore.use.enableWhenItems();
@@ -1 +1 @@
1
- {"version":3,"file":"useHidden.js","sourceRoot":"","sources":["../../src/hooks/useHidden.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,qBAAqB,E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AAM;QACpB,qBAAqB;QACrB,eAAe;QACf,qBAAqB;QACrB,sBAAsB;KACvB,CAAC,CAAC;AACL,CAAC;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ export default useBuildForm;
@@ -0,0 +1,55 @@
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
+ import { useEffect } from 'react';
18
+ import { readEncounter, readPatient, readUser } from '../api/smartClient';
19
+ import { useSmartConfigStore } from '../stores';
20
+ /**
21
+ * React hook wrapping to initialise a FHIRClient object for further FHIR calls in the renderer i.e. AnswerExpression calls
22
+ * Note: This does not provide pre-population capabilities
23
+ *
24
+ * @param questionnaire - Questionnaire to be rendered
25
+ * @param questionnaireResponse - Pre-populated/draft/loaded QuestionnaireResponse to be rendered (optional)
26
+ * @param readOnly - Applies read-only mode to all items in the form view
27
+ * @param terminologyServerUrl - Terminology server url to fetch terminology. If not provided, the default terminology server will be used. (optional)
28
+ * @param additionalVariables - Additional key-value pair of SDC variables <name, variable extension> for testing (optional)
29
+ *
30
+ * @author Sean Fong
31
+ */
32
+ function useInitaliseFhirClient(fhirClient) {
33
+ const setSmartClient = useSmartConfigStore.use.setClient();
34
+ const setPatient = useSmartConfigStore.use.setPatient();
35
+ const setUser = useSmartConfigStore.use.setUser();
36
+ const setEncounter = useSmartConfigStore.use.setEncounter();
37
+ useEffect(() => {
38
+ // set fhirClient if provided
39
+ if (fhirClient) {
40
+ setSmartClient(fhirClient);
41
+ readPatient(fhirClient).then((patient) => {
42
+ setPatient(patient);
43
+ });
44
+ readUser(fhirClient).then((user) => {
45
+ setUser(user);
46
+ });
47
+ readEncounter(fhirClient).then((encounter) => {
48
+ setEncounter(encounter);
49
+ });
50
+ }
51
+ }, [setSmartClient, setPatient, setUser, setEncounter]);
52
+ return isBuilding;
53
+ }
54
+ export default useBuildForm;
55
+ //# sourceMappingURL=useInitaliseFhirClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInitaliseFhirClient.js","sourceRoot":"","sources":["../../src/hooks/useInitaliseFhirClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,SAAS,sBAAsB,CAAC,UAAkB;IAChD,MAAM,cAAc,GAAG,mBAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;IAC3D,MAAM,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;IACxD,MAAM,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAClD,MAAM,YAAY,GAAG,mBAAmB,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;IAE5D,SAAS,CAAC,GAAG,EAAE;QACb,6BAA6B;QAC7B,IAAI,UAAU,EAAE;YACd,cAAc,CAAC,UAAU,CAAC,CAAC;YAC3B,WAAW,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBACvC,UAAU,CAAC,OAAO,CAAC,CAAC;YACtB,CAAC,CAAC,CAAC;YACH,QAAQ,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;gBACjC,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;YACH,aAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;gBAC3C,YAAY,CAAC,SAAS,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;IAExD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
2
+ import type Client from 'fhirclient/lib/Client';
3
+ /**
4
+ * React hook to initialise a form by:
5
+ * - Calling the buildForm() function to build a form from a questionnaire, an optional QuestionnaireResponse and other optional properties.
6
+ * - Setting a FHIRClient object to make further FHIR calls i.e. answerExpressions.
7
+ *
8
+ * @param questionnaire - Questionnaire to be rendered
9
+ * @param questionnaireResponse - Pre-populated/draft/loaded QuestionnaireResponse to be rendered (optional)
10
+ * @param readOnly - Applies read-only mode to all items in the form view
11
+ * @param terminologyServerUrl - Terminology server url to fetch terminology. If not provided, the default terminology server will be used. (optional)
12
+ * @param additionalVariables - Additional key-value pair of SDC variables `Record<name, variable extension>` for testing (optional)
13
+ * @param fhirClient - FHIRClient object to perform further FHIR calls. At the moment it's only used in answerExpressions (optional)
14
+ *
15
+ * @see {buildForm} for more information.
16
+ *
17
+ * @author Sean Fong
18
+ */
19
+ declare function useInitialiseForm(questionnaire: Questionnaire, questionnaireResponse?: QuestionnaireResponse, readOnly?: boolean, terminologyServerUrl?: string, additionalVariables?: Record<string, object>, fhirClient?: Client): boolean;
20
+ export default useInitialiseForm;
@@ -0,0 +1,72 @@
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
+ import { useLayoutEffect, useState } from 'react';
18
+ import { buildForm } from '../utils';
19
+ import { useSmartConfigStore } from '../stores';
20
+ import { initialiseFhirClient } from '../utils/manageForm';
21
+ /**
22
+ * React hook to initialise a form by:
23
+ * - Calling the buildForm() function to build a form from a questionnaire, an optional QuestionnaireResponse and other optional properties.
24
+ * - Setting a FHIRClient object to make further FHIR calls i.e. answerExpressions.
25
+ *
26
+ * @param questionnaire - Questionnaire to be rendered
27
+ * @param questionnaireResponse - Pre-populated/draft/loaded QuestionnaireResponse to be rendered (optional)
28
+ * @param readOnly - Applies read-only mode to all items in the form view
29
+ * @param terminologyServerUrl - Terminology server url to fetch terminology. If not provided, the default terminology server will be used. (optional)
30
+ * @param additionalVariables - Additional key-value pair of SDC variables `Record<name, variable extension>` for testing (optional)
31
+ * @param fhirClient - FHIRClient object to perform further FHIR calls. At the moment it's only used in answerExpressions (optional)
32
+ *
33
+ * @see {buildForm} for more information.
34
+ *
35
+ * @author Sean Fong
36
+ */
37
+ function useInitialiseForm(questionnaire, questionnaireResponse, readOnly, terminologyServerUrl, additionalVariables, fhirClient) {
38
+ const [isFhirClientReady, setIsFhirClientReady] = useState(true);
39
+ const [isBuilding, setIsBuilding] = useState(true);
40
+ const setSmartClient = useSmartConfigStore.use.setClient();
41
+ const setPatient = useSmartConfigStore.use.setPatient();
42
+ const setUser = useSmartConfigStore.use.setUser();
43
+ const setEncounter = useSmartConfigStore.use.setEncounter();
44
+ useLayoutEffect(() => {
45
+ setIsBuilding(true);
46
+ if (fhirClient) {
47
+ setIsFhirClientReady(true);
48
+ initialiseFhirClient(fhirClient).then(() => {
49
+ setIsFhirClientReady(false);
50
+ });
51
+ }
52
+ // Initialise form including Questionnaire and other optionally provided parameters
53
+ // Includes initialisation for enableWhen, enableWhenExpressions, calculatedExpressions, initialExpressions, answerExpressions, cache answerValueSets
54
+ buildForm(questionnaire, questionnaireResponse, readOnly, terminologyServerUrl, additionalVariables).then(() => {
55
+ setIsBuilding(false);
56
+ });
57
+ }, [
58
+ questionnaire,
59
+ questionnaireResponse,
60
+ additionalVariables,
61
+ terminologyServerUrl,
62
+ fhirClient,
63
+ readOnly,
64
+ setSmartClient,
65
+ setPatient,
66
+ setUser,
67
+ setEncounter
68
+ ]);
69
+ return isFhirClientReady && isBuilding;
70
+ }
71
+ export default useInitialiseForm;
72
+ //# sourceMappingURL=useInitialiseForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInitialiseForm.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;;;;;;;;;;GAeG;AACH,SAAS,iBAAiB,CACxB,aAA4B,EAC5B,qBAA6C,EAC7C,QAAkB,EAClB,oBAA6B,EAC7B,mBAA4C,EAC5C,UAAmB;IAEnB,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEnD,MAAM,cAAc,GAAG,mBAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;IAC3D,MAAM,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;IACxD,MAAM,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAClD,MAAM,YAAY,GAAG,mBAAmB,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;IAE5D,eAAe,CAAC,GAAG,EAAE;QACnB,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,IAAI,UAAU,EAAE;YACd,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAC3B,oBAAoB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBACzC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;SACJ;QAED,mFAAmF;QACnF,qJAAqJ;QACrJ,SAAS,CACP,aAAa,EACb,qBAAqB,EACrB,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,CACpB,CAAC,IAAI,CAAC,GAAG,EAAE;YACV,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE;QACD,aAAa;QACb,qBAAqB;QACrB,mBAAmB;QACnB,oBAAoB;QACpB,UAAU;QACV,QAAQ;QACR,cAAc;QACd,UAAU;QACV,OAAO;QACP,YAAY;KACb,CAAC,CAAC;IAEH,OAAO,iBAAiB,IAAI,UAAU,CAAC;AACzC,CAAC;AAED,eAAe,iBAAiB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
2
2
  import type Client from 'fhirclient/lib/Client';
3
- declare function useInitialiseRenderer(questionnaire: Questionnaire, questionnaireResponse?: QuestionnaireResponse, additionalVariables?: Record<string, object>, terminologyServerUrl?: string, fhirClient?: Client, readOnly?: boolean): boolean;
3
+ declare function useInitialiseRenderer(questionnaire: Questionnaire, questionnaireResponse?: QuestionnaireResponse, readOnly?: boolean, terminologyServerUrl?: string, additionalVariables?: Record<string, object>, fhirClient?: Client): boolean;
4
4
  export default useInitialiseRenderer;
@@ -15,16 +15,11 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { useLayoutEffect, useState } from 'react';
18
- import { initialiseQuestionnaireResponse } from '../utils';
18
+ import { buildForm } from '../utils';
19
19
  import { readEncounter, readPatient, readUser } from '../api/smartClient';
20
- import { useQuestionnaireResponseStore, useQuestionnaireStore, useSmartConfigStore, useTerminologyServerStore } from '../stores';
21
- function useInitialiseRenderer(questionnaire, questionnaireResponse, additionalVariables, terminologyServerUrl, fhirClient, readOnly) {
22
- const buildSourceQuestionnaire = useQuestionnaireStore.use.buildSourceQuestionnaire();
23
- const updatePopulatedProperties = useQuestionnaireStore.use.updatePopulatedProperties();
24
- const buildSourceResponse = useQuestionnaireResponseStore.use.buildSourceResponse();
25
- const setUpdatableResponseAsPopulated = useQuestionnaireResponseStore.use.setUpdatableResponseAsPopulated();
26
- const setTerminologyServerUrl = useTerminologyServerStore.use.setUrl();
27
- const resetTerminologyServerUrl = useTerminologyServerStore.use.resetUrl();
20
+ import { useSmartConfigStore } from '../stores';
21
+ // Smart Config store are only used in answerExpressions at the moment. If not using answerExpressions, this can be removed.
22
+ function useInitialiseRenderer(questionnaire, questionnaireResponse, readOnly, terminologyServerUrl, additionalVariables, fhirClient) {
28
23
  const setSmartClient = useSmartConfigStore.use.setClient();
29
24
  const setPatient = useSmartConfigStore.use.setPatient();
30
25
  const setUser = useSmartConfigStore.use.setUser();
@@ -45,39 +40,21 @@ function useInitialiseRenderer(questionnaire, questionnaireResponse, additionalV
45
40
  setEncounter(encounter);
46
41
  });
47
42
  }
48
- // set terminology server url if provided, otherwise reset it back to ontoserver
49
- if (terminologyServerUrl) {
50
- setTerminologyServerUrl(terminologyServerUrl);
51
- }
52
- else {
53
- resetTerminologyServerUrl();
54
- }
55
43
  // initialise form including enableWhen, enableWhenExpressions, calculatedExpressions, initialExpressions, answerExpressions, cache answerValueSets
56
- buildSourceQuestionnaire(questionnaire, questionnaireResponse, additionalVariables, terminologyServerUrl, readOnly).then(() => {
57
- buildSourceResponse(initialiseQuestionnaireResponse(questionnaire));
58
- if (questionnaireResponse) {
59
- const updatedResponse = updatePopulatedProperties(questionnaireResponse);
60
- setUpdatableResponseAsPopulated(updatedResponse);
61
- }
44
+ buildForm(questionnaire, questionnaireResponse, readOnly, terminologyServerUrl, additionalVariables).then(() => {
62
45
  setLoading(false);
63
46
  });
64
47
  }, [
65
48
  questionnaire,
66
49
  questionnaireResponse,
67
- buildSourceQuestionnaire,
68
- buildSourceResponse,
69
- setUpdatableResponseAsPopulated,
70
- updatePopulatedProperties,
71
50
  additionalVariables,
51
+ terminologyServerUrl,
72
52
  fhirClient,
53
+ readOnly,
73
54
  setSmartClient,
74
55
  setPatient,
75
56
  setUser,
76
- setEncounter,
77
- terminologyServerUrl,
78
- setTerminologyServerUrl,
79
- resetTerminologyServerUrl,
80
- readOnly
57
+ setEncounter
81
58
  ]);
82
59
  return loading;
83
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useInitialiseRenderer.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,WAAW,CAAC;AAEnB,SAAS,qBAAqB,CAC5B,aAA4B,EAC5B,qBAA6C,EAC7C,mBAA4C,EAC5C,oBAA6B,EAC7B,UAAmB,EACnB,QAAkB;IAElB,MAAM,wBAAwB,GAAG,qBAAqB,CAAC,GAAG,CAAC,wBAAwB,EAAE,CAAC;IACtF,MAAM,yBAAyB,GAAG,qBAAqB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;SACJ;QAED,gFAAgF;QAChF,IAAI,oBAAoB,EAAE;YACxB,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;SAC/C;aAAM;YACL,yBAAyB,EAAE,CAAC;SAC7B;QAED,mJAAmJ;QACnJ,wBAAwB,CACtB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,QAAQ,CACT,CAAC,IAAI,CAAC,GAAG,EAAE;YACV,mBAAmB,CAAC,+BAA+B,CAAC,aAAa,CAAC,CAAC,CAAC;YAEpE,IAAI,qBAAqB,EAAE;gBACzB,MAAM,eAAe,GAAG,yBAAyB,CAAC,qBAAqB,CAAC,CAAC;gBACzE,+BAA+B,CAAC,eAAe,CAAC,CAAC;aAClD;YACD,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE;QACD,aAAa;QACb,qBAAqB;QACrB,wBAAwB;QACxB,mBAAmB;QACnB,+BAA+B;QAC/B,yBAAyB;QACzB,mBAAmB;QACnB,UAAU;QACV,cAAc;QACd,UAAU;QACV,OAAO;QACP,YAAY;QACZ,oBAAoB;QACpB,uBAAuB;QACvB,yBAAyB;QACzB,QAAQ;KACT,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"useInitialiseRenderer.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,4HAA4H;AAC5H,SAAS,qBAAqB,CAC5B,aAA4B,EA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AAoB;QACpB,UAAU;QACV,QAAQ;QACR,cAAc;QACd,UAAU;QACV,OAAO;QACP,YAAY;KACb,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ /**
3
+ * Default QueryClient used by the renderer.
4
+ * You can customise your own QueryClient with your own options, use v4 of @tanstack/react-query.
5
+ * @see {@link https://tanstack.com/query/v4/docs/reference/QueryClient}
6
+ *
7
+ * @author Sean Fong
8
+ */
9
+ declare function useRendererQueryClient(): QueryClient;
10
+ export default useRendererQueryClient;
@@ -0,0 +1,36 @@
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
+ import { QueryClient } from '@tanstack/react-query';
18
+ /**
19
+ * Default QueryClient used by the renderer.
20
+ * You can customise your own QueryClient with your own options, use v4 of @tanstack/react-query.
21
+ * @see {@link https://tanstack.com/query/v4/docs/reference/QueryClient}
22
+ *
23
+ * @author Sean Fong
24
+ */
25
+ function useRendererQueryClient() {
26
+ return new QueryClient({
27
+ defaultOptions: {
28
+ queries: {
29
+ refetchOnWindowFocus: false,
30
+ keepPreviousData: true
31
+ }
32
+ }
33
+ });
34
+ }
35
+ export default useRendererQueryClient;
36
+ //# sourceMappingURL=useRendererQueryClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRendererQueryClient.js","sourceRoot":"","sources":["../../src/hooks/useRendererQueryClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;;;;GAMG;AACH,SAAS,sBAAsB;IAC7B,OAAO,IAAI,WAAW,CAAC;QACrB,cAAc,EAAE;YACd,OAAO,EAAE;gBACP,oBAAoB,EAAE,KAAK;gBAC3B,gBAAgB,EAAE,IAAI;aACvB;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,eAAe,sBAAsB,CAAC"}
@@ -60,6 +60,7 @@ function useValueSetCodings(qItem) {
60
60
  }
61
61
  return [];
62
62
  }, [cachedValueSetCodings, processedValueSetCodings, valueSetUrl]);
63
+ // Attempt to get codings from answer expression
63
64
  const answerExpression = (_a = getAnswerExpression(qItem)) === null || _a === void 0 ? void 0 : _a.expression;
64
65
  initialCodings = useMemo(() => {
65
66
  if (initialCodings.length === 0 && answerExpression) {
@@ -1 +1 @@
1
- {"version":3,"file":"useValueSetCodings.js","sourceRoot":"","sources":["../../src/hooks/useValueSetCodings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAClG,OAAO,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AAO/F,SAAS,kBAAkB,CAAC,KAAwB;;IAIlD,MAAM,OAAO,GA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,CAAC;qBACrB;gBACH,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;oBACtB,cAAc,CAAC,KAAK,CAAC,CAAC;gBACxB,CAAC,CAAC,CAAC;YACP,CAAC,CAAA,CAAC;iBACD,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;gBACtB,cAAc,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;SACN;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,EAAE,EAAE,CAAC;AAClG,CAAC;AAED,eAAe,kBAAkB,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,40 +1,10 @@
1
- import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
2
- import type { ItemToRepopulate } from './utils/repopulateItems';
3
- export * from './components';
4
- export * from './stores';
5
- export * from './hooks';
6
- export * from './utils';
7
- export * from './interfaces';
8
- export type { ItemToRepopulate };
9
- /**
10
- * Destroy the form to clean up the questionnaire and questionnaireResponse stores.
11
- *
12
- * @author Sean Fong
13
- */
14
- export declare function destroyForm(): void;
15
- /**
16
- * Get the filled QuestionnaireResponse at its current state.
17
- * If no changes have been made to the form, the initial QuestionnaireResponse is returned.
18
- *
19
- * @author Sean Fong
20
- */
21
- export declare function getResponse(): QuestionnaireResponse;
22
- /**
23
- * Remove all hidden answers from the filled QuestionnaireResponse.
24
- * This takes into account the questionnaire-hidden extension, enableWhens, enableWhenExpressions and empty strings.
25
- *
26
- * @author Sean Fong
27
- */
28
- export declare function removeEmptyAnswersFromResponse(questionnaire: Questionnaire, questionnaireResponse: QuestionnaireResponse): QuestionnaireResponse;
29
- /**
30
- * Compare latest data from the server with the current QuestionnaireResponse and decide items to re-populate.
31
- *
32
- * @author Sean Fong
33
- */
34
- export declare function generateItemsToRepopulate(populatedResponse: QuestionnaireResponse): Record<string, ItemToRepopulate>;
35
- /**
36
- * Re-populate checked items in the re-population dialog into the current QuestionnaireResponse.
37
- *
38
- * @author Sean Fong
39
- */
40
- export declare function repopulateResponse(checkedItemsToRepopulate: Record<string, ItemToRepopulate>): QuestionnaireResponse;
1
+ export type { Tab, Tabs, Variables, VariableXFhirQuery, LaunchContext } from './interfaces';
2
+ export type { SmartFormsRendererProps } from './components';
3
+ export { SmartFormsRenderer, BaseRenderer, SingleItem, RepeatItem, RepeatGroup, GroupTable, GridGroup, parseFhirDateToDisplayDate } from './components';
4
+ export type { QuestionnaireStoreType, QuestionnaireResponseStoreType, SmartConfigStoreType, TerminologyServerStoreType } from './stores';
5
+ export { questionnaireStore, useQuestionnaireStore, questionnaireResponseStore, useQuestionnaireResponseStore, smartConfigStore, useSmartConfigStore, terminologyServerStore, useTerminologyServerStore } from './stores';
6
+ export { useHidden, useBuildForm, useRendererQueryClient } from './hooks';
7
+ export type { ItemToRepopulate } from './utils';
8
+ export { buildForm, destroyForm, getResponse, removeEmptyAnswersFromResponse, isSpecificItemControl, isRepeatItemAndNotCheckbox, initialiseQuestionnaireResponse, generateItemsToRepopulate, repopulateResponse } from './utils';
9
+ export { RendererThemeProvider } from './theme';
10
+ export { InitialiseFormWrapperForStorybook, BuildFormButtonTesterWrapperForStorybook, PrePopWrapperForStorybook } from './stories/StorybookWrappers';
package/lib/index.js CHANGED
@@ -1,78 +1,9 @@
1
- import { questionnaireResponseStore, questionnaireStore } from './stores';
2
- import { removeEmptyAnswers } from './utils/removeEmptyAnswers';
3
- import { getItemsToRepopulate } from './utils/repopulateItems';
4
- import { repopulateItemsIntoResponse } from './utils/repopulateIntoResponse';
5
- export * from './components';
6
- export * from './stores';
7
- export * from './hooks';
8
- export * from './utils';
9
- export * from './interfaces';
10
- /**
11
- * Destroy the form to clean up the questionnaire and questionnaireResponse stores.
12
- *
13
- * @author Sean Fong
14
- */
15
- export function destroyForm() {
16
- questionnaireStore.getState().destroySourceQuestionnaire();
17
- questionnaireResponseStore.getState().destroySourceResponse();
18
- }
19
- /**
20
- * Get the filled QuestionnaireResponse at its current state.
21
- * If no changes have been made to the form, the initial QuestionnaireResponse is returned.
22
- *
23
- * @author Sean Fong
24
- */
25
- export function getResponse() {
26
- return questionnaireResponseStore.getState().updatableResponse;
27
- }
28
- /**
29
- * Remove all hidden answers from the filled QuestionnaireResponse.
30
- * This takes into account the questionnaire-hidden extension, enableWhens, enableWhenExpressions and empty strings.
31
- *
32
- * @author Sean Fong
33
- */
34
- export function removeEmptyAnswersFromResponse(questionnaire, questionnaireResponse) {
35
- const enableWhenIsActivated = questionnaireStore.getState().enableWhenIsActivated;
36
- const enableWhenItems = questionnaireStore.getState().enableWhenItems;
37
- const enableWhenExpressions = questionnaireStore.getState().enableWhenExpressions;
38
- return removeEmptyAnswers({
39
- questionnaire,
40
- questionnaireResponse,
41
- enableWhenIsActivated,
42
- enableWhenItems,
43
- enableWhenExpressions
44
- });
45
- }
46
- /**
47
- * Compare latest data from the server with the current QuestionnaireResponse and decide items to re-populate.
48
- *
49
- * @author Sean Fong
50
- */
51
- export function generateItemsToRepopulate(populatedResponse) {
52
- const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;
53
- const tabs = questionnaireStore.getState().tabs;
54
- const updatableResponse = questionnaireResponseStore.getState().updatableResponse;
55
- const enableWhenIsActivated = questionnaireStore.getState().enableWhenIsActivated;
56
- const enableWhenItems = questionnaireStore.getState().enableWhenItems;
57
- const enableWhenExpressions = questionnaireStore.getState().enableWhenExpressions;
58
- return getItemsToRepopulate({
59
- sourceQuestionnaire,
60
- tabs,
61
- populatedResponse,
62
- updatableResponse,
63
- enableWhenIsActivated,
64
- enableWhenItems,
65
- enableWhenExpressions
66
- });
67
- }
68
- /**
69
- * Re-populate checked items in the re-population dialog into the current QuestionnaireResponse.
70
- *
71
- * @author Sean Fong
72
- */
73
- export function repopulateResponse(checkedItemsToRepopulate) {
74
- const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;
75
- const updatableResponse = questionnaireResponseStore.getState().updatableResponse;
76
- return repopulateItemsIntoResponse(sourceQuestionnaire, updatableResponse, checkedItemsToRepopulate);
77
- }
1
+ export { SmartFormsRenderer, BaseRenderer, SingleItem, RepeatItem, RepeatGroup, GroupTable, GridGroup, parseFhirDateToDisplayDate } from './components';
2
+ export { questionnaireStore, useQuestionnaireStore, questionnaireResponseStore, useQuestionnaireResponseStore, smartConfigStore, useSmartConfigStore, terminologyServerStore, useTerminologyServerStore } from './stores';
3
+ // hooks exports
4
+ export { useHidden, useBuildForm, useRendererQueryClient } from './hooks';
5
+ export { buildForm, destroyForm, getResponse, removeEmptyAnswersFromResponse, isSpecificItemControl, isRepeatItemAndNotCheckbox, initialiseQuestionnaireResponse, generateItemsToRepopulate, repopulateResponse } from './utils';
6
+ // theme provider exports
7
+ export { RendererThemeProvider } from './theme';
8
+ export { InitialiseFormWrapperForStorybook, BuildFormButtonTesterWrapperForStorybook, PrePopWrapperForStorybook } from './stories/StorybookWrappers';
78
9
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAE7E,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAG7B;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,kBAAkB,CAAC,QAAQ,EAAE,CAAC,0BAA0B,EAAE,CAAC;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L,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,wBAA0D;IAC3F,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAC,mBAAmB,CAAC;IAC9E,MAAM,iBAAiB,GAAG,0BAA0B,CAAC,QAAQ,EAAE,CAAC,iBAAiB,CAAC;IAElF,OAAO,2BAA2B,CAChC,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,CACzB,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,0BAA0B,EAC3B,MAAM,cAAc,CAAC;AAStB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,EAC1B,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAElB,gBAAgB;AAChB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAI1E,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,8BAA8B,EAC9B,qBAAqB,EACrB,0BAA0B,EAC1B,+BAA+B,EAC/B,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,yBAAyB;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EACL,iCAAiC,EACjC,wCAAwC,EACxC,yBAAyB,EAC1B,MAAM,6BAA6B,CAAC"}
@@ -1,3 +1,10 @@
1
+ /**
2
+ * CalculatedExpression interface
3
+ *
4
+ * @property expression - CalculatedExpression FHIRPath expression
5
+ * @property from - Whether the expressions is for the item itself or for item._text
6
+ * @property value - Evaluated value of the expression via FHIRPath
7
+ */
1
8
  export interface CalculatedExpression {
2
9
  expression: string;
3
10
  from: 'item' | 'item._text';