@aehrc/smart-forms-renderer 0.12.0 → 0.13.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 (324) hide show
  1. package/lib/components/Box.styles.d.ts +6 -0
  2. package/lib/components/Box.styles.js +29 -1
  3. package/lib/components/Box.styles.js.map +1 -1
  4. package/lib/components/FormComponents/BooleanItem/BooleanItem.js +2 -2
  5. package/lib/components/FormComponents/BooleanItem/BooleanItem.js.map +1 -1
  6. package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js +4 -10
  7. package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js.map +1 -1
  8. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js +4 -9
  9. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js.map +1 -1
  10. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +4 -9
  11. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -1
  12. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js +4 -10
  13. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js.map +1 -1
  14. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js +4 -10
  15. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js.map +1 -1
  16. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js +4 -10
  17. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js.map +1 -1
  18. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js +4 -10
  19. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js.map +1 -1
  20. package/lib/components/FormComponents/CustomDateItem/CustomDateItem.js +2 -2
  21. package/lib/components/FormComponents/CustomDateItem/CustomDateItem.js.map +1 -1
  22. package/lib/components/FormComponents/DateItem/DateItem.js +2 -2
  23. package/lib/components/FormComponents/DateItem/DateItem.js.map +1 -1
  24. package/lib/components/FormComponents/DateTimeItem/DateTimeItem.js +2 -2
  25. package/lib/components/FormComponents/DateTimeItem/DateTimeItem.js.map +1 -1
  26. package/lib/components/FormComponents/DecimalItem/DecimalItem.js +4 -4
  27. package/lib/components/FormComponents/DecimalItem/DecimalItem.js.map +1 -1
  28. package/lib/components/FormComponents/IntegerItem/IntegerField.js +1 -1
  29. package/lib/components/FormComponents/IntegerItem/IntegerField.js.map +1 -1
  30. package/lib/components/FormComponents/IntegerItem/IntegerItem.js +4 -4
  31. package/lib/components/FormComponents/IntegerItem/IntegerItem.js.map +1 -1
  32. package/lib/components/FormComponents/ItemParts/ItemExtensionLabels.d.ts +7 -0
  33. package/lib/components/FormComponents/{DateItem/DatePickerField.js → ItemParts/ItemExtensionLabels.js} +12 -6
  34. package/lib/components/FormComponents/ItemParts/ItemExtensionLabels.js.map +1 -0
  35. package/lib/components/FormComponents/ItemParts/ItemFieldGrid.d.ts +1 -0
  36. package/lib/components/FormComponents/ItemParts/ItemFieldGrid.js +10 -7
  37. package/lib/components/FormComponents/ItemParts/ItemFieldGrid.js.map +1 -1
  38. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js +4 -10
  39. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js.map +1 -1
  40. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js +4 -9
  41. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js.map +1 -1
  42. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js +4 -10
  43. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js.map +1 -1
  44. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js +4 -10
  45. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js.map +1 -1
  46. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js +4 -10
  47. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js.map +1 -1
  48. package/lib/components/FormComponents/RepeatItem/RepeatItem.d.ts +1 -2
  49. package/lib/components/FormComponents/RepeatItem/RepeatItem.js +2 -2
  50. package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
  51. package/lib/components/FormComponents/SliderItem/SliderItem.js +2 -2
  52. package/lib/components/FormComponents/SliderItem/SliderItem.js.map +1 -1
  53. package/lib/components/FormComponents/StringItem/StringItem.js +4 -4
  54. package/lib/components/FormComponents/StringItem/StringItem.js.map +1 -1
  55. package/lib/components/FormComponents/Tables/GroupTable.js +0 -1
  56. package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -1
  57. package/lib/components/FormComponents/Tables/GroupTableRow.js +3 -3
  58. package/lib/components/FormComponents/Tables/GroupTableRow.js.map +1 -1
  59. package/lib/components/FormComponents/Tables/GroupTableView.js +1 -1
  60. package/lib/components/FormComponents/Tables/GroupTableView.js.map +1 -1
  61. package/lib/components/FormComponents/Tables/SelectRowButton.d.ts +1 -0
  62. package/lib/components/FormComponents/Tables/SelectRowButton.js +2 -2
  63. package/lib/components/FormComponents/Tables/SelectRowButton.js.map +1 -1
  64. package/lib/components/FormComponents/TextItem/TextItem.js +4 -4
  65. package/lib/components/FormComponents/TextItem/TextItem.js.map +1 -1
  66. package/lib/components/FormComponents/TimeItem/TimeItem.js +2 -2
  67. package/lib/components/FormComponents/TimeItem/TimeItem.js.map +1 -1
  68. package/lib/components/FormComponents/UrlItem/UrlItem.js +4 -4
  69. package/lib/components/FormComponents/UrlItem/UrlItem.js.map +1 -1
  70. package/lib/components/Renderer/BaseRenderer.js +9 -1
  71. package/lib/components/Renderer/BaseRenderer.js.map +1 -1
  72. package/lib/components/Renderer/FormBodyCollapsible.d.ts +2 -2
  73. package/lib/components/Renderer/FormBodyCollapsible.js +2 -2
  74. package/lib/components/Renderer/FormBodyCollapsible.js.map +1 -1
  75. package/lib/components/Renderer/FormBodySingleCollapsibleWrapper.d.ts +2 -2
  76. package/lib/components/Renderer/FormBodySingleCollapsibleWrapper.js +2 -2
  77. package/lib/components/Renderer/FormBodySingleCollapsibleWrapper.js.map +1 -1
  78. package/lib/components/Renderer/FormBodyTabbed.d.ts +2 -2
  79. package/lib/components/Renderer/FormBodyTabbed.js +2 -2
  80. package/lib/components/Renderer/FormBodyTabbed.js.map +1 -1
  81. package/lib/components/Renderer/FormTopLevelItem.d.ts +2 -2
  82. package/lib/components/Renderer/FormTopLevelItem.js +4 -4
  83. package/lib/components/Renderer/FormTopLevelItem.js.map +1 -1
  84. package/lib/components/Renderer/SmartFormsRenderer.d.ts +1 -0
  85. package/lib/components/Renderer/SmartFormsRenderer.js +2 -2
  86. package/lib/components/Renderer/SmartFormsRenderer.js.map +1 -1
  87. package/lib/hooks/useInitialiseRenderer.d.ts +1 -1
  88. package/lib/hooks/useInitialiseRenderer.js +4 -3
  89. package/lib/hooks/useInitialiseRenderer.js.map +1 -1
  90. package/lib/hooks/useRenderingExtensions.d.ts +2 -0
  91. package/lib/hooks/useRenderingExtensions.js +16 -11
  92. package/lib/hooks/useRenderingExtensions.js.map +1 -1
  93. package/lib/hooks/useValidationFeedback.d.ts +3 -0
  94. package/lib/hooks/useValidationFeedback.js +37 -0
  95. package/lib/hooks/useValidationFeedback.js.map +1 -0
  96. package/lib/stores/questionnaireResponseStore.d.ts +8 -1
  97. package/lib/stores/questionnaireResponseStore.js +22 -0
  98. package/lib/stores/questionnaireResponseStore.js.map +1 -1
  99. package/lib/stores/questionnaireStore.d.ts +4 -2
  100. package/lib/stores/questionnaireStore.js +4 -2
  101. package/lib/stores/questionnaireStore.js.map +1 -1
  102. package/lib/utils/itemControl.d.ts +1 -27
  103. package/lib/utils/itemControl.js +0 -49
  104. package/lib/utils/itemControl.js.map +1 -1
  105. package/lib/utils/mapItem.d.ts +2 -0
  106. package/lib/utils/mapItem.js +2 -0
  107. package/lib/utils/mapItem.js.map +1 -1
  108. package/lib/utils/validateQuestionnaire.d.ts +23 -0
  109. package/lib/utils/validateQuestionnaire.js +183 -0
  110. package/lib/utils/validateQuestionnaire.js.map +1 -0
  111. package/package.json +2 -2
  112. package/src/components/Box.styles.ts +31 -1
  113. package/src/components/FormComponents/BooleanItem/BooleanItem.tsx +6 -2
  114. package/src/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.tsx +19 -23
  115. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.tsx +15 -18
  116. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx +16 -19
  117. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx +15 -19
  118. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +17 -21
  119. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx +15 -19
  120. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.tsx +17 -21
  121. package/src/components/FormComponents/CustomDateItem/CustomDateItem.tsx +7 -2
  122. package/src/components/FormComponents/DateItem/DateItem.tsx +7 -2
  123. package/src/components/FormComponents/DateTimeItem/DateTimeItem.tsx +7 -2
  124. package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +9 -3
  125. package/src/components/FormComponents/IntegerItem/IntegerField.tsx +1 -0
  126. package/src/components/FormComponents/IntegerItem/IntegerItem.tsx +9 -3
  127. package/{lib/components/BackToTopButton/BackToTopButton.js → src/components/FormComponents/ItemParts/ItemExtensionLabels.tsx} +23 -15
  128. package/src/components/FormComponents/ItemParts/ItemFieldGrid.tsx +14 -9
  129. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.tsx +21 -25
  130. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx +20 -23
  131. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.tsx +18 -22
  132. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.tsx +16 -20
  133. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.tsx +17 -21
  134. package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +8 -4
  135. package/src/components/FormComponents/SliderItem/SliderItem.tsx +6 -2
  136. package/src/components/FormComponents/StringItem/StringItem.tsx +9 -3
  137. package/src/components/FormComponents/Tables/GroupTable.tsx +0 -2
  138. package/src/components/FormComponents/Tables/GroupTableRow.tsx +6 -2
  139. package/src/components/FormComponents/Tables/GroupTableView.tsx +1 -0
  140. package/src/components/FormComponents/Tables/SelectRowButton.tsx +9 -2
  141. package/src/components/FormComponents/TextItem/TextItem.tsx +9 -3
  142. package/src/components/FormComponents/TimeItem/TimeItem.tsx +7 -2
  143. package/src/components/FormComponents/UrlItem/UrlItem.tsx +9 -3
  144. package/src/components/Renderer/BaseRenderer.tsx +12 -0
  145. package/src/components/Renderer/FormBodyCollapsible.tsx +9 -3
  146. package/src/components/Renderer/FormBodySingleCollapsibleWrapper.tsx +10 -3
  147. package/src/components/Renderer/FormBodyTabbed.tsx +9 -3
  148. package/src/components/Renderer/FormTopLevelItem.tsx +13 -3
  149. package/src/components/Renderer/SmartFormsRenderer.tsx +5 -2
  150. package/src/hooks/useInitialiseRenderer.ts +6 -3
  151. package/src/hooks/useRenderingExtensions.ts +17 -11
  152. package/src/hooks/{useValidationError.ts → useValidationFeedback.ts} +23 -21
  153. package/src/stores/questionnaireResponseStore.ts +36 -1
  154. package/src/stores/questionnaireStore.ts +8 -3
  155. package/src/stories/SmartFormsRenderer.stories.ts +16 -0
  156. package/src/utils/itemControl.ts +1 -67
  157. package/src/utils/mapItem.ts +2 -0
  158. package/src/utils/validateQuestionnaire.ts +273 -0
  159. package/lib/components/BackToTopButton/BackToTopButton.d.ts +0 -7
  160. package/lib/components/BackToTopButton/BackToTopButton.js.map +0 -1
  161. package/lib/components/FormComponents/CustomDateItem/CustomDateField2.d.ts +0 -18
  162. package/lib/components/FormComponents/CustomDateItem/CustomDateField2.js +0 -31
  163. package/lib/components/FormComponents/CustomDateItem/CustomDateField2.js.map +0 -1
  164. package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.d.ts +0 -9
  165. package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.js +0 -75
  166. package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.js.map +0 -1
  167. package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.d.ts +0 -9
  168. package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.js +0 -75
  169. package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.js.map +0 -1
  170. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.d.ts +0 -5
  171. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.js +0 -27
  172. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.js.map +0 -1
  173. package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.d.ts +0 -9
  174. package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.js +0 -71
  175. package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.js.map +0 -1
  176. package/lib/components/FormComponents/DateItem/DatePicker.d.ts +0 -2
  177. package/lib/components/FormComponents/DateItem/DatePicker.js +0 -42
  178. package/lib/components/FormComponents/DateItem/DatePicker.js.map +0 -1
  179. package/lib/components/FormComponents/DateItem/DatePickerField.d.ts +0 -8
  180. package/lib/components/FormComponents/DateItem/DatePickerField.js.map +0 -1
  181. package/lib/components/FormComponents/DisplayItem/DisplayBox.d.ts +0 -0
  182. package/lib/components/FormComponents/DisplayItem/DisplayBox.js +0 -2
  183. package/lib/components/FormComponents/DisplayItem/DisplayBox.js.map +0 -1
  184. package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.d.ts +0 -4
  185. package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.js +0 -35
  186. package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.js.map +0 -1
  187. package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.d.ts +0 -10
  188. package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.js +0 -73
  189. package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.js.map +0 -1
  190. package/lib/components/FormComponents/GroupItem/ItemSwitcher.d.ts +0 -10
  191. package/lib/components/FormComponents/GroupItem/ItemSwitcher.js +0 -81
  192. package/lib/components/FormComponents/GroupItem/ItemSwitcher.js.map +0 -1
  193. package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.d.ts +0 -10
  194. package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.js +0 -45
  195. package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.js.map +0 -1
  196. package/lib/components/FormComponents/IntegerItem/SliderItem.d.ts +0 -9
  197. package/lib/components/FormComponents/IntegerItem/SliderItem.js +0 -75
  198. package/lib/components/FormComponents/IntegerItem/SliderItem.js.map +0 -1
  199. package/lib/components/FormComponents/ItemParts/RadioButtons.d.ts +0 -8
  200. package/lib/components/FormComponents/ItemParts/RadioButtons.js +0 -37
  201. package/lib/components/FormComponents/ItemParts/RadioButtons.js.map +0 -1
  202. package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.d.ts +0 -8
  203. package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.js +0 -37
  204. package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.js.map +0 -1
  205. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.d.ts +0 -0
  206. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.js +0 -2
  207. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.js.map +0 -1
  208. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.d.ts +0 -0
  209. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.js +0 -2
  210. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.js.map +0 -1
  211. package/lib/components/FormComponents/RepeatItem/DeleteItemButton.d.ts +0 -10
  212. package/lib/components/FormComponents/RepeatItem/DeleteItemButton.js +0 -30
  213. package/lib/components/FormComponents/RepeatItem/DeleteItemButton.js.map +0 -1
  214. package/lib/components/FormComponents/SliderItem/DisplayBox.styles.d.ts +0 -4
  215. package/lib/components/FormComponents/SliderItem/DisplayBox.styles.js +0 -35
  216. package/lib/components/FormComponents/SliderItem/DisplayBox.styles.js.map +0 -1
  217. package/lib/components/FormComponents/Tables/AddItemButton.d.ts +0 -8
  218. package/lib/components/FormComponents/Tables/AddItemButton.js +0 -28
  219. package/lib/components/FormComponents/Tables/AddItemButton.js.map +0 -1
  220. package/lib/components/FormComponents/Tables/DeleteRowButton.d.ts +0 -10
  221. package/lib/components/FormComponents/Tables/DeleteRowButton.js +0 -32
  222. package/lib/components/FormComponents/Tables/DeleteRowButton.js.map +0 -1
  223. package/lib/components/FormComponents/Tables/GroupTableRows.d.ts +0 -17
  224. package/lib/components/FormComponents/Tables/GroupTableRows.js +0 -45
  225. package/lib/components/FormComponents/Tables/GroupTableRows.js.map +0 -1
  226. package/lib/components/FormComponents/Tables/GroupTableTestRow.d.ts +0 -22
  227. package/lib/components/FormComponents/Tables/GroupTableTestRow.js +0 -43
  228. package/lib/components/FormComponents/Tables/GroupTableTestRow.js.map +0 -1
  229. package/lib/components/FormComponents/Tables/QItemGroupTable.d.ts +0 -10
  230. package/lib/components/FormComponents/Tables/QItemGroupTable.js +0 -109
  231. package/lib/components/FormComponents/Tables/QItemGroupTable.js.map +0 -1
  232. package/lib/components/FormComponents/Tables/QItemGroupTableRow.d.ts +0 -10
  233. package/lib/components/FormComponents/Tables/QItemGroupTableRow.js +0 -46
  234. package/lib/components/FormComponents/Tables/QItemGroupTableRow.js.map +0 -1
  235. package/lib/components/FormComponents/Typography.styles.d.ts +0 -6
  236. package/lib/components/FormComponents/Typography.styles.js +0 -24
  237. package/lib/components/FormComponents/Typography.styles.js.map +0 -1
  238. package/lib/hooks/useBackToTop.d.ts +0 -2
  239. package/lib/hooks/useBackToTop.js +0 -26
  240. package/lib/hooks/useBackToTop.js.map +0 -1
  241. package/lib/hooks/useDateSeparatorValidation.d.ts +0 -2
  242. package/lib/hooks/useDateSeparatorValidation.js +0 -25
  243. package/lib/hooks/useDateSeparatorValidation.js.map +0 -1
  244. package/lib/hooks/useDecimalUpdateFromProp.d.ts +0 -2
  245. package/lib/hooks/useDecimalUpdateFromProp.js +0 -29
  246. package/lib/hooks/useDecimalUpdateFromProp.js.map +0 -1
  247. package/lib/hooks/useIntegerUpdateFromProp.d.ts +0 -2
  248. package/lib/hooks/useIntegerUpdateFromProp.js +0 -29
  249. package/lib/hooks/useIntegerUpdateFromProp.js.map +0 -1
  250. package/lib/hooks/useMinimalStringCalculatedExpression.d.ts +0 -11
  251. package/lib/hooks/useMinimalStringCalculatedExpression.js +0 -49
  252. package/lib/hooks/useMinimalStringCalculatedExpression.js.map +0 -1
  253. package/lib/hooks/useNumberUpdateFromProp.d.ts +0 -2
  254. package/lib/hooks/useNumberUpdateFromProp.js +0 -29
  255. package/lib/hooks/useNumberUpdateFromProp.js.map +0 -1
  256. package/lib/hooks/useRepeatItemState.d.ts +0 -5
  257. package/lib/hooks/useRepeatItemState.js +0 -35
  258. package/lib/hooks/useRepeatItemState.js.map +0 -1
  259. package/lib/hooks/useRepeatItemUpdateFromProp.d.ts +0 -2
  260. package/lib/hooks/useRepeatItemUpdateFromProp.js +0 -29
  261. package/lib/hooks/useRepeatItemUpdateFromProp.js.map +0 -1
  262. package/lib/hooks/useStringField.d.ts +0 -2
  263. package/lib/hooks/useStringField.js +0 -29
  264. package/lib/hooks/useStringField.js.map +0 -1
  265. package/lib/hooks/useStringUpdateFromProp.d.ts +0 -2
  266. package/lib/hooks/useStringUpdateFromProp.js +0 -29
  267. package/lib/hooks/useStringUpdateFromProp.js.map +0 -1
  268. package/lib/hooks/useValidationError.d.ts +0 -3
  269. package/lib/hooks/useValidationError.js +0 -38
  270. package/lib/hooks/useValidationError.js.map +0 -1
  271. package/lib/interfaces/index.d.ts +0 -2
  272. package/lib/interfaces/index.js +0 -18
  273. package/lib/interfaces/index.js.map +0 -1
  274. package/lib/setup-jest.js +0 -1
  275. package/lib/setup-jest.js.map +0 -1
  276. package/lib/stores/useQuestionnaireResponseStore.d.ts +0 -27
  277. package/lib/stores/useQuestionnaireResponseStore.js +0 -49
  278. package/lib/stores/useQuestionnaireResponseStore.js.map +0 -1
  279. package/lib/stores/useQuestionnaireStore.d.ts +0 -64
  280. package/lib/stores/useQuestionnaireStore.js +0 -173
  281. package/lib/stores/useQuestionnaireStore.js.map +0 -1
  282. package/lib/stores/useSmartConfigStore.d.ts +0 -14
  283. package/lib/stores/useSmartConfigStore.js +0 -13
  284. package/lib/stores/useSmartConfigStore.js.map +0 -1
  285. package/lib/stores/useTerminologyServerStore.d.ts +0 -7
  286. package/lib/stores/useTerminologyServerStore.js +0 -25
  287. package/lib/stores/useTerminologyServerStore.js.map +0 -1
  288. package/lib/stories/MedicalHistoryTable.stories.js +0 -45
  289. package/lib/stories/MedicalHistoryTable.stories.js.map +0 -1
  290. package/lib/stories/SmartFormsRenderer.stories.js +0 -103
  291. package/lib/stories/SmartFormsRenderer.stories.js.map +0 -1
  292. package/lib/test.d.ts +0 -4
  293. package/lib/test.js +0 -18
  294. package/lib/test.js.map +0 -1
  295. package/lib/theme/overrides/Backdrop.d.ts +0 -13
  296. package/lib/theme/overrides/Backdrop.js +0 -32
  297. package/lib/theme/overrides/Backdrop.js.map +0 -1
  298. package/lib/theme/overrides/Typography.d.ts +0 -13
  299. package/lib/theme/overrides/Typography.js +0 -31
  300. package/lib/theme/overrides/Typography.js.map +0 -1
  301. package/lib/utils/formChangesOld.d.ts +0 -18
  302. package/lib/utils/formChangesOld.js +0 -91
  303. package/lib/utils/formChangesOld.js.map +0 -1
  304. package/lib/utils/initialiseForm.d.ts +0 -22
  305. package/lib/utils/initialiseForm.js +0 -53
  306. package/lib/utils/initialiseForm.js.map +0 -1
  307. package/lib/utils/launchContext.d.ts +0 -0
  308. package/lib/utils/launchContext.js +0 -2
  309. package/lib/utils/launchContext.js.map +0 -1
  310. package/lib/utils/populateInputParams.d.ts +0 -8
  311. package/lib/utils/populateInputParams.js +0 -193
  312. package/lib/utils/populateInputParams.js.map +0 -1
  313. package/lib/utils/removeHidden.d.ts +0 -16
  314. package/lib/utils/removeHidden.js +0 -105
  315. package/lib/utils/removeHidden.js.map +0 -1
  316. package/lib/utils/repopulate.d.ts +0 -9
  317. package/lib/utils/repopulate.js +0 -133
  318. package/lib/utils/repopulate.js.map +0 -1
  319. package/lib/utils/repopulateGenerateItems.d.ts +0 -9
  320. package/lib/utils/repopulateGenerateItems.js +0 -133
  321. package/lib/utils/repopulateGenerateItems.js.map +0 -1
  322. package/lib/utils/repopulateRepeatGroup.d.ts +0 -4
  323. package/lib/utils/repopulateRepeatGroup.js +0 -62
  324. package/lib/utils/repopulateRepeatGroup.js.map +0 -1
