@aehrc/smart-forms-renderer 0.7.1 → 0.8.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 (347) hide show
  1. package/README.md +1 -1
  2. package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js +1 -2
  3. package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js.map +1 -1
  4. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.d.ts +12 -0
  5. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js +39 -0
  6. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js.map +1 -0
  7. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.d.ts +3 -3
  8. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js +14 -27
  9. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js.map +1 -1
  10. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.d.ts +13 -0
  11. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js +42 -0
  12. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js.map +1 -0
  13. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.d.ts +4 -3
  14. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +14 -22
  15. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -1
  16. package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.d.ts +2 -2
  17. package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js +3 -3
  18. package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js.map +1 -1
  19. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.d.ts +12 -0
  20. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js +27 -0
  21. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js.map +1 -0
  22. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.d.ts +1 -1
  23. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js +9 -24
  24. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js.map +1 -1
  25. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.d.ts +14 -0
  26. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js +42 -0
  27. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js.map +1 -0
  28. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.d.ts +1 -1
  29. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js +8 -21
  30. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js.map +1 -1
  31. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.d.ts +10 -0
  32. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js +41 -0
  33. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js.map +1 -0
  34. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js +7 -23
  35. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js.map +1 -1
  36. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.d.ts +12 -0
  37. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.js +42 -0
  38. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.js.map +1 -0
  39. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js +8 -18
  40. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js.map +1 -1
  41. package/lib/components/FormComponents/DecimalItem/DecimalItem.js +3 -2
  42. package/lib/components/FormComponents/DecimalItem/DecimalItem.js.map +1 -1
  43. package/lib/components/FormComponents/GridGroup/GridGroup.js +2 -2
  44. package/lib/components/FormComponents/GridGroup/GridGroup.js.map +1 -1
  45. package/lib/components/FormComponents/GridGroup/GridRow.js +2 -2
  46. package/lib/components/FormComponents/GridGroup/GridRow.js.map +1 -1
  47. package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.d.ts +10 -0
  48. package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.js +73 -0
  49. package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.js.map +1 -0
  50. package/lib/components/FormComponents/GroupItem/GroupItem.js +3 -3
  51. package/lib/components/FormComponents/GroupItem/GroupItem.js.map +1 -1
  52. package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js +4 -4
  53. package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js.map +1 -1
  54. package/lib/components/FormComponents/GroupItem/ItemSwitcher.d.ts +10 -0
  55. package/lib/components/FormComponents/GroupItem/ItemSwitcher.js +81 -0
  56. package/lib/components/FormComponents/GroupItem/ItemSwitcher.js.map +1 -0
  57. package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.d.ts +10 -0
  58. package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.js +45 -0
  59. package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.js.map +1 -0
  60. package/lib/components/FormComponents/IntegerItem/IntegerItem.js +3 -2
  61. package/lib/components/FormComponents/IntegerItem/IntegerItem.js.map +1 -1
  62. package/lib/components/FormComponents/Item.styles.d.ts +2 -2
  63. package/lib/components/FormComponents/Item.styles.js +2 -2
  64. package/lib/components/FormComponents/Item.styles.js.map +1 -1
  65. package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.d.ts +8 -0
  66. package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.js +37 -0
  67. package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.js.map +1 -0
  68. package/lib/components/FormComponents/ItemParts/RadioButtons.d.ts +8 -0
  69. package/lib/components/FormComponents/ItemParts/RadioButtons.js +37 -0
  70. package/lib/components/FormComponents/ItemParts/RadioButtons.js.map +1 -0
  71. package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.d.ts +8 -0
  72. package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.js +37 -0
  73. package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.js.map +1 -0
  74. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.d.ts +20 -0
  75. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.js +49 -0
  76. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.js.map +1 -0
  77. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.d.ts +0 -0
  78. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.js +2 -0
  79. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.js.map +1 -0
  80. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js +11 -35
  81. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js.map +1 -1
  82. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.d.ts +17 -0
  83. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js +42 -0
  84. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js.map +1 -0
  85. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.d.ts +3 -3
  86. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js +23 -36
  87. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js.map +1 -1
  88. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.d.ts +2 -2
  89. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js +3 -3
  90. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js.map +1 -1
  91. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.d.ts +15 -0
  92. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js +29 -0
  93. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js.map +1 -0
  94. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.d.ts +1 -1
  95. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js +3 -23
  96. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js.map +1 -1
  97. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.d.ts +11 -0
  98. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.js +14 -0
  99. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.js.map +1 -0
  100. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.d.ts +0 -0
  101. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.js +2 -0
  102. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.js.map +1 -0
  103. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js +18 -23
  104. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js.map +1 -1
  105. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.d.ts +12 -0
  106. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.js +16 -0
  107. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.js.map +1 -0
  108. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js +8 -14
  109. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js.map +1 -1
  110. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +4 -3
  111. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
  112. package/lib/components/FormComponents/RepeatGroup/index.d.ts +1 -0
  113. package/lib/components/FormComponents/RepeatGroup/index.js +18 -0
  114. package/lib/components/FormComponents/RepeatGroup/index.js.map +1 -0
  115. package/lib/components/FormComponents/RepeatItem/RepeatItem.js +1 -1
  116. package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
  117. package/lib/components/FormComponents/SingleItem/SingleItem.d.ts +2 -2
  118. package/lib/components/FormComponents/SingleItem/SingleItem.js +2 -2
  119. package/lib/components/FormComponents/SingleItem/SingleItem.js.map +1 -1
  120. package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.d.ts +2 -2
  121. package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js +3 -3
  122. package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js.map +1 -1
  123. package/lib/components/FormComponents/SingleItem/index.d.ts +1 -0
  124. package/lib/components/FormComponents/SingleItem/index.js +18 -0
  125. package/lib/components/FormComponents/SingleItem/index.js.map +1 -0
  126. package/lib/components/FormComponents/StringItem/StringItem.js +3 -2
  127. package/lib/components/FormComponents/StringItem/StringItem.js.map +1 -1
  128. package/lib/components/FormComponents/Tables/AddItemButton.d.ts +8 -0
  129. package/lib/components/FormComponents/Tables/AddItemButton.js +28 -0
  130. package/lib/components/FormComponents/Tables/AddItemButton.js.map +1 -0
  131. package/lib/components/FormComponents/Tables/AddRowButton.d.ts +8 -0
  132. package/lib/components/FormComponents/Tables/AddRowButton.js +28 -0
  133. package/lib/components/FormComponents/Tables/AddRowButton.js.map +1 -0
  134. package/lib/components/FormComponents/Tables/GroupTable.d.ts +10 -0
  135. package/lib/components/FormComponents/Tables/GroupTable.js +108 -0
  136. package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -0
  137. package/lib/components/FormComponents/Tables/GroupTableRow.d.ts +10 -0
  138. package/lib/components/FormComponents/Tables/GroupTableRow.js +46 -0
  139. package/lib/components/FormComponents/Tables/GroupTableRow.js.map +1 -0
  140. package/lib/components/FormComponents/Tables/QItemGroupTable.js +7 -5
  141. package/lib/components/FormComponents/Tables/QItemGroupTable.js.map +1 -1
  142. package/lib/components/FormComponents/Tables/QItemGroupTableRow.js +2 -2
  143. package/lib/components/FormComponents/Tables/QItemGroupTableRow.js.map +1 -1
  144. package/lib/components/FormComponents/Tables/index.d.ts +1 -0
  145. package/lib/components/FormComponents/Tables/index.js +18 -0
  146. package/lib/components/FormComponents/Tables/index.js.map +1 -0
  147. package/lib/components/FormComponents/TextItem/TextItem.js +3 -2
  148. package/lib/components/FormComponents/TextItem/TextItem.js.map +1 -1
  149. package/lib/components/FormComponents/index.d.ts +3 -0
  150. package/lib/components/FormComponents/index.js +20 -0
  151. package/lib/components/FormComponents/index.js.map +1 -0
  152. package/lib/components/Renderer/BaseRenderer.js +26 -14
  153. package/lib/components/Renderer/BaseRenderer.js.map +1 -1
  154. package/lib/components/Renderer/FormBodyCollapsible.js +2 -2
  155. package/lib/components/Renderer/FormBodyCollapsible.js.map +1 -1
  156. package/lib/components/Renderer/FormBodyTabbed.js +3 -3
  157. package/lib/components/Renderer/FormBodyTabbed.js.map +1 -1
  158. package/lib/components/Renderer/FormTopLevelItem.d.ts +4 -4
  159. package/lib/components/Renderer/FormTopLevelItem.js +14 -1
  160. package/lib/components/Renderer/FormTopLevelItem.js.map +1 -1
  161. package/lib/components/Tabs/FormBodySingleTab.js +1 -1
  162. package/lib/components/Tabs/FormBodySingleTab.js.map +1 -1
  163. package/lib/components/Tabs/FormBodyTabList.d.ts +1 -0
  164. package/lib/components/Tabs/FormBodyTabList.js +3 -4
  165. package/lib/components/Tabs/FormBodyTabList.js.map +1 -1
  166. package/lib/components/Tabs/FormBodyTabListWrapper.d.ts +1 -1
  167. package/lib/components/Tabs/FormBodyTabListWrapper.js +6 -13
  168. package/lib/components/Tabs/FormBodyTabListWrapper.js.map +1 -1
  169. package/lib/components/Tabs/ShowCompletedTabsSection.d.ts +7 -0
  170. package/lib/components/Tabs/ShowCompletedTabsSection.js +34 -0
  171. package/lib/components/Tabs/ShowCompletedTabsSection.js.map +1 -0
  172. package/lib/components/index.d.ts +1 -0
  173. package/lib/components/index.js +1 -0
  174. package/lib/components/index.js.map +1 -1
  175. package/lib/hooks/index.d.ts +1 -0
  176. package/lib/hooks/index.js +2 -0
  177. package/lib/hooks/index.js.map +1 -0
  178. package/lib/hooks/useContextDisplayItems.d.ts +6 -0
  179. package/lib/hooks/useContextDisplayItems.js +30 -0
  180. package/lib/hooks/useContextDisplayItems.js.map +1 -0
  181. package/lib/hooks/useDecimalUpdateFromProp.d.ts +2 -0
  182. package/lib/hooks/useDecimalUpdateFromProp.js +29 -0
  183. package/lib/hooks/useDecimalUpdateFromProp.js.map +1 -0
  184. package/lib/hooks/useInitialiseRenderer.js +2 -2
  185. package/lib/hooks/useInitialiseRenderer.js.map +1 -1
  186. package/lib/hooks/useInitialiseRepeatAnswers.d.ts +2 -2
  187. package/lib/hooks/useInitialiseRepeatAnswers.js +21 -15
  188. package/lib/hooks/useInitialiseRepeatAnswers.js.map +1 -1
  189. package/lib/hooks/useInitialiseRepeatGroups.d.ts +2 -1
  190. package/lib/hooks/useInitialiseRepeatGroups.js +21 -15
  191. package/lib/hooks/useInitialiseRepeatGroups.js.map +1 -1
  192. package/lib/hooks/useIntegerUpdateFromProp.d.ts +2 -0
  193. package/lib/hooks/useIntegerUpdateFromProp.js +29 -0
  194. package/lib/hooks/useIntegerUpdateFromProp.js.map +1 -0
  195. package/lib/hooks/useNumberInput.d.ts +3 -0
  196. package/lib/hooks/useNumberInput.js +31 -0
  197. package/lib/hooks/useNumberInput.js.map +1 -0
  198. package/lib/hooks/useNumberUpdateFromProp.d.ts +2 -0
  199. package/lib/hooks/useNumberUpdateFromProp.js +29 -0
  200. package/lib/hooks/useNumberUpdateFromProp.js.map +1 -0
  201. package/lib/hooks/useRepeatItemState.d.ts +5 -0
  202. package/lib/hooks/useRepeatItemState.js +35 -0
  203. package/lib/hooks/useRepeatItemState.js.map +1 -0
  204. package/lib/hooks/useRepeatItemUpdateFromProp.d.ts +2 -0
  205. package/lib/hooks/useRepeatItemUpdateFromProp.js +29 -0
  206. package/lib/hooks/useRepeatItemUpdateFromProp.js.map +1 -0
  207. package/lib/hooks/useStringField.d.ts +2 -0
  208. package/lib/hooks/useStringField.js +29 -0
  209. package/lib/hooks/useStringField.js.map +1 -0
  210. package/lib/hooks/useStringInput.d.ts +3 -0
  211. package/lib/hooks/useStringInput.js +31 -0
  212. package/lib/hooks/useStringInput.js.map +1 -0
  213. package/lib/hooks/useStringUpdateFromProp.d.ts +2 -0
  214. package/lib/hooks/useStringUpdateFromProp.js +29 -0
  215. package/lib/hooks/useStringUpdateFromProp.js.map +1 -0
  216. package/lib/hooks/useTerminologyServerQuery.js +3 -6
  217. package/lib/hooks/useTerminologyServerQuery.js.map +1 -1
  218. package/lib/index.d.ts +16 -0
  219. package/lib/index.js +29 -2
  220. package/lib/index.js.map +1 -1
  221. package/lib/interfaces/questionnaireStore.interface.d.ts +1 -0
  222. package/lib/interfaces/renderProps.interface.d.ts +3 -0
  223. package/lib/stores/useQuestionnaireResponseStore.d.ts +2 -1
  224. package/lib/stores/useQuestionnaireResponseStore.js +17 -10
  225. package/lib/stores/useQuestionnaireResponseStore.js.map +1 -1
  226. package/lib/stores/useQuestionnaireStore.d.ts +2 -1
  227. package/lib/stores/useQuestionnaireStore.js +5 -2
  228. package/lib/stores/useQuestionnaireStore.js.map +1 -1
  229. package/lib/theme/overrides/Overrides.js +1 -2
  230. package/lib/theme/overrides/Overrides.js.map +1 -1
  231. package/lib/utils/calculatedExpression.js +2 -2
  232. package/lib/utils/calculatedExpression.js.map +1 -1
  233. package/lib/utils/formChanges.d.ts +18 -0
  234. package/lib/utils/formChanges.js +91 -0
  235. package/lib/utils/formChanges.js.map +1 -0
  236. package/lib/utils/formChangesOld.d.ts +18 -0
  237. package/lib/utils/formChangesOld.js +91 -0
  238. package/lib/utils/formChangesOld.js.map +1 -0
  239. package/lib/utils/index.d.ts +1 -0
  240. package/lib/utils/index.js +18 -0
  241. package/lib/utils/index.js.map +1 -0
  242. package/lib/utils/mapItem.d.ts +2 -2
  243. package/lib/utils/mapItem.js +3 -3
  244. package/lib/utils/mapItem.js.map +1 -1
  245. package/lib/utils/qItem.d.ts +2 -0
  246. package/lib/utils/qItem.js +22 -0
  247. package/lib/utils/qItem.js.map +1 -1
  248. package/lib/utils/qrItem.d.ts +3 -4
  249. package/lib/utils/qrItem.js +94 -96
  250. package/lib/utils/qrItem.js.map +1 -1
  251. package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js +4 -0
  252. package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js.map +1 -1
  253. package/lib/utils/repopulate.d.ts +9 -0
  254. package/lib/utils/repopulate.js +133 -0
  255. package/lib/utils/repopulate.js.map +1 -0
  256. package/lib/utils/repopulateGenerateItems.d.ts +9 -0
  257. package/lib/utils/repopulateGenerateItems.js +133 -0
  258. package/lib/utils/repopulateGenerateItems.js.map +1 -0
  259. package/lib/utils/repopulateIntoResponse.d.ts +3 -0
  260. package/lib/utils/repopulateIntoResponse.js +92 -0
  261. package/lib/utils/repopulateIntoResponse.js.map +1 -0
  262. package/lib/utils/repopulateItems.d.ts +9 -0
  263. package/lib/utils/repopulateItems.js +130 -0
  264. package/lib/utils/repopulateItems.js.map +1 -0
  265. package/lib/utils/repopulateRepeatGroup.d.ts +4 -0
  266. package/lib/utils/repopulateRepeatGroup.js +54 -0
  267. package/lib/utils/repopulateRepeatGroup.js.map +1 -0
  268. package/package.json +7 -5
  269. package/src/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.tsx +1 -2
  270. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.tsx +85 -0
  271. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.tsx +35 -58
  272. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.tsx +79 -0
  273. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx +37 -50
  274. package/src/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.tsx +10 -5
  275. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.tsx +48 -0
  276. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx +25 -53
  277. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx +83 -0
  278. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +27 -49
  279. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.tsx +81 -0
  280. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx +19 -54
  281. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.tsx +97 -0
  282. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.tsx +22 -60
  283. package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +3 -2
  284. package/src/components/FormComponents/GridGroup/GridGroup.tsx +2 -2
  285. package/src/components/FormComponents/GridGroup/GridRow.tsx +2 -2
  286. package/src/components/FormComponents/GroupItem/GroupItem.tsx +3 -3
  287. package/src/components/FormComponents/GroupItem/GroupItemSwitcher.tsx +4 -4
  288. package/src/components/FormComponents/IntegerItem/IntegerItem.tsx +3 -2
  289. package/src/components/FormComponents/Item.styles.ts +2 -2
  290. package/src/components/FormComponents/ItemParts/RadioAnswerOptionButtons.tsx +72 -0
  291. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.tsx +131 -0
  292. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.tsx +38 -93
  293. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.tsx +112 -0
  294. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx +57 -76
  295. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.tsx +8 -5
  296. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.tsx +72 -0
  297. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.tsx +12 -59
  298. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.tsx +54 -0
  299. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.tsx +40 -64
  300. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.tsx +63 -0
  301. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.tsx +22 -50
  302. package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +4 -3
  303. package/src/{theme/overrides/Backdrop.ts → components/FormComponents/RepeatGroup/index.ts} +1 -17
  304. package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +1 -1
  305. package/src/components/FormComponents/SingleItem/SingleItem.tsx +6 -3
  306. package/src/components/FormComponents/SingleItem/SingleItemSwitcher.tsx +7 -3
  307. package/src/components/FormComponents/SingleItem/index.ts +18 -0
  308. package/src/components/FormComponents/StringItem/StringItem.tsx +3 -2
  309. package/src/components/FormComponents/Tables/AddRowButton.tsx +49 -0
  310. package/src/components/FormComponents/Tables/{QItemGroupTable.tsx → GroupTable.tsx} +21 -23
  311. package/src/components/FormComponents/Tables/{QItemGroupTableRow.tsx → GroupTableRow.tsx} +4 -4
  312. package/src/components/FormComponents/Tables/index.ts +18 -0
  313. package/src/components/FormComponents/TextItem/TextItem.tsx +3 -2
  314. package/src/components/FormComponents/index.ts +20 -0
  315. package/src/components/Renderer/BaseRenderer.tsx +39 -18
  316. package/src/components/Renderer/FormBodyCollapsible.tsx +2 -2
  317. package/src/components/Renderer/FormBodyTabbed.tsx +3 -3
  318. package/src/components/Renderer/FormTopLevelItem.tsx +33 -4
  319. package/src/components/Tabs/FormBodySingleTab.tsx +1 -1
  320. package/src/components/Tabs/FormBodyTabList.tsx +5 -8
  321. package/src/components/Tabs/FormBodyTabListWrapper.tsx +15 -26
  322. package/src/components/Tabs/ShowCompletedTabsSection.tsx +52 -0
  323. package/src/components/index.ts +1 -0
  324. package/src/hooks/index.ts +1 -0
  325. package/src/hooks/useContextDisplayItems.ts +40 -0
  326. package/src/hooks/useInitialiseRenderer.ts +2 -2
  327. package/src/hooks/useInitialiseRepeatAnswers.ts +28 -17
  328. package/src/hooks/useInitialiseRepeatGroups.ts +28 -17
  329. package/src/hooks/useNumberInput.ts +38 -0
  330. package/src/hooks/useStringInput.ts +38 -0
  331. package/src/hooks/useTerminologyServerQuery.ts +3 -6
  332. package/src/index.ts +45 -2
  333. package/src/interfaces/questionnaireStore.interface.ts +1 -0
  334. package/src/interfaces/renderProps.interface.ts +4 -0
  335. package/src/stores/useQuestionnaireResponseStore.ts +15 -10
  336. package/src/stores/useQuestionnaireStore.ts +10 -3
  337. package/src/theme/overrides/Overrides.ts +0 -2
  338. package/src/utils/calculatedExpression.ts +2 -2
  339. package/src/utils/formChanges.ts +141 -0
  340. package/src/utils/index.ts +18 -0
  341. package/src/utils/mapItem.ts +6 -4
  342. package/src/utils/qItem.ts +29 -0
  343. package/src/utils/qrItem.ts +108 -97
  344. package/src/utils/questionnaireStoreUtils/createQuestionaireModel.ts +4 -0
  345. package/src/utils/repopulateIntoResponse.ts +153 -0
  346. package/src/utils/repopulateItems.ts +206 -0
  347. package/src/utils/repopulateRepeatGroup.ts +68 -0