@@ -1,193 +0,0 @@
1
- /*
2
- * Copyright 2023 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
- function createPatientSubject(questionnaire, patient) {
18
- const subjectTypes = questionnaire.subjectType;
19
- // If subjectTypes array is not empty AND "Patient" is not in the array, we cannot create a Patient subject reference.
20
- if (subjectTypes && subjectTypes.length > 0) {
21
- const patientSubject = subjectTypes.find((subject) => subject === 'Patient');
22
- if (!patientSubject) {
23
- return null;
24
- }
25
- }
26
- return {
27
- type: 'Patient',
28
- reference: 'Patient/' + patient.id
29
- };
30
- }
31
- function createCanonicalParam(canonicalUrl) {
32
- return {
33
- name: 'canonical',
34
- valueString: canonicalUrl
35
- };
36
- }
37
- // setting local parameter as false as we are calling $populate with an NPM package, not a server
38
- // package doesn't contain any fhir resources to "know" the context from
39
- function createLocalParam() {
40
- return {
41
- name: 'local',
42
- valueBoolean: false
43
- };
44
- }
45
- function createLaunchContextParam(launchContext, patient, user, encounter) {
46
- var _a, _b;
47
- const name = (_a = launchContext.extension[0].valueId) !== null && _a !== void 0 ? _a : (_b = launchContext.extension[0].valueCoding) === null || _b === void 0 ? void 0 : _b.code;
48
- if (!name) {
49
- return null;
50
- }
51
- // let resource :string
52
- const resourceType = launchContext.extension[1].valueCode;
53
- let resource;
54
- switch (resourceType) {
55
- case 'Patient':
56
- resource = patient;
57
- break;
58
- case 'Practitioner':
59
- resource = user;
60
- break;
61
- case 'Encounter':
62
- resource = encounter;
63
- break;
64
- default:
65
- return null;
66
- }
67
- if (!resource) {
68
- return null;
69
- }
70
- return {
71
- name: 'context',
72
- part: [
73
- {
74
- name: 'name',
75
- valueString: name
76
- },
77
- {
78
- name: 'content',
79
- resource: resource
80
- }
81
- ]
82
- };
83
- }
84
- function createSourceQueryParams(sourceQuery, index) {
85
- const reference = sourceQuery.valueReference.reference;
86
- if (reference && reference.startsWith('#')) {
87
- const containedReference = reference.slice(1);
88
- return {
89
- name: 'context',
90
- part: [
91
- {
92
- name: 'name',
93
- valueString: containedReference
94
- },
95
- {
96
- name: 'content',
97
- valueReference: sourceQuery.valueReference
98
- }
99
- ]
100
- };
101
- }
102
- // if sourceQuery cannot be referenced to a contained bundle, return itself as a context
103
- // this most likely shouldn't happen
104
- return {
105
- name: 'context',
106
- part: [
107
- {
108
- name: 'name',
109
- valueString: `sourceQuery${index}`
110
- },
111
- {
112
- name: 'content',
113
- valueReference: sourceQuery.valueReference
114
- }
115
- ]
116
- };
117
- }
118
- function createVariableParam(variable) {
119
- const query = variable.valueExpression.expression;
120
- const resourceType = query.split('?')[0];
121
- return {
122
- name: 'context',
123
- part: [
124
- {
125
- name: 'name',
126
- valueString: variable.valueExpression.name
127
- },
128
- {
129
- name: 'content',
130
- valueReference: { reference: query, type: resourceType }
131
- }
132
- ]
133
- };
134
- }
135
- /**
136
- * Define population input parameters without any batch response contexts
137
- *
138
- * @author Sean Fong
139
- */
140
- export function createPopulateInputParameters(questionnaire, patient, user, encounter, launchContexts, sourceQueries, questionnaireLevelVariables) {
141
- var _a, _b, _c;
142
- const patientSubject = createPatientSubject(questionnaire, patient);
143
- if (!patientSubject) {
144
- return null;
145
- }
146
- const inputParameters = {
147
- resourceType: 'Parameters',
148
- parameter: [
149
- {
150
- name: 'questionnaire',
151
- resource: questionnaire
152
- },
153
- {
154
- name: 'subject',
155
- valueReference: patientSubject
156
- }
157
- ]
158
- };
159
- // canonical
160
- if (questionnaire.url) {
161
- (_a = inputParameters.parameter) === null || _a === void 0 ? void 0 : _a.push(createCanonicalParam(questionnaire.url));
162
- }
163
- // contexts
164
- const contexts = [];
165
- // add launch contexts
166
- if (launchContexts.length > 0) {
167
- for (const launchContext of launchContexts) {
168
- const launchContextParam = createLaunchContextParam(launchContext, patient, user, encounter);
169
- if (launchContextParam) {
170
- contexts.push(launchContextParam);
171
- }
172
- }
173
- }
174
- // add source queries
175
- if (sourceQueries.length > 0) {
176
- for (const [index, sourceQuery] of sourceQueries.entries()) {
177
- contexts.push(createSourceQueryParams(sourceQuery, index));
178
- }
179
- }
180
- // add questionnaire-level variables
181
- if (questionnaireLevelVariables.length > 0) {
182
- for (const variable of questionnaireLevelVariables) {
183
- contexts.push(createVariableParam(variable));
184
- }
185
- }
186
- if (contexts.length > 0) {
187
- (_b = inputParameters.parameter) === null || _b === void 0 ? void 0 : _b.push(...contexts);
188
- }
189
- // local
190
- (_c = inputParameters.parameter) === null || _c === void 0 ? void 0 : _c.push(createLocalParam());
191
- return inputParameters;
192
- }
193
- //# sourceMappingURL=populateInputParams.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"populateInputParams.js","sourceRoot":"","sources":["../../src/utils/populateInputParams.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAmBH,SAAS,oBAAoB,CAAC,aAA4B,EAAE,OAAgB;IAC1E,MAAM,YAAY,GAAG,aAAa,CAAC,WAAW,CAAC;IAE/C,sHAAsH;IACtH,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3C,MAAM,cAAc,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC;QAC7E,IAAI,CAAC,cAAc,EAAE;YACnB,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO;QACL,IAAI,EAAE,SAAS;QACf,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,EAAE;KACnC,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,YAAoB;IAChD,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,YAAY;KAC1B,CAAC;AACJ,CAAC;AAED,iGAAiG;AACjG,wEAAwE;AACxE,SAAS,gBAAgB;IACvB,OAAO;QACL,IAAI,EAAE,OAAO;QACb,YAAY,EAAE,KAAK;KACpB,CAAC;AACJ,CAAC;AAED,SAAS,wBAAwB,CAC/B,aAA4B,EAC5B,OAAgB,EAChB,IAAkB,EAClB,SAA2B;;IAE3B,MAAM,IAAI,GAAG,MAAA,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,mCAAI,MAAA,aAAa,CAAC,SAA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CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;KAC1E;IAED,WAAW;IACX,MAAM,QAAQ,GAA0B,EAAE,CAAC;IAC3C,sBAAsB;IACtB,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7B,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE;YAC1C,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;YAC7F,IAAI,kBAAkB,EAAE;gBACtB,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;aACnC;SACF;KACF;IAED,qBAAqB;IACrB,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;QAC5B,KAAK,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,aAAa,CAAC,OAAO,EAAE,EAAE;YAC1D,QAAQ,CAAC,IAAI,CAAC,uBAAuB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;SAC5D;KACF;IAED,oCAAoC;IACpC,IAAI,2BAA2B,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1C,KAAK,MAAM,QAAQ,IAAI,2BAA2B,EAAE;YAClD,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;SAC9C;KACF;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,MAAA,eAAe,CAAC,SAAS,0CAAE,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;KAC9C;IAED,QAAQ;IACR,MAAA,eAAe,CAAC,SAAS,0CAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAEpD,OAAO,eAAe,CAAC;AACzB,CAAC"}
@@ -1,16 +0,0 @@
1
- import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
2
- import type { EnableWhenExpression, EnableWhenItems } from '../interfaces/enableWhen.interface';
3
- interface removeHiddenAnswersParams {
4
- questionnaire: Questionnaire;
5
- questionnaireResponse: QuestionnaireResponse;
6
- enableWhenIsActivated: boolean;
7
- enableWhenItems: EnableWhenItems;
8
- enableWhenExpressions: Record<string, EnableWhenExpression>;
9
- }
10
- /**
11
- * Recursively go through the questionnaireResponse and remove qrItems whose qItems are hidden in the form
12
- *
13
- * @author Sean Fong
14
- */
15
- export declare function removeHiddenAnswers(params: removeHiddenAnswersParams): QuestionnaireResponse;
16
- export {};
@@ -1,105 +0,0 @@
1
- /*
2
- * Copyright 2023 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 { isHidden } from './qItem';
18
- /**
19
- * Recursively go through the questionnaireResponse and remove qrItems whose qItems are hidden in the form
20
- *
21
- * @author Sean Fong
22
- */
23
- export function removeHiddenAnswers(params) {
24
- const { questionnaire, questionnaireResponse, enableWhenIsActivated, enableWhenItems, enableWhenExpressions } = params;
25
- const topLevelQItems = questionnaire.item;
26
- const topLevelQRItems = questionnaireResponse.item;
27
- if (!topLevelQItems ||
28
- topLevelQItems.length === 0 ||
29
- !topLevelQRItems ||
30
- topLevelQRItems.length === 0) {
31
- return questionnaireResponse;
32
- }
33
- topLevelQRItems.forEach((qrItem, i) => {
34
- const qItem = topLevelQItems[i];
35
- const newTopLevelQRItem = readQuestionnaireResponseItemRecursive({
36
- qItem,
37
- qrItem,
38
- enableWhenIsActivated,
39
- enableWhenItems,
40
- enableWhenExpressions
41
- });
42
- if (newTopLevelQRItem && questionnaireResponse.item) {
43
- questionnaireResponse.item[i] = Object.assign({}, newTopLevelQRItem);
44
- }
45
- });
46
- return questionnaireResponse;
47
- }
48
- function readQuestionnaireResponseItemRecursive(params) {
49
- const { qItem, qrItem, enableWhenIsActivated, enableWhenItems, enableWhenExpressions } = params;
50
- const qItems = qItem.item;
51
- const qrItems = qrItem.item;
52
- // Process group items
53
- if (qItems && qItems.length > 0) {
54
- // Return nothing if corresponding qItem is hidden
55
- if (isHidden({
56
- questionnaireItem: qItem,
57
- enableWhenIsActivated,
58
- enableWhenItems,
59
- enableWhenExpressions
60
- })) {
61
- return null;
62
- }
63
- if (qrItems && qrItems.length > 0) {
64
- const newQrItems = [];
65
- // Loop over qItems - but end loop if we either reach the end of qItems or qrItems
66
- // Under normal circumstances we will reach the end of both arrays together
67
- for (let qItemIndex = 0, qrItemIndex = 0; qItemIndex < qItems.length || qrItemIndex < qrItems.length; qItemIndex++) {
68
- // Save qrItem if linkIds of current qItem and qrItem are the same
69
- if (qrItems[qrItemIndex] && qItems[qItemIndex].linkId === qrItems[qrItemIndex].linkId) {
70
- const newQrItem = readQuestionnaireResponseItemRecursive({
71
- qItem: qItems[qItemIndex],
72
- qrItem: qrItems[qrItemIndex],
73
- enableWhenIsActivated,
74
- enableWhenItems,
75
- enableWhenExpressions
76
- });
77
- if (newQrItem) {
78
- newQrItems.push(newQrItem);
79
- }
80
- // Decrement qItem index if the next qrItem is an answer from a repeatGroup
81
- // Essentially persisting the current qItem linked to be matched up with the next qrItem linkId
82
- if (qrItems.length !== qrItemIndex + 1 &&
83
- qrItems[qrItemIndex].linkId === qrItems[qrItemIndex + 1].linkId) {
84
- qItemIndex--;
85
- }
86
- // Only Increment qrItem index whenever the current qrItem linkId matches up with the current qItem
87
- qrItemIndex++;
88
- }
89
- }
90
- return Object.assign(Object.assign({}, qrItem), { item: newQrItems });
91
- }
92
- // Also perform checking if answer exists
93
- return qrItem['answer'] ? qrItem : null;
94
- }
95
- // Process non-group items
96
- return isHidden({
97
- questionnaireItem: qItem,
98
- enableWhenIsActivated,
99
- enableWhenItems,
100
- enableWhenExpressions
101
- })
102
- ? null
103
- : Object.assign({}, qrItem);
104
- }
105
- //# sourceMappingURL=removeHidden.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"removeHidden.js","sourceRoot":"","sources":["../../src/utils/removeHidden.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUnC;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAiC;IACnE,MAAM,EACJ,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACtB,GAAG,MAAM,CAAC;IAEX,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC;IAC1C,MAAM,eAAe,GAAG,qBAAqB,CAAC,IAAI,CAAC;IACnD,IACE,CAAC,cAAc;QACf,cAAc,CAAC,MAAM,KAAK,CAAC;QAC3B,CAAC,eAAe;QAChB,eAAe,CAAC,MAAM,KAAK,CAAC,EAC5B;QACA,OAAO,qBAAqB,CAAC;KAC9B;IAED,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,iBAAiB,GAAG,sCAAsC,CAAC;YAC/D,KAAK;YACL,MAAM;YACN,qBAAqB;YACrB,eAAe;YACf,qBAAqB;SACtB,CAAC,CAAC;QACH,IAAI,iBAAiB,IAAI,qBAAqB,CAAC,IAAI,EAAE;YACnD,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,qBAAQ,iBAAiB,CAAE,CAAC;SAC1D;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAUD,SAAS,sCAAsC,CAC7C,MAAoD;IAEpD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,eAAe,EAAE,qBAAqB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AC/D;wBACA,UAAU,EAAE,CAAC;qBACd;oBAED,mGAAmG;oBACnG,WAAW,EAAE,CAAC;iBACf;aACF;YACD,uCAAY,MAAM,KAAE,IAAI,EAAE,UAAU,IAAG;SACxC;QAED,yCAAyC;QACzC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;KACzC;IAED,0BAA0B;IAC1B,OAAO,QAAQ,CAAC;QACd,iBAAiB,EAAE,KAAK;QACxB,qBAAqB;QACrB,eAAe;QACf,qBAAqB;KACtB,CAAC;QACA,CAAC,CAAC,IAAI;QACN,CAAC,mBAAM,MAAM,CAAE,CAAC;AACpB,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { Questionnaire, QuestionnaireItem, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';
2
- import type { Tabs } from '../interfaces/tab.interface';
3
- export interface ItemToRepopulate {
4
- qItem: QuestionnaireItem | null;
5
- heading: string | null;
6
- newQRItem: QuestionnaireResponseItem;
7
- oldQRItem?: QuestionnaireResponseItem;
8
- }
9
- export declare function getItemsToRepopulate(sourceQuestionnaire: Questionnaire, itemTypes: Record<string, string>, tabs: Tabs, populatedResponse: QuestionnaireResponse, updatableResponse: QuestionnaireResponse): Record<string, ItemToRepopulate>;
@@ -1,133 +0,0 @@
1
- /*
2
- * Copyright 2023 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 _isEqual from 'lodash/isEqual';
18
- import { containsTabs, isTabContainer } from './tabs';
19
- import { getShortText } from './itemControl';
20
- import { checkIsRepeatGroupToRepopulate, getRepeatGroupToRepopulate } from './repopulateRepeatGroup';
21
- export function getItemsToRepopulate(sourceQuestionnaire, itemTypes, tabs, populatedResponse, updatableResponse) {
22
- var _a;
23
- if (!sourceQuestionnaire.item ||
24
- sourceQuestionnaire.item.length === 0 ||
25
- !populatedResponse.item ||
26
- populatedResponse.item.length === 0 ||
27
- !updatableResponse.item ||
28
- updatableResponse.item.length === 0) {
29
- return {};
30
- }
31
- const populatedItems = [];
32
- for (const topLevelItem of populatedResponse.item) {
33
- populatedItems.push(...getPopulatedItemsRecursive(topLevelItem, itemTypes));
34
- }
35
- const itemsToRepopulate = populatedItems.reduce((mapping, item) => {
36
- mapping[item.linkId] = {
37
- qItem: null,
38
- heading: null,
39
- newQRItem: item
40
- };
41
- return mapping;
42
- }, {});
43
- // Get corresponding old items from updatableResponse if they are different
44
- for (const topLevelItem of updatableResponse.item) {
45
- checkCorrespondingOldItemsRecursive(topLevelItem, itemTypes, itemsToRepopulate);
46
- }
47
- // Get corresponding old items from updatableResponse if they are different
48
- for (const topLevelItem of sourceQuestionnaire.item) {
49
- const heading = (_a = topLevelItem.text) !== null && _a !== void 0 ? _a : null;
50
- const hasTabs = isTabContainer(topLevelItem) || containsTabs(topLevelItem);
51
- getCorrespondingQuestionnaireItemsRecursive(topLevelItem, heading, tabs, hasTabs, itemsToRepopulate);
52
- }
53
- return itemsToRepopulate;
54
- }
55
- // 1. Get items to repopulate (only new items)
56
- // 2. Get corresponding old items from updatableResponse (if they are different)
57
- // 3. Compare old and new items in dialog - if there are none, show a dialog saying there is no new data
58
- // 4. Have checkboxes in dialog to update response
59
- // 5. Replace old answers with new answers
60
- function getCorrespondingQuestionnaireItemsRecursive(qItem, heading, tabs, hasTabs, itemsToRepopulate) {
61
- var _a, _b;
62
- if (qItem.type === 'group' && qItem.item && qItem.item.length > 0) {
63
- const isTab = !!tabs[qItem.linkId];
64
- if (isTab) {
65
- heading = (_b = (_a = getShortText(qItem)) !== null && _a !== void 0 ? _a : qItem.text) !== null && _b !== void 0 ? _b : null;
66
- }
67
- // TODO it seems like there can only be one answer per linkId, we might need to do repeat groups differently
68
- // so we need to fix this one first it seems like
69
- /* Repeat group implementation */
70
- if (qItem.type === 'group' && qItem.repeats) {
71
- const isRepeatGroupToRepopulate = checkIsRepeatGroupToRepopulate(qItem, itemsToRepopulate);
72
- if (isRepeatGroupToRepopulate) {
73
- const repeatGroupToRepopulate = getRepeatGroupToRepopulate(qItem, itemsToRepopulate);
74
- if (repeatGroupToRepopulate) {
75
- itemsToRepopulate[qItem.linkId] = repeatGroupToRepopulate;
76
- return;
77
- }
78
- }
79
- }
80
- // /* Grid implementation */
81
- // if (qItem.type === 'group' && isSpecificItemControl(qItem, 'grid')) {
82
- // const isRepeatGroupToRepopulate = checkIsRepeatGroupToRepopulate(qItem, itemsToRepopulate);
83
- // if (isRepeatGroupToRepopulate) {
84
- // getRepeatGroupToRepopulate(qItem, itemsToRepopulate);
85
- // }
86
- // }
87
- /* */
88
- // console.log(itemsToRepopulate);
89
- for (const childItem of qItem.item) {
90
- getCorrespondingQuestionnaireItemsRecursive(childItem, heading, tabs, hasTabs, itemsToRepopulate);
91
- }
92
- return;
93
- }
94
- if (!itemsToRepopulate[qItem.linkId]) {
95
- return;
96
- }
97
- itemsToRepopulate[qItem.linkId].qItem = qItem;
98
- itemsToRepopulate[qItem.linkId].heading = heading;
99
- }
100
- function getPopulatedItemsRecursive(qrItem, itemTypes) {
101
- const itemType = itemTypes[qrItem.linkId];
102
- if (itemType === 'group' && qrItem.item && qrItem.item.length > 0) {
103
- const populatedChildItems = [];
104
- for (const childItem of qrItem.item) {
105
- populatedChildItems.push(...getPopulatedItemsRecursive(childItem, itemTypes));
106
- }
107
- return populatedChildItems;
108
- }
109
- // record item if it is not a group item
110
- return [qrItem];
111
- }
112
- function checkCorrespondingOldItemsRecursive(qrItem, itemTypes, itemsToRepopulate) {
113
- var _a;
114
- const itemType = itemTypes[qrItem.linkId];
115
- if (itemType === 'group' && qrItem.item && qrItem.item.length > 0) {
116
- for (const childItem of qrItem.item) {
117
- checkCorrespondingOldItemsRecursive(childItem, itemTypes, itemsToRepopulate);
118
- }
119
- return;
120
- }
121
- const oldItem = qrItem;
122
- const newItem = (_a = itemsToRepopulate[qrItem.linkId]) === null || _a === void 0 ? void 0 : _a.newQRItem;
123
- if (!newItem) {
124
- return;
125
- }
126
- if (_isEqual(oldItem, newItem)) {
127
- delete itemsToRepopulate[qrItem.linkId];
128
- return;
129
- }
130
- // const filteredNewItems = newItems.filter((newItem) => !_isEqual(oldItem, newItem));
131
- itemsToRepopulate[qrItem.linkId].oldQRItem = oldItem;
132
- }
133
- //# sourceMappingURL=repopulate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repopulate.js","sourceRoot":"","sources":["../../src/utils/repopulate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AASjC,MAAM,UAAU,oBAAoB,CAClC,mBAAkC,EAClC,SAAiC,EACjC,IAAU,EACV,iBAAwC,EACxC,iBAAwC;;IAExC,IACE,CAAC,mBAAmB,CAAC,IAAI;QACzB,mBAAmB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QACrC,CAAC,iBAAiB,CAAC,IAAI;QACvB,iBAAiB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QACnC,CAAC,iBAAiB,CAAC,IAAI;QACvB,iBAAiB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EACnC;QACA,OAAO,EAAE,CAAC;KACX;IAED,MAAM,cAAc,GAAgC,EA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QuestionnaireItem, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';
2
- import type { Tabs } from '../interfaces/tab.interface';
3
- export interface ItemToRepopulate {
4
- qItem: QuestionnaireItem | null;
5
- heading: string | null;
6
- newQRItem: QuestionnaireResponseItem;
7
- oldQRItem?: QuestionnaireResponseItem;
8
- }
9
- export declare function getItemsToRepopulate(sourceQuestionnaire: Questionnaire, itemTypes: Record<string, string>, tabs: Tabs, populatedResponse: QuestionnaireResponse, updatableResponse: QuestionnaireResponse): Record<string, ItemToRepopulate>;
@@ -1,133 +0,0 @@
1
- /*
2
- * Copyright 2023 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 _isEqual from 'lodash/isEqual';
18
- import { containsTabs, isTabContainer } from './tabs';
19
- import { getShortText } from './itemControl';
20
- import { checkIsRepeatGroupToRepopulate, getRepeatGroupToRepopulate } from './repopulateRepeatGroup';
21
- export function getItemsToRepopulate(sourceQuestionnaire, itemTypes, tabs, populatedResponse, updatableResponse) {
22
- var _a;
23
- if (!sourceQuestionnaire.item ||
24
- sourceQuestionnaire.item.length === 0 ||
25
- !populatedResponse.item ||
26
- populatedResponse.item.length === 0 ||
27
- !updatableResponse.item ||
28
- updatableResponse.item.length === 0) {
29
- return {};
30
- }
31
- const populatedItems = [];
32
- for (const topLevelItem of populatedResponse.item) {
33
- populatedItems.push(...getPopulatedItemsRecursive(topLevelItem, itemTypes));
34
- }
35
- const itemsToRepopulate = populatedItems.reduce((mapping, item) => {
36
- mapping[item.linkId] = {
37
- qItem: null,
38
- heading: null,
39
- newQRItem: item
40
- };
41
- return mapping;
42
- }, {});
43
- // Get corresponding old items from updatableResponse if they are different
44
- for (const topLevelItem of updatableResponse.item) {
45
- checkCorrespondingOldItemsRecursive(topLevelItem, itemTypes, itemsToRepopulate);
46
- }
47
- // Get corresponding old items from updatableResponse if they are different
48
- for (const topLevelItem of sourceQuestionnaire.item) {
49
- const heading = (_a = topLevelItem.text) !== null && _a !== void 0 ? _a : null;
50
- const hasTabs = isTabContainer(topLevelItem) || containsTabs(topLevelItem);
51
- getCorrespondingQuestionnaireItemsRecursive(topLevelItem, heading, tabs, hasTabs, itemsToRepopulate);
52
- }
53
- return itemsToRepopulate;
54
- }
55
- // 1. Get items to repopulate (only new items)
56
- // 2. Get corresponding old items from updatableResponse (if they are different)
57
- // 3. Compare old and new items in dialog - if there are none, show a dialog saying there is no new data
58
- // 4. Have checkboxes in dialog to update response
59
- // 5. Replace old answers with new answers
60
- function getCorrespondingQuestionnaireItemsRecursive(qItem, heading, tabs, hasTabs, itemsToRepopulate) {
61
- var _a, _b;
62
- if (qItem.type === 'group' && qItem.item && qItem.item.length > 0) {
63
- const isTab = !!tabs[qItem.linkId];
64
- if (isTab) {
65
- heading = (_b = (_a = getShortText(qItem)) !== null && _a !== void 0 ? _a : qItem.text) !== null && _b !== void 0 ? _b : null;
66
- }
67
- // TODO it seems like there can only be one answer per linkId, we might need to do repeat groups differently
68
- // so we need to fix this one first it seems like
69
- /* Repeat group implementation */
70
- if (qItem.type === 'group' && qItem.repeats) {
71
- const isRepeatGroupToRepopulate = checkIsRepeatGroupToRepopulate(qItem, itemsToRepopulate);
72
- if (isRepeatGroupToRepopulate) {
73
- const repeatGroupToRepopulate = getRepeatGroupToRepopulate(qItem, itemsToRepopulate);
74
- if (repeatGroupToRepopulate) {
75
- itemsToRepopulate[qItem.linkId] = repeatGroupToRepopulate;
76
- return;
77
- }
78
- }
79
- }
80
- // /* Grid implementation */
81
- // if (qItem.type === 'group' && isSpecificItemControl(qItem, 'grid')) {
82
- // const isRepeatGroupToRepopulate = checkIsRepeatGroupToRepopulate(qItem, itemsToRepopulate);
83
- // if (isRepeatGroupToRepopulate) {
84
- // getRepeatGroupToRepopulate(qItem, itemsToRepopulate);
85
- // }
86
- // }
87
- /* */
88
- // console.log(itemsToRepopulate);
89
- for (const childItem of qItem.item) {
90
- getCorrespondingQuestionnaireItemsRecursive(childItem, heading, tabs, hasTabs, itemsToRepopulate);
91
- }
92
- return;
93
- }
94
- if (!itemsToRepopulate[qItem.linkId]) {
95
- return;
96
- }
97
- itemsToRepopulate[qItem.linkId].qItem = qItem;
98
- itemsToRepopulate[qItem.linkId].heading = heading;
99
- }
100
- function getPopulatedItemsRecursive(qrItem, itemTypes) {
101
- const itemType = itemTypes[qrItem.linkId];
102
- if (itemType === 'group' && qrItem.item && qrItem.item.length > 0) {
103
- const populatedChildItems = [];
104
- for (const childItem of qrItem.item) {
105
- populatedChildItems.push(...getPopulatedItemsRecursive(childItem, itemTypes));
106
- }
107
- return populatedChildItems;
108
- }
109
- // record item if it is not a group item
110
- return [qrItem];
111
- }
112
- function checkCorrespondingOldItemsRecursive(qrItem, itemTypes, itemsToRepopulate) {
113
- var _a;
114
- const itemType = itemTypes[qrItem.linkId];
115
- if (itemType === 'group' && qrItem.item && qrItem.item.length > 0) {
116
- for (const childItem of qrItem.item) {
117
- checkCorrespondingOldItemsRecursive(childItem, itemTypes, itemsToRepopulate);
118
- }
119
- return;
120
- }
121
- const oldItem = qrItem;
122
- const newItem = (_a = itemsToRepopulate[qrItem.linkId]) === null || _a === void 0 ? void 0 : _a.newQRItem;
123
- if (!newItem) {
124
- return;
125
- }
126
- if (_isEqual(oldItem, newItem)) {
127
- delete itemsToRepopulate[qrItem.linkId];
128
- return;
129
- }
130
- // const filteredNewItems = newItems.filter((newItem) => !_isEqual(oldItem, newItem));
131
- itemsToRepopulate[qrItem.linkId].oldQRItem = oldItem;
132
- }
133
- //# sourceMappingURL=repopulateGenerateItems.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repopulateGenerateItems.js","sourceRoot":"","sources":["../../src/utils/repopulateGenerateItems.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AASjC,MAAM,UAAU,oBAAoB,CAClC,mBAAkC,EAClC,SAAiC,EACjC,IAAU,EACV,iBAAwC,EACxC,iBAAwC;;IAExC,IACE,CAAC,mBAAmB,CAAC,IAAI;QACzB,mBAAmB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QACrC,CAAC,iBAAiB,CAAC,IAAI;QACvB,iBAAiB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QACnC,CAAC,iBAAiB,CAAC,IAAI;QACvB,iBAAiB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EACnC;QACA,OAAO,EAAE,CAAC;KACX;IAED,MAAM,cAAc,GAAgC,EAAE,CAAC;IACvD,KAAK,MAAM,YAAY,IAAI,iBAAiB,CAAC,IAAI,EAAE;QACjD,cAAc,CAAC,IAAI,CAAC,GAAG,0BAA0B,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;KAC7E;IAED,MAAM,iBAAiB,GAAG,cAAc,CAAC,MAAM,CAC7C,CAAC,OAAyC,EAAE,IAAI,EAAE,EAAE;QAClD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;YACrB,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI;SAChB,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,EAAE,CACH,CAAC;IAEF,2EAA2E;IAC3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C,EACjC,iBAAmD;;IAEnD,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACjE,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,IAAI,EAAE;YACnC,mCAAmC,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;SAC9E;QAED,OAAO;KACR;IAED,MAAM,OAAO,GAAG,MAAM,CAAC;IACvB,MAAM,OAAO,GAAG,MAAA,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,0CAAE,SAAS,CAAC;IAE5D,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO;KACR;IAED,IAAI,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE;QAC9B,OAAO,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO;KACR;IAED,sFAAsF;IAEtF,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,GAAG,OAAO,CAAC;AACvD,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { QuestionnaireItem } from 'fhir/r4';
2
- import type { ItemToRepopulate } from './repopulateItems';
3
- export declare function checkIsRepeatGroupToRepopulate(qItem: QuestionnaireItem, itemsToRepopulate: Record<string, ItemToRepopulate>): boolean | undefined;
4
- export declare function getRepeatGroupToRepopulate(qItem: QuestionnaireItem, itemsToRepopulate: Record<string, ItemToRepopulate>): ItemToRepopulate | null;