@@ -1 +1 @@
1
- {"version":3,"file":"createQuestionaireModel.js","sourceRoot":"","sources":["../../../src/utils/questionnaireStoreUtils/createQuestionaireModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;AAMH,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,kCAAkC,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,UAAgB,wBAAwB,CAC5C,aAA4B,EAC5B,mBAA2C,EAC3C,oBAA4B;;QAE5B,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE;YACvB,OAAO,gBAAgB,EAAE,CAAC;SAC3B;QAED,MAAM,IAAI,GAAS,WAAW,CAAC,aAAa,CAAC,CAAC;QAE9C,MAAM,cAAc,GAAkC,qBAAqB,CAAC,aAAa,CAAC,CAAC;QAE3F,IAAI,SAAS,GAAc,kCAAkC,CAAC,aAAa,CAAC,CAAC;QAC7E,SAAS,GAAG,sBAAsB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;QAEnE,MAAM,+BAA+B,GAAG,yBAAyB,CAC/D,aAAa,EACb,oBAAoB,CACrB,CAAC;QACF,IAAI,gBAAgB,GAAG,+BAA+B,CAAC,gBAAgB,CAAC;QACxE,IAAI,wBAAwB,GAAG,+BAA+B,CAAC,wBAAwB,CAAC;QACxF,MAAM,qBAAqB,GAAG,+BAA+B,CAAC,qBAAqB,CAAC;QAEpF,MAAM,4BAA4B,GAAG,sBAAsB,CACzD,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAAoB,CACrB,CAAC;QAEF,MAAM,EAAE,eAAe,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,GACxF,4BAA4B,CAAC;QAC/B,SAAS,GAAG,4BAA4B,CAAC,SAAS,CAAC;QACnD,gBAAgB,GAAG,4BAA4B,CAAC,gBAAgB,CAAC;QAEjE,MAAM,sBAAsB,GAAG,MAAM,gBAAgB,CACnD,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,CACrB,CAAC;QAEF,SAAS,GAAG,sBAAsB,CAAC,SAAS,CAAC;QAC7C,wBAAwB,GAAG,sBAAsB,CAAC,wBAAwB,CAAC;QAE3E,OAAO;YACL,IAAI;YACJ,SAAS;YACT,cAAc;YACd,eAAe;YACf,qBAAqB;YACrB,qBAAqB;YACrB,iBAAiB;YACjB,wBAAwB;YACxB,qBAAqB;SACtB,CAAC;IACJ,CAAC;CAAA;AAED,SAAS,gBAAgB;IACvB,OAAO;QACL,IAAI,EAAE,EAAE;QACR,SAAS,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE;QAC7D,cAAc,EAAE,EAAE;QAClB,qBAAqB,EAAE,EAAE;QACzB,qBAAqB,EAAE,EAAE;QACzB,iBAAiB,EAAE,EAAE;QACrB,eAAe,EAAE,EAAE;QACnB,wBAAwB,EAAE,EAAE;QAC5B,qBAAqB,EAAE,EAAE;KAC1B,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"createQuestionaireModel.js","sourceRoot":"","sources":["../../../src/utils/questionnaireStoreUtils/createQuestionaireModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;AAMH,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,kCAAkC,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,WAAW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AAC,SAAS,CAAC;QACnD,gBAAgB,GAAG,4BAA4B,CAAC,gBAAgB,CAAC;QAEjE,MAAM,sBAAsB,GAAG,MAAM,gBAAgB,CACnD,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,CACrB,CAAC;QAEF,SAAS,GAAG,sBAAsB,CAAC,SAAS,CAAC;QAC7C,wBAAwB,GAAG,sBAAsB,CAAC,wBAAwB,CAAC;QAE3E,OAAO;YACL,SAAS;YACT,IAAI;YACJ,SAAS;YACT,cAAc;YACd,eAAe;YACf,qBAAqB;YACrB,qBAAqB;YACrB,iBAAiB;YACjB,wBAAwB;YACxB,qBAAqB;SACtB,CAAC;IACJ,CAAC;CAAA;AAED,SAAS,gBAAgB;IACvB,OAAO;QACL,SAAS,EAAE,EAAE;QACb,IAAI,EAAE,EAAE;QACR,SAAS,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE;QAC7D,cAAc,EAAE,EAAE;QAClB,qBAAqB,EAAE,EAAE;QACzB,qBAAqB,EAAE,EAAE;QACzB,iBAAiB,EAAE,EAAE;QACrB,eAAe,EAAE,EAAE;QACnB,wBAAwB,EAAE,EAAE;QAC5B,qBAAqB,EAAE,EAAE;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
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>;
@@ -0,0 +1,133 @@
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
@@ -0,0 +1 @@
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,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,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"}
@@ -0,0 +1,9 @@
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>;
@@ -0,0 +1,133 @@
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
@@ -0,0 +1 @@
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,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,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"}
@@ -0,0 +1,3 @@
1
+ import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
2
+ import type { ItemToRepopulate } from './repopulateItems';
3
+ export declare function repopulateItemsIntoResponse(questionnaire: Questionnaire, updatableResponse: QuestionnaireResponse, checkedItemsToRepopulate: Record<string, ItemToRepopulate>): QuestionnaireResponse;
@@ -0,0 +1,92 @@
1
+ import { getQrItemsIndex, mapQItemsIndex } from './mapItem';
2
+ import { updateQrItemsInGroup } from './qrItem';
3
+ export function repopulateItemsIntoResponse(questionnaire, updatableResponse, checkedItemsToRepopulate) {
4
+ var _a;
5
+ if (!questionnaire.item ||
6
+ questionnaire.item.length === 0 ||
7
+ !updatableResponse.item ||
8
+ updatableResponse.item.length === 0) {
9
+ return updatableResponse;
10
+ }
11
+ const topLevelQrItems = [];
12
+ for (const [index, topLevelQItem] of questionnaire.item.entries()) {
13
+ const repopulatedTopLevelQrItem = (_a = updatableResponse.item[index]) !== null && _a !== void 0 ? _a : {
14
+ linkId: topLevelQItem.linkId,
15
+ text: topLevelQItem.text,
16
+ item: []
17
+ };
18
+ const updatedTopLevelQRItem = repopulateItemRecursive(topLevelQItem, repopulatedTopLevelQrItem, checkedItemsToRepopulate);
19
+ if (Array.isArray(updatedTopLevelQRItem)) {
20
+ if (updatedTopLevelQRItem.length > 0) {
21
+ topLevelQrItems.push(...updatedTopLevelQRItem);
22
+ }
23
+ continue;
24
+ }
25
+ if (updatedTopLevelQRItem) {
26
+ topLevelQrItems.push(updatedTopLevelQRItem);
27
+ }
28
+ }
29
+ return Object.assign(Object.assign({}, updatableResponse), { item: topLevelQrItems });
30
+ }
31
+ function repopulateItemRecursive(qItem, qrItem, checkedItemsToRepopulate) {
32
+ var _a;
33
+ const childQItems = qItem.item;
34
+ if (childQItems && childQItems.length > 0) {
35
+ // iterate through items of item recursively
36
+ const childQrItems = (_a = qrItem === null || qrItem === void 0 ? void 0 : qrItem.item) !== null && _a !== void 0 ? _a : [];
37
+ // const updatedChildQrItems: QuestionnaireResponseItem[] = [];
38
+ // FIXME Not implemented for repeat groups
39
+ if (qItem.type === 'group' && qItem.repeats) {
40
+ return qrItem !== null && qrItem !== void 0 ? qrItem : null;
41
+ }
42
+ const indexMap = mapQItemsIndex(qItem);
43
+ const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap);
44
+ // Otherwise loop through qItem as usual
45
+ for (const [index, childQItem] of childQItems.entries()) {
46
+ const childQrItem = qrItemsByIndex[index];
47
+ // FIXME Not implemented for repeat groups
48
+ if (Array.isArray(childQrItem)) {
49
+ continue;
50
+ }
51
+ const newQrItem = repopulateItemRecursive(childQItem, childQrItem, checkedItemsToRepopulate);
52
+ // FIXME Not implemented for repeat groups
53
+ if (Array.isArray(newQrItem)) {
54
+ continue;
55
+ }
56
+ if (newQrItem) {
57
+ updateQrItemsInGroup(newQrItem, null, qrItem !== null && qrItem !== void 0 ? qrItem : { linkId: qItem.linkId, text: qItem.text, item: [] }, indexMap);
58
+ }
59
+ }
60
+ return constructGroupItem(qItem, qrItem, checkedItemsToRepopulate);
61
+ }
62
+ return constructSingleItem(qItem, qrItem, checkedItemsToRepopulate);
63
+ }
64
+ function constructGroupItem(qItem, qrItem, checkedItemsToRepopulate) {
65
+ const itemToRepopulate = checkedItemsToRepopulate[qItem.linkId];
66
+ if (!itemToRepopulate) {
67
+ return qrItem !== null && qrItem !== void 0 ? qrItem : null;
68
+ }
69
+ if (qrItem) {
70
+ return Object.assign(Object.assign({}, qrItem), { answer: itemToRepopulate.newQRItem.answer });
71
+ }
72
+ return {
73
+ linkId: qItem.linkId,
74
+ text: qItem.text,
75
+ answer: itemToRepopulate.newQRItem.answer
76
+ };
77
+ }
78
+ function constructSingleItem(qItem, qrItem, checkedItemsToRepopulate) {
79
+ const itemToRepopulate = checkedItemsToRepopulate[qItem.linkId];
80
+ if (!itemToRepopulate) {
81
+ return qrItem !== null && qrItem !== void 0 ? qrItem : null;
82
+ }
83
+ if (qrItem) {
84
+ return Object.assign(Object.assign({}, qrItem), { answer: itemToRepopulate.newQRItem.answer });
85
+ }
86
+ return {
87
+ linkId: qItem.linkId,
88
+ text: qItem.text,
89
+ answer: itemToRepopulate.newQRItem.answer
90
+ };
91
+ }
92
+ //# sourceMappingURL=repopulateIntoResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repopulateIntoResponse.js","sourceRoot":"","sources":["../../src/utils/repopulateIntoResponse.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,UAAU,2BAA2B,CACzC,aAA4B,EAC5B,iBAAwC,EACxC,wBAA0D;;IAE1D,IACE,CAAC,aAAa,CAAC,IAAI;QACnB,aAAa,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QAC/B,CAAC,iBAAiB,CAAC,IAAI;QACvB,iBAAiB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EACnC;QACA,OAAO,iBAAiB,CAAC;KAC1B;IAED,MAAM,eAAe,GAAgC,EAAE,CAAC;IACxD,KAAK,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE;QACjE,MAAM,yBAAyB,GAAG,MAAA,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,mCAAI;YACjE,MAAM,EAAE,aAAa,CAAC,MAAM;YAC5B,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,IAAI,EAAE,EAAE;SACT,CAAC;QAEF,MAAM,qBAAqB,GAAG,uBAAuB,CAC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aAAN,MAAM,cAAN,MAAM,GAAI,IAAI,CAAC;KACvB;IAED,IAAI,MAAM,EAAE;QACV,uCACK,MAAM,KACT,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC,MAAM,IACzC;KACH;IAED,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC,MAAM;KAC1C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
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>;
@@ -0,0 +1,130 @@
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
+ /* Repeat group implementation */
69
+ if (qItem.type === 'group' && qItem.repeats) {
70
+ const isRepeatGroupToRepopulate = checkIsRepeatGroupToRepopulate(qItem, itemsToRepopulate);
71
+ if (isRepeatGroupToRepopulate) {
72
+ const repeatGroupToRepopulate = getRepeatGroupToRepopulate(qItem, itemsToRepopulate);
73
+ if (repeatGroupToRepopulate) {
74
+ itemsToRepopulate[qItem.linkId] = repeatGroupToRepopulate;
75
+ return;
76
+ }
77
+ }
78
+ }
79
+ // /* Grid implementation */
80
+ // if (qItem.type === 'group' && isSpecificItemControl(qItem, 'grid')) {
81
+ // const isRepeatGroupToRepopulate = checkIsRepeatGroupToRepopulate(qItem, itemsToRepopulate);
82
+ // if (isRepeatGroupToRepopulate) {
83
+ // getRepeatGroupToRepopulate(qItem, itemsToRepopulate);
84
+ // }
85
+ // }
86
+ for (const childItem of qItem.item) {
87
+ getCorrespondingQuestionnaireItemsRecursive(childItem, heading, tabs, hasTabs, itemsToRepopulate);
88
+ }
89
+ return;
90
+ }
91
+ if (!itemsToRepopulate[qItem.linkId]) {
92
+ return;
93
+ }
94
+ itemsToRepopulate[qItem.linkId].qItem = qItem;
95
+ itemsToRepopulate[qItem.linkId].heading = heading;
96
+ }
97
+ function getPopulatedItemsRecursive(qrItem, itemTypes) {
98
+ const itemType = itemTypes[qrItem.linkId];
99
+ if (itemType === 'group' && qrItem.item && qrItem.item.length > 0) {
100
+ const populatedChildItems = [];
101
+ for (const childItem of qrItem.item) {
102
+ populatedChildItems.push(...getPopulatedItemsRecursive(childItem, itemTypes));
103
+ }
104
+ return populatedChildItems;
105
+ }
106
+ // record item if it is not a group item
107
+ return [qrItem];
108
+ }
109
+ function checkCorrespondingOldItemsRecursive(qrItem, itemTypes, itemsToRepopulate) {
110
+ var _a;
111
+ const itemType = itemTypes[qrItem.linkId];
112
+ if (itemType === 'group' && qrItem.item && qrItem.item.length > 0) {
113
+ for (const childItem of qrItem.item) {
114
+ checkCorrespondingOldItemsRecursive(childItem, itemTypes, itemsToRepopulate);
115
+ }
116
+ return;
117
+ }
118
+ const oldItem = qrItem;
119
+ const newItem = (_a = itemsToRepopulate[qrItem.linkId]) === null || _a === void 0 ? void 0 : _a.newQRItem;
120
+ if (!newItem) {
121
+ return;
122
+ }
123
+ if (_isEqual(oldItem, newItem)) {
124
+ delete itemsToRepopulate[qrItem.linkId];
125
+ return;
126
+ }
127
+ // const filteredNewItems = newItems.filter((newItem) => !_isEqual(oldItem, newItem));
128
+ itemsToRepopulate[qrItem.linkId].oldQRItem = oldItem;
129
+ }
130
+ //# sourceMappingURL=repopulateItems.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repopulateItems.js","sourceRoot":"","sources":["../../src/utils/repopulateItems.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;I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+ 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;
@@ -0,0 +1,54 @@
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
+ export function checkIsRepeatGroupToRepopulate(qItem, itemsToRepopulate) {
18
+ if (!qItem.item) {
19
+ return false;
20
+ }
21
+ for (const childItem of qItem.item) {
22
+ if (itemsToRepopulate[childItem.linkId]) {
23
+ return true;
24
+ }
25
+ }
26
+ }
27
+ export function getRepeatGroupToRepopulate(qItem, itemsToRepopulate) {
28
+ var _a;
29
+ if (!qItem.item) {
30
+ return null;
31
+ }
32
+ const childLinkIds = qItem.item
33
+ .filter((childItem) => !!itemsToRepopulate[childItem.linkId])
34
+ .map((childItem) => childItem.linkId);
35
+ const childQRItemsToRepopulate = childLinkIds
36
+ .reduce((result, linkId) => {
37
+ if (itemsToRepopulate[linkId]) {
38
+ result.push(itemsToRepopulate[linkId]);
39
+ }
40
+ return result;
41
+ }, [])
42
+ .map((itemToRepopulate) => itemToRepopulate.newQRItem);
43
+ const repeatGroupToRepopulate = {
44
+ heading: (_a = qItem.text) !== null && _a !== void 0 ? _a : null,
45
+ qItem: qItem,
46
+ newQRItem: {
47
+ linkId: qItem.linkId,
48
+ text: qItem.text,
49
+ item: childQRItemsToRepopulate
50
+ }
51
+ };
52
+ return repeatGroupToRepopulate;
53
+ }
54
+ //# sourceMappingURL=repopulateRepeatGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repopulateRepeatGroup.js","sourceRoot":"","sources":["../../src/utils/repopulateRepeatGroup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,MAAM,UAAU,8BAA8B,CAC5C,KAAwB,EACxB,iBAAmD;IAEnD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QACf,OAAO,KAAK,CAAC;KACd;IAED,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE;QAClC,IAAI,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;YACvC,OAAO,IAAI,CAAC;SACb;KACF;AACH,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,KAAwB,EACxB,iBAAmD;;IAEnD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IAED,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI;SAC5B,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;SAC5D,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAExC,MAAM,wBAAwB,GAAG,YAAY;SAC1C,MAAM,CAAC,CAAC,MAA0B,EAAE,MAAM,EAAE,EAAE;QAC7C,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE;YAC7B,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;SACxC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC;SACL,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAEzD,M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