@aehrc/smart-forms-renderer 1.0.0-alpha.42.dev7 → 1.0.0-alpha.42.dev8

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 (953) hide show
  1. package/lib/api/smartClient.d.ts +5 -0
  2. package/lib/api/smartClient.js +41 -0
  3. package/lib/api/smartClient.js.map +1 -0
  4. package/lib/components/Alert.styles.d.ts +6 -0
  5. package/lib/components/Alert.styles.js +41 -0
  6. package/lib/components/Alert.styles.js.map +1 -0
  7. package/lib/components/Box.styles.d.ts +13 -0
  8. package/lib/components/Box.styles.js +35 -0
  9. package/lib/components/Box.styles.js.map +1 -0
  10. package/lib/components/Checkbox.styles.d.ts +3 -0
  11. package/lib/components/Checkbox.styles.js +16 -0
  12. package/lib/components/Checkbox.styles.js.map +1 -0
  13. package/lib/components/FormComponents/AttachmentItem/AttachmentField.d.ts +14 -0
  14. package/lib/components/FormComponents/AttachmentItem/AttachmentField.js +23 -0
  15. package/lib/components/FormComponents/AttachmentItem/AttachmentField.js.map +1 -0
  16. package/lib/components/FormComponents/AttachmentItem/AttachmentFieldWrapper.d.ts +14 -0
  17. package/lib/components/FormComponents/AttachmentItem/AttachmentFieldWrapper.js +16 -0
  18. package/lib/components/FormComponents/AttachmentItem/AttachmentFieldWrapper.js.map +1 -0
  19. package/lib/components/FormComponents/AttachmentItem/AttachmentFileCollector.d.ts +9 -0
  20. package/lib/components/FormComponents/AttachmentItem/AttachmentFileCollector.js +30 -0
  21. package/lib/components/FormComponents/AttachmentItem/AttachmentFileCollector.js.map +1 -0
  22. package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.d.ts +11 -0
  23. package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.js +47 -0
  24. package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.js.map +1 -0
  25. package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.styles.d.ts +7 -0
  26. package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.styles.js +50 -0
  27. package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.styles.js.map +1 -0
  28. package/lib/components/FormComponents/AttachmentItem/AttachmentItem.d.ts +10 -0
  29. package/lib/components/FormComponents/AttachmentItem/AttachmentItem.js +90 -0
  30. package/lib/components/FormComponents/AttachmentItem/AttachmentItem.js.map +1 -0
  31. package/lib/components/FormComponents/AttachmentItem/AttachmentUrlField.d.ts +9 -0
  32. package/lib/components/FormComponents/AttachmentItem/AttachmentUrlField.js +25 -0
  33. package/lib/components/FormComponents/AttachmentItem/AttachmentUrlField.js.map +1 -0
  34. package/lib/components/FormComponents/BooleanItem/BooleanField.d.ts +13 -0
  35. package/lib/components/FormComponents/BooleanItem/BooleanField.js +65 -0
  36. package/lib/components/FormComponents/BooleanItem/BooleanField.js.map +1 -0
  37. package/lib/components/FormComponents/BooleanItem/BooleanItem.d.ts +8 -0
  38. package/lib/components/FormComponents/BooleanItem/BooleanItem.js +62 -0
  39. package/lib/components/FormComponents/BooleanItem/BooleanItem.js.map +1 -0
  40. package/lib/components/FormComponents/BooleanItem/index.d.ts +1 -0
  41. package/lib/components/FormComponents/BooleanItem/index.js +18 -0
  42. package/lib/components/FormComponents/BooleanItem/index.js.map +1 -0
  43. package/lib/components/FormComponents/Button.styles.d.ts +2 -0
  44. package/lib/components/FormComponents/Button.styles.js +10 -0
  45. package/lib/components/FormComponents/Button.styles.js.map +1 -0
  46. package/lib/components/FormComponents/ChoiceItems/CheckboxOptionList.d.ts +9 -0
  47. package/lib/components/FormComponents/ChoiceItems/CheckboxOptionList.js +20 -0
  48. package/lib/components/FormComponents/ChoiceItems/CheckboxOptionList.js.map +1 -0
  49. package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteField.d.ts +18 -0
  50. package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteField.js +29 -0
  51. package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteField.js.map +1 -0
  52. package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.d.ts +8 -0
  53. package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js +73 -0
  54. package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js.map +1 -0
  55. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.d.ts +11 -0
  56. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js +17 -0
  57. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js.map +1 -0
  58. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.d.ts +8 -0
  59. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js +45 -0
  60. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js.map +1 -0
  61. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.d.ts +13 -0
  62. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js +23 -0
  63. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js.map +1 -0
  64. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.d.ts +9 -0
  65. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +66 -0
  66. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -0
  67. package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.d.ts +8 -0
  68. package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js +45 -0
  69. package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js.map +1 -0
  70. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.d.ts +13 -0
  71. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js +29 -0
  72. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js.map +1 -0
  73. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.d.ts +8 -0
  74. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js +72 -0
  75. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js.map +1 -0
  76. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.d.ts +15 -0
  77. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.js +14 -0
  78. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.js.map +1 -0
  79. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.d.ts +15 -0
  80. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js +38 -0
  81. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js.map +1 -0
  82. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.d.ts +8 -0
  83. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js +74 -0
  84. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js.map +1 -0
  85. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioSingle.d.ts +8 -0
  86. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioSingle.js +13 -0
  87. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioSingle.js.map +1 -0
  88. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.d.ts +13 -0
  89. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js +20 -0
  90. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js.map +1 -0
  91. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.d.ts +8 -0
  92. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js +52 -0
  93. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js.map +1 -0
  94. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.d.ts +14 -0
  95. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.js +33 -0
  96. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.js.map +1 -0
  97. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.d.ts +15 -0
  98. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.js +27 -0
  99. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.js.map +1 -0
  100. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.d.ts +8 -0
  101. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js +91 -0
  102. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js.map +1 -0
  103. package/lib/components/FormComponents/ChoiceItems/index.d.ts +1 -0
  104. package/lib/components/FormComponents/ChoiceItems/index.js +18 -0
  105. package/lib/components/FormComponents/ChoiceItems/index.js.map +1 -0
  106. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateField.d.ts +19 -0
  107. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateField.js +24 -0
  108. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateField.js.map +1 -0
  109. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.d.ts +5 -0
  110. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.js +71 -0
  111. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.js.map +1 -0
  112. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/DatePicker.d.ts +10 -0
  113. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/DatePicker.js +57 -0
  114. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/DatePicker.js.map +1 -0
  115. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/DatePickerButton.d.ts +8 -0
  116. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/DatePickerButton.js +14 -0
  117. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/DatePickerButton.js.map +1 -0
  118. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/MuiDatePicker.d.ts +5 -0
  119. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/MuiDatePicker.js +20 -0
  120. package/lib/components/FormComponents/DateTimeItems/CustomDateItem/MuiDatePicker.js.map +1 -0
  121. package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.d.ts +5 -0
  122. package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js +120 -0
  123. package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js.map +1 -0
  124. package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomTimeField.d.ts +16 -0
  125. package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomTimeField.js +26 -0
  126. package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomTimeField.js.map +1 -0
  127. package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/DateTimeField.d.ts +23 -0
  128. package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/DateTimeField.js +10 -0
  129. package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/DateTimeField.js.map +1 -0
  130. package/lib/components/FormComponents/DateTimeItems/index.d.ts +1 -0
  131. package/lib/components/FormComponents/DateTimeItems/index.js +18 -0
  132. package/lib/components/FormComponents/DateTimeItems/index.js.map +1 -0
  133. package/lib/components/FormComponents/DateTimeItems/utils/index.d.ts +1 -0
  134. package/lib/components/FormComponents/DateTimeItems/utils/index.js +18 -0
  135. package/lib/components/FormComponents/DateTimeItems/utils/index.js.map +1 -0
  136. package/lib/components/FormComponents/DateTimeItems/utils/parseDate.d.ts +14 -0
  137. package/lib/components/FormComponents/DateTimeItems/utils/parseDate.js +126 -0
  138. package/lib/components/FormComponents/DateTimeItems/utils/parseDate.js.map +1 -0
  139. package/lib/components/FormComponents/DateTimeItems/utils/parseTime.d.ts +19 -0
  140. package/lib/components/FormComponents/DateTimeItems/utils/parseTime.js +81 -0
  141. package/lib/components/FormComponents/DateTimeItems/utils/parseTime.js.map +1 -0
  142. package/lib/components/FormComponents/DecimalItem/DecimalField.d.ts +15 -0
  143. package/lib/components/FormComponents/DecimalItem/DecimalField.js +20 -0
  144. package/lib/components/FormComponents/DecimalItem/DecimalField.js.map +1 -0
  145. package/lib/components/FormComponents/DecimalItem/DecimalItem.d.ts +8 -0
  146. package/lib/components/FormComponents/DecimalItem/DecimalItem.js +101 -0
  147. package/lib/components/FormComponents/DecimalItem/DecimalItem.js.map +1 -0
  148. package/lib/components/FormComponents/DecimalItem/index.d.ts +1 -0
  149. package/lib/components/FormComponents/DecimalItem/index.js +18 -0
  150. package/lib/components/FormComponents/DecimalItem/index.js.map +1 -0
  151. package/lib/components/FormComponents/DisplayItem/DisplayInstructions.d.ts +8 -0
  152. package/lib/components/FormComponents/DisplayItem/DisplayInstructions.js +10 -0
  153. package/lib/components/FormComponents/DisplayItem/DisplayInstructions.js.map +1 -0
  154. package/lib/components/FormComponents/DisplayItem/DisplayInstructions.styles.d.ts +3 -0
  155. package/lib/components/FormComponents/DisplayItem/DisplayInstructions.styles.js +23 -0
  156. package/lib/components/FormComponents/DisplayItem/DisplayInstructions.styles.js.map +1 -0
  157. package/lib/components/FormComponents/DisplayItem/DisplayItem.d.ts +11 -0
  158. package/lib/components/FormComponents/DisplayItem/DisplayItem.js +44 -0
  159. package/lib/components/FormComponents/DisplayItem/DisplayItem.js.map +1 -0
  160. package/lib/components/FormComponents/GridGroup/GridGroup.d.ts +16 -0
  161. package/lib/components/FormComponents/GridGroup/GridGroup.js +68 -0
  162. package/lib/components/FormComponents/GridGroup/GridGroup.js.map +1 -0
  163. package/lib/components/FormComponents/GridGroup/GridRow.d.ts +10 -0
  164. package/lib/components/FormComponents/GridGroup/GridRow.js +57 -0
  165. package/lib/components/FormComponents/GridGroup/GridRow.js.map +1 -0
  166. package/lib/components/FormComponents/GridGroup/GridTable.d.ts +10 -0
  167. package/lib/components/FormComponents/GridGroup/GridTable.js +28 -0
  168. package/lib/components/FormComponents/GridGroup/GridTable.js.map +1 -0
  169. package/lib/components/FormComponents/GridGroup/index.d.ts +1 -0
  170. package/lib/components/FormComponents/GridGroup/index.js +18 -0
  171. package/lib/components/FormComponents/GridGroup/index.js.map +1 -0
  172. package/lib/components/FormComponents/GroupItem/GroupAccordion.styles.d.ts +17 -0
  173. package/lib/components/FormComponents/GroupItem/GroupAccordion.styles.js +12 -0
  174. package/lib/components/FormComponents/GroupItem/GroupAccordion.styles.js.map +1 -0
  175. package/lib/components/FormComponents/GroupItem/GroupHeading.d.ts +13 -0
  176. package/lib/components/FormComponents/GroupItem/GroupHeading.js +44 -0
  177. package/lib/components/FormComponents/GroupItem/GroupHeading.js.map +1 -0
  178. package/lib/components/FormComponents/GroupItem/GroupItem.d.ts +19 -0
  179. package/lib/components/FormComponents/GroupItem/GroupItem.js +60 -0
  180. package/lib/components/FormComponents/GroupItem/GroupItem.js.map +1 -0
  181. package/lib/components/FormComponents/GroupItem/GroupItem.styles.d.ts +5 -0
  182. package/lib/components/FormComponents/GroupItem/GroupItem.styles.js +28 -0
  183. package/lib/components/FormComponents/GroupItem/GroupItem.styles.js.map +1 -0
  184. package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.d.ts +10 -0
  185. package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js +70 -0
  186. package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js.map +1 -0
  187. package/lib/components/FormComponents/GroupItem/GroupItemView.d.ts +20 -0
  188. package/lib/components/FormComponents/GroupItem/GroupItemView.js +75 -0
  189. package/lib/components/FormComponents/GroupItem/GroupItemView.js.map +1 -0
  190. package/lib/components/FormComponents/GroupItem/NextPageButton.d.ts +6 -0
  191. package/lib/components/FormComponents/GroupItem/NextPageButton.js +9 -0
  192. package/lib/components/FormComponents/GroupItem/NextPageButton.js.map +1 -0
  193. package/lib/components/FormComponents/GroupItem/NextTabButton.d.ts +6 -0
  194. package/lib/components/FormComponents/GroupItem/NextTabButton.js +9 -0
  195. package/lib/components/FormComponents/GroupItem/NextTabButton.js.map +1 -0
  196. package/lib/components/FormComponents/GroupItem/PageButtonWrapper.d.ts +8 -0
  197. package/lib/components/FormComponents/GroupItem/PageButtonWrapper.js +48 -0
  198. package/lib/components/FormComponents/GroupItem/PageButtonWrapper.js.map +1 -0
  199. package/lib/components/FormComponents/GroupItem/PreviousPageButton.d.ts +6 -0
  200. package/lib/components/FormComponents/GroupItem/PreviousPageButton.js +9 -0
  201. package/lib/components/FormComponents/GroupItem/PreviousPageButton.js.map +1 -0
  202. package/lib/components/FormComponents/GroupItem/PreviousTabButton.d.ts +6 -0
  203. package/lib/components/FormComponents/GroupItem/PreviousTabButton.js +9 -0
  204. package/lib/components/FormComponents/GroupItem/PreviousTabButton.js.map +1 -0
  205. package/lib/components/FormComponents/GroupItem/TabButtonsWrapper.d.ts +8 -0
  206. package/lib/components/FormComponents/GroupItem/TabButtonsWrapper.js +71 -0
  207. package/lib/components/FormComponents/GroupItem/TabButtonsWrapper.js.map +1 -0
  208. package/lib/components/FormComponents/GroupItem/index.d.ts +1 -0
  209. package/lib/components/FormComponents/GroupItem/index.js +18 -0
  210. package/lib/components/FormComponents/GroupItem/index.js.map +1 -0
  211. package/lib/components/FormComponents/IntegerItem/IntegerField.d.ts +15 -0
  212. package/lib/components/FormComponents/IntegerItem/IntegerField.js +20 -0
  213. package/lib/components/FormComponents/IntegerItem/IntegerField.js.map +1 -0
  214. package/lib/components/FormComponents/IntegerItem/IntegerItem.d.ts +8 -0
  215. package/lib/components/FormComponents/IntegerItem/IntegerItem.js +87 -0
  216. package/lib/components/FormComponents/IntegerItem/IntegerItem.js.map +1 -0
  217. package/lib/components/FormComponents/Item.styles.d.ts +4 -0
  218. package/lib/components/FormComponents/Item.styles.js +32 -0
  219. package/lib/components/FormComponents/Item.styles.js.map +1 -0
  220. package/lib/components/FormComponents/ItemParts/CheckboxSingle.d.ts +9 -0
  221. package/lib/components/FormComponents/ItemParts/CheckboxSingle.js +17 -0
  222. package/lib/components/FormComponents/ItemParts/CheckboxSingle.js.map +1 -0
  223. package/lib/components/FormComponents/ItemParts/CheckboxSingleWithOpenLabel.d.ts +10 -0
  224. package/lib/components/FormComponents/ItemParts/CheckboxSingleWithOpenLabel.js +16 -0
  225. package/lib/components/FormComponents/ItemParts/CheckboxSingleWithOpenLabel.js.map +1 -0
  226. package/lib/components/FormComponents/ItemParts/ClearInputButton.d.ts +7 -0
  227. package/lib/components/FormComponents/ItemParts/ClearInputButton.js +16 -0
  228. package/lib/components/FormComponents/ItemParts/ClearInputButton.js.map +1 -0
  229. package/lib/components/FormComponents/ItemParts/ContextDisplayItem.d.ts +7 -0
  230. package/lib/components/FormComponents/ItemParts/ContextDisplayItem.js +30 -0
  231. package/lib/components/FormComponents/ItemParts/ContextDisplayItem.js.map +1 -0
  232. package/lib/components/FormComponents/ItemParts/DisplayUnitText.d.ts +6 -0
  233. package/lib/components/FormComponents/ItemParts/DisplayUnitText.js +11 -0
  234. package/lib/components/FormComponents/ItemParts/DisplayUnitText.js.map +1 -0
  235. package/lib/components/FormComponents/ItemParts/FadingCheckIcon.d.ts +6 -0
  236. package/lib/components/FormComponents/ItemParts/FadingCheckIcon.js +9 -0
  237. package/lib/components/FormComponents/ItemParts/FadingCheckIcon.js.map +1 -0
  238. package/lib/components/FormComponents/ItemParts/FlyoverHoverCard.d.ts +6 -0
  239. package/lib/components/FormComponents/ItemParts/FlyoverHoverCard.js +35 -0
  240. package/lib/components/FormComponents/ItemParts/FlyoverHoverCard.js.map +1 -0
  241. package/lib/components/FormComponents/ItemParts/FlyoverItem.d.ts +7 -0
  242. package/lib/components/FormComponents/ItemParts/FlyoverItem.js +15 -0
  243. package/lib/components/FormComponents/ItemParts/FlyoverItem.js.map +1 -0
  244. package/lib/components/FormComponents/ItemParts/ItemFieldGrid.d.ts +13 -0
  245. package/lib/components/FormComponents/ItemParts/ItemFieldGrid.js +14 -0
  246. package/lib/components/FormComponents/ItemParts/ItemFieldGrid.js.map +1 -0
  247. package/lib/components/FormComponents/ItemParts/ItemLabel.d.ts +10 -0
  248. package/lib/components/FormComponents/ItemParts/ItemLabel.js +45 -0
  249. package/lib/components/FormComponents/ItemParts/ItemLabel.js.map +1 -0
  250. package/lib/components/FormComponents/ItemParts/ItemTextSwitcher.d.ts +8 -0
  251. package/lib/components/FormComponents/ItemParts/ItemTextSwitcher.js +45 -0
  252. package/lib/components/FormComponents/ItemParts/ItemTextSwitcher.js.map +1 -0
  253. package/lib/components/FormComponents/ItemParts/OpenLabelField.d.ts +8 -0
  254. package/lib/components/FormComponents/ItemParts/OpenLabelField.js +19 -0
  255. package/lib/components/FormComponents/ItemParts/OpenLabelField.js.map +1 -0
  256. package/lib/components/FormComponents/ItemParts/RadioButtonWithOpenLabel.d.ts +9 -0
  257. package/lib/components/FormComponents/ItemParts/RadioButtonWithOpenLabel.js +10 -0
  258. package/lib/components/FormComponents/ItemParts/RadioButtonWithOpenLabel.js.map +1 -0
  259. package/lib/components/FormComponents/ItemParts/RadioOptionList.d.ts +8 -0
  260. package/lib/components/FormComponents/ItemParts/RadioOptionList.js +20 -0
  261. package/lib/components/FormComponents/ItemParts/RadioOptionList.js.map +1 -0
  262. package/lib/components/FormComponents/ItemParts/RequiredAsterisk.d.ts +6 -0
  263. package/lib/components/FormComponents/ItemParts/RequiredAsterisk.js +22 -0
  264. package/lib/components/FormComponents/ItemParts/RequiredAsterisk.js.map +1 -0
  265. package/lib/components/FormComponents/ItemParts/index.d.ts +2 -0
  266. package/lib/components/FormComponents/ItemParts/index.js +19 -0
  267. package/lib/components/FormComponents/ItemParts/index.js.map +1 -0
  268. package/lib/components/FormComponents/Lists.styles.d.ts +2 -0
  269. package/lib/components/FormComponents/Lists.styles.js +38 -0
  270. package/lib/components/FormComponents/Lists.styles.js.map +1 -0
  271. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.d.ts +20 -0
  272. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.js +32 -0
  273. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.js.map +1 -0
  274. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.d.ts +8 -0
  275. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js +92 -0
  276. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js.map +1 -0
  277. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.d.ts +16 -0
  278. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js +15 -0
  279. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js.map +1 -0
  280. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.d.ts +8 -0
  281. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js +91 -0
  282. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js.map +1 -0
  283. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.d.ts +18 -0
  284. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.js +24 -0
  285. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.js.map +1 -0
  286. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.d.ts +8 -0
  287. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.js +95 -0
  288. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.js.map +1 -0
  289. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.d.ts +8 -0
  290. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js +43 -0
  291. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js.map +1 -0
  292. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.d.ts +14 -0
  293. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js +22 -0
  294. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js.map +1 -0
  295. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.d.ts +8 -0
  296. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js +96 -0
  297. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js.map +1 -0
  298. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.d.ts +16 -0
  299. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.js +31 -0
  300. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.js.map +1 -0
  301. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetItem.d.ts +8 -0
  302. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetItem.js +100 -0
  303. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetItem.js.map +1 -0
  304. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.d.ts +12 -0
  305. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.js +18 -0
  306. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.js.map +1 -0
  307. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.d.ts +8 -0
  308. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js +54 -0
  309. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js.map +1 -0
  310. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.d.ts +14 -0
  311. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.js +18 -0
  312. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.js.map +1 -0
  313. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.d.ts +8 -0
  314. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js +47 -0
  315. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js.map +1 -0
  316. package/lib/components/FormComponents/QuantityItem/QuantityComparatorField.d.ts +12 -0
  317. package/lib/components/FormComponents/QuantityItem/QuantityComparatorField.js +21 -0
  318. package/lib/components/FormComponents/QuantityItem/QuantityComparatorField.js.map +1 -0
  319. package/lib/components/FormComponents/QuantityItem/QuantityField.d.ts +15 -0
  320. package/lib/components/FormComponents/QuantityItem/QuantityField.js +20 -0
  321. package/lib/components/FormComponents/QuantityItem/QuantityField.js.map +1 -0
  322. package/lib/components/FormComponents/QuantityItem/QuantityItem.d.ts +8 -0
  323. package/lib/components/FormComponents/QuantityItem/QuantityItem.js +144 -0
  324. package/lib/components/FormComponents/QuantityItem/QuantityItem.js.map +1 -0
  325. package/lib/components/FormComponents/QuantityItem/QuantityUnitField.d.ts +12 -0
  326. package/lib/components/FormComponents/QuantityItem/QuantityUnitField.js +13 -0
  327. package/lib/components/FormComponents/QuantityItem/QuantityUnitField.js.map +1 -0
  328. package/lib/components/FormComponents/RepeatGroup/AddItemButton.d.ts +8 -0
  329. package/lib/components/FormComponents/RepeatGroup/AddItemButton.js +12 -0
  330. package/lib/components/FormComponents/RepeatGroup/AddItemButton.js.map +1 -0
  331. package/lib/components/FormComponents/RepeatGroup/DeleteItemButton.d.ts +9 -0
  332. package/lib/components/FormComponents/RepeatGroup/DeleteItemButton.js +11 -0
  333. package/lib/components/FormComponents/RepeatGroup/DeleteItemButton.js.map +1 -0
  334. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.d.ts +16 -0
  335. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +74 -0
  336. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -0
  337. package/lib/components/FormComponents/RepeatGroup/RepeatGroupItem.d.ts +13 -0
  338. package/lib/components/FormComponents/RepeatGroup/RepeatGroupItem.js +13 -0
  339. package/lib/components/FormComponents/RepeatGroup/RepeatGroupItem.js.map +1 -0
  340. package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.d.ts +20 -0
  341. package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.js +57 -0
  342. package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.js.map +1 -0
  343. package/lib/components/FormComponents/RepeatGroup/index.d.ts +1 -0
  344. package/lib/components/FormComponents/RepeatGroup/index.js +18 -0
  345. package/lib/components/FormComponents/RepeatGroup/index.js.map +1 -0
  346. package/lib/components/FormComponents/RepeatItem/AddItemButton.d.ts +8 -0
  347. package/lib/components/FormComponents/RepeatItem/AddItemButton.js +14 -0
  348. package/lib/components/FormComponents/RepeatItem/AddItemButton.js.map +1 -0
  349. package/lib/components/FormComponents/RepeatItem/RemoveItemButton.d.ts +9 -0
  350. package/lib/components/FormComponents/RepeatItem/RemoveItemButton.js +11 -0
  351. package/lib/components/FormComponents/RepeatItem/RemoveItemButton.js.map +1 -0
  352. package/lib/components/FormComponents/RepeatItem/RepeatField.d.ts +12 -0
  353. package/lib/components/FormComponents/RepeatItem/RepeatField.js +14 -0
  354. package/lib/components/FormComponents/RepeatItem/RepeatField.js.map +1 -0
  355. package/lib/components/FormComponents/RepeatItem/RepeatItem.d.ts +14 -0
  356. package/lib/components/FormComponents/RepeatItem/RepeatItem.js +59 -0
  357. package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -0
  358. package/lib/components/FormComponents/RepeatItem/RepeatItem.styles.d.ts +4 -0
  359. package/lib/components/FormComponents/RepeatItem/RepeatItem.styles.js +31 -0
  360. package/lib/components/FormComponents/RepeatItem/RepeatItem.styles.js.map +1 -0
  361. package/lib/components/FormComponents/RepeatItem/index.d.ts +1 -0
  362. package/lib/components/FormComponents/RepeatItem/index.js +18 -0
  363. package/lib/components/FormComponents/RepeatItem/index.js.map +1 -0
  364. package/lib/components/FormComponents/SingleItem/NestedSingleItemAccordion.styles.d.ts +23 -0
  365. package/lib/components/FormComponents/SingleItem/NestedSingleItemAccordion.styles.js +51 -0
  366. package/lib/components/FormComponents/SingleItem/NestedSingleItemAccordion.styles.js.map +1 -0
  367. package/lib/components/FormComponents/SingleItem/SingleItem.d.ts +16 -0
  368. package/lib/components/FormComponents/SingleItem/SingleItem.js +59 -0
  369. package/lib/components/FormComponents/SingleItem/SingleItem.js.map +1 -0
  370. package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.d.ts +8 -0
  371. package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js +70 -0
  372. package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js.map +1 -0
  373. package/lib/components/FormComponents/SingleItem/SingleItemView.d.ts +13 -0
  374. package/lib/components/FormComponents/SingleItem/SingleItemView.js +37 -0
  375. package/lib/components/FormComponents/SingleItem/SingleItemView.js.map +1 -0
  376. package/lib/components/FormComponents/SingleItem/SingleNestedItems.d.ts +9 -0
  377. package/lib/components/FormComponents/SingleItem/SingleNestedItems.js +54 -0
  378. package/lib/components/FormComponents/SingleItem/SingleNestedItems.js.map +1 -0
  379. package/lib/components/FormComponents/SingleItem/StopPropagationWrapper.d.ts +6 -0
  380. package/lib/components/FormComponents/SingleItem/StopPropagationWrapper.js +9 -0
  381. package/lib/components/FormComponents/SingleItem/StopPropagationWrapper.js.map +1 -0
  382. package/lib/components/FormComponents/SingleItem/index.d.ts +1 -0
  383. package/lib/components/FormComponents/SingleItem/index.js +18 -0
  384. package/lib/components/FormComponents/SingleItem/index.js.map +1 -0
  385. package/lib/components/FormComponents/SliderItem/Slider.styles.d.ts +9 -0
  386. package/lib/components/FormComponents/SliderItem/Slider.styles.js +59 -0
  387. package/lib/components/FormComponents/SliderItem/Slider.styles.js.map +1 -0
  388. package/lib/components/FormComponents/SliderItem/SliderDisplayValue.d.ts +7 -0
  389. package/lib/components/FormComponents/SliderItem/SliderDisplayValue.js +10 -0
  390. package/lib/components/FormComponents/SliderItem/SliderDisplayValue.js.map +1 -0
  391. package/lib/components/FormComponents/SliderItem/SliderField.d.ts +17 -0
  392. package/lib/components/FormComponents/SliderItem/SliderField.js +30 -0
  393. package/lib/components/FormComponents/SliderItem/SliderField.js.map +1 -0
  394. package/lib/components/FormComponents/SliderItem/SliderItem.d.ts +8 -0
  395. package/lib/components/FormComponents/SliderItem/SliderItem.js +42 -0
  396. package/lib/components/FormComponents/SliderItem/SliderItem.js.map +1 -0
  397. package/lib/components/FormComponents/SliderItem/SliderLabels.d.ts +6 -0
  398. package/lib/components/FormComponents/SliderItem/SliderLabels.js +15 -0
  399. package/lib/components/FormComponents/SliderItem/SliderLabels.js.map +1 -0
  400. package/lib/components/FormComponents/StringItem/StringField.d.ts +15 -0
  401. package/lib/components/FormComponents/StringItem/StringField.js +19 -0
  402. package/lib/components/FormComponents/StringItem/StringField.js.map +1 -0
  403. package/lib/components/FormComponents/StringItem/StringItem.d.ts +9 -0
  404. package/lib/components/FormComponents/StringItem/StringItem.js +79 -0
  405. package/lib/components/FormComponents/StringItem/StringItem.js.map +1 -0
  406. package/lib/components/FormComponents/StringItem/index.d.ts +1 -0
  407. package/lib/components/FormComponents/StringItem/index.js +18 -0
  408. package/lib/components/FormComponents/StringItem/index.js.map +1 -0
  409. package/lib/components/FormComponents/Tables/AddRowButton.d.ts +8 -0
  410. package/lib/components/FormComponents/Tables/AddRowButton.js +11 -0
  411. package/lib/components/FormComponents/Tables/AddRowButton.js.map +1 -0
  412. package/lib/components/FormComponents/Tables/GroupTable.d.ts +16 -0
  413. package/lib/components/FormComponents/Tables/GroupTable.js +133 -0
  414. package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -0
  415. package/lib/components/FormComponents/Tables/GroupTableBody.d.ts +16 -0
  416. package/lib/components/FormComponents/Tables/GroupTableBody.js +29 -0
  417. package/lib/components/FormComponents/Tables/GroupTableBody.js.map +1 -0
  418. package/lib/components/FormComponents/Tables/GroupTableRow.d.ts +23 -0
  419. package/lib/components/FormComponents/Tables/GroupTableRow.js +19 -0
  420. package/lib/components/FormComponents/Tables/GroupTableRow.js.map +1 -0
  421. package/lib/components/FormComponents/Tables/GroupTableRowCells.d.ts +9 -0
  422. package/lib/components/FormComponents/Tables/GroupTableRowCells.js +29 -0
  423. package/lib/components/FormComponents/Tables/GroupTableRowCells.js.map +1 -0
  424. package/lib/components/FormComponents/Tables/GroupTableView.d.ts +21 -0
  425. package/lib/components/FormComponents/Tables/GroupTableView.js +49 -0
  426. package/lib/components/FormComponents/Tables/GroupTableView.js.map +1 -0
  427. package/lib/components/FormComponents/Tables/RemoveRowButton.d.ts +9 -0
  428. package/lib/components/FormComponents/Tables/RemoveRowButton.js +12 -0
  429. package/lib/components/FormComponents/Tables/RemoveRowButton.js.map +1 -0
  430. package/lib/components/FormComponents/Tables/SelectRowButton.d.ts +7 -0
  431. package/lib/components/FormComponents/Tables/SelectRowButton.js +11 -0
  432. package/lib/components/FormComponents/Tables/SelectRowButton.js.map +1 -0
  433. package/lib/components/FormComponents/Tables/Table.styles.d.ts +15 -0
  434. package/lib/components/FormComponents/Tables/Table.styles.js +64 -0
  435. package/lib/components/FormComponents/Tables/Table.styles.js.map +1 -0
  436. package/lib/components/FormComponents/Tables/index.d.ts +1 -0
  437. package/lib/components/FormComponents/Tables/index.js +18 -0
  438. package/lib/components/FormComponents/Tables/index.js.map +1 -0
  439. package/lib/components/FormComponents/TextItem/MuiTextField.d.ts +3 -0
  440. package/lib/components/FormComponents/TextItem/MuiTextField.js +20 -0
  441. package/lib/components/FormComponents/TextItem/MuiTextField.js.map +1 -0
  442. package/lib/components/FormComponents/TextItem/TextField.d.ts +14 -0
  443. package/lib/components/FormComponents/TextItem/TextField.js +18 -0
  444. package/lib/components/FormComponents/TextItem/TextField.js.map +1 -0
  445. package/lib/components/FormComponents/TextItem/TextItem.d.ts +5 -0
  446. package/lib/components/FormComponents/TextItem/TextItem.js +79 -0
  447. package/lib/components/FormComponents/TextItem/TextItem.js.map +1 -0
  448. package/lib/components/FormComponents/Textfield.styles.d.ts +6 -0
  449. package/lib/components/FormComponents/Textfield.styles.js +28 -0
  450. package/lib/components/FormComponents/Textfield.styles.js.map +1 -0
  451. package/lib/components/FormComponents/TimeItem/TimeField.d.ts +13 -0
  452. package/lib/components/FormComponents/TimeItem/TimeField.js +21 -0
  453. package/lib/components/FormComponents/TimeItem/TimeField.js.map +1 -0
  454. package/lib/components/FormComponents/TimeItem/TimeItem.d.ts +8 -0
  455. package/lib/components/FormComponents/TimeItem/TimeItem.js +39 -0
  456. package/lib/components/FormComponents/TimeItem/TimeItem.js.map +1 -0
  457. package/lib/components/FormComponents/UrlItem/UrlField.d.ts +14 -0
  458. package/lib/components/FormComponents/UrlItem/UrlField.js +18 -0
  459. package/lib/components/FormComponents/UrlItem/UrlField.js.map +1 -0
  460. package/lib/components/FormComponents/UrlItem/UrlItem.d.ts +5 -0
  461. package/lib/components/FormComponents/UrlItem/UrlItem.js +65 -0
  462. package/lib/components/FormComponents/UrlItem/UrlItem.js.map +1 -0
  463. package/lib/components/FormComponents/index.d.ts +12 -0
  464. package/lib/components/FormComponents/index.js +30 -0
  465. package/lib/components/FormComponents/index.js.map +1 -0
  466. package/lib/components/Iconify/Iconify.d.ts +10 -0
  467. package/lib/components/Iconify/Iconify.js +27 -0
  468. package/lib/components/Iconify/Iconify.js.map +1 -0
  469. package/lib/components/Lists.styles.d.ts +2 -0
  470. package/lib/components/Lists.styles.js +38 -0
  471. package/lib/components/Lists.styles.js.map +1 -0
  472. package/lib/components/Radio.styles.d.ts +3 -0
  473. package/lib/components/Radio.styles.js +16 -0
  474. package/lib/components/Radio.styles.js.map +1 -0
  475. package/lib/components/Renderer/BaseRenderer.d.ts +9 -0
  476. package/lib/components/Renderer/BaseRenderer.js +80 -0
  477. package/lib/components/Renderer/BaseRenderer.js.map +1 -0
  478. package/lib/components/Renderer/FormBodyCollapsible.d.ts +8 -0
  479. package/lib/components/Renderer/FormBodyCollapsible.js +59 -0
  480. package/lib/components/Renderer/FormBodyCollapsible.js.map +1 -0
  481. package/lib/components/Renderer/FormBodyPage.d.ts +8 -0
  482. package/lib/components/Renderer/FormBodyPage.js +41 -0
  483. package/lib/components/Renderer/FormBodyPage.js.map +1 -0
  484. package/lib/components/Renderer/FormBodyPageContainer.d.ts +8 -0
  485. package/lib/components/Renderer/FormBodyPageContainer.js +48 -0
  486. package/lib/components/Renderer/FormBodyPageContainer.js.map +1 -0
  487. package/lib/components/Renderer/FormBodyPaginated.d.ts +8 -0
  488. package/lib/components/Renderer/FormBodyPaginated.js +84 -0
  489. package/lib/components/Renderer/FormBodyPaginated.js.map +1 -0
  490. package/lib/components/Renderer/FormBodySingleCollapsible.d.ts +12 -0
  491. package/lib/components/Renderer/FormBodySingleCollapsible.js +25 -0
  492. package/lib/components/Renderer/FormBodySingleCollapsible.js.map +1 -0
  493. package/lib/components/Renderer/FormBodySingleCollapsibleWrapper.d.ts +11 -0
  494. package/lib/components/Renderer/FormBodySingleCollapsibleWrapper.js +14 -0
  495. package/lib/components/Renderer/FormBodySingleCollapsibleWrapper.js.map +1 -0
  496. package/lib/components/Renderer/FormBodySinglePage.d.ts +8 -0
  497. package/lib/components/Renderer/FormBodySinglePage.js +42 -0
  498. package/lib/components/Renderer/FormBodySinglePage.js.map +1 -0
  499. package/lib/components/Renderer/FormBodyTabbed.d.ts +8 -0
  500. package/lib/components/Renderer/FormBodyTabbed.js +67 -0
  501. package/lib/components/Renderer/FormBodyTabbed.js.map +1 -0
  502. package/lib/components/Renderer/FormTopLevelItem.d.ts +9 -0
  503. package/lib/components/Renderer/FormTopLevelItem.js +80 -0
  504. package/lib/components/Renderer/FormTopLevelItem.js.map +1 -0
  505. package/lib/components/Renderer/FormTopLevelPage.d.ts +8 -0
  506. package/lib/components/Renderer/FormTopLevelPage.js +26 -0
  507. package/lib/components/Renderer/FormTopLevelPage.js.map +1 -0
  508. package/lib/components/Renderer/SmartFormsRenderer.d.ts +33 -0
  509. package/lib/components/Renderer/SmartFormsRenderer.js +29 -0
  510. package/lib/components/Renderer/SmartFormsRenderer.js.map +1 -0
  511. package/lib/components/Renderer/index.d.ts +3 -0
  512. package/lib/components/Renderer/index.js +19 -0
  513. package/lib/components/Renderer/index.js.map +1 -0
  514. package/lib/components/Tabs/CompleteTabButton.d.ts +7 -0
  515. package/lib/components/Tabs/CompleteTabButton.js +29 -0
  516. package/lib/components/Tabs/CompleteTabButton.js.map +1 -0
  517. package/lib/components/Tabs/FormBodySingleTab.d.ts +10 -0
  518. package/lib/components/Tabs/FormBodySingleTab.js +43 -0
  519. package/lib/components/Tabs/FormBodySingleTab.js.map +1 -0
  520. package/lib/components/Tabs/FormBodyTabList.d.ts +12 -0
  521. package/lib/components/Tabs/FormBodyTabList.js +51 -0
  522. package/lib/components/Tabs/FormBodyTabList.js.map +1 -0
  523. package/lib/components/Tabs/FormBodyTabListWrapper.d.ts +10 -0
  524. package/lib/components/Tabs/FormBodyTabListWrapper.js +33 -0
  525. package/lib/components/Tabs/FormBodyTabListWrapper.js.map +1 -0
  526. package/lib/components/Tabs/ShowCompletedTabsSection.d.ts +6 -0
  527. package/lib/components/Tabs/ShowCompletedTabsSection.js +14 -0
  528. package/lib/components/Tabs/ShowCompletedTabsSection.js.map +1 -0
  529. package/lib/components/index.d.ts +4 -0
  530. package/lib/components/index.js +21 -0
  531. package/lib/components/index.js.map +1 -0
  532. package/lib/globals.d.ts +1 -0
  533. package/lib/globals.js +18 -0
  534. package/lib/globals.js.map +1 -0
  535. package/lib/hooks/UseFileDrop.d.ts +10 -0
  536. package/lib/hooks/UseFileDrop.js +40 -0
  537. package/lib/hooks/UseFileDrop.js.map +1 -0
  538. package/lib/hooks/index.d.ts +12 -0
  539. package/lib/hooks/index.js +14 -0
  540. package/lib/hooks/index.js.map +1 -0
  541. package/lib/hooks/useAttachmentUrlValidation.d.ts +2 -0
  542. package/lib/hooks/useAttachmentUrlValidation.js +27 -0
  543. package/lib/hooks/useAttachmentUrlValidation.js.map +1 -0
  544. package/lib/hooks/useBooleanCalculatedExpression.d.ts +12 -0
  545. package/lib/hooks/useBooleanCalculatedExpression.js +53 -0
  546. package/lib/hooks/useBooleanCalculatedExpression.js.map +1 -0
  547. package/lib/hooks/useBuildForm.d.ts +22 -0
  548. package/lib/hooks/useBuildForm.js +61 -0
  549. package/lib/hooks/useBuildForm.js.map +1 -0
  550. package/lib/hooks/useCodingCalculatedExpression.d.ts +13 -0
  551. package/lib/hooks/useCodingCalculatedExpression.js +70 -0
  552. package/lib/hooks/useCodingCalculatedExpression.js.map +1 -0
  553. package/lib/hooks/useContextDisplayItems.d.ts +6 -0
  554. package/lib/hooks/useContextDisplayItems.js +30 -0
  555. package/lib/hooks/useContextDisplayItems.js.map +1 -0
  556. package/lib/hooks/useDateTimeNonEmpty.d.ts +2 -0
  557. package/lib/hooks/useDateTimeNonEmpty.js +24 -0
  558. package/lib/hooks/useDateTimeNonEmpty.js.map +1 -0
  559. package/lib/hooks/useDateValidation.d.ts +2 -0
  560. package/lib/hooks/useDateValidation.js +61 -0
  561. package/lib/hooks/useDateValidation.js.map +1 -0
  562. package/lib/hooks/useDebounce.d.ts +2 -0
  563. package/lib/hooks/useDebounce.js +38 -0
  564. package/lib/hooks/useDebounce.js.map +1 -0
  565. package/lib/hooks/useDecimalCalculatedExpression.d.ts +13 -0
  566. package/lib/hooks/useDecimalCalculatedExpression.js +59 -0
  567. package/lib/hooks/useDecimalCalculatedExpression.js.map +1 -0
  568. package/lib/hooks/useDisplayCqfAndCalculatedExpression.d.ts +3 -0
  569. package/lib/hooks/useDisplayCqfAndCalculatedExpression.js +40 -0
  570. package/lib/hooks/useDisplayCqfAndCalculatedExpression.js.map +1 -0
  571. package/lib/hooks/useFocusTabHeading.d.ts +1 -0
  572. package/lib/hooks/useFocusTabHeading.js +20 -0
  573. package/lib/hooks/useFocusTabHeading.js.map +1 -0
  574. package/lib/hooks/useGroupTableRows.d.ts +9 -0
  575. package/lib/hooks/useGroupTableRows.js +24 -0
  576. package/lib/hooks/useGroupTableRows.js.map +1 -0
  577. package/lib/hooks/useHidden.d.ts +9 -0
  578. package/lib/hooks/useHidden.js +50 -0
  579. package/lib/hooks/useHidden.js.map +1 -0
  580. package/lib/hooks/useInitialiseForm.d.ts +20 -0
  581. package/lib/hooks/useInitialiseForm.js +72 -0
  582. package/lib/hooks/useInitialiseForm.js.map +1 -0
  583. package/lib/hooks/useInitialiseGroupTableRows.d.ts +4 -0
  584. package/lib/hooks/useInitialiseGroupTableRows.js +34 -0
  585. package/lib/hooks/useInitialiseGroupTableRows.js.map +1 -0
  586. package/lib/hooks/useInitialiseRepeatAnswers.d.ts +3 -0
  587. package/lib/hooks/useInitialiseRepeatAnswers.js +31 -0
  588. package/lib/hooks/useInitialiseRepeatAnswers.js.map +1 -0
  589. package/lib/hooks/useInitialiseRepeatGroups.d.ts +4 -0
  590. package/lib/hooks/useInitialiseRepeatGroups.js +33 -0
  591. package/lib/hooks/useInitialiseRepeatGroups.js.map +1 -0
  592. package/lib/hooks/useIntegerCalculatedExpression.d.ts +12 -0
  593. package/lib/hooks/useIntegerCalculatedExpression.js +56 -0
  594. package/lib/hooks/useIntegerCalculatedExpression.js.map +1 -0
  595. package/lib/hooks/useNextAndPreviousVisiblePages.d.ts +7 -0
  596. package/lib/hooks/useNextAndPreviousVisiblePages.js +47 -0
  597. package/lib/hooks/useNextAndPreviousVisiblePages.js.map +1 -0
  598. package/lib/hooks/useNextAndPreviousVisibleTabs.d.ts +7 -0
  599. package/lib/hooks/useNextAndPreviousVisibleTabs.js +63 -0
  600. package/lib/hooks/useNextAndPreviousVisibleTabs.js.map +1 -0
  601. package/lib/hooks/useOpenLabel.d.ts +9 -0
  602. package/lib/hooks/useOpenLabel.js +34 -0
  603. package/lib/hooks/useOpenLabel.js.map +1 -0
  604. package/lib/hooks/useParseXhtml.d.ts +7 -0
  605. package/lib/hooks/useParseXhtml.js +158 -0
  606. package/lib/hooks/useParseXhtml.js.map +1 -0
  607. package/lib/hooks/useQuantityCalculatedExpression.d.ts +14 -0
  608. package/lib/hooks/useQuantityCalculatedExpression.js +107 -0
  609. package/lib/hooks/useQuantityCalculatedExpression.js.map +1 -0
  610. package/lib/hooks/useReadOnly.d.ts +3 -0
  611. package/lib/hooks/useReadOnly.js +47 -0
  612. package/lib/hooks/useReadOnly.js.map +1 -0
  613. package/lib/hooks/useRendererQueryClient.d.ts +10 -0
  614. package/lib/hooks/useRendererQueryClient.js +35 -0
  615. package/lib/hooks/useRendererQueryClient.js.map +1 -0
  616. package/lib/hooks/useRenderingExtensions.d.ts +14 -0
  617. package/lib/hooks/useRenderingExtensions.js +36 -0
  618. package/lib/hooks/useRenderingExtensions.js.map +1 -0
  619. package/lib/hooks/useResponsive.d.ts +50 -0
  620. package/lib/hooks/useResponsive.js +57 -0
  621. package/lib/hooks/useResponsive.js.map +1 -0
  622. package/lib/hooks/useSliderExtensions.d.ts +10 -0
  623. package/lib/hooks/useSliderExtensions.js +37 -0
  624. package/lib/hooks/useSliderExtensions.js.map +1 -0
  625. package/lib/hooks/useStringCalculatedExpression.d.ts +12 -0
  626. package/lib/hooks/useStringCalculatedExpression.js +63 -0
  627. package/lib/hooks/useStringCalculatedExpression.js.map +1 -0
  628. package/lib/hooks/useTerminologyServerQuery.d.ts +11 -0
  629. package/lib/hooks/useTerminologyServerQuery.js +76 -0
  630. package/lib/hooks/useTerminologyServerQuery.js.map +1 -0
  631. package/lib/hooks/useTimeValidation.d.ts +5 -0
  632. package/lib/hooks/useTimeValidation.js +54 -0
  633. package/lib/hooks/useTimeValidation.js.map +1 -0
  634. package/lib/hooks/useValidationFeedback.d.ts +3 -0
  635. package/lib/hooks/useValidationFeedback.js +122 -0
  636. package/lib/hooks/useValidationFeedback.js.map +1 -0
  637. package/lib/hooks/useValueSetCodings.d.ts +11 -0
  638. package/lib/hooks/useValueSetCodings.js +213 -0
  639. package/lib/hooks/useValueSetCodings.js.map +1 -0
  640. package/lib/index.d.ts +13 -0
  641. package/lib/index.js +10 -0
  642. package/lib/index.js.map +1 -0
  643. package/lib/interfaces/answerExpression.interface.d.ts +5 -0
  644. package/lib/interfaces/answerExpression.interface.js +18 -0
  645. package/lib/interfaces/answerExpression.interface.js.map +1 -0
  646. package/lib/interfaces/calculatedExpression.interface.d.ts +12 -0
  647. package/lib/interfaces/calculatedExpression.interface.js +18 -0
  648. package/lib/interfaces/calculatedExpression.interface.js.map +1 -0
  649. package/lib/interfaces/choice.enum.d.ts +20 -0
  650. package/lib/interfaces/choice.enum.js +41 -0
  651. package/lib/interfaces/choice.enum.js.map +1 -0
  652. package/lib/interfaces/computedChanges.interface.d.ts +5 -0
  653. package/lib/interfaces/computedChanges.interface.js +2 -0
  654. package/lib/interfaces/computedChanges.interface.js.map +1 -0
  655. package/lib/interfaces/computedUpdates.interface.d.ts +3 -0
  656. package/lib/interfaces/computedUpdates.interface.js +2 -0
  657. package/lib/interfaces/computedUpdates.interface.js.map +1 -0
  658. package/lib/interfaces/enableWhen.interface.d.ts +50 -0
  659. package/lib/interfaces/enableWhen.interface.js +18 -0
  660. package/lib/interfaces/enableWhen.interface.js.map +1 -0
  661. package/lib/interfaces/groupTable.interface.d.ts +5 -0
  662. package/lib/interfaces/groupTable.interface.js +18 -0
  663. package/lib/interfaces/groupTable.interface.js.map +1 -0
  664. package/lib/interfaces/index.d.ts +6 -0
  665. package/lib/interfaces/index.js +18 -0
  666. package/lib/interfaces/index.js.map +1 -0
  667. package/lib/interfaces/initialExpression.interface.d.ts +8 -0
  668. package/lib/interfaces/initialExpression.interface.js +18 -0
  669. package/lib/interfaces/initialExpression.interface.js.map +1 -0
  670. package/lib/interfaces/lookup.interface.d.ts +6 -0
  671. package/lib/interfaces/lookup.interface.js +18 -0
  672. package/lib/interfaces/lookup.interface.js.map +1 -0
  673. package/lib/interfaces/overrideComponent.interface.d.ts +23 -0
  674. package/lib/interfaces/overrideComponent.interface.js +18 -0
  675. package/lib/interfaces/overrideComponent.interface.js.map +1 -0
  676. package/lib/interfaces/page.interface.d.ts +16 -0
  677. package/lib/interfaces/page.interface.js +2 -0
  678. package/lib/interfaces/page.interface.js.map +1 -0
  679. package/lib/interfaces/parameterisedValueSets.interface.d.ts +13 -0
  680. package/lib/interfaces/parameterisedValueSets.interface.js +2 -0
  681. package/lib/interfaces/parameterisedValueSets.interface.js.map +1 -0
  682. package/lib/interfaces/populate.interface.d.ts +47 -0
  683. package/lib/interfaces/populate.interface.js +18 -0
  684. package/lib/interfaces/populate.interface.js.map +1 -0
  685. package/lib/interfaces/questionnaireStore.interface.d.ts +30 -0
  686. package/lib/interfaces/questionnaireStore.interface.js +18 -0
  687. package/lib/interfaces/questionnaireStore.interface.js.map +1 -0
  688. package/lib/interfaces/regex.interface.d.ts +4 -0
  689. package/lib/interfaces/regex.interface.js +18 -0
  690. package/lib/interfaces/regex.interface.js.map +1 -0
  691. package/lib/interfaces/renderProps.interface.d.ts +41 -0
  692. package/lib/interfaces/renderProps.interface.js +18 -0
  693. package/lib/interfaces/renderProps.interface.js.map +1 -0
  694. package/lib/interfaces/repeatGroup.interface.d.ts +9 -0
  695. package/lib/interfaces/repeatGroup.interface.js +18 -0
  696. package/lib/interfaces/repeatGroup.interface.js.map +1 -0
  697. package/lib/interfaces/tab.interface.d.ts +16 -0
  698. package/lib/interfaces/tab.interface.js +18 -0
  699. package/lib/interfaces/tab.interface.js.map +1 -0
  700. package/lib/interfaces/targetConstraint.interface.d.ts +30 -0
  701. package/lib/interfaces/targetConstraint.interface.js +2 -0
  702. package/lib/interfaces/targetConstraint.interface.js.map +1 -0
  703. package/lib/interfaces/valueSet.interface.d.ts +32 -0
  704. package/lib/interfaces/valueSet.interface.js +18 -0
  705. package/lib/interfaces/valueSet.interface.js.map +1 -0
  706. package/lib/interfaces/variables.interface.d.ts +21 -0
  707. package/lib/interfaces/variables.interface.js +18 -0
  708. package/lib/interfaces/variables.interface.js.map +1 -0
  709. package/lib/stores/index.d.ts +10 -0
  710. package/lib/stores/index.js +6 -0
  711. package/lib/stores/index.js.map +1 -0
  712. package/lib/stores/questionnaireResponseStore.d.ts +80 -0
  713. package/lib/stores/questionnaireResponseStore.js +140 -0
  714. package/lib/stores/questionnaireResponseStore.js.map +1 -0
  715. package/lib/stores/questionnaireStore.d.ts +169 -0
  716. package/lib/stores/questionnaireStore.js +313 -0
  717. package/lib/stores/questionnaireStore.js.map +1 -0
  718. package/lib/stores/rendererStylingStore.d.ts +144 -0
  719. package/lib/stores/rendererStylingStore.js +76 -0
  720. package/lib/stores/rendererStylingStore.js.map +1 -0
  721. package/lib/stores/selector.d.ts +10 -0
  722. package/lib/stores/selector.js +11 -0
  723. package/lib/stores/selector.js.map +1 -0
  724. package/lib/stores/smartConfigStore.d.ts +62 -0
  725. package/lib/stores/smartConfigStore.js +51 -0
  726. package/lib/stores/smartConfigStore.js.map +1 -0
  727. package/lib/stores/terminologyServerStore.d.ts +40 -0
  728. package/lib/stores/terminologyServerStore.js +42 -0
  729. package/lib/stores/terminologyServerStore.js.map +1 -0
  730. package/lib/stories/storybookWrappers/InitialiseFormWrapperForStorybook.d.ts +30 -0
  731. package/lib/stories/storybookWrappers/InitialiseFormWrapperForStorybook.js +46 -0
  732. package/lib/stories/storybookWrappers/InitialiseFormWrapperForStorybook.js.map +1 -0
  733. package/lib/stories/storybookWrappers/index.d.ts +2 -0
  734. package/lib/stories/storybookWrappers/index.js +18 -0
  735. package/lib/stories/storybookWrappers/index.js.map +1 -0
  736. package/lib/tests/test-data/initialValueSample.d.ts +2 -0
  737. package/lib/tests/test-data/initialValueSample.js +802 -0
  738. package/lib/tests/test-data/initialValueSample.js.map +1 -0
  739. package/lib/tests/test-data/observationSample.d.ts +6 -0
  740. package/lib/tests/test-data/observationSample.js +716 -0
  741. package/lib/tests/test-data/observationSample.js.map +1 -0
  742. package/lib/tests/test-data/removeIdSample.d.ts +3 -0
  743. package/lib/tests/test-data/removeIdSample.js +99 -0
  744. package/lib/tests/test-data/removeIdSample.js.map +1 -0
  745. package/lib/theme/RendererThemeProvider.d.ts +11 -0
  746. package/lib/theme/RendererThemeProvider.js +18 -0
  747. package/lib/theme/RendererThemeProvider.js.map +1 -0
  748. package/lib/theme/customGlobalStyles.d.ts +1 -0
  749. package/lib/theme/customGlobalStyles.js +45 -0
  750. package/lib/theme/customGlobalStyles.js.map +1 -0
  751. package/lib/theme/index.d.ts +2 -0
  752. package/lib/theme/index.js +3 -0
  753. package/lib/theme/index.js.map +1 -0
  754. package/lib/theme/overrides/Accordion.d.ts +14 -0
  755. package/lib/theme/overrides/Accordion.js +34 -0
  756. package/lib/theme/overrides/Accordion.js.map +1 -0
  757. package/lib/theme/overrides/Autocomplete.d.ts +10 -0
  758. package/lib/theme/overrides/Autocomplete.js +28 -0
  759. package/lib/theme/overrides/Autocomplete.js.map +1 -0
  760. package/lib/theme/overrides/Button.d.ts +33 -0
  761. package/lib/theme/overrides/Button.js +52 -0
  762. package/lib/theme/overrides/Button.js.map +1 -0
  763. package/lib/theme/overrides/Card.d.ts +35 -0
  764. package/lib/theme/overrides/Card.js +51 -0
  765. package/lib/theme/overrides/Card.js.map +1 -0
  766. package/lib/theme/overrides/Input.d.ts +75 -0
  767. package/lib/theme/overrides/Input.js +92 -0
  768. package/lib/theme/overrides/Input.js.map +1 -0
  769. package/lib/theme/overrides/Overrides.d.ts +3 -0
  770. package/lib/theme/overrides/Overrides.js +29 -0
  771. package/lib/theme/overrides/Overrides.js.map +1 -0
  772. package/lib/theme/overrides/Paper.d.ts +12 -0
  773. package/lib/theme/overrides/Paper.js +31 -0
  774. package/lib/theme/overrides/Paper.js.map +1 -0
  775. package/lib/theme/overrides/SpeedDial.d.ts +16 -0
  776. package/lib/theme/overrides/SpeedDial.js +34 -0
  777. package/lib/theme/overrides/SpeedDial.js.map +1 -0
  778. package/lib/theme/overrides/Table.d.ts +19 -0
  779. package/lib/theme/overrides/Table.js +39 -0
  780. package/lib/theme/overrides/Table.js.map +1 -0
  781. package/lib/theme/themeOptions.d.ts +2 -0
  782. package/lib/theme/themeOptions.js +85 -0
  783. package/lib/theme/themeOptions.js.map +1 -0
  784. package/lib/theme/typography.d.ts +20 -0
  785. package/lib/theme/typography.js +97 -0
  786. package/lib/theme/typography.js.map +1 -0
  787. package/lib/utils/calculatedExpression.d.ts +35 -0
  788. package/lib/utils/calculatedExpression.js +311 -0
  789. package/lib/utils/calculatedExpression.js.map +1 -0
  790. package/lib/utils/choice.d.ts +44 -0
  791. package/lib/utils/choice.js +166 -0
  792. package/lib/utils/choice.js.map +1 -0
  793. package/lib/utils/computedUpdates.d.ts +3 -0
  794. package/lib/utils/computedUpdates.js +85 -0
  795. package/lib/utils/computedUpdates.js.map +1 -0
  796. package/lib/utils/dayjsExtend.d.ts +1 -0
  797. package/lib/utils/dayjsExtend.js +22 -0
  798. package/lib/utils/dayjsExtend.js.map +1 -0
  799. package/lib/utils/debounce.d.ts +2 -0
  800. package/lib/utils/debounce.js +19 -0
  801. package/lib/utils/debounce.js.map +1 -0
  802. package/lib/utils/emptyResource.d.ts +3 -0
  803. package/lib/utils/emptyResource.js +25 -0
  804. package/lib/utils/emptyResource.js.map +1 -0
  805. package/lib/utils/enableWhen.d.ts +54 -0
  806. package/lib/utils/enableWhen.js +321 -0
  807. package/lib/utils/enableWhen.js.map +1 -0
  808. package/lib/utils/enableWhenExpression.d.ts +42 -0
  809. package/lib/utils/enableWhenExpression.js +209 -0
  810. package/lib/utils/enableWhenExpression.js.map +1 -0
  811. package/lib/utils/extractObservation.d.ts +15 -0
  812. package/lib/utils/extractObservation.js +182 -0
  813. package/lib/utils/extractObservation.js.map +1 -0
  814. package/lib/utils/fhirpath.d.ts +43 -0
  815. package/lib/utils/fhirpath.js +202 -0
  816. package/lib/utils/fhirpath.js.map +1 -0
  817. package/lib/utils/fileUtils.d.ts +3 -0
  818. package/lib/utils/fileUtils.js +64 -0
  819. package/lib/utils/fileUtils.js.map +1 -0
  820. package/lib/utils/formChanges.d.ts +18 -0
  821. package/lib/utils/formChanges.js +91 -0
  822. package/lib/utils/formChanges.js.map +1 -0
  823. package/lib/utils/genericRecursive.d.ts +20 -0
  824. package/lib/utils/genericRecursive.js +90 -0
  825. package/lib/utils/genericRecursive.js.map +1 -0
  826. package/lib/utils/getExpressionsFromItem.d.ts +27 -0
  827. package/lib/utils/getExpressionsFromItem.js +121 -0
  828. package/lib/utils/getExpressionsFromItem.js.map +1 -0
  829. package/lib/utils/groupTable.d.ts +3 -0
  830. package/lib/utils/groupTable.js +28 -0
  831. package/lib/utils/groupTable.js.map +1 -0
  832. package/lib/utils/headingVariant.d.ts +8 -0
  833. package/lib/utils/headingVariant.js +36 -0
  834. package/lib/utils/headingVariant.js.map +1 -0
  835. package/lib/utils/index.d.ts +12 -0
  836. package/lib/utils/index.js +28 -0
  837. package/lib/utils/index.js.map +1 -0
  838. package/lib/utils/initialise.d.ts +43 -0
  839. package/lib/utils/initialise.js +310 -0
  840. package/lib/utils/initialise.js.map +1 -0
  841. package/lib/utils/itemControl.d.ts +142 -0
  842. package/lib/utils/itemControl.js +470 -0
  843. package/lib/utils/itemControl.js.map +1 -0
  844. package/lib/utils/manageForm.d.ts +63 -0
  845. package/lib/utils/manageForm.js +132 -0
  846. package/lib/utils/manageForm.js.map +1 -0
  847. package/lib/utils/mapItem.d.ts +20 -0
  848. package/lib/utils/mapItem.js +82 -0
  849. package/lib/utils/mapItem.js.map +1 -0
  850. package/lib/utils/misc.d.ts +9 -0
  851. package/lib/utils/misc.js +216 -0
  852. package/lib/utils/misc.js.map +1 -0
  853. package/lib/utils/openChoice.d.ts +27 -0
  854. package/lib/utils/openChoice.js +140 -0
  855. package/lib/utils/openChoice.js.map +1 -0
  856. package/lib/utils/page.d.ts +55 -0
  857. package/lib/utils/page.js +117 -0
  858. package/lib/utils/page.js.map +1 -0
  859. package/lib/utils/parameterisedValueSets.d.ts +27 -0
  860. package/lib/utils/parameterisedValueSets.js +194 -0
  861. package/lib/utils/parameterisedValueSets.js.map +1 -0
  862. package/lib/utils/parseInputs.d.ts +5 -0
  863. package/lib/utils/parseInputs.js +59 -0
  864. package/lib/utils/parseInputs.js.map +1 -0
  865. package/lib/utils/populateContexts.d.ts +3 -0
  866. package/lib/utils/populateContexts.js +40 -0
  867. package/lib/utils/populateContexts.js.map +1 -0
  868. package/lib/utils/qItem.d.ts +24 -0
  869. package/lib/utils/qItem.js +144 -0
  870. package/lib/utils/qItem.js.map +1 -0
  871. package/lib/utils/qrItem.d.ts +29 -0
  872. package/lib/utils/qrItem.js +186 -0
  873. package/lib/utils/qrItem.js.map +1 -0
  874. package/lib/utils/quantity.d.ts +4 -0
  875. package/lib/utils/quantity.js +51 -0
  876. package/lib/utils/quantity.js.map +1 -0
  877. package/lib/utils/questionnaireResponseStoreUtils/updatableResponseItems.d.ts +2 -0
  878. package/lib/utils/questionnaireResponseStoreUtils/updatableResponseItems.js +64 -0
  879. package/lib/utils/questionnaireResponseStoreUtils/updatableResponseItems.js.map +1 -0
  880. package/lib/utils/questionnaireStoreUtils/addAdditionalVariables.d.ts +2 -0
  881. package/lib/utils/questionnaireStoreUtils/addAdditionalVariables.js +43 -0
  882. package/lib/utils/questionnaireStoreUtils/addAdditionalVariables.js.map +1 -0
  883. package/lib/utils/questionnaireStoreUtils/addDisplayToCodings.d.ts +15 -0
  884. package/lib/utils/questionnaireStoreUtils/addDisplayToCodings.js +160 -0
  885. package/lib/utils/questionnaireStoreUtils/addDisplayToCodings.js.map +1 -0
  886. package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.d.ts +3 -0
  887. package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js +109 -0
  888. package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js.map +1 -0
  889. package/lib/utils/questionnaireStoreUtils/extractContainedValueSets.d.ts +13 -0
  890. package/lib/utils/questionnaireStoreUtils/extractContainedValueSets.js +74 -0
  891. package/lib/utils/questionnaireStoreUtils/extractContainedValueSets.js.map +1 -0
  892. package/lib/utils/questionnaireStoreUtils/extractLaunchContext.d.ts +3 -0
  893. package/lib/utils/questionnaireStoreUtils/extractLaunchContext.js +18 -0
  894. package/lib/utils/questionnaireStoreUtils/extractLaunchContext.js.map +1 -0
  895. package/lib/utils/questionnaireStoreUtils/extractOtherExtensions.d.ts +37 -0
  896. package/lib/utils/questionnaireStoreUtils/extractOtherExtensions.js +335 -0
  897. package/lib/utils/questionnaireStoreUtils/extractOtherExtensions.js.map +1 -0
  898. package/lib/utils/questionnaireStoreUtils/extractPages.d.ts +3 -0
  899. package/lib/utils/questionnaireStoreUtils/extractPages.js +25 -0
  900. package/lib/utils/questionnaireStoreUtils/extractPages.js.map +1 -0
  901. package/lib/utils/questionnaireStoreUtils/extractTabs.d.ts +3 -0
  902. package/lib/utils/questionnaireStoreUtils/extractTabs.js +31 -0
  903. package/lib/utils/questionnaireStoreUtils/extractTabs.js.map +1 -0
  904. package/lib/utils/questionnaireStoreUtils/extractTargetConstraint.d.ts +4 -0
  905. package/lib/utils/questionnaireStoreUtils/extractTargetConstraint.js +39 -0
  906. package/lib/utils/questionnaireStoreUtils/extractTargetConstraint.js.map +1 -0
  907. package/lib/utils/questionnaireStoreUtils/extractVariables.d.ts +15 -0
  908. package/lib/utils/questionnaireStoreUtils/extractVariables.js +63 -0
  909. package/lib/utils/questionnaireStoreUtils/extractVariables.js.map +1 -0
  910. package/lib/utils/questionnaireStoreUtils/insertAnswerOptions.d.ts +7 -0
  911. package/lib/utils/questionnaireStoreUtils/insertAnswerOptions.js +44 -0
  912. package/lib/utils/questionnaireStoreUtils/insertAnswerOptions.js.map +1 -0
  913. package/lib/utils/questionnaireStoreUtils/resolveValueSets.d.ts +7 -0
  914. package/lib/utils/questionnaireStoreUtils/resolveValueSets.js +61 -0
  915. package/lib/utils/questionnaireStoreUtils/resolveValueSets.js.map +1 -0
  916. package/lib/utils/removeEmptyAnswers.d.ts +12 -0
  917. package/lib/utils/removeEmptyAnswers.js +101 -0
  918. package/lib/utils/removeEmptyAnswers.js.map +1 -0
  919. package/lib/utils/removeRepeatId.d.ts +2 -0
  920. package/lib/utils/removeRepeatId.js +85 -0
  921. package/lib/utils/removeRepeatId.js.map +1 -0
  922. package/lib/utils/repeatId.d.ts +2 -0
  923. package/lib/utils/repeatId.js +25 -0
  924. package/lib/utils/repeatId.js.map +1 -0
  925. package/lib/utils/repopulateIntoResponse.d.ts +7 -0
  926. package/lib/utils/repopulateIntoResponse.js +141 -0
  927. package/lib/utils/repopulateIntoResponse.js.map +1 -0
  928. package/lib/utils/repopulateItems.d.ts +40 -0
  929. package/lib/utils/repopulateItems.js +356 -0
  930. package/lib/utils/repopulateItems.js.map +1 -0
  931. package/lib/utils/slider.d.ts +28 -0
  932. package/lib/utils/slider.js +89 -0
  933. package/lib/utils/slider.js.map +1 -0
  934. package/lib/utils/tabs.d.ts +58 -0
  935. package/lib/utils/tabs.js +156 -0
  936. package/lib/utils/tabs.js.map +1 -0
  937. package/lib/utils/targetConstraint.d.ts +23 -0
  938. package/lib/utils/targetConstraint.js +179 -0
  939. package/lib/utils/targetConstraint.js.map +1 -0
  940. package/lib/utils/validate.d.ts +73 -0
  941. package/lib/utils/validate.js +742 -0
  942. package/lib/utils/validate.js.map +1 -0
  943. package/lib/utils/valueSet.d.ts +29 -0
  944. package/lib/utils/valueSet.js +171 -0
  945. package/lib/utils/valueSet.js.map +1 -0
  946. package/package.json +1 -1
  947. package/src/components/FormComponents/QuantityItem/QuantityUnitField.tsx +1 -10
  948. package/dist/index.cjs +0 -21025
  949. package/dist/index.cjs.map +0 -1
  950. package/dist/index.d.cts +0 -1283
  951. package/dist/index.d.ts +0 -1283
  952. package/dist/index.js +0 -20956
  953. package/dist/index.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../node_modules/fhir-extension-helpers/src/extensions.ts","../../../node_modules/fhir-sdc-helpers/src/structureddatacapture-r4.ts","../../../node_modules/prop-types/node_modules/react-is/cjs/react-is.production.min.js","../../../node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js","../../../node_modules/prop-types/node_modules/react-is/index.js","../../../node_modules/object-assign/index.js","../../../node_modules/prop-types/lib/ReactPropTypesSecret.js","../../../node_modules/prop-types/lib/has.js","../../../node_modules/prop-types/checkPropTypes.js","../../../node_modules/prop-types/factoryWithTypeCheckers.js","../../../node_modules/prop-types/factoryWithThrowingShims.js","../../../node_modules/prop-types/index.js","../src/index.ts","../src/hooks/useInitialiseForm.ts","../src/stores/questionnaireStore.ts","../src/utils/enableWhen.ts","../src/utils/fhirpath.ts","../src/utils/enableWhenExpression.ts","../src/utils/calculatedExpression.ts","../src/utils/emptyResource.ts","../src/utils/itemControl.ts","../src/utils/valueSet.ts","../src/utils/choice.ts","../src/utils/openChoice.ts","../src/utils/qItem.ts","../src/utils/mapItem.ts","../src/utils/qrItem.ts","../src/utils/genericRecursive.ts","../src/utils/targetConstraint.ts","../src/utils/parameterisedValueSets.ts","../src/utils/populateContexts.ts","../src/utils/questionnaireStoreUtils/extractLaunchContext.ts","../src/utils/questionnaireStoreUtils/extractVariables.ts","../src/utils/tabs.ts","../src/utils/questionnaireStoreUtils/extractTabs.ts","../src/utils/page.ts","../src/utils/questionnaireStoreUtils/extractPages.ts","../src/utils/questionnaireStoreUtils/extractContainedValueSets.ts","../src/utils/misc.ts","../src/utils/getExpressionsFromItem.ts","../src/utils/questionnaireStoreUtils/extractOtherExtensions.ts","../src/utils/questionnaireStoreUtils/resolveValueSets.ts","../src/utils/questionnaireStoreUtils/addAdditionalVariables.ts","../src/utils/questionnaireStoreUtils/addDisplayToCodings.ts","../src/utils/questionnaireStoreUtils/extractTargetConstraint.ts","../src/utils/questionnaireStoreUtils/createQuestionaireModel.ts","../src/utils/questionnaireResponseStoreUtils/updatableResponseItems.ts","../src/utils/initialise.ts","../src/stores/terminologyServerStore.ts","../src/stores/selector.ts","../src/globals.ts","../src/stores/questionnaireResponseStore.ts","../src/utils/validate.ts","../src/utils/parseInputs.ts","../src/utils/extractObservation.ts","../src/utils/questionnaireStoreUtils/insertAnswerOptions.ts","../src/stores/smartConfigStore.ts","../src/stores/rendererStylingStore.ts","../src/utils/removeEmptyAnswers.ts","../src/api/smartClient.ts","../src/utils/removeRepeatId.ts","../src/utils/manageForm.ts","../src/utils/repopulateItems.ts","../src/utils/repopulateIntoResponse.ts","../src/components/Renderer/SmartFormsRenderer.tsx","../src/hooks/useRendererQueryClient.ts","../src/components/Renderer/BaseRenderer.tsx","../src/components/Renderer/FormBodyTabbed.tsx","../src/components/FormComponents/GroupItem/GroupItem.tsx","../src/hooks/useHidden.ts","../src/components/FormComponents/GroupItem/GroupItemView.tsx","../src/components/Box.styles.ts","../src/components/FormComponents/GroupItem/GroupHeading.tsx","../src/components/FormComponents/ItemParts/ContextDisplayItem.tsx","../src/components/FormComponents/ItemParts/ItemTextSwitcher.tsx","../src/hooks/useParseXhtml.tsx","../src/hooks/useDisplayCqfAndCalculatedExpression.ts","../src/hooks/useRenderingExtensions.ts","../src/components/FormComponents/ItemParts/RequiredAsterisk.tsx","../src/components/FormComponents/ItemParts/FlyoverHoverCard.tsx","../src/components/FormComponents/ItemParts/FlyoverItem.tsx","../src/utils/headingVariant.ts","../src/components/FormComponents/GroupItem/GroupItem.styles.ts","../src/components/FormComponents/GroupItem/TabButtonsWrapper.tsx","../src/components/FormComponents/GroupItem/NextTabButton.tsx","../src/components/Iconify/Iconify.tsx","../src/components/FormComponents/GroupItem/PreviousTabButton.tsx","../src/hooks/useNextAndPreviousVisibleTabs.ts","../src/hooks/useFocusTabHeading.ts","../src/components/FormComponents/Tables/GroupTable.tsx","../src/hooks/useReadOnly.ts","../src/components/FormComponents/Tables/GroupTableView.tsx","../src/components/FormComponents/Tables/Table.styles.tsx","../src/components/FormComponents/Tables/AddRowButton.tsx","../src/components/FormComponents/Tables/GroupTableRow.tsx","../src/components/FormComponents/Tables/SelectRowButton.tsx","../src/components/Checkbox.styles.ts","../src/components/FormComponents/SingleItem/SingleItem.tsx","../src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx","../src/hooks/useCodingCalculatedExpression.ts","../src/components/FormComponents/ChoiceItems/ChoiceRadioSingle.tsx","../src/components/Radio.styles.tsx","../src/components/FormComponents/ItemParts/RadioOptionList.tsx","../src/components/FormComponents/Item.styles.ts","../src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.tsx","../src/components/FormComponents/ItemParts/FadingCheckIcon.tsx","../src/components/FormComponents/ItemParts/ClearInputButton.tsx","../src/components/FormComponents/DisplayItem/DisplayInstructions.tsx","../src/components/FormComponents/DisplayItem/DisplayInstructions.styles.ts","../src/components/FormComponents/ItemParts/ItemFieldGrid.tsx","../src/components/FormComponents/ItemParts/ItemLabel.tsx","../src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.tsx","../src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.tsx","../src/components/FormComponents/Textfield.styles.ts","../src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.tsx","../src/components/FormComponents/ItemParts/DisplayUnitText.tsx","../src/hooks/useValidationFeedback.ts","../src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx","../src/components/FormComponents/ItemParts/CheckboxSingle.tsx","../src/components/FormComponents/ChoiceItems/CheckboxOptionList.tsx","../src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.tsx","../src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.tsx","../src/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.tsx","../src/hooks/useDebounce.ts","../src/hooks/useTerminologyServerQuery.ts","../src/utils/debounce.ts","../src/components/FormComponents/ChoiceItems/ChoiceAutocompleteField.tsx","../src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.tsx","../src/hooks/useValueSetCodings.ts","../src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.tsx","../src/components/Alert.styles.ts","../src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx","../src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx","../src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx","../src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.tsx","../src/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx","../src/hooks/useOpenLabel.ts","../src/components/FormComponents/ItemParts/CheckboxSingleWithOpenLabel.tsx","../src/components/FormComponents/ItemParts/OpenLabelField.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.tsx","../src/components/FormComponents/ItemParts/RadioButtonWithOpenLabel.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetItem.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.tsx","../src/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.tsx","../src/components/FormComponents/SingleItem/SingleItemSwitcher.tsx","../src/components/FormComponents/StringItem/StringItem.tsx","../src/components/FormComponents/StringItem/StringField.tsx","../src/hooks/useStringCalculatedExpression.ts","../src/components/FormComponents/BooleanItem/BooleanField.tsx","../src/components/FormComponents/BooleanItem/BooleanItem.tsx","../src/hooks/useBooleanCalculatedExpression.ts","../src/components/FormComponents/TimeItem/TimeField.tsx","../src/components/FormComponents/TimeItem/TimeItem.tsx","../src/components/FormComponents/TextItem/TextItem.tsx","../src/components/FormComponents/TextItem/TextField.tsx","../src/components/FormComponents/TextItem/MuiTextField.ts","../src/components/FormComponents/DisplayItem/DisplayItem.tsx","../src/components/FormComponents/DecimalItem/DecimalItem.tsx","../src/components/FormComponents/DecimalItem/DecimalField.tsx","../src/hooks/useDecimalCalculatedExpression.ts","../src/components/FormComponents/UrlItem/UrlItem.tsx","../src/components/FormComponents/UrlItem/UrlField.tsx","../src/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.tsx","../src/components/FormComponents/DateTimeItems/utils/parseDate.ts","../src/hooks/useDateValidation.tsx","../src/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateField.tsx","../src/components/FormComponents/DateTimeItems/CustomDateItem/DatePicker.tsx","../src/components/FormComponents/DateTimeItems/CustomDateItem/MuiDatePicker.ts","../src/components/FormComponents/DateTimeItems/CustomDateItem/DatePickerButton.tsx","../src/utils/slider.ts","../src/components/FormComponents/SliderItem/SliderField.tsx","../src/components/FormComponents/SliderItem/SliderLabels.tsx","../src/components/FormComponents/SliderItem/Slider.styles.ts","../src/components/FormComponents/SliderItem/SliderDisplayValue.tsx","../src/hooks/useSliderExtensions.ts","../src/components/FormComponents/SliderItem/SliderItem.tsx","../src/components/FormComponents/IntegerItem/IntegerItem.tsx","../src/components/FormComponents/IntegerItem/IntegerField.tsx","../src/hooks/useIntegerCalculatedExpression.ts","../src/components/FormComponents/AttachmentItem/AttachmentItem.tsx","../src/components/FormComponents/AttachmentItem/AttachmentFileCollector.tsx","../src/components/FormComponents/AttachmentItem/AttachmentFileDropBox.tsx","../src/hooks/UseFileDrop.ts","../src/components/FormComponents/AttachmentItem/AttachmentFileDropBox.styles.ts","../src/utils/fileUtils.ts","../src/components/FormComponents/AttachmentItem/AttachmentField.tsx","../src/components/FormComponents/AttachmentItem/AttachmentUrlField.tsx","../src/hooks/useAttachmentUrlValidation.ts","../src/components/FormComponents/AttachmentItem/AttachmentFieldWrapper.tsx","../src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.tsx","../src/components/FormComponents/DateTimeItems/utils/parseTime.ts","../src/hooks/useTimeValidation.tsx","../src/hooks/useDateTimeNonEmpty.ts","../src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomTimeField.tsx","../src/components/FormComponents/DateTimeItems/CustomDateTimeItem/DateTimeField.tsx","../src/components/FormComponents/QuantityItem/QuantityItem.tsx","../src/components/FormComponents/QuantityItem/QuantityField.tsx","../src/components/FormComponents/QuantityItem/QuantityUnitField.tsx","../src/utils/quantity.ts","../src/components/FormComponents/QuantityItem/QuantityComparatorField.tsx","../src/hooks/useQuantityCalculatedExpression.ts","../src/components/FormComponents/SingleItem/SingleNestedItems.tsx","../src/components/FormComponents/SingleItem/SingleItemView.tsx","../src/components/FormComponents/SingleItem/StopPropagationWrapper.tsx","../src/components/FormComponents/SingleItem/NestedSingleItemAccordion.styles.ts","../src/components/FormComponents/Tables/GroupTableRowCells.tsx","../src/components/FormComponents/Tables/RemoveRowButton.tsx","../src/components/FormComponents/Tables/GroupTableBody.tsx","../src/utils/groupTable.ts","../src/components/FormComponents/GroupItem/GroupAccordion.styles.ts","../src/hooks/useGroupTableRows.ts","../src/utils/repeatId.ts","../src/hooks/useInitialiseGroupTableRows.ts","../src/components/FormComponents/RepeatGroup/RepeatGroup.tsx","../src/hooks/useInitialiseRepeatGroups.ts","../src/components/FormComponents/RepeatGroup/RepeatGroupView.tsx","../../../node_modules/@babel/runtime/helpers/esm/extends.js","../../../node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js","../../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","../../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","../../../node_modules/react-transition-group/esm/TransitionGroupContext.js","../../../node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js","../../../node_modules/react-transition-group/esm/TransitionGroup.js","../../../node_modules/react-transition-group/esm/utils/ChildMapping.js","../src/components/FormComponents/RepeatItem/RepeatItem.styles.tsx","../src/components/FormComponents/RepeatGroup/RepeatGroupItem.tsx","../src/components/FormComponents/RepeatGroup/DeleteItemButton.tsx","../src/components/FormComponents/RepeatGroup/AddItemButton.tsx","../src/components/FormComponents/RepeatItem/AddItemButton.tsx","../src/components/FormComponents/RepeatItem/RepeatField.tsx","../src/components/FormComponents/RepeatItem/RemoveItemButton.tsx","../src/components/FormComponents/RepeatItem/RepeatItem.tsx","../src/hooks/useInitialiseRepeatAnswers.ts","../src/components/FormComponents/GridGroup/GridGroup.tsx","../src/components/FormComponents/GridGroup/GridTable.tsx","../src/components/FormComponents/GridGroup/GridRow.tsx","../src/components/FormComponents/GroupItem/GroupItemSwitcher.tsx","../src/components/FormComponents/GroupItem/PageButtonWrapper.tsx","../src/components/FormComponents/Button.styles.ts","../src/components/FormComponents/GroupItem/NextPageButton.tsx","../src/components/FormComponents/GroupItem/PreviousPageButton.tsx","../src/hooks/useNextAndPreviousVisiblePages.ts","../src/components/Tabs/FormBodyTabListWrapper.tsx","../src/components/Lists.styles.ts","../src/components/Tabs/FormBodyTabList.tsx","../src/components/Tabs/FormBodySingleTab.tsx","../src/components/Tabs/ShowCompletedTabsSection.tsx","../src/hooks/useContextDisplayItems.ts","../src/components/Renderer/FormBodyCollapsible.tsx","../src/components/Renderer/FormBodySingleCollapsible.tsx","../src/components/Renderer/FormBodySingleCollapsibleWrapper.tsx","../src/hooks/useResponsive.ts","../src/components/Renderer/FormTopLevelItem.tsx","../src/components/Renderer/FormBodyPageContainer.tsx","../src/components/Renderer/FormBodyPaginated.tsx","../src/utils/computedUpdates.ts","../src/theme/RendererThemeProvider.tsx","../src/theme/customGlobalStyles.tsx","../src/theme/overrides/Card.ts","../src/theme/overrides/Paper.ts","../src/theme/overrides/Input.ts","../src/theme/overrides/Table.ts","../src/theme/overrides/Button.ts","../src/theme/overrides/Autocomplete.ts","../src/theme/overrides/Accordion.ts","../src/theme/overrides/SpeedDial.ts","../src/theme/overrides/Overrides.ts","../src/theme/themeOptions.ts","../src/theme/typography.ts","../src/hooks/useBuildForm.ts","../src/stories/storybookWrappers/InitialiseFormWrapperForStorybook.tsx"],"sourcesContent":[null,null,"/** @license React v16.13.1\n * react-is.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';var b=\"function\"===typeof Symbol&&Symbol.for,c=b?Symbol.for(\"react.element\"):60103,d=b?Symbol.for(\"react.portal\"):60106,e=b?Symbol.for(\"react.fragment\"):60107,f=b?Symbol.for(\"react.strict_mode\"):60108,g=b?Symbol.for(\"react.profiler\"):60114,h=b?Symbol.for(\"react.provider\"):60109,k=b?Symbol.for(\"react.context\"):60110,l=b?Symbol.for(\"react.async_mode\"):60111,m=b?Symbol.for(\"react.concurrent_mode\"):60111,n=b?Symbol.for(\"react.forward_ref\"):60112,p=b?Symbol.for(\"react.suspense\"):60113,q=b?\nSymbol.for(\"react.suspense_list\"):60120,r=b?Symbol.for(\"react.memo\"):60115,t=b?Symbol.for(\"react.lazy\"):60116,v=b?Symbol.for(\"react.block\"):60121,w=b?Symbol.for(\"react.fundamental\"):60117,x=b?Symbol.for(\"react.responder\"):60118,y=b?Symbol.for(\"react.scope\"):60119;\nfunction z(a){if(\"object\"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;\nexports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isAsyncMode=function(a){return A(a)||z(a)===l};exports.isConcurrentMode=A;exports.isContextConsumer=function(a){return z(a)===k};exports.isContextProvider=function(a){return z(a)===h};exports.isElement=function(a){return\"object\"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return z(a)===n};exports.isFragment=function(a){return z(a)===e};exports.isLazy=function(a){return z(a)===t};\nexports.isMemo=function(a){return z(a)===r};exports.isPortal=function(a){return z(a)===d};exports.isProfiler=function(a){return z(a)===g};exports.isStrictMode=function(a){return z(a)===f};exports.isSuspense=function(a){return z(a)===p};\nexports.isValidElementType=function(a){return\"string\"===typeof a||\"function\"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||\"object\"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};exports.typeOf=z;\n","/** @license React v16.13.1\n * react-is.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\n\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n'use strict';\n\n// The Symbol used to tag the ReactElement-like types. If there is no native Symbol\n// nor polyfill, then a plain number is used for performance.\nvar hasSymbol = typeof Symbol === 'function' && Symbol.for;\nvar REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;\nvar REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;\nvar REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;\nvar REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;\nvar REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;\nvar REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;\nvar REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary\n// (unstable) APIs that have been removed. Can we remove the symbols?\n\nvar REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;\nvar REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;\nvar REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;\nvar REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;\nvar REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;\nvar REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;\nvar REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;\nvar REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;\nvar REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;\nvar REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;\nvar REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;\n\nfunction isValidElementType(type) {\n return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.\n type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);\n}\n\nfunction typeOf(object) {\n if (typeof object === 'object' && object !== null) {\n var $$typeof = object.$$typeof;\n\n switch ($$typeof) {\n case REACT_ELEMENT_TYPE:\n var type = object.type;\n\n switch (type) {\n case REACT_ASYNC_MODE_TYPE:\n case REACT_CONCURRENT_MODE_TYPE:\n case REACT_FRAGMENT_TYPE:\n case REACT_PROFILER_TYPE:\n case REACT_STRICT_MODE_TYPE:\n case REACT_SUSPENSE_TYPE:\n return type;\n\n default:\n var $$typeofType = type && type.$$typeof;\n\n switch ($$typeofType) {\n case REACT_CONTEXT_TYPE:\n case REACT_FORWARD_REF_TYPE:\n case REACT_LAZY_TYPE:\n case REACT_MEMO_TYPE:\n case REACT_PROVIDER_TYPE:\n return $$typeofType;\n\n default:\n return $$typeof;\n }\n\n }\n\n case REACT_PORTAL_TYPE:\n return $$typeof;\n }\n }\n\n return undefined;\n} // AsyncMode is deprecated along with isAsyncMode\n\nvar AsyncMode = REACT_ASYNC_MODE_TYPE;\nvar ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;\nvar ContextConsumer = REACT_CONTEXT_TYPE;\nvar ContextProvider = REACT_PROVIDER_TYPE;\nvar Element = REACT_ELEMENT_TYPE;\nvar ForwardRef = REACT_FORWARD_REF_TYPE;\nvar Fragment = REACT_FRAGMENT_TYPE;\nvar Lazy = REACT_LAZY_TYPE;\nvar Memo = REACT_MEMO_TYPE;\nvar Portal = REACT_PORTAL_TYPE;\nvar Profiler = REACT_PROFILER_TYPE;\nvar StrictMode = REACT_STRICT_MODE_TYPE;\nvar Suspense = REACT_SUSPENSE_TYPE;\nvar hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated\n\nfunction isAsyncMode(object) {\n {\n if (!hasWarnedAboutDeprecatedIsAsyncMode) {\n hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint\n\n console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');\n }\n }\n\n return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;\n}\nfunction isConcurrentMode(object) {\n return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;\n}\nfunction isContextConsumer(object) {\n return typeOf(object) === REACT_CONTEXT_TYPE;\n}\nfunction isContextProvider(object) {\n return typeOf(object) === REACT_PROVIDER_TYPE;\n}\nfunction isElement(object) {\n return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;\n}\nfunction isForwardRef(object) {\n return typeOf(object) === REACT_FORWARD_REF_TYPE;\n}\nfunction isFragment(object) {\n return typeOf(object) === REACT_FRAGMENT_TYPE;\n}\nfunction isLazy(object) {\n return typeOf(object) === REACT_LAZY_TYPE;\n}\nfunction isMemo(object) {\n return typeOf(object) === REACT_MEMO_TYPE;\n}\nfunction isPortal(object) {\n return typeOf(object) === REACT_PORTAL_TYPE;\n}\nfunction isProfiler(object) {\n return typeOf(object) === REACT_PROFILER_TYPE;\n}\nfunction isStrictMode(object) {\n return typeOf(object) === REACT_STRICT_MODE_TYPE;\n}\nfunction isSuspense(object) {\n return typeOf(object) === REACT_SUSPENSE_TYPE;\n}\n\nexports.AsyncMode = AsyncMode;\nexports.ConcurrentMode = ConcurrentMode;\nexports.ContextConsumer = ContextConsumer;\nexports.ContextProvider = ContextProvider;\nexports.Element = Element;\nexports.ForwardRef = ForwardRef;\nexports.Fragment = Fragment;\nexports.Lazy = Lazy;\nexports.Memo = Memo;\nexports.Portal = Portal;\nexports.Profiler = Profiler;\nexports.StrictMode = StrictMode;\nexports.Suspense = Suspense;\nexports.isAsyncMode = isAsyncMode;\nexports.isConcurrentMode = isConcurrentMode;\nexports.isContextConsumer = isContextConsumer;\nexports.isContextProvider = isContextProvider;\nexports.isElement = isElement;\nexports.isForwardRef = isForwardRef;\nexports.isFragment = isFragment;\nexports.isLazy = isLazy;\nexports.isMemo = isMemo;\nexports.isPortal = isPortal;\nexports.isProfiler = isProfiler;\nexports.isStrictMode = isStrictMode;\nexports.isSuspense = isSuspense;\nexports.isValidElementType = isValidElementType;\nexports.typeOf = typeOf;\n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-is.production.min.js');\n} else {\n module.exports = require('./cjs/react-is.development.js');\n}\n","/*\nobject-assign\n(c) Sindre Sorhus\n@license MIT\n*/\n\n'use strict';\n/* eslint-disable no-unused-vars */\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nfunction toObject(val) {\n\tif (val === null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with null or undefined');\n\t}\n\n\treturn Object(val);\n}\n\nfunction shouldUseNative() {\n\ttry {\n\t\tif (!Object.assign) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Detect buggy property enumeration order in older V8 versions.\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=4118\n\t\tvar test1 = new String('abc'); // eslint-disable-line no-new-wrappers\n\t\ttest1[5] = 'de';\n\t\tif (Object.getOwnPropertyNames(test1)[0] === '5') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test2 = {};\n\t\tfor (var i = 0; i < 10; i++) {\n\t\t\ttest2['_' + String.fromCharCode(i)] = i;\n\t\t}\n\t\tvar order2 = Object.getOwnPropertyNames(test2).map(function (n) {\n\t\t\treturn test2[n];\n\t\t});\n\t\tif (order2.join('') !== '0123456789') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test3 = {};\n\t\t'abcdefghijklmnopqrst'.split('').forEach(function (letter) {\n\t\t\ttest3[letter] = letter;\n\t\t});\n\t\tif (Object.keys(Object.assign({}, test3)).join('') !==\n\t\t\t\t'abcdefghijklmnopqrst') {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (err) {\n\t\t// We don't expect any of the above to throw, but better to be safe.\n\t\treturn false;\n\t}\n}\n\nmodule.exports = shouldUseNative() ? Object.assign : function (target, source) {\n\tvar from;\n\tvar to = toObject(target);\n\tvar symbols;\n\n\tfor (var s = 1; s < arguments.length; s++) {\n\t\tfrom = Object(arguments[s]);\n\n\t\tfor (var key in from) {\n\t\t\tif (hasOwnProperty.call(from, key)) {\n\t\t\t\tto[key] = from[key];\n\t\t\t}\n\t\t}\n\n\t\tif (getOwnPropertySymbols) {\n\t\t\tsymbols = getOwnPropertySymbols(from);\n\t\t\tfor (var i = 0; i < symbols.length; i++) {\n\t\t\t\tif (propIsEnumerable.call(from, symbols[i])) {\n\t\t\t\t\tto[symbols[i]] = from[symbols[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';\n\nmodule.exports = ReactPropTypesSecret;\n","module.exports = Function.call.bind(Object.prototype.hasOwnProperty);\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar printWarning = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\n var loggedTypeFailures = {};\n var has = require('./lib/has');\n\n printWarning = function(text) {\n var message = 'Warning: ' + text;\n if (typeof console !== 'undefined') {\n console.error(message);\n }\n try {\n // --- Welcome to debugging React ---\n // This error was thrown as a convenience so that you can use this stack\n // to find the callsite that caused this warning to fire.\n throw new Error(message);\n } catch (x) { /**/ }\n };\n}\n\n/**\n * Assert that the values match with the type specs.\n * Error messages are memorized and will only be shown once.\n *\n * @param {object} typeSpecs Map of name to a ReactPropType\n * @param {object} values Runtime values that need to be type-checked\n * @param {string} location e.g. \"prop\", \"context\", \"child context\"\n * @param {string} componentName Name of the component for error messages.\n * @param {?Function} getStack Returns the component stack.\n * @private\n */\nfunction checkPropTypes(typeSpecs, values, location, componentName, getStack) {\n if (process.env.NODE_ENV !== 'production') {\n for (var typeSpecName in typeSpecs) {\n if (has(typeSpecs, typeSpecName)) {\n var error;\n // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n var err = Error(\n (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +\n 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +\n 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'\n );\n err.name = 'Invariant Violation';\n throw err;\n }\n error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);\n } catch (ex) {\n error = ex;\n }\n if (error && !(error instanceof Error)) {\n printWarning(\n (componentName || 'React class') + ': type specification of ' +\n location + ' `' + typeSpecName + '` is invalid; the type checker ' +\n 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +\n 'You may have forgotten to pass an argument to the type checker ' +\n 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +\n 'shape all require an argument).'\n );\n }\n if (error instanceof Error && !(error.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error.message] = true;\n\n var stack = getStack ? getStack() : '';\n\n printWarning(\n 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')\n );\n }\n }\n }\n }\n}\n\n/**\n * Resets warning cache when testing.\n *\n * @private\n */\ncheckPropTypes.resetWarningCache = function() {\n if (process.env.NODE_ENV !== 'production') {\n loggedTypeFailures = {};\n }\n}\n\nmodule.exports = checkPropTypes;\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactIs = require('react-is');\nvar assign = require('object-assign');\n\nvar ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\nvar has = require('./lib/has');\nvar checkPropTypes = require('./checkPropTypes');\n\nvar printWarning = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n printWarning = function(text) {\n var message = 'Warning: ' + text;\n if (typeof console !== 'undefined') {\n console.error(message);\n }\n try {\n // --- Welcome to debugging React ---\n // This error was thrown as a convenience so that you can use this stack\n // to find the callsite that caused this warning to fire.\n throw new Error(message);\n } catch (x) {}\n };\n}\n\nfunction emptyFunctionThatReturnsNull() {\n return null;\n}\n\nmodule.exports = function(isValidElement, throwOnDirectAccess) {\n /* global Symbol */\n var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;\n var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.\n\n /**\n * Returns the iterator method function contained on the iterable object.\n *\n * Be sure to invoke the function with the iterable as context:\n *\n * var iteratorFn = getIteratorFn(myIterable);\n * if (iteratorFn) {\n * var iterator = iteratorFn.call(myIterable);\n * ...\n * }\n *\n * @param {?object} maybeIterable\n * @return {?function}\n */\n function getIteratorFn(maybeIterable) {\n var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);\n if (typeof iteratorFn === 'function') {\n return iteratorFn;\n }\n }\n\n /**\n * Collection of methods that allow declaration and validation of props that are\n * supplied to React components. Example usage:\n *\n * var Props = require('ReactPropTypes');\n * var MyArticle = React.createClass({\n * propTypes: {\n * // An optional string prop named \"description\".\n * description: Props.string,\n *\n * // A required enum prop named \"category\".\n * category: Props.oneOf(['News','Photos']).isRequired,\n *\n * // A prop named \"dialog\" that requires an instance of Dialog.\n * dialog: Props.instanceOf(Dialog).isRequired\n * },\n * render: function() { ... }\n * });\n *\n * A more formal specification of how these methods are used:\n *\n * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)\n * decl := ReactPropTypes.{type}(.isRequired)?\n *\n * Each and every declaration produces a function with the same signature. This\n * allows the creation of custom validation functions. For example:\n *\n * var MyLink = React.createClass({\n * propTypes: {\n * // An optional string or URI prop named \"href\".\n * href: function(props, propName, componentName) {\n * var propValue = props[propName];\n * if (propValue != null && typeof propValue !== 'string' &&\n * !(propValue instanceof URI)) {\n * return new Error(\n * 'Expected a string or an URI for ' + propName + ' in ' +\n * componentName\n * );\n * }\n * }\n * },\n * render: function() {...}\n * });\n *\n * @internal\n */\n\n var ANONYMOUS = '<<anonymous>>';\n\n // Important!\n // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.\n var ReactPropTypes = {\n array: createPrimitiveTypeChecker('array'),\n bigint: createPrimitiveTypeChecker('bigint'),\n bool: createPrimitiveTypeChecker('boolean'),\n func: createPrimitiveTypeChecker('function'),\n number: createPrimitiveTypeChecker('number'),\n object: createPrimitiveTypeChecker('object'),\n string: createPrimitiveTypeChecker('string'),\n symbol: createPrimitiveTypeChecker('symbol'),\n\n any: createAnyTypeChecker(),\n arrayOf: createArrayOfTypeChecker,\n element: createElementTypeChecker(),\n elementType: createElementTypeTypeChecker(),\n instanceOf: createInstanceTypeChecker,\n node: createNodeChecker(),\n objectOf: createObjectOfTypeChecker,\n oneOf: createEnumTypeChecker,\n oneOfType: createUnionTypeChecker,\n shape: createShapeTypeChecker,\n exact: createStrictShapeTypeChecker,\n };\n\n /**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\n /*eslint-disable no-self-compare*/\n function is(x, y) {\n // SameValue algorithm\n if (x === y) {\n // Steps 1-5, 7-10\n // Steps 6.b-6.e: +0 != -0\n return x !== 0 || 1 / x === 1 / y;\n } else {\n // Step 6.a: NaN == NaN\n return x !== x && y !== y;\n }\n }\n /*eslint-enable no-self-compare*/\n\n /**\n * We use an Error-like object for backward compatibility as people may call\n * PropTypes directly and inspect their output. However, we don't use real\n * Errors anymore. We don't inspect their stack anyway, and creating them\n * is prohibitively expensive if they are created too often, such as what\n * happens in oneOfType() for any type before the one that matched.\n */\n function PropTypeError(message, data) {\n this.message = message;\n this.data = data && typeof data === 'object' ? data: {};\n this.stack = '';\n }\n // Make `instanceof Error` still work for returned errors.\n PropTypeError.prototype = Error.prototype;\n\n function createChainableTypeChecker(validate) {\n if (process.env.NODE_ENV !== 'production') {\n var manualPropTypeCallCache = {};\n var manualPropTypeWarningCount = 0;\n }\n function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {\n componentName = componentName || ANONYMOUS;\n propFullName = propFullName || propName;\n\n if (secret !== ReactPropTypesSecret) {\n if (throwOnDirectAccess) {\n // New behavior only for users of `prop-types` package\n var err = new Error(\n 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n 'Use `PropTypes.checkPropTypes()` to call them. ' +\n 'Read more at http://fb.me/use-check-prop-types'\n );\n err.name = 'Invariant Violation';\n throw err;\n } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {\n // Old behavior for people using React.PropTypes\n var cacheKey = componentName + ':' + propName;\n if (\n !manualPropTypeCallCache[cacheKey] &&\n // Avoid spamming the console because they are often not actionable except for lib authors\n manualPropTypeWarningCount < 3\n ) {\n printWarning(\n 'You are manually calling a React.PropTypes validation ' +\n 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +\n 'and will throw in the standalone `prop-types` package. ' +\n 'You may be seeing this warning due to a third-party PropTypes ' +\n 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'\n );\n manualPropTypeCallCache[cacheKey] = true;\n manualPropTypeWarningCount++;\n }\n }\n }\n if (props[propName] == null) {\n if (isRequired) {\n if (props[propName] === null) {\n return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));\n }\n return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));\n }\n return null;\n } else {\n return validate(props, propName, componentName, location, propFullName);\n }\n }\n\n var chainedCheckType = checkType.bind(null, false);\n chainedCheckType.isRequired = checkType.bind(null, true);\n\n return chainedCheckType;\n }\n\n function createPrimitiveTypeChecker(expectedType) {\n function validate(props, propName, componentName, location, propFullName, secret) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== expectedType) {\n // `propValue` being instance of, say, date/regexp, pass the 'object'\n // check, but we can offer a more precise error message here rather than\n // 'of type `object`'.\n var preciseType = getPreciseType(propValue);\n\n return new PropTypeError(\n 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),\n {expectedType: expectedType}\n );\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createAnyTypeChecker() {\n return createChainableTypeChecker(emptyFunctionThatReturnsNull);\n }\n\n function createArrayOfTypeChecker(typeChecker) {\n function validate(props, propName, componentName, location, propFullName) {\n if (typeof typeChecker !== 'function') {\n return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');\n }\n var propValue = props[propName];\n if (!Array.isArray(propValue)) {\n var propType = getPropType(propValue);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));\n }\n for (var i = 0; i < propValue.length; i++) {\n var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);\n if (error instanceof Error) {\n return error;\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createElementTypeChecker() {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n if (!isValidElement(propValue)) {\n var propType = getPropType(propValue);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createElementTypeTypeChecker() {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n if (!ReactIs.isValidElementType(propValue)) {\n var propType = getPropType(propValue);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createInstanceTypeChecker(expectedClass) {\n function validate(props, propName, componentName, location, propFullName) {\n if (!(props[propName] instanceof expectedClass)) {\n var expectedClassName = expectedClass.name || ANONYMOUS;\n var actualClassName = getClassName(props[propName]);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createEnumTypeChecker(expectedValues) {\n if (!Array.isArray(expectedValues)) {\n if (process.env.NODE_ENV !== 'production') {\n if (arguments.length > 1) {\n printWarning(\n 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +\n 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'\n );\n } else {\n printWarning('Invalid argument supplied to oneOf, expected an array.');\n }\n }\n return emptyFunctionThatReturnsNull;\n }\n\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n for (var i = 0; i < expectedValues.length; i++) {\n if (is(propValue, expectedValues[i])) {\n return null;\n }\n }\n\n var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {\n var type = getPreciseType(value);\n if (type === 'symbol') {\n return String(value);\n }\n return value;\n });\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));\n }\n return createChainableTypeChecker(validate);\n }\n\n function createObjectOfTypeChecker(typeChecker) {\n function validate(props, propName, componentName, location, propFullName) {\n if (typeof typeChecker !== 'function') {\n return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');\n }\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));\n }\n for (var key in propValue) {\n if (has(propValue, key)) {\n var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error instanceof Error) {\n return error;\n }\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createUnionTypeChecker(arrayOfTypeCheckers) {\n if (!Array.isArray(arrayOfTypeCheckers)) {\n process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;\n return emptyFunctionThatReturnsNull;\n }\n\n for (var i = 0; i < arrayOfTypeCheckers.length; i++) {\n var checker = arrayOfTypeCheckers[i];\n if (typeof checker !== 'function') {\n printWarning(\n 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +\n 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'\n );\n return emptyFunctionThatReturnsNull;\n }\n }\n\n function validate(props, propName, componentName, location, propFullName) {\n var expectedTypes = [];\n for (var i = 0; i < arrayOfTypeCheckers.length; i++) {\n var checker = arrayOfTypeCheckers[i];\n var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);\n if (checkerResult == null) {\n return null;\n }\n if (checkerResult.data && has(checkerResult.data, 'expectedType')) {\n expectedTypes.push(checkerResult.data.expectedType);\n }\n }\n var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));\n }\n return createChainableTypeChecker(validate);\n }\n\n function createNodeChecker() {\n function validate(props, propName, componentName, location, propFullName) {\n if (!isNode(props[propName])) {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function invalidValidatorError(componentName, location, propFullName, key, type) {\n return new PropTypeError(\n (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +\n 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'\n );\n }\n\n function createShapeTypeChecker(shapeTypes) {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));\n }\n for (var key in shapeTypes) {\n var checker = shapeTypes[key];\n if (typeof checker !== 'function') {\n return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));\n }\n var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error) {\n return error;\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createStrictShapeTypeChecker(shapeTypes) {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));\n }\n // We need to check all keys in case some are required but missing from props.\n var allKeys = assign({}, props[propName], shapeTypes);\n for (var key in allKeys) {\n var checker = shapeTypes[key];\n if (has(shapeTypes, key) && typeof checker !== 'function') {\n return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));\n }\n if (!checker) {\n return new PropTypeError(\n 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +\n '\\nBad object: ' + JSON.stringify(props[propName], null, ' ') +\n '\\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')\n );\n }\n var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error) {\n return error;\n }\n }\n return null;\n }\n\n return createChainableTypeChecker(validate);\n }\n\n function isNode(propValue) {\n switch (typeof propValue) {\n case 'number':\n case 'string':\n case 'undefined':\n return true;\n case 'boolean':\n return !propValue;\n case 'object':\n if (Array.isArray(propValue)) {\n return propValue.every(isNode);\n }\n if (propValue === null || isValidElement(propValue)) {\n return true;\n }\n\n var iteratorFn = getIteratorFn(propValue);\n if (iteratorFn) {\n var iterator = iteratorFn.call(propValue);\n var step;\n if (iteratorFn !== propValue.entries) {\n while (!(step = iterator.next()).done) {\n if (!isNode(step.value)) {\n return false;\n }\n }\n } else {\n // Iterator will provide entry [k,v] tuples rather than values.\n while (!(step = iterator.next()).done) {\n var entry = step.value;\n if (entry) {\n if (!isNode(entry[1])) {\n return false;\n }\n }\n }\n }\n } else {\n return false;\n }\n\n return true;\n default:\n return false;\n }\n }\n\n function isSymbol(propType, propValue) {\n // Native Symbol.\n if (propType === 'symbol') {\n return true;\n }\n\n // falsy value can't be a Symbol\n if (!propValue) {\n return false;\n }\n\n // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'\n if (propValue['@@toStringTag'] === 'Symbol') {\n return true;\n }\n\n // Fallback for non-spec compliant Symbols which are polyfilled.\n if (typeof Symbol === 'function' && propValue instanceof Symbol) {\n return true;\n }\n\n return false;\n }\n\n // Equivalent of `typeof` but with special handling for array and regexp.\n function getPropType(propValue) {\n var propType = typeof propValue;\n if (Array.isArray(propValue)) {\n return 'array';\n }\n if (propValue instanceof RegExp) {\n // Old webkits (at least until Android 4.0) return 'function' rather than\n // 'object' for typeof a RegExp. We'll normalize this here so that /bla/\n // passes PropTypes.object.\n return 'object';\n }\n if (isSymbol(propType, propValue)) {\n return 'symbol';\n }\n return propType;\n }\n\n // This handles more types than `getPropType`. Only used for error messages.\n // See `createPrimitiveTypeChecker`.\n function getPreciseType(propValue) {\n if (typeof propValue === 'undefined' || propValue === null) {\n return '' + propValue;\n }\n var propType = getPropType(propValue);\n if (propType === 'object') {\n if (propValue instanceof Date) {\n return 'date';\n } else if (propValue instanceof RegExp) {\n return 'regexp';\n }\n }\n return propType;\n }\n\n // Returns a string that is postfixed to a warning about an invalid type.\n // For example, \"undefined\" or \"of type array\"\n function getPostfixForTypeWarning(value) {\n var type = getPreciseType(value);\n switch (type) {\n case 'array':\n case 'object':\n return 'an ' + type;\n case 'boolean':\n case 'date':\n case 'regexp':\n return 'a ' + type;\n default:\n return type;\n }\n }\n\n // Returns class name of the object, if any.\n function getClassName(propValue) {\n if (!propValue.constructor || !propValue.constructor.name) {\n return ANONYMOUS;\n }\n return propValue.constructor.name;\n }\n\n ReactPropTypes.checkPropTypes = checkPropTypes;\n ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;\n ReactPropTypes.PropTypes = ReactPropTypes;\n\n return ReactPropTypes;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\n\nfunction emptyFunction() {}\nfunction emptyFunctionWithReset() {}\nemptyFunctionWithReset.resetWarningCache = emptyFunction;\n\nmodule.exports = function() {\n function shim(props, propName, componentName, location, propFullName, secret) {\n if (secret === ReactPropTypesSecret) {\n // It is still safe when called from React.\n return;\n }\n var err = new Error(\n 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n 'Use PropTypes.checkPropTypes() to call them. ' +\n 'Read more at http://fb.me/use-check-prop-types'\n );\n err.name = 'Invariant Violation';\n throw err;\n };\n shim.isRequired = shim;\n function getShim() {\n return shim;\n };\n // Important!\n // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.\n var ReactPropTypes = {\n array: shim,\n bigint: shim,\n bool: shim,\n func: shim,\n number: shim,\n object: shim,\n string: shim,\n symbol: shim,\n\n any: shim,\n arrayOf: getShim,\n element: shim,\n elementType: shim,\n instanceOf: getShim,\n node: shim,\n objectOf: getShim,\n oneOf: getShim,\n oneOfType: getShim,\n shape: getShim,\n exact: getShim,\n\n checkPropTypes: emptyFunctionWithReset,\n resetWarningCache: emptyFunction\n };\n\n ReactPropTypes.PropTypes = ReactPropTypes;\n\n return ReactPropTypes;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (process.env.NODE_ENV !== 'production') {\n var ReactIs = require('react-is');\n\n // By explicitly using `prop-types` you are opting into new development behavior.\n // http://fb.me/prop-types-in-prod\n var throwOnDirectAccess = true;\n module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess);\n} else {\n // By explicitly using `prop-types` you are opting into new production behavior.\n // http://fb.me/prop-types-in-prod\n module.exports = require('./factoryWithThrowingShims')();\n}\n","// Import self-host typography Inter font\nimport '@fontsource/inter';\n\n// interface exports\nexport type {\n Tab,\n Tabs,\n Variables,\n VariableXFhirQuery,\n LaunchContext,\n CalculatedExpression,\n QItemOverrideComponentProps,\n SdcUiOverrideComponentProps\n} from './interfaces';\n\n// component exports\nexport type { SmartFormsRendererProps } from './components';\nexport {\n SmartFormsRenderer,\n BaseRenderer,\n SingleItem,\n GroupItem,\n RepeatItem,\n RepeatGroup,\n GroupTable,\n GridGroup,\n parseFhirDateToDisplayDate,\n ItemFieldGrid,\n ItemLabel,\n BooleanField,\n DecimalField,\n StringField,\n ChoiceRadioSingle,\n FullWidthFormComponentBox\n} from './components';\n\n// state management store exports\nexport type {\n QuestionnaireStoreType,\n QuestionnaireResponseStoreType,\n SmartConfigStoreType,\n TerminologyServerStoreType,\n RendererStyling,\n RendererStylingStoreType\n} from './stores';\nexport {\n questionnaireStore,\n useQuestionnaireStore,\n questionnaireResponseStore,\n useQuestionnaireResponseStore,\n smartConfigStore,\n useSmartConfigStore,\n terminologyServerStore,\n useTerminologyServerStore,\n rendererStylingStore,\n useRendererStylingStore\n} from './stores';\n\n// hooks exports\nexport type { UseResponsiveProps } from './hooks';\nexport {\n useHidden,\n useReadOnly,\n useBuildForm,\n useRendererQueryClient,\n useRenderingExtensions,\n useValidationFeedback,\n useValueSetCodings,\n useStringCalculatedExpression,\n useDisplayCqfAndCalculatedExpression,\n useCodingCalculatedExpression,\n objectIsCoding,\n useResponsive\n} from './hooks';\n\n// utils exports\nexport type { ItemToRepopulate } from './utils';\nexport {\n buildForm,\n destroyForm,\n getResponse,\n removeEmptyAnswersFromResponse,\n removeInternalIdsFromResponse,\n createEmptyQrItem,\n createEmptyQrGroup,\n updateQrItemsInGroup,\n mapQItemsIndex,\n getQrItemsIndex,\n isSpecificItemControl,\n getDecimalPrecision,\n isRepeatItemAndNotCheckbox,\n parseDecimalStringToFloat,\n parseDecimalStringWithPrecision,\n isHiddenByEnableWhen,\n initialiseQuestionnaireResponse,\n generateItemsToRepopulate,\n repopulateResponse,\n extractObservationBased,\n getQuestionnaireItem\n} from './utils';\n\n// theme provider exports\nexport { RendererThemeProvider, themeOptions } from './theme';\n\n// wrapper exports - only for smartforms.csiro.au/standalone use\nexport type { InitialiseFormWrapperProps } from './stories/storybookWrappers';\nexport { InitialiseFormWrapperForStorybook } from './stories/storybookWrappers';\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';\nimport { useLayoutEffect, useState } from 'react';\nimport { buildForm } from '../utils';\nimport type Client from 'fhirclient/lib/Client';\nimport { useSmartConfigStore } from '../stores';\nimport { initialiseFhirClient } from '../utils/manageForm';\n\n/**\n * React hook to initialise a form by:\n * - Calling the buildForm() function to build a form from a questionnaire, an optional QuestionnaireResponse and other optional properties.\n * - Setting a FHIRClient object to make further FHIR calls i.e. answerExpressions.\n *\n * @param questionnaire - Questionnaire to be rendered\n * @param questionnaireResponse - Pre-populated/draft/loaded QuestionnaireResponse to be rendered (optional)\n * @param readOnly - Applies read-only mode to all items in the form view\n * @param terminologyServerUrl - Terminology server url to fetch terminology. If not provided, the default terminology server will be used. (optional)\n * @param additionalVariables - Additional key-value pair of SDC variables `Record<name, variable extension>` for testing (optional)\n * @param fhirClient - FHIRClient object to perform further FHIR calls. At the moment it's only used in answerExpressions (optional)\n *\n * @see buildForm() for more information.\n *\n * @author Sean Fong\n */\nfunction useInitialiseForm(\n questionnaire: Questionnaire,\n questionnaireResponse?: QuestionnaireResponse,\n readOnly?: boolean,\n terminologyServerUrl?: string,\n additionalVariables?: Record<string, object>,\n fhirClient?: Client\n): boolean {\n const [isFhirClientReady, setIsFhirClientReady] = useState(true);\n const [isBuilding, setIsBuilding] = useState(true);\n\n const setSmartClient = useSmartConfigStore.use.setClient();\n const setPatient = useSmartConfigStore.use.setPatient();\n const setUser = useSmartConfigStore.use.setUser();\n const setEncounter = useSmartConfigStore.use.setEncounter();\n\n useLayoutEffect(() => {\n setIsBuilding(true);\n if (fhirClient) {\n setIsFhirClientReady(true);\n initialiseFhirClient(fhirClient).then(() => {\n setIsFhirClientReady(false);\n });\n }\n\n // Initialise form including Questionnaire and other optionally provided parameters\n // Includes initialisation for enableWhen, enableWhenExpressions, calculatedExpressions, initialExpressions, answerExpressions, cache answerValueSets\n buildForm(\n questionnaire,\n questionnaireResponse,\n readOnly,\n terminologyServerUrl,\n additionalVariables\n ).then(() => {\n setIsBuilding(false);\n });\n }, [\n questionnaire,\n questionnaireResponse,\n additionalVariables,\n terminologyServerUrl,\n fhirClient,\n readOnly,\n setSmartClient,\n setPatient,\n setUser,\n setEncounter\n ]);\n\n return isFhirClientReady && isBuilding;\n}\n\nexport default useInitialiseForm;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createStore } from 'zustand/vanilla';\nimport type {\n Coding,\n Questionnaire,\n QuestionnaireResponse,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport type { Variables } from '../interfaces/variables.interface';\nimport type { LaunchContext } from '../interfaces/populate.interface';\nimport type { CalculatedExpression } from '../interfaces/calculatedExpression.interface';\nimport type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';\nimport type { AnswerExpression } from '../interfaces/answerExpression.interface';\nimport type { Tabs } from '../interfaces/tab.interface';\nimport type { Pages } from '../interfaces/page.interface';\nimport {\n mutateRepeatEnableWhenItemInstances,\n updateEnableWhenItemAnswer\n} from '../utils/enableWhen';\nimport { evaluateUpdatedExpressions } from '../utils/fhirpath';\nimport {\n evaluateInitialCalculatedExpressions,\n initialiseCalculatedExpressionValues\n} from '../utils/calculatedExpression';\nimport { createQuestionnaireModel } from '../utils/questionnaireStoreUtils/createQuestionaireModel';\nimport { initialiseFormFromResponse } from '../utils/initialise';\nimport { emptyQuestionnaire, emptyResponse } from '../utils/emptyResource';\nimport { terminologyServerStore } from './terminologyServerStore';\nimport { createSelectors } from './selector';\nimport { mutateRepeatEnableWhenExpressionInstances } from '../utils/enableWhenExpression';\nimport { questionnaireResponseStore } from './questionnaireResponseStore';\nimport { createQuestionnaireResponseItemMap } from '../utils/questionnaireResponseStoreUtils/updatableResponseItems';\nimport { insertCompleteAnswerOptionsIntoQuestionnaire } from '../utils/questionnaireStoreUtils/insertAnswerOptions';\nimport type { InitialExpression } from '../interfaces/initialExpression.interface';\nimport type { QItemOverrideComponentProps, SdcUiOverrideComponentProps } from '../interfaces';\nimport type { ComponentType } from 'react';\nimport type { TargetConstraint } from '../interfaces/targetConstraint.interface';\nimport { readTargetConstraintLocationLinkIds } from '../utils/targetConstraint';\nimport type { ProcessedValueSet } from '../interfaces/valueSet.interface';\nimport type { ComputedQRItemUpdates } from '../interfaces/computedUpdates.interface';\n\n/**\n * QuestionnaireStore properties and methods\n * Properties can be accessed for fine-grain details.\n * Methods are usually used internally, using them from an external source is not recommended.\n *\n * @property sourceQuestionnaire - FHIR R4 Questionnaire to render\n * @property itemTypes - Key-value pair of item types `Record<linkId, item.type>`\n * @property itemPreferredTerminologyServers - Key-value pair of item types `Record<linkId, preferred terminology servers>`\n * @property tabs - Key-value pair of tabs `Record<linkId, Tab>`\n * @property currentTabIndex - Index of the current tab\n * @property pages - Key-value pair of pages `Record<linkId, Page>`\n * @property currentPageIndex - Index of the current page\n * @property variables - Questionnaire variables object containing FHIRPath and x-fhir-query variables\n * @property launchContexts - Key-value pair of launch contexts `Record<launch context name, launch context properties>`\n * @property targetConstraints - Key-value pair of target constraints `Record<target constraint key, target constraint properties>`\n * @property targetConstraintLinkIds - Key-value pair of linkIds against target constraint key(s) `Record<linkId, target constraint keys>`\n * @property enableWhenItems - EnableWhenItems object containing enableWhen items and their linked questions\n * @property enableWhenLinkedQuestions - Key-value pair of linked questions to enableWhen items `Record<linkId, linkIds of linked questions>`\n * @property enableWhenIsActivated - Flag to turn enableWhen checks on/off\n * @property enableWhenExpressions - EnableWhenExpressions object containing enableWhen expressions\n * @property calculatedExpressions - Key-value pair of calculated expressions `Record<linkId, array of calculated expression properties>`\n * @property answerExpressions - Key-value pair of answer expressions `Record<linkId, answer expression properties>`\n * @property processedValueSets - Key-value pair of (pre-)processed value set codings `Record<valueSetUrl, ProcessedValueSet>`\n * @property cachedValueSetCodings - Key-value pair of cached value set codings `Record<valueSetUrl, codings>`\n * @property fhirPathContext - Key-value pair of evaluated FHIRPath values `Record<variable name, evaluated value(s)>`\n * @property fhirPathTerminologyCache - Key-value pair of cached FHIRPath Terminology results `Record<cacheKey, cached terminology result>`\n * @property populatedContext - Key-value pair of one-off pre-populated FHIRPath values `Record<variable/launchContext/sourceQueries batch name, evaluated value(s)>`\n * @property qItemOverrideComponents - Key-value pair of React component overrides for Questionnaire Items via linkId `Record<linkId, React component>`\n * @property sdcUiOverrideComponents - Key-value pair of React component overrides for SDC UI Controls https://hl7.org/fhir/extensions/ValueSet-questionnaire-item-control.html `Record<SDC UI code, React component>`\n * @property focusedLinkId - LinkId of the currently focused item\n * @property readOnly - Flag to set the form to read-only mode\n * @property buildSourceQuestionnaire - Used to build the source questionnaire with the provided questionnaire and optionally questionnaire response, additional variables, terminology server url and readyOnly flag\n * @property destroySourceQuestionnaire - Used to destroy the source questionnaire and reset all properties\n * @property switchTab - Used to switch the current tab index\n * @property switchPage - Used to switch the current page index\n * @property markTabAsComplete - Used to mark a tab index as complete\n * @property markPageAsComplete - Used to mark a page index as complete\n * @property updateEnableWhenItem - Used to update linked enableWhen items by updating a question with a new answer\n * @property mutateRepeatEnableWhenItems - Used to add or remove instances of repeating enableWhen items\n * @property toggleEnableWhenActivation - Used to toggle enableWhen checks on/off\n * @property updateExpressions - Used to update all SDC expressions based on the updated questionnaire response\n * @property addCodingToCache - Used to add a coding to the cached value set codings\n * @property updatePopulatedProperties - Used to update all SDC expressions based on a pre-populated questionnaire response\n * @property onFocusLinkId - Used to set the focused linkId\n * @property setPopulatedContext - Used to set the populated contexts (launchContext, sourceQueries, x-fhir-query vars) for debugging purposes, and optionally add to the FHIRPath context\n * @property setFormAsReadOnly - Used to set the form as read-only\n *\n * @author Sean Fong\n */\nexport interface QuestionnaireStoreType {\n sourceQuestionnaire: Questionnaire;\n itemTypes: Record<string, string>;\n itemPreferredTerminologyServers: Record<string, string>;\n tabs: Tabs;\n currentTabIndex: number;\n pages: Pages;\n currentPageIndex: number;\n variables: Variables;\n launchContexts: Record<string, LaunchContext>;\n targetConstraints: Record<string, TargetConstraint>;\n targetConstraintLinkIds: Record<string, string[]>;\n enableWhenItems: EnableWhenItems;\n enableWhenLinkedQuestions: Record<string, string[]>;\n enableWhenIsActivated: boolean;\n enableWhenExpressions: EnableWhenExpressions;\n calculatedExpressions: Record<string, CalculatedExpression[]>;\n initialExpressions: Record<string, InitialExpression>;\n answerExpressions: Record<string, AnswerExpression>;\n processedValueSets: Record<string, ProcessedValueSet>;\n cachedValueSetCodings: Record<string, Coding[]>;\n fhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n populatedContext: Record<string, any>;\n qItemOverrideComponents: Record<string, ComponentType<QItemOverrideComponentProps>>;\n sdcUiOverrideComponents: Record<string, ComponentType<SdcUiOverrideComponentProps>>;\n focusedLinkId: string;\n readOnly: boolean;\n buildSourceQuestionnaire: (\n questionnaire: Questionnaire,\n questionnaireResponse?: QuestionnaireResponse,\n additionalVariables?: Record<string, object>,\n terminologyServerUrl?: string,\n readOnly?: boolean,\n qItemOverrideComponents?: Record<string, ComponentType<QItemOverrideComponentProps>>,\n sdcUiOverrideComponents?: Record<string, ComponentType<SdcUiOverrideComponentProps>>\n ) => Promise<void>;\n destroySourceQuestionnaire: () => void;\n switchTab: (newTabIndex: number) => void;\n switchPage: (newPageIndex: number) => void;\n markTabAsComplete: (tabLinkId: string) => void;\n markPageAsComplete: (pageLinkId: string) => void;\n updateEnableWhenItem: (\n linkId: string,\n newAnswer: QuestionnaireResponseItemAnswer[] | undefined,\n parentRepeatGroupIndex: number | null\n ) => void;\n mutateRepeatEnableWhenItems: (\n parentRepeatGroupLinkId: string,\n parentRepeatGroupIndex: number,\n actionType: 'add' | 'remove'\n ) => void;\n toggleEnableWhenActivation: (isActivated: boolean) => void;\n updateExpressions: (updatedResponse: QuestionnaireResponse) => Promise<ComputedQRItemUpdates>;\n addCodingToCache: (valueSetUrl: string, codings: Coding[]) => void;\n updatePopulatedProperties: (\n populatedResponse: QuestionnaireResponse,\n populatedContext?: Record<string, any>,\n persistTabIndex?: boolean\n ) => Promise<QuestionnaireResponse>;\n onFocusLinkId: (linkId: string) => void;\n setPopulatedContext: (\n newPopulatedContext: Record<string, any>,\n addToFhirPathContext?: boolean\n ) => void;\n setFormAsReadOnly: (readOnly: boolean) => void;\n}\n\n/**\n * Questionnaire state management store which contains all properties and methods to manage the state of the questionnaire.\n * This is the vanilla version of the store which can be used in non-React environments.\n * @see QuestionnaireStoreType for available properties and methods.\n *\n * @author Sean Fong\n */\nexport const questionnaireStore = createStore<QuestionnaireStoreType>()((set, get) => ({\n sourceQuestionnaire: structuredClone(emptyQuestionnaire),\n itemTypes: {},\n itemPreferredTerminologyServers: {},\n tabs: {},\n currentTabIndex: 0,\n pages: {},\n currentPageIndex: 0,\n variables: { fhirPathVariables: {}, xFhirQueryVariables: {} },\n launchContexts: {},\n targetConstraints: {},\n targetConstraintLinkIds: {},\n calculatedExpressions: {},\n initialExpressions: {},\n enableWhenExpressions: { singleExpressions: {}, repeatExpressions: {} },\n answerExpressions: {},\n enableWhenItems: { singleItems: {}, repeatItems: {} },\n enableWhenLinkedQuestions: {},\n enableWhenIsActivated: true,\n processedValueSets: {},\n cachedValueSetCodings: {},\n fhirPathContext: {},\n fhirPathTerminologyCache: {},\n populatedContext: {},\n qItemOverrideComponents: {},\n sdcUiOverrideComponents: {},\n focusedLinkId: '',\n readOnly: false,\n buildSourceQuestionnaire: async (\n questionnaire,\n questionnaireResponse = structuredClone(emptyResponse),\n additionalVariables = {},\n terminologyServerUrl = terminologyServerStore.getState().url,\n readOnly = false,\n qItemOverrideComponents = {},\n sdcUiOverrideComponents = {}\n ) => {\n const questionnaireModel = await createQuestionnaireModel(\n questionnaire,\n additionalVariables,\n terminologyServerUrl\n );\n\n // Insert answerOptions with displays into questionnaire\n questionnaire = insertCompleteAnswerOptionsIntoQuestionnaire(\n questionnaire,\n questionnaireModel.answerOptions\n );\n\n // If existing fhirPathContext is empty, use the one from the questionnaire model\n // Mostly existing fhirPathContext will be empty, but in some cases it may not be e.g. after pre-population\n const fhirPathContext = get().fhirPathContext ?? questionnaireModel.fhirPathContext;\n const fhirPathTerminologyCache =\n get().fhirPathTerminologyCache ?? questionnaireModel.fhirPathTerminologyCache;\n\n // Initialise form with questionnaire response and properties in questionnaire model\n const {\n initialTargetConstraints,\n initialEnableWhenItems,\n initialEnableWhenLinkedQuestions,\n initialEnableWhenExpressions,\n initialCalculatedExpressions,\n initialProcessedValueSets,\n firstVisibleTab,\n firstVisiblePage,\n updatedFhirPathContext,\n fhirPathTerminologyCache: updatedFhirPathTerminologyCache\n } = await initialiseFormFromResponse({\n sourceQuestionnaire: questionnaire,\n questionnaireResponse,\n targetConstraints: questionnaireModel.targetConstraints,\n enableWhenItems: questionnaireModel.enableWhenItems,\n enableWhenExpressions: questionnaireModel.enableWhenExpressions,\n calculatedExpressions: questionnaireModel.calculatedExpressions,\n variables: questionnaireModel.variables,\n processedValueSets: questionnaireModel.processedValueSets,\n tabs: questionnaireModel.tabs,\n pages: questionnaireModel.pages,\n fhirPathContext: fhirPathContext,\n fhirPathTerminologyCache: fhirPathTerminologyCache,\n terminologyServerUrl: terminologyServerUrl\n });\n\n // Read target constraint locations\n const targetConstraintLinkIds = readTargetConstraintLocationLinkIds(\n questionnaire,\n initialTargetConstraints\n );\n\n set({\n sourceQuestionnaire: questionnaire,\n itemTypes: questionnaireModel.itemTypes,\n itemPreferredTerminologyServers: questionnaireModel.itemPreferredTerminologyServers,\n tabs: questionnaireModel.tabs,\n currentTabIndex: firstVisibleTab,\n pages: questionnaireModel.pages,\n currentPageIndex: firstVisiblePage,\n variables: questionnaireModel.variables,\n launchContexts: questionnaireModel.launchContexts,\n targetConstraints: initialTargetConstraints,\n targetConstraintLinkIds: targetConstraintLinkIds,\n enableWhenItems: initialEnableWhenItems,\n enableWhenLinkedQuestions: initialEnableWhenLinkedQuestions,\n enableWhenExpressions: initialEnableWhenExpressions,\n calculatedExpressions: initialCalculatedExpressions,\n initialExpressions: questionnaireModel.initialExpressions,\n answerExpressions: questionnaireModel.answerExpressions,\n processedValueSets: initialProcessedValueSets,\n cachedValueSetCodings: questionnaireModel.cachedValueSetCodings,\n fhirPathContext: updatedFhirPathContext,\n fhirPathTerminologyCache: updatedFhirPathTerminologyCache,\n qItemOverrideComponents: qItemOverrideComponents,\n sdcUiOverrideComponents: sdcUiOverrideComponents,\n readOnly: readOnly\n });\n },\n destroySourceQuestionnaire: () =>\n set({\n sourceQuestionnaire: structuredClone(emptyQuestionnaire),\n itemTypes: {},\n itemPreferredTerminologyServers: {},\n tabs: {},\n currentTabIndex: 0,\n pages: {},\n currentPageIndex: 0,\n variables: { fhirPathVariables: {}, xFhirQueryVariables: {} },\n launchContexts: {},\n targetConstraints: {},\n targetConstraintLinkIds: {},\n enableWhenItems: { singleItems: {}, repeatItems: {} },\n enableWhenLinkedQuestions: {},\n enableWhenExpressions: { singleExpressions: {}, repeatExpressions: {} },\n calculatedExpressions: {},\n initialExpressions: {},\n answerExpressions: {},\n processedValueSets: {},\n fhirPathContext: {},\n fhirPathTerminologyCache: {},\n qItemOverrideComponents: {},\n sdcUiOverrideComponents: {}\n }),\n switchTab: (newTabIndex: number) => set(() => ({ currentTabIndex: newTabIndex })),\n switchPage: (newPageIndex: number) => set(() => ({ currentPageIndex: newPageIndex })),\n markTabAsComplete: (tabLinkId: string) => {\n const tabs = get().tabs;\n set(() => ({\n tabs: {\n ...tabs,\n [tabLinkId]: { ...tabs[tabLinkId], isComplete: !tabs[tabLinkId].isComplete }\n }\n }));\n },\n markPageAsComplete: (pageLinkId: string) => {\n const pages = get().pages;\n set(() => ({\n pages: {\n ...pages,\n [pageLinkId]: { ...pages[pageLinkId], isComplete: !pages[pageLinkId].isComplete }\n }\n }));\n },\n updateEnableWhenItem: (\n linkId: string,\n newAnswer: QuestionnaireResponseItemAnswer[] | undefined,\n parentRepeatGroupIndex: number | null\n ) => {\n const enableWhenLinkedQuestions = get().enableWhenLinkedQuestions;\n const enableWhenItems = get().enableWhenItems;\n if (!enableWhenLinkedQuestions[linkId]) {\n return;\n }\n\n const itemLinkedQuestions = enableWhenLinkedQuestions[linkId];\n const updatedEnableWhenItems = updateEnableWhenItemAnswer(\n { ...enableWhenItems },\n itemLinkedQuestions,\n linkId,\n newAnswer,\n parentRepeatGroupIndex\n );\n\n set(() => ({\n enableWhenItems: updatedEnableWhenItems\n }));\n },\n mutateRepeatEnableWhenItems: async (\n parentRepeatGroupLinkId: string,\n parentRepeatGroupIndex: number,\n actionType: 'add' | 'remove'\n ) => {\n const enableWhenItems = get().enableWhenItems;\n const enableWhenExpressions = get().enableWhenExpressions;\n\n const updatedEnableWhenItems = mutateRepeatEnableWhenItemInstances(\n {\n ...enableWhenItems\n },\n parentRepeatGroupLinkId,\n parentRepeatGroupIndex,\n actionType\n );\n\n const { updatedEnableWhenExpressions, isUpdated } =\n await mutateRepeatEnableWhenExpressionInstances({\n questionnaireResponse: questionnaireResponseStore.getState().updatableResponse,\n questionnaireResponseItemMap: questionnaireResponseStore.getState().updatableResponseItems,\n variables: get().variables,\n existingFhirPathContext: get().fhirPathContext,\n fhirPathTerminologyCache: get().fhirPathTerminologyCache,\n enableWhenExpressions: enableWhenExpressions,\n parentRepeatGroupLinkId,\n parentRepeatGroupIndex,\n actionType,\n terminologyServerUrl: terminologyServerStore.getState().url\n });\n\n if (isUpdated) {\n set(() => ({\n enableWhenItems: updatedEnableWhenItems,\n enableWhenExpressions: updatedEnableWhenExpressions\n }));\n }\n },\n toggleEnableWhenActivation: (isActivated: boolean) =>\n set(() => ({ enableWhenIsActivated: isActivated })),\n updateExpressions: async (updatedResponse: QuestionnaireResponse) => {\n const updatedResponseItemMap = createQuestionnaireResponseItemMap(\n get().sourceQuestionnaire,\n updatedResponse\n );\n const {\n isUpdated,\n updatedTargetConstraints,\n updatedEnableWhenExpressions,\n updatedCalculatedExpressions,\n updatedProcessedValueSets,\n updatedFhirPathContext,\n fhirPathTerminologyCache,\n computedQRItemUpdates\n } = await evaluateUpdatedExpressions({\n updatedResponse,\n updatedResponseItemMap,\n targetConstraints: get().targetConstraints,\n enableWhenExpressions: get().enableWhenExpressions,\n calculatedExpressions: get().calculatedExpressions,\n processedValueSets: get().processedValueSets,\n variables: get().variables,\n existingFhirPathContext: get().fhirPathContext,\n fhirPathTerminologyCache: get().fhirPathTerminologyCache,\n terminologyServerUrl: terminologyServerStore.getState().url\n });\n\n if (isUpdated) {\n set(() => ({\n targetConstraints: updatedTargetConstraints,\n enableWhenExpressions: updatedEnableWhenExpressions,\n calculatedExpressions: updatedCalculatedExpressions,\n processedValueSets: updatedProcessedValueSets,\n fhirPathContext: updatedFhirPathContext,\n fhirPathTerminologyCache: fhirPathTerminologyCache\n }));\n return computedQRItemUpdates;\n }\n\n set(() => ({\n fhirPathContext: updatedFhirPathContext,\n fhirPathTerminologyCache: fhirPathTerminologyCache\n }));\n return computedQRItemUpdates;\n },\n addCodingToCache: (valueSetUrl: string, codings: Coding[]) =>\n set(() => ({\n cachedValueSetCodings: {\n ...get().cachedValueSetCodings,\n [valueSetUrl]: codings\n }\n })),\n updatePopulatedProperties: async (\n populatedResponse: QuestionnaireResponse,\n populatedContext?: Record<string, any>,\n persistTabIndex?: boolean,\n persistPageIndex?: boolean\n ) => {\n const sourceQuestionnaire = get().sourceQuestionnaire;\n const initialResponseItemMap = createQuestionnaireResponseItemMap(\n sourceQuestionnaire,\n populatedResponse\n );\n\n const evaluateInitialCalculatedExpressionsResult = await evaluateInitialCalculatedExpressions({\n initialResponse: populatedResponse,\n initialResponseItemMap: initialResponseItemMap,\n calculatedExpressions: get().calculatedExpressions,\n variables: get().variables,\n existingFhirPathContext: get().fhirPathContext,\n fhirPathTerminologyCache: get().fhirPathTerminologyCache,\n terminologyServerUrl: terminologyServerStore.getState().url\n });\n const { initialCalculatedExpressions } = evaluateInitialCalculatedExpressionsResult;\n let updatedFhirPathContext = evaluateInitialCalculatedExpressionsResult.updatedFhirPathContext;\n let fhirPathTerminologyCache =\n evaluateInitialCalculatedExpressionsResult.fhirPathTerminologyCache;\n\n const updatedResponse = initialiseCalculatedExpressionValues(\n sourceQuestionnaire,\n populatedResponse,\n initialCalculatedExpressions\n );\n\n const {\n initialTargetConstraints,\n initialEnableWhenItems,\n initialEnableWhenLinkedQuestions,\n initialEnableWhenExpressions,\n firstVisibleTab,\n firstVisiblePage\n } = await initialiseFormFromResponse({\n sourceQuestionnaire,\n questionnaireResponse: updatedResponse,\n targetConstraints: get().targetConstraints,\n enableWhenItems: get().enableWhenItems,\n enableWhenExpressions: get().enableWhenExpressions,\n calculatedExpressions: initialCalculatedExpressions,\n variables: get().variables,\n processedValueSets: get().processedValueSets,\n tabs: get().tabs,\n pages: get().pages,\n fhirPathContext: updatedFhirPathContext,\n fhirPathTerminologyCache: fhirPathTerminologyCache,\n terminologyServerUrl: terminologyServerStore.getState().url\n });\n updatedFhirPathContext = evaluateInitialCalculatedExpressionsResult.updatedFhirPathContext;\n fhirPathTerminologyCache = evaluateInitialCalculatedExpressionsResult.fhirPathTerminologyCache;\n\n set(() => ({\n targetConstraints: initialTargetConstraints,\n enableWhenItems: initialEnableWhenItems,\n enableWhenLinkedQuestions: initialEnableWhenLinkedQuestions,\n enableWhenExpressions: initialEnableWhenExpressions,\n calculatedExpressions: initialCalculatedExpressions,\n currentTabIndex: persistTabIndex ? get().currentTabIndex : firstVisibleTab,\n currentPageIndex: persistPageIndex ? get().currentPageIndex : firstVisiblePage,\n fhirPathContext: updatedFhirPathContext,\n fhirPathTerminologyCache: fhirPathTerminologyCache,\n populatedContext: populatedContext ?? get().populatedContext\n }));\n\n return updatedResponse;\n },\n onFocusLinkId: (linkId: string) =>\n set(() => ({\n focusedLinkId: linkId\n })),\n setPopulatedContext: (\n newPopulatedContext: Record<string, any>,\n addToFhirPathContext?: boolean\n ) => {\n if (addToFhirPathContext) {\n const newFhirPathContext = { ...get().fhirPathContext, ...newPopulatedContext };\n set(() => ({\n populatedContext: newPopulatedContext,\n fhirPathContext: newFhirPathContext\n }));\n return;\n }\n\n set(() => ({\n populatedContext: newPopulatedContext\n }));\n },\n setFormAsReadOnly: (readOnly: boolean) =>\n set(() => ({\n readOnly: readOnly\n }))\n}));\n\n/**\n * Questionnaire state management store which contains all properties and methods to manage the state of the questionnaire.\n * This is the React version of the store which can be used as React hooks in React functional components.\n * @see QuestionnaireStoreType for available properties and methods.\n * @see questionnaireStore for the vanilla store.\n *\n * @author Sean Fong\n */\nexport const useQuestionnaireStore = createSelectors(questionnaireStore);\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n Quantity,\n QuestionnaireItemEnableWhen,\n QuestionnaireResponse,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport type {\n EnableWhenItems,\n EnableWhenRepeatItemProperties,\n EnableWhenSingleItemProperties\n} from '../interfaces/enableWhen.interface';\n\n/**\n * Create a linkedQuestionsMap that contains linked items of enableWhen items\n * mapped to an array containing all its respective enableWhen items' linkIds\n * returns a key-value pair of <linkedItemId, [enableWhenItem1LinkId, enableWhenItem2LinkId, enableWhenItem3LinkId]>\n *\n * @author Sean Fong\n */\nexport function createEnableWhenLinkedQuestions(enableWhenItems: EnableWhenItems) {\n const linkedQuestionsMap: Record<string, string[]> = {};\n\n const { singleItems, repeatItems } = enableWhenItems;\n\n for (const items of [singleItems, repeatItems]) {\n for (const linkId in items) {\n items[linkId].linked.forEach((linkedItem) => {\n const linkQId = linkedItem.enableWhen.question;\n if (!linkedQuestionsMap[linkQId]) {\n linkedQuestionsMap[linkQId] = [];\n }\n\n if (!linkedQuestionsMap[linkQId].includes(linkId)) {\n linkedQuestionsMap[linkQId].push(linkId);\n }\n });\n }\n }\n\n return linkedQuestionsMap;\n}\n\n/**\n * Performs switching for non-group enableWhenItems based on their item types.\n *\n * @author Sean Fong\n */\nexport function isEnabledAnswerTypeSwitcher(\n enableWhen: QuestionnaireItemEnableWhen,\n answer: QuestionnaireResponseItemAnswer\n): boolean {\n if (typeof enableWhen.answerBoolean === 'boolean' && enableWhen.operator === 'exists') {\n return answerOperatorSwitcher(enableWhen.answerBoolean, answer, enableWhen.operator);\n }\n\n if (typeof enableWhen.answerBoolean === 'boolean' && typeof answer.valueBoolean === 'boolean') {\n return answerOperatorSwitcher(\n enableWhen.answerBoolean,\n answer.valueBoolean,\n enableWhen.operator\n );\n }\n\n if (typeof enableWhen.answerDecimal === 'number' && typeof answer.valueDecimal === 'number') {\n return answerOperatorSwitcher(\n enableWhen.answerDecimal,\n answer.valueDecimal,\n enableWhen.operator\n );\n }\n\n if (typeof enableWhen.answerInteger === 'number' && typeof answer.valueInteger === 'number') {\n return answerOperatorSwitcher(\n enableWhen.answerInteger,\n answer.valueInteger,\n enableWhen.operator\n );\n }\n\n if (typeof enableWhen.answerDate === 'string' && typeof answer.valueDate === 'string') {\n return answerOperatorSwitcher(enableWhen.answerDate, answer.valueDate, enableWhen.operator);\n }\n\n if (typeof enableWhen.answerDateTime === 'string' && typeof answer.valueDateTime === 'string') {\n return answerOperatorSwitcher(\n enableWhen.answerDateTime,\n answer.valueDateTime,\n enableWhen.operator\n );\n }\n\n if (typeof enableWhen.answerTime === 'string' && typeof answer.valueTime === 'string') {\n return answerOperatorSwitcher(enableWhen.answerTime, answer.valueTime, enableWhen.operator);\n }\n\n if (typeof enableWhen.answerString === 'string' && typeof answer.valueString === 'string') {\n return answerOperatorSwitcher(enableWhen.answerString, answer.valueString, enableWhen.operator);\n }\n\n if (\n typeof enableWhen.answerCoding?.code === 'string' &&\n typeof answer.valueCoding?.code === 'string'\n ) {\n return answerOperatorSwitcher(\n enableWhen.answerCoding.code,\n answer.valueCoding.code,\n enableWhen.operator\n );\n }\n\n // Handle case where valueCoding.code is not present\n if (\n typeof enableWhen.answerCoding?.display === 'string' &&\n typeof answer.valueCoding?.display === 'string'\n ) {\n return answerOperatorSwitcher(\n enableWhen.answerCoding.display,\n answer.valueCoding.display,\n enableWhen.operator\n );\n }\n\n if (enableWhen.answerQuantity && answer.valueQuantity) {\n return answerOperatorSwitcher(\n enableWhen.answerQuantity,\n answer.valueQuantity,\n enableWhen.operator\n );\n }\n\n return false;\n}\n\n/**\n * Performs switching for value and expected comparisons based on given operator\n *\n * @author Sean Fong\n */\nfunction answerOperatorSwitcher(\n expected: boolean | string | number | Quantity,\n value: boolean | string | number | Quantity | QuestionnaireResponseItemAnswer,\n operator: QuestionnaireItemEnableWhen['operator']\n): boolean {\n switch (operator) {\n case 'exists': {\n const answerExists = typeof value === 'object' && Object.keys(value).length !== 0;\n return answerExists === expected;\n }\n case '=':\n return value === expected;\n case '!=':\n return value !== expected;\n case '<':\n return value < expected;\n case '<=':\n return value <= expected;\n case '>':\n return value > expected;\n case '>=':\n return value >= expected;\n default:\n return false;\n }\n}\n\nexport function mutateRepeatEnableWhenItemInstances(\n items: EnableWhenItems,\n parentRepeatGroupLinkId: string,\n parentRepeatGroupIndex: number,\n actionType: 'add' | 'remove'\n): EnableWhenItems {\n const { repeatItems } = items;\n\n for (const linkId in repeatItems) {\n for (const linkedItem of repeatItems[linkId].linked) {\n if (linkedItem.parentLinkId !== parentRepeatGroupLinkId) {\n continue;\n }\n\n if (actionType === 'add') {\n linkedItem.answers.splice(parentRepeatGroupIndex, 0);\n repeatItems[linkId].enabledIndexes[parentRepeatGroupIndex] = checkItemIsEnabledRepeat(\n repeatItems[linkId],\n parentRepeatGroupIndex\n );\n } else if (actionType === 'remove') {\n linkedItem.answers.splice(parentRepeatGroupIndex, 1);\n repeatItems[linkId].enabledIndexes.splice(parentRepeatGroupIndex, 1);\n }\n }\n }\n\n return items;\n}\n\n/**\n * Read initial answer values in questionnaireResponse\n * return a map of initial values with key-value pair <linkedItemId, initial value>\n *\n * @author Sean Fong\n */\nexport function readInitialAnswers(\n questionnaireResponse: QuestionnaireResponse,\n linkedQuestionsMap: Record<string, string[]>\n): Record<string, QuestionnaireResponseItemAnswer[]> {\n if (!questionnaireResponse.item) return {};\n\n const initialValuesMap: Record<string, QuestionnaireResponseItemAnswer[]> = {};\n questionnaireResponse.item.forEach((item) => {\n readQuestionnaireResponseItemRecursive(item, initialValuesMap, linkedQuestionsMap);\n });\n return initialValuesMap;\n}\n\n/**\n * Read initial answer values of each qrItem recursively\n *\n * @author Sean Fong\n */\nfunction readQuestionnaireResponseItemRecursive(\n item: QuestionnaireResponseItem,\n initialValues: Record<string, QuestionnaireResponseItemAnswer[]>,\n linkedQuestionsMap: Record<string, string[]>\n) {\n const items = item.item;\n if (items && items.length > 0) {\n // iterate through items of item recursively\n items.forEach((item) => {\n readQuestionnaireResponseItemRecursive(item, initialValues, linkedQuestionsMap);\n });\n return;\n }\n\n // Read initial answer value of single qrItem\n if (linkedQuestionsMap[item.linkId] && item.answer) {\n initialValues[item.linkId] = item.answer;\n }\n\n return;\n}\n\n/**\n * Set initial answer values into enableWhenItems' answer attributes\n * Update enabled status of each enableWhenItem simultaneously\n *\n * @author Sean Fong\n */\nexport function setInitialAnswers(\n initialAnswers: Record<string, QuestionnaireResponseItemAnswer[]>,\n items: EnableWhenItems,\n linkedQuestionsMap: Record<string, string[]>\n): EnableWhenItems {\n let updatedItems = structuredClone(items);\n\n if (initialAnswers) {\n for (const linkId in initialAnswers) {\n const linkedQuestions = linkedQuestionsMap[linkId];\n const newAnswer = initialAnswers[linkId];\n\n updatedItems = updateEnableWhenItemAnswer(\n updatedItems,\n linkedQuestions,\n linkId,\n newAnswer,\n null\n );\n }\n }\n return updatedItems;\n}\n\n/**\n * Update answer of the target linkId in every related enableWhenItem's linked items\n * Then update the enabled status of every related enableWhenItem\n *\n * @author Sean Fong\n */\nexport function updateEnableWhenItemAnswer(\n items: EnableWhenItems,\n linkedQuestions: string[],\n linkId: string,\n newAnswer: QuestionnaireResponseItemAnswer[] | undefined,\n parentRepeatGroupIndex: number | null\n): EnableWhenItems {\n const { singleItems, repeatItems } = items;\n\n for (const linkedQuestion of linkedQuestions) {\n // Linked question is in single items\n if (singleItems[linkedQuestion]) {\n // Update modified linked answer\n singleItems[linkedQuestion].linked.forEach((linkedItem) => {\n if (linkedItem.enableWhen.question === linkId) {\n linkedItem.answer = newAnswer ?? undefined;\n }\n });\n\n // Update enabled status of modified enableWhenItem\n singleItems[linkedQuestion].isEnabled = checkItemIsEnabledSingle(singleItems[linkedQuestion]);\n continue;\n }\n\n // Linked question is in repeat items\n if (repeatItems[linkedQuestion] && parentRepeatGroupIndex !== null) {\n // Update modified linked answer\n repeatItems[linkedQuestion].linked.forEach((linkedItem) => {\n if (linkedItem.enableWhen.question === linkId) {\n if (newAnswer) {\n linkedItem.answers[parentRepeatGroupIndex] = newAnswer[0] ?? undefined;\n } else {\n delete linkedItem.answers[parentRepeatGroupIndex];\n }\n }\n });\n\n // Update enabled status of modified enableWhenItem\n repeatItems[linkedQuestion].enabledIndexes[parentRepeatGroupIndex] = checkItemIsEnabledRepeat(\n repeatItems[linkedQuestion],\n parentRepeatGroupIndex\n );\n }\n }\n\n return items;\n}\n\n/**\n * Check if a single enableWhenItem is enabled based on the answer of its linked items\n *\n * @author Sean Fong\n */\nexport function checkItemIsEnabledSingle(\n enableWhenItemProperties: EnableWhenSingleItemProperties\n): boolean {\n const checkedIsEnabledItems: boolean[] = [];\n\n // Check if linked item satisfies enableWhen condition\n for (const linkedItem of enableWhenItemProperties.linked) {\n let isEnabledForThisLinkedItem = false;\n\n // Linked item has answers\n if (linkedItem.answer && linkedItem.answer.length > 0) {\n // Check if linked answer within item satisfies enableWhen condition\n // Exit early once a linked answer is found to satisfy the condition\n for (const answer of linkedItem.answer) {\n const isEnabledForThisLinkedAnswer = isEnabledAnswerTypeSwitcher(\n linkedItem.enableWhen,\n answer\n );\n\n if (isEnabledForThisLinkedAnswer) {\n isEnabledForThisLinkedItem = true;\n break;\n }\n }\n\n // Push result of the linked item to the checkedIsEnabledItems array\n checkedIsEnabledItems.push(isEnabledForThisLinkedItem);\n\n continue;\n }\n\n // Linked item doesn't have any answers, but we still have to check for unanswered booleans\n const checkedNonExistentAnswer = evaluateNonExistentAnswers(linkedItem.enableWhen);\n checkedIsEnabledItems.push(checkedNonExistentAnswer);\n }\n\n if (checkedIsEnabledItems.length === 0) {\n return false;\n }\n\n return evaluateEnableBehaviour(checkedIsEnabledItems, enableWhenItemProperties.enableBehavior);\n}\n\n/**\n * Check if a repeat enableWhenItem is enabled based on the answer of its linked items\n *\n * @author Sean Fong\n */\nexport function checkItemIsEnabledRepeat(\n enableWhenItemProperties: EnableWhenRepeatItemProperties,\n parentRepeatGroupIndex: number\n): boolean {\n const checkedIsEnabledItems: boolean[] = [];\n\n for (const linkedItem of enableWhenItemProperties.linked) {\n const linkedAnswer = linkedItem.answers[parentRepeatGroupIndex];\n if (linkedAnswer) {\n const isEnabledForThisLinkedItem = isEnabledAnswerTypeSwitcher(\n linkedItem.enableWhen,\n linkedAnswer\n );\n\n if (isEnabledForThisLinkedItem) {\n checkedIsEnabledItems.push(\n isEnabledAnswerTypeSwitcher(linkedItem.enableWhen, linkedAnswer)\n );\n }\n continue;\n }\n\n // Linked item doesn't have any answers, but we still have to check for unanswered booleans\n if (evaluateNonExistentAnswers(linkedItem.enableWhen)) {\n checkedIsEnabledItems.push(true);\n }\n }\n\n if (checkedIsEnabledItems.length === 0) {\n return false;\n }\n\n return evaluateEnableBehaviour(checkedIsEnabledItems, enableWhenItemProperties.enableBehavior);\n}\n\nexport function assignPopulatedAnswersToEnableWhen(\n items: EnableWhenItems,\n questionnaireResponse: QuestionnaireResponse\n): { initialisedItems: EnableWhenItems; linkedQuestions: Record<string, string[]> } {\n const linkedQuestions = createEnableWhenLinkedQuestions(items);\n const initialAnswers = readInitialAnswers(questionnaireResponse, linkedQuestions);\n items = initialiseUnansweredBooleans(items);\n\n const initialisedItems =\n Object.keys(initialAnswers).length > 0\n ? setInitialAnswers(initialAnswers, items, linkedQuestions)\n : items;\n\n return { initialisedItems, linkedQuestions };\n}\n\nfunction initialiseUnansweredBooleans(items: EnableWhenItems): EnableWhenItems {\n const { singleItems, repeatItems } = items;\n\n // Initialise unanswered booleans for enableWhen single items\n for (const linkId in singleItems) {\n const checkedIsEnabledItems = singleItems[linkId].linked.map((linkedItem) =>\n evaluateNonExistentAnswers(linkedItem.enableWhen)\n );\n\n singleItems[linkId].isEnabled = evaluateEnableBehaviour(\n checkedIsEnabledItems,\n singleItems[linkId].enableBehavior\n );\n }\n\n // Initialise unanswered booleans for enableWhen repeat items\n for (const linkId in repeatItems) {\n const checkedIsEnabledItems = repeatItems[linkId].linked.map((linkedItem) =>\n evaluateNonExistentAnswers(linkedItem.enableWhen)\n );\n\n const isEnabled = evaluateEnableBehaviour(\n checkedIsEnabledItems,\n repeatItems[linkId].enableBehavior\n );\n repeatItems[linkId].enabledIndexes = repeatItems[linkId].enabledIndexes.map(() => isEnabled);\n }\n\n return items;\n}\n\n// Internal functions\nfunction evaluateNonExistentAnswers(enableWhen: QuestionnaireItemEnableWhen) {\n const unansweredBoolean =\n typeof enableWhen.answerBoolean === 'boolean' && enableWhen.operator === '!=';\n const unExistingAnswer = enableWhen.answerBoolean === false && enableWhen.operator === 'exists';\n return unansweredBoolean || unExistingAnswer;\n}\n\nfunction evaluateEnableBehaviour(\n isEnabledArr: boolean[],\n enableBehavior: 'all' | 'any' | undefined\n) {\n return enableBehavior === 'any'\n ? isEnabledArr.some((isEnabled) => isEnabled)\n : isEnabledArr.every((isEnabled) => isEnabled);\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fhirpath from 'fhirpath';\nimport fhirpath_r4_model from 'fhirpath/fhir-context/r4';\nimport type { Expression, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';\nimport type { CalculatedExpression } from '../interfaces/calculatedExpression.interface';\nimport type { EnableWhenExpressions } from '../interfaces/enableWhen.interface';\nimport { evaluateEnableWhenExpressions } from './enableWhenExpression';\nimport { evaluateCalculatedExpressions } from './calculatedExpression';\nimport { evaluateTargetConstraints } from './targetConstraint';\nimport type { TargetConstraint } from '../interfaces/targetConstraint.interface';\nimport type { Variables, VariableXFhirQuery } from '../interfaces';\nimport { evaluateDynamicValueSets } from './parameterisedValueSets';\nimport type { ComputedQRItemUpdates } from '../interfaces/computedUpdates.interface';\n\ninterface EvaluateUpdatedExpressionsParams {\n updatedResponse: QuestionnaireResponse;\n updatedResponseItemMap: Record<string, QuestionnaireResponseItem[]>;\n targetConstraints: Record<string, TargetConstraint>;\n calculatedExpressions: Record<string, CalculatedExpression[]>;\n enableWhenExpressions: EnableWhenExpressions;\n variables: Variables;\n processedValueSets: Record<string, any>;\n existingFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n terminologyServerUrl: string;\n}\n\nexport async function evaluateUpdatedExpressions(\n params: EvaluateUpdatedExpressionsParams\n): Promise<{\n isUpdated: boolean;\n updatedTargetConstraints: Record<string, TargetConstraint>;\n updatedEnableWhenExpressions: EnableWhenExpressions;\n updatedCalculatedExpressions: Record<string, CalculatedExpression[]>;\n updatedProcessedValueSets: Record<string, any>;\n updatedFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n computedQRItemUpdates: ComputedQRItemUpdates;\n}> {\n const {\n updatedResponse,\n updatedResponseItemMap,\n targetConstraints,\n enableWhenExpressions,\n calculatedExpressions,\n processedValueSets,\n variables,\n existingFhirPathContext,\n terminologyServerUrl\n } = params;\n let { fhirPathTerminologyCache } = params;\n\n const noExpressionsToBeUpdated =\n Object.keys(enableWhenExpressions).length === 0 &&\n Object.keys(calculatedExpressions).length === 0;\n if (noExpressionsToBeUpdated) {\n return {\n isUpdated: false,\n updatedTargetConstraints: targetConstraints,\n updatedEnableWhenExpressions: enableWhenExpressions,\n updatedCalculatedExpressions: calculatedExpressions,\n updatedProcessedValueSets: processedValueSets,\n updatedFhirPathContext: existingFhirPathContext,\n fhirPathTerminologyCache,\n computedQRItemUpdates: {}\n };\n }\n\n const computedQRItemUpdates: ComputedQRItemUpdates = {};\n const fhirPathEvalResult = await createFhirPathContext(\n updatedResponse,\n updatedResponseItemMap,\n variables,\n existingFhirPathContext,\n fhirPathTerminologyCache,\n terminologyServerUrl\n );\n\n const updatedFhirPathContext = fhirPathEvalResult.fhirPathContext;\n fhirPathTerminologyCache = fhirPathEvalResult.fhirPathTerminologyCache;\n\n // Update targetConstraints\n const { targetConstraintsIsUpdated, updatedTargetConstraints } = await evaluateTargetConstraints(\n updatedFhirPathContext,\n fhirPathTerminologyCache,\n targetConstraints,\n terminologyServerUrl\n );\n\n // Update enableWhenExpressions\n const { enableWhenExpsIsUpdated, updatedEnableWhenExpressions } =\n await evaluateEnableWhenExpressions(\n updatedFhirPathContext,\n fhirPathTerminologyCache,\n enableWhenExpressions,\n terminologyServerUrl\n );\n\n // Update calculatedExpressions\n const { calculatedExpsIsUpdated, updatedCalculatedExpressions } =\n await evaluateCalculatedExpressions(\n updatedFhirPathContext,\n fhirPathTerminologyCache,\n calculatedExpressions,\n terminologyServerUrl\n );\n\n // Update dynamic value sets\n const {\n processedValueSetsIsUpdated,\n updatedProcessedValueSets,\n computedNewAnswers: computedNewAnswersDynamicValueSets\n } = await evaluateDynamicValueSets(\n updatedFhirPathContext,\n fhirPathTerminologyCache,\n processedValueSets,\n terminologyServerUrl\n );\n\n // Have a process here to find their QRItems and assign updates based on the computedNewAnswers\n // In the case of dynamic value sets, just clear the existing answers\n // Eventually we want to expand this to calculatedExpressions\n for (const linkId in computedNewAnswersDynamicValueSets) {\n computedQRItemUpdates[linkId] = null;\n }\n\n const isUpdated =\n enableWhenExpsIsUpdated ||\n calculatedExpsIsUpdated ||\n targetConstraintsIsUpdated ||\n processedValueSetsIsUpdated;\n\n return {\n isUpdated,\n updatedTargetConstraints,\n updatedEnableWhenExpressions,\n updatedCalculatedExpressions,\n updatedProcessedValueSets,\n updatedFhirPathContext,\n fhirPathTerminologyCache,\n computedQRItemUpdates\n };\n}\n\nexport async function createFhirPathContext(\n questionnaireResponse: QuestionnaireResponse,\n questionnaireResponseItemMap: Record<string, QuestionnaireResponseItem[]>,\n variables: Variables,\n existingFhirPathContext: Record<string, any>,\n fhirPathTerminologyCache: Record<string, any>,\n terminologyServerUrl: string\n): Promise<{\n fhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n}> {\n const { fhirPathVariables: variablesFhirPath, xFhirQueryVariables: variablesXFhirQuery } =\n variables;\n\n // Add latest resource to fhirPathContext\n let fhirPathContext: Record<string, any> = {\n ...existingFhirPathContext,\n resource: questionnaireResponse,\n rootResource: questionnaireResponse\n };\n\n // Add empty x-fhir-query variables to fhirPathContext to prevent false-positive warnings\n fhirPathContext = addEmptyXFhirQueryVariablesToFhirPathContext(\n fhirPathContext,\n variablesXFhirQuery\n );\n\n // Evaluate resource-level variables\n const fhirPathEvalResult = await evaluateQuestionnaireLevelVariables(\n questionnaireResponse,\n variablesFhirPath,\n fhirPathContext,\n fhirPathTerminologyCache,\n terminologyServerUrl\n );\n fhirPathContext = fhirPathEvalResult.fhirPathContext;\n fhirPathTerminologyCache = fhirPathEvalResult.fhirPathTerminologyCache;\n\n // Add variables of items that exist in questionnaireResponseItemMap into fhirPathContext\n for (const linkId in questionnaireResponseItemMap) {\n const qrItems = questionnaireResponseItemMap[linkId] ?? [];\n\n // Ensure at least one iteration even if qrItems is empty\n const qrItemsToProcess = qrItems.length > 0 ? qrItems : [undefined];\n\n // For non-repeat groups, the same linkId will have only one item\n // For repeat groups, the same linkId will have multiple items\n for (const qrItem of qrItemsToProcess) {\n const fhirPathEvalResult = await evaluateLinkIdVariables(\n linkId,\n variablesFhirPath,\n fhirPathContext,\n fhirPathTerminologyCache,\n terminologyServerUrl,\n qrItem\n );\n fhirPathContext = fhirPathEvalResult.fhirPathContext;\n fhirPathTerminologyCache = fhirPathEvalResult.fhirPathTerminologyCache;\n }\n }\n\n return { fhirPathContext, fhirPathTerminologyCache };\n}\n\nexport function addEmptyXFhirQueryVariablesToFhirPathContext(\n fhirPathContext: Record<string, any>,\n variablesXFhirQuery: Record<string, VariableXFhirQuery>\n) {\n for (const variableName in variablesXFhirQuery) {\n if (!fhirPathContext[variableName]) {\n fhirPathContext[variableName] = [];\n }\n }\n\n return fhirPathContext;\n}\n\nexport async function evaluateLinkIdVariables(\n linkId: string,\n variablesFhirPath: Record<string, Expression[]>,\n fhirPathContext: Record<string, any>,\n fhirPathTerminologyCache: Record<string, any>,\n terminologyServerUrl: string,\n qrItem?: QuestionnaireResponseItem\n) {\n const linkIdVariables = variablesFhirPath[linkId];\n if (!linkIdVariables || linkIdVariables.length === 0) {\n return { fhirPathContext, fhirPathTerminologyCache };\n }\n\n for (const variable of linkIdVariables) {\n if (variable.expression && variable.name) {\n const cacheKey = JSON.stringify(variable.expression); // Use expression as cache key\n if (fhirPathTerminologyCache[cacheKey]) {\n continue;\n }\n\n try {\n const fhirPathResult = fhirpath.evaluate(\n qrItem ?? {},\n {\n base: 'QuestionnaireResponse.item',\n expression: variable.expression\n },\n fhirPathContext,\n fhirpath_r4_model,\n {\n async: true,\n terminologyUrl: terminologyServerUrl\n }\n );\n fhirPathContext[`${variable.name}`] = await handleFhirPathResult(fhirPathResult);\n\n // If fhirPathResult is an async terminology call, cache the result\n if (fhirPathResult instanceof Promise) {\n fhirPathTerminologyCache[cacheKey] = fhirPathContext[`${variable.name}`];\n }\n } catch (e) {\n console.warn(e.message, `LinkId: ${linkId}\\nExpression: ${variable.expression}`);\n }\n }\n }\n\n return { fhirPathContext, fhirPathTerminologyCache };\n}\n\nexport async function evaluateQuestionnaireLevelVariables(\n resource: QuestionnaireResponse,\n variablesFhirPath: Record<string, Expression[]>,\n fhirPathContext: Record<string, any>,\n fhirPathTerminologyCache: Record<string, any>,\n terminologyServerUrl: string\n) {\n const questionnaireLevelVariables = variablesFhirPath['QuestionnaireLevel'];\n if (!questionnaireLevelVariables || questionnaireLevelVariables.length === 0) {\n return {\n fhirPathContext,\n fhirPathTerminologyCache\n };\n }\n\n for (const variable of questionnaireLevelVariables) {\n if (variable.expression) {\n const cacheKey = JSON.stringify(variable.expression); // Use expression as cache key\n if (fhirPathTerminologyCache[cacheKey]) {\n continue;\n }\n\n try {\n const fhirPathResult = fhirpath.evaluate(\n resource,\n {\n base: 'QuestionnaireResponse',\n expression: variable.expression\n },\n fhirPathContext,\n fhirpath_r4_model,\n {\n async: true,\n terminologyUrl: terminologyServerUrl\n }\n );\n\n fhirPathContext[`${variable.name}`] = await handleFhirPathResult(fhirPathResult);\n\n // If fhirPathResult is an async terminology call, cache the result\n if (fhirPathResult instanceof Promise) {\n fhirPathTerminologyCache[cacheKey] = fhirPathContext[`${variable.name}`];\n }\n } catch (e) {\n console.warn(e.message, `Questionnaire-level\\nExpression: ${variable.expression}`);\n }\n }\n }\n\n return {\n fhirPathContext,\n fhirPathTerminologyCache\n };\n}\n\nexport async function handleFhirPathResult(result: any[] | Promise<any[]>) {\n if (result instanceof Promise) {\n return await result;\n }\n\n return result;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createFhirPathContext, handleFhirPathResult } from './fhirpath';\nimport fhirpath from 'fhirpath';\nimport fhirpath_r4_model from 'fhirpath/fhir-context/r4';\nimport type {\n EnableWhenExpressions,\n EnableWhenRepeatExpression,\n EnableWhenSingleExpression\n} from '../interfaces/enableWhen.interface';\nimport type { Variables } from '../interfaces';\n\ninterface EvaluateInitialEnableWhenExpressionsParams {\n initialResponse: QuestionnaireResponse;\n initialResponseItemMap: Record<string, QuestionnaireResponseItem[]>;\n enableWhenExpressions: EnableWhenExpressions;\n variables: Variables;\n existingFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n terminologyServerUrl: string;\n}\n\nexport async function evaluateInitialEnableWhenExpressions(\n params: EvaluateInitialEnableWhenExpressionsParams\n): Promise<{\n initialEnableWhenExpressions: EnableWhenExpressions;\n updatedFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n}> {\n const {\n initialResponse,\n initialResponseItemMap,\n enableWhenExpressions,\n variables,\n existingFhirPathContext,\n terminologyServerUrl\n } = params;\n let { fhirPathTerminologyCache } = params;\n\n const initialEnableWhenExpressions: EnableWhenExpressions = {\n ...enableWhenExpressions\n };\n const fhirPathEvalResult = await createFhirPathContext(\n initialResponse,\n initialResponseItemMap,\n variables,\n existingFhirPathContext,\n fhirPathTerminologyCache,\n terminologyServerUrl\n );\n const updatedFhirPathContext = fhirPathEvalResult.fhirPathContext;\n fhirPathTerminologyCache = fhirPathEvalResult.fhirPathTerminologyCache;\n\n const initialEnableWhenSingleExpressions = await evaluateEnableWhenSingleExpressions(\n initialEnableWhenExpressions.singleExpressions,\n updatedFhirPathContext,\n fhirPathTerminologyCache,\n terminologyServerUrl\n );\n\n const initialEnableWhenRepeatExpressions = await evaluateEnableWhenRepeatExpressions(\n initialEnableWhenExpressions.repeatExpressions,\n updatedFhirPathContext,\n terminologyServerUrl\n );\n\n return {\n initialEnableWhenExpressions: {\n singleExpressions: initialEnableWhenSingleExpressions.updatedExpressions,\n repeatExpressions: initialEnableWhenRepeatExpressions.updatedExpressions\n },\n updatedFhirPathContext,\n fhirPathTerminologyCache\n };\n}\n\nasync function evaluateEnableWhenSingleExpressions(\n enableWhenSingleExpressions: Record<string, EnableWhenSingleExpression>,\n updatedFhirPathContext: Record<string, any>,\n fhirPathTerminologyCache: Record<string, any>,\n terminologyServerUrl: string\n): Promise<{\n updatedExpressions: Record<string, EnableWhenSingleExpression>;\n isUpdated: boolean;\n}> {\n let isUpdated = false;\n for (const linkId in enableWhenSingleExpressions) {\n const initialValue = enableWhenSingleExpressions[linkId].isEnabled;\n const expression = enableWhenSingleExpressions[linkId].expression;\n\n const cacheKey = JSON.stringify(expression); // Use expression as cache key\n if (fhirPathTerminologyCache[cacheKey]) {\n continue;\n }\n\n try {\n const fhirPathResult = fhirpath.evaluate(\n {},\n expression,\n updatedFhirPathContext,\n fhirpath_r4_model,\n {\n async: true,\n terminologyUrl: terminologyServerUrl\n }\n );\n const result = await handleFhirPathResult(fhirPathResult);\n\n // If fhirPathResult is an async terminology call, cache the result\n if (fhirPathResult instanceof Promise) {\n fhirPathTerminologyCache[cacheKey] = result;\n }\n\n // Update enableWhenExpressions if length of result array > 0\n // Only update when current isEnabled value is different from the result, otherwise it will result in an infinite loop as per issue #733\n if (result.length > 0 && initialValue !== result[0] && typeof result[0] === 'boolean') {\n enableWhenSingleExpressions[linkId].isEnabled = result[0];\n isUpdated = true;\n }\n\n // Update isEnabled value to false if no result is returned\n if (result.length === 0 && initialValue !== false) {\n enableWhenSingleExpressions[linkId].isEnabled = false;\n isUpdated = true;\n }\n\n // handle intersect edge case - evaluate() returns empty array if result is false\n if (\n enableWhenSingleExpressions[linkId].expression.includes('intersect') &&\n result.length === 0 &&\n initialValue !== false\n ) {\n enableWhenSingleExpressions[linkId].isEnabled = false;\n isUpdated = true;\n }\n } catch (e) {\n console.warn(\n e.message,\n `LinkId: ${linkId}\\nExpression: ${enableWhenSingleExpressions[linkId].expression}`\n );\n }\n }\n\n return { updatedExpressions: enableWhenSingleExpressions, isUpdated };\n}\n\nasync function getNumOfEnableWhenExpressionItemInstances(\n enableWhenExpression: EnableWhenRepeatExpression,\n fhirPathContext: Record<string, any>,\n terminologyServerUrl: string\n) {\n const fhirPathResult = fhirpath.evaluate(\n {},\n `%resource.descendants().where(linkId = '${enableWhenExpression.parentLinkId}').count()`,\n fhirPathContext,\n fhirpath_r4_model,\n {\n async: true,\n terminologyUrl: terminologyServerUrl\n }\n );\n const result = await handleFhirPathResult(fhirPathResult);\n\n return typeof result[0] === 'number' ? result[0] : null;\n}\n\nasync function evaluateEnableWhenRepeatExpressions(\n enableWhenRepeatExpressions: Record<string, EnableWhenRepeatExpression>,\n fhirPathContext: Record<string, any>,\n terminologyServerUrl: string\n): Promise<{\n updatedExpressions: Record<string, EnableWhenRepeatExpression>;\n isUpdated: boolean;\n}> {\n let aggregatedUpdated = false;\n for (const linkId in enableWhenRepeatExpressions) {\n // Get number of repeat group instances in the QR\n const enableWhenExpression = enableWhenRepeatExpressions[linkId];\n\n const numOfInstances = await getNumOfEnableWhenExpressionItemInstances(\n enableWhenExpression,\n fhirPathContext,\n terminologyServerUrl\n );\n if (!numOfInstances) {\n continue;\n }\n\n const lastLinkIdIndex = enableWhenExpression.expression.lastIndexOf('.where(linkId');\n if (lastLinkIdIndex === -1) {\n continue;\n }\n\n for (let i = 0; i < numOfInstances; i++) {\n const { isEnabled, isUpdated } = await evaluateEnableWhenRepeatExpressionInstance(\n linkId,\n fhirPathContext,\n enableWhenExpression,\n lastLinkIdIndex,\n i,\n terminologyServerUrl\n );\n\n if (typeof isEnabled === 'boolean') {\n enableWhenRepeatExpressions[linkId].enabledIndexes[i] = isEnabled;\n }\n\n aggregatedUpdated = aggregatedUpdated || isUpdated;\n }\n }\n\n return { updatedExpressions: enableWhenRepeatExpressions, isUpdated: aggregatedUpdated };\n}\n\nexport async function evaluateEnableWhenRepeatExpressionInstance(\n linkId: string,\n fhirPathContext: Record<string, any>,\n enableWhenRepeatExpression: EnableWhenRepeatExpression,\n lastLinkIdIndex: number,\n instanceIndex: number,\n terminologyServerUrl: string\n): Promise<{ isEnabled: boolean | null; isUpdated: boolean }> {\n const expression = enableWhenRepeatExpression.expression;\n const parentLinkId = enableWhenRepeatExpression.parentLinkId;\n const initialValue = enableWhenRepeatExpression.enabledIndexes[instanceIndex];\n\n const modifiedExpression =\n expression.slice(0, lastLinkIdIndex) +\n `.where(linkId='${parentLinkId}').item[${instanceIndex}]` +\n expression.slice(lastLinkIdIndex);\n\n let isEnabled = null;\n let isUpdated = false;\n try {\n const fhirPathResult = fhirpath.evaluate(\n {},\n modifiedExpression,\n fhirPathContext,\n fhirpath_r4_model,\n {\n async: true,\n terminologyUrl: terminologyServerUrl\n }\n );\n const result = await handleFhirPathResult(fhirPathResult);\n\n // Update enableWhenExpressions if length of result array > 0\n // Only update when current isEnabled value is different from the result, otherwise it will result in am infinite loop as per #733\n if (result.length > 0 && initialValue !== result[0] && typeof result[0] === 'boolean') {\n isEnabled = result[0];\n isUpdated = true;\n }\n\n // Update isEnabled value to false if no result is returned\n if (result.length === 0 && initialValue !== false) {\n isEnabled = false;\n isUpdated = true;\n }\n\n // handle intersect edge case - evaluate() returns empty array if result is false\n if (expression.includes('intersect') && result.length === 0 && initialValue !== result[0]) {\n isEnabled = false;\n isUpdated = true;\n }\n } catch (e) {\n console.warn(e.message, `LinkId: ${linkId}\\nExpression: ${expression}`);\n }\n\n return { isEnabled, isUpdated };\n}\n\nexport async function evaluateEnableWhenExpressions(\n fhirPathContext: Record<string, any>,\n fhirPathTerminologyCache: Record<string, any>,\n enableWhenExpressions: EnableWhenExpressions,\n terminologyServerUrl: string\n): Promise<{\n enableWhenExpsIsUpdated: boolean;\n updatedEnableWhenExpressions: EnableWhenExpressions;\n}> {\n const updatedEnableWhenExpressions: EnableWhenExpressions = {\n ...enableWhenExpressions\n };\n\n const updatedEnableWhenSingleExpressions = await evaluateEnableWhenSingleExpressions(\n updatedEnableWhenExpressions.singleExpressions,\n fhirPathContext,\n fhirPathTerminologyCache,\n terminologyServerUrl\n );\n\n const updatedEnableWhenRepeatExpressions = await evaluateEnableWhenRepeatExpressions(\n updatedEnableWhenExpressions.repeatExpressions,\n fhirPathContext,\n terminologyServerUrl\n );\n\n const isUpdated =\n updatedEnableWhenSingleExpressions.isUpdated || updatedEnableWhenRepeatExpressions.isUpdated;\n\n return {\n enableWhenExpsIsUpdated: isUpdated,\n updatedEnableWhenExpressions: {\n singleExpressions: updatedEnableWhenSingleExpressions.updatedExpressions,\n repeatExpressions: updatedEnableWhenRepeatExpressions.updatedExpressions\n }\n };\n}\n\ninterface MutateRepeatEnableWhenExpressionInstancesParams {\n questionnaireResponse: QuestionnaireResponse;\n questionnaireResponseItemMap: Record<string, QuestionnaireResponseItem[]>;\n variables: Variables;\n existingFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n enableWhenExpressions: EnableWhenExpressions;\n parentRepeatGroupLinkId: string;\n parentRepeatGroupIndex: number;\n actionType: 'add' | 'remove';\n terminologyServerUrl: string;\n}\n\nexport async function mutateRepeatEnableWhenExpressionInstances(\n params: MutateRepeatEnableWhenExpressionInstancesParams\n): Promise<{ updatedEnableWhenExpressions: EnableWhenExpressions; isUpdated: boolean }> {\n const {\n questionnaireResponse,\n questionnaireResponseItemMap,\n variables,\n fhirPathTerminologyCache,\n existingFhirPathContext,\n enableWhenExpressions,\n parentRepeatGroupLinkId,\n parentRepeatGroupIndex,\n actionType,\n terminologyServerUrl\n } = params;\n\n const { repeatExpressions } = enableWhenExpressions;\n\n const fhirPathEvalResult = await createFhirPathContext(\n questionnaireResponse,\n questionnaireResponseItemMap,\n variables,\n existingFhirPathContext,\n fhirPathTerminologyCache,\n terminologyServerUrl\n );\n\n const updatedFhirPathContext = fhirPathEvalResult.fhirPathContext;\n\n let isUpdated = false;\n for (const linkId in repeatExpressions) {\n if (repeatExpressions[linkId].parentLinkId !== parentRepeatGroupLinkId) {\n continue;\n }\n\n if (actionType === 'add') {\n const { isEnabled } = await evaluateEnableWhenRepeatExpressionInstance(\n linkId,\n updatedFhirPathContext,\n repeatExpressions[linkId],\n repeatExpressions[linkId].expression.lastIndexOf('.where(linkId'),\n parentRepeatGroupIndex,\n terminologyServerUrl\n );\n\n if (typeof isEnabled === 'boolean') {\n repeatExpressions[linkId].enabledIndexes[parentRepeatGroupIndex] = isEnabled;\n }\n } else if (actionType === 'remove') {\n repeatExpressions[linkId].enabledIndexes.splice(parentRepeatGroupIndex, 1);\n }\n\n isUpdated = true;\n }\n\n return { updatedEnableWhenExpressions: enableWhenExpressions, isUpdated };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { CalculatedExpression } from '../interfaces/calculatedExpression.interface';\nimport fhirpath from 'fhirpath';\nimport fhirpath_r4_model from 'fhirpath/fhir-context/r4';\nimport type {\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponse,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport { emptyResponse } from './emptyResource';\nimport { createFhirPathContext, handleFhirPathResult } from './fhirpath';\nimport { getQrItemsIndex, mapQItemsIndex } from './mapItem';\nimport { createEmptyQrGroup, updateQrItemsInGroup } from './qrItem';\nimport dayjs from 'dayjs';\nimport { updateQuestionnaireResponse } from './genericRecursive';\nimport isEqual from 'lodash.isequal';\nimport type { Variables } from '../interfaces';\n\ninterface EvaluateInitialCalculatedExpressionsParams {\n initialResponse: QuestionnaireResponse;\n initialResponseItemMap: Record<string, QuestionnaireResponseItem[]>;\n calculatedExpressions: Record<string, CalculatedExpression[]>;\n variables: Variables;\n existingFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n terminologyServerUrl: string;\n}\n\nexport async function evaluateInitialCalculatedExpressions(\n params: EvaluateInitialCalculatedExpressionsParams\n): Promise<{\n initialCalculatedExpressions: Record<string, CalculatedExpression[]>;\n updatedFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n}> {\n const {\n initialResponse,\n initialResponseItemMap,\n calculatedExpressions,\n variables,\n existingFhirPathContext,\n terminologyServerUrl\n } = params;\n let { fhirPathTerminologyCache } = params;\n\n // Return early if initialResponse is empty or there are no calculated expressions to evaluate\n if (\n isEqual(initialResponse, structuredClone(emptyResponse)) ||\n Object.keys(calculatedExpressions).length === 0\n ) {\n return {\n initialCalculatedExpressions: calculatedExpressions,\n updatedFhirPathContext: existingFhirPathContext,\n fhirPathTerminologyCache\n };\n }\n\n const initialCalculatedExpressions: Record<string, CalculatedExpression[]> = {\n ...calculatedExpressions\n };\n\n const fhirPathEvalResult = await createFhirPathContext(\n initialResponse,\n initialResponseItemMap,\n variables,\n existingFhirPathContext,\n fhirPathTerminologyCache,\n terminologyServerUrl\n );\n const updatedFhirPathContext = fhirPathEvalResult.fhirPathContext;\n fhirPathTerminologyCache = fhirPathEvalResult.fhirPathTerminologyCache;\n\n for (const linkId in initialCalculatedExpressions) {\n const itemCalcExpressions = calculatedExpressions[linkId];\n\n for (const calcExpression of itemCalcExpressions) {\n const cacheKey = JSON.stringify(calcExpression.expression); // Use expression as cache key\n if (fhirPathTerminologyCache[cacheKey]) {\n continue;\n }\n\n try {\n const fhirPathResult = fhirpath.evaluate(\n {},\n calcExpression.expression,\n updatedFhirPathContext,\n fhirpath_r4_model,\n {\n async: true,\n terminologyUrl: terminologyServerUrl\n }\n );\n const result = await handleFhirPathResult(fhirPathResult);\n\n // If fhirPathResult is an async terminology call, cache the result\n if (fhirPathResult instanceof Promise) {\n fhirPathTerminologyCache[cacheKey] = result;\n }\n\n // Only update calculatedExpressions if length of result array > 0\n if (result.length > 0 && !isEqual(calcExpression.value, result[0])) {\n calcExpression.value = result[0];\n }\n } catch (e) {\n console.warn(e.message, `LinkId: ${linkId}\\nExpression: ${calcExpression.expression}`);\n }\n }\n\n initialCalculatedExpressions[linkId] = itemCalcExpressions;\n }\n\n return {\n initialCalculatedExpressions,\n updatedFhirPathContext,\n fhirPathTerminologyCache\n };\n}\n\nexport async function evaluateCalculatedExpressions(\n fhirPathContext: Record<string, any>,\n fhirPathTerminologyCache: Record<string, any>,\n calculatedExpressions: Record<string, CalculatedExpression[]>,\n terminologyServerUrl: string\n): Promise<{\n calculatedExpsIsUpdated: boolean;\n updatedCalculatedExpressions: Record<string, CalculatedExpression[]>;\n}> {\n const updatedCalculatedExpressions: Record<string, CalculatedExpression[]> = {\n ...calculatedExpressions\n };\n\n let isUpdated = false;\n for (const linkId in calculatedExpressions) {\n const itemCalcExpressions = calculatedExpressions[linkId];\n\n for (const calcExpression of itemCalcExpressions) {\n const cacheKey = JSON.stringify(calcExpression.expression); // Use expression as cache key\n if (fhirPathTerminologyCache[cacheKey]) {\n continue;\n }\n\n try {\n const fhirPathResult = fhirpath.evaluate(\n {},\n calcExpression.expression,\n fhirPathContext,\n fhirpath_r4_model,\n {\n async: true,\n terminologyUrl: terminologyServerUrl\n }\n );\n const result = await handleFhirPathResult(fhirPathResult);\n\n // If fhirPathResult is an async terminology call, cache the result\n if (fhirPathResult instanceof Promise) {\n fhirPathTerminologyCache[cacheKey] = result;\n }\n\n // Update calculatedExpressions if length of result array > 0\n // Only update when current calcExpression value is different from the result, otherwise it will result in an infinite loop as per issue #733\n if (result.length > 0 && !isEqual(calcExpression.value, result[0])) {\n isUpdated = true;\n calcExpression.value = result[0];\n }\n\n // Update calculatedExpression value to null if no result is returned\n if (result.length === 0 && calcExpression.value !== null) {\n isUpdated = true;\n calcExpression.value = null;\n }\n } catch (e) {\n console.warn(e.message, `LinkId: ${linkId}\\nExpression: ${calcExpression.expression}`);\n }\n }\n\n updatedCalculatedExpressions[linkId] = itemCalcExpressions;\n }\n\n return {\n calculatedExpsIsUpdated: isUpdated,\n updatedCalculatedExpressions: updatedCalculatedExpressions\n };\n}\n\nexport function initialiseCalculatedExpressionValues(\n questionnaire: Questionnaire,\n populatedResponse: QuestionnaireResponse,\n calculatedExpressions: Record<string, CalculatedExpression[]>\n): QuestionnaireResponse {\n // Filter calculated expressions, only preserve key-value pairs with values\n const calculatedExpressionsWithValues: Record<string, CalculatedExpression[]> = {};\n for (const linkId in calculatedExpressions) {\n const itemCalcExpressionsWithValues = calculatedExpressions[linkId].filter(\n (calcExpression) => calcExpression.value !== undefined\n );\n\n if (itemCalcExpressionsWithValues.length > 0) {\n calculatedExpressionsWithValues[linkId] = itemCalcExpressionsWithValues;\n }\n }\n\n return updateQuestionnaireResponse(\n questionnaire,\n populatedResponse,\n initialiseItemCalculatedExpressionValueRecursive,\n calculatedExpressionsWithValues\n );\n}\n\nfunction initialiseItemCalculatedExpressionValueRecursive(\n qItem: QuestionnaireItem,\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null,\n calculatedExpressions: Record<string, CalculatedExpression[]>\n): QuestionnaireResponseItem | QuestionnaireResponseItem[] | null {\n // For repeat groups\n const hasMultipleAnswers = Array.isArray(qrItemOrItems);\n if (hasMultipleAnswers) {\n const updatedQrItems = initialiseItemCalculatedExpressionValueInRepeatGroup(\n qItem,\n qrItemOrItems,\n calculatedExpressions\n );\n return constructGroupItem(\n qItem,\n updatedQrItems\n ? {\n linkId: qItem.linkId,\n text: qItem.text,\n item: updatedQrItems\n }\n : null,\n calculatedExpressions\n );\n }\n\n let qrItem = qrItemOrItems;\n const childQItems = qItem.item;\n if (childQItems && childQItems.length > 0) {\n qrItem = qrItemOrItems ?? structuredClone(createEmptyQrGroup(qItem));\n const childQrItems = qrItem.item ?? [];\n\n const indexMap = mapQItemsIndex(qItem);\n const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap);\n\n // Otherwise loop through qItem as usual\n for (const [index, childQItem] of childQItems.entries()) {\n const childQRItemOrItems = qrItemsByIndex[index];\n\n const updatedChildQRItemOrItems = initialiseItemCalculatedExpressionValueRecursive(\n childQItem,\n childQRItemOrItems ?? null,\n calculatedExpressions\n );\n\n // Update QR items in repeating group\n if (Array.isArray(updatedChildQRItemOrItems)) {\n if (updatedChildQRItemOrItems.length > 0) {\n updateQrItemsInGroup(\n null,\n {\n linkId: childQItem.linkId,\n qrItems: updatedChildQRItemOrItems\n },\n qrItem,\n indexMap\n );\n }\n continue;\n }\n\n // Update QR items in non-repeating group\n const updatedChildQRItem = updatedChildQRItemOrItems;\n if (updatedChildQRItem) {\n updateQrItemsInGroup(updatedChildQRItem, null, qrItem, indexMap);\n }\n }\n\n return constructGroupItem(qItem, qrItem, calculatedExpressions);\n }\n\n return constructSingleItem(qItem, qrItem, calculatedExpressions);\n}\n\nfunction initialiseItemCalculatedExpressionValueInRepeatGroup(\n qItem: QuestionnaireItem,\n qrItems: QuestionnaireResponseItem[],\n calculatedExpressions: Record<string, CalculatedExpression[]>\n): QuestionnaireResponseItem[] | null {\n if (!qItem.item) {\n return [];\n }\n\n const indexMap = mapQItemsIndex(qItem);\n const qrItemsByIndex = getQrItemsIndex(qItem.item, qrItems, indexMap);\n const updatedQrItems: QuestionnaireResponseItem[] = [];\n\n for (const [index, childQItem] of qItem.item.entries()) {\n const childQRItemOrItems = qrItemsByIndex[index] ?? null;\n\n const updatedChildQRItemOrItems = initialiseItemCalculatedExpressionValueRecursive(\n childQItem,\n childQRItemOrItems,\n calculatedExpressions\n );\n\n if (Array.isArray(updatedChildQRItemOrItems)) {\n updatedQrItems.push(...updatedChildQRItemOrItems);\n } else if (updatedChildQRItemOrItems) {\n updatedQrItems.push(updatedChildQRItemOrItems);\n }\n }\n\n return updatedQrItems.length > 0 ? updatedQrItems : null;\n}\n\nfunction getCalculatedExpressionAnswer(\n qItem: QuestionnaireItem,\n calculatedExpressions: Record<string, CalculatedExpression[]>\n): QuestionnaireResponseItemAnswer | undefined {\n const calcExpressionFromItem = calculatedExpressions[qItem.linkId]?.find(\n (calcExpression) => calcExpression.from === 'item'\n );\n\n if (calcExpressionFromItem) {\n // If value is undefined or null, do not return anything\n if (calcExpressionFromItem?.value === undefined || calcExpressionFromItem.value === null) {\n return;\n }\n\n // Otherwise there is a value (including 0 and empty strings)\n return parseValueToAnswer(qItem, calcExpressionFromItem.value);\n }\n\n return;\n}\n\nfunction constructGroupItem(\n qItem: QuestionnaireItem,\n qrItem: QuestionnaireResponseItem | null,\n calculatedExpressions: Record<string, CalculatedExpression[]>\n): QuestionnaireResponseItem | null {\n const calculatedExpressionAnswer = getCalculatedExpressionAnswer(qItem, calculatedExpressions);\n\n // If group item has an existing answer, do not overwrite it with calculated expression value\n if (qrItem?.answer && qrItem?.answer.length > 0) {\n return qrItem ?? null;\n }\n\n if (!calculatedExpressionAnswer) {\n return qrItem ?? null;\n }\n\n if (qrItem) {\n return {\n ...qrItem,\n answer: [calculatedExpressionAnswer]\n };\n }\n\n return {\n linkId: qItem.linkId,\n text: qItem.text,\n answer: [calculatedExpressionAnswer]\n };\n}\n\nfunction constructSingleItem(\n qItem: QuestionnaireItem,\n qrItem: QuestionnaireResponseItem | null,\n calculatedExpressions: Record<string, CalculatedExpression[]>\n): QuestionnaireResponseItem | null {\n const calculatedExpressionAnswer = getCalculatedExpressionAnswer(qItem, calculatedExpressions);\n if (!calculatedExpressionAnswer) {\n return qrItem ?? null;\n }\n\n return {\n linkId: qItem.linkId,\n text: qItem.text,\n answer: [calculatedExpressionAnswer]\n };\n}\n\n// duplicate functions in sdc-populate\nfunction parseValueToAnswer(qItem: QuestionnaireItem, value: any): QuestionnaireResponseItemAnswer {\n if (qItem.answerOption) {\n const answerOption = qItem.answerOption.find(\n (option: QuestionnaireItemAnswerOption) =>\n option.valueCoding?.code === value?.code ||\n // Handle case where valueCoding.code is not available\n (!option.valueCoding?.code && option.valueCoding?.display === value?.display)\n );\n\n if (answerOption) {\n return answerOption;\n }\n }\n\n if (typeof value === 'boolean' && qItem.type === 'boolean') {\n return { valueBoolean: value };\n }\n\n if (typeof value === 'number') {\n if (qItem.type === 'decimal') {\n return { valueDecimal: value };\n }\n if (qItem.type === 'integer') {\n return { valueInteger: value };\n }\n }\n\n if (typeof value === 'object' && value.unit) {\n return { valueQuantity: value };\n }\n\n if (typeof value === 'object' && value.system && value.code) {\n return { valueCoding: value };\n }\n\n // Value is string at this point\n if (qItem.type === 'date' && checkIsDateTime(value)) {\n return { valueDate: value };\n }\n\n if (qItem.type === 'dateTime' && checkIsDateTime(value)) {\n return { valueDateTime: value };\n }\n\n if (qItem.type === 'time' && checkIsTime(value)) {\n return { valueTime: value };\n }\n\n return { valueString: value };\n}\n\n/**\n * Check if an answer is a datetime in the format YYYY, YYYY-MM, YYYY-MM-DD, YYYY-MM-DDThh:mm:ss+zz:zz\n *\n * @author Sean Fong\n */\nexport function checkIsDateTime(value: string): boolean {\n const acceptedFormats = ['YYYY', 'YYYY-MM', 'YYYY-MM-DD', 'YYYY-MM-DDTHH:mm:ssZ'];\n const formattedDate = dayjs(value).format();\n return dayjs(formattedDate, acceptedFormats, true).isValid();\n}\n\n/**\n * Check if an answer is in a time format - Regex: ([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?\n *\n * @author Sean Fong\n */\nexport function checkIsTime(value: string): boolean {\n const timeRegex = /^([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?$/;\n return timeRegex.test(value);\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';\n\nexport const emptyQuestionnaire: Questionnaire = {\n resourceType: 'Questionnaire',\n status: 'draft'\n};\n\nexport const emptyResponse: QuestionnaireResponse = {\n resourceType: 'QuestionnaireResponse',\n status: 'in-progress'\n};\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Coding, Extension, QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport type { RegexValidation } from '../interfaces/regex.interface';\nimport { structuredDataCapture } from 'fhir-sdc-helpers';\nimport { default as htmlParse } from 'html-react-parser';\n\nfunction hasDisplayCategory(qItem: QuestionnaireItem): boolean {\n return !!qItem.extension?.some(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory'\n );\n}\n\nfunction hasItemControl(qItem: QuestionnaireItem): boolean {\n return !!qItem.extension?.some(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl'\n );\n}\n\n// If all nested items are of type display and have itemControl, then they should not be rendered\nexport function shouldRenderNestedItems(qItem: QuestionnaireItem): boolean {\n return !qItem.item?.every(\n (childItem) =>\n childItem.type === 'display' && (hasDisplayCategory(childItem) || hasItemControl(childItem))\n );\n}\n\n/**\n * Check if the extension has an itemControl code equal to the given itemControlCode\n *\n * @author Sean Fong\n */\nexport function isSpecificItemControl(qItem: QuestionnaireItem, itemControlCode: string): boolean {\n const itemControl = qItem?.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl'\n );\n if (itemControl) {\n const code = itemControl.valueCodeableConcept?.coding?.find(\n (coding: Coding) => coding.code === itemControlCode\n );\n if (code) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if the extension has an displayCategory code equal to the given displayCategory\n *\n * @author Sean Fong\n */\nexport function isSpecificDisplayCategory(\n qItem: QuestionnaireItem,\n itemControlCode: string\n): boolean {\n const displayCategory = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory'\n );\n if (displayCategory) {\n const code = displayCategory.valueCodeableConcept?.coding?.find(\n (coding: Coding) => coding.code === itemControlCode\n );\n if (code) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if the extension has url for items that use shortText\n *\n * @author Sean Fong\n */\nexport function getShortText(qItem: QuestionnaireItem): string | null {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-shortText'\n );\n if (itemControl) {\n if (itemControl.valueString) {\n return itemControl.valueString;\n }\n }\n return null;\n}\n\n/**\n * Check if the extension has url for hidden questions\n *\n * @author Sean Fong\n */\nexport function hasHiddenExtension(qItem: QuestionnaireItem): boolean {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-hidden'\n );\n\n if (itemControl) {\n if (itemControl.valueBoolean) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if the extension has url for items that use open label\n *\n * @author Sean Fong\n */\nexport function getOpenLabelText(qItem: QuestionnaireItem): string | null {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-openLabel'\n );\n if (itemControl) {\n if (itemControl.valueString) {\n return itemControl.valueString;\n }\n }\n return null;\n}\n\n/**\n * Check if the decimal value has a quantity precision for the decimal value\n *\n * @author Sean Fong\n */\nexport function getDecimalPrecision(qItem: QuestionnaireItem): number | null {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/quantity-precision'\n );\n if (itemControl) {\n if (itemControl.valueInteger) {\n return itemControl.valueInteger;\n }\n }\n return null;\n}\n\n/**\n * Check if the extension has a url for xhtml rendering\n *\n * @author Sean Fong\n */\nexport function getXHtmlString(qItem: QuestionnaireItem): string | null {\n let xHtmlString = null;\n if (qItem.extension) {\n xHtmlString = getXHtmlStringFromExtension(qItem.extension);\n if (xHtmlString) {\n return xHtmlString;\n }\n }\n\n if (qItem._text?.extension) {\n xHtmlString = getXHtmlStringFromExtension(qItem._text?.extension);\n if (xHtmlString) {\n return xHtmlString;\n }\n }\n\n return null;\n}\n\nexport function getXHtmlStringFromExtension(extensions: Extension[]): string | null {\n const itemControl = extensions?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/rendering-xhtml'\n );\n\n if (itemControl) {\n if (itemControl.valueString) {\n return itemControl.valueString;\n }\n }\n\n return null;\n}\n\n/**\n * Check if the item label (text) has a valueMarkdown extension\n *\n * @author Sean Fong\n */\nexport function getMarkdownString(qItem: QuestionnaireItem): string | null {\n const itemControl = qItem._text?.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/rendering-markdown'\n );\n\n if (itemControl) {\n if (itemControl.valueMarkdown) {\n return itemControl.valueMarkdown;\n }\n }\n return null;\n}\n\n/**\n * Get text display prompt for items with itemControlCode prompt and has a prompt childItem\n *\n * @author Sean Fong\n */\nexport function getTextDisplayPrompt(qItem: QuestionnaireItem): string {\n if (qItem.item) {\n for (const childItem of qItem.item) {\n if (childItem.type === 'display' && isSpecificItemControl(childItem, 'prompt')) {\n const promptText = `${childItem.text}`;\n return promptText[0].toUpperCase() + promptText.substring(1);\n }\n }\n }\n return '';\n}\n\n/**\n * Get Quantity unit for items with itemControlCode unit and has a unit childItem\n *\n * @author Sean Fong\n */\nexport function getQuantityUnit(qItem: QuestionnaireItem): QuestionnaireItemAnswerOption | null {\n // Otherwise, check if the item has a unit extension\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-unit'\n );\n if (itemControl && itemControl.valueCoding) {\n return itemControl;\n }\n\n return null;\n}\n\n/**\n * Get decimal text display unit for items with itemControlCode unit and has a unit childItem\n *\n * @author Sean Fong\n */\nexport function getTextDisplayUnit(qItem: QuestionnaireItem): string {\n // Check if the item has a display unit childItem\n if (qItem.item) {\n for (const childItem of qItem.item) {\n if (childItem.type === 'display' && isSpecificItemControl(childItem, 'unit')) {\n return `${childItem.text}`;\n }\n }\n }\n\n // Otherwise, check if the item has a unit extension\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-unit'\n );\n if (itemControl && itemControl.valueCoding) {\n return itemControl.valueCoding.display ?? '';\n }\n\n return '';\n}\n\n/**\n * Get text display lower bound for items with itemControlCode \"lower\" and has a \"lower\" childItem\n *\n * @author Sean Fong\n */\nexport function getTextDisplayLower(qItem: QuestionnaireItem): string {\n if (qItem.item) {\n for (const childItem of qItem.item) {\n if (childItem.type === 'display' && isSpecificItemControl(childItem, 'lower')) {\n return `${childItem.text}`;\n }\n }\n }\n return '';\n}\n\n/**\n * Get text display upper bound for items with itemControlCode \"upper\" and has a \"upper\" childItem\n *\n * @author Sean Fong\n */\nexport function getTextDisplayUpper(qItem: QuestionnaireItem): string {\n if (qItem.item) {\n for (const childItem of qItem.item) {\n if (childItem.type === 'display' && isSpecificItemControl(childItem, 'upper')) {\n return `${childItem.text}`;\n }\n }\n }\n return '';\n}\n\n/**\n * Get text display instructions for items with itemControlCode instructions and has an instructions childItem\n *\n * @author Sean Fong\n */\nexport function getTextDisplayInstructions(qItem: QuestionnaireItem): string {\n if (qItem.item) {\n for (const childItem of qItem.item) {\n if (childItem.type === 'display' && isSpecificDisplayCategory(childItem, 'instructions')) {\n return `${childItem.text}`;\n }\n }\n }\n return '';\n}\n\n/**\n * Get text display flyover for items with itemControlCode flyover and has an flyover childItem\n *\n * @author Sean Fong\n */\nexport function getTextDisplayFlyover(qItem: QuestionnaireItem) {\n if (qItem.item) {\n for (const childItem of qItem.item) {\n if (childItem.type === 'display' && isSpecificItemControl(childItem, 'flyover')) {\n const xHtmlString = getXHtmlString(childItem);\n if (xHtmlString) {\n return htmlParse(xHtmlString);\n }\n\n return `${childItem.text}`;\n }\n }\n }\n\n return '';\n}\n\n/**\n * Get regex validation for items with regex extensions\n *\n * @author Sean Fong\n */\nexport function getRegexValidation(qItem: QuestionnaireItem): RegexValidation | undefined {\n // Get regex expression from extension\n const regexString = getRegexString(qItem);\n if (regexString) {\n return { expression: new RegExp(regexString), feedback: null };\n }\n\n // Get regex expression from item types if regex extensions not present\n if (qItem.type === 'url') {\n return { expression: new RegExp(/^\\S*$/), feedback: 'URLs should not contain any whitespaces' };\n }\n\n return undefined;\n}\n\nexport function getRegexString(qItem: QuestionnaireItem): string | null {\n const itemControl = qItem.extension?.find(\n (extension: Extension) => extension.url === 'http://hl7.org/fhir/StructureDefinition/regex'\n );\n\n if (itemControl) {\n const extensionString = itemControl.valueString;\n if (extensionString) {\n let regexString;\n if (extensionString.includes('matches(')) {\n regexString = extensionString.substring(\n extensionString.indexOf(\"matches('\") + \"matches('\".length,\n extensionString.lastIndexOf(\"')\")\n );\n } else {\n regexString = extensionString;\n }\n\n return regexString;\n }\n }\n\n return null;\n}\n\nexport function getMinValue(qItem: QuestionnaireItem) {\n switch (qItem.type) {\n case 'integer':\n return structuredDataCapture.getMinValueAsInteger(qItem);\n case 'decimal':\n // In the case for decimals, permit minValue to be a decimal or integer\n return (\n structuredDataCapture.getMinValueAsDecimal(qItem) ??\n structuredDataCapture.getMinValueAsInteger(qItem)\n );\n case 'date':\n return structuredDataCapture.getMinValueAsDate(qItem);\n case 'dateTime':\n // In the case for dateTime, permit minValue to be a dateTime or date\n return (\n structuredDataCapture.getMinValueAsDateTime(qItem) ??\n structuredDataCapture.getMinValueAsDate(qItem)\n );\n default:\n return undefined;\n }\n}\n\nexport function getMinValueFeedback(qItem: QuestionnaireItem) {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'https://smartforms.csiro.au/ig/StructureDefinition/minValue-feedback'\n );\n if (itemControl) {\n const extensionString = itemControl.valueString;\n if (extensionString) {\n return extensionString;\n }\n }\n\n return null;\n}\n\nexport function getMaxValue(qItem: QuestionnaireItem) {\n switch (qItem.type) {\n case 'integer':\n return structuredDataCapture.getMaxValueAsInteger(qItem);\n case 'decimal':\n // In the case for decimals, permit maxValue to be a decimal or integer\n return (\n structuredDataCapture.getMaxValueAsDecimal(qItem) ??\n structuredDataCapture.getMaxValueAsInteger(qItem)\n );\n case 'date':\n return structuredDataCapture.getMaxValueAsDate(qItem);\n case 'dateTime':\n // In the case for dateTime, permit maxValue to be a dateTime or date\n return (\n structuredDataCapture.getMaxValueAsDateTime(qItem) ??\n structuredDataCapture.getMaxValueAsDate(qItem)\n );\n default:\n return undefined;\n }\n}\n\nexport function getMaxValueFeedback(qItem: QuestionnaireItem) {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'https://smartforms.csiro.au/ig/StructureDefinition/maxValue-feedback'\n );\n if (itemControl) {\n const extensionString = itemControl.valueString;\n if (extensionString) {\n return extensionString;\n }\n }\n\n return null;\n}\n\nexport function getRequiredFeedback(qItem: QuestionnaireItem) {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'https://smartforms.csiro.au/ig/StructureDefinition/required-feedback'\n );\n if (itemControl) {\n const extensionString = itemControl.valueString;\n if (extensionString) {\n return extensionString;\n }\n }\n\n return null;\n}\n\n/**\n * Check if the item has a sdc-questionnaire-minQuantity and minQuantity extension\n * @author Janardhan Vignarajan\n * @export\n * @param {QuestionnaireItem} qItem\n * @return {*} {(number | undefined)}\n */\nexport function getMinQuantityValue(qItem: QuestionnaireItem): number | undefined {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url ===\n 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-minQuantity'\n );\n\n if (itemControl && itemControl.valueQuantity) {\n //check if valueQuantity exists in the extension\n if (typeof itemControl.valueQuantity.value === 'number') {\n //check if valueQuantity.value exists in the extension\n return itemControl.valueQuantity.value;\n }\n }\n return undefined;\n}\n\n/**\n * Check if the item has a sdc-questionnaire-minQuantity feedback extension\n *\n * @author Janardhan Vignarajan\n * @export\n * @param {QuestionnaireItem} qItem\n * @return {*}\n */\nexport function getMinQuantityValueFeedback(qItem: QuestionnaireItem) {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url ===\n 'https://smartforms.csiro.au/ig/StructureDefinition/minQuantityValue-feedback'\n );\n if (itemControl) {\n const extensionString = itemControl.valueString;\n if (extensionString) {\n return extensionString;\n }\n }\n\n return null;\n}\n\n/**\n * Check if the item has a sdc-questionnaire-maxQuantity extension\n *\n * @author Janardhan Vignarajan\n * @export\n * @param {QuestionnaireItem} qItem\n * @return {*} {(number | undefined)}\n */\nexport function getMaxQuantityValue(qItem: QuestionnaireItem): number | undefined {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url ===\n 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-maxQuantity'\n );\n\n if (itemControl && itemControl.valueQuantity) {\n //check if valueQuantity exists in the extension\n if (typeof itemControl.valueQuantity.value === 'number') {\n //check if valueQuantity.value exists in the extension\n return itemControl.valueQuantity.value;\n }\n }\n return undefined;\n}\n\n/**\n * Check if the item has a sdc-questionnaire-maxQuantity Feedback extension\n *\n * @author Janardhan Vignarajan\n \n * @export\n * @param {QuestionnaireItem} qItem\n * @return {*} \n */\nexport function getMaxQuantityValueFeedback(qItem: QuestionnaireItem) {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url ===\n 'https://smartforms.csiro.au/ig/StructureDefinition/maxQuantityValue-feedback'\n );\n if (itemControl) {\n const extensionString = itemControl.valueString;\n if (extensionString) {\n return extensionString;\n }\n }\n\n return null;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n Coding,\n Encounter,\n Expression,\n Extension,\n FhirResource,\n Patient,\n Practitioner,\n QuestionnaireItem,\n ValueSet\n} from 'fhir/r4';\nimport * as FHIR from 'fhirclient';\nimport type { FhirResourceString } from '../interfaces/populate.interface';\nimport type { VariableXFhirQuery } from '../interfaces/variables.interface';\nimport type { ValidateCodeResponse, ValueSetPromise } from '../interfaces/valueSet.interface';\n\nconst VALID_VALUE_SET_URL_REGEX =\n /https?:\\/\\/(www\\.)?[-\\w@:%.+~#=]{2,256}\\.[a-z]{2,4}\\b([-@\\w:%+.~#?&/=]*ValueSet[-@\\w:%+.~#?&/=]*)/;\n\nconst VALID_FHIRPATH_VARIABLE_REGEX = /%(.*?)\\./;\n\n// Mainly for backwards compatibility, doesn't exist in the SDC spec anymore\nexport function getTerminologyServerUrl(qItem: QuestionnaireItem): string | undefined {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/terminology-server'\n );\n if (itemControl) {\n return itemControl.valueUrl;\n }\n return undefined;\n}\n\nexport function getValueSetPromise(url: string, terminologyServerUrl: string): Promise<ValueSet> {\n let valueSetUrl = url;\n\n if (url.includes('ValueSet/$expand?url=')) {\n const splitUrl = url.split('ValueSet/$expand?url=');\n if (splitUrl[0] && splitUrl[1]) {\n terminologyServerUrl = splitUrl[0];\n valueSetUrl = splitUrl[1];\n }\n }\n\n valueSetUrl = valueSetUrl.replace('|', '&version=');\n\n return FHIR.client({ serverUrl: terminologyServerUrl }).request({\n url: 'ValueSet/$expand?url=' + valueSetUrl\n });\n}\n\nfunction validateCodeResponseIsValid(response: any): response is ValidateCodeResponse {\n return (\n response &&\n response.resourceType === 'Parameters' &&\n response.parameter &&\n response.parameter.find((p: any) => p.name === 'code') &&\n response.parameter.find((p: any) => p.name === 'code').valueCode &&\n response.parameter.find((p: any) => p.name === 'system') &&\n response.parameter.find((p: any) => p.name === 'system').valueUri &&\n response.parameter.find((p: any) => p.name === 'display') &&\n response.parameter.find((p: any) => p.name === 'display').valueString\n );\n}\n\nexport async function validateCodePromise(\n url: string,\n system: string,\n code: string,\n terminologyServerUrl: string\n): Promise<ValidateCodeResponse | null> {\n const validateCodeResponse = await FHIR.client({ serverUrl: terminologyServerUrl }).request({\n url: `ValueSet/$validate-code?url=${url}&system=${system}&code=${code}`\n });\n\n if (validateCodeResponse && validateCodeResponseIsValid(validateCodeResponse)) {\n return validateCodeResponse;\n }\n\n return null;\n}\n\nasync function addTimeoutToPromise(promise: Promise<any>, timeoutMs: number) {\n const timeoutPromise = new Promise((_, reject) => {\n setTimeout(() => {\n reject(new Error(`Promise timed out after ${timeoutMs} milliseconds`));\n }, timeoutMs);\n });\n\n // Use Promise.race to wait for either the original promise or the timeout promise\n return Promise.race([promise, timeoutPromise]);\n}\n\nexport async function resolveValueSetPromises(\n valueSetPromises: Record<string, ValueSetPromise>\n): Promise<Record<string, ValueSetPromise>> {\n const newValueSetPromises: Record<string, ValueSetPromise> = {};\n\n const valueSetPromiseKeys = Object.keys(valueSetPromises);\n const valueSetPromiseValues = Object.values(valueSetPromises);\n\n const timeoutMs = 5000;\n const promises = valueSetPromiseValues.map((valueSetPromise) =>\n addTimeoutToPromise(valueSetPromise.promise, timeoutMs)\n );\n\n const settledPromises = await Promise.allSettled(promises);\n\n for (const [i, settledPromise] of settledPromises.entries()) {\n // Only add valueSet if the promise was fulfilled\n if (settledPromise.status === 'fulfilled') {\n const valueSet = settledPromise.value;\n const key = valueSetPromiseKeys[i];\n const valueSetPromise = valueSetPromiseValues[i];\n\n if (key && valueSetPromise) {\n valueSetPromise.valueSet = valueSet;\n newValueSetPromises[key] = valueSetPromise;\n }\n }\n }\n return newValueSetPromises;\n}\n\n/**\n * Sets an array of codings with the values from a valueSet\n *\n * @author Sean Fong\n */\nexport function getValueSetCodings(valueSet: ValueSet): Coding[] {\n return valueSet.expansion?.contains?.map((coding) => getRelevantCodingProperties(coding)) ?? [];\n}\n\n/**\n * Retrieves only the relevant properties of a Coding object.\n * Reason: https://tx.ontoserver.csiro.au/fhir returns a Coding with designation element, which is not in the FHIR spec, causing QRs with it to fail validation.\n *\n * @author Sean Fong\n */\nexport function getRelevantCodingProperties(coding: Coding): Coding {\n return {\n system: coding.system,\n code: coding.code,\n display: coding.display,\n ...(coding.extension && { extension: coding.extension })\n };\n}\n\n/**\n * Evaluate valueSets in answerExpression with fhirpath\n *\n * @author Sean Fong\n */\nexport function evaluateAnswerExpressionValueSet(\n answerExpression: Expression,\n itemLevelVariables: Expression[],\n preprocessedCodings: Record<string, Coding[]>\n): Coding[] {\n const expression = answerExpression.expression;\n if (!expression) return [];\n\n const match = expression.match(VALID_FHIRPATH_VARIABLE_REGEX);\n const variableName = match?.[1];\n if (!variableName) return [];\n\n const matchedVariable = itemLevelVariables?.find((variable) => variable.name === variableName);\n if (!matchedVariable) return [];\n\n const valueSetExpression = matchedVariable.expression;\n if (!valueSetExpression) return [];\n\n if (!VALID_VALUE_SET_URL_REGEX.test(valueSetExpression)) return [];\n\n return preprocessedCodings[valueSetExpression] ?? [];\n}\n\nexport function createValueSetToXFhirQueryVariableNameMap(\n variables: Record<string, VariableXFhirQuery>\n): Record<string, string> {\n const valueSetToNameMap: Record<string, string> = {};\n for (const [name, variable] of Object.entries(variables)) {\n const expressionStr = variable.valueExpression.expression;\n if (expressionStr && VALID_VALUE_SET_URL_REGEX.test(expressionStr)) {\n valueSetToNameMap[expressionStr] = name;\n }\n }\n return valueSetToNameMap;\n}\n\nexport function getResourceFromLaunchContext(\n resourceType: FhirResourceString,\n patient: Patient | null,\n user: Practitioner | null,\n encounter: Encounter | null\n): FhirResource | null {\n switch (resourceType) {\n case 'Patient':\n return patient;\n case 'Practitioner':\n return user;\n case 'Encounter':\n return encounter;\n }\n return null;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type {\n Coding,\n Extension,\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport { ChoiceItemControl, ChoiceItemOrientation } from '../interfaces/choice.enum';\nimport { isSpecificItemControl } from './itemControl';\nimport { getRelevantCodingProperties } from './valueSet';\n\n/**\n * Convert codings to Questionnaire answer options\n *\n * @author Sean Fong\n */\nexport function convertCodingsToAnswerOptions(codings: Coding[]): QuestionnaireItemAnswerOption[] {\n return codings.map(\n (coding): QuestionnaireItemAnswerOption => ({\n valueCoding: getRelevantCodingProperties(coding)\n })\n );\n}\n\n/**\n * Find and return corresponding answerOption based on selected answer in form\n *\n * @author Sean Fong\n */\nexport function findInAnswerOptions(\n options: QuestionnaireItemAnswerOption[],\n valueInString: string\n): QuestionnaireResponseItemAnswer | undefined {\n for (const option of options) {\n if (option.valueCoding) {\n if (valueInString === option.valueCoding.code) {\n return {\n valueCoding: getRelevantCodingProperties(option.valueCoding)\n };\n }\n\n // handle case where valueCoding.code is not present\n if (valueInString === option.valueCoding.display) {\n return {\n valueCoding: getRelevantCodingProperties(option.valueCoding)\n };\n }\n }\n\n if (option.valueString) {\n if (valueInString === option.valueString) {\n return {\n valueString: option.valueString\n };\n }\n }\n\n if (option.valueInteger) {\n if (valueInString === option.valueInteger.toString()) {\n return {\n valueInteger: option.valueInteger\n };\n }\n }\n }\n\n return;\n}\n\n/**\n * Compare answer option value with selected value via valueString, valueInteger, or valueCoding.code\n *\n * @author Sean Fong\n */\nexport function compareAnswerOptionValue(\n option: QuestionnaireItemAnswerOption,\n value: QuestionnaireItemAnswerOption\n): boolean {\n if (!value) {\n return false;\n }\n\n if (value.valueString) {\n return option.valueString === value.valueString;\n }\n\n if (value.valueInteger) {\n return option.valueInteger === value.valueInteger;\n }\n\n if (value.valueCoding) {\n if (value.valueCoding.code) {\n return option.valueCoding?.code === value.valueCoding.code;\n }\n\n // handle case where valueCoding.code is not present\n return option.valueCoding?.display === value.valueCoding.display;\n }\n\n return false;\n}\n\n/**\n * Get choice control type based on certain criteria in choice items\n *\n * @author Sean Fong\n */\nexport function getChoiceControlType(qItem: QuestionnaireItem) {\n if (isSpecificItemControl(qItem, 'autocomplete')) {\n return ChoiceItemControl.Autocomplete;\n }\n\n if (isSpecificItemControl(qItem, 'check-box')) {\n return ChoiceItemControl.Checkbox;\n }\n\n if (isSpecificItemControl(qItem, 'radio-button')) {\n return ChoiceItemControl.Radio;\n }\n\n if (isSpecificItemControl(qItem, 'drop-down')) {\n return ChoiceItemControl.Select;\n }\n\n return ChoiceItemControl.Select;\n}\n\n/**\n * Find and return string value from selected answer\n *\n * @author Sean Fong\n */\nexport function getQrChoiceValue(\n qrChoice: QuestionnaireResponseItem,\n returnNull?: boolean\n): string | null {\n if (qrChoice.answer && qrChoice.answer.length > 0) {\n const answer = qrChoice['answer'][0];\n if (answer['valueCoding']) {\n return answer.valueCoding.code ?? answer.valueCoding.display ?? '';\n } else if (answer['valueString'] !== undefined) {\n return answer.valueString;\n } else if (answer['valueInteger']) {\n return answer.valueInteger.toString();\n }\n }\n\n return returnNull ? null : '';\n}\n\n/**\n * Update choice checkbox group answers based on checkbox changes\n *\n * @author Sean Fong\n */\nexport function updateChoiceCheckboxAnswers(\n changedValue: string,\n answers: QuestionnaireResponseItemAnswer[],\n options: QuestionnaireItemAnswerOption[],\n oldQrItem: QuestionnaireResponseItem,\n isMultiSelection: boolean,\n answerKey: string | undefined\n): QuestionnaireResponseItem | null {\n // search for answer item of changedValue from list of answer options\n const newAnswer = findInAnswerOptions(options, changedValue);\n if (!newAnswer) {\n return null;\n }\n\n // Process multi-selection\n if (isMultiSelection && answers.length > 0) {\n // check and filter if new answer exists in existing qrAnswers\n const updatedAnswers = answers.filter(\n (answer) => JSON.stringify(answer) !== JSON.stringify(newAnswer)\n );\n\n // new answer is not present in existing answers, so we add it to the array\n if (updatedAnswers.length === answers.length) {\n updatedAnswers.push(newAnswer);\n }\n\n const updatedAnswersWithKey = updatedAnswers.map((answer) => ({ ...answer, id: answerKey }));\n\n return { ...oldQrItem, answer: updatedAnswersWithKey };\n }\n\n // Process single selection\n // If answer already exists, remove it from the array. Otherwise, add it to the array\n const answerExists = answers.some(\n (answer) => JSON.stringify(answer) === JSON.stringify(newAnswer)\n );\n return answerExists\n ? { ...oldQrItem, answer: [] }\n : { ...oldQrItem, answer: [{ ...newAnswer, id: answerKey }] };\n}\n\n/**\n * Get choice orientation from its itemControl\n *\n * @author Sean Fong\n */\nexport function getChoiceOrientation(qItem: QuestionnaireItem): ChoiceItemOrientation | null {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-choiceOrientation'\n );\n\n if (itemControl) {\n const code = itemControl.valueCode;\n if (code) {\n if (code === 'horizontal') {\n return ChoiceItemOrientation.Horizontal;\n } else if (code === 'vertical') {\n return ChoiceItemOrientation.Vertical;\n }\n }\n }\n\n return null;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport { OpenChoiceItemControl } from '../interfaces/choice.enum';\nimport { isSpecificItemControl } from './itemControl';\nimport isEqual from 'lodash.isequal';\nimport differenceWith from 'lodash.differencewith';\n\n/**\n * Update open choice answer based on open label value\n *\n * @author Sean Fong\n */\nexport function updateOpenLabelAnswer(\n openLabelChecked: boolean,\n changedOpenLabelValue: string,\n answers: QuestionnaireResponseItemAnswer[],\n options: QuestionnaireItemAnswerOption[],\n oldQrItem: QuestionnaireResponseItem,\n isMultiSelection: boolean,\n answerKey: string | undefined\n) {\n // Open label is unchecked, search for open label value and remove it\n if (!openLabelChecked) {\n // In single-selection, return empty array because there can only be one answer\n if (!isMultiSelection) {\n return {\n ...oldQrItem,\n answer: []\n };\n }\n\n // The rest of the processing is for multi-selection\n // Get the indexes of answers that match the open label value\n const matchedIndexes = answers\n .filter((answer) => answer.valueString === changedOpenLabelValue)\n .map((matched) => answers.indexOf(matched));\n\n // Only remove the last one if there are multiple matches, in case open label value is same as an option\n if (matchedIndexes.length > 0) {\n const lastMatchedIndex = matchedIndexes[matchedIndexes.length - 1];\n const newAnswers = answers.filter((answer, index) => index !== lastMatchedIndex);\n\n const newAnswersWithKey = newAnswers.map((answer) => ({ ...answer, id: answerKey }));\n return {\n ...oldQrItem,\n answer: newAnswersWithKey\n };\n }\n\n // Return oldQrItem if no matches are found\n return oldQrItem;\n }\n\n // Open label is checked, search for open label value and add it\n const newOpenLabelAnswer: QuestionnaireResponseItemAnswer = {\n valueString: changedOpenLabelValue\n };\n\n // In single-selection, return only newOpenLabelAnswer in an array because there can only be one answer\n if (!isMultiSelection) {\n return {\n ...oldQrItem,\n answer: [{ ...newOpenLabelAnswer, id: answerKey }]\n };\n }\n\n const oldOpenLabelAnswer: QuestionnaireResponseItemAnswer | null = getOldOpenLabelAnswer(\n answers,\n options\n );\n\n // No open label answer exists initially, add newOpenLabelAnswer to answers\n if (!oldOpenLabelAnswer) {\n const answersWithKey = answers.map((answer) => ({ ...answer, id: answerKey }));\n return {\n ...oldQrItem,\n answer: [...answersWithKey, { ...newOpenLabelAnswer, id: answerKey }]\n };\n }\n\n // Old open label answer equals to new open label answer\n // This should not happen, but return oldQrItem\n if (isEqual(oldOpenLabelAnswer, newOpenLabelAnswer)) {\n return oldQrItem;\n }\n\n // New open label answer is different from old open label answer, update it\n oldOpenLabelAnswer.valueString = changedOpenLabelValue;\n return {\n ...oldQrItem,\n answer: oldQrItem.answer\n };\n}\n\n/**\n * Get the old open label answer from the list of answers\n *\n * @author Sean Fong\n */\nexport function getOldOpenLabelAnswer(\n answers: QuestionnaireResponseItemAnswer[],\n options: QuestionnaireItemAnswerOption[]\n): QuestionnaireResponseItemAnswer | null {\n const answersWithoutId = answers.map((answer) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { id, ...rest } = answer;\n return rest as QuestionnaireResponseItemAnswer;\n });\n\n const outliers = differenceWith(answersWithoutId, options, isEqual);\n\n return outliers?.[0] ?? null;\n}\n\n/**\n * Get openChoice control type from qItem\n * defaults to select if no control code is provided\n *\n * @author Sean Fong\n */\nexport function getOpenChoiceControlType(qItem: QuestionnaireItem) {\n if (isSpecificItemControl(qItem, 'autocomplete')) {\n return OpenChoiceItemControl.Autocomplete;\n } else if (isSpecificItemControl(qItem, 'check-box')) {\n return OpenChoiceItemControl.Checkbox;\n } else if (isSpecificItemControl(qItem, 'radio-button')) {\n return OpenChoiceItemControl.Radio;\n } else {\n return OpenChoiceItemControl.Select;\n }\n}\n\n/**\n * Get string label from given answerOption\n *\n * @author Sean Fong\n */\nexport function getAnswerOptionLabel(option: QuestionnaireItemAnswerOption | string): string {\n if (typeof option === 'string') {\n return option;\n }\n\n if (option['valueCoding']) {\n return option.valueCoding.display ?? `${option.valueCoding.code}`;\n } else if (option['valueString']) {\n return option.valueString;\n } else if (option['valueInteger']) {\n return option.valueInteger.toString();\n } else {\n return '';\n }\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { BackboneElement, Extension, Questionnaire, QuestionnaireItem } from 'fhir/r4';\nimport { getChoiceControlType } from './choice';\nimport { ChoiceItemControl, OpenChoiceItemControl } from '../interfaces/choice.enum';\nimport { getOpenChoiceControlType } from './openChoice';\nimport type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';\n\ninterface isHiddenByEnableWhensParams {\n linkId: string;\n enableWhenIsActivated: boolean;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n parentRepeatGroupIndex?: number;\n}\n\nexport function isHiddenByEnableWhen(params: isHiddenByEnableWhensParams): boolean {\n const {\n linkId,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions,\n parentRepeatGroupIndex\n } = params;\n\n // If enableWhen is not activated, items are not hidden by enableWhen\n if (!enableWhenIsActivated) {\n return false;\n }\n\n // Check enableWhen items\n const { singleItems, repeatItems } = enableWhenItems;\n if (singleItems[linkId]) {\n return !singleItems[linkId].isEnabled;\n }\n\n if (repeatItems[linkId] && parentRepeatGroupIndex !== undefined) {\n return !repeatItems[linkId].enabledIndexes[parentRepeatGroupIndex];\n }\n\n // Check enableWhenExpressions\n const { singleExpressions, repeatExpressions } = enableWhenExpressions;\n\n if (repeatExpressions[linkId] && parentRepeatGroupIndex !== undefined) {\n return !repeatExpressions[linkId].enabledIndexes[parentRepeatGroupIndex];\n }\n\n if (singleExpressions[linkId]) {\n return !enableWhenExpressions.singleExpressions[linkId].isEnabled;\n }\n\n return false;\n}\n\n/**\n * Check if qItem is a repeat item AND if it isn't a checkbox item\n * Note: repeat checkbox items are rendered as multi-select checkbox instead of being rendered as a traditional repeat item\n *\n * @author Sean Fong\n */\nexport function isRepeatItemAndNotCheckbox(qItem: QuestionnaireItem): boolean {\n // Prevents form from crashing due to mismatched Q and QR\n // In reality this should never happen\n if (!qItem) {\n return false;\n }\n\n const isCheckbox =\n getChoiceControlType(qItem) === ChoiceItemControl.Checkbox ||\n getOpenChoiceControlType(qItem) === OpenChoiceItemControl.Checkbox;\n\n return !!qItem['repeats'] && !isCheckbox;\n}\n\nexport function getXHtmlStringFromQuestionnaire(questionnaire: Questionnaire): string | null {\n const itemControl = questionnaire._title?.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/rendering-xhtml'\n );\n\n if (itemControl) {\n if (itemControl.valueString) {\n return itemControl.valueString;\n }\n }\n return null;\n}\n\nexport function getLinkIdTypeTuples(questionnaire: Questionnaire): [string, string][] {\n if (!questionnaire.item || questionnaire.item.length === 0) {\n return [];\n }\n\n const linkIds: [string, string][] = [];\n for (const topLevelItem of questionnaire.item) {\n linkIds.push(...getLinkIdTypeTuplesFromItemRecursive(topLevelItem));\n }\n\n return linkIds;\n}\n\nexport function getLinkIdTypeTuplesFromItemRecursive(qItem: QuestionnaireItem): [string, string][] {\n const linkIds: [string, string][] = [];\n\n if (qItem.linkId) {\n linkIds.push([qItem.linkId, qItem.type]);\n }\n\n if (qItem.item) {\n for (const childItem of qItem.item) {\n linkIds.push(...getLinkIdTypeTuplesFromItemRecursive(childItem));\n }\n }\n\n return linkIds;\n}\n\nfunction getPreferredTerminologyServer(element: BackboneElement): string | null {\n const preferredTerminologyServerExtension = element.extension?.find(\n (ext) =>\n ext.url ===\n 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-preferredTerminologyServer'\n );\n\n if (preferredTerminologyServerExtension) {\n return (\n preferredTerminologyServerExtension.valueUrl ??\n preferredTerminologyServerExtension.valueUri ??\n preferredTerminologyServerExtension.valueString ??\n null\n );\n }\n\n return null;\n}\n\nexport function getLinkIdPreferredTerminologyServerTuples(\n questionnaire: Questionnaire\n): [string, string][] {\n if (!questionnaire.item || questionnaire.item.length === 0) {\n return [];\n }\n\n const preferredTerminologyServer = getPreferredTerminologyServer(questionnaire);\n\n const linkIds: [string, string][] = [];\n for (const topLevelItem of questionnaire.item) {\n linkIds.push(\n ...getLinkIdPreferredTerminologyServerTuplesRecursive(\n topLevelItem,\n preferredTerminologyServer\n )\n );\n }\n\n return linkIds;\n}\n\nfunction getLinkIdPreferredTerminologyServerTuplesRecursive(\n qItem: QuestionnaireItem,\n parentPreferredTerminologyServer: string | null\n): [string, string][] {\n const linkIds: [string, string][] = [];\n\n let preferredTerminologyServer = null;\n if (qItem.linkId) {\n preferredTerminologyServer =\n getPreferredTerminologyServer(qItem) ?? parentPreferredTerminologyServer ?? null;\n\n if (preferredTerminologyServer) {\n linkIds.push([qItem.linkId, preferredTerminologyServer]);\n }\n }\n\n if (qItem.item) {\n for (const childItem of qItem.item) {\n linkIds.push(\n ...getLinkIdPreferredTerminologyServerTuplesRecursive(childItem, preferredTerminologyServer)\n );\n }\n }\n\n return linkIds;\n}\n\nexport type CollapsibleType = 'default-open' | 'default-closed';\n\nfunction valueCodeIsCollapsibleType(valueCode: string): valueCode is CollapsibleType {\n return valueCode === 'default-open' || valueCode === 'default-closed';\n}\n\nexport function getGroupCollapsible(qItem: QuestionnaireItem): CollapsibleType | null {\n const collapsibleExtension = qItem.extension?.find(\n (ext) =>\n ext.url === 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-collapsible'\n );\n\n if (collapsibleExtension) {\n if (\n collapsibleExtension.valueCode &&\n valueCodeIsCollapsibleType(collapsibleExtension.valueCode)\n ) {\n return collapsibleExtension.valueCode;\n }\n }\n\n return null;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Questionnaire, QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { isRepeatItemAndNotCheckbox } from './qItem';\n\n/**\n * Generate an array of QuestionnaireResponseItems corresponding to its QuestionnaireItem indexes an array.\n * QuestionnaireItems without a corresponding QuestionnaireResponseItem is set as undefined.\n * i.e. QItems = [QItem0, QItem1, QItem2]. Only QItem0 and QItem2 have QrItems\n * Generated array: [QrItem0, undefined, QrItem2]\n * Note: There's a bug where if the qItems are child items from a repeat group, the function fails at the isRepeatGroup line.\n * Ensure that repeat groups are handled prior to calling this function.\n *\n * @author Sean Fong\n */\nexport function getQrItemsIndex(\n qItems: QuestionnaireItem[],\n qrItems: QuestionnaireResponseItem[],\n qItemsIndexMap: Record<string, number>\n): (QuestionnaireResponseItem | QuestionnaireResponseItem[] | undefined)[] {\n // Generate a <linkId, QrItem OR QrItems> dictionary\n const qrItemsCollected: Record<string, QuestionnaireResponseItem | QuestionnaireResponseItem[]> =\n {};\n for (const qrItem of qrItems) {\n const linkId = qrItem.linkId;\n\n // If item already exists, it has multiple qrItems and is therefore a repeat group\n if (qrItemsCollected[linkId]) {\n let storedValue = qrItemsCollected[linkId];\n\n // Create an array out of initial stored value if it is not an array initially\n if (!Array.isArray(storedValue)) {\n storedValue = [storedValue];\n }\n\n // Push new qrItem into array\n storedValue.push(qrItem);\n qrItemsCollected[linkId] = storedValue;\n } else {\n const qItemIndex = qItemsIndexMap[linkId];\n\n // Assign either a qrItem array or a single qrItem based on whether it is a repeatGroup or not\n const isRepeatGroup =\n isRepeatItemAndNotCheckbox(qItems[qItemIndex]) && qItems[qItemIndex].type === 'group';\n\n qrItemsCollected[linkId] = isRepeatGroup ? [qrItem] : qrItem;\n }\n }\n\n // Generate an array of QuestionnaireResponseItems corresponding to its QuestionnaireItem indexes in sequence\n // Qitems with no answers has a default value of undefined\n return qItems.reduce(\n (mapping: (QuestionnaireResponseItem | QuestionnaireResponseItem[])[], qItem, i) => {\n const qrItemOrItems = qrItemsCollected[qItem.linkId];\n // If qItem is a repeat group, default its value to an array instead of undefined\n if (isRepeatItemAndNotCheckbox(qItem) && qItem.type === 'group') {\n mapping[i] = qrItemOrItems ? qrItemsCollected[qItem.linkId] : [];\n } else {\n mapping[i] = qrItemsCollected[qItem.linkId];\n }\n return mapping;\n },\n []\n );\n}\n\n/**\n * Generate a dictionary of QuestionnaireItems linkIds mapped to their respective array indexes `<linkId, QItemIndex>`\n * i.e. `{ ee2589d5: 0, f9aaa187: 1, 88cab112: 2 }`\n * where ee2589d5, f9aaa187 and 88cab112 are linkIds of QItem0, QItem1 and QItem2 respectively\n *\n * @author Sean Fong\n */\nexport function mapQItemsIndex(\n questionnaireOrQItem: QuestionnaireItem | Questionnaire\n): Record<string, number> {\n if (!questionnaireOrQItem.item) {\n return {};\n }\n\n // generate a <linkId, QItemIndex> dictionary\n return questionnaireOrQItem.item.reduce((mapping: Record<string, number>, item, i) => {\n mapping[item.linkId] = i;\n return mapping;\n }, {});\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { QuestionnaireItem, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';\n\nimport type { QrRepeatGroup } from '../interfaces/repeatGroup.interface';\n\n/**\n * Remove items with no answers from a given questionnaireResponse\n * Also remove any starting or trailing whitespace from valueStrings\n * Generated questionnaireResponse only has items with answers\n *\n * @author Sean Fong\n */\nexport function removeNoAnswerQrItem(\n qrItem: QuestionnaireResponseItem\n): QuestionnaireResponseItem | undefined {\n const items = qrItem.item;\n if (items && items.length > 0) {\n const itemsCleaned: QuestionnaireResponseItem[] = [];\n\n // only get items with answers\n items.forEach((item) => {\n const QrItemCleaned = removeNoAnswerQrItem(item);\n if (QrItemCleaned) {\n itemsCleaned.push(QrItemCleaned);\n }\n });\n\n return itemsCleaned.length > 0 ? { ...qrItem, item: itemsCleaned } : undefined;\n }\n\n // remove starting or trailing whitespace\n if (qrItem['answer'] && qrItem['answer'][0]['valueString']) {\n qrItem['answer'][0]['valueString'] = qrItem['answer'][0]['valueString'].trim();\n }\n\n // check answer when qrItem is a single question\n return qrItem['answer'] ? qrItem : undefined;\n}\n\n/**\n * Create an empty group qrItem from a given group qItem\n *\n * @author Sean Fong\n */\nexport function createEmptyQrGroup(qItem: QuestionnaireItem): QuestionnaireResponseItem {\n return {\n linkId: qItem.linkId,\n text: qItem.text,\n item: []\n };\n}\n\n/**\n * Create an empty qrItem from a given qItem, optionally with an answer key\n *\n * @author Sean Fong\n */\nexport function createEmptyQrItem(\n qItem: QuestionnaireItem,\n answerKey: string | undefined\n): QuestionnaireResponseItem {\n const qrItem: QuestionnaireResponseItem = {\n linkId: qItem.linkId,\n text: qItem.text\n };\n\n if (answerKey) {\n qrItem.answer = [{ id: answerKey }];\n }\n\n return qrItem;\n}\n\n/**\n * Updates the QuestionnaireResponseItem group by adding/removing a new/modified child QuestionnaireResponseItem into/from a qrGroup\n * Takes either a single newQrItem or an array of newQrItems\n *\n * @author Sean Fong\n */\nexport function updateQrItemsInGroup(\n newQrItem: QuestionnaireResponseItem | null,\n newQrRepeatGroup: QrRepeatGroup | null,\n questionnaireResponseOrQrItem: QuestionnaireResponseItem | QuestionnaireResponse,\n qItemsIndexMap: Record<string, number>\n): void {\n let qrItems = questionnaireResponseOrQrItem.item;\n if (!qrItems) {\n qrItems = [];\n }\n\n // Get actual sequence indexes of qrItems present within a qrGroup\n // e.g. qrGroup has 4 fields but only the 2nd and 3rd field have values - resulting array is [1, 2]\n const qrItemsRealIndexArr = qrItems.map((qrItem) => qItemsIndexMap[qrItem.linkId]);\n\n if (newQrItem && newQrItem.linkId in qItemsIndexMap) {\n if (qrItems.length === 0) {\n qrItems.push(newQrItem);\n return;\n }\n\n // Get actual sequence index of qrItem within qrGroup\n const newQrItemIndex = qItemsIndexMap[newQrItem.linkId];\n for (let i = 0; i < qrItemsRealIndexArr.length; i++) {\n // Add qrItem at the end of qrGroup if it is larger than the other indexes\n if (newQrItemIndex > qrItemsRealIndexArr[i]) {\n if (i === qrItemsRealIndexArr.length - 1) {\n qrItems.push(newQrItem);\n }\n continue;\n }\n\n // Replace or delete qrItem at its supposed position if its index is already present within qrGroup\n if (newQrItemIndex === qrItemsRealIndexArr[i]) {\n // newQrItem has answer value\n if (newQrItem.item?.length || newQrItem.answer?.length) {\n qrItems[i] = newQrItem;\n break;\n }\n\n // newQrItem has no answer value\n qrItems.splice(i, 1);\n break;\n }\n\n // Add qrItem at its supposed position if its index is not present within qrGroup\n if (newQrItemIndex < qrItemsRealIndexArr[i]) {\n qrItems.splice(i, 0, newQrItem);\n break;\n }\n }\n }\n\n if (newQrRepeatGroup && newQrRepeatGroup.linkId in qItemsIndexMap) {\n const newQrItems = newQrRepeatGroup.qrItems;\n if (qrItems.length === 0) {\n qrItems.push(...newQrItems);\n return;\n }\n\n // Get actual sequence index of qrItems within qrGroup\n const newQrItemIndex = qItemsIndexMap[newQrRepeatGroup.linkId];\n for (let i = 0; i < qrItemsRealIndexArr.length; i++) {\n // Add qrItem at the end of qrGroup if it is larger than the other indexes\n if (newQrItemIndex > qrItemsRealIndexArr[i]) {\n if (i === qrItemsRealIndexArr.length - 1) {\n qrItems.push(...newQrItems);\n }\n continue;\n }\n\n // Replace or delete qrItem at its supposed position if its index is already present within qrGroup\n if (newQrItemIndex === qrItemsRealIndexArr[i]) {\n // Get number of repeatGroupItems that has the same linkId present in qrGroup\n let repeatGroupItemCount = 0;\n while (newQrItemIndex === qrItemsRealIndexArr[i + repeatGroupItemCount]) {\n repeatGroupItemCount++;\n }\n\n // Replace each repeat group qrItem with their new counterparts\n if (newQrItems.length === repeatGroupItemCount) {\n for (let j = 0; j < newQrItems.length; j++) {\n qrItems[i + j] = newQrItems[j];\n }\n break;\n }\n\n if (newQrItems.length > repeatGroupItemCount) {\n // Replace each repeat group qrItem with their new counterparts,\n // followed by adding an extra newQrItem behind the newly replaced qrItems\n for (let j = 0, k = repeatGroupItemCount; j < newQrItems.length; j++, k--) {\n if (k > 0) {\n qrItems[i + j] = newQrItems[j];\n } else {\n qrItems.splice(i + j, 0, newQrItems[j]);\n }\n }\n break;\n }\n\n if (newQrItems.length < repeatGroupItemCount) {\n // Replace each repeat group qrItem with their new counterparts (except the last one),\n // followed by deleting the last newQrItem which wasn't replaced\n for (let j = 0; j < repeatGroupItemCount; j++) {\n if (j <= newQrItems.length - 1) {\n qrItems[i + j] = newQrItems[j];\n } else {\n qrItems.splice(i + j, 1);\n }\n }\n break;\n }\n }\n\n // Add qrItem at its supposed position if its index is not present within qrGroup\n if (newQrItemIndex < qrItemsRealIndexArr[i]) {\n for (let j = 0; j < newQrItems.length; j++) {\n qrItems.splice(i + j, 0, newQrItems[j]);\n }\n break;\n }\n }\n }\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireResponse,\n QuestionnaireResponseItem\n} from 'fhir/r4';\nimport { getQrItemsIndex, mapQItemsIndex } from './mapItem';\nimport { qrItemHasItemsOrAnswer } from './manageForm';\n\nexport type RecursiveUpdateFunction<T> = (\n qItem: QuestionnaireItem,\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null,\n extraData: T\n) => QuestionnaireResponseItem | QuestionnaireResponseItem[] | null;\n\n/**\n * A generic (and safe) way to update a QuestionnaireResponse given a recursive function and a set of data i.e. Record<linkId, calculated expression values>, Record<linkId, re-populated values>\n * This function relies heavily on mapQItemsIndex() and getQrItemsIndex() to accurately pinpoint the locations of QR items based on their positions in the Q, taking into account repeating group answers, non-filled questions, etc\n *\n * @author Sean Fong\n */\nexport function updateQuestionnaireResponse<T>(\n questionnaire: Questionnaire,\n questionnaireResponse: QuestionnaireResponse,\n recursiveUpdateFunction: RecursiveUpdateFunction<T>,\n extraData: T\n) {\n if (\n !questionnaire.item ||\n questionnaire.item.length === 0 ||\n !questionnaireResponse.item ||\n questionnaireResponse.item.length === 0\n ) {\n return questionnaireResponse;\n }\n\n const qItemsIndexMap = mapQItemsIndex(questionnaire);\n const topLevelQRItemsByIndex = getQrItemsIndex(\n questionnaire.item,\n questionnaireResponse.item,\n qItemsIndexMap\n );\n\n const topLevelQrItems = [];\n for (const [index, topLevelQItem] of questionnaire.item.entries()) {\n const topLevelQRItemOrItems = topLevelQRItemsByIndex[index] ?? {\n linkId: topLevelQItem.linkId,\n text: topLevelQItem.text,\n item: []\n };\n\n const updatedTopLevelQRItem = recursiveUpdateFunction(\n topLevelQItem,\n topLevelQRItemOrItems,\n extraData\n );\n\n if (Array.isArray(updatedTopLevelQRItem)) {\n if (updatedTopLevelQRItem.length > 0) {\n topLevelQrItems.push(...updatedTopLevelQRItem);\n }\n continue;\n }\n\n if (updatedTopLevelQRItem && qrItemHasItemsOrAnswer(updatedTopLevelQRItem)) {\n topLevelQrItems.push(updatedTopLevelQRItem);\n }\n }\n\n return { ...questionnaireResponse, item: topLevelQrItems };\n}\n\nexport type RecursiveReadArrayFunction<T, U> = (\n qItem: QuestionnaireItem,\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null,\n extraData?: U\n) => T[] | null;\n\n/**\n * A generic (and safe) way to read an array of element(s) i.e. QuestionnaireResponseItem[], extracted Observation[] from a QuestionnaireResponse given a recursive function.\n * It also provides an optional extraData (generic U) parameter for additional data that the recursive function may need.\n * This function relies heavily on mapQItemsIndex() and getQrItemsIndex() to accurately pinpoint the locations of QR items based on their positions in the Q, taking into account repeating group answers, non-filled questions, etc\n *\n * @author Sean Fong\n */\nexport function readQuestionnaireResponse<T, U>(\n questionnaire: Questionnaire,\n questionnaireResponse: QuestionnaireResponse,\n recursiveReadFunction: RecursiveReadArrayFunction<T, U>,\n extraData?: U\n): T[] {\n if (!questionnaire.item || questionnaire.item.length === 0) {\n return [];\n }\n\n const qItemsIndexMap = mapQItemsIndex(questionnaire);\n const topLevelQRItemsByIndex = getQrItemsIndex(\n questionnaire.item,\n questionnaireResponse.item ?? [],\n qItemsIndexMap\n );\n\n const readValueArray = [];\n for (const [index, topLevelQItem] of questionnaire.item.entries()) {\n const topLevelQRItemOrItems = topLevelQRItemsByIndex[index] ?? {\n linkId: topLevelQItem.linkId,\n text: topLevelQItem.text,\n item: []\n };\n\n const readValue = recursiveReadFunction(topLevelQItem, topLevelQRItemOrItems, extraData);\n\n if (readValue) {\n readValueArray.push(...readValue);\n }\n }\n\n return readValueArray;\n}\n\nexport type RecursiveTranverseFunction<U> = (\n qItem: QuestionnaireItem,\n root?: Questionnaire,\n parent?: QuestionnaireItem,\n extraData?: U\n) => void;\n\nexport function transverseQuestionnaire<U>(\n questionnaire: Questionnaire,\n recursiveTranverseFunction: RecursiveTranverseFunction<U>,\n extraData?: U\n): void {\n if (!questionnaire.item || questionnaire.item.length === 0) return;\n\n for (const topLevelQItem of questionnaire.item) {\n recursiveTranverseFunction(topLevelQItem, questionnaire, undefined, extraData);\n }\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Questionnaire, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createFhirPathContext, handleFhirPathResult } from './fhirpath';\nimport fhirpath from 'fhirpath';\nimport fhirpath_r4_model from 'fhirpath/fhir-context/r4';\nimport type { TargetConstraint } from '../interfaces/targetConstraint.interface';\nimport type { Variables } from '../interfaces';\n\ninterface EvaluateInitialTargetConstraintsParams {\n initialResponse: QuestionnaireResponse;\n initialResponseItemMap: Record<string, QuestionnaireResponseItem[]>;\n targetConstraints: Record<string, TargetConstraint>;\n variables: Variables;\n existingFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n terminologyServerUrl: string;\n}\n\nexport async function evaluateInitialTargetConstraints(\n params: EvaluateInitialTargetConstraintsParams\n): Promise<{\n initialTargetConstraints: Record<string, TargetConstraint>;\n updatedFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n}> {\n const {\n initialResponse,\n initialResponseItemMap,\n targetConstraints,\n variables,\n existingFhirPathContext,\n terminologyServerUrl\n } = params;\n let { fhirPathTerminologyCache } = params;\n\n const fhirPathEvalResult = await createFhirPathContext(\n initialResponse,\n initialResponseItemMap,\n variables,\n existingFhirPathContext,\n fhirPathTerminologyCache,\n terminologyServerUrl\n );\n const updatedFhirPathContext = fhirPathEvalResult.fhirPathContext;\n fhirPathTerminologyCache = fhirPathEvalResult.fhirPathTerminologyCache;\n\n for (const key in targetConstraints) {\n const initialValue = targetConstraints[key].isEnabled;\n const expression = targetConstraints[key].valueExpression?.expression;\n if (!expression) {\n continue;\n }\n\n const cacheKey = JSON.stringify(expression); // Use expression as cache key\n if (fhirPathTerminologyCache[cacheKey]) {\n continue;\n }\n\n try {\n const fhirPathResult = fhirpath.evaluate(\n {},\n expression,\n updatedFhirPathContext,\n fhirpath_r4_model,\n {\n async: true,\n terminologyUrl: terminologyServerUrl\n }\n );\n const result = await handleFhirPathResult(fhirPathResult);\n\n // Update targetConstraints if length of result array > 0\n // Only update when current isEnabled value is different from the result, otherwise it will result in am infinite loop as per #733\n if (result.length > 0 && initialValue !== result[0] && typeof result[0] === 'boolean') {\n targetConstraints[key].isEnabled = result[0];\n }\n\n // Update isEnabled value to false if no result is returned\n if (result.length === 0 && initialValue !== false) {\n targetConstraints[key].isEnabled = false;\n }\n\n // handle intersect edge case - evaluate() returns empty array if result is false\n if (expression.includes('intersect') && result.length === 0 && initialValue !== false) {\n targetConstraints[key].isEnabled = false;\n }\n\n // If fhirPathResult is an async terminology call, cache the result\n if (fhirPathResult instanceof Promise) {\n fhirPathTerminologyCache[cacheKey] = result;\n }\n } catch (e) {\n console.warn(e.message, `Target Constraint Key: ${key}\\nExpression: ${expression}`);\n }\n }\n\n return {\n initialTargetConstraints: targetConstraints,\n updatedFhirPathContext,\n fhirPathTerminologyCache\n };\n}\n\nexport async function evaluateTargetConstraints(\n fhirPathContext: Record<string, any>,\n fhirPathTerminologyCache: Record<string, any>,\n targetConstraints: Record<string, TargetConstraint>,\n terminologyServerUrl: string\n): Promise<{\n targetConstraintsIsUpdated: boolean;\n updatedTargetConstraints: Record<string, TargetConstraint>;\n}> {\n let isUpdated = false;\n for (const key in targetConstraints) {\n const initialValue = targetConstraints[key].isEnabled;\n const expression = targetConstraints[key].valueExpression?.expression;\n if (!expression) {\n continue;\n }\n\n const cacheKey = JSON.stringify(expression); // Use expression as cache key\n if (fhirPathTerminologyCache[cacheKey]) {\n continue;\n }\n\n try {\n const fhirPathResult = fhirpath.evaluate({}, expression, fhirPathContext, fhirpath_r4_model, {\n async: true,\n terminologyUrl: terminologyServerUrl\n });\n const result = await handleFhirPathResult(fhirPathResult);\n\n // Update targetConstraints if length of result array > 0\n // Only update when current isEnabled value is different from the result, otherwise it will result in am infinite loop as per #733\n if (result.length > 0 && initialValue !== result[0] && typeof result[0] === 'boolean') {\n targetConstraints[key].isEnabled = result[0];\n isUpdated = true;\n }\n\n // Update isEnabled value to false if no result is returned\n if (result.length === 0 && initialValue !== false) {\n targetConstraints[key].isEnabled = false;\n isUpdated = true;\n }\n\n // handle intersect edge case - evaluate() returns empty array if result is false\n if (expression.includes('intersect') && result.length === 0 && initialValue !== false) {\n targetConstraints[key].isEnabled = false;\n isUpdated = true;\n }\n\n // If fhirPathResult is an async terminology call, cache the result\n if (fhirPathResult instanceof Promise) {\n fhirPathTerminologyCache[cacheKey] = result;\n }\n } catch (e) {\n console.warn(e.message, `Target Constraint Key: ${key}\\nExpression: ${expression}`);\n }\n }\n\n return {\n targetConstraintsIsUpdated: isUpdated,\n updatedTargetConstraints: targetConstraints\n };\n}\n\nexport function readTargetConstraintLocationLinkIds(\n questionnaire: Questionnaire,\n targetConstraints: Record<string, TargetConstraint>\n) {\n const targetConstraintLinkIds: Record<string, string[]> = {};\n for (const [targetConstraintKey, targetConstraint] of Object.entries(targetConstraints)) {\n if (targetConstraint.location) {\n const targetConstraintLinkId = getTargetConstraintLocationLinkId(\n questionnaire,\n targetConstraint.location\n );\n\n if (targetConstraintLinkId) {\n // Add to targetConstraintLinkIds <linkId, key>\n // If targetConstraintLinkId is not in targetConstraintLinkIds, create an array\n if (targetConstraintLinkIds[targetConstraintLinkId]) {\n targetConstraintLinkIds[targetConstraintLinkId].push(targetConstraintKey);\n } else {\n targetConstraintLinkIds[targetConstraintLinkId] = [targetConstraintKey];\n }\n\n // Add to targetConstraint.linkId\n targetConstraints[targetConstraintKey].linkId = targetConstraintLinkId;\n }\n }\n }\n\n return targetConstraintLinkIds;\n}\n\n/**\n * Reads a value from a Questionnaire based on a FHIRPath location string.\n * @param questionnaire - The Questionnaire resource.\n * @param location - The FHIRPath location string.\n * @returns - The matched linkId, or null if no match is found.\n */\nfunction getTargetConstraintLocationLinkId(\n questionnaire: Questionnaire,\n location: string\n): string | null {\n try {\n const fhirPathResult = fhirpath.evaluate(questionnaire, location, {}, fhirpath_r4_model, {\n async: false\n });\n\n if (fhirPathResult.length > 0) {\n const singleResult = fhirPathResult[0];\n if (\n typeof singleResult === 'object' &&\n singleResult.linkId &&\n typeof singleResult.linkId === 'string'\n ) {\n return singleResult.linkId;\n }\n }\n } catch (e) {\n console.warn(e.message, `Target Constraint Location: ${location}}`);\n }\n\n return null;\n}\n","import type {\n Extension,\n QuestionnaireItem,\n QuestionnaireResponse,\n QuestionnaireResponseItem\n} from 'fhir/r4';\nimport type { BindingParameter, ProcessedValueSet } from '../interfaces/valueSet.interface';\nimport type { Variables } from '../interfaces';\nimport { createFhirPathContext, handleFhirPathResult } from './fhirpath';\nimport fhirpath from 'fhirpath';\nimport fhirpath_r4_model from 'fhirpath/fhir-context/r4';\nimport type { ComputedNewAnswers } from '../interfaces/computedUpdates.interface';\n\nexport function getBindingParameter(bindingParamExtension: Extension): BindingParameter | null {\n const paramName = bindingParamExtension.extension?.find((ext) => ext.url === 'name')?.valueString;\n const paramExpression = bindingParamExtension.extension?.find((ext) => ext.url === 'expression');\n\n if (!paramName || !paramExpression) {\n return null;\n }\n\n // extension:expression has a valueExpression\n if (\n paramExpression.valueExpression?.expression &&\n paramExpression.valueExpression?.language === 'text/fhirpath'\n ) {\n return {\n name: paramName,\n value: '',\n fhirPathExpression: paramExpression.valueExpression.expression\n };\n }\n\n // extension:expression has a valueString\n if (paramExpression.valueString) {\n return {\n name: paramName,\n value: paramExpression.valueString\n };\n }\n\n return null;\n}\n\nexport function getBindingParameters(\n qItem: QuestionnaireItem,\n initialValueSetUrl: string\n): BindingParameter[] {\n if (!qItem._answerValueSet) {\n return [];\n }\n\n // Reference to contained valueSets doesn't work with binding parameters\n if (initialValueSetUrl.startsWith('#')) {\n return [];\n }\n\n const bindingParameterExtensions =\n qItem._answerValueSet?.extension?.filter(\n (ext) => ext.url === 'http://hl7.org/fhir/tools/StructureDefinition/binding-parameter'\n ) || [];\n\n const bindingParameters: BindingParameter[] = [];\n for (const bindingParameterExtension of bindingParameterExtensions) {\n if (bindingParameterExtension?.extension) {\n const bindingParameter = getBindingParameter(bindingParameterExtension);\n if (bindingParameter) {\n bindingParameters.push(bindingParameter);\n }\n }\n }\n\n return bindingParameters;\n}\n\nexport function addBindingParametersToValueSetUrl(\n valueSetUrl: string,\n bindingParameters: BindingParameter[]\n): string {\n for (const bindingParameter of bindingParameters) {\n if (bindingParameter.value !== '') {\n valueSetUrl += `&${bindingParameter.name}=${bindingParameter.value}`;\n }\n }\n\n return valueSetUrl;\n}\n\ninterface EvaluateInitialDynamicValueSetsParams {\n initialResponse: QuestionnaireResponse;\n initialResponseItemMap: Record<string, QuestionnaireResponseItem[]>;\n processedValueSets: Record<string, ProcessedValueSet>;\n variables: Variables;\n existingFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n terminologyServerUrl: string;\n}\n\nexport async function evaluateInitialDynamicValueSets(\n params: EvaluateInitialDynamicValueSetsParams\n): Promise<{\n initialProcessedValueSets: Record<string, ProcessedValueSet>;\n updatedFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n}> {\n const {\n initialResponse,\n initialResponseItemMap,\n processedValueSets,\n variables,\n existingFhirPathContext,\n terminologyServerUrl\n } = params;\n let { fhirPathTerminologyCache } = params;\n\n const hasDynamicEntries = Object.values(processedValueSets).some(\n (valueSet) => valueSet.isDynamic\n );\n if (!hasDynamicEntries) {\n return {\n initialProcessedValueSets: processedValueSets,\n updatedFhirPathContext: existingFhirPathContext,\n fhirPathTerminologyCache\n };\n }\n\n const fhirPathEvalResult = await createFhirPathContext(\n initialResponse,\n initialResponseItemMap,\n variables,\n existingFhirPathContext,\n fhirPathTerminologyCache,\n terminologyServerUrl\n );\n const updatedFhirPathContext = fhirPathEvalResult.fhirPathContext;\n fhirPathTerminologyCache = fhirPathEvalResult.fhirPathTerminologyCache;\n\n for (const key in processedValueSets) {\n const processedValueSet = processedValueSets[key];\n if (!processedValueSet.isDynamic) {\n continue;\n }\n\n for (const bindingParameter of processedValueSet.bindingParameters) {\n if (bindingParameter.fhirPathExpression) {\n const cacheKey = JSON.stringify(bindingParameter.fhirPathExpression); // Use expression as cache key\n if (fhirPathTerminologyCache[cacheKey]) {\n continue;\n }\n\n try {\n const fhirPathResult = fhirpath.evaluate(\n {},\n bindingParameter.fhirPathExpression,\n updatedFhirPathContext,\n fhirpath_r4_model,\n {\n async: true,\n terminologyUrl: terminologyServerUrl\n }\n );\n const result = await handleFhirPathResult(fhirPathResult);\n\n // If fhirPathResult is an async terminology call, cache the result\n if (fhirPathResult instanceof Promise) {\n fhirPathTerminologyCache[cacheKey] = result;\n }\n\n /*\n * Update processedValueSet.updatableValueSetUrl (add or remove p-param)\n * Only update when current processedValueSet.updatableValueSetUrl value is different from the result, otherwise it will result in an infinite loop as per issue #733\n */\n // Add p-param if result exists, is string, and is different from current value\n const hasNewPParam =\n result.length > 0 &&\n typeof result[0] === 'string' &&\n bindingParameter.value !== result[0];\n\n // Remove p-param if result is empty, and current value is not an empty string\n const toRemovePParam = result.length === 0 && bindingParameter.value !== '';\n if (hasNewPParam || toRemovePParam) {\n bindingParameter.value = hasNewPParam ? result[0] : '';\n processedValueSet.updatableValueSetUrl = addBindingParametersToValueSetUrl(\n processedValueSet.initialValueSetUrl,\n processedValueSet.bindingParameters\n );\n }\n } catch (e) {\n console.warn(\n e.message,\n `Dynamic ValueSets Key: ${key}\\nExpression: ${bindingParameter.fhirPathExpression}`\n );\n }\n }\n }\n }\n\n return {\n initialProcessedValueSets: processedValueSets,\n updatedFhirPathContext,\n fhirPathTerminologyCache\n };\n}\n\nexport async function evaluateDynamicValueSets(\n fhirPathContext: Record<string, any>,\n fhirPathTerminologyCache: Record<string, any>,\n processedValueSets: Record<string, ProcessedValueSet>,\n terminologyServerUrl: string\n): Promise<{\n processedValueSetsIsUpdated: boolean;\n updatedProcessedValueSets: Record<string, ProcessedValueSet>;\n computedNewAnswers: ComputedNewAnswers;\n}> {\n let isUpdated = false;\n let computedNewAnswers: ComputedNewAnswers = {};\n for (const key in processedValueSets) {\n const processedValueSet = processedValueSets[key];\n if (!processedValueSet.isDynamic) {\n continue;\n }\n\n for (const bindingParameter of processedValueSet.bindingParameters) {\n if (bindingParameter.fhirPathExpression) {\n const cacheKey = JSON.stringify(bindingParameter.fhirPathExpression); // Use expression as cache key\n if (fhirPathTerminologyCache[cacheKey]) {\n continue;\n }\n\n try {\n const fhirPathResult = fhirpath.evaluate(\n {},\n bindingParameter.fhirPathExpression,\n fhirPathContext,\n fhirpath_r4_model,\n {\n async: true,\n terminologyUrl: terminologyServerUrl\n }\n );\n const result = await handleFhirPathResult(fhirPathResult);\n\n // If fhirPathResult is an async terminology call, cache the result\n if (fhirPathResult instanceof Promise) {\n fhirPathTerminologyCache[cacheKey] = result;\n }\n\n /*\n * Update processedValueSet.updatableValueSetUrl (add or remove p-param)\n * Only update when current processedValueSet.updatableValueSetUrl value is different from the result, otherwise it will result in an infinite loop as per issue #733\n */\n // Add p-param if result exists, is string, and is different from current value\n const hasNewPParam =\n result.length > 0 &&\n typeof result[0] === 'string' &&\n bindingParameter.value !== result[0];\n\n // Remove p-param if result is empty, and current value is not an empty string\n const toRemovePParam = result.length === 0 && bindingParameter.value !== '';\n if (hasNewPParam || toRemovePParam) {\n isUpdated = true;\n bindingParameter.value = hasNewPParam ? result[0] : '';\n processedValueSet.updatableValueSetUrl = addBindingParametersToValueSetUrl(\n processedValueSet.initialValueSetUrl,\n processedValueSet.bindingParameters\n );\n\n computedNewAnswers = {\n ...computedNewAnswers,\n ...getComputedAnswerUpdates(processedValueSet.linkIds)\n };\n }\n } catch (e) {\n console.warn(\n e.message,\n `Dynamic ValueSets Key: ${key}\\nExpression: ${bindingParameter.fhirPathExpression}`\n );\n }\n }\n }\n }\n\n return {\n processedValueSetsIsUpdated: isUpdated,\n updatedProcessedValueSets: processedValueSets,\n computedNewAnswers\n };\n}\n\n// For parameterised valueSets, if the valueSet options is updated, clear the answers\nfunction getComputedAnswerUpdates(linkIds: string[]): ComputedNewAnswers {\n const computedAnswerUpdates: ComputedNewAnswers = {};\n for (const linkId of linkIds) {\n computedAnswerUpdates[linkId] = null;\n }\n\n return computedAnswerUpdates;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Extension } from 'fhir/r4';\nimport type { LaunchContext } from '../interfaces/populate.interface';\n\nexport function isLaunchContext(extension: Extension): extension is LaunchContext {\n const hasLaunchContextName =\n extension.url ===\n 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-launchContext' &&\n !!extension.extension?.find(\n (ext) =>\n ext.url === 'name' &&\n (ext.valueId ||\n (ext.valueCoding &&\n (ext.valueCoding.code === 'patient' ||\n ext.valueCoding.code === 'encounter' ||\n ext.valueCoding.code === 'location' ||\n ext.valueCoding.code === 'user' ||\n ext.valueCoding.code === 'study' ||\n ext.valueCoding.code === 'sourceQueries')))\n );\n\n const hasLaunchContextType = !!extension.extension?.find(\n (ext) =>\n ext.url === 'type' &&\n ext.valueCode &&\n (ext.valueCode === 'Patient' ||\n ext.valueCode === 'Practitioner' ||\n ext.valueCode === 'Encounter')\n );\n\n return (\n extension.url ===\n 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-launchContext' &&\n hasLaunchContextName &&\n hasLaunchContextType\n );\n}\n","import type { Questionnaire } from 'fhir/r4';\nimport type { LaunchContext } from '../../interfaces/populate.interface';\nimport { isLaunchContext } from '../populateContexts';\n\nexport function extractLaunchContexts(questionnaire: Questionnaire): Record<string, LaunchContext> {\n if (!questionnaire.extension || questionnaire.extension.length === 0) {\n return {};\n }\n\n const launchContexts: Record<string, LaunchContext> = {};\n for (const ext of questionnaire.extension) {\n if (isLaunchContext(ext)) {\n const launchContextName = ext.extension[0].valueId ?? ext.extension[0].valueCoding?.code;\n if (launchContextName) {\n launchContexts[launchContextName] = ext;\n }\n }\n }\n\n return launchContexts;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Expression, Extension, Questionnaire } from 'fhir/r4';\nimport type { Variables } from '../../interfaces/variables.interface';\n\nexport function extractQuestionnaireLevelVariables(questionnaire: Questionnaire): Variables {\n const variables: Variables = { fhirPathVariables: {}, xFhirQueryVariables: {} };\n\n variables.fhirPathVariables['QuestionnaireLevel'] = [];\n\n if (!questionnaire.extension || questionnaire.extension.length === 0) {\n return variables;\n }\n\n variables.fhirPathVariables['QuestionnaireLevel'] = getFhirPathVariables(questionnaire.extension);\n\n for (const exp of getXFhirQueryVariables(questionnaire.extension)) {\n if (exp.name) {\n variables.xFhirQueryVariables[exp.name] = {\n valueExpression: exp\n };\n }\n }\n\n return variables;\n}\n\n/**\n * Get fhirpath variables from an array of extensions\n *\n * @author Sean Fong\n */\nexport function getFhirPathVariables(extensions: Extension[]): Expression[] {\n return (\n extensions\n .filter(\n (extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/variable' &&\n extension.valueExpression?.language === 'text/fhirpath'\n )\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n .map((extension) => extension.valueExpression!)\n );\n}\n\n/**\n * Get x-fhir-query variables from an array of extensions\n *\n * @author Sean Fong\n */\nexport function getXFhirQueryVariables(extensions: Extension[]): Expression[] {\n return (\n extensions\n .filter(\n (extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/variable' &&\n extension.valueExpression?.language === 'application/x-fhir-query'\n )\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n .map((extension) => extension.valueExpression!)\n );\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Tabs } from '../interfaces/tab.interface';\nimport type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';\nimport type { Coding, QuestionnaireItem } from 'fhir/r4';\nimport { isSpecificItemControl } from './itemControl';\nimport { isHiddenByEnableWhen } from './qItem';\nimport { structuredDataCapture } from 'fhir-sdc-helpers';\n\nexport function getFirstVisibleTab(\n tabs: Tabs,\n enableWhenItems: EnableWhenItems,\n enableWhenExpressions: EnableWhenExpressions\n) {\n // Only singleEnableWhenItems are relevant for tab operations\n const { singleItems } = enableWhenItems;\n const { singleExpressions } = enableWhenExpressions;\n\n return Object.entries(tabs)\n .sort(([, tabA], [, tabB]) => tabA.tabIndex - tabB.tabIndex)\n .findIndex(([tabLinkId, tab]) => {\n if (tab.isHidden) {\n return false;\n }\n\n const singleItem = singleItems[tabLinkId];\n if (singleItem) {\n return singleItem.isEnabled;\n }\n\n const singleExpression = singleExpressions[tabLinkId];\n if (singleExpression) {\n return singleExpression.isEnabled;\n }\n\n return true;\n });\n}\n\n/**\n * Checks if any of the items in a qItem array is a tabbed item\n * Returns true if there is at least one tabbed item\n *\n * @author Sean Fong\n */\nexport function containsTabs(topLevelQItem: QuestionnaireItem): boolean {\n if (!topLevelQItem.item) {\n return false;\n }\n\n const tabs = getTabbedItems(topLevelQItem.item);\n return tabs.length > 0;\n}\n\n/**\n * Checks if a top-level QItem is a tab container\n * All items within a tab container are tabbed items\n *\n * @author Sean Fong\n */\nexport function isTabContainer(topLevelQItem: QuestionnaireItem): boolean {\n return isSpecificItemControl(topLevelQItem, 'tab-container');\n}\n\n/**\n * Get tabbed items from a qItem array\n *\n * @author Sean Fong\n */\nexport function getTabbedItems(items: QuestionnaireItem[]): QuestionnaireItem[] {\n return items.filter((i: QuestionnaireItem) => isTab(i));\n}\n\n/**\n * Check if a qItem is a tabbed item\n *\n * @author Sean Fong\n */\nexport function isTab(item: QuestionnaireItem) {\n const itemControl = item.extension?.find(\n (e) => e.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl'\n );\n\n if (itemControl) {\n const tabCoding = itemControl.valueCodeableConcept?.coding?.find(\n (c: Coding) => c.code === 'tab'\n );\n if (tabCoding) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Create a `Record<linkId, {isComplete: boolean}>` key-value pair for all tabbed items in a qItem array\n *\n * @author Sean Fong\n */\nexport function constructTabsWithProperties(\n qItems: QuestionnaireItem[] | undefined,\n hasTabContainer: boolean\n): Tabs {\n if (!qItems) return {};\n\n const qItemTabs = hasTabContainer ? qItems : qItems.filter(isTab);\n\n const tabs: Tabs = {};\n for (const [i, qItem] of qItemTabs.entries()) {\n tabs[qItem.linkId] = {\n tabIndex: i,\n isComplete: false,\n isHidden: structuredDataCapture.getHidden(qItem) ?? false\n };\n }\n return tabs;\n}\n\ninterface constructTabsWithVisibilityParams {\n tabs: Tabs;\n enableWhenIsActivated: boolean;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n}\n\nexport function constructTabsWithVisibility(\n params: constructTabsWithVisibilityParams\n): { linkId: string; isVisible: boolean }[] {\n const { tabs, enableWhenIsActivated, enableWhenItems, enableWhenExpressions } = params;\n\n return Object.entries(tabs).map(([linkId]) => {\n const isVisible = !isHiddenByEnableWhen({\n linkId,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n });\n\n return {\n linkId,\n isVisible\n };\n });\n}\n\nexport function getContextDisplays(item: QuestionnaireItem): QuestionnaireItem[] {\n if (!item.item || item.item.length === 0) {\n return [];\n }\n\n return item.item.filter(\n (childItem) =>\n isSpecificItemControl(childItem, 'context-display') && childItem.type === 'display'\n );\n}\n\ninterface IsTabHiddenParams {\n qItem: QuestionnaireItem;\n contextDisplayItems: QuestionnaireItem[];\n isTab: boolean;\n enableWhenIsActivated: boolean;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n completedTabsCollapsed: boolean;\n}\n\nexport function isTabHidden(params: IsTabHiddenParams): boolean {\n const {\n qItem,\n contextDisplayItems,\n isTab,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions,\n completedTabsCollapsed\n } = params;\n\n if (\n !isTab ||\n isHiddenByEnableWhen({\n linkId: qItem.linkId,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n }) ||\n structuredDataCapture.getHidden(qItem)\n ) {\n return true;\n }\n\n if (completedTabsCollapsed) {\n const completedDisplayItem = contextDisplayItems.find(\n (contextDisplayItem) => contextDisplayItem.text === 'Complete'\n );\n const isHidden =\n (completedDisplayItem &&\n isHiddenByEnableWhen({\n linkId: completedDisplayItem.linkId,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n })) ||\n structuredDataCapture.getHidden(completedDisplayItem);\n\n if (!isHidden) {\n return true;\n }\n }\n\n return false;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { constructTabsWithProperties, isTabContainer } from '../tabs';\nimport type { Questionnaire } from 'fhir/r4';\nimport type { Tabs } from '../../interfaces/tab.interface';\n\nexport function extractTabs(questionnaire: Questionnaire): Tabs {\n if (!questionnaire.item || questionnaire.item.length === 0) {\n return {};\n }\n\n let totalTabs = {};\n for (const topLevelItem of questionnaire.item) {\n const items = topLevelItem.item;\n const topLevelItemIsTabContainer = isTabContainer(topLevelItem);\n\n const tabs = constructTabsWithProperties(items, topLevelItemIsTabContainer);\n totalTabs = { ...totalTabs, ...tabs };\n }\n\n return totalTabs;\n}\n","import type { Pages } from '../interfaces/page.interface';\nimport type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport { isSpecificItemControl } from './itemControl';\nimport { isHiddenByEnableWhen } from './qItem';\nimport { structuredDataCapture } from 'fhir-sdc-helpers';\n\nexport function getFirstVisiblePage(\n pages: Pages,\n enableWhenItems: EnableWhenItems,\n enableWhenExpressions: EnableWhenExpressions\n) {\n // Only singleEnableWhenItems are relevant for page operations\n const { singleItems } = enableWhenItems;\n const { singleExpressions } = enableWhenExpressions;\n\n return Object.entries(pages)\n .sort(([, pageA], [, pageB]) => pageA.pageIndex - pageB.pageIndex)\n .findIndex(([pageLinkId, page]) => {\n if (page.isHidden) {\n return false;\n }\n\n const singleItem = singleItems[pageLinkId];\n if (singleItem) {\n return singleItem.isEnabled;\n }\n\n const singleExpression = singleExpressions[pageLinkId];\n if (singleExpression) {\n return singleExpression.isEnabled;\n }\n\n return true;\n });\n}\n\n/**\n * Checks if all items in a qItem array is a page item, header item, or footer item\n * Returns true if all items is page item, header item, or footer item\n * Returns false if only have one item\n *\n * @author Riza Nafis, Sean Fong\n */\nexport function isPaginatedForm(topLevelQItems: QuestionnaireItem[] | undefined): boolean {\n if (!topLevelQItems) return false;\n\n return topLevelQItems.every(\n (topLevelQItem: QuestionnaireItem) =>\n isPage(topLevelQItem) || isHeader(topLevelQItem) || isFooter(topLevelQItem)\n );\n}\n\nexport function isPageContainer(topLevelQItem: QuestionnaireItem[] | undefined): boolean {\n const anyPage = topLevelQItem?.filter(isPage);\n\n if (!anyPage) return false;\n\n return anyPage.some((page) => page.item?.every((i) => i.type === 'group') || false);\n}\n\n/**\n * Checks if any of the items in a qItem array is a page item\n * Returns true if there is at least one page item\n *\n * @author Riza Nafis\n */\nexport function containsPages(topLevelQItem: QuestionnaireItem): boolean {\n if (!topLevelQItem.item) {\n return false;\n }\n\n const pages = topLevelQItem.item.filter((i) => isPage(i));\n return pages.length > 0;\n}\n\n/**\n * Check if a qItem is a page item\n *\n * @author Riza Nafis\n */\nexport function isPage(item: QuestionnaireItem) {\n return isSpecificItemControl(item, 'page');\n}\n\n/**\n * Check if a qItem is a header item\n *\n * @author Sean Fong\n */\nexport function isHeader(item: QuestionnaireItem) {\n return isSpecificItemControl(item, 'header');\n}\n\n/**\n * Check if a qItem is a footer item\n *\n * @author Sean Fong\n */\nexport function isFooter(item: QuestionnaireItem) {\n return isSpecificItemControl(item, 'footer');\n}\n\n/**\n * Create a `Record<linkId, Pages>` key-value pair for all page items in a qItem array\n *\n * @author Riza Nafis\n */\nexport function constructPagesWithProperties(\n qItems: QuestionnaireItem[] | undefined,\n allChildItemsArePages: boolean\n): Pages {\n if (!qItems) return {};\n\n const pages: Pages = {};\n for (const [i, qItem] of qItems.entries()) {\n // allChildItemsArePages will only be true if we are using the backwards-compatible method, it should be false most of the time\n if (allChildItemsArePages || isPage(qItem)) {\n pages[qItem.linkId] = {\n pageIndex: i,\n isComplete: false,\n isHidden: structuredDataCapture.getHidden(qItem) ?? false\n };\n }\n }\n return pages;\n}\n\ninterface constructPagesWithVisibilityParams {\n pages: Pages;\n enableWhenIsActivated: boolean;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n}\n\nexport function constructPagesWithVisibility(\n params: constructPagesWithVisibilityParams\n): { linkId: string; isVisible: boolean }[] {\n const { pages, enableWhenIsActivated, enableWhenItems, enableWhenExpressions } = params;\n\n return Object.entries(pages).map(([linkId]) => {\n const isVisible = !isHiddenByEnableWhen({\n linkId,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n });\n\n return {\n linkId,\n isVisible\n };\n });\n}\n","import type { Questionnaire } from 'fhir/r4';\nimport type { Pages } from '../../interfaces/page.interface';\nimport { constructPagesWithProperties, isFooter, isHeader, isPage } from '../page';\n\nexport function extractPages(questionnaire: Questionnaire): Pages {\n if (!questionnaire.item || questionnaire.item.length === 0) {\n return {};\n }\n\n // Two scenarios to consider here:\n /* 1. Proper way:\n * - Every single top-level item is a page, header or footer\n * Note: \"header\" and \"footer\" itemControl is not supported ATM so there's no way to have a header or footer\n */\n const renderQuestionnaireAsPaginated = questionnaire.item.every(\n (item) => isPage(item) || isHeader(item) || isFooter(item)\n );\n\n if (renderQuestionnaireAsPaginated) {\n return constructPagesWithProperties(questionnaire.item, false);\n }\n\n /* 2. Using \"page\" item as a page-container - only preserved for backwards compatibility\n * - The first \"page\" item will be considered as a page-container, and all its children will be considered as pages\n * - You can have non-page items in the same level as the page-container to be used as faux headers or footers\n */\n const pageContainerItem = questionnaire.item.find((item) => isPage(item));\n if (pageContainerItem) {\n return constructPagesWithProperties(pageContainerItem.item, true);\n }\n\n return {};\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ProcessedValueSet, ValueSetPromise } from '../../interfaces/valueSet.interface';\nimport { getValueSetCodings, getValueSetPromise } from '../valueSet';\nimport type { Coding, Questionnaire, ValueSet } from 'fhir/r4';\n\nexport function extractContainedValueSets(\n questionnaire: Questionnaire,\n terminologyServerUrl: string\n): {\n processedValueSets: Record<string, ProcessedValueSet>;\n valueSetPromises: Record<string, ValueSetPromise>;\n cachedValueSetCodings: Record<string, Coding[]>;\n} {\n const processedValueSets: Record<string, ProcessedValueSet> = {};\n const valueSetPromises: Record<string, ValueSetPromise> = {};\n const cachedValueSetCodings: Record<string, Coding[]> = {};\n\n if (!questionnaire.contained || questionnaire.contained.length === 0) {\n return { processedValueSets, valueSetPromises, cachedValueSetCodings };\n }\n\n // Process contained ValueSets\n for (const entry of questionnaire.contained) {\n if (entry.resourceType !== 'ValueSet' || !entry.id) {\n continue;\n }\n\n // There are Codings in contained ValueSets, save into cache and skip to next iteration\n if (entry.expansion) {\n // Store contained valueSet codings\n processedValueSets[entry.id] = {\n initialValueSetUrl: entry.url ?? '',\n updatableValueSetUrl: entry.url ?? '',\n bindingParameters: [],\n isDynamic: false,\n linkIds: []\n };\n cachedValueSetCodings[entry.id] = getValueSetCodings(entry);\n continue;\n }\n\n // Add unexpanded contained ValueSets to valueSetPromiseMap\n const valueSetUrl = getValueSetUrlFromContained(entry);\n if (valueSetUrl) {\n valueSetPromises[entry.id] = {\n promise: getValueSetPromise(valueSetUrl, terminologyServerUrl)\n };\n continue;\n }\n\n if (entry.url) {\n processedValueSets[entry.id] = {\n initialValueSetUrl: entry.url,\n updatableValueSetUrl: entry.url,\n bindingParameters: [],\n isDynamic: false,\n linkIds: []\n };\n }\n }\n\n return { processedValueSets, valueSetPromises, cachedValueSetCodings };\n}\n\n/**\n * Sets an array of codings with the values from a valueSet\n *\n * @author Sean Fong\n */\nexport function getValueSetUrlFromContained(valueSet: ValueSet): string {\n const urls = valueSet.compose?.include?.map((include) =>\n include.valueSet?.[0] ? include.valueSet[0] : ''\n );\n\n return urls && urls.length > 0 ? urls[0] : '';\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// TODO to be imported into sdc-fhir-helpers\n\nimport type {\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireResponse,\n QuestionnaireResponseItem\n} from 'fhir/r4';\nimport type { Tabs } from '../interfaces';\nimport { getShortText } from './itemControl';\n\n// Get QuestionnaireItem from Questionnaire based on linkId\nexport function getQuestionnaireItem(\n questionnaire: Questionnaire,\n targetLinkId: string\n): QuestionnaireItem | null {\n // Search through the top level items recursively\n const topLevelQItems = questionnaire.item;\n if (topLevelQItems) {\n for (const topLevelQItem of topLevelQItems) {\n const foundQItem = getQuestionnaireItemRecursive(topLevelQItem, targetLinkId);\n if (foundQItem) {\n return foundQItem;\n }\n }\n }\n\n // No matching item found in the questionnaire, return null\n return null;\n}\n\nfunction getQuestionnaireItemRecursive(\n qItem: QuestionnaireItem,\n targetLinkId: string\n): QuestionnaireItem | null {\n // Target linkId found in current item\n if (qItem.linkId === targetLinkId) {\n return qItem;\n }\n\n // Search through its child items recursively\n const childQItems = qItem.item;\n if (childQItems) {\n for (const childQItem of childQItems) {\n const foundQItem = getQuestionnaireItemRecursive(childQItem, targetLinkId);\n if (foundQItem) {\n return foundQItem;\n }\n }\n }\n\n // No matching item found in the current item or its child items, return null\n return null;\n}\n\n// Get QuestionnaireResponseItem from QuestionnaireResponse based on linkId\nexport function getQuestionnaireResponseItem(\n questionnaireResponse: QuestionnaireResponse,\n targetLinkId: string\n): QuestionnaireResponseItem | null {\n // Search through the top level items recursively\n const topLevelQRItems = questionnaireResponse.item;\n if (topLevelQRItems) {\n for (const topLevelQRItem of topLevelQRItems) {\n const foundQRItem = getQuestionnaireResponseItemRecursive(topLevelQRItem, targetLinkId);\n if (foundQRItem) {\n return foundQRItem;\n }\n }\n }\n\n // No matching item found in the questionnaire, return null\n return null;\n}\n\nfunction getQuestionnaireResponseItemRecursive(\n qrItem: QuestionnaireResponseItem,\n targetLinkId: string\n): QuestionnaireResponseItem | null {\n // Target linkId found in current item\n if (qrItem.linkId === targetLinkId) {\n return qrItem;\n }\n\n // Search through its child items recursively\n const childQRItems = qrItem.item;\n if (childQRItems) {\n for (const childQRItem of childQRItems) {\n const foundQRItem = getQuestionnaireResponseItemRecursive(childQRItem, targetLinkId);\n if (foundQRItem) {\n return foundQRItem;\n }\n }\n }\n\n // No matching item found in the current item or its child items, return null\n return null;\n}\n\n// Replace QuestionnaireResponseItem in QuestionnaireResponse based on linkId with a new QR item\nexport function replaceQuestionnaireResponseItem(\n questionnaireResponse: QuestionnaireResponse,\n targetLinkId: string,\n newQRItem: QuestionnaireResponseItem | null\n): QuestionnaireResponse {\n if (!questionnaireResponse.item) return questionnaireResponse;\n\n const updatedItems = replaceQuestionnaireResponseItemRecursive(\n questionnaireResponse.item,\n targetLinkId,\n newQRItem\n );\n\n return {\n ...questionnaireResponse,\n item: updatedItems.length > 0 ? updatedItems : undefined // Remove top-level item array if empty\n };\n}\n\nfunction replaceQuestionnaireResponseItemRecursive(\n items: QuestionnaireResponseItem[],\n targetLinkId: string,\n newQRItem: QuestionnaireResponseItem | null\n): QuestionnaireResponseItem[] {\n return items\n .map((item) => {\n if (item.linkId === targetLinkId) {\n return newQRItem; // Replace or remove\n }\n\n if (!item.item) return item; // No child items, return as is\n\n const updatedChildren = replaceQuestionnaireResponseItemRecursive(\n item.item,\n targetLinkId,\n newQRItem\n );\n\n if (updatedChildren.length === 0) {\n return null; // Remove parent if all its children are gone\n }\n\n return { ...item, item: updatedChildren };\n })\n .filter(Boolean) as QuestionnaireResponseItem[]; // Remove any `null` entries\n}\n\nexport function getParentItem(\n questionnaire: Questionnaire,\n targetLinkId: string\n): QuestionnaireItem | null {\n // Search through the top level items recursively\n const topLevelQItems = questionnaire.item;\n if (topLevelQItems) {\n for (const topLevelQItem of topLevelQItems) {\n const foundParentQItem = getParentItemRecursive(topLevelQItem, targetLinkId);\n if (foundParentQItem) {\n return foundParentQItem;\n }\n }\n }\n\n // No matching parent item found in the questionnaire, return null\n return null;\n}\n\nfunction getParentItemRecursive(\n qItem: QuestionnaireItem,\n targetLinkId: string,\n parentQItem?: QuestionnaireItem\n): QuestionnaireItem | null {\n // Current item has the target linkId, return the parent item if it exists\n if (qItem.linkId === targetLinkId) {\n return parentQItem ?? null;\n }\n\n // Search through its child items recursively\n const childQItems = qItem.item;\n if (childQItems) {\n for (const childQItem of childQItems) {\n const foundParentQItem = getParentItemRecursive(childQItem, targetLinkId, qItem);\n if (foundParentQItem) {\n return foundParentQItem;\n }\n }\n }\n\n // No matching parent item found in the current item or its child items, return null\n return null;\n}\n\nexport function getRepeatGroupParentItem(\n questionnaire: Questionnaire,\n targetLinkId: string\n): QuestionnaireItem | null {\n // Search through the top level items recursively\n const topLevelQItems = questionnaire.item;\n if (topLevelQItems) {\n for (const topLevelQItem of topLevelQItems) {\n const foundParentQItem = getRepeatGroupParentItemRecursive(topLevelQItem, targetLinkId);\n if (foundParentQItem) {\n return foundParentQItem;\n }\n }\n }\n\n // No matching repeat group parent item found in the questionnaire, return null\n return null;\n}\n\nfunction getRepeatGroupParentItemRecursive(\n qItem: QuestionnaireItem,\n targetLinkId: string,\n repeatGroupParentQItem?: QuestionnaireItem\n): QuestionnaireItem | null {\n // Current item has the target linkId, return the parent item if it exists\n if (qItem.linkId === targetLinkId && repeatGroupParentQItem) {\n return repeatGroupParentQItem ?? null;\n }\n\n // Check if the current item is a repeat group\n const isRepeatGroup = qItem.repeats && qItem.type === 'group';\n\n // Search through its child items recursively\n const childQItems = qItem.item;\n if (childQItems) {\n for (const childQItem of childQItems) {\n const foundParentQItem = getRepeatGroupParentItemRecursive(\n childQItem,\n targetLinkId,\n isRepeatGroup ? qItem : repeatGroupParentQItem\n );\n if (foundParentQItem) {\n return foundParentQItem;\n }\n }\n }\n\n // No matching repeat group parent item found in the current item or its child items, return null\n return null;\n}\n\n/*\n Used for getting the tab section heading for Smart Form's re-population\n */\nexport function getSectionHeading(\n questionnaire: Questionnaire,\n targetLinkId: string,\n tabs: Tabs\n): string | null {\n // Search through the top level items recursively\n const topLevelQItems = questionnaire.item;\n if (topLevelQItems) {\n for (const topLevelQItem of topLevelQItems) {\n const heading = topLevelQItem.text ?? null;\n\n const foundQItem = getSectionHeadingRecursive(topLevelQItem, targetLinkId, heading, tabs);\n if (foundQItem) {\n return foundQItem;\n }\n }\n }\n\n // No heading found in the questionnaire, return null\n return null;\n}\n\nexport function getSectionHeadingRecursive(\n qItem: QuestionnaireItem,\n targetLinkId: string,\n heading: string | null,\n tabs: Tabs\n): string | null {\n // Target linkId found in current item\n if (qItem.linkId === targetLinkId) {\n return heading;\n }\n\n // Search through its child items recursively\n const childQItems = qItem.item;\n if (childQItems) {\n const isTab = !!tabs[qItem.linkId];\n if (isTab) {\n heading = getShortText(qItem) ?? qItem.text ?? null;\n }\n for (const childQItem of childQItems) {\n const foundHeading = getSectionHeadingRecursive(childQItem, targetLinkId, heading, tabs);\n if (foundHeading) {\n return foundHeading;\n }\n }\n }\n\n // No heading found in the current item or its child items, return null\n return null;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Expression, Extension, QuestionnaireItem } from 'fhir/r4';\nimport type { CalculatedExpression } from '../interfaces/calculatedExpression.interface';\n\n/**\n * Get enableWhenExpression.valueExpression if its present in item\n *\n * @author Sean Fong\n */\nexport function getInitialExpression(qItem: QuestionnaireItem): Expression | null {\n const initialExpression = qItem.extension?.find(\n (extension: Extension) =>\n extension.url ===\n 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression' &&\n extension.valueExpression?.language === 'text/fhirpath'\n );\n\n if (initialExpression?.valueExpression) {\n return initialExpression.valueExpression;\n }\n return null;\n}\n\n/**\n * Get enableWhenExpression.valueExpression if its present in item\n *\n * @author Sean Fong\n */\nexport function getEnableWhenExpression(qItem: QuestionnaireItem): Expression | null {\n const enableWhenExpression = qItem.extension?.find(\n (extension: Extension) =>\n extension.url ===\n 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression' &&\n extension.valueExpression?.language === 'text/fhirpath'\n );\n\n if (enableWhenExpression?.valueExpression) {\n return enableWhenExpression.valueExpression;\n }\n return null;\n}\n\n/**\n * Get calculatedExpression.valueExpression if its present in item or item._text\n *\n * @author Sean Fong\n */\nexport function getCalculatedExpressions(qItem: QuestionnaireItem): CalculatedExpression[] {\n // For questions - calculatedExpressions\n const calculatedExpressionsInItem = findCalculatedExpressionsInExtensions(qItem.extension ?? [])\n .map(\n (calculatedExpression): CalculatedExpression => ({\n expression: calculatedExpression.valueExpression?.expression ?? '',\n from: 'item'\n })\n )\n .filter((calculatedExpression) => calculatedExpression.expression !== '');\n\n // For item._text - calculatedExpressions and cqfExpressions\n // FIXME this is a band aid addition, eventually we want to fully support cqfExpressions\n const calculatedAndCqfExpressionsInText = [\n ...findCqfExpressionsInExtensions(qItem._text?.extension ?? []),\n ...findCalculatedExpressionsInExtensions(qItem._text?.extension ?? [])\n ]\n .map(\n (calculatedExpression): CalculatedExpression => ({\n expression: calculatedExpression.valueExpression?.expression ?? '',\n from: 'item._text'\n })\n )\n .filter((calculatedExpression) => calculatedExpression.expression !== '');\n\n return [...calculatedExpressionsInItem, ...calculatedAndCqfExpressionsInText];\n}\n\nexport function findCalculatedExpressionsInExtensions(extensions: Extension[]): Extension[] {\n return extensions.filter(\n (extension) =>\n extension.url ===\n 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression' &&\n extension.valueExpression?.language === 'text/fhirpath'\n );\n}\n\nfunction findCqfExpressionsInExtensions(extensions: Extension[]): Extension[] {\n return extensions.filter(\n (extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/cqf-expression' &&\n extension.valueExpression?.language === 'text/fhirpath'\n );\n}\n\n/**\n * Get answerExpression.valueExpression if its present in item\n *\n * @author Sean Fong\n */\nexport function getAnswerExpression(qItem: QuestionnaireItem): Expression | null {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url ===\n 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-answerExpression' &&\n extension.valueExpression?.language === 'text/fhirpath'\n );\n if (itemControl) {\n if (itemControl.valueExpression) {\n return itemControl.valueExpression;\n }\n }\n return null;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n Coding,\n Expression,\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireItemEnableWhen\n} from 'fhir/r4';\nimport type { CalculatedExpression } from '../../interfaces/calculatedExpression.interface';\nimport type {\n EnableWhenExpressions,\n EnableWhenItems,\n EnableWhenRepeatExpression,\n EnableWhenRepeatItemProperties,\n EnableWhenRepeatLinkedItem,\n EnableWhenSingleExpression,\n EnableWhenSingleItemProperties,\n EnableWhenSingleLinkedItem\n} from '../../interfaces/enableWhen.interface';\nimport type { AnswerExpression } from '../../interfaces/answerExpression.interface';\nimport type { ProcessedValueSet, ValueSetPromise } from '../../interfaces/valueSet.interface';\nimport { getTerminologyServerUrl, getValueSetPromise } from '../valueSet';\nimport type { Variables } from '../../interfaces/variables.interface';\nimport { getFhirPathVariables, getXFhirQueryVariables } from './extractVariables';\nimport { getRepeatGroupParentItem } from '../misc';\nimport { checkItemIsEnabledRepeat } from '../enableWhen';\nimport { emptyResponse } from '../emptyResource';\nimport { evaluateEnableWhenRepeatExpressionInstance } from '../enableWhenExpression';\nimport {\n getAnswerExpression,\n getCalculatedExpressions,\n getEnableWhenExpression,\n getInitialExpression\n} from '../getExpressionsFromItem';\nimport type { InitialExpression } from '../../interfaces/initialExpression.interface';\nimport { addBindingParametersToValueSetUrl, getBindingParameters } from '../parameterisedValueSets';\n\ninterface ReturnParamsRecursive {\n variables: Variables;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n calculatedExpressions: Record<string, CalculatedExpression[]>;\n initialExpressions: Record<string, InitialExpression>;\n answerExpressions: Record<string, AnswerExpression>;\n valueSetPromises: Record<string, ValueSetPromise>;\n processedValueSets: Record<string, ProcessedValueSet>;\n cachedValueSetCodings: Record<string, Coding[]>;\n answerOptions: Record<string, QuestionnaireItemAnswerOption[]>;\n}\n\nexport async function extractOtherExtensions(\n questionnaire: Questionnaire,\n variables: Variables,\n valueSetPromises: Record<string, ValueSetPromise>,\n processedValueSets: Record<string, ProcessedValueSet>,\n cachedValueSetCodings: Record<string, Coding[]>,\n itemPreferredTerminologyServers: Record<string, string>,\n terminologyServerUrl: string\n): Promise<ReturnParamsRecursive> {\n const enableWhenItems: EnableWhenItems = { singleItems: {}, repeatItems: {} };\n const enableWhenExpressions: EnableWhenExpressions = {\n singleExpressions: {},\n repeatExpressions: {}\n };\n const calculatedExpressions: Record<string, CalculatedExpression[]> = {};\n const initialExpressions: Record<string, InitialExpression> = {};\n const answerExpressions: Record<string, AnswerExpression> = {};\n const answerOptions: Record<string, QuestionnaireItemAnswerOption[]> = {};\n\n if (!questionnaire.item || questionnaire.item.length === 0) {\n return {\n variables: variables,\n enableWhenItems: { singleItems: {}, repeatItems: {} },\n enableWhenExpressions: {\n singleExpressions: {},\n repeatExpressions: {}\n },\n calculatedExpressions: {},\n initialExpressions: {},\n answerExpressions: {},\n answerOptions: {},\n valueSetPromises: valueSetPromises,\n processedValueSets: processedValueSets,\n cachedValueSetCodings: cachedValueSetCodings\n };\n }\n\n for (const topLevelItem of questionnaire.item) {\n const isRepeatGroup = !!topLevelItem.repeats && topLevelItem.type === 'group';\n await extractExtensionsFromItemRecursive({\n questionnaire,\n item: topLevelItem,\n variables,\n enableWhenItems,\n enableWhenExpressions,\n calculatedExpressions,\n initialExpressions,\n answerExpressions,\n answerOptions,\n valueSetPromises,\n processedValueSets,\n cachedValueSetCodings,\n itemPreferredTerminologyServers,\n defaultTerminologyServerUrl: terminologyServerUrl,\n parentRepeatGroupLinkId: isRepeatGroup ? topLevelItem.linkId : undefined\n });\n }\n\n return {\n variables,\n enableWhenItems,\n enableWhenExpressions,\n calculatedExpressions,\n initialExpressions,\n answerExpressions,\n answerOptions,\n valueSetPromises,\n processedValueSets,\n cachedValueSetCodings\n };\n}\n\ninterface extractExtensionsFromItemRecursiveParams {\n questionnaire: Questionnaire;\n item: QuestionnaireItem;\n variables: Variables;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n calculatedExpressions: Record<string, CalculatedExpression[]>;\n initialExpressions: Record<string, InitialExpression>;\n answerExpressions: Record<string, AnswerExpression>;\n answerOptions: Record<string, QuestionnaireItemAnswerOption[]>;\n valueSetPromises: Record<string, ValueSetPromise>;\n processedValueSets: Record<string, ProcessedValueSet>;\n cachedValueSetCodings: Record<string, Coding[]>;\n itemPreferredTerminologyServers: Record<string, string>;\n defaultTerminologyServerUrl: string;\n parentRepeatGroupLinkId?: string;\n}\n\nasync function extractExtensionsFromItemRecursive(\n params: extractExtensionsFromItemRecursiveParams\n): Promise<ReturnParamsRecursive> {\n const {\n questionnaire,\n item,\n variables,\n enableWhenItems,\n enableWhenExpressions,\n calculatedExpressions,\n initialExpressions,\n answerExpressions,\n answerOptions,\n valueSetPromises,\n processedValueSets,\n cachedValueSetCodings,\n itemPreferredTerminologyServers,\n defaultTerminologyServerUrl,\n parentRepeatGroupLinkId\n } = params;\n\n const items = item.item;\n const isRepeatGroup = !!item.repeats && item.type === 'group';\n if (items && items.length > 0) {\n // iterate through items of item recursively\n for (const childItem of items) {\n await extractExtensionsFromItemRecursive({\n ...params,\n item: childItem,\n parentRepeatGroupLinkId: isRepeatGroup ? item.linkId : parentRepeatGroupLinkId\n });\n }\n }\n\n // Read enable when items, enableWhen/calculated/answer expressions, valueSets and variables from qItem\n const initialisedEnableWhenItemProperties = initialiseEnableWhenItemProperties(\n item,\n questionnaire,\n parentRepeatGroupLinkId\n );\n if (initialisedEnableWhenItemProperties) {\n const { enableWhenItemType, enableWhenItemProperties } = initialisedEnableWhenItemProperties;\n if (enableWhenItemType === 'single') {\n enableWhenItems.singleItems[item.linkId] =\n enableWhenItemProperties as EnableWhenSingleItemProperties;\n } else if (enableWhenItemType === 'repeat') {\n enableWhenItems.repeatItems[item.linkId] =\n enableWhenItemProperties as EnableWhenRepeatItemProperties;\n }\n }\n\n // Get preferred terminology server URL of the item\n const preferredTerminologyServerUrl = itemPreferredTerminologyServers[item.linkId];\n const terminologyServerUrl =\n getTerminologyServerUrl(item) ?? preferredTerminologyServerUrl ?? defaultTerminologyServerUrl;\n\n const initialisedEnableWhenExpressions = await initialiseEnableWhenExpression(\n item,\n questionnaire,\n terminologyServerUrl,\n parentRepeatGroupLinkId\n );\n if (initialisedEnableWhenExpressions) {\n const { enableWhenExpressionType, enableWhenExpression } = initialisedEnableWhenExpressions;\n\n if (enableWhenExpressionType === 'single') {\n enableWhenExpressions.singleExpressions[item.linkId] =\n enableWhenExpression as EnableWhenSingleExpression;\n } else if (enableWhenExpressionType === 'repeat') {\n enableWhenExpressions.repeatExpressions[item.linkId] =\n enableWhenExpression as EnableWhenRepeatExpression;\n }\n }\n\n // Get calculatedExpressions\n const calculatedExpressionsOfItem = getCalculatedExpressions(item);\n if (calculatedExpressionsOfItem.length > 0) {\n calculatedExpressions[item.linkId] = calculatedExpressionsOfItem;\n }\n\n // Get initialExpressions\n const initialExpression = getInitialExpression(item);\n if (initialExpression) {\n initialExpressions[item.linkId] = {\n expression: `${initialExpression.expression}`\n };\n }\n\n // Get answerExpressions\n const answerExpression = getAnswerExpression(item);\n if (answerExpression) {\n answerExpressions[item.linkId] = {\n expression: `${answerExpression.expression}`\n };\n }\n\n // Get answerOptions\n const options = item.answerOption ?? null;\n if (options) {\n answerOptions[item.linkId] = options;\n }\n\n const initialValueSetUrl = item.answerValueSet;\n if (initialValueSetUrl) {\n const bindingParameters = getBindingParameters(item, initialValueSetUrl);\n const fixedBindingParameters = bindingParameters.filter((param) => !param.fhirPathExpression);\n const isDynamic = bindingParameters.length !== fixedBindingParameters.length;\n const valueSetUrlWithParams = addBindingParametersToValueSetUrl(\n initialValueSetUrl,\n fixedBindingParameters\n );\n\n // Only continue to process if answerValueSetUrl is not a reference, because we have already processed it earlier\n if (!initialValueSetUrl.startsWith('#')) {\n // Get valueSet promise to be resolved\n // Note: this entry uses valueSetUrlWithParams as the key\n if (!valueSetPromises[initialValueSetUrl]) {\n valueSetPromises[valueSetUrlWithParams] = {\n promise: getValueSetPromise(valueSetUrlWithParams, terminologyServerUrl)\n };\n }\n\n // Create entries in processedValueSets and cachedValueSetCodings\n // Note: initialValueSetUrl is key for processedValueSets, while valueSetUrlWithParams is key for cachedValueSetCodings\n if (!processedValueSets[initialValueSetUrl]) {\n processedValueSets[initialValueSetUrl] = {\n initialValueSetUrl: initialValueSetUrl,\n updatableValueSetUrl: valueSetUrlWithParams,\n bindingParameters: bindingParameters,\n isDynamic: isDynamic,\n linkIds: [item.linkId]\n };\n } else {\n processedValueSets[initialValueSetUrl].linkIds.push(item.linkId);\n }\n cachedValueSetCodings[valueSetUrlWithParams] = [];\n }\n }\n\n if (item.extension) {\n variables.fhirPathVariables[item.linkId] = getFhirPathVariables(item.extension);\n\n for (const expression of getXFhirQueryVariables(item.extension)) {\n if (expression.name) {\n variables.xFhirQueryVariables[expression.name] = {\n valueExpression: expression\n };\n }\n }\n }\n\n return {\n variables,\n enableWhenItems,\n enableWhenExpressions,\n calculatedExpressions,\n initialExpressions,\n answerExpressions,\n answerOptions,\n valueSetPromises,\n processedValueSets,\n cachedValueSetCodings\n };\n}\n\n/**\n * Get enableWhen items' linked items and enableBehaviour attribute and save them in an EnableWhenItemProperties object\n *\n * @author Sean Fong\n */\nexport function initialiseEnableWhenItemProperties(\n qItem: QuestionnaireItem,\n questionnaire: Questionnaire,\n parentLinkId?: string\n): {\n enableWhenItemType: 'single' | 'repeat';\n enableWhenItemProperties: EnableWhenSingleItemProperties | EnableWhenRepeatItemProperties;\n} | null {\n const enableWhen = qItem.enableWhen;\n if (!enableWhen) {\n return null;\n }\n\n // Parent repeat group linkId exist, try to classify this item as a repeat enableWhen item\n if (parentLinkId) {\n const enableWhenRepeatItemProperties = initialiseEnableWhenRepeatItemProperties(\n qItem,\n enableWhen,\n questionnaire,\n parentLinkId\n );\n\n if (enableWhenRepeatItemProperties) {\n return {\n enableWhenItemType: 'repeat',\n enableWhenItemProperties: enableWhenRepeatItemProperties\n };\n }\n }\n\n // If parentLinkId is not provided or item cannot be classified as a repeat enableWhen item, classify it as a single enableWhen item\n const enableWhenSingleItemProperties = initialiseEnableWhenSingleItemProperties(\n qItem,\n enableWhen\n );\n return {\n enableWhenItemType: 'single',\n enableWhenItemProperties: enableWhenSingleItemProperties\n };\n}\n\nexport function initialiseEnableWhenRepeatItemProperties(\n qItem: QuestionnaireItem,\n enableWhen: QuestionnaireItemEnableWhen[],\n questionnaire: Questionnaire,\n parentLinkId: string\n): EnableWhenRepeatItemProperties | null {\n const linkedItemsNullable = enableWhen.map((linkedItem): EnableWhenRepeatLinkedItem | null => {\n const linkedParentItem = getRepeatGroupParentItem(questionnaire, linkedItem.question);\n // Check if parentLinkId match the linked item's parent linkId\n if (parentLinkId === linkedParentItem?.linkId) {\n return { enableWhen: linkedItem, parentLinkId: linkedParentItem.linkId, answers: [] };\n }\n\n // Otherwise, this linked item is not a valid repeat enableWhen linked item\n return null;\n });\n\n // If any linked item is not valid, exit early\n if (linkedItemsNullable.some((linkedItem) => linkedItem === null)) {\n return null;\n }\n\n const linkedItems = linkedItemsNullable as EnableWhenRepeatLinkedItem[];\n const enableWhenRepeatItemProperties = {\n linked: linkedItems as EnableWhenRepeatLinkedItem[],\n parentLinkId: parentLinkId,\n enabledIndexes: [false],\n enableBehavior: qItem.enableBehavior\n };\n\n enableWhenRepeatItemProperties.enabledIndexes[0] = checkItemIsEnabledRepeat(\n enableWhenRepeatItemProperties,\n 0\n );\n\n return enableWhenRepeatItemProperties;\n}\n\n/**\n * Get enableWhen items' linked items and enableBehaviour attribute and save them in an EnableWhenItemProperties object\n *\n * @author Sean Fong\n */\nexport function initialiseEnableWhenSingleItemProperties(\n qItem: QuestionnaireItem,\n enableWhen: QuestionnaireItemEnableWhen[]\n): EnableWhenSingleItemProperties {\n return {\n linked: enableWhen.map((linkedItem): EnableWhenSingleLinkedItem => {\n return { enableWhen: linkedItem };\n }),\n isEnabled: false,\n enableBehavior: qItem.enableBehavior\n };\n}\n\nfunction initialiseEnableWhenExpressionRepeat(\n enableWhenExpression: Expression,\n questionnaire: Questionnaire,\n parentLinkId: string\n): Expression | null {\n const expression = enableWhenExpression.expression;\n if (!expression) {\n return null;\n }\n\n // Get the last linkId in the expression\n const regExpLinkId = /linkId\\s*=\\s*'([^']+)'/g;\n const matches = expression.replace(' ', '').match(regExpLinkId);\n if (!matches) {\n return null;\n }\n const linkIdMatches = matches.map((match) =>\n match.substring(match.indexOf(\"'\") + 1, match.lastIndexOf(\"'\"))\n );\n const lastLinkIdMatch = linkIdMatches[linkIdMatches.length - 1];\n\n // Use the last linkId as the linkedItem, and get it's repeat group parent item's linkId\n // If both parent linkId matches, this enableWhenExpression is a repeat enableWhenExpression\n const linkedParentItem = getRepeatGroupParentItem(questionnaire, lastLinkIdMatch);\n if (parentLinkId === linkedParentItem?.linkId) {\n return enableWhenExpression;\n }\n\n return null;\n}\n\nasync function initialiseEnableWhenExpression(\n qItem: QuestionnaireItem,\n questionnaire: Questionnaire,\n terminologyServerUrl: string,\n parentLinkId?: string\n): Promise<{\n enableWhenExpressionType: 'single' | 'repeat';\n enableWhenExpression: EnableWhenSingleExpression | EnableWhenRepeatExpression;\n} | null> {\n const enableWhenExpression = getEnableWhenExpression(qItem);\n if (!enableWhenExpression) {\n return null;\n }\n\n // Parent repeat group linkId exist, try to classify this item as a repeat enableWhen item\n if (parentLinkId) {\n const expressionRepeat = initialiseEnableWhenExpressionRepeat(\n enableWhenExpression,\n questionnaire,\n parentLinkId\n );\n\n if (expressionRepeat) {\n const enableWhenRepeatExpression = {\n expression: `${expressionRepeat.expression}`,\n parentLinkId: parentLinkId,\n enabledIndexes: [false]\n };\n\n const { isEnabled } = await evaluateEnableWhenRepeatExpressionInstance(\n qItem.linkId,\n { resource: structuredClone(emptyResponse) },\n enableWhenRepeatExpression,\n enableWhenRepeatExpression.expression.lastIndexOf('.where(linkId'),\n 0,\n terminologyServerUrl\n );\n\n if (typeof isEnabled === 'boolean') {\n enableWhenRepeatExpression.enabledIndexes[0] = isEnabled;\n }\n\n return {\n enableWhenExpressionType: 'repeat',\n enableWhenExpression: enableWhenRepeatExpression\n };\n }\n }\n\n return {\n enableWhenExpressionType: 'single',\n enableWhenExpression: {\n expression: `${enableWhenExpression.expression}`\n }\n };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createValueSetToXFhirQueryVariableNameMap,\n getValueSetCodings,\n getValueSetPromise,\n resolveValueSetPromises\n} from '../valueSet';\nimport type { Variables } from '../../interfaces/variables.interface';\nimport type { ValueSetPromise } from '../../interfaces/valueSet.interface';\nimport type { Coding } from 'fhir/r4';\n\nexport async function resolveValueSets(\n variables: Variables,\n valueSetPromises: Record<string, ValueSetPromise>,\n cachedValueSetCodings: Record<string, Coding[]>,\n terminologyServerUrl: string\n): Promise<{\n variables: Variables;\n cachedValueSetCodings: Record<string, Coding[]>;\n}> {\n // Create a <valueSetUrl, XFhirQueryVariableName> map\n const valueSetToXFhirQueryVariableNameMap: Record<string, string> =\n createValueSetToXFhirQueryVariableNameMap(variables.xFhirQueryVariables);\n\n if (Object.keys(valueSetToXFhirQueryVariableNameMap).length > 0) {\n for (const valueSetUrl in valueSetToXFhirQueryVariableNameMap) {\n valueSetPromises[valueSetUrl] = {\n promise: getValueSetPromise(valueSetUrl, terminologyServerUrl)\n };\n }\n }\n\n // Resolve promises and store valueSet codings in XFhirQueryVariables and cachedValueSetCodings\n const resolvedPromises = await resolveValueSetPromises(valueSetPromises);\n\n for (const valueSetUrl in resolvedPromises) {\n const valueSet = resolvedPromises[valueSetUrl]?.valueSet;\n\n if (valueSet) {\n // valueSetUrl is in x-fhir-query variables, save to variable\n if (valueSetToXFhirQueryVariableNameMap[valueSetUrl]) {\n const variableName = valueSetToXFhirQueryVariableNameMap[valueSetUrl];\n if (variableName) {\n const variable = variables.xFhirQueryVariables[variableName];\n if (variable) {\n variables.xFhirQueryVariables[variableName] = {\n ...variable,\n result: resolvedPromises[valueSetUrl]?.valueSet\n };\n }\n }\n }\n\n // Store codings in cachedValueSetCodings\n cachedValueSetCodings[valueSetUrl] = getValueSetCodings(valueSet);\n }\n }\n\n return { variables, cachedValueSetCodings };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Extension } from 'fhir/r4';\nimport type { Variables } from '../../interfaces/variables.interface';\n\nexport function addAdditionalVariables(\n existingVariables: Variables,\n additionalVariables: Record<string, object>\n) {\n for (const key in additionalVariables) {\n const variable = additionalVariables[key];\n\n if (variable && isVariable(variable)) {\n const expression = variable.valueExpression;\n if (expression && expression.language && expression.name) {\n if (expression.language === 'text/fhirpath') {\n existingVariables.fhirPathVariables['QuestionnaireLevel'].push(expression);\n } else if (expression.language === 'application/x-fhir-query') {\n existingVariables.xFhirQueryVariables[expression.name] = {\n valueExpression: expression\n };\n }\n }\n }\n }\n\n return existingVariables;\n}\n\nfunction isVariable(variable: object): variable is Extension {\n const v = variable as Extension;\n return (\n (v.url === 'http://hl7.org/fhir/StructureDefinition/variable' &&\n v.valueExpression?.language === 'text/fhirpath') ||\n v.valueExpression?.language === 'application/x-fhir-query'\n );\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Coding, QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport type { CodeSystemLookupPromise } from '../../interfaces/lookup.interface';\nimport * as FHIR from 'fhirclient';\n\n// Use this for QuestionnaireStore.cachedValueSetCodings\nexport async function addDisplayToCacheCodings(\n cachedValueSetCodings: Record<string, Coding[]>,\n terminologyServerUrl: string\n): Promise<Record<string, Coding[]>> {\n // Store code system lookup promises for codings without displays\n const codeSystemLookupPromises: Record<string, CodeSystemLookupPromise> = {};\n for (const key in cachedValueSetCodings) {\n const codings = cachedValueSetCodings[key];\n for (const coding of codings) {\n if (!coding.display) {\n const query = `system=${coding.system}&code=${coding.code}`;\n codeSystemLookupPromises[query] = {\n promise: getCodeSystemLookupPromise(query, terminologyServerUrl),\n oldCoding: coding\n };\n }\n }\n }\n\n // Resolves lookup promises in one go and assign newCodings to processedCodings\n const resolvedCodeSystemLookupPromises = await resolveLookupPromises(codeSystemLookupPromises);\n for (const key in cachedValueSetCodings) {\n const codings = cachedValueSetCodings[key];\n for (const coding of codings) {\n const lookUpKey = `system=${coding.system}&code=${coding.code}`;\n const resolvedLookup = resolvedCodeSystemLookupPromises[lookUpKey];\n if (resolvedLookup?.newCoding?.display) {\n coding.display = resolvedLookup.newCoding.display;\n }\n }\n }\n\n return cachedValueSetCodings;\n}\n\n// Use this for a Record<linkId, answerOption[]>\nexport async function addDisplayToAnswerOptions(\n answerOptions: Record<string, QuestionnaireItemAnswerOption[]>,\n terminologyServerUrl: string\n): Promise<Record<string, QuestionnaireItemAnswerOption[]>> {\n // Store code system lookup promises for codings without displays\n const codeSystemLookupPromises: Record<string, CodeSystemLookupPromise> = {};\n for (const key in answerOptions) {\n const options = answerOptions[key];\n for (const option of options) {\n if (option.valueCoding && !option.valueCoding.display) {\n const query = `system=${option.valueCoding.system}&code=${option.valueCoding.code}`;\n codeSystemLookupPromises[query] = {\n promise: getCodeSystemLookupPromise(query, terminologyServerUrl),\n oldCoding: option.valueCoding\n };\n }\n }\n }\n\n // Resolves lookup promises in one go and assign newCodings to processedCodings\n const resolvedCodeSystemLookupPromises = await resolveLookupPromises(codeSystemLookupPromises);\n for (const key in answerOptions) {\n const options = answerOptions[key];\n\n for (const option of options) {\n if (option.valueCoding) {\n const lookUpKey = `system=${option.valueCoding.system}&code=${option.valueCoding.code}`;\n const resolvedLookup = resolvedCodeSystemLookupPromises[lookUpKey];\n if (resolvedLookup?.newCoding?.display) {\n option.valueCoding.display = resolvedLookup.newCoding.display;\n }\n }\n }\n }\n\n return answerOptions;\n}\n\n// Use this for an array of codings\nexport async function addDisplayToCodingArray(\n codings: Coding[],\n terminologyServerUrl: string\n): Promise<Coding[]> {\n // Store code system lookup promises for codings without displays\n const codeSystemLookupPromises: Record<string, CodeSystemLookupPromise> = {};\n for (const coding of codings) {\n if (!coding.display) {\n const query = `system=${coding.system}&code=${coding.code}`;\n codeSystemLookupPromises[query] = {\n promise: getCodeSystemLookupPromise(query, terminologyServerUrl),\n oldCoding: coding\n };\n }\n }\n\n // Resolves lookup promises in one go and assign newCodings to processedCodings\n const resolvedCodeSystemLookupPromises = await resolveLookupPromises(codeSystemLookupPromises);\n for (const coding of codings) {\n const lookUpKey = `system=${coding.system}&code=${coding.code}`;\n const resolvedLookup = resolvedCodeSystemLookupPromises[lookUpKey];\n if (resolvedLookup?.newCoding?.display) {\n coding.display = resolvedLookup.newCoding.display;\n }\n }\n\n return codings;\n}\n\nexport function getCodeSystemLookupPromise(query: string, terminologyServerUrl: string) {\n return FHIR.client({ serverUrl: terminologyServerUrl }).request({\n url: `CodeSystem/$lookup?${query}`\n });\n}\n\nexport async function resolveLookupPromises(\n codeSystemLookupPromises: Record<string, CodeSystemLookupPromise>\n): Promise<Record<string, CodeSystemLookupPromise>> {\n const newCodeSystemLookupPromises: Record<string, CodeSystemLookupPromise> = {};\n\n const lookupPromiseKeys = Object.keys(codeSystemLookupPromises);\n const lookupPromiseValues = Object.values(codeSystemLookupPromises);\n\n const promises = lookupPromiseValues.map((lookupPromise) => lookupPromise.promise);\n const settledPromises = await Promise.allSettled(promises);\n\n for (const [i, settledPromise] of settledPromises.entries()) {\n if (settledPromise.status === 'rejected') {\n continue;\n }\n\n const lookupResult = settledPromise.value;\n if (!lookupResponseIsValid(lookupResult)) {\n continue;\n }\n\n const key = lookupPromiseKeys[i];\n const lookupPromise = lookupPromiseValues[i];\n\n if (key && lookupPromise) {\n lookupPromise.newCoding = {\n ...lookupPromise.oldCoding,\n display: lookupResult.parameter.find((p) => p.name === 'display')?.valueString ?? undefined\n };\n newCodeSystemLookupPromises[key] = lookupPromise;\n }\n }\n\n return newCodeSystemLookupPromises;\n}\n\nexport interface LookupResponse {\n parameter: [DisplayParameter];\n}\n\nexport interface DisplayParameter {\n name: 'display';\n valueString: string;\n}\n\nexport function lookupResponseIsValid(response: any): response is LookupResponse {\n return (\n response &&\n response.resourceType === 'Parameters' &&\n response.parameter &&\n response.parameter.find((p: any) => p.name === 'display') &&\n response.parameter.find((p: any) => p.name === 'display').valueString\n );\n}\n","import type { Extension, Questionnaire } from 'fhir/r4';\nimport type {\n TargetConstraint,\n TargetConstraintExpression,\n TargetConstraintHuman,\n TargetConstraintKey,\n TargetConstraintLocation,\n TargetConstraintSeverity\n} from '../../interfaces/targetConstraint.interface';\n\nexport function constructTargetConstraint(extension: Extension): TargetConstraint | null {\n const targetConstraintUrl = extension.url;\n const targetConstraintKey = extension.extension?.find(\n (ext) => ext.url === 'key' && typeof ext.valueId === 'string'\n ) as TargetConstraintKey | undefined;\n\n const targetConstraintSeverity = extension.extension?.find(\n (ext) =>\n ext.url === 'severity' &&\n ext.valueCode &&\n (ext.valueCode === 'error' || ext.valueCode === 'warning')\n ) as TargetConstraintSeverity | undefined;\n\n const targetConstraintExpression = extension.extension?.find(\n (ext) => ext.url === 'expression' && ext.valueExpression\n ) as TargetConstraintExpression | undefined;\n\n const targetConstraintHuman = extension.extension?.find(\n (ext) => ext.url === 'human' && ext.valueString\n ) as TargetConstraintHuman | undefined;\n\n const hasTargetConstraintLocation = extension.extension?.find(\n (ext) => ext.url === 'location' && ext.valueString\n ) as TargetConstraintLocation | undefined;\n\n if (\n targetConstraintUrl === 'http://hl7.org/fhir/StructureDefinition/targetConstraint' &&\n targetConstraintKey &&\n targetConstraintSeverity &&\n targetConstraintExpression &&\n targetConstraintHuman\n ) {\n return {\n key: targetConstraintKey.valueId,\n severityCode: targetConstraintSeverity.valueCode,\n valueExpression: targetConstraintExpression.valueExpression,\n human: targetConstraintHuman.valueString,\n location: hasTargetConstraintLocation?.valueString\n };\n }\n\n return null;\n}\n\nexport function extractTargetConstraints(\n questionnaire: Questionnaire\n): Record<string, TargetConstraint> {\n if (!questionnaire.extension || questionnaire.extension.length === 0) {\n return {};\n }\n\n const targetConstraints: Record<string, TargetConstraint> = {};\n for (const ext of questionnaire.extension) {\n const targetConstraint = constructTargetConstraint(ext);\n if (targetConstraint?.key) {\n targetConstraints[targetConstraint?.key] = targetConstraint;\n }\n }\n\n return targetConstraints;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Questionnaire } from 'fhir/r4';\nimport type { Tabs } from '../../interfaces/tab.interface';\nimport type { Pages } from '../../interfaces/page.interface';\nimport type { LaunchContext } from '../../interfaces/populate.interface';\nimport type { QuestionnaireModel } from '../../interfaces/questionnaireStore.interface';\nimport { extractLaunchContexts } from './extractLaunchContext';\nimport { extractQuestionnaireLevelVariables } from './extractVariables';\nimport { extractTabs } from './extractTabs';\nimport { extractPages } from './extractPages';\nimport { extractContainedValueSets } from './extractContainedValueSets';\nimport { extractOtherExtensions } from './extractOtherExtensions';\nimport type { Variables } from '../../interfaces/variables.interface';\nimport { resolveValueSets } from './resolveValueSets';\nimport { addAdditionalVariables } from './addAdditionalVariables';\nimport { getLinkIdPreferredTerminologyServerTuples, getLinkIdTypeTuples } from '../qItem';\nimport { addDisplayToAnswerOptions, addDisplayToCacheCodings } from './addDisplayToCodings';\nimport type { TargetConstraint } from '../../interfaces/targetConstraint.interface';\nimport { extractTargetConstraints } from './extractTargetConstraint';\n\nexport async function createQuestionnaireModel(\n questionnaire: Questionnaire,\n additionalVariables: Record<string, object>,\n terminologyServerUrl: string\n): Promise<QuestionnaireModel> {\n if (!questionnaire.item) {\n return createEmptyModel();\n }\n\n const itemTypes: Record<string, string> = Object.fromEntries(getLinkIdTypeTuples(questionnaire));\n const itemPreferredTerminologyServers: Record<string, string> = Object.fromEntries(\n getLinkIdPreferredTerminologyServerTuples(questionnaire)\n );\n const tabs: Tabs = extractTabs(questionnaire);\n const pages: Pages = extractPages(questionnaire);\n\n const launchContexts: Record<string, LaunchContext> = extractLaunchContexts(questionnaire);\n const targetConstraints: Record<string, TargetConstraint> =\n extractTargetConstraints(questionnaire);\n\n let variables: Variables = extractQuestionnaireLevelVariables(questionnaire);\n variables = addAdditionalVariables(variables, additionalVariables);\n\n const extractContainedValueSetsResult = extractContainedValueSets(\n questionnaire,\n terminologyServerUrl\n );\n let valueSetPromises = extractContainedValueSetsResult.valueSetPromises;\n let processedValueSets = extractContainedValueSetsResult.processedValueSets;\n let cachedValueSetCodings = extractContainedValueSetsResult.cachedValueSetCodings;\n\n const extractOtherExtensionsResult = await extractOtherExtensions(\n questionnaire,\n variables,\n valueSetPromises,\n processedValueSets,\n cachedValueSetCodings,\n itemPreferredTerminologyServers,\n terminologyServerUrl\n );\n\n const {\n enableWhenItems,\n enableWhenExpressions,\n calculatedExpressions,\n initialExpressions,\n answerExpressions,\n answerOptions\n } = extractOtherExtensionsResult;\n variables = extractOtherExtensionsResult.variables;\n valueSetPromises = extractOtherExtensionsResult.valueSetPromises;\n processedValueSets = extractOtherExtensionsResult.processedValueSets;\n cachedValueSetCodings = extractOtherExtensionsResult.cachedValueSetCodings;\n\n const resolveValueSetsResult = await resolveValueSets(\n variables,\n valueSetPromises,\n cachedValueSetCodings,\n terminologyServerUrl\n );\n\n variables = resolveValueSetsResult.variables;\n cachedValueSetCodings = resolveValueSetsResult.cachedValueSetCodings;\n\n // In processedCodings, add display values to codings lacking them\n cachedValueSetCodings = await addDisplayToCacheCodings(\n cachedValueSetCodings,\n terminologyServerUrl\n );\n\n // In answerOptions, add display values to codings lacking them\n const completeAnswerOptions = await addDisplayToAnswerOptions(\n answerOptions,\n terminologyServerUrl\n );\n\n return {\n itemTypes,\n itemPreferredTerminologyServers,\n tabs,\n pages,\n variables,\n launchContexts,\n targetConstraints,\n enableWhenItems,\n enableWhenExpressions,\n calculatedExpressions,\n initialExpressions,\n answerExpressions,\n answerOptions: completeAnswerOptions,\n processedValueSets,\n cachedValueSetCodings,\n fhirPathContext: {},\n fhirPathTerminologyCache: {}\n };\n}\n\nfunction createEmptyModel(): QuestionnaireModel {\n return {\n itemTypes: {},\n itemPreferredTerminologyServers: {},\n tabs: {},\n pages: {},\n variables: { fhirPathVariables: {}, xFhirQueryVariables: {} },\n launchContexts: {},\n targetConstraints: {},\n calculatedExpressions: {},\n initialExpressions: {},\n enableWhenExpressions: { singleExpressions: {}, repeatExpressions: {} },\n answerExpressions: {},\n answerOptions: {},\n enableWhenItems: { singleItems: {}, repeatItems: {} },\n processedValueSets: {},\n cachedValueSetCodings: {},\n fhirPathContext: {},\n fhirPathTerminologyCache: {}\n };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireResponse,\n QuestionnaireResponseItem\n} from 'fhir/r4';\n\nexport function createQuestionnaireResponseItemMap(\n sourceQuestionnaire: Questionnaire,\n questionnaireResponse: QuestionnaireResponse\n): Record<string, QuestionnaireResponseItem[]> {\n if (!sourceQuestionnaire.item || sourceQuestionnaire.item.length === 0) {\n return {};\n }\n\n // Even if the questionnaireResponse has no items, we still need to identify an empty entry for every linkId\n const questionnaireResponseItemMap: Record<string, QuestionnaireResponseItem[]> = {};\n for (const topLevelQItem of sourceQuestionnaire.item) {\n fillQuestionnaireResponseItemMapEmptyEntriesRecursive(\n topLevelQItem,\n questionnaireResponseItemMap\n );\n }\n\n // Now loop through the questionnaireResponse items and fill the map\n if (questionnaireResponse.item) {\n for (const topLevelQRItem of questionnaireResponse.item) {\n fillQuestionnaireResponseItemMapRecursive(topLevelQRItem, questionnaireResponseItemMap);\n }\n }\n\n return questionnaireResponseItemMap;\n}\n\nfunction fillQuestionnaireResponseItemMapRecursive(\n qrItem: QuestionnaireResponseItem,\n questionnaireResponseItemMap: Record<string, QuestionnaireResponseItem[]>\n) {\n const qrItems = qrItem.item;\n if (qrItems && qrItems.length > 0) {\n // iterate through items of item recursively\n for (const childQRItem of qrItems) {\n fillQuestionnaireResponseItemMapRecursive(childQRItem, questionnaireResponseItemMap);\n }\n }\n\n fillQuestionnaireResponseItemMap(qrItem, questionnaireResponseItemMap);\n}\n\nfunction fillQuestionnaireResponseItemMap(\n qrItem: QuestionnaireResponseItem,\n questionnaireResponseItemMap: Record<string, QuestionnaireResponseItem[]>\n) {\n // linkId already exists in questionnaireResponseItemMap, it would be a repeat group\n if (qrItem.linkId in questionnaireResponseItemMap) {\n questionnaireResponseItemMap[qrItem.linkId].push(qrItem);\n }\n // Add item to questionnaireResponseItemMap\n else {\n questionnaireResponseItemMap[qrItem.linkId] = [qrItem];\n }\n}\n\nfunction fillQuestionnaireResponseItemMapEmptyEntriesRecursive(\n qItem: QuestionnaireItem,\n questionnaireResponseItemMap: Record<string, QuestionnaireResponseItem[]>\n) {\n const qItems = qItem.item;\n if (qItems && qItems.length > 0) {\n // iterate through items of item recursively\n for (const childQItem of qItems) {\n fillQuestionnaireResponseItemMapEmptyEntriesRecursive(\n childQItem,\n questionnaireResponseItemMap\n );\n }\n }\n\n questionnaireResponseItemMap[qItem.linkId] = [];\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { evaluateInitialEnableWhenExpressions } from './enableWhenExpression';\nimport { getFirstVisibleTab } from './tabs';\nimport { getFirstVisiblePage } from './page';\nimport type {\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireItemInitial,\n QuestionnaireResponse,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';\nimport type { Tabs } from '../interfaces/tab.interface';\nimport type { Pages } from '../interfaces/page.interface';\nimport { assignPopulatedAnswersToEnableWhen } from './enableWhen';\nimport type { CalculatedExpression } from '../interfaces/calculatedExpression.interface';\nimport { evaluateInitialCalculatedExpressions } from './calculatedExpression';\nimport { createQuestionnaireResponseItemMap } from './questionnaireResponseStoreUtils/updatableResponseItems';\nimport { readQuestionnaireResponse } from './genericRecursive';\nimport { getQrItemsIndex, mapQItemsIndex } from './mapItem';\nimport type { TargetConstraint } from '../interfaces/targetConstraint.interface';\nimport { evaluateInitialTargetConstraints } from './targetConstraint';\nimport type { Variables } from '../interfaces';\nimport { getRelevantCodingProperties } from './valueSet';\nimport type { ProcessedValueSet } from '../interfaces/valueSet.interface';\nimport { evaluateInitialDynamicValueSets } from './parameterisedValueSets';\n\n/**\n * Initialise a questionnaireResponse from a given questionnaire\n * optionally takes in an existing questionnaireResponse to be initialised\n *\n * @author Sean Fong\n */\nexport function initialiseQuestionnaireResponse(\n questionnaire: Questionnaire,\n questionnaireResponse?: QuestionnaireResponse\n) {\n if (!questionnaireResponse) {\n questionnaireResponse = {\n resourceType: 'QuestionnaireResponse',\n status: 'in-progress'\n };\n }\n\n if (!questionnaireResponse.status) {\n questionnaireResponse.status = 'in-progress';\n }\n\n const firstTopLevelItem = questionnaire?.item?.[0];\n if (firstTopLevelItem && !questionnaireResponse.item) {\n const initialItems = readQuestionnaireResponse(\n questionnaire,\n questionnaireResponse,\n readInitialValuesRecursive\n );\n\n if (initialItems && initialItems.length > 0) {\n questionnaireResponse.item = initialItems;\n }\n }\n\n if (!questionnaireResponse.questionnaire) {\n questionnaireResponse.questionnaire = createQuestionnaireReference(questionnaire);\n }\n\n // Add \"http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaireresponse\" profile\n // const profiles: string[] = [\n // 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaireresponse'\n // ];\n // questionnaireResponse.meta = questionnaireResponse.meta || {};\n // questionnaireResponse.meta.profile = profiles;\n\n return questionnaireResponse;\n}\n\nfunction createQuestionnaireReference(questionnaire: Questionnaire) {\n // Use {url}|{version}\n if (questionnaire.url) {\n let questionnaireReference = questionnaire.url;\n if (questionnaire.version) {\n questionnaireReference += '|' + questionnaire.version;\n }\n return questionnaireReference;\n }\n\n // If no url exists, use Questionnaire/{id}\n if (questionnaire.id) {\n return `Questionnaire/${questionnaire.id}`;\n }\n\n return '';\n}\n\nfunction readInitialValuesRecursive(\n qItem: QuestionnaireItem,\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null\n): QuestionnaireResponseItem[] | null {\n // Process items with child items\n const initialValues: QuestionnaireResponseItem[] = [];\n const childQItems = qItem.item;\n if (childQItems && childQItems.length > 0) {\n // Process repeating group items separately\n if (qItem.type === 'group' && qItem.repeats) {\n const initialItemsFromRepeatGroup = getInitialValueAnswersFromRepeatGroup(\n qItem,\n qrItemOrItems\n );\n const newRepeatGroupQuestionnaireResponseItem = createNewRepeatGroupQuestionnaireResponseItem(\n qItem,\n initialItemsFromRepeatGroup\n );\n\n return newRepeatGroupQuestionnaireResponseItem\n ? [newRepeatGroupQuestionnaireResponseItem]\n : null;\n }\n\n // Map qrItemOrItems into an array of qrItems\n let childQrItems: QuestionnaireResponseItem[] = [];\n if (qrItemOrItems) {\n if (Array.isArray(qrItemOrItems)) {\n childQrItems = qrItemOrItems;\n } else {\n childQrItems = qrItemOrItems.item ?? [];\n }\n }\n\n const indexMap = mapQItemsIndex(qItem);\n const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap);\n\n for (const [index, childQItem] of childQItems.entries()) {\n const childQRItemOrItems = qrItemsByIndex[index];\n\n const childInitialValues = readInitialValuesRecursive(childQItem, childQRItemOrItems ?? null);\n\n if (childInitialValues) {\n initialValues.push(...childInitialValues);\n }\n }\n }\n\n // Create new qrItem for items with initial values\n let qrItem = createNewQuestionnaireResponseItem(qItem, getInitialValueAnswers(qItem));\n\n if (initialValues.length > 0) {\n if (!qrItem) {\n qrItem = {\n linkId: qItem.linkId,\n text: qItem.text\n };\n }\n qrItem.item = initialValues;\n }\n\n return qrItem ? [qrItem] : null;\n}\n\nfunction getInitialValueAnswersFromRepeatGroup(\n qItem: QuestionnaireItem,\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null\n) {\n if (!qItem.item) {\n return [];\n }\n\n return qItem.item\n .flatMap((childQItem) => readInitialValuesRecursive(childQItem, qrItemOrItems))\n .filter((childQRItem): childQRItem is QuestionnaireResponseItem => !!childQRItem);\n}\n\nfunction getInitialValueAnswers(qItem: QuestionnaireItem): QuestionnaireResponseItemAnswer[] {\n // For answerOption.initialSelected\n if (qItem.type === 'choice' && qItem.answerOption) {\n return qItem.answerOption\n .filter((option) => option.initialSelected)\n .map((option): QuestionnaireResponseItemAnswer | null => {\n if (option.valueCoding) {\n return {\n valueCoding: getRelevantCodingProperties(option.valueCoding)\n };\n }\n\n if (option.valueString) {\n return {\n valueString: option.valueString\n };\n }\n\n if (option.valueInteger) {\n return {\n valueInteger: option.valueInteger\n };\n }\n\n return null;\n })\n .filter((item): item is QuestionnaireResponseItemAnswer => !!item);\n }\n\n // For item.initial\n const initialValues = qItem.initial;\n if (!initialValues) {\n return [];\n }\n\n return initialValues\n .map((initialValue) => parseItemInitialToAnswer(initialValue))\n .filter((item): item is QuestionnaireResponseItemAnswer => item !== null);\n}\n\nexport function parseItemInitialToAnswer(\n initial: QuestionnaireItemInitial\n): QuestionnaireResponseItemAnswer | null {\n if (typeof initial.valueBoolean === 'boolean') {\n return { valueBoolean: initial.valueBoolean };\n }\n\n if (typeof initial.valueDecimal === 'number') {\n return { valueDecimal: initial.valueDecimal };\n }\n\n if (typeof initial.valueInteger === 'number') {\n return { valueInteger: initial.valueInteger };\n }\n\n if (typeof initial.valueDate === 'string') {\n return { valueDate: initial.valueDate };\n }\n\n if (typeof initial.valueDateTime === 'string') {\n return { valueDateTime: initial.valueDateTime };\n }\n\n if (typeof initial.valueTime === 'string') {\n return { valueTime: initial.valueTime };\n }\n\n if (typeof initial.valueString === 'string') {\n return { valueString: initial.valueString };\n }\n\n if (typeof initial.valueUri === 'string') {\n return { valueUri: initial.valueUri };\n }\n\n if (initial.valueAttachment) {\n return { valueAttachment: initial.valueAttachment };\n }\n\n if (initial.valueCoding) {\n return { valueCoding: getRelevantCodingProperties(initial.valueCoding) };\n }\n\n if (initial.valueQuantity) {\n return { valueQuantity: initial.valueQuantity };\n }\n\n if (initial.valueReference) {\n return { valueReference: initial.valueReference };\n }\n\n return null;\n}\n\nfunction createNewQuestionnaireResponseItem(\n qItem: QuestionnaireItem,\n initialValueAnswers: QuestionnaireResponseItemAnswer[]\n): QuestionnaireResponseItem | null {\n if (initialValueAnswers.length === 0) {\n return null;\n }\n\n // If item is non-repeating, only take the first initial value\n if (!qItem.repeats) {\n initialValueAnswers = [initialValueAnswers[0]];\n }\n\n return {\n linkId: qItem.linkId,\n text: qItem.text,\n answer: initialValueAnswers\n };\n}\n\nfunction createNewRepeatGroupQuestionnaireResponseItem(\n qItem: QuestionnaireItem,\n initialValueItems: QuestionnaireResponseItem[]\n): QuestionnaireResponseItem | null {\n if (initialValueItems.length === 0) {\n return null;\n }\n\n return {\n linkId: qItem.linkId,\n text: qItem.text,\n item: initialValueItems\n };\n}\n\nexport interface initialFormFromResponseParams {\n sourceQuestionnaire: Questionnaire;\n questionnaireResponse: QuestionnaireResponse;\n targetConstraints: Record<string, TargetConstraint>;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n calculatedExpressions: Record<string, CalculatedExpression[]>;\n variables: Variables;\n processedValueSets: Record<string, ProcessedValueSet>;\n tabs: Tabs;\n pages: Pages;\n fhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n terminologyServerUrl: string;\n}\n\nexport async function initialiseFormFromResponse(params: initialFormFromResponseParams): Promise<{\n initialTargetConstraints: Record<string, TargetConstraint>;\n initialEnableWhenItems: EnableWhenItems;\n initialEnableWhenLinkedQuestions: Record<string, string[]>;\n initialEnableWhenExpressions: EnableWhenExpressions;\n initialCalculatedExpressions: Record<string, CalculatedExpression[]>;\n initialProcessedValueSets: Record<string, ProcessedValueSet>;\n firstVisibleTab: number;\n firstVisiblePage: number;\n updatedFhirPathContext: Record<string, any>;\n fhirPathTerminologyCache: Record<string, any>;\n}> {\n const {\n sourceQuestionnaire,\n questionnaireResponse,\n targetConstraints,\n enableWhenItems,\n enableWhenExpressions,\n calculatedExpressions,\n variables,\n processedValueSets,\n tabs,\n pages,\n fhirPathContext,\n terminologyServerUrl\n } = params;\n let { fhirPathTerminologyCache } = params;\n\n const initialResponseItemMap = createQuestionnaireResponseItemMap(\n sourceQuestionnaire,\n questionnaireResponse\n );\n let updatedFhirPathContext = {};\n\n const { initialisedItems, linkedQuestions } = assignPopulatedAnswersToEnableWhen(\n enableWhenItems,\n questionnaireResponse\n );\n\n const evaluateInitialTargetConstraintsResult = await evaluateInitialTargetConstraints({\n initialResponse: questionnaireResponse,\n initialResponseItemMap: initialResponseItemMap,\n targetConstraints: targetConstraints,\n variables: variables,\n existingFhirPathContext: fhirPathContext,\n fhirPathTerminologyCache: fhirPathTerminologyCache,\n terminologyServerUrl\n });\n const { initialTargetConstraints } = evaluateInitialTargetConstraintsResult;\n fhirPathTerminologyCache = evaluateInitialTargetConstraintsResult.fhirPathTerminologyCache;\n\n const evaluateInitialDynamicValueSetsResult = await evaluateInitialDynamicValueSets({\n initialResponse: questionnaireResponse,\n initialResponseItemMap: initialResponseItemMap,\n processedValueSets: processedValueSets,\n variables: variables,\n existingFhirPathContext: fhirPathContext,\n fhirPathTerminologyCache: fhirPathTerminologyCache,\n terminologyServerUrl\n });\n const { initialProcessedValueSets } = evaluateInitialDynamicValueSetsResult;\n fhirPathTerminologyCache = evaluateInitialDynamicValueSetsResult.fhirPathTerminologyCache;\n\n const evaluateInitialEnableWhenExpressionsResult = await evaluateInitialEnableWhenExpressions({\n initialResponse: questionnaireResponse,\n initialResponseItemMap: initialResponseItemMap,\n enableWhenExpressions: enableWhenExpressions,\n variables: variables,\n existingFhirPathContext: fhirPathContext,\n fhirPathTerminologyCache: fhirPathTerminologyCache,\n terminologyServerUrl: terminologyServerUrl\n });\n const { initialEnableWhenExpressions } = evaluateInitialEnableWhenExpressionsResult;\n fhirPathTerminologyCache = evaluateInitialEnableWhenExpressionsResult.fhirPathTerminologyCache;\n\n const evaluateInitialCalculatedExpressionsResult = await evaluateInitialCalculatedExpressions({\n initialResponse: questionnaireResponse,\n initialResponseItemMap: initialResponseItemMap,\n calculatedExpressions: calculatedExpressions,\n variables: variables,\n existingFhirPathContext: fhirPathContext,\n fhirPathTerminologyCache: fhirPathTerminologyCache,\n terminologyServerUrl\n });\n const { initialCalculatedExpressions } = evaluateInitialCalculatedExpressionsResult;\n updatedFhirPathContext = evaluateInitialEnableWhenExpressionsResult.updatedFhirPathContext;\n\n const firstVisibleTab =\n Object.keys(tabs).length > 0\n ? getFirstVisibleTab(tabs, initialisedItems, initialEnableWhenExpressions)\n : 0;\n\n const firstVisiblePage =\n Object.keys(pages).length > 0\n ? getFirstVisiblePage(pages, initialisedItems, initialEnableWhenExpressions)\n : 0;\n\n return {\n initialTargetConstraints,\n initialEnableWhenItems: initialisedItems,\n initialEnableWhenLinkedQuestions: linkedQuestions,\n initialEnableWhenExpressions,\n initialCalculatedExpressions,\n initialProcessedValueSets,\n firstVisibleTab,\n firstVisiblePage,\n updatedFhirPathContext,\n fhirPathTerminologyCache\n };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createStore } from 'zustand/vanilla';\nimport { createSelectors } from './selector';\nimport { TERMINOLOGY_SERVER_URL } from '../globals';\n\n/**\n * TerminologyServerStore properties and methods\n * Properties can be accessed for fine-grain details.\n * Methods are usually used internally, using them from an external source is not recommended.\n *\n * @property url - The current terminology server URL\n * @property setUrl - Set the terminology server URL\n * @property resetUrl - Reset the terminology server URL to the default\n *\n * @author Sean Fong\n */\nexport interface TerminologyServerStoreType {\n url: string;\n setUrl: (newUrl: string) => void;\n resetUrl: () => void;\n}\n\n/**\n * Terminology server state management store. This is used for resolving valueSets externally.\n * Defaults to use https://tx.ontoserver.csiro.au/fhir.\n * This is the vanilla version of the store which can be used in non-React environments.\n * @see TerminologyServerStoreType for available properties and methods.\n *\n * @author Sean Fong\n */\nexport const terminologyServerStore = createStore<TerminologyServerStoreType>()((set) => ({\n url: TERMINOLOGY_SERVER_URL,\n setUrl: (newUrl: string) => set(() => ({ url: newUrl })),\n resetUrl: () => set(() => ({ url: TERMINOLOGY_SERVER_URL }))\n}));\n\n/**\n * Terminology server state management store. This is used for resolving valueSets externally.\n * Defaults to use https://tx.ontoserver.csiro.au/fhir.\n * This is the React version of the store which can be used as React hooks in React functional components.\n * @see TerminologyServerStoreType for available properties and methods.\n *\n * @author Sean Fong\n */\nexport const useTerminologyServerStore = createSelectors(terminologyServerStore);\n","import type { StoreApi } from 'zustand';\nimport { useStore } from 'zustand';\n\ntype WithSelectors<S> = S extends { getState: () => infer T }\n ? S & { use: { [K in keyof T]: () => T[K] } }\n : never;\n\nexport const createSelectors = <S extends StoreApi<object>>(_store: S) => {\n const store = _store as WithSelectors<typeof _store>;\n store.use = {};\n for (const k of Object.keys(store.getState())) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n (store.use as any)[k] = () => useStore(_store, (s) => s[k as keyof typeof s]);\n }\n\n return store;\n};\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const TERMINOLOGY_SERVER_URL = 'https://tx.ontoserver.csiro.au/fhir';\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createStore } from 'zustand/vanilla';\nimport type {\n OperationOutcome,\n Questionnaire,\n QuestionnaireResponse,\n QuestionnaireResponseItem\n} from 'fhir/r4';\nimport { emptyResponse } from '../utils/emptyResource';\nimport type { Diff } from 'deep-diff';\nimport { diff } from 'deep-diff';\nimport { createSelectors } from './selector';\nimport { validateForm } from '../utils/validate';\nimport { questionnaireStore } from './questionnaireStore';\nimport { createQuestionnaireResponseItemMap } from '../utils/questionnaireResponseStoreUtils/updatableResponseItems';\nimport { generateUniqueId } from '../utils/extractObservation';\n\n/**\n * QuestionnaireResponseStore properties and methods\n * Properties can be accessed for fine-grain details.\n * Methods are usually used internally, but it is possible to use them externally to hook into the renderer for more fine-grain control.\n *\n * @property key - The React key of the questionnaireResponse, used internally for refreshing the BaseRenderer\n * @property sourceResponse - The original response created when the form is first initialised i.e. empty, pre-populated, opened saved draft\n * @property updatableResponse - The current state of the response that is being updated via form fields\n * @property updatableResponseItems - Key-value pair of updatableResponse items `Record<linkId, QR.item(s)>`\n * @property formChangesHistory - Array of form changes history in the form of deep-diff objects\n * @property invalidItems - Key-value pair of invalid items based on defined value constraints in the questionnaire `Record<linkId, OperationOutcome>`\n * @property requiredItemsIsHighlighted - Required items are not highlighted by default (to provide a less-jarring UX), but can be manually toggled to be highlighted\n * @property responseIsValid - Whether there are any invalid items in the response\n * @property validateQuestionnaireResponse - Used to validate the questionnaire response based on the questionnaire\n * @property buildSourceResponse - Used to build the source response when the form is first initialised\n * @property setUpdatableResponseAsPopulated - Used to set a pre-populated response as the current response\n * @property updateResponse - Used to update the current response\n * @property setUpdatableResponseAsSaved - Used to set a saved response as the current response\n * @property setUpdatableResponseAsEmpty - Used to set an empty response as the current response\n * @property destroySourceResponse - Used to destroy the source response and reset all properties\n * @property highlightRequiredItems - Used to highlight invalid items and show error feedback in the UI\n *\n * @author Sean Fong\n */\nexport interface QuestionnaireResponseStoreType {\n key: string;\n sourceResponse: QuestionnaireResponse;\n updatableResponse: QuestionnaireResponse;\n updatableResponseItems: Record<string, QuestionnaireResponseItem[]>;\n formChangesHistory: (Diff<QuestionnaireResponse, QuestionnaireResponse>[] | null)[];\n invalidItems: Record<string, OperationOutcome>;\n requiredItemsIsHighlighted: boolean;\n responseIsValid: boolean;\n validateQuestionnaire: (\n questionnaire: Questionnaire,\n updatedResponse: QuestionnaireResponse\n ) => void;\n buildSourceResponse: (response: QuestionnaireResponse) => void;\n setUpdatableResponseAsPopulated: (populatedResponse: QuestionnaireResponse) => void;\n updateResponse: (updatedResponse: QuestionnaireResponse) => void;\n setUpdatableResponseAsSaved: (savedResponse: QuestionnaireResponse) => void;\n setUpdatableResponseAsEmpty: (clearedResponse: QuestionnaireResponse) => void;\n destroySourceResponse: () => void;\n highlightRequiredItems: () => void;\n}\n\n/**\n * QuestionnaireResponse state management store which contains all properties and methods to manage the state of the questionnaireResponse.\n * This is the vanilla version of the store which can be used in non-React environments.\n * @see QuestionnaireResponseStoreType for available properties and methods.\n *\n * @author Sean Fong\n */\nexport const questionnaireResponseStore = createStore<QuestionnaireResponseStoreType>()(\n (set, get) => ({\n key: 'QR-initial-key',\n sourceResponse: structuredClone(emptyResponse),\n updatableResponse: structuredClone(emptyResponse),\n updatableResponseItems: {},\n formChangesHistory: [],\n invalidItems: {},\n requiredItemsIsHighlighted: false,\n responseIsValid: true,\n validateQuestionnaire: (\n questionnaire: Questionnaire,\n updatedResponse: QuestionnaireResponse\n ) => {\n const updatedInvalidItems = validateForm(questionnaire, updatedResponse);\n\n set(() => ({\n invalidItems: updatedInvalidItems,\n responseIsValid: Object.keys(updatedInvalidItems).length === 0\n }));\n },\n buildSourceResponse: (questionnaireResponse: QuestionnaireResponse) => {\n const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;\n const initialInvalidItems = validateForm(sourceQuestionnaire, questionnaireResponse);\n\n set(() => ({\n key: generateUniqueId('QR'),\n sourceResponse: questionnaireResponse,\n updatableResponse: questionnaireResponse,\n updatableResponseItems: createQuestionnaireResponseItemMap(\n sourceQuestionnaire,\n questionnaireResponse\n ),\n invalidItems: initialInvalidItems,\n requiredItemsIsHighlighted: false,\n responseIsValid: Object.keys(initialInvalidItems).length === 0\n }));\n },\n setUpdatableResponseAsPopulated: (populatedResponse: QuestionnaireResponse) => {\n const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;\n const formChanges = diff(get().updatableResponse, populatedResponse) ?? null;\n\n const updatedInvalidItems = validateForm(sourceQuestionnaire, populatedResponse);\n\n set(() => ({\n sourceResponse: populatedResponse,\n updatableResponse: populatedResponse,\n updatableResponseItems: createQuestionnaireResponseItemMap(\n sourceQuestionnaire,\n populatedResponse\n ),\n formChangesHistory: [...get().formChangesHistory, formChanges],\n invalidItems: updatedInvalidItems,\n requiredItemsIsHighlighted: false,\n responseIsValid: Object.keys(updatedInvalidItems).length === 0\n }));\n },\n updateResponse: (updatedResponse: QuestionnaireResponse) => {\n const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;\n const formChanges = diff(get().updatableResponse, updatedResponse) ?? null;\n const updatedInvalidItems = validateForm(sourceQuestionnaire, updatedResponse);\n\n set(() => ({\n updatableResponse: updatedResponse,\n updatableResponseItems: createQuestionnaireResponseItemMap(\n sourceQuestionnaire,\n updatedResponse\n ),\n formChangesHistory: [...get().formChangesHistory, formChanges],\n invalidItems: updatedInvalidItems,\n responseIsValid: Object.keys(updatedInvalidItems).length === 0\n }));\n },\n setUpdatableResponseAsSaved: (savedResponse: QuestionnaireResponse) => {\n const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;\n const updatedInvalidItems = validateForm(sourceQuestionnaire, savedResponse);\n\n set(() => ({\n key: generateUniqueId('QR'),\n sourceResponse: savedResponse,\n updatableResponse: savedResponse,\n updatableResponseItems: createQuestionnaireResponseItemMap(\n sourceQuestionnaire,\n savedResponse\n ),\n formChangesHistory: [],\n invalidItems: updatedInvalidItems,\n responseIsValid: Object.keys(updatedInvalidItems).length === 0\n }));\n },\n setUpdatableResponseAsEmpty: (clearedResponse: QuestionnaireResponse) => {\n const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;\n const updatedInvalidItems = validateForm(sourceQuestionnaire, clearedResponse);\n\n set(() => ({\n updatableResponse: clearedResponse,\n updatableResponseItems: createQuestionnaireResponseItemMap(\n sourceQuestionnaire,\n clearedResponse\n ),\n formChangesHistory: [],\n invalidItems: updatedInvalidItems,\n requiredItemsIsHighlighted: false,\n responseIsValid: Object.keys(updatedInvalidItems).length === 0\n }));\n },\n destroySourceResponse: () => {\n const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;\n set(() => ({\n key: generateUniqueId('QR'),\n sourceResponse: structuredClone(emptyResponse),\n updatableResponse: structuredClone(emptyResponse),\n updatableResponseItems: createQuestionnaireResponseItemMap(\n sourceQuestionnaire,\n structuredClone(emptyResponse)\n ),\n formChangesHistory: [],\n invalidItems: {},\n requiredItemsIsHighlighted: false,\n responseIsValid: true\n }));\n },\n highlightRequiredItems: () =>\n set(() => ({\n requiredItemsIsHighlighted: true\n }))\n })\n);\n\n/**\n * QuestionnaireResponse state management store which contains all properties and methods to manage the state of the questionnaire.\n * This is the React version of the store which can be used as React hooks in React functional components.\n * @see QuestionnaireResponseStoreType for available properties and methods.\n * @see questionnaireResponseStore for the vanilla store.\n *\n * @author Sean Fong\n */\nexport const useQuestionnaireResponseStore = createSelectors(questionnaireResponseStore);\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n OperationOutcome,\n OperationOutcomeIssue,\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireResponse,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport { getQrItemsIndex, mapQItemsIndex } from './mapItem';\nimport type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';\nimport { isHiddenByEnableWhen } from './qItem';\nimport {\n getDecimalPrecision,\n getMaxQuantityValue,\n getMaxValue,\n getMinQuantityValue,\n getMinValue,\n getRegexString,\n getRegexValidation,\n getShortText\n} from './itemControl';\nimport { structuredDataCapture } from 'fhir-sdc-helpers';\nimport type { RegexValidation } from '../interfaces/regex.interface';\nimport { parseDecimalStringToFloat } from './parseInputs';\nimport dayjs from 'dayjs';\nimport { questionnaireStore } from '../stores';\n\nexport enum ValidationResult {\n unknown = 'unknown', // Unknown validation result\n questionnaireNotFound = 'questionnaireNotFound', // The Questionnaire referenced by the QR was not found\n questionnaireInactive = 'questionnaireInactive', // The QuestionnaireResponse.authored is outside the defined Questionnaire.effectivePeriod\n questionnaireDraft = 'questionnaireDraft', // The Questionnaire.status was not active (draft)\n questionnaireRetired = 'questionnaireRetired', // The Questionnaire.status was not active (retired)\n invalidLinkId = 'invalidLinkId', // LinkId was not found in the questionnaire\n invalidType = 'invalidType', // The Question Type should not be included in Response (or Definition) data\n invalidAnswerType = 'invalidAnswerType', // The Answer does not conform to the Item.Type value required (also taking into consideration the fhir-type extension)\n invalidAnswerOption = 'invalidAnswerOption', // A set of valid AnswerOptions were provided in the definition, but the value entered was not in the set\n exclusiveAnswerOption = 'exclusiveAnswerOption', // The selected answer cannot be used in conjunction with other answers in this multi-select choice option\n invalidUrlValue = 'invalidUrlValue', // URL value not formatted correctly as a UUID, or relative/absolute URL\n groupShouldNotHaveAnswers = 'groupShouldNotHaveAnswers', // A Group Item should not use the `answer` child, it should use the `item` child\n required = 'required', // There was no answer provided for a mandatory field\n invariant = 'invariant', // A FHIRPATH validation expression did not pass\n invariantExecution = 'invariantExecution', // A FHIRPATH validation expression failed to execute\n repeats = 'repeats', // There was more than one answer provided for an item with repeats = false (which is the default)\n minCount = 'minCount', // Minimum number of answers required for the item was not provided\n maxCount = 'maxCount', // Number of answers provided exceeded the maximum permitted\n minValue = 'minValue', // Minimum value constraint violated\n maxValue = 'maxValue', // Maximum value constraint violated\n maxDecimalPlaces = 'maxDecimalPlaces', // Maximum decimal places constraint violated\n minLength = 'minLength', // Minimum length constraint violated\n maxLength = 'maxLength', // Maximum length constraint violated\n invalidNewLine = 'invalidNewLine', // 'string' type items cannot include newline characters, use a 'text' type for these\n invalidCoding = 'invalidCoding', // Coding value not valid in the ValueSet\n tsError = 'tsError', // Error accessing the Terminology Server\n maxAttachmentSize = 'maxAttachmentSize', // Maximum attachment size constraint violated\n attachmentSizeInconsistent = 'attachmentSizeInconsistent', // The Size of the attachment data and the reported size are different\n invalidAttachmentType = 'invalidAttachmentType', // Attachment type constraint violated\n displayAnswer = 'displayAnswer', // Display Items should not have an answer provided\n regex = 'regex', // The answer does not match the provided regex expression\n regexTimeout = 'regexTimeout', // Evaluating the regex expression timed out\n invalidRefValue = 'invalidRefValue', // The Reference value was not a valid URL value (relative or absolute)\n invalidRefResourceType = 'invalidRefResourceType', // The Reference value did not refer to a valid FHIR resource type\n invalidRefResourceTypeRestriction = 'invalidRefResourceTypeRestriction', // The Reference value was not\n minValueIncompatUnits = 'minValueIncompatUnits', // The units provided in the Quantity cannot be converted to the min Quantity units\n maxValueIncompatUnits = 'maxValueIncompatUnits', // The units provided in the Quantity cannot be converted to the max Quantity units\n invalidUnit = 'invalidUnit', // The unit provided was not among the list selected (or did not have all the properties defined in the unit coding)\n invalidUnitValueSet = 'invalidUnitValueSet', // The unit provided was not in the provided valueset\n minQuantityValue = 'minQuantityValue', // Minimum Quantity value constraint violated\n maxQuantityValue = 'maxQuantityValue' // Maximum Quantity value constraint violated\n}\n\nexport function validateForm(\n questionnaire: Questionnaire,\n questionnaireResponse: QuestionnaireResponse\n): Record<string, OperationOutcome> {\n const invalidItemsFromQRValidation = validateQuestionnaireResponse({\n questionnaire,\n questionnaireResponse\n });\n\n const invalidItemsFromTCValidation = validateTargetConstraint();\n\n return {\n ...invalidItemsFromQRValidation,\n ...invalidItemsFromTCValidation\n };\n}\n\nexport function validateTargetConstraint(): Record<string, OperationOutcome> {\n const targetConstraints = questionnaireStore.getState().targetConstraints;\n const invalidItems: Record<string, OperationOutcome> = {};\n for (const [, targetConstraint] of Object.entries(targetConstraints)) {\n if (targetConstraint.isEnabled) {\n const locationExpression = targetConstraint.location\n ? `${targetConstraint.valueExpression.expression ?? 'unknown FHIRPath expression'} at ${\n targetConstraint.location\n }`\n : `${targetConstraint.valueExpression.expression ?? 'unknown FHIRPath expression'}`;\n\n const validationOutcome = createValidationOperationOutcome(\n ValidationResult.invariant,\n null as unknown as QuestionnaireItem, // We don't need a QuestionnaireItem here\n null as unknown as QuestionnaireResponseItem, // We don't need a QuestionnaireResponseItem here\n null,\n locationExpression,\n []\n );\n\n const invalidItemKey = targetConstraint.linkId ?? `target-constraint-${targetConstraint.key}`;\n invalidItems[invalidItemKey] = validationOutcome;\n }\n }\n\n return invalidItems;\n}\n\ninterface ValidateQuestionnaireResponseParams {\n questionnaire: Questionnaire;\n questionnaireResponse: QuestionnaireResponse;\n}\n\n/**\n * Recursively go through the questionnaireResponse and check for un-filled required qItems\n * At the moment item.required for group items are not checked\n *\n * @author Sean Fong\n */\nexport function validateQuestionnaireResponse(\n params: ValidateQuestionnaireResponseParams\n): Record<string, OperationOutcome> {\n const { questionnaire, questionnaireResponse } = params;\n\n const enableWhenIsActivated = questionnaireStore.getState().enableWhenIsActivated;\n const enableWhenItems = questionnaireStore.getState().enableWhenItems;\n const enableWhenExpressions = questionnaireStore.getState().enableWhenExpressions;\n\n if (!questionnaire.item || questionnaire.item.length === 0) {\n return {};\n }\n\n if (!questionnaireResponse.item || questionnaireResponse.item.length === 0) {\n questionnaireResponse.item = [];\n }\n\n const qItemsIndexMap = mapQItemsIndex(questionnaire);\n const topLevelQRItemsByIndex = getQrItemsIndex(\n questionnaire.item,\n questionnaireResponse.item,\n qItemsIndexMap\n );\n\n const invalidItems: Record<string, OperationOutcome> = {};\n let qrItemIndex = 0;\n for (const [index, topLevelQItem] of questionnaire.item.entries()) {\n let repeatGroupInstances: number | null = null;\n let topLevelQRItem = topLevelQRItemsByIndex[index] ?? {\n linkId: topLevelQItem.linkId,\n text: topLevelQItem.text\n };\n\n // topLevelQRItem being an array means this item is a repeat group\n const isRepeatGroup = Array.isArray(topLevelQRItem);\n if (Array.isArray(topLevelQRItem)) {\n repeatGroupInstances = topLevelQRItem.length;\n topLevelQRItem = {\n linkId: topLevelQItem.linkId,\n text: topLevelQItem.text,\n item: topLevelQRItem\n };\n }\n\n const locationExpression = `QuestionnaireResponse.item`;\n validateItemRecursive({\n qItem: topLevelQItem,\n qrItem: topLevelQRItem,\n qrItemIndex,\n locationExpression,\n invalidItems,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions,\n isRepeatGroupInstance: false\n });\n\n // Increment qrItemIndex\n // If it's a repeat group, increment by the number of instances so qrItemIndex is correct once we reach the next item\n if (isRepeatGroup && typeof repeatGroupInstances === 'number') {\n qrItemIndex += repeatGroupInstances;\n } else {\n qrItemIndex++;\n }\n }\n\n return invalidItems;\n}\n\ninterface ValidateItemRecursiveParams {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem;\n qrItemIndex: number;\n locationExpression: string;\n invalidItems: Record<string, OperationOutcome>;\n enableWhenIsActivated: boolean;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n isRepeatGroupInstance: boolean;\n}\n\nfunction validateItemRecursive(params: ValidateItemRecursiveParams) {\n const {\n qItem,\n qrItem,\n qrItemIndex,\n invalidItems,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions,\n isRepeatGroupInstance\n } = params;\n let { locationExpression } = params;\n\n // Skip display items\n if (qItem.type === 'display') {\n return;\n }\n\n // If item is hidden by enableWhen, skip validation\n if (\n isHiddenByEnableWhen({\n linkId: qItem.linkId,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n })\n ) {\n return;\n }\n\n // Validate repeat groups\n if (qItem.type === 'group' && qItem.repeats) {\n if (!isRepeatGroupInstance) {\n validateRepeatGroupRecursive({\n qItem,\n qrItem,\n qrItemIndex,\n locationExpression,\n invalidItems,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions,\n isRepeatGroupInstance: false\n });\n return;\n }\n }\n\n locationExpression = `${locationExpression}[${qrItemIndex}]`;\n\n // Recursively validate groups with child items\n const childQItems = qItem.item;\n if (childQItems && childQItems.length > 0) {\n const childQrItems = qrItem?.item ?? [];\n\n const indexMap = mapQItemsIndex(qItem);\n const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap);\n\n // Check if group is required and has no answers\n if (qItem.type === 'group' && qItem.required) {\n if (!qrItem.item || qrItem.item?.length === 0) {\n invalidItems[qItem.linkId] = createValidationOperationOutcome(\n ValidationResult.required,\n qItem,\n qrItem,\n null,\n locationExpression,\n invalidItems[qItem.linkId]?.issue\n );\n }\n }\n\n // Loop through child items\n for (const [index, childQItem] of childQItems.entries()) {\n const childLocationExpression = `${locationExpression}.item`;\n let childQRItem = qrItemsByIndex[index] ?? {\n linkId: childQItem.linkId,\n text: childQItem.text\n };\n\n if (Array.isArray(childQRItem)) {\n childQRItem = {\n linkId: childQItem.linkId,\n text: childQItem.text,\n item: childQRItem\n };\n }\n\n validateItemRecursive({\n qItem: childQItem,\n qrItem: childQRItem,\n qrItemIndex: index,\n locationExpression: childLocationExpression,\n invalidItems: invalidItems,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions,\n isRepeatGroupInstance: false\n });\n }\n }\n\n // Stop checking if the item is a group, we have checked previously\n if (qItem.type === 'group') {\n return;\n }\n\n // Validate the item, note that this can be either a group or a non-group\n validateSingleItem(qItem, qrItem, invalidItems, locationExpression);\n}\n\nfunction validateRepeatGroupRecursive(params: ValidateItemRecursiveParams) {\n const {\n qItem,\n qrItem,\n qrItemIndex,\n locationExpression,\n invalidItems,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n } = params;\n\n if (!qItem.item || qItem.item.length === 0 || !qrItem.item || qrItem.item.length === 0) {\n return;\n }\n\n // Get repeat group answers\n const repeatGroupAnswers = qrItem.item ?? [];\n for (const [index, repeatGroupAnswer] of repeatGroupAnswers.entries()) {\n // Because the item is a repeat group and might have multiple answer instances, we need to increment the qItemIndex by the instanceIndex\n const updatedQrItemIndex = qrItemIndex + index;\n\n validateItemRecursive({\n qItem: qItem,\n qrItem: repeatGroupAnswer,\n qrItemIndex: updatedQrItemIndex,\n locationExpression: locationExpression,\n invalidItems: invalidItems,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions,\n isRepeatGroupInstance: true\n });\n }\n}\n\nfunction validateSingleItem(\n qItem: QuestionnaireItem,\n qrItem: QuestionnaireResponseItem,\n invalidItems: Record<string, OperationOutcome>,\n locationExpression: string\n) {\n // Skip display items\n if (qItem.type === 'display') {\n return invalidItems;\n }\n\n // Validate item.required first before every other validation check\n if (qItem.required && !qrItem.answer) {\n invalidItems[qItem.linkId] = createValidationOperationOutcome(\n ValidationResult.required,\n qItem,\n qrItem,\n null,\n locationExpression,\n invalidItems[qItem.linkId]?.issue\n );\n\n return invalidItems;\n }\n\n // Validate regex, maxLength and minLength, maxQuantity and minQuantity\n if (qrItem.answer) {\n for (const [i, answer] of qrItem.answer.entries()) {\n // Your code here, you can use 'index' and 'answer' as needed\n if (\n answer.valueString ||\n answer.valueInteger ||\n answer.valueDecimal ||\n answer.valueUri ||\n answer.valueQuantity\n ) {\n const invalidInputType = getInputInvalidType({\n qItem,\n input: getInputInString(answer),\n regexValidation: getRegexValidation(qItem),\n minLength: structuredDataCapture.getMinLength(qItem),\n maxLength: qItem.maxLength,\n maxDecimalPlaces: structuredDataCapture.getMaxDecimalPlaces(qItem),\n minValue: getMinValue(qItem),\n maxValue: getMaxValue(qItem),\n minQuantityValue: getMinQuantityValue(qItem),\n maxQuantityValue: getMaxQuantityValue(qItem)\n });\n\n if (invalidInputType) {\n invalidItems[qItem.linkId] = createValidationOperationOutcome(\n invalidInputType,\n qItem,\n qrItem,\n i,\n locationExpression,\n invalidItems[qItem.linkId]?.issue\n );\n } // if not invalid input types found\n else {\n //do nothing\n }\n }\n }\n }\n\n return invalidItems;\n}\n\nfunction getInputInString(answer?: QuestionnaireResponseItemAnswer) {\n if (!answer) {\n return '';\n }\n\n if (answer.valueString) {\n return answer.valueString;\n } else if (answer.valueInteger) {\n return answer.valueInteger.toString();\n } else if (answer.valueDecimal) {\n return answer.valueDecimal.toString();\n } else if (answer.valueUri) {\n return answer.valueUri;\n } else if (answer.valueQuantity && answer.valueQuantity.value) {\n // return the valueQuantity as string\n return answer.valueQuantity.value.toString();\n }\n\n return '';\n}\n\ninterface GetInputInvalidTypeParams {\n qItem: QuestionnaireItem;\n input: string;\n regexValidation?: RegexValidation;\n minLength?: number;\n maxLength?: number;\n maxDecimalPlaces?: number;\n minValue?: string | number;\n maxValue?: string | number;\n minQuantityValue?: number;\n maxQuantityValue?: number;\n}\n\nexport function getInputInvalidType(\n getInputInvalidTypeParams: GetInputInvalidTypeParams\n): ValidationResult | null {\n const {\n qItem,\n input,\n regexValidation,\n minLength,\n maxLength,\n maxDecimalPlaces,\n minValue,\n maxValue,\n minQuantityValue,\n maxQuantityValue\n } = getInputInvalidTypeParams;\n\n if (input) {\n if (regexValidation && !regexValidation.expression.test(input)) {\n return ValidationResult.regex;\n }\n\n if (minLength !== undefined && input.length < minLength) {\n return ValidationResult.minLength;\n }\n\n if (maxLength !== undefined && input.length > maxLength) {\n return ValidationResult.maxLength;\n }\n\n if (maxDecimalPlaces !== undefined) {\n const decimalPlaces = input.split('.')[1]?.length ?? 0;\n if (decimalPlaces > maxDecimalPlaces) {\n return ValidationResult.maxDecimalPlaces;\n }\n }\n\n if (minValue !== undefined) {\n const minValueError = checkMinValue(qItem, input, minValue);\n if (minValueError !== null) {\n return ValidationResult.minValue;\n }\n }\n\n if (maxValue !== undefined) {\n const maxValueError = checkMaxValue(qItem, input, maxValue);\n if (maxValueError !== null) {\n return ValidationResult.maxValue;\n }\n }\n\n // if minQuantityValue exists then check the value and validate\n if (minQuantityValue !== undefined) {\n const minQuantityValueError = checkMinQuantityValue(qItem, input, minQuantityValue);\n if (minQuantityValueError !== null) {\n return ValidationResult.minQuantityValue;\n } else {\n // No error, do nothing\n }\n }\n // if maxQuantityValue exists then check the value and validate\n if (maxQuantityValue !== undefined) {\n const maxQuantityValueError = checkMaxQuantityValue(qItem, input, maxQuantityValue);\n if (maxQuantityValueError !== null) {\n return ValidationResult.maxQuantityValue;\n } else {\n // No error, do nothing\n }\n }\n }\n\n return null;\n}\n\nfunction checkMinValue(\n qItem: QuestionnaireItem,\n input: string,\n minValue: string | number\n): ValidationResult.minValue | null {\n switch (qItem.type) {\n case 'integer':\n if (typeof minValue === 'number') {\n if (parseInt(input) < minValue) {\n return ValidationResult.minValue;\n }\n }\n break;\n case 'decimal': {\n const precision = getDecimalPrecision(qItem);\n const decimalValue = precision\n ? parseDecimalStringToFloat(input, precision)\n : parseFloat(input);\n\n if (typeof minValue === 'number') {\n if (decimalValue < minValue) {\n return ValidationResult.minValue;\n }\n }\n break;\n }\n case 'date':\n if (typeof minValue === 'string') {\n if (new Date(input) < new Date(minValue)) {\n return ValidationResult.minValue;\n }\n }\n break;\n case 'dateTime':\n if (typeof minValue === 'string') {\n if (dayjs(input).isBefore(dayjs(minValue))) {\n return ValidationResult.minValue;\n }\n }\n break;\n default:\n return null;\n }\n\n return null;\n}\n\nfunction checkMaxValue(\n qItem: QuestionnaireItem,\n input: string,\n maxValue: string | number\n): ValidationResult.maxValue | null {\n switch (qItem.type) {\n case 'integer':\n if (typeof maxValue === 'number') {\n if (parseInt(input) > maxValue) {\n return ValidationResult.maxValue;\n }\n }\n break;\n case 'decimal': {\n const precision = getDecimalPrecision(qItem);\n const decimalValue = precision\n ? parseDecimalStringToFloat(input, precision)\n : parseFloat(input);\n\n if (typeof maxValue === 'number') {\n if (decimalValue > maxValue) {\n return ValidationResult.maxValue;\n }\n }\n break;\n }\n case 'date':\n if (typeof maxValue === 'string') {\n if (new Date(input) > new Date(maxValue)) {\n return ValidationResult.maxValue;\n }\n }\n break;\n case 'dateTime':\n if (typeof maxValue === 'string') {\n if (dayjs(input).isAfter(dayjs(maxValue))) {\n return ValidationResult.maxValue;\n }\n }\n break;\n default:\n return null;\n }\n\n return null;\n}\n\n/**\n * Checks for Minimum Quantity Value and returns the validation results\n *\n * @param {QuestionnaireItem} qItem\n * @param {string} input\n * @param {number} minQuantityValue\n * @return {*} {(ValidationResult.minQuantityValue | null)}\n */\nfunction checkMinQuantityValue(\n qItem: QuestionnaireItem,\n input: string,\n minQuantityValue: number\n): ValidationResult.minQuantityValue | null {\n switch (qItem.type) {\n case 'quantity': {\n const precision = getDecimalPrecision(qItem);\n const decimalValue = precision\n ? parseDecimalStringToFloat(input, precision)\n : parseFloat(input);\n\n if (decimalValue < minQuantityValue) {\n return ValidationResult.minQuantityValue;\n }\n\n break;\n }\n default:\n return null;\n }\n\n return null;\n}\n\n/**\n * Checks for Maxmim Quantity Value and returns the validation results\n *\n * @param {QuestionnaireItem} qItem\n * @param {string} input\n * @param {number} maxQuantityValue\n * @return {*} {(ValidationResult.maxQuantityValue | null)}\n */\nfunction checkMaxQuantityValue(\n qItem: QuestionnaireItem,\n input: string,\n maxQuantityValue: number\n): ValidationResult.maxQuantityValue | null {\n switch (qItem.type) {\n case 'quantity': {\n const precision = getDecimalPrecision(qItem);\n const decimalValue = precision\n ? parseDecimalStringToFloat(input, precision)\n : parseFloat(input);\n\n if (decimalValue > maxQuantityValue) {\n return ValidationResult.maxQuantityValue;\n }\n\n break;\n }\n default:\n return null;\n }\n\n return null;\n}\n\nexport function createValidationOperationOutcome(\n error: ValidationResult,\n qItem: QuestionnaireItem | null,\n qrItem: QuestionnaireResponseItem | null,\n answerIndex: number | null,\n locationExpression: string,\n existingOperationOutcomeIssues: OperationOutcomeIssue[] = []\n): OperationOutcome {\n return {\n resourceType: 'OperationOutcome',\n issue: existingOperationOutcomeIssues.concat(\n createValidationOperationOutcomeIssue(error, qItem, qrItem, answerIndex, locationExpression)\n )\n };\n}\n\nfunction createValidationOperationOutcomeIssue(\n error: ValidationResult,\n qItem: QuestionnaireItem | null,\n qrItem: QuestionnaireResponseItem | null,\n answerIndex: number | null,\n locationExpression: string,\n severity: 'error' | 'warning' = 'error',\n humanReadable?: string\n): OperationOutcomeIssue {\n const errorCodeSystem = 'http://fhir.forms-lab.com/CodeSystem/errors';\n let detailsText = '';\n let fieldDisplayText = '';\n if (qItem && qrItem) {\n fieldDisplayText =\n qrItem?.text ?? getShortText(qItem) ?? qItem?.text ?? qItem.linkId ?? qrItem.linkId;\n } else {\n fieldDisplayText = 'Unknown item';\n }\n\n if (!fieldDisplayText && fieldDisplayText.endsWith(':')) {\n fieldDisplayText = fieldDisplayText.substring(0, fieldDisplayText.length - 1);\n }\n\n answerIndex = answerIndex ?? 0;\n\n // create operationOutcomeIssue based on error\n switch (error) {\n case ValidationResult.required: {\n if (qItem?.type === 'group') {\n detailsText = `${fieldDisplayText}: Mandatory group does not have answer(s)`;\n } else {\n detailsText = `${fieldDisplayText}: Mandatory field does not have an answer`;\n }\n\n return {\n severity: severity,\n code: 'required',\n expression: [locationExpression],\n details: {\n coding: [\n {\n system: errorCodeSystem,\n code: error,\n display: 'Required'\n }\n ],\n text: detailsText\n }\n };\n }\n\n case ValidationResult.regex: {\n detailsText = `${fieldDisplayText}: The value '${getInputInString(\n qrItem?.answer?.[answerIndex]\n )}' does not match the defined format.`;\n if (qItem && structuredDataCapture.getEntryFormat(qItem)) {\n detailsText += ` ${structuredDataCapture.getEntryFormat(qItem)}`;\n }\n\n return {\n severity: severity,\n code: 'invalid',\n expression: [locationExpression],\n details: {\n coding: [\n {\n system: errorCodeSystem,\n code: error,\n display: 'Invalid format'\n }\n ],\n text: detailsText\n },\n diagnostics: qItem ? (getRegexString(qItem) ?? undefined) : undefined\n };\n }\n\n case ValidationResult.minLength: {\n detailsText = `${fieldDisplayText}: Expected the minimum value ${\n qItem ? structuredDataCapture.getMinLength(qItem) : undefined\n } characters, received '${getInputInString(qrItem?.answer?.[answerIndex])}'`;\n return {\n severity: severity,\n code: 'business-rule',\n expression: [locationExpression],\n details: {\n coding: [\n {\n system: errorCodeSystem,\n code: error,\n display: 'Too short'\n }\n ],\n text: detailsText\n }\n };\n }\n\n case ValidationResult.maxLength: {\n detailsText = `${fieldDisplayText}: Exceeded maximum of ${\n qItem?.maxLength\n } characters, received '${getInputInString(qrItem?.answer?.[answerIndex])}'`;\n return {\n severity: severity,\n code: 'business-rule',\n expression: [locationExpression],\n details: {\n coding: [\n {\n system: errorCodeSystem,\n code: error,\n display: 'Too long'\n }\n ],\n text: detailsText\n }\n };\n }\n\n case ValidationResult.maxDecimalPlaces: {\n detailsText = `${fieldDisplayText}: Exceeded maximum decimal places ${\n qItem ? structuredDataCapture.getMaxDecimalPlaces(qItem) : undefined\n }, received '${getInputInString(qrItem?.answer?.[answerIndex])}'`;\n return {\n severity: severity,\n code: 'business-rule',\n expression: [locationExpression],\n details: {\n coding: [\n {\n system: errorCodeSystem,\n code: error,\n display: 'Too precise'\n }\n ],\n text: detailsText\n }\n };\n }\n\n case ValidationResult.minValue: {\n detailsText = `${fieldDisplayText}: Expected the minimum value ${\n qItem ? getMinValue(qItem) : undefined\n }, received '${getInputInString(qrItem?.answer?.[answerIndex])}'`;\n return {\n severity: severity,\n code: 'business-rule',\n expression: [locationExpression],\n details: {\n coding: [\n {\n system: errorCodeSystem,\n code: error,\n display: 'Too small'\n }\n ],\n text: detailsText\n }\n };\n }\n\n case ValidationResult.maxValue: {\n detailsText = `${fieldDisplayText}: Exceeded the maximum value ${\n qItem ? getMaxValue(qItem) : undefined\n }, received '${getInputInString(qrItem?.answer?.[answerIndex])}'`;\n return {\n severity: severity,\n code: 'business-rule',\n expression: [locationExpression],\n details: {\n coding: [\n {\n system: errorCodeSystem,\n code: error,\n display: 'Too big'\n }\n ],\n text: detailsText\n }\n };\n }\n\n // Validation result error handling for min quantity extension\n case ValidationResult.minQuantityValue: {\n detailsText = `${fieldDisplayText}: Expected the minimum value ${\n qItem ? getMinQuantityValue(qItem) : undefined\n }, received '${getInputInString(qrItem?.answer?.[answerIndex])}'`;\n return {\n severity: severity,\n code: 'business-rule',\n expression: [locationExpression],\n details: {\n coding: [\n {\n system: errorCodeSystem,\n code: error,\n display: 'Too small'\n }\n ],\n text: detailsText\n }\n };\n }\n\n // Validation result error handling for max quantity extension\n case ValidationResult.maxQuantityValue: {\n detailsText = `${fieldDisplayText}: Exceeded the maximum value ${\n qItem ? getMaxQuantityValue(qItem) : undefined\n }, received '${getInputInString(qrItem?.answer?.[answerIndex])}'`;\n return {\n severity: severity,\n code: 'business-rule',\n expression: [locationExpression],\n details: {\n coding: [\n {\n system: errorCodeSystem,\n code: error,\n display: 'Too big'\n }\n ],\n text: detailsText\n }\n };\n }\n\n case ValidationResult.invariant: {\n return {\n severity: severity,\n code: 'business-rule',\n expression: [locationExpression],\n details: {\n coding: [\n {\n system: errorCodeSystem,\n code: error,\n display: humanReadable\n }\n ],\n text: humanReadable\n }\n };\n }\n\n // mark unknown issues as fatal\n default: {\n return {\n severity: 'error',\n code: 'unknown',\n expression: [locationExpression],\n details: {\n coding: [\n {\n system: errorCodeSystem,\n code: 'unknown',\n display: 'Unknown'\n }\n ]\n }\n };\n }\n }\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function parseValidInteger(input: string): number {\n const validNumericString = parseValidNumericString(input);\n\n return parseInt(validNumericString);\n}\n\nexport function parseValidNumericString(input: string): string {\n const hasNumber = /\\d/;\n if (!hasNumber.test(input)) {\n return '0';\n }\n\n return input;\n}\n\nexport function parseIntegerString(input: string): string {\n if (input === '') {\n return '';\n }\n\n input = parseValidNumericString(input);\n return parseInt(input).toString();\n}\n\nexport function parseDecimalStringWithPrecision(input: string, precision: number | null): string {\n if (input === '') {\n return '';\n }\n\n input = parseValidNumericString(input);\n\n let parsedInput = parseFloat(input).toString();\n\n // restore decimal digits if parseFloat() removes them\n const decimalPoint = input.indexOf('.');\n if (decimalPoint !== -1) {\n const decimalDigits = input.slice(decimalPoint);\n if (parsedInput.indexOf('.') === -1) {\n parsedInput += decimalDigits;\n }\n }\n\n // truncate decimal digits based on precision\n const parsedDecimalPoint = input.indexOf('.');\n if (typeof precision === 'number' && parsedDecimalPoint !== -1) {\n parsedInput = parsedInput.substring(0, parsedDecimalPoint + precision + 1);\n }\n\n return parsedInput;\n}\n\nexport function parseDecimalStringToFloat(input: string, precision: number): number {\n return parseFloat(parseFloat(input).toFixed(precision));\n}\n","import type {\n CodeableConcept,\n Observation,\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireResponse,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport { readQuestionnaireResponse, transverseQuestionnaire } from './genericRecursive';\nimport { getQrItemsIndex, mapQItemsIndex } from './mapItem';\nimport { getRelevantCodingProperties } from './valueSet';\n\n/**\n * Extract an array of Observations from a QuestionnaireResponse and its source Questionnaire.\n * @see https://build.fhir.org/ig/HL7/sdc/extraction.html#observation-based-extraction\n *\n * @author Riza Nafis\n */\nexport function extractObservationBased(\n questionnaire: Questionnaire,\n questionnaireResponse: QuestionnaireResponse\n): Observation[] {\n const observations: Observation[] = [];\n\n if (\n !questionnaire.item ||\n questionnaire.item.length === 0 ||\n !questionnaireResponse.item ||\n questionnaireResponse.item.length === 0\n ) {\n return observations;\n }\n\n if (!questionnaireResponse.id) {\n questionnaireResponse.id = generateUniqueId(\n (questionnaireResponse.identifier && questionnaireResponse.identifier.value) || 'QR'\n );\n }\n\n const qItemExtractableMap = mapQItemsExtractable(questionnaire);\n\n return readQuestionnaireResponse(\n questionnaire,\n questionnaireResponse,\n extractObservationBasedRecursive,\n { qr: questionnaireResponse, qItemMap: qItemExtractableMap }\n );\n}\n\nconst FHIR_OBSERVATION_EXTRACT_EXTENSION =\n 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract';\n\nconst FHIR_OBSERVATION_EXTRACT_CATEGORY_EXTENSION =\n 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observation-extract-category';\n\nfunction extractObservationBasedRecursive(\n qItem: QuestionnaireItem,\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null,\n extraData?: { qr: QuestionnaireResponse; qItemMap: Record<string, Extractable> }\n): Observation[] | null {\n // Process items with child items\n const observations: Observation[] = [];\n\n if (!extraData?.qr || !extraData?.qItemMap) return observations;\n\n // Map qrItemOrItems into an array of qrItems\n let qrItems: QuestionnaireResponseItem[] = [];\n if (qrItemOrItems) {\n if (Array.isArray(qrItemOrItems)) {\n qrItems = qrItemOrItems;\n } else {\n qrItems = [qrItemOrItems];\n }\n }\n\n for (const responseItem of qrItems) {\n // Check if the response item has any values or nested items\n if (responseItem.answer && responseItem.answer.length > 0) {\n for (const answer of responseItem.answer) {\n const currentQItemExtractable = extraData.qItemMap[qItem.linkId];\n\n if (currentQItemExtractable.extractable) {\n const observation = createObservation(\n qItem,\n extraData.qr,\n answer,\n currentQItemExtractable.extractCategories\n );\n\n observations.push(observation);\n }\n }\n }\n }\n\n const childQItems = qItem.item;\n if (!childQItems || childQItems.length === 0) return observations;\n\n // Map qrItemOrItems into an array of qrItems\n let childQrItems: QuestionnaireResponseItem[] = [];\n if (qrItemOrItems) {\n if (Array.isArray(qrItemOrItems)) {\n childQrItems = qrItemOrItems;\n } else {\n childQrItems = qrItemOrItems.item ?? [];\n }\n }\n\n const indexMap = mapQItemsIndex(qItem);\n const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap);\n\n for (const [index, childQItem] of childQItems.entries()) {\n const childQRItemOrItems = qrItemsByIndex[index];\n\n const childObservations = extractObservationBasedRecursive(\n childQItem,\n childQRItemOrItems ?? null,\n extraData\n );\n\n if (childObservations) {\n observations.push(...childObservations);\n }\n }\n\n return observations;\n}\n\nexport type Extractable = {\n extractable: boolean;\n extractCategories: CodeableConcept[];\n};\n\nexport function mapQItemsExtractable(questionnaire: Questionnaire): Record<string, Extractable> {\n if (!questionnaire.item || questionnaire.item.length === 0) {\n return {};\n }\n\n const initialExtension = questionnaire.extension?.find(\n (e) => e.url === FHIR_OBSERVATION_EXTRACT_EXTENSION\n );\n\n const extractCategoryExts = questionnaire.extension\n ?.filter((e) => e.url === FHIR_OBSERVATION_EXTRACT_CATEGORY_EXTENSION && e.valueCodeableConcept)\n ?.map((e) => e.valueCodeableConcept) as CodeableConcept[] | undefined;\n\n const initialExtractMap: Record<string, Extractable> = {\n [questionnaire.id ?? 'root']: {\n extractable: initialExtension?.valueBoolean ?? false,\n extractCategories: extractCategoryExts ?? []\n }\n };\n\n transverseQuestionnaire(questionnaire, mapQItemsExtractableRecursive, initialExtractMap);\n\n return initialExtractMap;\n}\n\nfunction mapQItemsExtractableRecursive(\n qItem: QuestionnaireItem,\n root?: Questionnaire,\n parent?: QuestionnaireItem,\n qItemExtrableMap?: Record<string, Extractable>\n): void {\n if (!qItemExtrableMap) return;\n\n if (!qItemExtrableMap[qItem.linkId]) {\n qItemExtrableMap[qItem.linkId] = { extractable: false, extractCategories: [] };\n }\n\n // Check if questionnaire extractable\n const extension = qItem.extension?.find((e) => e.url === FHIR_OBSERVATION_EXTRACT_EXTENSION);\n\n if (extension?.valueBoolean || extension?.valueBoolean === false) {\n qItemExtrableMap[qItem.linkId].extractable = extension?.valueBoolean ?? false;\n } else if (parent && qItemExtrableMap[parent.linkId]) {\n qItemExtrableMap[qItem.linkId].extractable = qItemExtrableMap[parent.linkId].extractable;\n } else if (root && qItemExtrableMap[root.id ?? 'root']) {\n qItemExtrableMap[qItem.linkId].extractable = qItemExtrableMap[root?.id ?? 'root'].extractable;\n } else {\n qItemExtrableMap[qItem.linkId].extractable = false;\n }\n\n // if questionnaire extractable, check for extract category\n if (qItemExtrableMap[qItem.linkId].extractable) {\n const extractCategoryExts = qItem.extension\n ?.filter(\n (e) => e.url === FHIR_OBSERVATION_EXTRACT_CATEGORY_EXTENSION && e.valueCodeableConcept\n )\n ?.map((e) => e.valueCodeableConcept) as CodeableConcept[] | undefined;\n\n if (extractCategoryExts) {\n qItemExtrableMap[qItem.linkId].extractCategories = extractCategoryExts;\n } else if (parent && qItemExtrableMap[parent.linkId].extractCategories.length) {\n qItemExtrableMap[qItem.linkId].extractCategories =\n qItemExtrableMap[parent.linkId].extractCategories;\n } else if (root && qItemExtrableMap[root.id ?? 'root'].extractCategories.length) {\n qItemExtrableMap[qItem.linkId].extractCategories =\n qItemExtrableMap[root?.id ?? 'root'].extractCategories;\n } else {\n qItemExtrableMap[qItem.linkId].extractCategories = [];\n }\n }\n\n if (qItem.item && qItem.item.length !== 0) {\n for (const qChildItem of qItem.item) {\n mapQItemsExtractableRecursive(qChildItem, root, qItem, qItemExtrableMap);\n }\n }\n}\n\nexport function createObservation(\n questionnaireItem: QuestionnaireItem,\n questionnaireResponse: QuestionnaireResponse,\n answer: QuestionnaireResponseItemAnswer,\n categories: CodeableConcept[]\n): Observation {\n const qrRef = `QuestionnaireResponse/${questionnaireResponse.id}`;\n\n const observation: Observation = {\n resourceType: 'Observation',\n status: 'final',\n ...removeIfNull('id', questionnaireItem.linkId, `obs-${questionnaireItem.linkId}`),\n code: {\n coding:\n questionnaireItem.code?.map((c) => ({\n ...removeIfNull('system', c.system),\n ...removeIfNull('code', c.code),\n ...removeIfNull('display', c.display)\n })) ?? []\n },\n ...removeIfNull('basedOn', questionnaireResponse.basedOn),\n ...removeIfNull('partOf', questionnaireResponse.partOf),\n ...removeIfNull('subject', questionnaireResponse.subject),\n ...removeIfNull('encounter', questionnaireResponse.encounter),\n derivedFrom: [{ reference: qrRef }],\n ...removeIfNull('effectiveDateTime', questionnaireResponse.authored),\n ...removeIfNull('issued', questionnaireResponse.authored),\n ...removeIfNull('author', questionnaireResponse.author)\n };\n\n // Set the value of the Observation based on the answer type\n if (answer.valueQuantity) {\n observation.valueQuantity = answer.valueQuantity;\n } else if (answer.valueString) {\n observation.valueString = answer.valueString;\n } else if (answer.valueBoolean) {\n observation.valueBoolean = answer.valueBoolean;\n } else if (answer.valueInteger) {\n observation.valueInteger = answer.valueInteger;\n } else if (answer.valueCoding) {\n observation.valueCodeableConcept = {\n coding: [getRelevantCodingProperties(answer.valueCoding)]\n };\n }\n\n if (categories.length) {\n observation.category = categories;\n }\n\n return observation;\n}\n\nlet ID_COUNTER = 0;\n\nexport function generateUniqueId(prefix: string) {\n if (ID_COUNTER) {\n ID_COUNTER = 0;\n }\n\n return (\n prefix + '-' + Date.now() + '-' + ++ID_COUNTER + '-' + Math.random().toString(16).substring(2)\n );\n}\n\nfunction removeIfNull<T, U>(\n key: string,\n value?: T,\n expectedValue?: U\n): Record<string, T> | Record<string, U> | Record<string, never> {\n if (!value) return {};\n\n if (expectedValue) return { [key]: expectedValue };\n\n return { [key]: value };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Questionnaire, QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';\n\n/**\n * Filter x-fhir-query variables from questionnaire's extensions needed for population\n *\n * @author Sean Fong\n */\nexport function insertCompleteAnswerOptionsIntoQuestionnaire(\n questionnaire: Questionnaire,\n completeAnswerOptions: Record<string, QuestionnaireItemAnswerOption[]>\n): Questionnaire {\n if (questionnaire.item && questionnaire.item.length > 0) {\n for (const qItem of questionnaire.item) {\n insertCompleteAnswerOptionsRecursive(qItem, completeAnswerOptions);\n }\n }\n\n return questionnaire;\n}\n\nfunction insertCompleteAnswerOptionsRecursive(\n qItem: QuestionnaireItem,\n completeAnswerOptions: Record<string, QuestionnaireItemAnswerOption[]>\n) {\n if (qItem.item) {\n for (const childItem of qItem.item) {\n insertCompleteAnswerOptionsRecursive(childItem, completeAnswerOptions);\n }\n }\n\n if (qItem.answerOption) {\n const options = completeAnswerOptions[qItem.linkId];\n if (options) {\n qItem.answerOption = options;\n }\n }\n\n return;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createStore } from 'zustand/vanilla';\nimport type { Encounter, Patient, Practitioner } from 'fhir/r4';\nimport type Client from 'fhirclient/lib/Client';\nimport { createSelectors } from './selector';\n\n/**\n * SmartConfigStore properties and methods\n * Properties can be accessed for fine-grain details.\n * Methods are usually used internally, using them from an external source is not recommended.\n *\n * @property client - The FHIRClient object (https://github.com/smart-on-fhir/client-js)\n * @property patient - The patient resource in context\n * @property user - The user resource in context\n * @property encounter - The encounter resource in context\n * @property setClient - Set the FHIRClient object when launching via SMART App Launch\n * @property setPatient - Set the patient resource in context\n * @property setUser - Set the user resource in context\n * @property setEncounter - Set the encounter resource in context\n *\n * @author Sean Fong\n */\nexport interface SmartConfigStoreType {\n client: Client | null;\n patient: Patient | null;\n user: Practitioner | null;\n encounter: Encounter | null;\n setClient: (client: Client) => void;\n setPatient: (patient: Patient) => void;\n setUser: (user: Practitioner) => void;\n setEncounter: (encounter: Encounter) => void;\n}\n\n/**\n * Smart Config state management store. This is only used for answerExpressions.\n * It is recommended to manage the state of the FHIRClient, patient, user, and encounter in the parent application, since the renderer doesn't provide pre-population capabilities.\n * Will be deprecated in version 1.0.0.\n *\n * This is the vanilla version of the store which can be used in non-React environments.\n * @see SmartConfigStoreType for available properties and methods.\n *\n * @author Sean Fong\n */\nexport const smartConfigStore = createStore<SmartConfigStoreType>()((set) => ({\n client: null,\n patient: null,\n user: null,\n encounter: null,\n setClient: (client: Client) => set(() => ({ client: client })),\n setPatient: (patient: Patient) => set(() => ({ patient: patient })),\n setUser: (user: Practitioner) => set(() => ({ user: user })),\n setEncounter: (encounter: Encounter) => set(() => ({ encounter: encounter }))\n}));\n\n/**\n * Smart Config state management store. This is only used for answerExpressions.\n * It is recommended to manage the state of the FHIRClient, patient, user, and encounter in the parent application, since the renderer doesn't provide pre-population capabilities.\n * Will be deprecated in version 1.0.0.\n *\n * This is the React version of the store which can be used as React hooks in React functional components.\n * @see SmartConfigStoreType for available properties and methods.\n * @see smartConfigStore for the vanilla store.\n *\n * @author Sean Fong\n */\nexport const useSmartConfigStore = createSelectors(smartConfigStore);\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createStore } from 'zustand/vanilla';\nimport { createSelectors } from './selector';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport type { UseResponsiveProps } from '../hooks';\nimport type { Breakpoints } from '@mui/material';\n\n/**\n * RendererStyling interface\n * Provides fine-grained control over the styling and behaviour of the renderer.\n *\n * @property requiredIndicatorPosition - Defines where the required asterisk (*) is placed relative to the label.\n * - `\"start\"` (default): Asterisk appears before the label.\n * - `\"end\"`: Asterisk appears after the label.\n *\n * @property itemResponsive - Controls responsive layout settings for item labels and fields.\n * @property labelBreakpoints - Defines breakpoints for label width at different screen sizes.\n * - Default: `{ xs: 12, md: 4 }`\n * @property fieldBreakpoints - Defines breakpoints for field width at different screen sizes.\n * - Default: `{ xs: 12, md: 8 }`\n * @property columnGapPixels - Spacing (in pixels) between the label and the field.\n * - Default: `32`\n * @property rowGapPixels - Vertical spacing (in pixels) between stacked items.\n * - Default: `4`\n *\n * @property showTabbedFormAt - Defines when the form should switch to a tabbed layout based on screen size.\n * - Default: `{ query: 'up', start: 'md' }`\n *\n * @property tabListWidthOrResponsive - Configures the width of the tab list, either as a fixed number or responsive breakpoints.\n * - Default: `{ tabListBreakpoints: { xs: 12, sm: 3, md: 3, lg: 2.75 }, tabContentBreakpoints: { xs: 12, sm: 9, md: 9, lg: 9.25 } }`\n *\n * @property textFieldWidth - Defines the default width for text input fields (in pixels).\n * - Default: `320`\n *\n * @property inputsFlexGrow - Determines whether input fields should grow to fill available space.\n * - `false` (default): Inputs maintain their default size.\n * - `true`: Inputs expand to fill space.\n *\n * @property reverseBooleanYesNo - If `true`, swaps \"Yes\" and \"No\" options for boolean fields.\n * - Default: `false`\n *\n * @property hideClearButton - If `true`, hides the clear button on input fields.\n * - Default: `false`\n *\n * @property hideQuantityComparatorField - If `true`, hides the quantity comparator field.\n * - Default: `false`\n *\n * @property enableWhenAsReadOnly - Determines whether fields hidden by `enableWhen` logic should still be shown as read-only.\n * - Can be `true` (all fields affected) or a `Set<QuestionnaireItem['type']>` to specify types.\n * - Default: `false`\n *\n * @property disablePageCardView - If `true`, disables the card-style layout for pages.\n * - Default: `false`\n *\n * @property disablePageButtons - If `true`, hides navigation buttons for pages.\n * - Default: `false`\n *\n * @property disableTabButtons - If `true`, hides navigation buttons for tabs.\n * - Default: `false`\n *\n * @property readOnlyVisualStyle - If `true`, item.readOnly will result in form fields having MUI disabled property and styles (recommended from usability perspective). If `false`, item.readOnly will result in form fields having HTML readonly property (less stable, but recommended from accessibility perspective).\n * - Default: `true`\n */\nexport interface RendererStyling {\n readOnlyVisualStyle?: 'disabled' | 'readonly';\n requiredIndicatorPosition?: 'start' | 'end';\n itemResponsive?: {\n labelBreakpoints: Partial<Breakpoints['values']>;\n fieldBreakpoints: Partial<Breakpoints['values']>;\n columnGapPixels: number;\n rowGapPixels: number;\n };\n showTabbedFormAt?: UseResponsiveProps;\n tabListWidthOrResponsive?:\n | number\n | {\n tabListBreakpoints: Partial<Breakpoints['values']>;\n tabContentBreakpoints: Partial<Breakpoints['values']>;\n };\n textFieldWidth?: number;\n inputsFlexGrow?: boolean;\n reverseBooleanYesNo?: boolean;\n hideClearButton?: boolean;\n hideQuantityComparatorField?: boolean;\n enableWhenAsReadOnly?: boolean | Set<QuestionnaireItem['type']>; // The Set<QuestionnaireItem['type']> is used to store the types of items that should be displayed as readOnly when hidden by enableWhen\n disablePageCardView?: boolean;\n disablePageButtons?: boolean;\n disableTabButtons?: boolean;\n}\n\n/**\n * RendererStylingStore properties and methods\n *\n * @author Sean Fong\n */\nexport interface RendererStylingStoreType {\n readOnlyVisualStyle: 'disabled' | 'readonly';\n requiredIndicatorPosition: 'start' | 'end';\n itemResponsive: {\n labelBreakpoints: Partial<Breakpoints['values']>;\n fieldBreakpoints: Partial<Breakpoints['values']>;\n columnGapPixels: number;\n rowGapPixels: number;\n };\n tabListWidthOrResponsive:\n | number\n | {\n tabListBreakpoints: Partial<Breakpoints['values']>;\n tabContentBreakpoints: Partial<Breakpoints['values']>;\n };\n showTabbedFormAt: UseResponsiveProps;\n textFieldWidth: number;\n inputsFlexGrow: boolean; // radio, checkbox and boolean inputs should have flexGrow: 1\n reverseBooleanYesNo: boolean;\n hideClearButton: boolean;\n hideQuantityComparatorField: boolean;\n enableWhenAsReadOnly: boolean | Set<QuestionnaireItem['type']>;\n disablePageCardView: boolean;\n disablePageButtons: boolean;\n disableTabButtons: boolean;\n setRendererStyling: (params: RendererStyling) => void;\n}\n\n/**\n * @author Sean Fong\n */\nexport const rendererStylingStore = createStore<RendererStylingStoreType>()((set) => ({\n readOnlyVisualStyle: 'disabled',\n requiredIndicatorPosition: 'start',\n itemResponsive: {\n labelBreakpoints: { xs: 12, md: 4 },\n fieldBreakpoints: { xs: 12, md: 8 },\n columnGapPixels: 32,\n rowGapPixels: 4\n },\n tabListWidthOrResponsive: {\n tabListBreakpoints: { xs: 12, sm: 3, md: 3, lg: 2.75 },\n tabContentBreakpoints: { xs: 12, sm: 9, md: 9, lg: 9.25 }\n },\n showTabbedFormAt: { query: 'up', start: 'md' },\n textFieldWidth: 320,\n inputsFlexGrow: false,\n reverseBooleanYesNo: false,\n hideClearButton: false,\n hideQuantityComparatorField: false,\n enableWhenAsReadOnly: false,\n disablePageCardView: false,\n disablePageButtons: false,\n disableTabButtons: false,\n setRendererStyling: (params: RendererStyling) => {\n set(() => ({\n readOnlyVisualStyle: params.readOnlyVisualStyle ?? 'disabled',\n requiredIndicatorPosition: params.requiredIndicatorPosition ?? 'start',\n itemResponsive: params.itemResponsive ?? {\n labelBreakpoints: { xs: 12, md: 4 },\n fieldBreakpoints: { xs: 12, md: 8 },\n columnGapPixels: 32,\n rowGapPixels: 4\n },\n tabListWidthOrResponsive: params.tabListWidthOrResponsive ?? {\n tabListBreakpoints: { xs: 12, md: 3, lg: 2.75 },\n tabContentBreakpoints: { xs: 12, md: 9, lg: 9.25 }\n },\n showTabbedFormAt: params.showTabbedFormAt ?? { query: 'up', start: 'md' },\n textFieldWidth: params.textFieldWidth ?? 320,\n inputsFlexGrow: params.inputsFlexGrow ?? false,\n reverseBooleanYesNo: params.reverseBooleanYesNo ?? false,\n hideClearButton: params.hideClearButton ?? false,\n hideQuantityComparatorField: params.hideQuantityComparatorField ?? false,\n enableWhenAsReadOnly: params.enableWhenAsReadOnly ?? false,\n disablePageCardView: params.disablePageCardView ?? false,\n disablePageButtons: params.disablePageButtons ?? false,\n disableTabButtons: params.disableTabButtons ?? false\n }));\n }\n}));\n\nexport const useRendererStylingStore = createSelectors(rendererStylingStore);\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n QuestionnaireItem,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';\nimport { isHiddenByEnableWhen } from './qItem';\nimport { qrItemHasItemsOrAnswer } from './manageForm';\nimport { getQrItemsIndex, mapQItemsIndex } from './mapItem';\n\n/**\n * Recursively go through the questionnaireResponse and remove qrItems whose qItems are empty in the form\n *\n * @author Sean Fong\n */\nexport function removeEmptyAnswersFromItemRecursive(\n qItem: QuestionnaireItem,\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null,\n enableWhenContext: {\n enableWhenIsActivated: boolean;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n }\n): QuestionnaireResponseItem | QuestionnaireResponseItem[] | null {\n // Process repeating group items separately\n const hasMultipleAnswers = Array.isArray(qrItemOrItems);\n if (hasMultipleAnswers) {\n return removeEmptyAnswersFromRepeatGroup(qItem, qrItemOrItems, enableWhenContext);\n }\n\n // At this point, qrItemOrItems is a single QuestionnaireResponseItem\n const qrItem = qrItemOrItems;\n\n // If QR item is null, return null\n if (qrItem === null) {\n return null;\n }\n\n // If QR item don't have either item.item and item.answer, return null\n if (!qrItemHasItemsOrAnswer(qrItem)) {\n return null;\n }\n\n // If qItem is hidden by enableWhen, return null\n if (\n isHiddenByEnableWhen({\n linkId: qItem.linkId,\n enableWhenIsActivated: enableWhenContext.enableWhenIsActivated,\n enableWhenItems: enableWhenContext.enableWhenItems,\n enableWhenExpressions: enableWhenContext.enableWhenExpressions\n })\n ) {\n return null;\n }\n\n // Process items with child items\n const childQItems = qItem.item ?? [];\n const childQrItems = qrItem?.item ?? [];\n const updatedChildQrItems: QuestionnaireResponseItem[] = [];\n if (childQItems.length > 0) {\n const indexMap = mapQItemsIndex(qItem);\n const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap);\n\n // Iterate child items\n for (const [index, childQItem] of childQItems.entries()) {\n const childQRItemOrItems = qrItemsByIndex[index];\n\n const updatedChildQRItemOrItems = removeEmptyAnswersFromItemRecursive(\n childQItem,\n childQRItemOrItems ?? null,\n enableWhenContext\n );\n\n if (Array.isArray(updatedChildQRItemOrItems)) {\n if (updatedChildQRItemOrItems.length > 0) {\n updatedChildQrItems.push(...updatedChildQRItemOrItems);\n }\n continue;\n }\n\n if (updatedChildQRItemOrItems) {\n updatedChildQrItems.push(updatedChildQRItemOrItems);\n }\n }\n }\n\n // Construct updated qrItem\n return removeEmptyAnswersFromItem(qItem, qrItem, updatedChildQrItems);\n}\n\nfunction removeEmptyAnswersFromRepeatGroup(\n qItem: QuestionnaireItem,\n qrItems: QuestionnaireResponseItem[],\n enableWhenContext: {\n enableWhenIsActivated: boolean;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n }\n) {\n if (!qItem.item) {\n return [];\n }\n\n return qrItems\n .flatMap((childQrItem) =>\n removeEmptyAnswersFromItemRecursive(qItem, childQrItem, enableWhenContext)\n )\n .filter((childQRItem): childQRItem is QuestionnaireResponseItem => !!childQRItem);\n}\n\nfunction removeEmptyAnswersFromItem(\n qItem: QuestionnaireItem,\n qrItem: QuestionnaireResponseItem | null,\n childQrItems: QuestionnaireResponseItem[]\n): QuestionnaireResponseItem | null {\n if (!qrItem) {\n return null;\n }\n\n // Remove empty answers\n const updatedAnswers: QuestionnaireResponseItemAnswer[] =\n qrItem.answer?.filter((answer) => !isEmptyAnswer(answer)) ?? [];\n\n // Remove item if it has no answers and no children\n if (updatedAnswers.length === 0 && childQrItems.length === 0) {\n return null;\n }\n\n return {\n linkId: qItem.linkId,\n ...(qItem.text && { text: qItem.text }),\n ...(childQrItems.length > 0 && { item: childQrItems }),\n ...(updatedAnswers.length > 0 && { answer: updatedAnswers })\n };\n}\n\nfunction isEmptyAnswer(answer: QuestionnaireResponseItemAnswer): boolean {\n return answer?.valueString === '' || answer?.item?.length === 0;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type Client from 'fhirclient/lib/Client';\nimport type { Encounter, Patient, Practitioner } from 'fhir/r4';\n\nexport async function readPatient(client: Client): Promise<Patient> {\n return await client.patient.read();\n}\n\nexport async function readUser(client: Client): Promise<Practitioner> {\n return (await client.user.read()) as Practitioner;\n}\n\nexport async function readEncounter(client: Client): Promise<Encounter> {\n return (await client.encounter.read()) as Encounter;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n QuestionnaireItem,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport { getQrItemsIndex, mapQItemsIndex } from './mapItem';\n\nexport function removeInternalRepeatIdsRecursive(\n qItem: QuestionnaireItem,\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null\n): QuestionnaireResponseItem | QuestionnaireResponseItem[] | null {\n // Process repeating group items separately\n const hasMultipleAnswers = Array.isArray(qrItemOrItems);\n if (hasMultipleAnswers) {\n return removeInternalRepeatIdsFromRepeatGroup(qItem, qrItemOrItems);\n }\n\n // At this point qrItemOrItems is a single QuestionnaireResponseItem\n const qrItem = qrItemOrItems;\n\n // Process items with child items\n const childQItems = qItem.item ?? [];\n const childQrItems = qrItem?.item ?? [];\n const updatedChildQrItems: QuestionnaireResponseItem[] = [];\n if (childQItems.length > 0) {\n const indexMap = mapQItemsIndex(qItem);\n const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap);\n\n // Iterate child items\n for (const [index, childQItem] of childQItems.entries()) {\n const childQRItemOrItems = qrItemsByIndex[index];\n\n const updatedChildQRItemOrItems = removeInternalRepeatIdsRecursive(\n childQItem,\n childQRItemOrItems ?? null\n );\n\n if (Array.isArray(updatedChildQRItemOrItems)) {\n if (updatedChildQRItemOrItems.length > 0) {\n updatedChildQrItems.push(...updatedChildQRItemOrItems);\n }\n continue;\n }\n\n if (updatedChildQRItemOrItems) {\n updatedChildQrItems.push(updatedChildQRItemOrItems);\n }\n }\n }\n\n // Construct updated qrItem\n return removeInternalRepeatIdsFromItem(qItem, qrItem, updatedChildQrItems);\n}\n\nfunction removeInternalRepeatIdsFromRepeatGroup(\n qItem: QuestionnaireItem,\n qrItems: QuestionnaireResponseItem[]\n) {\n if (!qItem.item) {\n return [];\n }\n\n return qrItems\n .flatMap((childQrItem) => removeInternalRepeatIdsRecursive(qItem, childQrItem))\n .filter((childQRItem): childQRItem is QuestionnaireResponseItem => !!childQRItem);\n}\n\nfunction removeInternalRepeatIdsFromItem(\n qItem: QuestionnaireItem,\n qrItem: QuestionnaireResponseItem | null,\n childQrItems: QuestionnaireResponseItem[]\n): QuestionnaireResponseItem | null {\n if (!qrItem) {\n return null;\n }\n\n // Remove internal repeatId from all answers\n const updatedAnswers: QuestionnaireResponseItemAnswer[] =\n qrItem.answer\n ?.map(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ({ id, ...rest }) => {\n return {\n ...rest\n };\n }\n )\n .filter((answer) => !!answer && Object.keys(answer).length > 0) ?? [];\n\n return {\n linkId: qItem.linkId,\n ...(qItem.text && { text: qItem.text }),\n ...(childQrItems.length > 0 && { item: childQrItems }),\n ...(updatedAnswers.length > 0 && { answer: updatedAnswers })\n };\n}\n","import type { Questionnaire, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';\nimport {\n questionnaireResponseStore,\n questionnaireStore,\n smartConfigStore,\n terminologyServerStore\n} from '../stores';\nimport { initialiseQuestionnaireResponse } from './initialise';\nimport { removeEmptyAnswersFromItemRecursive } from './removeEmptyAnswers';\nimport { readEncounter, readPatient, readUser } from '../api/smartClient';\nimport type Client from 'fhirclient/lib/Client';\nimport { updateQuestionnaireResponse } from './genericRecursive';\nimport { removeInternalRepeatIdsRecursive } from './removeRepeatId';\nimport type { ComponentType } from 'react';\nimport type { QItemOverrideComponentProps, SdcUiOverrideComponentProps } from '../interfaces';\n\n/**\n * Build the form with an initial Questionnaire and an optional filled QuestionnaireResponse.\n * If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse.\n * There are other optional properties such as applying readOnly, providing a terminology server url and additional variables.\n *\n * @param questionnaire - Questionnaire to be rendered\n * @param questionnaireResponse - Pre-populated/draft/loaded QuestionnaireResponse to be rendered (optional)\n * @param readOnly - Applies read-only mode to all items in the form view\n * @param terminologyServerUrl - Terminology server url to fetch terminology. If not provided, the default terminology server will be used. (optional)\n * @param additionalVariables - Additional key-value pair of SDC variables `Record<name, variable extension>` for testing (optional)\n * @param qItemOverrideComponents - FIXME add comment\n * @param sdcUiOverrideComponents - FIXME add comment\n *\n * @author Sean Fong\n */\nexport async function buildForm(\n questionnaire: Questionnaire,\n questionnaireResponse?: QuestionnaireResponse,\n readOnly?: boolean,\n terminologyServerUrl?: string,\n additionalVariables?: Record<string, object>,\n qItemOverrideComponents?: Record<string, ComponentType<QItemOverrideComponentProps>>,\n sdcUiOverrideComponents?: Record<string, ComponentType<SdcUiOverrideComponentProps>>\n): Promise<void> {\n // Reset terminology server\n if (terminologyServerUrl) {\n terminologyServerStore.getState().setUrl(terminologyServerUrl);\n } else {\n terminologyServerStore.getState().resetUrl();\n }\n\n // QR is set to undefined here to prevent it from being initialised twice. This is defined like that for backward compatibility purposes.\n await questionnaireStore\n .getState()\n .buildSourceQuestionnaire(\n questionnaire,\n undefined,\n additionalVariables,\n terminologyServerUrl,\n undefined,\n qItemOverrideComponents,\n sdcUiOverrideComponents\n );\n\n const initialisedQuestionnaireResponse = initialiseQuestionnaireResponse(\n questionnaire,\n questionnaireResponse\n );\n questionnaireResponseStore.getState().buildSourceResponse(initialisedQuestionnaireResponse);\n await questionnaireStore.getState().updatePopulatedProperties(initialisedQuestionnaireResponse);\n\n // Adding another call to buildSourceResponse so invalidItems is truly updated - not great, but a cheap fix\n questionnaireResponseStore.getState().buildSourceResponse(initialisedQuestionnaireResponse);\n\n if (readOnly) {\n questionnaireStore.getState().setFormAsReadOnly(readOnly);\n }\n}\n\n/**\n * Destroy the form to clean up the questionnaire and questionnaireResponse stores.\n *\n * @author Sean Fong\n */\nexport function destroyForm(): void {\n questionnaireStore.getState().destroySourceQuestionnaire();\n questionnaireResponseStore.getState().destroySourceResponse();\n}\n\n/**\n * Initialise the FHIRClient object to make further FHIR calls in the renderer.\n * Note that this does not provide pre-population capabilities.\n *\n * @param fhirClient - FHIRClient object to perform further FHIR calls. At the moment it's only used in answerExpressions\n *\n * @author Sean Fong\n */\nexport async function initialiseFhirClient(fhirClient: Client): Promise<void> {\n smartConfigStore.getState().setClient(fhirClient);\n const patientPromise = readPatient(fhirClient);\n const userPromise = readUser(fhirClient);\n const encounterPromise = readEncounter(fhirClient);\n\n const [patient, user, encounter] = await Promise.all([\n patientPromise,\n userPromise,\n encounterPromise\n ]);\n smartConfigStore.getState().setPatient(patient);\n smartConfigStore.getState().setUser(user);\n smartConfigStore.getState().setEncounter(encounter);\n}\n\n/**\n * Get the filled QuestionnaireResponse at its current state.\n * If no changes have been made to the form, the initial QuestionnaireResponse is returned.\n *\n * @author Sean Fong\n */\nexport function getResponse(): QuestionnaireResponse {\n const cleanResponse = removeInternalIdsFromResponse(\n questionnaireStore.getState().sourceQuestionnaire,\n questionnaireResponseStore.getState().updatableResponse\n );\n return structuredClone(cleanResponse);\n}\n\n/**\n * Remove all empty/hidden answers from the filled QuestionnaireResponse.\n * This takes into account enableWhens, enableWhenExpressions, items without item.answer, empty item.answer arrays and empty strings.\n * This does not remove items that are hidden by the http://hl7.org/fhir/StructureDefinition/questionnaire-hidden extension.\n *\n * @author Sean Fong\n */\nexport function removeEmptyAnswersFromResponse(\n questionnaire: Questionnaire,\n questionnaireResponse: QuestionnaireResponse\n): QuestionnaireResponse {\n const enableWhenIsActivated = questionnaireStore.getState().enableWhenIsActivated;\n const enableWhenItems = questionnaireStore.getState().enableWhenItems;\n const enableWhenExpressions = questionnaireStore.getState().enableWhenExpressions;\n\n return updateQuestionnaireResponse(\n questionnaire,\n questionnaireResponse,\n removeEmptyAnswersFromItemRecursive,\n {\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n }\n );\n}\n\n/**\n * Remove all instances of item.answer.id from the filled QuestionnaireResponse.\n * These IDs are used internally for rendering repeating items, and can be safely left out of the final response.\n *\n * @author Sean Fong\n */\nexport function removeInternalIdsFromResponse(\n questionnaire: Questionnaire,\n questionnaireResponse: QuestionnaireResponse\n): QuestionnaireResponse {\n const questionnaireResponseToUpdate = structuredClone(questionnaireResponse);\n\n return updateQuestionnaireResponse(\n questionnaire,\n questionnaireResponseToUpdate,\n removeInternalRepeatIdsRecursive,\n undefined\n );\n}\n\n/**\n * Check if a QuestionnaireResponseItem has either an item or an answer property.\n *\n * @author Sean Fong\n */\nexport function qrItemHasItemsOrAnswer(qrItem: QuestionnaireResponseItem): boolean {\n return (!!qrItem.item && qrItem.item.length > 0) || (!!qrItem.answer && qrItem.answer.length > 0);\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireResponse,\n QuestionnaireResponseItem\n} from 'fhir/r4';\nimport type { Tabs } from '../interfaces/tab.interface';\nimport { containsTabs, isTabContainer } from './tabs';\nimport { getShortText, isSpecificItemControl } from './itemControl';\nimport { getQrItemsIndex, mapQItemsIndex } from './mapItem';\nimport type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';\nimport { isHiddenByEnableWhen } from './qItem';\nimport { questionnaireResponseStore, questionnaireStore } from '../stores';\nimport { createQuestionnaireResponseItemMap } from './questionnaireResponseStoreUtils/updatableResponseItems';\nimport { getQuestionnaireItem, getSectionHeading } from './misc';\nimport difference from 'lodash.difference';\nimport intersection from 'lodash.intersection';\nimport isEqual from 'lodash.isequal';\n\n/**\n * ItemToRepopulate interface\n *\n * @property qItem - The QuestionnaireItem to repopulate\n * @property heading - The heading of the group to repopulate\n * @property newQRItem - The new QuestionnaireResponseItem to replace the old one\n * @property oldQRItem - The old QuestionnaireResponseItem to be replaced\n * @property newQRItems - The new QuestionnaireResponseItems to replace the old ones\n * @property oldQRItems - The old QuestionnaireResponseItems to be replaced\n *\n * @author Sean Fong\n */\nexport interface ItemToRepopulate {\n qItem: QuestionnaireItem | null;\n heading: string | null;\n\n // for non-repeat groups\n newQRItem?: QuestionnaireResponseItem;\n oldQRItem?: QuestionnaireResponseItem;\n\n // for repeat groups\n newQRItems?: QuestionnaireResponseItem[];\n oldQRItems?: QuestionnaireResponseItem[];\n}\n\ninterface getItemsToRepopulateParams {\n sourceQuestionnaire: Questionnaire;\n tabs: Tabs;\n populatedResponse: QuestionnaireResponse;\n updatableResponse: QuestionnaireResponse;\n enableWhenIsActivated: boolean;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n}\n\n/**\n * Compare latest data from the server with the current QuestionnaireResponse and decide items to re-populate\n *\n * @author Sean Fong\n */\nexport function generateItemsToRepopulate(populatedResponse: QuestionnaireResponse) {\n const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;\n const tabs = questionnaireStore.getState().tabs;\n const updatableResponse = questionnaireResponseStore.getState().updatableResponse;\n const updatableResponseItems = questionnaireResponseStore.getState().updatableResponseItems;\n const enableWhenIsActivated = questionnaireStore.getState().enableWhenIsActivated;\n const enableWhenItems = questionnaireStore.getState().enableWhenItems;\n const enableWhenExpressions = questionnaireStore.getState().enableWhenExpressions;\n const initialExpressions = questionnaireStore.getState().initialExpressions;\n\n // This function is able to capture additions, however it is not able to capture deletions\n const itemsToRepopulate = getItemsToRepopulate({\n sourceQuestionnaire,\n tabs,\n populatedResponse,\n updatableResponse,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n });\n\n // Get linkIds that are different between current QRItems and populated QRItems\n // Doesn't work with repeat groups, but at the same time I'm not sure if it's needed, given you can't delete completely the first repeat group\n const populatedResponseItemMap = createQuestionnaireResponseItemMap(\n sourceQuestionnaire,\n populatedResponse\n );\n const diffLinkIds = difference(\n Object.keys(updatableResponseItems),\n Object.keys(populatedResponseItemMap)\n );\n const diffLinkIdsWithInitialExpressions = intersection(\n Object.keys(initialExpressions),\n diffLinkIds\n );\n for (const linkId of diffLinkIdsWithInitialExpressions) {\n if (linkId in updatableResponseItems) {\n itemsToRepopulate[linkId] = {\n qItem: getQuestionnaireItem(sourceQuestionnaire, linkId),\n heading: getSectionHeading(sourceQuestionnaire, linkId, tabs),\n oldQRItem: updatableResponseItems[linkId][0]\n };\n }\n }\n\n return itemsToRepopulate;\n}\n\nexport function getItemsToRepopulate(\n params: getItemsToRepopulateParams\n): Record<string, ItemToRepopulate> {\n const {\n sourceQuestionnaire,\n tabs,\n populatedResponse,\n updatableResponse,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n } = params;\n\n if (\n !sourceQuestionnaire.item ||\n sourceQuestionnaire.item.length === 0 ||\n !populatedResponse.item ||\n populatedResponse.item.length === 0 ||\n !updatableResponse.item ||\n updatableResponse.item.length === 0\n ) {\n return {};\n }\n\n const topLevelQItems = sourceQuestionnaire.item;\n const populatedTopLevelQRItems = populatedResponse.item;\n\n const qItemsIndexMap = mapQItemsIndex(sourceQuestionnaire);\n const populatedTopLevelQRItemsByIndex = getQrItemsIndex(\n topLevelQItems,\n populatedTopLevelQRItems,\n qItemsIndexMap\n );\n\n const itemsToRepopulate: Record<string, ItemToRepopulate> = {};\n for (const [index, topLevelQItem] of topLevelQItems.entries()) {\n const populatedQrItemOrItems = populatedTopLevelQRItemsByIndex[index];\n if (!populatedQrItemOrItems) {\n continue;\n }\n\n const heading = topLevelQItem.text ?? null;\n const hasTabs = isTabContainer(topLevelQItem) || containsTabs(topLevelQItem);\n\n getItemsToRepopulateRecursive({\n qItem: topLevelQItem,\n qrItemOrItems: populatedQrItemOrItems,\n heading,\n tabs,\n hasTabs,\n itemsToRepopulate,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n });\n }\n\n const oldTopLevelQRItemsByIndex = getQrItemsIndex(\n topLevelQItems,\n updatableResponse.item,\n qItemsIndexMap\n );\n for (const [index, topLevelQItem] of topLevelQItems.entries()) {\n const oldQrItemOrItems = oldTopLevelQRItemsByIndex[index];\n if (!oldQrItemOrItems) {\n continue;\n }\n\n checkCorrespondingOldItemsRecursive(topLevelQItem, oldQrItemOrItems, itemsToRepopulate);\n }\n\n return itemsToRepopulate;\n}\n\ninterface getItemsToRepopulateRecursiveParams {\n qItem: QuestionnaireItem;\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[];\n heading: string | null;\n tabs: Tabs;\n hasTabs: boolean;\n itemsToRepopulate: Record<string, ItemToRepopulate>;\n enableWhenIsActivated: boolean;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n}\n\n// 1. Get items to repopulate (only new items)\n// 2. Get corresponding old items from updatableResponse (if they are different)\n// 3. Compare old and new items in dialog - if there are none, show a dialog saying there is no new data\n// 4. Have checkboxes in dialog to update response\n// 5. Replace old answers with new answers\nfunction getItemsToRepopulateRecursive(params: getItemsToRepopulateRecursiveParams) {\n const {\n qItem,\n qrItemOrItems,\n tabs,\n hasTabs,\n itemsToRepopulate,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n } = params;\n let { heading } = params;\n\n if (!qrItemOrItems) {\n return;\n }\n\n // Return nothing if corresponding qItem is hidden\n if (\n isHiddenByEnableWhen({\n linkId: qItem.linkId,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n })\n ) {\n return null;\n }\n\n // For repeat groups\n const hasMultipleAnswers = Array.isArray(qrItemOrItems);\n if (hasMultipleAnswers) {\n if (qrItemOrItems.length > 0) {\n getRepeatGroupToRepopulate(qItem, qrItemOrItems, heading, itemsToRepopulate);\n }\n return;\n }\n\n const childQItems = qItem.item;\n const childQRItems = qrItemOrItems.item;\n\n if (childQItems && childQItems.length > 0 && childQRItems) {\n const isTab = !!tabs[qItem.linkId];\n if (isTab) {\n heading = getShortText(qItem) ?? qItem.text ?? null;\n }\n\n const qItemsIndexMap = mapQItemsIndex(qItem);\n const populatedQRItemsByIndex = getQrItemsIndex(childQItems, childQRItems, qItemsIndexMap);\n\n // For grid groups\n const itemIsGrid = isSpecificItemControl(qItem, 'grid');\n if (itemIsGrid) {\n getGridTableToRepopulate({\n qItem,\n gridChildQItems: childQItems,\n gridChildQRItemsByIndex: populatedQRItemsByIndex,\n heading,\n itemsToRepopulate,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n });\n return;\n }\n\n // For normal groups with children\n for (const [index, childQItem] of childQItems.entries()) {\n const childQrItemOrItems = populatedQRItemsByIndex[index];\n if (!childQrItemOrItems) {\n continue;\n }\n\n getItemsToRepopulateRecursive({\n qItem: childQItem,\n qrItemOrItems: childQrItemOrItems,\n heading,\n tabs,\n hasTabs,\n itemsToRepopulate,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n });\n }\n\n const hasSingleAnswer = !Array.isArray(qrItemOrItems);\n if (hasSingleAnswer && qrItemOrItems.answer) {\n getSingleItemToRepopulate(qItem, qrItemOrItems, heading, itemsToRepopulate);\n }\n return;\n }\n\n // For single items without children\n getSingleItemToRepopulate(qItem, qrItemOrItems, heading, itemsToRepopulate);\n}\n\nfunction getSingleItemToRepopulate(\n qItem: QuestionnaireItem,\n qrItem: QuestionnaireResponseItem,\n heading: string | null,\n itemsToRepopulate: Record<string, ItemToRepopulate>\n) {\n itemsToRepopulate[qItem.linkId] = {\n qItem: qItem,\n heading: heading,\n newQRItem: qrItem,\n newQRItems: []\n };\n}\n\nfunction getRepeatGroupToRepopulate(\n qItem: QuestionnaireItem,\n qrItems: QuestionnaireResponseItem[],\n heading: string | null,\n itemsToRepopulate: Record<string, ItemToRepopulate>\n) {\n itemsToRepopulate[qItem.linkId] = {\n qItem: qItem,\n heading: heading,\n newQRItem: {\n linkId: qItem.linkId\n },\n newQRItems: qrItems\n };\n}\n\ninterface getGridTableToRepopulateParams {\n qItem: QuestionnaireItem;\n gridChildQItems: QuestionnaireItem[];\n gridChildQRItemsByIndex: (QuestionnaireResponseItem | QuestionnaireResponseItem[] | undefined)[];\n heading: string | null;\n itemsToRepopulate: Record<string, ItemToRepopulate>;\n enableWhenIsActivated: boolean;\n enableWhenItems: EnableWhenItems;\n enableWhenExpressions: EnableWhenExpressions;\n}\n\nfunction getGridTableToRepopulate(params: getGridTableToRepopulateParams) {\n const {\n qItem,\n gridChildQItems,\n gridChildQRItemsByIndex,\n heading,\n itemsToRepopulate,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n } = params;\n\n if (gridChildQItems.length === 0) {\n return;\n }\n\n const gridChildQRItemsToRepopulate = gridChildQItems\n .map((qItem, index) => {\n if (\n isHiddenByEnableWhen({\n linkId: qItem.linkId,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n })\n ) {\n return null;\n }\n\n const gridChildQrItemOrItems = gridChildQRItemsByIndex?.[index];\n if (gridChildQrItemOrItems && !Array.isArray(gridChildQrItemOrItems)) {\n return gridChildQrItemOrItems;\n }\n\n return null;\n })\n .filter((item) => item !== null) as QuestionnaireResponseItem[];\n\n itemsToRepopulate[qItem.linkId] = {\n qItem: qItem,\n heading: heading,\n newQRItem: {\n linkId: qItem.linkId,\n text: qItem.text,\n item: gridChildQRItemsToRepopulate\n },\n newQRItems: []\n };\n}\n\nfunction checkCorrespondingOldItemsRecursive(\n qItem: QuestionnaireItem,\n oldQrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[],\n itemsToRepopulate: Record<string, ItemToRepopulate>\n) {\n // For repeat groups\n const hasMultipleAnswers = Array.isArray(oldQrItemOrItems);\n if (hasMultipleAnswers) {\n retrieveRepeatGroupOldQRItems(qItem, oldQrItemOrItems, itemsToRepopulate);\n return;\n }\n\n const childQItems = qItem.item;\n const oldChildQRItems = oldQrItemOrItems.item;\n\n if (childQItems && childQItems.length > 0 && oldChildQRItems) {\n const qItemsIndexMap = mapQItemsIndex(qItem);\n const oldQRItemsByIndex = getQrItemsIndex(childQItems, oldChildQRItems, qItemsIndexMap);\n\n // For grid groups\n const itemIsGrid = isSpecificItemControl(qItem, 'grid');\n if (itemIsGrid) {\n retrieveGridGroupOldQRItems(qItem, childQItems, oldQRItemsByIndex, itemsToRepopulate);\n return;\n }\n\n // For normal groups with children\n for (const [index, childQItem] of childQItems.entries()) {\n const oldChildQrItemOrItems = oldQRItemsByIndex[index];\n if (!oldChildQrItemOrItems) {\n continue;\n }\n\n checkCorrespondingOldItemsRecursive(childQItem, oldChildQrItemOrItems, itemsToRepopulate);\n }\n\n const hasSingleAnswer = !Array.isArray(oldQrItemOrItems);\n if (hasSingleAnswer && oldQrItemOrItems.answer) {\n retrieveSingleOldQRItem(qItem, oldQrItemOrItems, itemsToRepopulate);\n }\n return;\n }\n\n // For single items without children\n retrieveSingleOldQRItem(qItem, oldQrItemOrItems, itemsToRepopulate);\n}\n\nfunction retrieveSingleOldQRItem(\n qItem: QuestionnaireItem,\n oldQRItem: QuestionnaireResponseItem,\n itemsToRepopulate: Record<string, ItemToRepopulate>\n) {\n const newQRItem = itemsToRepopulate[qItem.linkId]?.newQRItem;\n\n if (!newQRItem) {\n return;\n }\n\n if (isEqual(oldQRItem, newQRItem)) {\n delete itemsToRepopulate[qItem.linkId];\n return;\n }\n\n itemsToRepopulate[qItem.linkId].oldQRItem = oldQRItem;\n}\n\nfunction retrieveRepeatGroupOldQRItems(\n qItem: QuestionnaireItem,\n oldQRItems: QuestionnaireResponseItem[],\n itemsToRepopulate: Record<string, ItemToRepopulate>\n) {\n if (!(qItem && oldQRItems && oldQRItems.length > 0)) {\n return;\n }\n\n const newQRItems = itemsToRepopulate[qItem.linkId]?.newQRItems;\n if (!newQRItems) {\n return;\n }\n\n if (isEqual(oldQRItems, newQRItems)) {\n delete itemsToRepopulate[qItem.linkId];\n return;\n }\n\n itemsToRepopulate[qItem.linkId].oldQRItems = oldQRItems;\n}\n\nfunction retrieveGridGroupOldQRItems(\n qItem: QuestionnaireItem,\n gridChildQItems: QuestionnaireItem[],\n oldGridQRItemsByIndex: (QuestionnaireResponseItem | QuestionnaireResponseItem[] | undefined)[],\n itemsToRepopulate: Record<string, ItemToRepopulate>\n) {\n if (gridChildQItems.length === 0) {\n return;\n }\n\n const newGridQRItem = itemsToRepopulate[qItem.linkId]?.newQRItem;\n if (!newGridQRItem || !newGridQRItem.item) {\n return;\n }\n\n const newGridChildQRItemMap = new Map<string, QuestionnaireResponseItem>();\n\n for (const newGridChildQRItem of newGridQRItem.item) {\n newGridChildQRItemMap.set(newGridChildQRItem.linkId, newGridChildQRItem);\n }\n\n // Get old qr items that are different from the new qr items\n const oldGridChildQRItems: QuestionnaireResponseItem[] = [];\n for (const [index, gridChildQItem] of gridChildQItems.entries()) {\n const oldGridChildQrItemOrItems = oldGridQRItemsByIndex[index];\n if (!oldGridChildQrItemOrItems || Array.isArray(oldGridChildQrItemOrItems)) {\n continue;\n }\n\n // At this point we have a single qrItem\n const oldGridChildQrItem = oldGridChildQrItemOrItems;\n const newGridChildQRItem = newGridChildQRItemMap.get(gridChildQItem.linkId);\n\n if (!newGridChildQRItem) {\n continue;\n }\n\n if (isEqual(oldGridChildQrItem, newGridChildQRItem)) {\n newGridChildQRItemMap.delete(gridChildQItem.linkId);\n } else {\n oldGridChildQRItems.push(oldGridChildQrItem);\n }\n }\n\n const newGridChildQRItemsToRepopulate = [...newGridChildQRItemMap.values()];\n // Nothing to repopulate, delete whole item\n if (newGridChildQRItemsToRepopulate.length === 0) {\n delete itemsToRepopulate[qItem.linkId];\n return;\n }\n\n // Otherwise create both old and new grid qr item\n itemsToRepopulate[qItem.linkId].newQRItem = {\n linkId: qItem.linkId,\n text: qItem.text,\n item: newGridChildQRItemsToRepopulate\n };\n itemsToRepopulate[qItem.linkId].oldQRItem = {\n linkId: qItem.linkId,\n text: qItem.text,\n item: oldGridChildQRItems\n };\n}\n","import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport type { ItemToRepopulate } from './repopulateItems';\nimport { getQrItemsIndex, mapQItemsIndex } from './mapItem';\nimport { isSpecificItemControl } from './itemControl';\nimport { questionnaireResponseStore, questionnaireStore } from '../stores';\nimport { updateQuestionnaireResponse } from './genericRecursive';\n\n/**\n * Re-populate checked items in the re-population dialog into the current QuestionnaireResponse\n *\n * @author Sean Fong\n */\nexport function repopulateResponse(checkedItemsToRepopulate: Record<string, ItemToRepopulate>) {\n const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;\n const updatableResponse = questionnaireResponseStore.getState().updatableResponse;\n\n return updateQuestionnaireResponse(\n sourceQuestionnaire,\n updatableResponse,\n repopulateItemRecursive,\n checkedItemsToRepopulate\n );\n}\n\nfunction repopulateItemRecursive(\n qItem: QuestionnaireItem,\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null,\n checkedItemsToRepopulate: Record<string, ItemToRepopulate>\n): QuestionnaireResponseItem | QuestionnaireResponseItem[] | null {\n // For repeat groups\n const hasMultipleAnswers = Array.isArray(qrItemOrItems);\n if (hasMultipleAnswers) {\n return constructRepeatGroup(qItem, qrItemOrItems, checkedItemsToRepopulate);\n }\n\n const childQItems = qItem.item;\n if (childQItems && childQItems.length > 0) {\n const childQrItems = qrItemOrItems?.item ?? [];\n\n const indexMap = mapQItemsIndex(qItem);\n const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap);\n\n // For grid groups\n const itemIsGrid = isSpecificItemControl(qItem, 'grid');\n if (itemIsGrid) {\n return constructGridGroup(qItem, qrItemOrItems, checkedItemsToRepopulate);\n }\n\n // For normal groups with children\n const updatedQRItems: QuestionnaireResponseItem[] = [];\n for (const [index, childQItem] of childQItems.entries()) {\n const childQRItemOrItems = qrItemsByIndex[index];\n\n const updatedChildQRItemOrItems = repopulateItemRecursive(\n childQItem,\n childQRItemOrItems ?? null,\n checkedItemsToRepopulate\n );\n\n if (Array.isArray(updatedChildQRItemOrItems)) {\n if (updatedChildQRItemOrItems.length > 0) {\n updatedQRItems.push(...updatedChildQRItemOrItems);\n }\n continue;\n }\n\n if (updatedChildQRItemOrItems) {\n updatedQRItems.push(updatedChildQRItemOrItems);\n }\n }\n\n return constructGroupItem(qItem, qrItemOrItems, updatedQRItems, checkedItemsToRepopulate);\n }\n\n return constructSingleItem(qItem, qrItemOrItems, checkedItemsToRepopulate);\n}\n\nfunction constructGroupItem(\n qItem: QuestionnaireItem,\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null,\n childQrItems: QuestionnaireResponseItem[],\n checkedItemsToRepopulate: Record<string, ItemToRepopulate>\n): QuestionnaireResponseItem | null {\n // Handle group items\n if (qItem.type === 'group') {\n return childQrItems && childQrItems.length > 0\n ? {\n linkId: qItem.linkId,\n text: qItem.text,\n item: childQrItems\n }\n : null;\n }\n\n // qrItemOrItems not supposed to be an array at this point\n if (Array.isArray(qrItemOrItems)) {\n return null;\n }\n\n // If item is not of type group, its a single item with children\n const itemToRepopulate = checkedItemsToRepopulate[qItem.linkId];\n if (!itemToRepopulate) {\n if (qrItemOrItems) {\n return {\n linkId: qItem.linkId,\n text: qItem.text,\n answer: qrItemOrItems.answer\n };\n }\n return null;\n }\n\n if (!itemToRepopulate.newQRItem) {\n return null;\n }\n\n return {\n linkId: qItem.linkId,\n text: qItem.text,\n answer: itemToRepopulate.newQRItem.answer\n };\n}\n\nfunction constructSingleItem(\n qItem: QuestionnaireItem,\n qrItem: QuestionnaireResponseItem | null,\n checkedItemsToRepopulate: Record<string, ItemToRepopulate>\n): QuestionnaireResponseItem | null {\n const itemToRepopulate = checkedItemsToRepopulate[qItem.linkId];\n\n if (!itemToRepopulate) {\n return qrItem ?? null;\n }\n\n if (qrItem && itemToRepopulate.newQRItem) {\n return {\n ...qrItem,\n answer: itemToRepopulate.newQRItem.answer\n };\n }\n\n if (!itemToRepopulate.newQRItem) {\n return null;\n }\n\n return {\n linkId: qItem.linkId,\n text: qItem.text,\n answer: itemToRepopulate.newQRItem.answer\n };\n}\n\nfunction constructGridGroup(\n qItem: QuestionnaireItem,\n qrItem: QuestionnaireResponseItem | null,\n checkedItemsToRepopulate: Record<string, ItemToRepopulate>\n) {\n const itemToRepopulate = checkedItemsToRepopulate[qItem.linkId];\n\n if (!itemToRepopulate || !itemToRepopulate.newQRItem) {\n return qrItem;\n }\n\n const qrItemsToRepopulate = itemToRepopulate.newQRItem.item;\n\n if (!qrItemsToRepopulate) {\n return qrItem;\n }\n\n const oldQrItems = qrItem?.item;\n\n if (!oldQrItems) {\n return {\n linkId: qItem.linkId,\n text: qItem.text,\n item: qrItemsToRepopulate\n };\n }\n\n const qrItemsToRepopulateMap = qrItemsToRepopulate.reduce(\n (mapping: Record<string, QuestionnaireResponseItem>, item) => {\n mapping[item.linkId] = item;\n return mapping;\n },\n {}\n );\n\n const repopulatedQrItems = oldQrItems.map((oldQrItem) => {\n const qrItemToRepopulate = qrItemsToRepopulateMap[oldQrItem.linkId];\n\n if (!qrItemToRepopulate) {\n return oldQrItem;\n }\n\n return {\n ...oldQrItem,\n item: qrItemToRepopulate.item\n };\n });\n\n return { ...qrItem, item: repopulatedQrItems };\n}\n\nfunction constructRepeatGroup(\n qItem: QuestionnaireItem,\n qrItems: QuestionnaireResponseItem[],\n checkedItemsToRepopulate: Record<string, ItemToRepopulate>\n): QuestionnaireResponseItem[] {\n const itemToRepopulate = checkedItemsToRepopulate[qItem.linkId];\n\n if (!itemToRepopulate || !itemToRepopulate.newQRItems) {\n return qrItems;\n }\n\n return itemToRepopulate.newQRItems;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';\nimport useInitialiseForm from '../../hooks/useInitialiseForm';\nimport Box from '@mui/material/Box';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport Typography from '@mui/material/Typography';\n\nimport { QueryClientProvider } from '@tanstack/react-query';\nimport useRendererQueryClient from '../../hooks/useRendererQueryClient';\nimport BaseRenderer from './BaseRenderer';\nimport type Client from 'fhirclient/lib/Client';\nimport RendererThemeProvider from '../../theme/RendererThemeProvider';\n\n/**\n * SmartFormsRenderer properties\n *\n * @property questionnaire - Input FHIR R4 Questionnaire to be rendered\n * @property questionnaireResponse - Pre-populated QuestionnaireResponse to be rendered (optional)\n * @property additionalVariables - Additional key-value pair of SDC variables `Record<name, variable extension>` for testing (optional)\n * @property terminologyServerUrl - Terminology server url to fetch terminology. If not provided, the default terminology server will be used. (optional)\n * @property fhirClient - FHIRClient object to perform further FHIR calls. At the moment it's only used in answerExpressions (optional)\n * @property readOnly - Applies read-only mode to all items in the form\n *\n * @author Sean Fong\n */\nexport interface SmartFormsRendererProps {\n questionnaire: Questionnaire;\n questionnaireResponse?: QuestionnaireResponse;\n additionalVariables?: Record<string, object>;\n terminologyServerUrl?: string;\n fhirClient?: Client;\n readOnly?: boolean;\n}\n\n/**\n * A self-initialising wrapper around the BaseRenderer rendering engine.\n * Will be deprecated in version 1.0.0. For alternative usage, see:\n * - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/InitialiseFormWrapperForStorybook.tsx#L40-L57\n *\n * @see SmartFormsRendererProps for props.\n *\n * @author Sean Fong\n */\nfunction SmartFormsRenderer(props: SmartFormsRendererProps) {\n const {\n questionnaire,\n questionnaireResponse,\n additionalVariables,\n terminologyServerUrl,\n fhirClient,\n readOnly\n } = props;\n\n const isLoading = useInitialiseForm(\n questionnaire,\n questionnaireResponse,\n readOnly,\n terminologyServerUrl,\n additionalVariables,\n fhirClient\n );\n const queryClient = useRendererQueryClient();\n\n if (isLoading) {\n return (\n <Box display=\"flex\" alignItems=\"center\" columnGap={2}>\n <CircularProgress />\n <Typography>Loading questionnaire...</Typography>\n </Box>\n );\n }\n\n return (\n <RendererThemeProvider>\n <QueryClientProvider client={queryClient}>\n <BaseRenderer />\n </QueryClientProvider>\n </RendererThemeProvider>\n );\n}\n\nexport default SmartFormsRenderer;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { QueryClient } from '@tanstack/react-query';\n\n/**\n * Default QueryClient used by the renderer.\n * You can customise your own QueryClient with your own options, use v4 of @tanstack/react-query.\n * @see {@link https://tanstack.com/query/v4/docs/reference/QueryClient}\n *\n * @author Sean Fong\n */\nfunction useRendererQueryClient() {\n return new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false\n }\n }\n });\n}\n\nexport default useRendererQueryClient;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport Fade from '@mui/material/Fade';\nimport FormTopLevelItem from './FormTopLevelItem';\nimport type { QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';\nimport { useQuestionnaireResponseStore, useQuestionnaireStore } from '../../stores';\nimport { getQrItemsIndex, mapQItemsIndex } from '../../utils/mapItem';\nimport { updateQrItemsInGroup } from '../../utils/qrItem';\nimport { isPaginatedForm } from '../../utils/page';\nimport type { QrRepeatGroup } from '../../interfaces/repeatGroup.interface';\nimport FormBodyPaginated from './FormBodyPaginated';\nimport { Container } from '@mui/material';\nimport { applyComputedUpdates } from '../../utils/computedUpdates';\n\n/**\n * Main component of the form-rendering engine.\n * Renders the Questionnaire and QuestionnaireResponse defined in the state management stores QuestionnaireStore and QuestionnaireResponseStore respectively.\n * Use buildForm() in your wrapping component or in an event handler to initialise the form.\n *\n * @author Sean Fong\n */\nfunction BaseRenderer() {\n const sourceQuestionnaire = useQuestionnaireStore.use.sourceQuestionnaire();\n const updateExpressions = useQuestionnaireStore.use.updateExpressions();\n const readOnly = useQuestionnaireStore.use.readOnly();\n\n const responseKey = useQuestionnaireResponseStore.use.key();\n const updatableResponse = useQuestionnaireResponseStore.use.updatableResponse();\n const updateResponse = useQuestionnaireResponseStore.use.updateResponse();\n\n const qItemsIndexMap = useMemo(() => mapQItemsIndex(sourceQuestionnaire), [sourceQuestionnaire]);\n\n function updateFormState(updatedResponse: QuestionnaireResponse) {\n // Perform first pass QR update to immediately update UI answers\n updateResponse(updatedResponse);\n\n updateExpressions(updatedResponse).then((computedQRItemUpdates) => {\n // Async update for changed values: clear answers for dynamic valueSets and calculated expressions (in the future)\n const appliedComputedUpdatesResponse = applyComputedUpdates(\n sourceQuestionnaire,\n updatedResponse,\n computedQRItemUpdates\n );\n updateResponse(appliedComputedUpdatesResponse);\n });\n }\n\n function handleTopLevelQRItemSingleChange(newTopLevelQRItem: QuestionnaireResponseItem) {\n const updatedResponse: QuestionnaireResponse = structuredClone(updatableResponse);\n\n updateQrItemsInGroup(newTopLevelQRItem, null, updatedResponse, qItemsIndexMap);\n\n updateFormState(updatedResponse);\n }\n\n function handleTopLevelQRItemMultipleChange(newTopLevelQRItems: QrRepeatGroup) {\n const updatedResponse: QuestionnaireResponse = structuredClone(updatableResponse);\n\n updateQrItemsInGroup(null, newTopLevelQRItems, updatedResponse, qItemsIndexMap);\n\n updateFormState(updatedResponse);\n }\n\n const topLevelQItems = sourceQuestionnaire.item;\n const topLevelQRItems = structuredClone(updatableResponse.item) ?? [];\n\n if (!topLevelQItems) {\n return <>Questionnaire does not have any items</>;\n }\n\n // If an item has multiple answers, it is a repeat group\n const topLevelQRItemsByIndex = getQrItemsIndex(topLevelQItems, topLevelQRItems, qItemsIndexMap);\n\n const wholeFormIsPaginated = isPaginatedForm(topLevelQItems);\n if (wholeFormIsPaginated) {\n return (\n <Fade in={true} timeout={500}>\n <Container disableGutters maxWidth=\"xl\" key={responseKey}>\n <FormBodyPaginated\n topLevelQItems={topLevelQItems}\n topLevelQRItems={topLevelQRItemsByIndex}\n parentIsReadOnly={readOnly}\n onQrItemChange={(newTopLevelQRItem) =>\n handleTopLevelQRItemSingleChange(newTopLevelQRItem)\n }\n />\n </Container>\n </Fade>\n );\n }\n\n return (\n <Fade in={true} timeout={500}>\n <Container disableGutters maxWidth=\"xl\" key={responseKey}>\n {topLevelQItems.map((qItem, index) => {\n const qrItemOrItems = topLevelQRItemsByIndex[index];\n\n return (\n <FormTopLevelItem\n key={qItem.linkId}\n topLevelQItem={qItem}\n topLevelQRItemOrItems={qrItemOrItems ?? null}\n parentIsReadOnly={readOnly}\n wholeFormIsPaginated={wholeFormIsPaginated}\n onQrItemChange={(newTopLevelQRItem) =>\n handleTopLevelQRItemSingleChange(newTopLevelQRItem)\n }\n onQrRepeatGroupChange={(newTopLevelQRItems) =>\n handleTopLevelQRItemMultipleChange(newTopLevelQRItems)\n }\n />\n );\n })}\n </Container>\n </Fade>\n );\n}\n\nexport default BaseRenderer;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport { Grid } from '@mui/material';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport TabContext from '@mui/lab/TabContext';\nimport TabPanel from '@mui/lab/TabPanel';\nimport { getQrItemsIndex, mapQItemsIndex } from '../../utils/mapItem';\nimport GroupItem from '../FormComponents/GroupItem/GroupItem';\nimport { createEmptyQrGroup, updateQrItemsInGroup } from '../../utils/qrItem';\nimport FormBodyTabListWrapper from '../Tabs/FormBodyTabListWrapper';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler\n} from '../../interfaces/renderProps.interface';\nimport { useQuestionnaireStore, useRendererStylingStore } from '../../stores';\nimport { GridProps } from '@mui/material/Grid';\n\ninterface FormBodyTabbedProps\n extends PropsWithQrItemChangeHandler,\n PropsWithParentIsReadOnlyAttribute {\n topLevelQItem: QuestionnaireItem;\n topLevelQRItem: QuestionnaireResponseItem | null;\n}\n\nfunction FormBodyTabbed(props: FormBodyTabbedProps) {\n const { topLevelQItem, topLevelQRItem, parentIsReadOnly, onQrItemChange } = props;\n\n const tabs = useQuestionnaireStore.use.tabs();\n const currentTab = useQuestionnaireStore.use.currentTabIndex();\n\n const tabListWidthOrResponsive = useRendererStylingStore.use.tabListWidthOrResponsive();\n\n const indexMap: Record<string, number> = useMemo(\n () => mapQItemsIndex(topLevelQItem),\n [topLevelQItem]\n );\n\n const nonNullTopLevelQRItem = topLevelQRItem ?? createEmptyQrGroup(topLevelQItem);\n\n const qItems = topLevelQItem.item;\n const qrItems = nonNullTopLevelQRItem.item;\n\n function handleQrGroupChange(qrItem: QuestionnaireResponseItem) {\n updateQrItemsInGroup(qrItem, null, nonNullTopLevelQRItem, indexMap);\n onQrItemChange(nonNullTopLevelQRItem);\n }\n\n if (!qItems || !qrItems) {\n return <>Unable to load form</>;\n }\n\n const qrItemsByIndex = getQrItemsIndex(qItems, qrItems, indexMap);\n\n // If tabListWidthOrBreakpoints is a number, it is a fixed width of the tab list - set a fixed width and prevent shrinking\n // If tabListWidthOrBreakpoints is an object, it is a MUI Breakpoints object\n const tabListWrapperProps: GridProps =\n typeof tabListWidthOrResponsive === 'number'\n ? { sx: { width: tabListWidthOrResponsive, flexShrink: 0 } }\n : { size: { ...tabListWidthOrResponsive.tabListBreakpoints } };\n\n const qItemTabPanelProps: GridProps =\n typeof tabListWidthOrResponsive === 'number'\n ? { sx: { flexGrow: 1 } }\n : { size: { ...tabListWidthOrResponsive.tabContentBreakpoints } };\n\n return (\n <Grid container spacing={1.5} sx={{ flexWrap: 'nowrap' }}>\n <TabContext value={currentTab.toString()}>\n <Grid {...tabListWrapperProps}>\n <FormBodyTabListWrapper topLevelItems={qItems} currentTabIndex={currentTab} tabs={tabs} />\n </Grid>\n\n <Grid {...qItemTabPanelProps}>\n {qItems.map((qItem, i) => {\n const qrItem = qrItemsByIndex[i];\n\n const isNotRepeatGroup = !Array.isArray(qrItem);\n const isTab = !!tabs[qItem.linkId];\n\n if (!isTab || !isNotRepeatGroup) {\n // Something has gone horribly wrong\n return null;\n }\n\n const isRepeated = qItem.repeats ?? false;\n const tabIsMarkedAsComplete = tabs[qItem.linkId].isComplete ?? false;\n\n return (\n <TabPanel\n key={qItem.linkId}\n sx={{ p: 0 }}\n value={i.toString()}\n id={`tabpanel-${i}`}\n data-test=\"renderer-tab-panel\">\n <GroupItem\n qItem={qItem}\n qrItem={qrItem ?? null}\n isRepeated={isRepeated}\n groupCardElevation={1}\n tabIsMarkedAsComplete={tabIsMarkedAsComplete}\n tabs={tabs}\n currentTabIndex={currentTab}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={handleQrGroupChange}\n />\n </TabPanel>\n );\n })}\n </Grid>\n </TabContext>\n </Grid>\n );\n}\n\nexport default FormBodyTabbed;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport { getQrItemsIndex, mapQItemsIndex } from '../../../utils/mapItem';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrGroup, updateQrItemsInGroup } from '../../../utils/qrItem';\nimport type {\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute,\n PropsWithQrItemChangeHandler\n} from '../../../interfaces/renderProps.interface';\nimport type { QrRepeatGroup } from '../../../interfaces/repeatGroup.interface';\nimport useHidden from '../../../hooks/useHidden';\nimport type { Tabs } from '../../../interfaces/tab.interface';\nimport type { Pages } from '../../../interfaces/page.interface';\nimport GroupItemView from './GroupItemView';\nimport { QGroupContainerBox } from '../../Box.styles';\nimport { GroupCard } from './GroupItem.styles';\nimport PageButtonsWrapper from './PageButtonWrapper';\n\ninterface GroupItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n groupCardElevation: number;\n disableCardView?: boolean;\n tabIsMarkedAsComplete?: boolean;\n tabs?: Tabs;\n currentTabIndex?: number;\n pageIsMarkedAsComplete?: boolean;\n pages?: Pages;\n currentPageIndex?: number;\n parentStyles?: Record<string, string>;\n}\n\nfunction GroupItem(props: GroupItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n groupCardElevation,\n disableCardView,\n tabIsMarkedAsComplete,\n tabs,\n currentTabIndex,\n pageIsMarkedAsComplete,\n pages,\n currentPageIndex,\n parentIsReadOnly,\n parentIsRepeatGroup,\n parentRepeatGroupIndex,\n onQrItemChange,\n parentStyles\n } = props;\n\n const qItemsIndexMap = useMemo(() => mapQItemsIndex(qItem), [qItem]);\n\n const itemIsHidden = useHidden(qItem, parentRepeatGroupIndex);\n if (itemIsHidden) {\n return null;\n }\n\n const qItems = qItem.item;\n const qrGroup = qrItem && qrItem.item ? qrItem : createEmptyQrGroup(qItem);\n const qrItems = qrGroup.item;\n\n // Event Handlers\n function handleQrItemChange(newQrItem: QuestionnaireResponseItem) {\n const updatedQrGroup: QuestionnaireResponseItem = { ...qrGroup };\n updateQrItemsInGroup(newQrItem, null, updatedQrGroup, qItemsIndexMap);\n onQrItemChange(updatedQrGroup);\n }\n\n function handleQrRepeatGroupChange(qrRepeatGroup: QrRepeatGroup) {\n const updatedQrGroup: QuestionnaireResponseItem = { ...qrGroup };\n updateQrItemsInGroup(null, qrRepeatGroup, updatedQrGroup, qItemsIndexMap);\n onQrItemChange(updatedQrGroup);\n }\n\n if (!qItems || !qrItems) {\n // If there are pages passed through, render this invalid group as a card to at least allow the user to see the error\n if (pages) {\n return (\n <QGroupContainerBox cardElevation={groupCardElevation} isRepeated={isRepeated}>\n <GroupCard elevation={groupCardElevation} isRepeated={isRepeated}>\n <>\n Group Item: Unable to load group, something has gone terribly wrong. If you are seeing\n this error message, see{' '}\n <a\n href=\"https://hl7.org/fhir/extensions/CodeSystem-questionnaire-item-control.html#questionnaire-item-control-page\"\n target=\"_blank\"\n rel=\"noreferrer\">\n https://hl7.org/fhir/extensions/CodeSystem-questionnaire-item-control.html#questionnaire-item-control-page\n </a>{' '}\n for a standards-based way to use pages.\n </>\n </GroupCard>\n <PageButtonsWrapper currentPageIndex={currentPageIndex} pages={pages} />\n </QGroupContainerBox>\n );\n }\n\n // Otherwise, render the regular error message\n return <>Group Item: Unable to load group, something has gone terribly wrong.</>;\n }\n\n // If an item has multiple answers, it is a repeat group\n const qrItemsByIndex = getQrItemsIndex(qItems, qrItems, qItemsIndexMap);\n\n return (\n <GroupItemView\n qItem={qItem}\n childQItems={qItems}\n qrItemsByIndex={qrItemsByIndex}\n isRepeated={isRepeated}\n groupCardElevation={groupCardElevation}\n disableCardView={disableCardView}\n tabIsMarkedAsComplete={tabIsMarkedAsComplete}\n tabs={tabs}\n currentTabIndex={currentTabIndex}\n pageIsMarkedAsComplete={pageIsMarkedAsComplete}\n pages={pages}\n currentPageIndex={currentPageIndex}\n parentIsReadOnly={parentIsReadOnly}\n parentIsRepeatGroup={parentIsRepeatGroup}\n parentRepeatGroupIndex={parentRepeatGroupIndex}\n onQrItemChange={handleQrItemChange}\n onQrRepeatGroupChange={handleQrRepeatGroupChange}\n parentStyles={parentStyles}\n />\n );\n}\n\nexport default GroupItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport { useQuestionnaireStore } from '../stores';\nimport { isHiddenByEnableWhen } from '../utils/qItem';\nimport { structuredDataCapture } from 'fhir-sdc-helpers';\nimport { useRendererStylingStore } from '../stores/rendererStylingStore';\n\n/**\n * React hook to determine if a QuestionnaireItem is hidden via item.hidden, enableWhens, enableWhenExpressions.\n * When checking for repeating group enableWhen items, the parentRepeatGroupIndex should be provided.\n *\n * @author Sean Fong\n */\nfunction useHidden(qItem: QuestionnaireItem, parentRepeatGroupIndex?: number): boolean {\n const enableWhenIsActivated = useQuestionnaireStore.use.enableWhenIsActivated();\n const enableWhenItems = useQuestionnaireStore.use.enableWhenItems();\n const enableWhenExpressions = useQuestionnaireStore.use.enableWhenExpressions();\n\n const enableWhenAsReadOnly = useRendererStylingStore.use.enableWhenAsReadOnly();\n\n if (structuredDataCapture.getHidden(qItem)) {\n return true;\n }\n\n // If enableWhenAsReadOnly is true, then items hidden by enableWhen should be displayed, but set as readOnly\n // If enableWhenAsReadOnly is a Set, all item types in the set should be displayed, but set as readOnly\n if (\n enableWhenAsReadOnly === true ||\n (enableWhenAsReadOnly instanceof Set && enableWhenAsReadOnly.has(qItem.type))\n ) {\n return false;\n }\n\n return isHiddenByEnableWhen({\n linkId: qItem.linkId,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions,\n parentRepeatGroupIndex\n });\n}\n\nexport default useHidden;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { QGroupContainerBox } from '../../Box.styles';\nimport type {\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithQrRepeatGroupChangeHandler\n} from '../../../interfaces/renderProps.interface';\nimport type { Tabs } from '../../../interfaces/tab.interface';\nimport type { Pages } from '../../../interfaces/page.interface';\nimport GroupHeading from './GroupHeading';\nimport { GroupCard } from './GroupItem.styles';\nimport TabButtonsWrapper from './TabButtonsWrapper';\nimport GroupItemSwitcher from './GroupItemSwitcher';\nimport AccordionSummary from '@mui/material/AccordionSummary';\nimport ExpandMoreIcon from '@mui/icons-material/ExpandMore';\nimport AccordionDetails from '@mui/material/AccordionDetails';\nimport Divider from '@mui/material/Divider';\nimport { getGroupCollapsible } from '../../../utils/qItem';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { GroupAccordion } from './GroupAccordion.styles';\nimport PageButtonsWrapper from './PageButtonWrapper';\nimport { useParseXhtml } from '../../../hooks/useParseXhtml';\n\ninterface GroupItemViewProps\n extends PropsWithQrItemChangeHandler,\n PropsWithQrRepeatGroupChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute {\n qItem: QuestionnaireItem;\n childQItems: QuestionnaireItem[];\n qrItemsByIndex: (QuestionnaireResponseItem | QuestionnaireResponseItem[] | undefined)[];\n groupCardElevation: number;\n disableCardView?: boolean;\n tabIsMarkedAsComplete?: boolean;\n tabs?: Tabs;\n currentTabIndex?: number;\n pageIsMarkedAsComplete?: boolean;\n pages?: Pages;\n currentPageIndex?: number;\n parentStyles?: Record<string, string>;\n}\n\nfunction GroupItemView(props: GroupItemViewProps) {\n const {\n qItem,\n childQItems,\n qrItemsByIndex,\n isRepeated = false,\n groupCardElevation,\n disableCardView,\n tabIsMarkedAsComplete,\n tabs,\n currentTabIndex,\n pageIsMarkedAsComplete,\n pages,\n currentPageIndex,\n parentIsReadOnly,\n parentIsRepeatGroup,\n parentRepeatGroupIndex,\n onQrItemChange,\n onQrRepeatGroupChange,\n parentStyles\n } = props;\n\n // If XHTML has styles, pass them to the GroupItemView so it cna be applied down the tree\n const xhtmlStyles = useParseXhtml(qItem)?.styles;\n\n // Combine parent styles with this group's styles\n const combinedStyles = React.useMemo(() => {\n if (!parentStyles && !xhtmlStyles) return undefined;\n if (parentStyles && !xhtmlStyles) return parentStyles;\n if (!parentStyles && xhtmlStyles) return xhtmlStyles;\n\n // Merge parent styles with extracted styles (extracted styles take precedence)\n return { ...parentStyles, ...xhtmlStyles };\n }, [parentStyles, xhtmlStyles]);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly, parentRepeatGroupIndex);\n\n // Render collapsible group item\n // If group item is a repeating instance, do not render group item as collapsible\n const groupCollapsibleValue = getGroupCollapsible(qItem);\n if (groupCollapsibleValue && !isRepeated) {\n const isDefaultOpen = groupCollapsibleValue === 'default-open';\n return (\n <GroupAccordion\n disableGutters\n defaultExpanded={isDefaultOpen}\n elevation={groupCardElevation}\n slotProps={{\n transition: { unmountOnExit: true, timeout: 250 }\n }}\n style={combinedStyles || undefined}>\n <AccordionSummary expandIcon={<ExpandMoreIcon />} sx={{ minHeight: '28px' }}>\n <GroupHeading\n qItem={qItem}\n readOnly={readOnly}\n groupCardElevation={groupCardElevation}\n tabIsMarkedAsComplete={tabIsMarkedAsComplete}\n pageIsMarkedAsComplete={pageIsMarkedAsComplete}\n parentStyles={combinedStyles}\n />\n </AccordionSummary>\n <AccordionDetails sx={{ pt: 0 }}>\n {qItem.text ? <Divider sx={{ mb: 1.5, opacity: 0.6 }} /> : null}\n <>\n {childQItems.map((qItem: QuestionnaireItem, i) => {\n const qrItemOrItems = qrItemsByIndex[i];\n\n return (\n <GroupItemSwitcher\n key={qItem.linkId}\n qItem={qItem}\n qrItemOrItems={qrItemOrItems}\n groupCardElevation={groupCardElevation + 1}\n parentIsReadOnly={readOnly}\n parentIsRepeatGroup={parentIsRepeatGroup}\n parentRepeatGroupIndex={parentRepeatGroupIndex}\n onQrItemChange={onQrItemChange}\n onQrRepeatGroupChange={onQrRepeatGroupChange}\n parentStyles={combinedStyles}\n />\n );\n })}\n\n {/* Next tab button at the end of each tab group */}\n <TabButtonsWrapper currentTabIndex={currentTabIndex} tabs={tabs} />\n <PageButtonsWrapper currentPageIndex={currentPageIndex} pages={pages} />\n </>\n </AccordionDetails>\n </GroupAccordion>\n );\n }\n\n // Disable card view - currently only available via disablePageCardView API\n if (disableCardView) {\n return (\n <QGroupContainerBox\n cardElevation={groupCardElevation}\n isRepeated={isRepeated}\n data-test=\"q-item-group-box\"\n style={combinedStyles || undefined}>\n {isRepeated ? null : (\n <>\n <GroupHeading\n qItem={qItem}\n readOnly={readOnly}\n tabIsMarkedAsComplete={tabIsMarkedAsComplete}\n pageIsMarkedAsComplete={pageIsMarkedAsComplete}\n groupCardElevation={groupCardElevation}\n parentStyles={combinedStyles}\n />\n {qItem.text ? <Divider sx={{ mt: 1, mb: 1.5, opacity: 0.6 }} /> : null}\n </>\n )}\n {childQItems.map((qItem: QuestionnaireItem, i) => {\n const qrItemOrItems = qrItemsByIndex[i];\n\n return (\n <GroupItemSwitcher\n key={qItem.linkId}\n qItem={qItem}\n qrItemOrItems={qrItemOrItems}\n groupCardElevation={groupCardElevation + 1}\n parentIsReadOnly={readOnly}\n parentIsRepeatGroup={parentIsRepeatGroup}\n parentRepeatGroupIndex={parentRepeatGroupIndex}\n onQrItemChange={onQrItemChange}\n onQrRepeatGroupChange={onQrRepeatGroupChange}\n parentStyles={combinedStyles}\n />\n );\n })}\n {/* Next tab button at the end of each tab group */}\n <TabButtonsWrapper currentTabIndex={currentTabIndex} tabs={tabs} />\n <PageButtonsWrapper currentPageIndex={currentPageIndex} pages={pages} />\n </QGroupContainerBox>\n );\n }\n\n return (\n <QGroupContainerBox\n cardElevation={groupCardElevation}\n isRepeated={isRepeated}\n data-test=\"q-item-group-box\">\n <GroupCard\n elevation={groupCardElevation}\n isRepeated={isRepeated}\n style={combinedStyles || undefined}>\n {isRepeated ? null : (\n <>\n <GroupHeading\n qItem={qItem}\n readOnly={readOnly}\n tabIsMarkedAsComplete={tabIsMarkedAsComplete}\n pageIsMarkedAsComplete={pageIsMarkedAsComplete}\n groupCardElevation={groupCardElevation}\n parentStyles={combinedStyles}\n />\n {qItem.text ? <Divider sx={{ mt: 1, mb: 1.5, opacity: 0.6 }} /> : null}\n </>\n )}\n {childQItems.map((qItem: QuestionnaireItem, i) => {\n const qrItemOrItems = qrItemsByIndex[i];\n\n return (\n <GroupItemSwitcher\n key={qItem.linkId}\n qItem={qItem}\n qrItemOrItems={qrItemOrItems}\n groupCardElevation={groupCardElevation + 1}\n parentIsReadOnly={readOnly}\n parentIsRepeatGroup={parentIsRepeatGroup}\n parentRepeatGroupIndex={parentRepeatGroupIndex}\n onQrItemChange={onQrItemChange}\n onQrRepeatGroupChange={onQrRepeatGroupChange}\n parentStyles={combinedStyles}\n />\n );\n })}\n\n {/* Next tab button at the end of each tab group */}\n <TabButtonsWrapper currentTabIndex={currentTabIndex} tabs={tabs} />\n <PageButtonsWrapper currentPageIndex={currentPageIndex} pages={pages} />\n </GroupCard>\n </QGroupContainerBox>\n );\n}\n\nexport default GroupItemView;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Box from '@mui/material/Box';\nimport { styled } from '@mui/material/styles';\nimport FormControlLabel from '@mui/material/FormControlLabel';\n\nexport const QGroupContainerBox = styled(Box, {\n shouldForwardProp: (prop) => prop !== 'cardElevation' && prop !== 'isRepeated'\n})<{ cardElevation: number; isRepeated: boolean }>(({ cardElevation, isRepeated }) => ({\n marginTop: cardElevation === 1 || isRepeated ? 0 : 18,\n marginBottom: cardElevation === 1 || isRepeated ? 0 : 18\n}));\n\nexport const FullWidthFormComponentBox = styled(Box)(() => ({\n marginBottom: 10\n}));\n\nexport const FormTitleWrapper = styled(Box)(() => ({\n marginTop: 12\n}));\n\nexport const StyledFormControlLabel = styled(FormControlLabel)(() => ({\n height: 34\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { memo } from 'react';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport { getContextDisplays } from '../../../utils/tabs';\nimport ContextDisplayItem from '../ItemParts/ContextDisplayItem';\nimport useRenderingExtensions from '../../../hooks/useRenderingExtensions';\nimport { useRendererStylingStore } from '../../../stores';\nimport RequiredAsterisk from '../ItemParts/RequiredAsterisk';\nimport ItemTextSwitcher from '../ItemParts/ItemTextSwitcher';\nimport FlyoverItem from '../ItemParts/FlyoverItem';\nimport { getHeadingTag } from '../../../utils/headingVariant';\n\ninterface GroupHeadingProps {\n qItem: QuestionnaireItem;\n readOnly: boolean;\n groupCardElevation: number;\n tabIsMarkedAsComplete?: boolean;\n pageIsMarkedAsComplete?: boolean;\n onStylesExtracted?: (styles: Record<string, any>) => void;\n parentStyles?: Record<string, string>;\n}\n\nconst GroupHeading = memo(function GroupHeading(props: GroupHeadingProps) {\n const {\n qItem,\n readOnly,\n groupCardElevation,\n tabIsMarkedAsComplete,\n pageIsMarkedAsComplete,\n onStylesExtracted,\n parentStyles\n } = props;\n\n const requiredIndicatorPosition = useRendererStylingStore.use.requiredIndicatorPosition();\n\n const { required, displayFlyover } = useRenderingExtensions(qItem);\n const contextDisplayItems = getContextDisplays(qItem);\n\n const isTabHeading = tabIsMarkedAsComplete !== undefined;\n const isPageHeading = pageIsMarkedAsComplete !== undefined;\n\n // Get text color from parent styles if available\n const textColor =\n parentStyles?.color ||\n (readOnly && (!isTabHeading || !isPageHeading) ? 'text.secondary' : 'text.primary');\n\n return (\n <>\n <Box display=\"flex\" alignItems=\"center\" width=\"100%\">\n <Box position=\"relative\" display=\"flex\" flexGrow={1} alignItems=\"center\">\n {/* Required asterisk position is in front of text */}\n {required && requiredIndicatorPosition === 'start' ? (\n <RequiredAsterisk\n sx={{ position: 'absolute', top: 0, left: -8 }} // Adjust top and left values as needed\n >\n *\n </RequiredAsterisk>\n ) : null}\n\n {/* Group Heading typography */}\n {/* flexGrow: 1 is important if xhtml and markdown rendering has width: 100% */}\n <Typography\n component={getHeadingTag(groupCardElevation)}\n variant=\"groupHeading\"\n color={textColor}\n display=\"flex\"\n alignItems=\"center\"\n sx={{ flexGrow: 1, ...(parentStyles || {}) }}>\n <ItemTextSwitcher qItem={qItem} onStylesExtracted={onStylesExtracted} />\n\n {/* Required asterisk position is behind text */}\n {required && requiredIndicatorPosition === 'end' ? (\n <RequiredAsterisk readOnly={readOnly} variant=\"groupHeading\">\n *\n </RequiredAsterisk>\n ) : null}\n {/* Flyover */}\n {displayFlyover !== '' ? (\n <Typography component=\"span\" sx={{ ml: 0.75 }}>\n <FlyoverItem displayFlyover={displayFlyover} readOnly={readOnly} />\n </Typography>\n ) : null}\n </Typography>\n </Box>\n\n <Box display=\"flex\" columnGap={0.5}>\n {contextDisplayItems.map((item) => {\n return <ContextDisplayItem key={item.linkId} displayItem={item} />;\n })}\n </Box>\n </Box>\n </>\n );\n});\n\nexport default GroupHeading;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { memo } from 'react';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport useHidden from '../../../hooks/useHidden';\nimport ItemTextSwitcher from './ItemTextSwitcher';\n\ninterface GroupHeadingIconProps {\n displayItem: QuestionnaireItem;\n}\n\nconst ContextDisplayItem = memo(function GroupHeadingIcon(props: GroupHeadingIconProps) {\n const { displayItem } = props;\n\n const itemIsHidden = useHidden(displayItem);\n if (itemIsHidden) {\n return null;\n }\n\n return <ItemTextSwitcher qItem={displayItem} />;\n});\n\nexport default ContextDisplayItem;\n","import React, { memo } from 'react';\nimport ReactMarkdown from 'react-markdown';\nimport { getMarkdownString } from '../../../utils/itemControl';\nimport { structuredDataCapture } from 'fhir-sdc-helpers';\nimport { default as parseStyleToJs } from 'style-to-js';\nimport { useParseXhtml } from '../../../hooks/useParseXhtml';\nimport useDisplayCqfAndCalculatedExpression from '../../../hooks/useDisplayCqfAndCalculatedExpression';\nimport type { QuestionnaireItem } from 'fhir/r4';\n\ninterface ItemTextSwitcherProps {\n qItem: QuestionnaireItem;\n onStylesExtracted?: (styles: Record<string, any>) => void;\n}\n\nconst ItemTextSwitcher = memo(function ItemTextSwitcher({\n qItem,\n onStylesExtracted\n}: ItemTextSwitcherProps) {\n let itemText = qItem.text ?? '';\n\n // Use calculatedExpressionString if available\n const calculatedExpressionString = useDisplayCqfAndCalculatedExpression(qItem) ?? '';\n if (calculatedExpressionString) {\n itemText = calculatedExpressionString;\n }\n\n // parse XHTML if found\n const parsedXhtml = useParseXhtml(qItem);\n if (parsedXhtml) {\n // If we have styles and a callback, pass the styles to the parent\n if (parsedXhtml.styles && onStylesExtracted) {\n onStylesExtracted(parsedXhtml.styles);\n }\n\n return <span>{parsedXhtml.content}</span>;\n }\n\n // parse markdown if found\n const markdownString = getMarkdownString(qItem);\n if (markdownString) {\n return (\n <span>\n <ReactMarkdown>{markdownString}</ReactMarkdown>\n </span>\n );\n }\n\n // labelText is empty, return null\n if (!itemText) {\n return null;\n }\n\n // parse styles if found\n const stylesString = structuredDataCapture.getStyle(qItem._text);\n if (stylesString) {\n const styles = parseStyleToJs(stylesString);\n return <span style={styles}>{itemText}</span>;\n }\n\n // parse regular text\n return <span>{itemText}</span>;\n});\n\nexport default ItemTextSwitcher;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport { getXHtmlString } from '../utils/itemControl';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport type { HTMLReactParserOptions } from 'html-react-parser';\nimport { attributesToProps, default as htmlParse, domToReact } from 'html-react-parser';\nimport type { Attributes } from 'html-react-parser/lib/attributes-to-props';\n\nexport interface ParsedXhtml {\n content: React.ReactNode;\n styles?: Record<string, string>;\n}\n\nexport function useParseXhtml(qItem: QuestionnaireItem): ParsedXhtml | null {\n return useMemo(() => {\n const xHtmlString = getXHtmlString(qItem);\n\n if (xHtmlString === null || xHtmlString === '') {\n return null;\n }\n\n // Extract global styles from the XHTML\n let extractedStyles: Record<string, string> | undefined;\n\n const htmlParseOptions = {\n // Limited to work with document.getElementById manipulation only\n replace: (domNode: { attribs: Attributes; name: string; children: any[]; type?: string }) => {\n if (!domNode.attribs) return;\n\n // Extract CSS styles from style tags\n if (domNode.name === 'style' && domNode.children && domNode.children.length > 0) {\n const styleContent = domNode.children[0].data;\n if (styleContent) {\n // We don't return anything for style tags as they will be applied globally\n return <></>;\n }\n }\n\n // Extract external CSS styles from class attributes\n // To use this, define your stylesheet where you are calling <BaseRenderer/> in your app\n if (domNode.name === 'div' && domNode.attribs.class) {\n const classNames = domNode.attribs.class.split(/\\s+/);\n classNames.forEach((className) => {\n const classStyles = getStylesFromClass(className);\n if (classStyles) {\n extractedStyles = { ...extractedStyles, ...classStyles };\n }\n });\n }\n\n // Extract styles from the root div for group-level styling\n if (\n domNode.name === 'div' &&\n !domNode.attribs.class &&\n Object.keys(domNode.attribs).length > 0\n ) {\n if (domNode.attribs.style) {\n try {\n // Convert style string to object\n const styleObj: Record<string, string> = {};\n const styleStr = domNode.attribs.style;\n styleStr.split(';').forEach((style) => {\n if (style.trim()) {\n const [property, value] = style.split(':');\n if (property && value) {\n // Convert kebab-case to camelCase for React\n const propName = convertKebabToCamelCase(property);\n styleObj[propName] = value.trim();\n }\n }\n });\n\n // Store styles to be applied to parent container\n extractedStyles = styleObj;\n } catch (error) {\n console.error('Error parsing style', error);\n }\n }\n }\n\n if (domNode.attribs) {\n if (domNode.name === 'button') {\n // Extract the onclick attribute\n const { onclick } = domNode.attribs;\n\n let clickHandler;\n if (onclick) {\n clickHandler = () => {\n try {\n // Check if it starts with 'document.getElementById' and safely execute it\n if (onclick.trim().startsWith('document.getElementById')) {\n const fn = new Function(onclick);\n fn();\n } else {\n console.warn('Unhandled onclick:', onclick);\n }\n } catch (error) {\n console.error('Error executing onclick:', error);\n }\n };\n }\n delete domNode.attribs.onclick;\n\n return (\n <button\n {...attributesToProps(domNode.attribs)}\n onClick={clickHandler || (() => console.log('No specific handler defined'))}>\n {domToReact(domNode.children, htmlParseOptions as HTMLReactParserOptions)}\n </button>\n );\n }\n }\n }\n };\n\n const parsedContent = htmlParse(xHtmlString, htmlParseOptions as HTMLReactParserOptions);\n\n return {\n content: parsedContent,\n styles: extractedStyles\n };\n }, [qItem]);\n}\n\nfunction getStylesFromClass(className: string): Record<string, string> | null {\n if (!className) {\n return null;\n }\n\n const selector = className.startsWith('.') ? className : `.${className}`;\n\n for (const sheet of document.styleSheets) {\n // Skip stylesheets that are not on the same origin, as they may cause CORS issues - we also don't want to show warnings every time the user performs an action in the form\n if (sheet.href) {\n const sheetURL = new URL(sheet.href);\n if (sheetURL.hostname !== location.hostname) {\n continue;\n }\n }\n\n try {\n const rules = sheet.cssRules;\n for (const rule of rules) {\n if (rule instanceof CSSStyleRule && rule.selectorText === selector) {\n const computedStyles: Record<string, string> = {};\n const style = rule.style;\n\n for (let i = 0; i < style.length; i++) {\n const property = style[i];\n\n // Convert propertyName from kebab-case to camelCase for React\n const propNameCamelCase = convertKebabToCamelCase(property);\n\n computedStyles[propNameCamelCase] = style.getPropertyValue(property);\n }\n\n return computedStyles;\n }\n }\n } catch (error) {\n if (error instanceof DOMException && error.name === 'SecurityError') {\n console.warn(\n `Unable to access stylesheet due to CORS restrictions: Skipping sheet ${sheet.href}. Add crossorigin=\"anonymous\" to the stylesheet link if you want to bypass this warning.`,\n sheet.href\n );\n continue;\n }\n\n console.warn(`Error accessing stylesheet ${sheet.href}`, error);\n }\n }\n\n return null;\n}\n\n// Convert kebab-case to camelCase for React\nfunction convertKebabToCamelCase(property: string): string {\n return property.trim().replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useQuestionnaireStore } from '../stores';\nimport type { QuestionnaireItem } from 'fhir/r4';\n\nfunction useDisplayCqfAndCalculatedExpression(qItem: QuestionnaireItem): string | null {\n const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();\n\n const cqfOrCalcExpression = calculatedExpressions[qItem.linkId]?.find(\n (exp) => exp.from === 'item._text'\n );\n\n if (!cqfOrCalcExpression) {\n return null;\n }\n\n if (\n typeof cqfOrCalcExpression.value === 'string' ||\n typeof cqfOrCalcExpression.value === 'number' ||\n cqfOrCalcExpression.value === null\n ) {\n // calculatedExpression value is null\n if (cqfOrCalcExpression.value === null) {\n return '';\n }\n\n // calculatedExpression value is string or number\n return typeof cqfOrCalcExpression.value === 'string'\n ? cqfOrCalcExpression.value\n : cqfOrCalcExpression.value.toString();\n }\n\n return null;\n}\n\nexport default useDisplayCqfAndCalculatedExpression;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n getQuantityUnit,\n getTextDisplayFlyover,\n getTextDisplayInstructions,\n getTextDisplayPrompt,\n getTextDisplayUnit\n} from '../utils/itemControl';\nimport type { QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport { structuredDataCapture } from 'fhir-sdc-helpers';\nimport type { JSX } from 'react';\nimport { useMemo } from 'react';\n\nexport interface RenderingExtensions {\n displayUnit: string;\n displayPrompt: string;\n displayInstructions: string;\n displayFlyover: string | JSX.Element | JSX.Element[];\n readOnly: boolean;\n entryFormat: string;\n required: boolean;\n quantityUnit: QuestionnaireItemAnswerOption | null;\n}\n\nfunction useRenderingExtensions(qItem: QuestionnaireItem): RenderingExtensions {\n return useMemo(\n () => ({\n displayUnit: getTextDisplayUnit(qItem),\n displayPrompt: getTextDisplayPrompt(qItem),\n displayInstructions: getTextDisplayInstructions(qItem),\n displayFlyover: getTextDisplayFlyover(qItem),\n readOnly: !!qItem.readOnly,\n entryFormat: structuredDataCapture.getEntryFormat(qItem) ?? '',\n required: qItem.required ?? false,\n quantityUnit: getQuantityUnit(qItem)\n }),\n [qItem]\n );\n}\n\nexport default useRenderingExtensions;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { TypographyProps } from '@mui/material/Typography';\nimport Typography from '@mui/material/Typography';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface RequiredAsteriskProps extends TypographyProps {\n readOnly?: boolean;\n}\n\nfunction RequiredAsterisk(props: RequiredAsteriskProps) {\n const { readOnly, children = '*', ...rest } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n\n const readOnlyTextColor = readOnlyVisualStyle === 'disabled' ? 'text.disabled' : 'text.secondary';\n\n return (\n <Typography color={readOnly ? readOnlyTextColor : 'red'} {...rest}>\n {children}\n </Typography>\n );\n}\n\nexport default RequiredAsterisk;\n","import React, { type JSX, useState } from 'react';\nimport Popover from '@mui/material/Popover';\nimport { Box } from '@mui/material';\nimport QuestionMarkOutlinedIcon from '@mui/icons-material/QuestionMarkOutlined';\nimport Typography from '@mui/material/Typography';\n\ninterface FlyoverHoverCardProps {\n children: string | JSX.Element | JSX.Element[];\n}\n\nfunction FlyoverHoverCard(props: FlyoverHoverCardProps) {\n const { children } = props;\n\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n\n const handleOpen = (event: React.MouseEvent<HTMLElement>) => {\n setAnchorEl(event.currentTarget);\n };\n\n const handleClose = () => {\n setAnchorEl(null);\n };\n\n const childrenIsString = typeof children === 'string';\n\n return (\n <>\n <Box\n onMouseEnter={handleOpen} // Show popover on hover\n onMouseLeave={handleClose} // Hide popover when not hovered\n sx={{\n height: 16,\n width: 16,\n backgroundColor: 'rgba(25, 118, 210, 0.8)',\n borderRadius: '50%',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n transition: 'background-color 0.3s'\n }}>\n <QuestionMarkOutlinedIcon sx={{ color: 'white', height: 12, width: 12 }} />\n </Box>\n\n <Popover\n open={Boolean(anchorEl)}\n anchorEl={anchorEl}\n onClose={handleClose}\n disableRestoreFocus\n anchorOrigin={{\n vertical: 'top',\n horizontal: 'left'\n }}\n transformOrigin={{\n vertical: 'bottom',\n horizontal: 'left'\n }}\n sx={{ pointerEvents: 'none' }} // Ensures hover-only behavior\n >\n {childrenIsString ? (\n <Box sx={{ p: 2, maxWidth: 550, bgcolor: 'background.paper', boxShadow: 8 }}>\n <Typography variant=\"body2\">{children}</Typography>\n </Box>\n ) : (\n <Box>{children}</Box>\n )}\n </Popover>\n </>\n );\n}\n\nexport default FlyoverHoverCard;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { JSX } from 'react';\nimport React from 'react';\nimport { useQuestionnaireStore } from '../../../stores';\nimport FlyoverHoverCard from './FlyoverHoverCard';\n\ninterface FlyoverItemProps {\n displayFlyover: string | JSX.Element | JSX.Element[];\n readOnly: boolean;\n}\n\nfunction FlyoverItem(props: FlyoverItemProps) {\n const { displayFlyover, readOnly } = props;\n\n const sdcUiOverrideComponents = useQuestionnaireStore.use.sdcUiOverrideComponents();\n const FlyoverOverrideComponent = sdcUiOverrideComponents['flyover'];\n\n // If a flyover override component is defined for this item, render it\n if (FlyoverOverrideComponent && typeof FlyoverOverrideComponent === 'function') {\n return <FlyoverOverrideComponent displayText={displayFlyover} readOnly={readOnly} />;\n }\n\n return <FlyoverHoverCard>{displayFlyover}</FlyoverHoverCard>;\n}\n\nexport default FlyoverItem;\n","/*\n * Copyright 2025 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * @author Janardhan Vignarajan\n *\n */\n\n/**\n * Returns the values from h1 to h6 based on the elevation number.\n *\n * @export\n * @param {number} groupCardElevation\n * @return {*} {'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'}\n */\n\nexport function getHeadingTag(groupCardElevation: number): 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' {\n // Ensure heading level is within valid range\n let headingIntValue = Math.min(groupCardElevation, 6);\n\n // If Elevation is 0, then return always 1\n if (groupCardElevation === 0) {\n headingIntValue = 1;\n }\n\n // Construct the Heading tag type\n return `h${headingIntValue}` as 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Card from '@mui/material/Card';\nimport { styled } from '@mui/material/styles';\n\nexport const GroupCard = styled(Card, {\n shouldForwardProp: (prop) => prop !== 'elevation' && prop !== 'isRepeated'\n})<{ elevation: number; isRepeated: boolean }>(({ elevation, isRepeated }) => ({\n paddingTop: '20px',\n paddingBottom: '20px',\n paddingLeft: elevation === 1 ? '26px' : '24px',\n paddingRight: elevation === 1 ? '26px' : '24px',\n marginBottom: isRepeated ? 0 : '28px'\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { memo } from 'react';\nimport Box from '@mui/material/Box';\nimport type { Tabs } from '../../../interfaces/tab.interface';\nimport { useQuestionnaireStore, useRendererStylingStore } from '../../../stores';\nimport NextTabButton from './NextTabButton';\nimport PreviousTabButton from './PreviousTabButton';\nimport useNextAndPreviousVisibleTabs from '../../../hooks/useNextAndPreviousVisibleTabs';\nimport { useFocusTabHeading } from '../../../hooks/useFocusTabHeading';\n\ninterface TabButtonsWrapperProps {\n currentTabIndex?: number;\n tabs?: Tabs;\n}\n\nconst TabButtonsWrapper = memo(function TabButtonsWrapper(props: TabButtonsWrapperProps) {\n const { currentTabIndex, tabs } = props;\n\n const switchTab = useQuestionnaireStore.use.switchTab();\n const disableTabButtons = useRendererStylingStore.use.disableTabButtons();\n\n const { previousTabIndex, nextTabIndex, numOfVisibleTabs } = useNextAndPreviousVisibleTabs(\n currentTabIndex,\n tabs\n );\n\n const focusHeading = useFocusTabHeading();\n\n const tabsNotDefined = currentTabIndex === undefined || tabs === undefined;\n\n // Event handlers\n function handlePreviousTabButtonClick() {\n if (previousTabIndex === null) {\n return;\n }\n\n switchTab(previousTabIndex);\n\n // Scroll to top of page\n window.scrollTo(0, 0);\n\n // Focus the first heading in the new tab panel\n setTimeout(() => {\n focusHeading(`tabpanel-${previousTabIndex}`);\n }, 100); // Small delay to ensure panel is rendered\n }\n\n function handleNextTabButtonClick() {\n if (nextTabIndex === null) {\n return;\n }\n\n switchTab(nextTabIndex);\n\n // Scroll to top of page\n window.scrollTo(0, 0);\n\n // Focus the first heading in the new tab panel\n setTimeout(() => {\n focusHeading(`tabpanel-${nextTabIndex}`);\n }, 100); // Small delay to ensure panel is rendered\n }\n\n if (tabsNotDefined) {\n return null;\n }\n\n // Disable tab buttons - currently only available via disableTabButtons API\n if (disableTabButtons) {\n return null;\n }\n\n const previousTabButtonHidden = previousTabIndex === null;\n const nextTabButtonHidden = nextTabIndex === null;\n\n // This is more of a fallback check to prevent the user from navigating to an invisble tab if buttons are visble for some reason\n const tabButtonsDisabled = numOfVisibleTabs <= 1;\n\n return (\n <Box display=\"flex\" mt={3}>\n {previousTabButtonHidden ? null : (\n <PreviousTabButton\n isDisabled={tabButtonsDisabled}\n onPreviousTabClick={handlePreviousTabButtonClick}\n />\n )}\n <Box flexGrow={1} />\n {nextTabButtonHidden ? null : (\n <NextTabButton isDisabled={tabButtonsDisabled} onNextTabClick={handleNextTabButtonClick} />\n )}\n </Box>\n );\n});\n\nexport default TabButtonsWrapper;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Button from '@mui/material/Button';\nimport Iconify from '../../Iconify/Iconify';\n\ninterface NextTabButtonProps {\n isDisabled: boolean;\n onNextTabClick: () => void;\n}\n\nfunction NextTabButton(props: NextTabButtonProps) {\n const { isDisabled, onNextTabClick } = props;\n\n return (\n <Button\n variant=\"contained\"\n size=\"small\"\n endIcon={<Iconify icon=\"material-symbols:arrow-forward\" />}\n disabled={isDisabled}\n color=\"secondary\"\n onClick={onNextTabClick}>\n Next tab\n </Button>\n );\n}\n\nexport default NextTabButton;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { forwardRef, memo } from 'react';\nimport { Icon } from '@iconify/react';\nimport type { SxProps, Theme } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\n\ninterface IconifyProps {\n icon: string;\n width?: number;\n height?: number;\n sx?: SxProps<Theme>;\n}\n\nconst Iconify = memo(\n forwardRef(function Iconify(props: IconifyProps, ref) {\n // eslint-disable-next-line react/prop-types\n const { icon, width = 20, height = 20, sx } = props;\n return <Box ref={ref} component={Icon} icon={icon} sx={{ width, height, ...sx }} />;\n })\n);\n\nexport default Iconify;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Button from '@mui/material/Button';\nimport Iconify from '../../Iconify/Iconify';\n\ninterface PreviousTabButtonProps {\n isDisabled: boolean;\n onPreviousTabClick: () => void;\n}\n\nfunction PreviousTabButton(props: PreviousTabButtonProps) {\n const { isDisabled, onPreviousTabClick } = props;\n\n return (\n <Button\n variant=\"contained\"\n size=\"small\"\n endIcon={<Iconify icon=\"material-symbols:arrow-back\" />}\n disabled={isDisabled}\n color=\"secondary\"\n onClick={onPreviousTabClick}>\n Previous tab\n </Button>\n );\n}\n\nexport default PreviousTabButton;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useQuestionnaireStore } from '../stores';\nimport type { Tabs } from '../interfaces/tab.interface';\nimport { constructTabsWithVisibility } from '../utils/tabs';\n\nfunction useNextAndPreviousVisibleTabs(\n currentTabIndex?: number,\n tabs?: Tabs\n): { previousTabIndex: number | null; nextTabIndex: number | null; numOfVisibleTabs: number } {\n const enableWhenIsActivated = useQuestionnaireStore.use.enableWhenIsActivated();\n const enableWhenItems = useQuestionnaireStore.use.enableWhenItems();\n const enableWhenExpressions = useQuestionnaireStore.use.enableWhenExpressions();\n\n const tabsNotDefined = currentTabIndex === undefined || tabs === undefined;\n\n if (tabsNotDefined) {\n return { previousTabIndex: null, nextTabIndex: null, numOfVisibleTabs: 0 };\n }\n\n const tabsWithVisibility = constructTabsWithVisibility({\n tabs,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n });\n\n return {\n previousTabIndex: getPreviousTabIndex(currentTabIndex, tabsWithVisibility),\n nextTabIndex: getNextTabIndex(currentTabIndex, tabsWithVisibility),\n numOfVisibleTabs: tabsWithVisibility.filter((tab) => tab.isVisible).length\n };\n}\n\nfunction getPreviousTabIndex(\n currentTabIndex: number,\n tabsWithVisibility: { linkId: string; isVisible: boolean }[]\n): number | null {\n const previousTabs = tabsWithVisibility.slice(0, currentTabIndex);\n const foundIndex = previousTabs.reverse().findIndex((tab) => tab.isVisible);\n\n // Previous visible tab not found\n if (foundIndex === -1) {\n return null;\n }\n\n // Previous visible tab less than 0\n const previousTabIndex = currentTabIndex - foundIndex - 1;\n if (previousTabIndex < 0) {\n return null;\n }\n\n return previousTabIndex;\n}\n\nfunction getNextTabIndex(\n currentTabIndex: number,\n tabsWithVisibility: { linkId: string; isVisible: boolean }[]\n): number | null {\n const subsequentTabs = tabsWithVisibility.slice(currentTabIndex + 1);\n const foundIndex = subsequentTabs.findIndex((tab) => tab.isVisible);\n\n // Next visible tab not found, something is wrong\n if (foundIndex === -1) {\n return null;\n }\n\n return currentTabIndex + foundIndex + 1;\n}\n\nexport default useNextAndPreviousVisibleTabs;\n","import { useCallback } from 'react';\n\nexport function useFocusTabHeading() {\n return useCallback((tabPanelId: string) => {\n // Find the first heading in the tab panel that was just activated\n const tabPanel = document.getElementById(tabPanelId);\n if (!tabPanel) return;\n\n // Look for the first heading element within the tab panel\n const firstHeading = tabPanel.querySelector('h1, h2, h3, h4, h5, h6');\n if (!firstHeading) return;\n\n // If heading doesn't have tabindex=-1, add it\n if (!firstHeading.hasAttribute('tabindex')) {\n firstHeading.setAttribute('tabindex', '-1');\n }\n\n // Focus the heading\n (firstHeading as HTMLElement).focus();\n }, []);\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\n\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { mapQItemsIndex } from '../../../utils/mapItem';\nimport type {\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrRepeatGroupChangeHandler,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport GroupTableView from './GroupTableView';\nimport type { GroupTableRowModel } from '../../../interfaces/groupTable.interface';\nimport { getGroupTableItemsToUpdate } from '../../../utils/groupTable';\nimport useGroupTableRows from '../../../hooks/useGroupTableRows';\nimport { flushSync } from 'react-dom';\nimport { generateNewRepeatId } from '../../../utils/repeatId';\nimport useInitialiseGroupTableRows from '../../../hooks/useInitialiseGroupTableRows';\n\ninterface GroupTableProps\n extends PropsWithQrRepeatGroupChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute {\n qItem: QuestionnaireItem;\n qrItems: QuestionnaireResponseItem[];\n groupCardElevation: number;\n parentStyles?: Record<string, string>;\n}\n\n/**\n * Main component to render a Group Table (gtable) Questionnaire item.\n * @see {@link https://hl7.org/fhir/extensions/CodeSystem-questionnaire-item-control.html}\n *\n * @author Sean Fong\n */\nfunction GroupTable(props: GroupTableProps) {\n const {\n qItem,\n qrItems,\n groupCardElevation,\n isRepeated,\n showMinimalView,\n parentIsReadOnly,\n onQrRepeatGroupChange,\n parentStyles\n } = props;\n\n const initialGroupTableRows = useInitialiseGroupTableRows(qItem.linkId, qrItems);\n const { tableRows, selectedIds, setTableRows, setSelectedIds } =\n useGroupTableRows(initialGroupTableRows);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Generate item labels as table headers\n const qItems = qItem.item;\n const itemLabels: string[] = useMemo(\n () => qItems?.map((item) => item.text ?? '') ?? [],\n [qItems]\n );\n\n const qItemsIndexMap = useMemo(() => mapQItemsIndex(qItem), [qItem]);\n\n // Check if there are columns within the group table\n if (!qItems || qItems.length === 0) {\n return null;\n }\n\n // Event Handlers\n function handleRowChange(newQrRow: QuestionnaireResponseItem, index: number) {\n const updatedTableRows = [...tableRows];\n\n if (newQrRow.item) {\n updatedTableRows[index].qrItem = {\n linkId: newQrRow.linkId,\n text: newQrRow.text,\n item: newQrRow.item\n };\n }\n\n setTableRows(updatedTableRows);\n onQrRepeatGroupChange({\n linkId: qItem.linkId,\n qrItems: getGroupTableItemsToUpdate(updatedTableRows, selectedIds)\n });\n }\n\n function handleRemoveRow(index: number) {\n const updatedTableRows = [...tableRows];\n\n const rowToRemove = updatedTableRows[index];\n const updatedSelectedIds = selectedIds.filter((id) => id !== rowToRemove.id);\n\n updatedTableRows.splice(index, 1);\n\n setTableRows(updatedTableRows);\n onQrRepeatGroupChange({\n linkId: qItem.linkId,\n qrItems: getGroupTableItemsToUpdate(updatedTableRows, updatedSelectedIds)\n });\n setSelectedIds(updatedSelectedIds);\n }\n\n function handleAddRow() {\n const newRowId = generateNewRepeatId(qItem.linkId);\n setTableRows([\n ...tableRows,\n {\n id: newRowId,\n qrItem: null\n }\n ]);\n setSelectedIds([...selectedIds, newRowId]);\n }\n\n function handleSelectAll() {\n // deselect all if all are selected, otherwise select all\n const updatedTableIds =\n selectedIds.length === tableRows.length ? [] : tableRows.map((tableRow) => tableRow.id);\n setSelectedIds(updatedTableIds);\n onQrRepeatGroupChange({\n linkId: qItem.linkId,\n qrItems: getGroupTableItemsToUpdate(tableRows, updatedTableIds)\n });\n }\n\n function handleSelectRow(rowId: string) {\n const updatedSelectedIds = [...selectedIds];\n\n const index = updatedSelectedIds.indexOf(rowId);\n if (index === -1) {\n updatedSelectedIds.push(rowId);\n } else {\n updatedSelectedIds.splice(index, 1);\n }\n\n setSelectedIds(updatedSelectedIds);\n onQrRepeatGroupChange({\n linkId: qItem.linkId,\n qrItems: getGroupTableItemsToUpdate(tableRows, updatedSelectedIds)\n });\n }\n\n async function handleReorderRows(newTableRows: GroupTableRowModel[]) {\n // Prevent state batching when reordering to prevent view stuttering https://react.dev/reference/react-dom/flushSync\n flushSync(() => {\n setTableRows(newTableRows);\n });\n onQrRepeatGroupChange({\n linkId: qItem.linkId,\n qrItems: getGroupTableItemsToUpdate(newTableRows, selectedIds)\n });\n }\n\n return (\n <GroupTableView\n qItem={qItem}\n qItemsIndexMap={qItemsIndexMap}\n groupCardElevation={groupCardElevation}\n isRepeated={isRepeated}\n readOnly={readOnly}\n tableRows={tableRows}\n selectedIds={selectedIds}\n itemLabels={itemLabels}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n onAddRow={handleAddRow}\n onRowChange={handleRowChange}\n onRemoveRow={handleRemoveRow}\n onSelectRow={handleSelectRow}\n onSelectAll={handleSelectAll}\n onReorderRows={handleReorderRows}\n parentStyles={parentStyles}\n />\n );\n}\n\nexport default GroupTable;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport useRenderingExtensions from './useRenderingExtensions';\nimport { useRendererStylingStore } from '../stores/rendererStylingStore';\nimport { isHiddenByEnableWhen } from '../utils/qItem';\nimport { useQuestionnaireStore } from '../stores';\n\nfunction useReadOnly(\n qItem: QuestionnaireItem,\n parentIsReadOnly: boolean | undefined,\n parentRepeatGroupIndex?: number\n): boolean {\n let { readOnly } = useRenderingExtensions(qItem);\n\n const enableWhenIsActivated = useQuestionnaireStore.use.enableWhenIsActivated();\n const enableWhenItems = useQuestionnaireStore.use.enableWhenItems();\n const enableWhenExpressions = useQuestionnaireStore.use.enableWhenExpressions();\n\n const enableWhenAsReadOnly = useRendererStylingStore.use.enableWhenAsReadOnly();\n\n // If enableWhenAsReadOnly is true, then items hidden by enableWhen should be displayed, but set as readOnly\n // If enableWhenAsReadOnly is a Set, all item types in the set should be displayed, but set as readOnly\n if (!readOnly) {\n if (\n enableWhenAsReadOnly === true ||\n (enableWhenAsReadOnly instanceof Set && enableWhenAsReadOnly.has(qItem.type))\n ) {\n readOnly = isHiddenByEnableWhen({\n linkId: qItem.linkId,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions,\n parentRepeatGroupIndex\n });\n }\n }\n\n if (typeof parentIsReadOnly === 'boolean' && parentIsReadOnly) {\n readOnly = parentIsReadOnly;\n }\n\n return readOnly;\n}\n\nexport default useReadOnly;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { QGroupContainerBox } from '../../Box.styles';\nimport TableContainer from '@mui/material/TableContainer';\nimport Paper from '@mui/material/Paper';\nimport Table from '@mui/material/Table';\nimport TableHead from '@mui/material/TableHead';\nimport TableRow from '@mui/material/TableRow';\nimport { HeaderTableCell } from './Table.styles';\nimport TableCell from '@mui/material/TableCell';\nimport TableBody from '@mui/material/TableBody';\nimport Divider from '@mui/material/Divider';\nimport AddRowButton from './AddRowButton';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport type {\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { GroupTableRowModel } from '../../../interfaces/groupTable.interface';\nimport GroupTableBody from './GroupTableBody';\nimport { useQuestionnaireStore, useRendererStylingStore } from '../../../stores';\nimport { getGroupCollapsible } from '../../../utils/qItem';\nimport { GroupAccordion } from '../GroupItem/GroupAccordion.styles';\nimport AccordionSummary from '@mui/material/AccordionSummary';\nimport ExpandMoreIcon from '@mui/icons-material/ExpandMore';\nimport AccordionDetails from '@mui/material/AccordionDetails';\nimport GroupHeading from '../GroupItem/GroupHeading';\nimport { StandardCheckbox } from '../../Checkbox.styles';\n\ninterface GroupTableViewProps\n extends PropsWithIsRepeatedAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute {\n qItem: QuestionnaireItem;\n qItemsIndexMap: Record<string, number>;\n groupCardElevation: number;\n readOnly: boolean;\n tableRows: GroupTableRowModel[];\n selectedIds: string[];\n itemLabels: string[];\n onAddRow: () => void;\n onRowChange: (newQrRow: QuestionnaireResponseItem, index: number) => void;\n onRemoveRow: (index: number) => void;\n onSelectRow: (rowId: string) => void;\n onSelectAll: () => void;\n onReorderRows: (newTableRows: GroupTableRowModel[]) => void;\n parentStyles?: Record<string, string>;\n}\n\nfunction GroupTableView(props: GroupTableViewProps) {\n const {\n qItem,\n qItemsIndexMap,\n groupCardElevation,\n isRepeated,\n readOnly,\n tableRows,\n selectedIds,\n itemLabels,\n showMinimalView,\n parentIsReadOnly,\n onAddRow,\n onRowChange,\n onRemoveRow,\n onSelectRow,\n onSelectAll,\n onReorderRows,\n parentStyles\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n\n const groupCollapsibleValue = getGroupCollapsible(qItem);\n\n // If the table is collapsible, wrap it in an accordion\n if (groupCollapsibleValue) {\n const isDefaultOpen = groupCollapsibleValue === 'default-open';\n\n // Minimal + Accordion\n if (showMinimalView) {\n return (\n <GroupAccordion\n disableGutters\n defaultExpanded={isDefaultOpen}\n elevation={groupCardElevation}\n slotProps={{\n transition: { unmountOnExit: true, timeout: 250 }\n }}>\n <AccordionSummary expandIcon={<ExpandMoreIcon />} sx={{ minHeight: '28px' }}>\n <GroupHeading\n qItem={qItem}\n readOnly={readOnly}\n groupCardElevation={groupCardElevation}\n />\n </AccordionSummary>\n <AccordionDetails sx={{ pt: 0 }}>\n {qItem.text ? <Divider sx={{ mb: 1.5, opacity: 0.6 }} /> : null}\n <TableContainer component={Paper} elevation={groupCardElevation}>\n <Table size=\"small\">\n <TableHead>\n <TableRow>\n {itemLabels.map((itemLabel) => (\n <HeaderTableCell key={itemLabel} size=\"medium\">\n {itemLabel}\n </HeaderTableCell>\n ))}\n <TableCell />\n </TableRow>\n </TableHead>\n <TableBody>\n <GroupTableBody\n tableQItem={qItem}\n readOnly={readOnly}\n tableRows={tableRows}\n selectedIds={selectedIds}\n qItemsIndexMap={qItemsIndexMap}\n isRepeated={isRepeated}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n onRowChange={onRowChange}\n onRemoveRow={onRemoveRow}\n onSelectRow={onSelectRow}\n onReorderRows={onReorderRows}\n />\n </TableBody>\n </Table>\n </TableContainer>\n </AccordionDetails>\n </GroupAccordion>\n );\n }\n\n // Non-minimal Accordion\n return (\n <GroupAccordion\n disableGutters\n defaultExpanded={isDefaultOpen}\n elevation={groupCardElevation}\n slotProps={{\n transition: { unmountOnExit: true, timeout: 250 }\n }}>\n <AccordionSummary expandIcon={<ExpandMoreIcon />} sx={{ minHeight: '28px' }}>\n <GroupHeading qItem={qItem} readOnly={readOnly} groupCardElevation={groupCardElevation} />\n </AccordionSummary>\n <AccordionDetails sx={{ pt: 0 }}>\n {qItem.text ? <Divider sx={{ mb: 1.5, opacity: 0.6 }} /> : null}\n <TableContainer component={Paper} elevation={groupCardElevation}>\n <Table>\n {isRepeated ? (\n <caption>\n <AddRowButton repeatGroups={tableRows} readOnly={readOnly} onAddItem={onAddRow} />\n </caption>\n ) : null}\n <TableHead>\n <TableRow>\n <HeaderTableCell padding=\"none\" />\n {isRepeated ? (\n <HeaderTableCell padding=\"none\">\n <StandardCheckbox\n color=\"primary\"\n size=\"small\"\n indeterminate={\n selectedIds.length > 0 && selectedIds.length < tableRows.length\n }\n checked={tableRows.length > 0 && selectedIds.length === tableRows.length}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n onChange={onSelectAll}\n />\n </HeaderTableCell>\n ) : null}\n {itemLabels.map((itemLabel) => (\n <HeaderTableCell key={itemLabel}>{itemLabel}</HeaderTableCell>\n ))}\n <TableCell padding=\"checkbox\" />\n </TableRow>\n </TableHead>\n <GroupTableBody\n tableQItem={qItem}\n readOnly={readOnly}\n tableRows={tableRows}\n selectedIds={selectedIds}\n qItemsIndexMap={qItemsIndexMap}\n isRepeated={isRepeated}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n onRowChange={onRowChange}\n onRemoveRow={onRemoveRow}\n onSelectRow={onSelectRow}\n onReorderRows={onReorderRows}\n />\n </Table>\n </TableContainer>\n </AccordionDetails>\n </GroupAccordion>\n );\n }\n\n // Minimal + Regular GTable\n if (showMinimalView) {\n return (\n <QGroupContainerBox\n cardElevation={groupCardElevation}\n isRepeated={false}\n py={1}\n style={parentStyles || undefined}>\n <TableContainer component={Paper} elevation={groupCardElevation}>\n <Table size=\"small\">\n <TableHead>\n <TableRow>\n {itemLabels.map((itemLabel) => (\n <HeaderTableCell key={itemLabel} size=\"medium\">\n {itemLabel}\n </HeaderTableCell>\n ))}\n <TableCell />\n </TableRow>\n </TableHead>\n <TableBody>\n <GroupTableBody\n tableQItem={qItem}\n readOnly={readOnly}\n tableRows={tableRows}\n selectedIds={selectedIds}\n qItemsIndexMap={qItemsIndexMap}\n isRepeated={isRepeated}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n onRowChange={onRowChange}\n onRemoveRow={onRemoveRow}\n onSelectRow={onSelectRow}\n onReorderRows={onReorderRows}\n />\n </TableBody>\n </Table>\n </TableContainer>\n </QGroupContainerBox>\n );\n }\n\n // Regular GTable (not minimal)\n return (\n <QGroupContainerBox\n cardElevation={groupCardElevation}\n isRepeated={false}\n py={3}\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}\n style={parentStyles || undefined}>\n <>\n <GroupHeading qItem={qItem} readOnly={readOnly} groupCardElevation={groupCardElevation} />\n <Divider sx={{ my: 1, opacity: 0.6 }} />\n </>\n <TableContainer component={Paper} elevation={groupCardElevation}>\n <Table>\n {isRepeated ? (\n <caption>\n <AddRowButton repeatGroups={tableRows} readOnly={readOnly} onAddItem={onAddRow} />\n </caption>\n ) : null}\n <TableHead>\n <TableRow>\n <HeaderTableCell padding=\"none\" />\n {isRepeated ? (\n <HeaderTableCell padding=\"none\">\n <StandardCheckbox\n color=\"primary\"\n size=\"small\"\n indeterminate={selectedIds.length > 0 && selectedIds.length < tableRows.length}\n checked={tableRows.length > 0 && selectedIds.length === tableRows.length}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n onChange={onSelectAll}\n />\n </HeaderTableCell>\n ) : null}\n {itemLabels.map((itemLabel) => (\n <HeaderTableCell key={itemLabel}>{itemLabel}</HeaderTableCell>\n ))}\n <TableCell padding=\"checkbox\" />\n </TableRow>\n </TableHead>\n <GroupTableBody\n tableQItem={qItem}\n readOnly={readOnly}\n tableRows={tableRows}\n selectedIds={selectedIds}\n qItemsIndexMap={qItemsIndexMap}\n isRepeated={isRepeated}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n onRowChange={onRowChange}\n onRemoveRow={onRemoveRow}\n onSelectRow={onSelectRow}\n onReorderRows={onReorderRows}\n />\n </Table>\n </TableContainer>\n </QGroupContainerBox>\n );\n}\n\nexport default GroupTableView;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { styled } from '@mui/material/styles';\nimport TableCell from '@mui/material/TableCell';\nimport TableRow from '@mui/material/TableRow';\nimport { grey } from '@mui/material/colors';\n\nexport const HeaderTableCell = styled(TableCell)(() => ({\n fontSize: 13,\n lineHeight: 'normal'\n}));\n\nexport const StandardTableCell = styled(TableCell, {\n shouldForwardProp: (prop) => prop !== 'numOfColumns'\n})<{ numOfColumns: number }>(({ numOfColumns }) => ({\n width: `${100 / numOfColumns}%`,\n paddingLeft: 4,\n paddingRight: 4\n}));\n\nexport const DeleteButtonTableCell = styled(TableCell)(() => ({\n paddingLeft: 0,\n paddingRight: 4\n}));\n\nexport const GridTextTableCell = styled(TableCell)(({ theme }) => ({\n width: '20%',\n paddingLeft: '18px',\n paddingRight: '18px',\n color: theme.palette.text.secondary\n}));\n\nexport const GridAnswerTableCell = styled(TableCell, {\n shouldForwardProp: (prop) => prop !== 'numOfColumns'\n})<{ numOfColumns: number }>(({ numOfColumns }) => ({\n width: `${80 / numOfColumns}%`,\n paddingLeft: 5,\n paddingRight: 5\n}));\n\nexport const StyledGroupTableRow = styled(TableRow, {\n shouldForwardProp: (prop) =>\n prop !== 'itemIsDragged' && prop !== 'itemIsSelected' && prop !== 'hoverDisabled'\n})<{ itemIsDragged: boolean; itemIsSelected: boolean; hoverDisabled: boolean }>(\n ({ theme, itemIsDragged, itemIsSelected, hoverDisabled }) => ({\n backgroundColor: itemIsSelected ? '#f4f8ff' : '#fff',\n ...(hoverDisabled\n ? {}\n : {\n '&.MuiTableRow-root:hover': {\n backgroundColor: itemIsSelected ? '#e9f1ff' : grey['50']\n }\n }),\n ...(itemIsDragged\n ? {\n boxShadow: theme.shadows[8],\n opacity: 1,\n backgroundColor: itemIsSelected ? '#edf4ff' : '#fafafa'\n }\n : {})\n })\n);\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport AddIcon from '@mui/icons-material/Add';\nimport type { RepeatGroupSingleModel } from '../../../interfaces/repeatGroup.interface';\n\ninterface AddItemButtonProps {\n repeatGroups: RepeatGroupSingleModel[];\n readOnly: boolean;\n onAddItem: () => void;\n}\n\nfunction AddRowButton(props: AddItemButtonProps) {\n const { repeatGroups, readOnly, onAddItem } = props;\n\n const isDisabled = repeatGroups[repeatGroups.length - 1].qrItem === null || readOnly;\n\n return (\n <Box display=\"flex\" flexDirection=\"row-reverse\">\n <Button\n variant=\"contained\"\n size=\"small\"\n startIcon={<AddIcon />}\n disabled={isDisabled}\n onClick={onAddItem}\n data-test=\"button-add-repeat-item\">\n Add Row\n </Button>\n </Box>\n );\n}\n\nexport default AddRowButton;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport type {\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { TableRowProps } from '@mui/material/TableRow';\nimport TableRow from '@mui/material/TableRow';\nimport SelectRowButton from './SelectRowButton';\nimport GroupTableRowCells from './GroupTableRowCells';\nimport RemoveRowButton from './RemoveRowButton';\nimport type { GroupTableRowModel } from '../../../interfaces/groupTable.interface';\nimport DragIndicator from '@mui/icons-material/DragIndicator';\nimport TableCell from '@mui/material/TableCell';\nimport Box from '@mui/material/Box';\nimport { Draggable } from 'react-beautiful-dnd';\nimport { StyledGroupTableRow } from './Table.styles';\n\ninterface GroupTableRowProps\n extends PropsWithIsRepeatedAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n TableRowProps {\n rowId: string;\n index: number;\n tableQItem: QuestionnaireItem;\n answeredQrItem: QuestionnaireResponseItem;\n nullableQrItem: QuestionnaireResponseItem | null;\n readOnly: boolean;\n isRepeated: boolean;\n hoverDisabled: boolean;\n tableRows: GroupTableRowModel[];\n itemIsSelected: boolean;\n selectedIds: string[];\n qItemsIndexMap: Record<string, number>;\n onRowChange: (newQrRow: QuestionnaireResponseItem, index: number) => void;\n onRemoveRow: (index: number) => void;\n onSelectRow: (nanoId: string) => void;\n}\n\nfunction GroupTableRow(props: GroupTableRowProps) {\n const {\n rowId,\n index,\n tableQItem,\n answeredQrItem,\n nullableQrItem,\n readOnly,\n isRepeated,\n hoverDisabled,\n tableRows,\n itemIsSelected,\n qItemsIndexMap,\n showMinimalView,\n parentIsReadOnly,\n onRowChange,\n onRemoveRow,\n onSelectRow\n } = props;\n\n if (isRepeated) {\n return (\n <Draggable draggableId={rowId} index={index}>\n {(draggableProvided, snapshot) => (\n <StyledGroupTableRow\n itemIsDragged={snapshot.isDragging}\n itemIsSelected={itemIsSelected}\n hoverDisabled={hoverDisabled}\n hover={!hoverDisabled}\n ref={draggableProvided.innerRef}\n {...draggableProvided.draggableProps}>\n {showMinimalView || !isRepeated ? (\n <TableCell padding=\"checkbox\" />\n ) : (\n <>\n <TableCell padding=\"none\">\n <Box\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n {...(readOnly ? {} : draggableProvided.dragHandleProps)}>\n <DragIndicator\n fontSize=\"small\"\n sx={{ color: readOnly ? 'text.disabled' : 'inherit' }}\n />\n </Box>\n </TableCell>\n <SelectRowButton\n isSelected={itemIsSelected}\n readOnly={readOnly}\n onSelectItem={() => onSelectRow(rowId)}\n />\n </>\n )}\n <GroupTableRowCells\n qItem={tableQItem}\n qrItem={answeredQrItem}\n qItemsIndexMap={qItemsIndexMap}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={(newQrGroup) => onRowChange(newQrGroup, index)}\n />\n {showMinimalView || !isRepeated ? (\n <TableCell padding=\"checkbox\" />\n ) : (\n <RemoveRowButton\n nullableQrItem={nullableQrItem}\n numOfRows={tableRows.length}\n readOnly={readOnly}\n onRemoveItem={() => onRemoveRow(index)}\n />\n )}\n </StyledGroupTableRow>\n )}\n </Draggable>\n );\n }\n\n return (\n <TableRow>\n {showMinimalView || !isRepeated ? (\n <TableCell padding=\"checkbox\" />\n ) : (\n <>\n <TableCell padding=\"none\">\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"center\">\n <DragIndicator\n fontSize=\"small\"\n sx={{ color: readOnly ? 'text.disabled' : 'inherit' }}\n />\n </Box>\n </TableCell>\n <SelectRowButton\n isSelected={itemIsSelected}\n readOnly={readOnly}\n onSelectItem={() => onSelectRow(rowId)}\n />\n </>\n )}\n <GroupTableRowCells\n qItem={tableQItem}\n qrItem={answeredQrItem}\n qItemsIndexMap={qItemsIndexMap}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={(newQrGroup) => onRowChange(newQrGroup, index)}\n />\n {showMinimalView || !isRepeated ? (\n <TableCell padding=\"checkbox\" />\n ) : (\n <RemoveRowButton\n nullableQrItem={nullableQrItem}\n numOfRows={tableRows.length}\n readOnly={readOnly}\n onRemoveItem={() => onRemoveRow(index)}\n />\n )}\n </TableRow>\n );\n}\n\nexport default GroupTableRow;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport TableCell from '@mui/material/TableCell';\nimport { StandardCheckbox } from '../../Checkbox.styles';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface SelectRowButtonProps {\n isSelected: boolean;\n readOnly: boolean;\n onSelectItem: () => void;\n}\n\nfunction SelectRowButton(props: SelectRowButtonProps) {\n const { isSelected, readOnly, onSelectItem } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n\n return (\n <TableCell padding=\"none\">\n <StandardCheckbox\n color=\"primary\"\n size=\"small\"\n checked={isSelected}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n onChange={onSelectItem}\n />\n </TableCell>\n );\n}\n\nexport default SelectRowButton;\n","import { styled } from '@mui/material/styles';\nimport Checkbox from '@mui/material/Checkbox';\n\nexport const StandardCheckbox = styled(Checkbox, {\n shouldForwardProp: (prop) => prop !== 'readOnly'\n})<{ readOnly: boolean }>(({ theme, readOnly }) => ({\n ...(readOnly && {\n '&.MuiButtonBase-root': {\n '&.MuiCheckbox-root': {\n // Use text.disabled colour (same as disabled field) here because text.secondary is too dark, and 'rgb(220, 223, 228)' is too light\n color: theme.palette.text.disabled\n },\n '&:hover': {\n backgroundColor: theme.palette.action.hover\n }\n }\n })\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback, useMemo } from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useHidden from '../../../hooks/useHidden';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { shouldRenderNestedItems } from '../../../utils/itemControl';\nimport SingleItemView from './SingleItemView';\n\ninterface SingleItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n groupCardElevation: number;\n parentStyles?: Record<string, string>;\n}\n\n/**\n * Main component to render a repeating, non-group Questionnaire item.\n * Store and manages the state of multiple instances of SingleItem in a repeating item.\n *\n * @author Sean Fong\n */\nfunction SingleItem(props: SingleItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated = false,\n isTabled = false,\n groupCardElevation,\n showMinimalView = false,\n parentIsReadOnly,\n feedbackFromParent,\n parentIsRepeatGroup,\n parentRepeatGroupIndex,\n onQrItemChange,\n parentStyles\n } = props;\n\n const updateEnableWhenItem = useQuestionnaireStore.use.updateEnableWhenItem();\n\n const handleQrItemChange = useCallback(\n (newQrItem: QuestionnaireResponseItem) => {\n updateEnableWhenItem(\n qItem.linkId,\n newQrItem.answer,\n parentIsRepeatGroup ? (parentRepeatGroupIndex ?? null) : null\n );\n\n if (qrItem && qrItem.item && qrItem.item.length > 0) {\n onQrItemChange({ ...newQrItem, item: qrItem.item });\n } else {\n onQrItemChange(newQrItem);\n }\n },\n [\n qrItem,\n updateEnableWhenItem,\n qItem.linkId,\n parentIsRepeatGroup,\n parentRepeatGroupIndex,\n onQrItemChange\n ]\n );\n\n const handleQrItemChangeWithNestedItems = useCallback(\n (newQrItem: QuestionnaireResponseItem) => {\n const updatedQrItem = qrItem ? { ...qrItem, item: newQrItem.item } : newQrItem;\n onQrItemChange(updatedQrItem);\n },\n [qrItem, onQrItemChange]\n );\n\n const itemHasNestedItems = useMemo(\n () => !!qItem.item && qItem.item.length > 0 && shouldRenderNestedItems(qItem),\n [qItem]\n );\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly, parentRepeatGroupIndex);\n const itemIsHidden = useHidden(qItem, parentRepeatGroupIndex);\n\n return (\n <SingleItemView\n qItem={qItem}\n qrItem={qrItem}\n itemIsHidden={itemIsHidden}\n itemHasNestedItems={itemHasNestedItems}\n isRepeated={isRepeated}\n isTabled={isTabled}\n groupCardElevation={groupCardElevation}\n showMinimalView={showMinimalView}\n parentIsReadOnly={readOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={handleQrItemChange}\n onQrItemChangeWithNestedItems={handleQrItemChangeWithNestedItems}\n parentStyles={parentStyles}\n />\n );\n}\n\nexport default SingleItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type {\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponseItem\n} from 'fhir/r4';\nimport { findInAnswerOptions, getChoiceControlType, getQrChoiceValue } from '../../../utils/choice';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport { ChoiceItemControl } from '../../../interfaces/choice.enum';\nimport Typography from '@mui/material/Typography';\nimport useCodingCalculatedExpression from '../../../hooks/useCodingCalculatedExpression';\nimport ChoiceRadioAnswerOptionView from './ChoiceRadioAnswerOptionView';\nimport ChoiceSelectAnswerOptionView from './ChoiceSelectAnswerOptionView';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\n\ninterface ChoiceRadioAnswerOptionItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction ChoiceRadioAnswerOptionItem(props: ChoiceRadioAnswerOptionItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrChoice = qrItem ?? createEmptyQrItem(qItem, answerKey);\n const valueChoice = getQrChoiceValue(qrChoice);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks - there's no string-based input here\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n const options = qItem.answerOption ?? [];\n\n // Process calculated expressions\n const { calcExpUpdated } = useCodingCalculatedExpression({\n qItem: qItem,\n valueInString: valueChoice ?? '',\n onChangeByCalcExpressionString: (newValueString: string) => {\n handleChange(newValueString);\n },\n onChangeByCalcExpressionNull: () => {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n });\n\n // Event handlers\n function handleChange(newValue: QuestionnaireItemAnswerOption | string | null) {\n // No options present or newValue is type null\n if (options.length === 0 || newValue === null) {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n // newValue is type string\n if (typeof newValue === 'string') {\n const qrAnswer = findInAnswerOptions(options, newValue);\n onQrItemChange(\n qrAnswer\n ? { ...createEmptyQrItem(qItem, answerKey), answer: [{ ...qrAnswer, id: answerKey }] }\n : createEmptyQrItem(qItem, answerKey)\n );\n return;\n }\n\n // newValue is type QuestionnaireItemAnswerOption\n onQrItemChange(\n newValue\n ? { ...createEmptyQrItem(qItem, answerKey), answer: [{ ...newValue, id: answerKey }] }\n : createEmptyQrItem(qItem, answerKey)\n );\n }\n\n function handleClear() {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n\n // TODO This is in preparation of refactoring all choice answerOption fields into one component\n const choiceControlType = getChoiceControlType(qItem);\n\n switch (choiceControlType) {\n // TODO At the moment only this case will be executed because this switch statement was already in the parent components\n case ChoiceItemControl.Radio: {\n return (\n <ChoiceRadioAnswerOptionView\n qItem={qItem}\n options={options}\n valueChoice={valueChoice}\n feedback={feedback}\n isRepeated={isRepeated}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n onFocusLinkId={() => onFocusLinkId(qItem.linkId)}\n onCheckedChange={handleChange}\n onClear={handleClear}\n />\n );\n }\n\n case ChoiceItemControl.Select: {\n return (\n <ChoiceSelectAnswerOptionView\n qItem={qItem}\n options={options}\n valueChoice={valueChoice}\n feedback={feedback}\n isRepeated={isRepeated}\n isTabled={isTabled}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n renderingExtensions={renderingExtensions}\n onFocusLinkId={() => onFocusLinkId(qItem.linkId)}\n onSelectChange={handleChange}\n />\n );\n }\n\n default: {\n return (\n <Typography>\n Something has went wrong when parsing item {qItem.linkId} - {qItem.text}\n </Typography>\n );\n }\n }\n}\n\nexport default ChoiceRadioAnswerOptionItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from 'react';\nimport type { Coding, QuestionnaireItem } from 'fhir/r4';\nimport { useQuestionnaireStore } from '../stores';\n\ninterface UseCodingCalculatedExpression {\n calcExpUpdated: boolean;\n}\n\ninterface UseCodingCalculatedExpressionProps {\n qItem: QuestionnaireItem;\n valueInString: string;\n onChangeByCalcExpressionString: (newValueInString: string) => void;\n onChangeByCalcExpressionNull: () => void;\n}\n\n// TODO use this in all choice and open choice items if possible\nfunction useCodingCalculatedExpression(\n props: UseCodingCalculatedExpressionProps\n): UseCodingCalculatedExpression {\n const { qItem, valueInString, onChangeByCalcExpressionString, onChangeByCalcExpressionNull } =\n props;\n\n const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();\n\n const [calcExpUpdated, setCalcExpUpdated] = useState(false);\n\n useEffect(\n () => {\n const calcExpression = calculatedExpressions[qItem.linkId]?.find(\n (exp) => exp.from === 'item'\n );\n\n if (!calcExpression) {\n return;\n }\n\n // only update if calculated value is different from current value\n if (\n calcExpression.value !== valueInString &&\n (typeof calcExpression.value === 'string' ||\n typeof calcExpression.value === 'number' ||\n typeof calcExpression.value === 'object' ||\n calcExpression.value === null)\n ) {\n // update ui to show calculated value changes\n setCalcExpUpdated(true);\n const timeoutId = setTimeout(() => {\n setCalcExpUpdated(false);\n }, 500);\n\n // calculatedExpression value is null\n if (calcExpression.value === null) {\n onChangeByCalcExpressionNull();\n return () => clearTimeout(timeoutId);\n }\n\n // calculatedExpression value is object, check if it is a Coding object\n if (typeof calcExpression.value === 'object' && objectIsCoding(calcExpression.value)) {\n if (calcExpression.value.code) {\n onChangeByCalcExpressionString(calcExpression.value.code);\n return () => clearTimeout(timeoutId);\n }\n }\n\n // calculatedExpression value is a string or number\n const newValueString =\n typeof calcExpression.value === 'string'\n ? calcExpression.value\n : calcExpression.value.toString();\n\n onChangeByCalcExpressionString(newValueString);\n return () => clearTimeout(timeoutId);\n }\n },\n // Only trigger this effect if calculatedExpression of item changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [calculatedExpressions]\n );\n\n return { calcExpUpdated: calcExpUpdated };\n}\n\nexport function objectIsCoding(obj: any): obj is Coding {\n return obj && obj.code && typeof obj.code === 'string';\n}\n\nexport default useCodingCalculatedExpression;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport { useRendererStylingStore } from '../../../stores';\nimport { StandardRadio } from '../../Radio.styles';\n\ninterface ChoiceRadioSingleProps {\n value: string;\n label: string;\n readOnly: boolean;\n fullWidth: boolean;\n}\n\nfunction ChoiceRadioSingle(props: ChoiceRadioSingleProps) {\n const { value, label, readOnly, fullWidth } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n\n return (\n <FormControlLabel\n sx={{\n width: fullWidth ? '100%' : 'unset',\n ...(readOnly && {\n color: readOnlyVisualStyle === 'readonly' ? 'text.secondary' : undefined\n })\n }}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n aria-readonly={readOnly && readOnlyVisualStyle === 'readonly'}\n value={value}\n control={\n <StandardRadio size=\"small\" readOnly={readOnly && readOnlyVisualStyle === 'readonly'} />\n }\n label={label}\n />\n );\n}\n\nexport default ChoiceRadioSingle;\n","import { styled } from '@mui/material/styles';\nimport Radio from '@mui/material/Radio';\n\nexport const StandardRadio = styled(Radio, {\n shouldForwardProp: (prop) => prop !== 'readOnly'\n})<{ readOnly: boolean }>(({ theme, readOnly }) => ({\n ...(readOnly && {\n '&.MuiButtonBase-root': {\n '&.MuiRadio-root': {\n // Use text.disabled colour (same as disabled field) here because text.secondary is too dark, and 'rgb(220, 223, 228)' is too light\n color: theme.palette.text.disabled\n },\n '&:hover': {\n backgroundColor: theme.palette.action.hover\n }\n }\n })\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport ChoiceRadioSingle from '../ChoiceItems/ChoiceRadioSingle';\nimport type { QuestionnaireItemAnswerOption } from 'fhir/r4';\n\ninterface RadioOptionListProps {\n options: QuestionnaireItemAnswerOption[];\n readOnly: boolean;\n fullWidth: boolean;\n}\n\nfunction RadioOptionList(props: RadioOptionListProps) {\n const { options, readOnly, fullWidth } = props;\n\n return (\n <>\n {options.map((option) => {\n if (option['valueCoding']) {\n return (\n <ChoiceRadioSingle\n key={option.valueCoding.code ?? ''}\n value={option.valueCoding.code ?? ''}\n label={option.valueCoding.display ?? `${option.valueCoding.code}`}\n readOnly={readOnly}\n fullWidth={fullWidth}\n />\n );\n }\n\n if (option['valueString']) {\n return (\n <ChoiceRadioSingle\n key={option.valueString}\n value={option.valueString}\n label={option.valueString}\n readOnly={readOnly}\n fullWidth={fullWidth}\n />\n );\n }\n\n if (option['valueInteger']) {\n return (\n <ChoiceRadioSingle\n key={option.valueInteger}\n value={option.valueInteger.toString()}\n label={option.valueInteger.toString()}\n readOnly={readOnly}\n fullWidth={fullWidth}\n />\n );\n }\n\n return null;\n })}\n </>\n );\n}\n\nexport default RadioOptionList;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport FormGroup from '@mui/material/FormGroup';\nimport RadioGroup from '@mui/material/RadioGroup';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nexport const StyledFormGroup = styled(FormGroup)(() => ({\n marginBottom: 4\n}));\n\nexport const StyledRadioGroup = styled(RadioGroup)(() => ({\n marginBottom: 4\n}));\n\nexport const StyledRequiredTypography = styled(Typography)(({ theme }) => ({\n color: theme.palette.error.main,\n fontSize: '0.75rem',\n marginTop: 4\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { ChoiceItemOrientation } from '../../../interfaces/choice.enum';\nimport type { QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport RadioOptionList from '../ItemParts/RadioOptionList';\nimport { StyledRadioGroup, StyledRequiredTypography } from '../Item.styles';\nimport { getChoiceOrientation } from '../../../utils/choice';\nimport Box from '@mui/material/Box';\nimport FadingCheckIcon from '../ItemParts/FadingCheckIcon';\nimport ClearInputButton from '../ItemParts/ClearInputButton';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface ChoiceRadioAnswerOptionFieldsProps {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n valueRadio: string | null;\n feedback: string;\n readOnly: boolean;\n calcExpUpdated: boolean;\n onCheckedChange: (newValue: string) => void;\n onClear: () => void;\n}\n\nfunction ChoiceRadioAnswerOptionFields(props: ChoiceRadioAnswerOptionFieldsProps) {\n const {\n qItem,\n options,\n valueRadio,\n feedback,\n readOnly,\n calcExpUpdated,\n onCheckedChange,\n onClear\n } = props;\n\n const inputsFlexGrow = useRendererStylingStore.use.inputsFlexGrow();\n const hideClearButton = useRendererStylingStore.use.hideClearButton();\n\n const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Vertical;\n\n return (\n <>\n <Box\n display=\"flex\"\n sx={{\n justifyContent: 'space-between',\n alignItems: { xs: 'start', sm: 'center' },\n flexDirection: { xs: 'column', sm: 'row' }\n }}>\n <Box\n display=\"flex\"\n alignItems=\"center\"\n sx={inputsFlexGrow ? { width: '100%', flexWrap: 'nowrap' } : {}}>\n <StyledRadioGroup\n id={qItem.type + '-' + qItem.linkId}\n row={orientation === ChoiceItemOrientation.Horizontal}\n sx={inputsFlexGrow ? { width: '100%', flexWrap: 'nowrap' } : {}}\n onChange={(e) => {\n // If item.readOnly=true, do not allow any changes\n if (readOnly) {\n return;\n }\n\n onCheckedChange(e.target.value);\n }}\n value={valueRadio}\n data-test=\"q-item-radio-group\">\n <RadioOptionList options={options} readOnly={readOnly} fullWidth={inputsFlexGrow} />\n </StyledRadioGroup>\n\n <Box flexGrow={1} />\n\n <FadingCheckIcon fadeIn={calcExpUpdated} disabled={readOnly} />\n </Box>\n\n {hideClearButton ? null : (\n <ClearInputButton buttonShown={!!valueRadio} readOnly={readOnly} onClear={onClear} />\n )}\n </Box>\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </>\n );\n}\n\nexport default ChoiceRadioAnswerOptionFields;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Fade from '@mui/material/Fade';\nimport SyncIcon from '@mui/icons-material/Sync';\n\ninterface FadingCheckIconProps {\n fadeIn: boolean;\n disabled: boolean;\n}\n\nfunction FadingCheckIcon(props: FadingCheckIconProps) {\n const { fadeIn, disabled } = props;\n\n return (\n <Fade in={fadeIn} timeout={{ enter: 100, exit: 300 }}>\n <SyncIcon\n color=\"success\"\n fontSize=\"small\"\n sx={{ ...(disabled ? { color: 'text.disabled' } : null) }}\n />\n </Fade>\n );\n}\n\nexport default FadingCheckIcon;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { Tooltip } from '@mui/material';\nimport Button from '@mui/material/Button';\nimport { grey } from '@mui/material/colors';\nimport Fade from '@mui/material/Fade';\n\ninterface ClearInputButtonProps {\n buttonShown: boolean;\n readOnly: boolean;\n onClear: () => void;\n}\n\nfunction ClearInputButton(props: ClearInputButtonProps) {\n const { buttonShown, readOnly, onClear } = props;\n\n return (\n <Fade in={buttonShown} timeout={100}>\n <Tooltip title=\"Set question as unanswered\">\n <span\n style={{\n cursor: readOnly ? 'not-allowed' : 'pointer'\n }}>\n <Button\n sx={{\n color: grey['500'],\n '&:hover': { backgroundColor: grey['200'] }\n }}\n disabled={readOnly}\n onClick={onClear}>\n Clear\n </Button>\n </span>\n </Tooltip>\n </Fade>\n );\n}\n\nexport default ClearInputButton;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ReactNode } from 'react';\nimport React, { memo } from 'react';\nimport Typography from '@mui/material/Typography';\nimport { DisplayInstructionsWrapper } from './DisplayInstructions.styles';\n\ninterface DisplayInstructionsProps {\n readOnly: boolean;\n children?: ReactNode;\n}\n\nconst DisplayInstructions = memo(function DisplayInstructions(props: DisplayInstructionsProps) {\n const { readOnly, children } = props;\n\n return children ? (\n <DisplayInstructionsWrapper>\n <Typography variant=\"caption\" color={readOnly ? 'text.secondary' : 'text.primary'}>\n <>{children}</>\n </Typography>\n </DisplayInstructionsWrapper>\n ) : null;\n});\n\nexport default DisplayInstructions;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Box from '@mui/material/Box';\nimport { styled } from '@mui/material/styles';\n\nexport const DisplayInstructionsWrapper = styled(Box)(({ theme }) => ({\n color: theme.palette.text.secondary,\n marginBottom: '8px'\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ReactNode } from 'react';\nimport React from 'react';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport useRenderingExtensions from '../../../hooks/useRenderingExtensions';\nimport { useRendererStylingStore } from '../../../stores';\nimport DisplayInstructions from '../DisplayItem/DisplayInstructions';\nimport Grid from '@mui/material/Grid';\n\ninterface ItemFieldGridProps {\n qItem: QuestionnaireItem;\n readOnly: boolean;\n labelChildren?: ReactNode;\n fieldChildren?: ReactNode;\n feedback?: string;\n dateFeedback?: string;\n timeFeedback?: string;\n}\n\nfunction ItemFieldGrid(props: ItemFieldGridProps) {\n const { qItem, readOnly, labelChildren, fieldChildren } = props;\n\n const itemResponsive = useRendererStylingStore.use.itemResponsive();\n const { labelBreakpoints, fieldBreakpoints, columnGapPixels, rowGapPixels } = itemResponsive;\n\n const { displayInstructions } = useRenderingExtensions(qItem);\n\n return (\n <Grid container columnSpacing={columnGapPixels + 'px'} rowGap={rowGapPixels + 'px'}>\n <Grid size={{ ...labelBreakpoints }}>\n <>{labelChildren}</>\n </Grid>\n <Grid size={{ ...fieldBreakpoints }}>\n <>{fieldChildren}</>\n {/* Only show display instructions if there is no feedback of any type */}\n {!props.feedback && !props.dateFeedback && !props.timeFeedback && (\n <DisplayInstructions readOnly={readOnly}>{displayInstructions}</DisplayInstructions>\n )}\n </Grid>\n </Grid>\n );\n}\n\nexport default ItemFieldGrid;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { memo } from 'react';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport Box from '@mui/material/Box';\nimport { useRendererStylingStore } from '../../../stores/rendererStylingStore';\nimport useRenderingExtensions from '../../../hooks/useRenderingExtensions';\nimport RequiredAsterisk from './RequiredAsterisk';\nimport { getContextDisplays } from '../../../utils/tabs';\nimport ContextDisplayItem from './ContextDisplayItem';\nimport ItemTextSwitcher from './ItemTextSwitcher';\nimport Typography from '@mui/material/Typography';\nimport FlyoverItem from './FlyoverItem';\n\ninterface ItemLabelProps {\n qItem: QuestionnaireItem;\n readOnly: boolean;\n isDisplayItem?: boolean;\n parentStyles?: Record<string, string>;\n}\n\nconst ItemLabel = memo(function ItemLabel(props: ItemLabelProps) {\n const { qItem, readOnly, isDisplayItem, parentStyles } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const requiredIndicatorPosition = useRendererStylingStore.use.requiredIndicatorPosition();\n\n const { required, displayFlyover } = useRenderingExtensions(qItem);\n const contextDisplayItems = getContextDisplays(qItem);\n\n // is item is a display item, it should not use the \"label\" variant\n const component = isDisplayItem ? 'span' : 'label';\n const variant = isDisplayItem ? undefined : 'label';\n\n // Get text color from parent styles if available\n\n const readOnlyTextColor = readOnlyVisualStyle === 'disabled' ? 'text.disabled' : 'text.secondary';\n const textColor = parentStyles?.color || (readOnly ? readOnlyTextColor : 'text.primary');\n\n return (\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\">\n <Box position=\"relative\" display=\"flex\" flexGrow={1} alignItems=\"center\">\n {/* Required asterisk position is in front of text */}\n {required && requiredIndicatorPosition === 'start' ? (\n <RequiredAsterisk\n readOnly={readOnly}\n variant={variant}\n sx={{ position: 'absolute', top: 0, left: -8 }}>\n *\n </RequiredAsterisk>\n ) : null}\n\n {/* Label typography */}\n {/* Added 0.5 marginTop (4px) because item labels doesn't look in line with their fields */}\n {/* flexGrow: 1 is important if xhtml and markdown rendering has width: 100% */}\n <Typography\n component={component}\n variant={variant}\n htmlFor={qItem.type + '-' + qItem.linkId}\n color={textColor}\n sx={{ mt: 0.5, flexGrow: 1, ...(parentStyles || {}) }}>\n <ItemTextSwitcher qItem={qItem} />\n\n {/* Required asterisk position is behind text */}\n {required && requiredIndicatorPosition === 'end' ? (\n <RequiredAsterisk readOnly={readOnly} variant={variant}>\n *\n </RequiredAsterisk>\n ) : null}\n\n {/* Flyover */}\n {displayFlyover !== '' ? (\n <Typography component=\"span\" sx={{ ml: 0.75 }}>\n <FlyoverItem displayFlyover={displayFlyover} readOnly={readOnly} />\n </Typography>\n ) : null}\n </Typography>\n </Box>\n\n <Box display=\"flex\" columnGap={0.5}>\n {contextDisplayItems.map((item) => {\n return <ContextDisplayItem key={item.linkId} displayItem={item} />;\n })}\n </Box>\n </Box>\n );\n});\n\nexport default ItemLabel;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport ChoiceRadioAnswerOptionFields from './ChoiceRadioAnswerOptionFields';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport type { PropsWithIsRepeatedAttribute } from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface ChoiceRadioAnswerOptionViewProps extends PropsWithIsRepeatedAttribute {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n valueChoice: string | null;\n feedback: string;\n readOnly: boolean;\n calcExpUpdated: boolean;\n onCheckedChange: (linkId: string) => void;\n onFocusLinkId: () => void;\n onClear: () => void;\n}\n\nfunction ChoiceRadioAnswerOptionView(props: ChoiceRadioAnswerOptionViewProps) {\n const {\n qItem,\n options,\n valueChoice,\n feedback,\n isRepeated,\n readOnly,\n calcExpUpdated,\n onFocusLinkId,\n onCheckedChange,\n onClear\n } = props;\n\n if (isRepeated) {\n return (\n <ChoiceRadioAnswerOptionFields\n qItem={qItem}\n options={options}\n valueRadio={valueChoice}\n feedback={feedback}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n onCheckedChange={onCheckedChange}\n onClear={onClear}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-choice-radio-answer-option-box\"\n data-linkid={qItem.linkId}\n onClick={onFocusLinkId}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <ChoiceRadioAnswerOptionFields\n qItem={qItem}\n options={options}\n valueRadio={valueChoice}\n feedback={feedback}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n onCheckedChange={onCheckedChange}\n onClear={onClear}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default ChoiceRadioAnswerOptionView;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport type {\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport { findInAnswerOptions } from '../../../utils/choice';\nimport ChoiceSelectAnswerOptionFields from './ChoiceSelectAnswerOptionFields';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface ChoiceSelectAnswerOptionViewProps\n extends PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n valueChoice: string | null;\n feedback: string;\n readOnly: boolean;\n calcExpUpdated: boolean;\n onSelectChange: (newValue: QuestionnaireItemAnswerOption | null) => void;\n onFocusLinkId: () => void;\n}\n\nfunction ChoiceSelectAnswerOptionView(props: ChoiceSelectAnswerOptionViewProps) {\n const {\n qItem,\n options,\n valueChoice,\n feedback,\n isRepeated,\n isTabled,\n renderingExtensions,\n readOnly,\n calcExpUpdated,\n onFocusLinkId,\n onSelectChange\n } = props;\n\n const valueSelect: QuestionnaireItemAnswerOption | null = useMemo(\n () => findInAnswerOptions(options, valueChoice ?? '') ?? null,\n [options, valueChoice]\n );\n\n if (isRepeated) {\n return (\n <ChoiceSelectAnswerOptionFields\n qItem={qItem}\n options={options}\n valueSelect={valueSelect}\n feedback={feedback}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n onSelectChange={onSelectChange}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-choice-select-answer-option-box\"\n data-linkid={qItem.linkId}\n onClick={onFocusLinkId}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <ChoiceSelectAnswerOptionFields\n qItem={qItem}\n options={options}\n valueSelect={valueSelect}\n feedback={feedback}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n onSelectChange={onSelectChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default ChoiceSelectAnswerOptionView;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { styled } from '@mui/material/styles';\nimport TextField from '@mui/material/TextField';\n\n// Always use this accompanied by the TextField prop fullWidth\nexport const StandardTextField = styled(TextField, {\n shouldForwardProp: (prop) => prop !== 'isTabled' && prop !== 'textFieldWidth'\n})<{ isTabled: boolean; textFieldWidth: number }>(({ isTabled, textFieldWidth }) => ({\n // Set textFieldWidth (defaults to 320 in rendererStylingStore) as the standard width for a field\n // Set a theoretical infinite maxWidth (3000) if field is within a table to fill the table row\n maxWidth: !isTabled ? textFieldWidth : 3000,\n minWidth: 160\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { Fragment } from 'react';\nimport type { QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport type {\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport { StandardTextField } from '../Textfield.styles';\nimport FadingCheckIcon from '../ItemParts/FadingCheckIcon';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport { getAnswerOptionLabel } from '../../../utils/openChoice';\nimport { compareAnswerOptionValue } from '../../../utils/choice';\nimport { useRendererStylingStore } from '../../../stores';\nimport { StyledRequiredTypography } from '../Item.styles';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\n\ninterface ChoiceSelectAnswerOptionFieldsProps\n extends PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n valueSelect: QuestionnaireItemAnswerOption | null;\n feedback: string;\n readOnly: boolean;\n calcExpUpdated: boolean;\n onSelectChange: (newValue: QuestionnaireItemAnswerOption | null) => void;\n}\n\nfunction ChoiceSelectAnswerOptionFields(props: ChoiceSelectAnswerOptionFieldsProps) {\n const {\n qItem,\n options,\n valueSelect,\n feedback,\n readOnly,\n calcExpUpdated,\n isTabled,\n renderingExtensions,\n onSelectChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const { displayUnit, displayPrompt, entryFormat } = renderingExtensions;\n\n return (\n <>\n <Autocomplete\n id={qItem.type + '-' + qItem.linkId}\n value={valueSelect ?? null}\n options={options}\n getOptionLabel={(option) => getAnswerOptionLabel(option)}\n isOptionEqualToValue={(option, value) => compareAnswerOptionValue(option, value)}\n onChange={(_, newValue) => onSelectChange(newValue)}\n openOnFocus\n autoHighlight\n sx={{ maxWidth: !isTabled ? textFieldWidth : 3000, minWidth: 160, flexGrow: 1 }}\n size=\"small\"\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n renderInput={(params) => (\n <StandardTextField\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n label={displayPrompt}\n placeholder={entryFormat}\n {...params}\n slotProps={{\n input: {\n ...params.InputProps,\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <>\n {params.InputProps.endAdornment}\n <FadingCheckIcon fadeIn={calcExpUpdated} disabled={readOnly} />\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </>\n )\n }\n }}\n />\n )}\n />\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </>\n );\n}\n\nexport default ChoiceSelectAnswerOptionFields;\n","import React from 'react';\nimport Typography from '@mui/material/Typography';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface DisplayUnitTextProps {\n readOnly: boolean;\n children: string;\n}\n\nfunction DisplayUnitText(props: DisplayUnitTextProps) {\n const { readOnly, children } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n\n const readOnlyTextColor = readOnlyVisualStyle === 'disabled' ? 'text.disabled' : 'text.secondary';\n\n return (\n <Typography color={readOnly ? readOnlyTextColor : 'text.secondary'}>{children}</Typography>\n );\n}\n\nexport default DisplayUnitText;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getInputInvalidType, ValidationResult } from '../utils/validate';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport {\n getMaxQuantityValue,\n getMaxQuantityValueFeedback,\n getMaxValue,\n getMaxValueFeedback,\n getMinQuantityValue,\n getMinQuantityValueFeedback,\n getMinValue,\n getMinValueFeedback,\n getRegexValidation,\n getRequiredFeedback\n} from '../utils/itemControl';\nimport { structuredDataCapture } from 'fhir-sdc-helpers';\nimport { useQuestionnaireResponseStore, useQuestionnaireStore } from '../stores';\n\nfunction useValidationFeedback(\n qItem: QuestionnaireItem,\n feedbackFromParent: string | undefined,\n input: string\n): string {\n const invalidItems = useQuestionnaireResponseStore.use.invalidItems();\n const requiredItemsIsHighlighted = useQuestionnaireResponseStore.use.requiredItemsIsHighlighted();\n\n // Target constraint-based validation\n const targetConstraints = useQuestionnaireStore.use.targetConstraints();\n const targetConstraintLinkIds = useQuestionnaireStore.use.targetConstraintLinkIds();\n const targetConstraintKeys = targetConstraintLinkIds[qItem.linkId];\n if (targetConstraintKeys && targetConstraintKeys.length > 0) {\n for (const targetConstraintKey of targetConstraintKeys) {\n const targetConstraint = targetConstraints[targetConstraintKey];\n if (targetConstraint) {\n const { isEnabled, human } = targetConstraint;\n if (isEnabled) {\n return human;\n }\n }\n }\n }\n\n // Feedback from parent\n if (feedbackFromParent) {\n return feedbackFromParent;\n }\n\n // Required-based validation\n // User needs to manually invoke required items to be highlighted\n if (requiredItemsIsHighlighted) {\n const invalidOperationOutcome = invalidItems[qItem.linkId];\n if (invalidOperationOutcome) {\n const requiredIssue = invalidOperationOutcome.issue.find(\n (issue) => issue.code === 'required'\n );\n if (requiredIssue) {\n const requiredFeedback = getRequiredFeedback(qItem);\n return requiredFeedback ?? 'This field is required.';\n }\n }\n }\n\n // Extension-based validation\n const regexValidation = getRegexValidation(qItem);\n const minLength = structuredDataCapture.getMinLength(qItem);\n const maxLength = qItem.maxLength;\n const maxDecimalPlaces = structuredDataCapture.getMaxDecimalPlaces(qItem);\n const minValue = getMinValue(qItem);\n const maxValue = getMaxValue(qItem);\n const minQuantityValue = getMinQuantityValue(qItem); // gets the minQuantity value from the questionnaire item\n const maxQuantityValue = getMaxQuantityValue(qItem); // gets the maxQuantity value from the questionnaire item\n\n const invalidType = getInputInvalidType({\n qItem,\n input,\n regexValidation,\n minLength,\n maxLength,\n maxDecimalPlaces,\n minValue,\n maxValue,\n minQuantityValue, // Min Quantity validation type\n maxQuantityValue // Max Quantity validation type\n });\n\n if (!invalidType) {\n return '';\n } else {\n //invalid type exists, so we proceed\n }\n\n if (invalidType === ValidationResult.regex && regexValidation) {\n return `Input should match the specified regex ${regexValidation.expression}`;\n }\n\n // Test min character limit\n if (invalidType === ValidationResult.minLength && typeof minLength === 'number') {\n return `Enter at least ${minLength} characters.`;\n }\n\n // Test max character limit\n if (invalidType === ValidationResult.maxLength && typeof maxLength === 'number') {\n return `Input exceeds maximum character limit of ${maxLength}.`;\n }\n\n // Test max decimal places limit\n if (invalidType === ValidationResult.maxDecimalPlaces && typeof maxDecimalPlaces === 'number') {\n return `Input exceeds maximum decimal places limit of ${maxDecimalPlaces}.`;\n }\n\n // Test min value\n if (\n invalidType === ValidationResult.minValue &&\n (typeof minValue === 'string' || typeof minValue === 'number')\n ) {\n const minValueFeedback = getMinValueFeedback(qItem);\n return minValueFeedback ?? `Input is lower than the expected minimum value of ${minValue}.`;\n }\n\n // Test max value\n if (\n invalidType === ValidationResult.maxValue &&\n (typeof maxValue === 'string' || typeof maxValue === 'number')\n ) {\n const maxValueFeedback = getMaxValueFeedback(qItem);\n return maxValueFeedback ?? `Input exceeds permitted maximum value of ${maxValue}.`;\n }\n\n // Test min quantity\n if (invalidType === ValidationResult.minQuantityValue && typeof minQuantityValue === 'number') {\n const minQuantityFeedback = getMinQuantityValueFeedback(qItem); // get the feedback for minQuantity if it exists\n return (\n minQuantityFeedback ??\n `Input is lower than the expected minimum quantity value of ${minQuantityValue}.`\n );\n }\n\n // Test max quantity\n if (invalidType === ValidationResult.maxQuantityValue && typeof maxQuantityValue === 'number') {\n const maxQuantityFeedback = getMaxQuantityValueFeedback(qItem); // get the feedback for maxQuantity if it exists\n return (\n maxQuantityFeedback ??\n `Input exceeds permitted maximum quantity value of ${maxQuantityValue}.`\n );\n }\n return '';\n}\n\nexport default useValidationFeedback;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\n\nimport type {\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponseItem\n} from 'fhir/r4';\nimport { findInAnswerOptions, getQrChoiceValue } from '../../../utils/choice';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useCodingCalculatedExpression from '../../../hooks/useCodingCalculatedExpression';\nimport ChoiceSelectAnswerOptionView from './ChoiceSelectAnswerOptionView';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\n\n// TODO eventually merge this item with ChoiceRadioAnswerOptionItem\ninterface ChoiceSelectAnswerOptionItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction ChoiceSelectAnswerOptionItem(props: ChoiceSelectAnswerOptionItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks - there's no string-based input here\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrChoice = qrItem ?? createEmptyQrItem(qItem, answerKey);\n const valueChoice = getQrChoiceValue(qrChoice);\n\n const options = qItem.answerOption ?? [];\n\n // Process calculated expressions\n const { calcExpUpdated } = useCodingCalculatedExpression({\n qItem: qItem,\n valueInString: valueChoice ?? '',\n onChangeByCalcExpressionString: (newValueString: string) => {\n handleChange(newValueString);\n },\n onChangeByCalcExpressionNull: () => {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n });\n\n function handleChange(newValue: QuestionnaireItemAnswerOption | string | null) {\n // No options present or newValue is type null\n if (options.length === 0 || newValue === null) {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n // newValue is type string\n if (typeof newValue === 'string') {\n const qrAnswer = findInAnswerOptions(options, newValue);\n onQrItemChange(\n qrAnswer\n ? { ...createEmptyQrItem(qItem, answerKey), answer: [{ ...qrAnswer, id: answerKey }] }\n : createEmptyQrItem(qItem, answerKey)\n );\n return;\n }\n\n // newValue is type QuestionnaireItemAnswerOption\n onQrItemChange(\n newValue\n ? { ...createEmptyQrItem(qItem, answerKey), answer: [{ ...newValue, id: answerKey }] }\n : createEmptyQrItem(qItem, answerKey)\n );\n }\n\n return (\n <ChoiceSelectAnswerOptionView\n qItem={qItem}\n options={options}\n valueChoice={valueChoice}\n feedback={feedback}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n onFocusLinkId={() => onFocusLinkId(qItem.linkId)}\n onSelectChange={handleChange}\n />\n );\n}\n\nexport default ChoiceSelectAnswerOptionItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport { StandardCheckbox } from '../../Checkbox.styles';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface Props {\n value: string;\n label: string;\n readOnly: boolean;\n isChecked: boolean;\n onCheckedChange: (value: string) => unknown;\n}\n\nfunction CheckboxSingle(props: Props) {\n const { value, label, readOnly, isChecked, onCheckedChange } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n\n return (\n <FormControlLabel\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n aria-readonly={readOnly && readOnlyVisualStyle === 'readonly'}\n control={\n <StandardCheckbox\n size=\"small\"\n checked={isChecked}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n onChange={() => {\n // If item.readOnly=true, do not allow any changes\n if (readOnly) {\n return;\n }\n\n onCheckedChange(value);\n }}\n />\n }\n label={label}\n />\n );\n}\n\nexport default CheckboxSingle;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { QuestionnaireItemAnswerOption, QuestionnaireResponseItemAnswer } from 'fhir/r4';\nimport CheckboxSingle from '../ItemParts/CheckboxSingle';\n\ninterface CheckboxOptionListProps {\n options: QuestionnaireItemAnswerOption[];\n answers: QuestionnaireResponseItemAnswer[];\n readOnly: boolean;\n onCheckedChange: (newValue: string) => void;\n}\n\nfunction CheckboxOptionList(props: CheckboxOptionListProps) {\n const { options, answers, readOnly, onCheckedChange } = props;\n\n return (\n <>\n {options.map((option) => {\n if (option['valueCoding']) {\n return (\n <CheckboxSingle\n key={option.valueCoding.code ?? option.valueCoding.display ?? ''}\n value={option.valueCoding.code ?? option.valueCoding.display ?? ''}\n label={option.valueCoding.display ?? `${option.valueCoding.code}`}\n readOnly={readOnly}\n isChecked={answers.some(\n (answer) => JSON.stringify(answer) === JSON.stringify(option)\n )}\n onCheckedChange={onCheckedChange}\n />\n );\n }\n\n if (option['valueString']) {\n return (\n <CheckboxSingle\n key={option.valueString}\n value={option.valueString}\n label={option.valueString}\n readOnly={readOnly}\n isChecked={answers.some((answer) => answer.valueString === option.valueString)}\n onCheckedChange={onCheckedChange}\n />\n );\n }\n\n if (option['valueInteger']) {\n return (\n <CheckboxSingle\n key={option.valueInteger}\n value={option.valueInteger.toString()}\n label={option.valueInteger.toString()}\n readOnly={readOnly}\n isChecked={answers.some((answer) => answer.valueInteger === option.valueInteger)}\n onCheckedChange={onCheckedChange}\n />\n );\n }\n\n return null;\n })}\n </>\n );\n}\n\nexport default CheckboxOptionList;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type {\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport { getChoiceOrientation } from '../../../utils/choice';\nimport { ChoiceItemOrientation } from '../../../interfaces/choice.enum';\nimport CheckboxOptionList from './CheckboxOptionList';\nimport { StyledFormGroup, StyledRequiredTypography } from '../Item.styles';\nimport { Box } from '@mui/material';\n\ninterface ChoiceCheckboxAnswerOptionFieldsProps {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n answers: QuestionnaireResponseItemAnswer[];\n feedback: string;\n readOnly: boolean;\n onCheckedChange: (newValue: string) => void;\n}\n\nfunction ChoiceCheckboxAnswerOptionFields(props: ChoiceCheckboxAnswerOptionFieldsProps) {\n const { qItem, options, answers, feedback, readOnly, onCheckedChange } = props;\n\n const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Vertical;\n\n if (options.length > 0) {\n return (\n <Box id={qItem.type + '-' + qItem.linkId}>\n <StyledFormGroup row={orientation === ChoiceItemOrientation.Horizontal}>\n <CheckboxOptionList\n options={options}\n answers={answers}\n readOnly={readOnly}\n onCheckedChange={onCheckedChange}\n />\n </StyledFormGroup>\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </Box>\n );\n }\n\n return null;\n}\n\nexport default ChoiceCheckboxAnswerOptionFields;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { updateChoiceCheckboxAnswers } from '../../../utils/choice';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport DisplayInstructions from '../DisplayItem/DisplayInstructions';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport ChoiceCheckboxAnswerOptionFields from './ChoiceCheckboxAnswerOptionFields';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface ChoiceCheckboxAnswerOptionItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction ChoiceCheckboxAnswerOptionItem(props: ChoiceCheckboxAnswerOptionItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n renderingExtensions,\n showMinimalView = false,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrChoiceCheckbox = qrItem ?? createEmptyQrItem(qItem, answerKey);\n const answers = qrChoiceCheckbox.answer ?? [];\n\n const { displayInstructions } = renderingExtensions;\n\n // TODO Process calculated expressions\n // This requires its own hook, because in the case of multi-select, we need to check if the value is already checked to prevent an infinite loop\n // This will be done after the choice/open-choice refactoring\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n const options = qItem.answerOption ?? [];\n\n // Event handlers\n function handleCheckedChange(changedValue: string) {\n if (options.length === 0) {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n const updatedQrChoiceCheckbox = updateChoiceCheckboxAnswers(\n changedValue,\n answers,\n options,\n qrChoiceCheckbox,\n isRepeated,\n answerKey\n );\n\n if (updatedQrChoiceCheckbox) {\n onQrItemChange(updatedQrChoiceCheckbox);\n }\n }\n\n if (showMinimalView) {\n return (\n <>\n <ChoiceCheckboxAnswerOptionFields\n qItem={qItem}\n options={options}\n answers={answers}\n feedback={feedback}\n readOnly={readOnly}\n onCheckedChange={handleCheckedChange}\n />\n <DisplayInstructions readOnly={readOnly}>{displayInstructions}</DisplayInstructions>\n </>\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-choice-checkbox-answer-option-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <ChoiceCheckboxAnswerOptionFields\n qItem={qItem}\n options={options}\n answers={answers}\n feedback={feedback}\n readOnly={readOnly}\n onCheckedChange={handleCheckedChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default ChoiceCheckboxAnswerOptionItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport type { Coding, QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\n\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport useDebounce from '../../../hooks/useDebounce';\nimport useTerminologyServerQuery from '../../../hooks/useTerminologyServerQuery';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport { AUTOCOMPLETE_DEBOUNCE_DURATION } from '../../../utils/debounce';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ChoiceAutocompleteField from './ChoiceAutocompleteField';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport type { AlertColor } from '@mui/material/Alert';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface ChoiceAutocompleteItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction ChoiceAutocompleteItem(props: ChoiceAutocompleteItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrChoice = qrItem ?? createEmptyQrItem(qItem, answerKey);\n\n let valueCoding: Coding | undefined;\n if (qrChoice.answer) {\n valueCoding = qrChoice.answer[0].valueCoding;\n }\n\n const maxList = 10;\n\n const [input, setInput] = useState('');\n const debouncedInput = useDebounce(input, AUTOCOMPLETE_DEBOUNCE_DURATION);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const validationFeedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n const {\n options,\n loading,\n feedback: terminologyFeedback\n } = useTerminologyServerQuery(qItem, maxList, input, debouncedInput);\n\n let feedback: { message: string; color: AlertColor } | null = null;\n if (terminologyFeedback) {\n feedback = terminologyFeedback;\n } else if (validationFeedback !== '') {\n feedback = { message: validationFeedback, color: 'error' };\n }\n\n if (!qItem.answerValueSet) {\n return null;\n }\n\n // Event handlers\n function handleValueChange(newValue: Coding | null) {\n if (newValue === null) {\n setInput('');\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueCoding: newValue }]\n });\n }\n\n if (isRepeated) {\n return (\n <ChoiceAutocompleteField\n qItem={qItem}\n options={options}\n valueCoding={valueCoding ?? null}\n loading={loading}\n feedback={feedback}\n readOnly={readOnly}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n onInputChange={setInput}\n onValueChange={handleValueChange}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-choice-autocomplete-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <ChoiceAutocompleteField\n qItem={qItem}\n options={options}\n valueCoding={valueCoding ?? null}\n loading={loading}\n feedback={feedback}\n readOnly={readOnly}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n onInputChange={setInput}\n onValueChange={handleValueChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default ChoiceAutocompleteItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from 'react';\n\n// Lifted from https://usehooks.com/useDebounce/\nfunction useDebounce(value: string, delay: number): string {\n // State and setters for debounced value\n const [debouncedValue, setDebouncedValue] = useState<string>(value);\n\n useEffect(\n () => {\n // Update debounced value after delay\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n\n // Cancel the timeout if value changes (also on delay change or unmount)\n // This is how we prevent debounced value from updating if value is changed ...\n // .. within the delay period. Timeout gets cleared and restarted.\n return () => {\n clearTimeout(handler);\n };\n },\n [value, delay] // Only re-call effect if value or delay changes\n );\n\n return debouncedValue;\n}\n\nexport default useDebounce;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Coding, QuestionnaireItem, ValueSet } from 'fhir/r4';\nimport { getTerminologyServerUrl, getValueSetCodings, getValueSetPromise } from '../utils/valueSet';\n\nimport type { AlertColor } from '@mui/material/Alert';\nimport { useQuestionnaireStore, useTerminologyServerStore } from '../stores';\nimport { useQuery } from '@tanstack/react-query';\n\nfunction useTerminologyServerQuery(\n qItem: QuestionnaireItem,\n maxList: number,\n input: string,\n searchTerm: string\n): { options: Coding[]; loading: boolean; feedback?: { message: string; color: AlertColor } } {\n const processedValueSets = useQuestionnaireStore.use.processedValueSets();\n const itemPreferredTerminologyServers =\n useQuestionnaireStore.use.itemPreferredTerminologyServers();\n const defaultTerminologyServerUrl = useTerminologyServerStore.use.url();\n\n let fullUrl = '';\n let options: Coding[] = [];\n let feedback: { message: string; color: AlertColor } | undefined;\n\n if (input.length === 0) {\n feedback = undefined;\n }\n\n if (searchTerm.length < 1 && searchTerm.length > 0) {\n feedback = { message: 'Enter at least 2 characters to search for results.', color: 'info' };\n }\n\n // Restructure url to include filter and count parameters\n let answerValueSetUrl = qItem.answerValueSet;\n if (answerValueSetUrl) {\n if (answerValueSetUrl.startsWith('#')) {\n answerValueSetUrl = answerValueSetUrl.slice(1);\n }\n\n // attempt to get url from contained value sets when loading questionnaire\n if (processedValueSets[answerValueSetUrl]?.updatableValueSetUrl) {\n answerValueSetUrl = processedValueSets[answerValueSetUrl].updatableValueSetUrl;\n }\n\n const urlWithTrailingAmpersand =\n answerValueSetUrl + (answerValueSetUrl[answerValueSetUrl.length - 1] !== '&' ? '&' : '');\n fullUrl = urlWithTrailingAmpersand + 'filter=' + searchTerm + '&count=' + maxList;\n }\n\n // Perform query\n const preferredTerminologyServerUrl = itemPreferredTerminologyServers[qItem.linkId];\n const terminologyServerUrl =\n getTerminologyServerUrl(qItem) ?? preferredTerminologyServerUrl ?? defaultTerminologyServerUrl;\n\n const { isFetching, error, data } = useQuery<ValueSet>({\n queryKey: ['expandValueSet', fullUrl],\n queryFn: () => getValueSetPromise(fullUrl, terminologyServerUrl),\n enabled: searchTerm.length >= 2 && answerValueSetUrl !== undefined\n });\n\n if (error) {\n console.warn('Ontoserver query failed. Details below: \\n' + error);\n feedback = {\n message: 'An error occurred. Try again later or try searching for a different term.',\n color: 'error'\n };\n }\n\n if (data) {\n if (data.expansion?.total !== 0) {\n options = getValueSetCodings(data);\n } else {\n feedback = {\n message: \"We couldn't seem to find anything. Try searching for a different term.\",\n color: 'warning'\n };\n }\n }\n\n return { options, loading: isFetching, feedback };\n}\nexport default useTerminologyServerQuery;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const DEBOUNCE_DURATION = 300;\n\nexport const AUTOCOMPLETE_DEBOUNCE_DURATION = 300;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport Fade from '@mui/material/Fade';\nimport Tooltip from '@mui/material/Tooltip';\nimport type { Coding, QuestionnaireItem } from 'fhir/r4';\nimport { StandardTextField } from '../Textfield.styles';\nimport SearchIcon from '@mui/icons-material/Search';\nimport InfoIcon from '@mui/icons-material/Info';\nimport WarningAmberIcon from '@mui/icons-material/WarningAmber';\nimport DoneIcon from '@mui/icons-material/Done';\nimport ErrorIcon from '@mui/icons-material/Error';\nimport type {\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { AlertColor } from '@mui/material/Alert';\nimport { useRendererStylingStore } from '../../../stores';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\n\ninterface ChoiceAutocompleteFieldsProps\n extends PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute {\n qItem: QuestionnaireItem;\n options: Coding[];\n valueCoding: Coding | null;\n loading: boolean;\n feedback: { message: string; color: AlertColor } | null;\n readOnly: boolean;\n onInputChange: (newInput: string) => void;\n onValueChange: (newValue: Coding | null) => void;\n}\n\nfunction ChoiceAutocompleteField(props: ChoiceAutocompleteFieldsProps) {\n const {\n qItem,\n options,\n valueCoding,\n loading,\n feedback,\n readOnly,\n isTabled,\n renderingExtensions,\n onInputChange,\n onValueChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const { displayUnit, displayPrompt, entryFormat } = renderingExtensions;\n\n return (\n <Autocomplete\n id={qItem.type + '-' + qItem.linkId}\n value={valueCoding ?? null}\n options={options}\n getOptionLabel={(option) => option.display ?? `${option.code}`}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n loading={loading}\n loadingText={'Fetching results...'}\n clearOnEscape\n autoHighlight\n onChange={(_, newValue) => onValueChange(newValue)}\n sx={{ maxWidth: !isTabled ? textFieldWidth : 3000, minWidth: 160, flexGrow: 1 }}\n filterOptions={(x) => x}\n renderInput={(params) => (\n <StandardTextField\n {...params}\n onChange={(e) => onInputChange(e.target.value)}\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n label={displayPrompt}\n size=\"small\"\n placeholder={entryFormat}\n slotProps={{\n input: {\n ...params.InputProps,\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n startAdornment: (\n <>\n {!valueCoding ? <SearchIcon fontSize=\"small\" sx={{ ml: 0.5 }} /> : null}\n {params.InputProps.startAdornment}\n </>\n ),\n endAdornment: (\n <>\n {loading ? (\n <CircularProgress color=\"inherit\" size={16} />\n ) : feedback ? (\n <Fade in={!!feedback} timeout={300}>\n <Tooltip title={feedback.message} arrow sx={{ ml: 1 }}>\n {\n {\n info: <InfoIcon fontSize=\"small\" color=\"info\" />,\n warning: <WarningAmberIcon fontSize=\"small\" color=\"warning\" />,\n success: <DoneIcon fontSize=\"small\" color=\"success\" />,\n error: <ErrorIcon fontSize=\"small\" color=\"error\" />\n }[feedback.color]\n }\n </Tooltip>\n </Fade>\n ) : null}\n {params.InputProps.endAdornment}\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </>\n )\n }\n }}\n />\n )}\n />\n );\n}\n\nexport default ChoiceAutocompleteField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useMemo } from 'react';\n\nimport type { Coding, QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport useValueSetCodings from '../../../hooks/useValueSetCodings';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport ChoiceSelectAnswerValueSetFields from './ChoiceSelectAnswerValueSetFields';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useCodingCalculatedExpression from '../../../hooks/useCodingCalculatedExpression';\nimport { convertCodingsToAnswerOptions, findInAnswerOptions } from '../../../utils/choice';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface ChoiceSelectAnswerValueSetItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction ChoiceSelectAnswerValueSetItem(props: ChoiceSelectAnswerValueSetItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrChoiceSelect = qrItem ?? createEmptyQrItem(qItem, answerKey);\n\n let valueCoding: Coding | null = null;\n if (qrChoiceSelect.answer) {\n valueCoding = qrChoiceSelect.answer[0].valueCoding ?? null;\n }\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n // Get codings/options from valueSet\n const { codings, terminologyError, dynamicCodingsUpdated } = useValueSetCodings(qItem);\n\n valueCoding = useMemo(() => {\n const updatedValueCoding = codings.find(\n (queriedCoding) => queriedCoding.code === valueCoding?.code\n );\n return updatedValueCoding ?? valueCoding;\n }, [codings, valueCoding]);\n\n // Check and remove populated answer if it is a string\n // NOTE: $populate will try to populate answer as valueCoding,\n // but will fail if answer provided is not within options\n useEffect(\n () => {\n if (qrChoiceSelect.answer && qrChoiceSelect.answer[0].valueString) {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n },\n // Only run effect once - on populate\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n\n const answerOptions = useMemo(() => convertCodingsToAnswerOptions(codings), [codings]);\n\n // Process calculated expressions\n const { calcExpUpdated } = useCodingCalculatedExpression({\n qItem: qItem,\n valueInString: valueCoding?.code ?? valueCoding?.display ?? '',\n onChangeByCalcExpressionString: (newValueString) => {\n if (codings.length > 0) {\n const qrAnswer = findInAnswerOptions(answerOptions, newValueString);\n onQrItemChange(\n qrAnswer\n ? { ...createEmptyQrItem(qItem, answerKey), answer: [{ ...qrAnswer, id: answerKey }] }\n : createEmptyQrItem(qItem, answerKey)\n );\n }\n },\n onChangeByCalcExpressionNull: () => {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n });\n\n // Event handlers\n function handleChange(newValue: Coding | null) {\n if (newValue) {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueCoding: newValue }]\n });\n return;\n }\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n\n if (isRepeated) {\n return (\n <ChoiceSelectAnswerValueSetFields\n qItem={qItem}\n codings={codings}\n valueCoding={valueCoding}\n terminologyError={terminologyError}\n feedback={feedback}\n readOnly={readOnly}\n expressionUpdated={calcExpUpdated || dynamicCodingsUpdated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n onSelectChange={handleChange}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-choice-select-answer-value-set-box\"\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <ChoiceSelectAnswerValueSetFields\n qItem={qItem}\n codings={codings}\n valueCoding={valueCoding}\n terminologyError={terminologyError}\n feedback={feedback}\n readOnly={readOnly}\n expressionUpdated={calcExpUpdated || dynamicCodingsUpdated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n onSelectChange={handleChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default ChoiceSelectAnswerValueSetItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useMemo, useState } from 'react';\nimport type { Coding, FhirResource, QuestionnaireItem, ValueSet } from 'fhir/r4';\nimport {\n getResourceFromLaunchContext,\n getTerminologyServerUrl,\n getValueSetCodings,\n getValueSetPromise\n} from '../utils/valueSet';\nimport { getAnswerExpression } from '../utils/getExpressionsFromItem';\nimport fhirpath from 'fhirpath';\nimport fhirpath_r4_model from 'fhirpath/fhir-context/r4';\nimport { useQuestionnaireStore, useSmartConfigStore, useTerminologyServerStore } from '../stores';\nimport { addDisplayToCodingArray } from '../utils/questionnaireStoreUtils/addDisplayToCodings';\n\nexport interface TerminologyError {\n error: Error | null;\n answerValueSet: string;\n}\n\nfunction useValueSetCodings(qItem: QuestionnaireItem): {\n codings: Coding[];\n terminologyError: TerminologyError;\n dynamicCodingsUpdated: boolean;\n} {\n const patient = useSmartConfigStore.use.patient();\n const user = useSmartConfigStore.use.user();\n const encounter = useSmartConfigStore.use.encounter();\n\n const launchContexts = useQuestionnaireStore.use.launchContexts();\n const processedValueSets = useQuestionnaireStore.use.processedValueSets();\n const cachedValueSetCodings = useQuestionnaireStore.use.cachedValueSetCodings();\n const addCodingToCache = useQuestionnaireStore.use.addCodingToCache();\n const { xFhirQueryVariables } = useQuestionnaireStore.use.variables();\n const itemPreferredTerminologyServers =\n useQuestionnaireStore.use.itemPreferredTerminologyServers();\n\n const defaultTerminologyServerUrl = useTerminologyServerStore.use.url();\n\n const answerValueSetUrl = qItem.answerValueSet;\n let initialCodings = useMemo(() => {\n // set options from cached answer options if present\n if (answerValueSetUrl) {\n let valueSetUrl = answerValueSetUrl;\n\n // answerValueSetUrl is a reference to a contained value set\n // If found, return early\n if (valueSetUrl.startsWith('#')) {\n const valueSetReference = answerValueSetUrl.slice(1);\n if (cachedValueSetCodings[valueSetReference]) {\n return cachedValueSetCodings[valueSetReference];\n }\n }\n\n // Get updatableValueSetUrl and use it as the current valueSetUrl\n if (processedValueSets[valueSetUrl]?.updatableValueSetUrl) {\n valueSetUrl = processedValueSets[valueSetUrl].updatableValueSetUrl;\n }\n\n // attempt to get codings from cached queried value sets\n if (cachedValueSetCodings[valueSetUrl]) {\n return cachedValueSetCodings[valueSetUrl];\n }\n }\n\n return [];\n }, [cachedValueSetCodings, processedValueSets, answerValueSetUrl]);\n\n // Attempt to get codings from answer expression\n const answerExpression = getAnswerExpression(qItem)?.expression;\n initialCodings = useMemo(() => {\n if (initialCodings.length === 0 && answerExpression) {\n const variable = answerExpression.substring(\n answerExpression.indexOf('%') + 1,\n answerExpression.indexOf('.')\n );\n const contextMap: Record<string, FhirResource> = {};\n\n // get answer expression resource from launch contexts\n if (launchContexts[variable]) {\n const resourceType = launchContexts[variable].extension[1].valueCode;\n const resource = getResourceFromLaunchContext(resourceType, patient, user, encounter);\n if (resource) {\n contextMap[variable] = resource;\n }\n } else if (xFhirQueryVariables[variable]) {\n const resource = xFhirQueryVariables[variable].result;\n if (resource) {\n contextMap[variable] = resource;\n }\n }\n\n if (contextMap[variable]) {\n try {\n const evaluated = fhirpath.evaluate({}, answerExpression, contextMap, fhirpath_r4_model, {\n async: false\n });\n\n // Check for Promise and throw an error\n if (evaluated instanceof Promise) {\n throw new Error(\n 'Unexpected Promise returned from fhirpath.evaluate in the useValueSetCodings hook. Expected synchronous evaluation.'\n );\n }\n\n if (evaluated[0].system || evaluated[0].code) {\n // determine if the evaluated array is a coding array\n return evaluated;\n } else if (evaluated[0].coding) {\n // determine and return if the evaluated array is a codeable concept\n return evaluated[0].coding;\n }\n } catch (e) {\n console.warn(e.message);\n }\n }\n }\n\n return initialCodings;\n }, [\n answerExpression,\n encounter,\n initialCodings,\n launchContexts,\n patient,\n user,\n xFhirQueryVariables\n ]);\n\n const [codings, setCodings] = useState<Coding[]>(initialCodings);\n const [serverError, setServerError] = useState<Error | null>(null);\n const [dynamicCodingsUpdated, setDynamicCodingsUpdated] = useState(false);\n\n const codingsCount = codings.length;\n const preferredTerminologyServerUrl = itemPreferredTerminologyServers[qItem.linkId];\n const terminologyServerUrl =\n getTerminologyServerUrl(qItem) ?? preferredTerminologyServerUrl ?? defaultTerminologyServerUrl;\n\n // Get options from parameterised/dynamic value sets when the updatableValueSetUrl changes (p-param is updated via fhirpath)\n const updatableValueSetUrl = processedValueSets[answerValueSetUrl ?? '']?.updatableValueSetUrl;\n useEffect(\n () => {\n if (!qItem.answerValueSet || !qItem._answerValueSet) {\n return;\n }\n\n if (!updatableValueSetUrl) {\n return;\n }\n\n // Update ui to show calculated value changes\n setDynamicCodingsUpdated(true);\n const timeoutId = setTimeout(() => {\n setDynamicCodingsUpdated(false);\n }, 500);\n\n // attempt to get codings from cached queried value sets\n if (cachedValueSetCodings[updatableValueSetUrl]) {\n setCodings(cachedValueSetCodings[updatableValueSetUrl]);\n return () => clearTimeout(timeoutId);\n }\n\n const promise = getValueSetPromise(updatableValueSetUrl, terminologyServerUrl);\n if (promise) {\n promise\n .then(async (valueSet: ValueSet) => {\n const newCodings = getValueSetCodings(valueSet);\n addDisplayToCodingArray(newCodings, terminologyServerUrl)\n .then((codingsWithDisplay) => {\n if (codingsWithDisplay.length > 0) {\n addCodingToCache(updatableValueSetUrl, codingsWithDisplay);\n setCodings(newCodings);\n } else {\n addCodingToCache(updatableValueSetUrl, codingsWithDisplay);\n setCodings([]);\n }\n return () => clearTimeout(timeoutId);\n })\n .catch((error: Error) => {\n setServerError(error);\n return () => clearTimeout(timeoutId);\n });\n })\n .catch((error: Error) => {\n setServerError(error);\n return () => clearTimeout(timeoutId);\n });\n }\n },\n // Omit clearAnswer from dependencies to avoid infinite loop\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [addCodingToCache, cachedValueSetCodings, qItem, terminologyServerUrl, updatableValueSetUrl]\n );\n\n // Acts as a fallback - get options from answerValueSet in real-time if it's not pre-processed or cached which is very unlikely\n useEffect(() => {\n const valueSetUrl = qItem.answerValueSet;\n if (!valueSetUrl || codingsCount > 0) {\n return;\n }\n\n const promise = getValueSetPromise(valueSetUrl, terminologyServerUrl);\n if (promise) {\n promise\n .then(async (valueSet: ValueSet) => {\n const newCodings = getValueSetCodings(valueSet);\n addDisplayToCodingArray(newCodings, terminologyServerUrl)\n .then((codingsWithDisplay) => {\n if (codingsWithDisplay.length > 0) {\n addCodingToCache(valueSetUrl, codingsWithDisplay);\n setCodings(newCodings);\n }\n })\n .catch((error: Error) => {\n setServerError(error);\n });\n })\n .catch((error: Error) => {\n setServerError(error);\n });\n }\n }, [addCodingToCache, codingsCount, qItem, terminologyServerUrl]);\n\n return {\n codings,\n terminologyError: { error: serverError, answerValueSet: answerValueSetUrl ?? '' },\n dynamicCodingsUpdated\n };\n}\n\nexport default useValueSetCodings;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport { StandardTextField } from '../Textfield.styles';\nimport { StyledAlert } from '../../Alert.styles';\nimport ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';\nimport Typography from '@mui/material/Typography';\nimport type { Coding, QuestionnaireItem } from 'fhir/r4';\nimport type {\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { TerminologyError } from '../../../hooks/useValueSetCodings';\nimport FadingCheckIcon from '../ItemParts/FadingCheckIcon';\nimport { useRendererStylingStore } from '../../../stores';\nimport { StyledRequiredTypography } from '../Item.styles';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\n\ninterface ChoiceSelectAnswerValueSetFieldsProps\n extends PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute {\n qItem: QuestionnaireItem;\n codings: Coding[];\n valueCoding: Coding | null;\n terminologyError: TerminologyError;\n feedback: string;\n readOnly: boolean;\n expressionUpdated: boolean;\n onSelectChange: (newValue: Coding | null) => void;\n}\n\nfunction ChoiceSelectAnswerValueSetFields(props: ChoiceSelectAnswerValueSetFieldsProps) {\n const {\n qItem,\n codings,\n valueCoding,\n terminologyError,\n feedback,\n readOnly,\n expressionUpdated,\n isTabled,\n renderingExtensions,\n onSelectChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const { displayUnit, displayPrompt, entryFormat } = renderingExtensions;\n\n if (codings.length > 0) {\n return (\n <>\n <Autocomplete\n id={qItem.type + '-' + qItem.linkId}\n options={codings}\n getOptionLabel={(option) => option.display ?? `${option.code}`}\n value={valueCoding ?? null}\n onChange={(_, newValue) => onSelectChange(newValue)}\n openOnFocus\n autoHighlight\n sx={{ maxWidth: !isTabled ? textFieldWidth : 3000, minWidth: 160, flexGrow: 1 }}\n size=\"small\"\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n renderInput={(params) => (\n <StandardTextField\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n label={displayPrompt}\n placeholder={entryFormat}\n {...params}\n slotProps={{\n input: {\n ...params.InputProps,\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <>\n {params.InputProps.endAdornment}\n <FadingCheckIcon fadeIn={expressionUpdated} disabled={readOnly} />\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </>\n )\n }\n }}\n data-test=\"q-item-choice-select-answer-value-set-field\"\n />\n )}\n />\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </>\n );\n }\n\n if (terminologyError.error) {\n return (\n <StyledAlert color=\"error\">\n <ErrorOutlineIcon color=\"error\" sx={{ pr: 0.75 }} />\n <Typography>\n There was an error fetching options from the terminology server for{' '}\n {terminologyError.answerValueSet}\n </Typography>\n </StyledAlert>\n );\n }\n\n return (\n <StyledAlert color=\"error\">\n <ErrorOutlineIcon color=\"error\" sx={{ pr: 0.75 }} />\n <Typography>Unable to fetch options from the questionnaire or launch context</Typography>\n </StyledAlert>\n );\n}\n\nexport default ChoiceSelectAnswerValueSetFields;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { alpha, styled } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\nimport ListItemIcon from '@mui/material/ListItemIcon';\n\nexport const StyledAlert = styled(Box, {\n shouldForwardProp: (prop) => prop !== 'color'\n})<{ color: 'info' | 'error' }>(({ theme, color }) => ({\n display: 'flex',\n alignItems: 'center',\n padding: theme.spacing(1.25),\n borderRadius: Number(theme.shape.borderRadius) * 1.5,\n backgroundColor: alpha(\n color === 'error' ? theme.palette.error.light : theme.palette.info.light,\n 0.12\n ),\n [theme.breakpoints.up('sm')]: {\n padding: theme.spacing(1.5)\n },\n [theme.breakpoints.up('md')]: {\n padding: theme.spacing(2)\n }\n}));\n\nexport const StyledNavItemIcon = styled(ListItemIcon)({\n color: 'inherit',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center'\n});\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { convertCodingsToAnswerOptions, findInAnswerOptions } from '../../../utils/choice';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport useValueSetCodings from '../../../hooks/useValueSetCodings';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport ChoiceRadioAnswerValueSetFields from './ChoiceRadioAnswerValueSetFields';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useCodingCalculatedExpression from '../../../hooks/useCodingCalculatedExpression';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface ChoiceRadioAnswerValueSetItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction ChoiceRadioAnswerValueSetItem(props: ChoiceRadioAnswerValueSetItemProps) {\n const { qItem, qrItem, isRepeated, parentIsReadOnly, feedbackFromParent, onQrItemChange } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrChoiceRadio = qrItem ?? createEmptyQrItem(qItem, answerKey);\n\n let valueRadio: string | null = null;\n if (qrChoiceRadio.answer) {\n valueRadio =\n qrChoiceRadio.answer[0].valueCoding?.code ??\n qrChoiceRadio.answer[0].valueCoding?.display ??\n null;\n }\n\n // Get codings/options from valueSet\n const { codings, terminologyError, dynamicCodingsUpdated } = useValueSetCodings(qItem);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks - there's no string-based input here\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n const options = useMemo(() => convertCodingsToAnswerOptions(codings), [codings]);\n\n const { calcExpUpdated } = useCodingCalculatedExpression({\n qItem: qItem,\n valueInString: valueRadio ?? '',\n onChangeByCalcExpressionString: (newValueString: string) => {\n handleChange(newValueString);\n },\n onChangeByCalcExpressionNull: () => {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n });\n\n function handleChange(newValue: string) {\n if (codings.length > 0) {\n const qrAnswer = findInAnswerOptions(options, newValue);\n const emptyQrItem = createEmptyQrItem(qItem, answerKey);\n onQrItemChange(\n qrAnswer ? { ...emptyQrItem, answer: [{ ...qrAnswer, id: answerKey }] } : emptyQrItem\n );\n }\n }\n\n function handleClear() {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n\n if (isRepeated) {\n return (\n <ChoiceRadioAnswerValueSetFields\n qItem={qItem}\n options={options}\n valueRadio={valueRadio}\n feedback={feedback}\n readOnly={readOnly}\n expressionUpdated={calcExpUpdated || dynamicCodingsUpdated}\n terminologyError={terminologyError}\n onCheckedChange={handleChange}\n onClear={handleClear}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-choice-radio-answer-value-set-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <ChoiceRadioAnswerValueSetFields\n qItem={qItem}\n options={options}\n valueRadio={valueRadio}\n feedback={feedback}\n readOnly={readOnly}\n expressionUpdated={calcExpUpdated || dynamicCodingsUpdated}\n terminologyError={terminologyError}\n onCheckedChange={handleChange}\n onClear={handleClear}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default ChoiceRadioAnswerValueSetItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Typography from '@mui/material/Typography';\nimport { ChoiceItemOrientation } from '../../../interfaces/choice.enum';\nimport type { QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport { StyledRadioGroup, StyledRequiredTypography } from '../Item.styles';\nimport ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';\nimport { StyledAlert } from '../../Alert.styles';\nimport type { TerminologyError } from '../../../hooks/useValueSetCodings';\nimport { getChoiceOrientation } from '../../../utils/choice';\nimport FadingCheckIcon from '../ItemParts/FadingCheckIcon';\nimport Box from '@mui/material/Box';\nimport RadioOptionList from '../ItemParts/RadioOptionList';\nimport ClearInputButton from '../ItemParts/ClearInputButton';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface ChoiceRadioAnswerValueSetFieldsProps {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n valueRadio: string | null;\n feedback: string;\n readOnly: boolean;\n expressionUpdated: boolean;\n terminologyError: TerminologyError;\n onCheckedChange: (newValue: string) => void;\n onClear: () => void;\n}\n\nfunction ChoiceRadioAnswerValueSetFields(props: ChoiceRadioAnswerValueSetFieldsProps) {\n const {\n qItem,\n options,\n valueRadio,\n feedback,\n readOnly,\n expressionUpdated,\n terminologyError,\n onCheckedChange,\n onClear\n } = props;\n\n const inputsFlexGrow = useRendererStylingStore.use.inputsFlexGrow();\n const hideClearButton = useRendererStylingStore.use.hideClearButton();\n\n const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Vertical;\n\n if (options.length > 0) {\n return (\n <>\n <Box\n display=\"flex\"\n sx={{\n justifyContent: 'space-between',\n alignItems: { xs: 'start', sm: 'center' },\n flexDirection: { xs: 'column', sm: 'row' }\n }}>\n <Box\n display=\"flex\"\n alignItems=\"center\"\n sx={inputsFlexGrow ? { width: '100%', flexWrap: 'nowrap' } : {}}>\n <StyledRadioGroup\n id={qItem.type + '-' + qItem.linkId}\n row={orientation === ChoiceItemOrientation.Horizontal}\n sx={inputsFlexGrow ? { width: '100%', flexWrap: 'nowrap' } : {}}\n onChange={(e) => {\n // If item.readOnly=true, do not allow any changes\n if (readOnly) {\n return;\n }\n\n onCheckedChange(e.target.value);\n }}\n value={valueRadio}\n data-test=\"q-item-radio-group\">\n <RadioOptionList options={options} readOnly={readOnly} fullWidth={inputsFlexGrow} />\n </StyledRadioGroup>\n\n <Box flexGrow={1} />\n\n <FadingCheckIcon fadeIn={expressionUpdated} disabled={readOnly} />\n </Box>\n\n {hideClearButton ? null : (\n <ClearInputButton buttonShown={!!valueRadio} readOnly={readOnly} onClear={onClear} />\n )}\n </Box>\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </>\n );\n }\n\n if (terminologyError.error) {\n return (\n <StyledAlert color=\"error\">\n <ErrorOutlineIcon color=\"error\" sx={{ pr: 0.75 }} />\n <Typography>\n There was an error fetching options from the terminology server for{' '}\n {terminologyError.answerValueSet}\n </Typography>\n </StyledAlert>\n );\n }\n\n return (\n <StyledAlert color=\"error\">\n <ErrorOutlineIcon color=\"error\" sx={{ pr: 0.75 }} />\n <Typography>Unable to fetch options from the questionnaire or launch context</Typography>\n </StyledAlert>\n );\n}\n\nexport default ChoiceRadioAnswerValueSetFields;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport useValueSetCodings from '../../../hooks/useValueSetCodings';\nimport { convertCodingsToAnswerOptions, updateChoiceCheckboxAnswers } from '../../../utils/choice';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport DisplayInstructions from '../DisplayItem/DisplayInstructions';\nimport ChoiceCheckboxAnswerValueSetFields from './ChoiceCheckboxAnswerValueSetFields';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface ChoiceCheckboxAnswerValueSetItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n showText?: boolean;\n}\n\nfunction ChoiceCheckboxAnswerValueSetItem(props: ChoiceCheckboxAnswerValueSetItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n renderingExtensions,\n showMinimalView = false,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrChoiceCheckbox = qrItem ?? createEmptyQrItem(qItem, answerKey);\n const answers = qrChoiceCheckbox.answer ?? [];\n\n const { displayInstructions } = renderingExtensions;\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n // Get codings/options from valueSet\n // TODO use dynamicCodingsUpdated to trigger a \"refresh\" icon when codings are dynamically updated\n const { codings, terminologyError } = useValueSetCodings(qItem);\n\n const options = useMemo(() => convertCodingsToAnswerOptions(codings), [codings]);\n\n // TODO Process calculated expressions\n // This requires its own hook, because in the case of multi-select, we need to check if the value is already checked to prevent an infinite loop\n // This will be done after the choice/open-choice refactoring\n\n // Event handlers\n function handleCheckedChange(changedValue: string) {\n if (options.length === 0) {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n const updatedQrChoiceCheckbox = updateChoiceCheckboxAnswers(\n changedValue,\n answers,\n options,\n qrChoiceCheckbox,\n isRepeated,\n answerKey\n );\n\n if (updatedQrChoiceCheckbox) {\n onQrItemChange(updatedQrChoiceCheckbox);\n }\n }\n\n if (showMinimalView) {\n return (\n <>\n <ChoiceCheckboxAnswerValueSetFields\n qItem={qItem}\n options={options}\n answers={answers}\n feedback={feedback}\n readOnly={readOnly}\n terminologyError={terminologyError}\n onCheckedChange={handleCheckedChange}\n />\n <DisplayInstructions readOnly={readOnly}>{displayInstructions}</DisplayInstructions>\n </>\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-choice-checkbox-answer-value-set-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <ChoiceCheckboxAnswerValueSetFields\n qItem={qItem}\n options={options}\n answers={answers}\n feedback={feedback}\n readOnly={readOnly}\n terminologyError={terminologyError}\n onCheckedChange={handleCheckedChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default ChoiceCheckboxAnswerValueSetItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type {\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport { StyledAlert } from '../../Alert.styles';\nimport ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';\nimport Typography from '@mui/material/Typography';\nimport type { TerminologyError } from '../../../hooks/useValueSetCodings';\nimport { getChoiceOrientation } from '../../../utils/choice';\nimport { ChoiceItemOrientation } from '../../../interfaces/choice.enum';\nimport CheckboxOptionList from './CheckboxOptionList';\nimport { StyledFormGroup, StyledRequiredTypography } from '../Item.styles';\nimport { Box } from '@mui/material';\n\ninterface ChoiceCheckboxAnswerValueSetFieldsProps {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n answers: QuestionnaireResponseItemAnswer[];\n feedback: string;\n readOnly: boolean;\n terminologyError: TerminologyError;\n onCheckedChange: (newValue: string) => void;\n}\n\nfunction ChoiceCheckboxAnswerValueSetFields(props: ChoiceCheckboxAnswerValueSetFieldsProps) {\n const { qItem, options, answers, feedback, readOnly, terminologyError, onCheckedChange } = props;\n\n const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Vertical;\n\n if (options.length > 0) {\n return (\n <Box id={qItem.type + '-' + qItem.linkId}>\n <StyledFormGroup row={orientation === ChoiceItemOrientation.Horizontal}>\n <CheckboxOptionList\n options={options}\n answers={answers}\n readOnly={readOnly}\n onCheckedChange={onCheckedChange}\n />\n </StyledFormGroup>\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </Box>\n );\n }\n\n if (terminologyError.error) {\n return (\n <StyledAlert color=\"error\">\n <ErrorOutlineIcon color=\"error\" sx={{ pr: 0.75 }} />\n <Typography>\n There was an error fetching options from the terminology server for{' '}\n {terminologyError.answerValueSet}\n </Typography>\n </StyledAlert>\n );\n }\n\n return (\n <StyledAlert color=\"error\">\n <ErrorOutlineIcon color=\"error\" sx={{ pr: 0.75 }} />\n <Typography>Unable to fetch options from the questionnaire or launch context</Typography>\n </StyledAlert>\n );\n}\n\nexport default ChoiceCheckboxAnswerValueSetFields;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { ChoiceItemControl } from '../../../interfaces/choice.enum';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport ChoiceRadioAnswerOptionItem from './ChoiceRadioAnswerOptionItem';\nimport ChoiceSelectAnswerOptionItem from './ChoiceSelectAnswerOptionItem';\nimport ChoiceCheckboxAnswerOptionItem from './ChoiceCheckboxAnswerOptionItem';\nimport ChoiceAutocompleteItem from './ChoiceAutocompleteItem';\nimport ChoiceSelectAnswerValueSetItem from './ChoiceSelectAnswerValueSetItem';\nimport { getChoiceControlType } from '../../../utils/choice';\nimport ChoiceRadioAnswerValueSetItem from './ChoiceRadioAnswerValueSetItem';\nimport ChoiceCheckboxAnswerValueSetItem from './ChoiceCheckboxAnswerValueSetItem';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentStylesAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport Typography from '@mui/material/Typography';\n\ninterface ChoiceItemSwitcherProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute,\n PropsWithParentStylesAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction ChoiceItemSwitcher(props: ChoiceItemSwitcherProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n showMinimalView,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const choiceControlType = getChoiceControlType(qItem);\n\n switch (choiceControlType) {\n case ChoiceItemControl.Radio:\n if (qItem.answerOption) {\n return (\n <ChoiceRadioAnswerOptionItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n } else {\n return (\n <ChoiceRadioAnswerValueSetItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n case ChoiceItemControl.Checkbox:\n if (qItem.answerOption) {\n return (\n <ChoiceCheckboxAnswerOptionItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={qItem.repeats ?? false}\n renderingExtensions={renderingExtensions}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n } else {\n return (\n <ChoiceCheckboxAnswerValueSetItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={qItem.repeats ?? false}\n renderingExtensions={renderingExtensions}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n case ChoiceItemControl.Autocomplete:\n return (\n <ChoiceAutocompleteItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n case ChoiceItemControl.Select:\n if (qItem.answerOption) {\n return (\n <ChoiceSelectAnswerOptionItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n } else {\n return (\n <ChoiceSelectAnswerValueSetItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n default:\n return (\n <Typography>\n Something has went wrong when parsing item {qItem.linkId} - {qItem.text}\n </Typography>\n );\n }\n}\n\nexport default ChoiceItemSwitcher;\n","import React from 'react';\nimport { getAnswerOptionLabel } from '../../../utils/openChoice';\nimport { StandardTextField } from '../Textfield.styles';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport type { QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport type {\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport { useRendererStylingStore } from '../../../stores';\nimport { StyledRequiredTypography } from '../Item.styles';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\n\ninterface OpenChoiceSelectAnswerOptionFieldProps\n extends PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n valueSelect: QuestionnaireItemAnswerOption | null;\n feedback: string;\n readOnly: boolean;\n onChange: (newValue: QuestionnaireItemAnswerOption | string | null) => void;\n}\n\nfunction OpenChoiceSelectAnswerOptionField(props: OpenChoiceSelectAnswerOptionFieldProps) {\n const {\n qItem,\n options,\n valueSelect,\n feedback,\n readOnly,\n isTabled,\n renderingExtensions,\n onChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const { displayUnit, displayPrompt, entryFormat } = renderingExtensions;\n\n return (\n <>\n <Autocomplete\n id={qItem.type + '-' + qItem.linkId}\n value={valueSelect ?? null}\n options={options}\n getOptionLabel={(option) => getAnswerOptionLabel(option)}\n onChange={(_, newValue) => onChange(newValue)}\n freeSolo\n autoHighlight\n sx={{ maxWidth: !isTabled ? textFieldWidth : 3000, minWidth: 160, flexGrow: 1 }}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n size=\"small\"\n renderInput={(params) => (\n <StandardTextField\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n label={displayPrompt}\n placeholder={entryFormat}\n {...params}\n slotProps={{\n input: {\n ...params.InputProps,\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <>\n {params.InputProps.endAdornment}\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </>\n )\n }\n }}\n />\n )}\n />\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </>\n );\n}\n\nexport default OpenChoiceSelectAnswerOptionField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type {\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponseItem\n} from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport OpenChoiceSelectAnswerOptionField from './OpenChoiceSelectAnswerOptionField';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface OpenChoiceSelectAnswerOptionItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction OpenChoiceSelectAnswerOptionItem(props: OpenChoiceSelectAnswerOptionItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const answerOptions = qItem.answerOption;\n if (!answerOptions) return null;\n\n const qrOpenChoice = qrItem ?? createEmptyQrItem(qItem, answerKey);\n let valueSelect: QuestionnaireItemAnswerOption | null = null;\n if (qrOpenChoice.answer) {\n valueSelect = qrOpenChoice.answer[0] ?? null;\n }\n\n // Event handlers\n function handleChange(newValue: QuestionnaireItemAnswerOption | string | null) {\n if (newValue) {\n if (typeof newValue === 'string') {\n onQrItemChange({\n ...qrOpenChoice,\n answer: [{ id: answerKey, valueString: newValue }]\n });\n return;\n }\n\n const option = newValue;\n if (option['valueCoding']) {\n onQrItemChange({\n ...qrOpenChoice,\n answer: [{ id: answerKey, valueCoding: option.valueCoding }]\n });\n } else if (option['valueString']) {\n onQrItemChange({\n ...qrOpenChoice,\n answer: [{ id: answerKey, valueString: option.valueString }]\n });\n } else if (option['valueInteger']) {\n onQrItemChange({\n ...qrOpenChoice,\n answer: [{ id: answerKey, valueInteger: option.valueInteger }]\n });\n }\n return;\n }\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n\n if (isRepeated) {\n return (\n <OpenChoiceSelectAnswerOptionField\n qItem={qItem}\n options={answerOptions}\n valueSelect={valueSelect}\n feedback={feedback}\n readOnly={readOnly}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n onChange={handleChange}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-open-choice-select-answer-option-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <OpenChoiceSelectAnswerOptionField\n qItem={qItem}\n options={answerOptions}\n valueSelect={valueSelect}\n feedback={feedback}\n readOnly={readOnly}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n onChange={handleChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default OpenChoiceSelectAnswerOptionItem;\n","import React from 'react';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport { StandardTextField } from '../Textfield.styles';\nimport Typography from '@mui/material/Typography';\nimport type {\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { Coding, QuestionnaireItem } from 'fhir/r4';\nimport type { TerminologyError } from '../../../hooks/useValueSetCodings';\nimport { useRendererStylingStore } from '../../../stores';\nimport { StyledRequiredTypography } from '../Item.styles';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\n\ninterface OpenChoiceSelectAnswerValueSetFieldProps\n extends PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute {\n qItem: QuestionnaireItem;\n options: Coding[];\n valueSelect: Coding | null;\n terminologyError: TerminologyError;\n feedback: string;\n readOnly: boolean;\n onValueChange: (newValue: Coding | string | null) => void;\n}\n\nfunction OpenChoiceSelectAnswerValueSetField(props: OpenChoiceSelectAnswerValueSetFieldProps) {\n const {\n qItem,\n options,\n valueSelect,\n terminologyError,\n feedback,\n readOnly,\n isTabled,\n renderingExtensions,\n onValueChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const { displayUnit, displayPrompt, entryFormat } = renderingExtensions;\n\n return (\n <>\n <Autocomplete\n id={qItem.type + '-' + qItem.linkId}\n value={valueSelect ?? null}\n options={options}\n getOptionLabel={(option) =>\n typeof option === 'string' ? option : (option.display ?? `${option.code}`)\n }\n onChange={(_, newValue) => onValueChange(newValue)}\n onInputChange={(_, newValue) => onValueChange(newValue)}\n freeSolo\n autoHighlight\n sx={{ maxWidth: !isTabled ? textFieldWidth : 3000, minWidth: 160, flexGrow: 1 }}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n size=\"small\"\n renderInput={(params) => (\n <StandardTextField\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n label={displayPrompt}\n placeholder={entryFormat}\n {...params}\n slotProps={{\n input: {\n ...params.InputProps,\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <>\n {params.InputProps.endAdornment}\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </>\n )\n }\n }}\n />\n )}\n />\n {terminologyError.error ? (\n <Typography>\n There was an error fetching options from the terminology server for{' '}\n {terminologyError.answerValueSet}\n </Typography>\n ) : null}\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </>\n );\n}\n\nexport default OpenChoiceSelectAnswerValueSetField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { Coding, QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport useValueSetCodings from '../../../hooks/useValueSetCodings';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport OpenChoiceSelectAnswerValueSetField from './OpenChoiceSelectAnswerValueSetField';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface OpenChoiceSelectAnswerValueSetItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction OpenChoiceSelectAnswerValueSetItem(props: OpenChoiceSelectAnswerValueSetItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrOpenChoice = qrItem ?? createEmptyQrItem(qItem, answerKey);\n\n let valueSelect: Coding | null = null;\n if (qrOpenChoice['answer']) {\n valueSelect = qrOpenChoice['answer'][0].valueCoding ?? null;\n }\n\n // Get codings/options from valueSet\n // TODO use dynamicCodingsUpdated to trigger a \"refresh\" icon when codings are dynamically updated\n const { codings, terminologyError } = useValueSetCodings(qItem);\n\n // Event handlers\n function handleValueChange(newValue: Coding | string | null) {\n if (newValue) {\n if (typeof newValue === 'string') {\n onQrItemChange({\n ...qrOpenChoice,\n answer: [{ id: answerKey, valueString: newValue }]\n });\n } else {\n onQrItemChange({\n ...qrOpenChoice,\n answer: [{ id: answerKey, valueCoding: newValue }]\n });\n }\n return;\n }\n\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n\n if (isRepeated) {\n return (\n <OpenChoiceSelectAnswerValueSetField\n qItem={qItem}\n options={codings}\n valueSelect={valueSelect}\n terminologyError={terminologyError}\n feedback={feedback}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n readOnly={readOnly}\n onValueChange={handleValueChange}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-open-choice-select-answer-value-set-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <OpenChoiceSelectAnswerValueSetField\n qItem={qItem}\n options={codings}\n valueSelect={valueSelect}\n terminologyError={terminologyError}\n feedback={feedback}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n readOnly={readOnly}\n onValueChange={handleValueChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default OpenChoiceSelectAnswerValueSetItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\n\nimport type { Coding, QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\n\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport useDebounce from '../../../hooks/useDebounce';\nimport useTerminologyServerQuery from '../../../hooks/useTerminologyServerQuery';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport { AUTOCOMPLETE_DEBOUNCE_DURATION } from '../../../utils/debounce';\nimport OpenChoiceAutocompleteField from './OpenChoiceAutocompleteField';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport type { AlertColor } from '@mui/material/Alert';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface OpenChoiceAutocompleteItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction OpenChoiceAutocompleteItem(props: OpenChoiceAutocompleteItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n feedbackFromParent,\n parentIsReadOnly,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const answerKey = qrItem?.answer?.[0].id;\n const qrOpenChoice = qrItem ?? createEmptyQrItem(qItem, answerKey);\n\n // Init input value\n let valueAutocomplete: Coding | string | undefined;\n if (qrOpenChoice.answer) {\n const answer = qrOpenChoice.answer[0];\n valueAutocomplete = answer.valueCoding ? answer.valueCoding : answer.valueString;\n }\n\n if (!valueAutocomplete) {\n valueAutocomplete = '';\n }\n\n const maxList = 10;\n\n const [input, setInput] = useState('');\n const debouncedInput = useDebounce(input, AUTOCOMPLETE_DEBOUNCE_DURATION);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const validationFeedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n const {\n options,\n loading,\n feedback: terminologyFeedback\n } = useTerminologyServerQuery(qItem, maxList, input, debouncedInput);\n\n let feedback: { message: string; color: AlertColor } | null = null;\n if (terminologyFeedback) {\n feedback = terminologyFeedback;\n } else if (validationFeedback !== '') {\n feedback = { message: validationFeedback, color: 'error' };\n }\n\n if (!qItem.answerValueSet) {\n return null;\n }\n\n // Event handlers\n function handleValueChange(newValue: Coding | string | null) {\n if (newValue === null) {\n setInput('');\n newValue = '';\n }\n\n if (typeof newValue === 'string') {\n if (newValue !== '') {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueString: newValue }]\n });\n } else {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n } else {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueCoding: newValue }]\n });\n }\n }\n\n function handleUnfocus() {\n // set answer to current input when text field is unfocused\n if (!valueAutocomplete && input !== '') {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueString: input }]\n });\n }\n }\n\n if (isRepeated) {\n return (\n <OpenChoiceAutocompleteField\n qItem={qItem}\n options={options}\n valueAutocomplete={valueAutocomplete}\n input={input}\n loading={loading}\n feedback={feedback}\n readOnly={readOnly}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n onInputChange={(newValue) => setInput(newValue)}\n onValueChange={handleValueChange}\n onUnfocus={handleUnfocus}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-open-choice-autocomplete-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <OpenChoiceAutocompleteField\n qItem={qItem}\n options={options}\n valueAutocomplete={valueAutocomplete}\n input={input}\n loading={loading}\n feedback={feedback}\n readOnly={readOnly}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n onInputChange={(newValue) => setInput(newValue)}\n onValueChange={handleValueChange}\n onUnfocus={handleUnfocus}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default OpenChoiceAutocompleteItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Box from '@mui/material/Box';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport { StandardTextField } from '../Textfield.styles';\nimport SearchIcon from '@mui/icons-material/Search';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport Fade from '@mui/material/Fade';\nimport Tooltip from '@mui/material/Tooltip';\nimport InfoIcon from '@mui/icons-material/Info';\nimport WarningAmberIcon from '@mui/icons-material/WarningAmber';\nimport DoneIcon from '@mui/icons-material/Done';\nimport ErrorIcon from '@mui/icons-material/Error';\nimport type { Coding, QuestionnaireItem } from 'fhir/r4';\nimport type {\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { AlertColor } from '@mui/material/Alert';\nimport { useRendererStylingStore } from '../../../stores';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\n\ninterface OpenChoiceAutocompleteFieldProps\n extends PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute {\n qItem: QuestionnaireItem;\n options: Coding[];\n valueAutocomplete: string | Coding;\n input: string;\n loading: boolean;\n feedback: { message: string; color: AlertColor } | null;\n readOnly: boolean;\n onInputChange: (newInput: string) => void;\n onValueChange: (newValue: Coding | string | null) => void;\n onUnfocus: () => void;\n}\n\nfunction OpenChoiceAutocompleteField(props: OpenChoiceAutocompleteFieldProps) {\n const {\n qItem,\n options,\n valueAutocomplete,\n input,\n loading,\n feedback,\n readOnly,\n isTabled,\n renderingExtensions,\n onInputChange,\n onValueChange,\n onUnfocus\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const { displayUnit, displayPrompt, entryFormat } = renderingExtensions;\n\n return (\n <Box display=\"flex\">\n <Autocomplete\n id={qItem.type + '-' + qItem.linkId}\n value={valueAutocomplete}\n options={options}\n getOptionLabel={(option) =>\n typeof option === 'string' ? option : (option.display ?? `${option.code}`)\n }\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n loading={loading}\n loadingText={'Fetching results...'}\n clearOnEscape\n freeSolo\n sx={{ maxWidth: !isTabled ? textFieldWidth : 3000, minWidth: 220, flexGrow: 1 }}\n onChange={(_, newValue) => onValueChange(newValue)}\n filterOptions={(x) => x}\n renderInput={(params) => (\n <StandardTextField\n {...params}\n value={input}\n onBlur={onUnfocus}\n onChange={(e) => onInputChange(e.target.value)}\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n label={displayPrompt}\n size=\"small\"\n placeholder={entryFormat}\n slotProps={{\n input: {\n ...params.InputProps,\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n startAdornment: (\n <>\n {!valueAutocomplete || valueAutocomplete === '' ? (\n <SearchIcon fontSize=\"small\" sx={{ ml: 0.5 }} />\n ) : null}\n {params.InputProps.startAdornment}\n </>\n ),\n // Warning indicator should not show up in open-choice autocomplete\n endAdornment: (\n <>\n {loading ? (\n <CircularProgress color=\"inherit\" size={16} />\n ) : feedback && feedback.color !== 'warning' ? (\n <Fade in={!!feedback} timeout={300}>\n <Tooltip title={feedback.message} arrow sx={{ ml: 1 }}>\n {\n {\n info: <InfoIcon fontSize=\"small\" color=\"info\" />,\n warning: <WarningAmberIcon fontSize=\"small\" color=\"warning\" />,\n success: <DoneIcon fontSize=\"small\" color=\"success\" />,\n error: <ErrorIcon fontSize=\"small\" color=\"error\" />\n }[feedback.color]\n }\n </Tooltip>\n </Fade>\n ) : null}\n {params.InputProps.endAdornment}\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </>\n )\n }\n }}\n data-test=\"q-item-open-choice-autocomplete-field\"\n />\n )}\n />\n </Box>\n );\n}\n\nexport default OpenChoiceAutocompleteField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback } from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { getOpenLabelText } from '../../../utils/itemControl';\nimport { updateOpenLabelAnswer } from '../../../utils/openChoice';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport debounce from 'lodash.debounce';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport { DEBOUNCE_DURATION } from '../../../utils/debounce';\nimport DisplayInstructions from '../DisplayItem/DisplayInstructions';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useOpenLabel from '../../../hooks/useOpenLabel';\nimport { updateChoiceCheckboxAnswers } from '../../../utils/choice';\nimport OpenChoiceCheckboxAnswerOptionFields from './OpenChoiceCheckboxAnswerOptionFields';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface OpenChoiceCheckboxAnswerOptionItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction OpenChoiceCheckboxAnswerOptionItem(props: OpenChoiceCheckboxAnswerOptionItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n renderingExtensions,\n showMinimalView = false,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrOpenChoiceCheckbox = qrItem ?? createEmptyQrItem(qItem, answerKey);\n const answers = qrOpenChoiceCheckbox.answer ?? [];\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n const { displayInstructions } = renderingExtensions;\n const openLabelText = getOpenLabelText(qItem);\n\n const options = qItem.answerOption ?? [];\n\n const { openLabelValue, setOpenLabelValue, openLabelChecked, setOpenLabelChecked } = useOpenLabel(\n options,\n answers\n );\n\n // Event handlers\n\n // One of the options is changed\n // Processing is similar to a choice checkbox\n function handleOptionChange(changedOptionValue: string) {\n if (options.length === 0) {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n // Process as a choice checkbox\n const updatedQrItem = updateChoiceCheckboxAnswers(\n changedOptionValue,\n answers,\n options,\n qrOpenChoiceCheckbox,\n isRepeated,\n answerKey\n );\n\n if (updatedQrItem) {\n onQrItemChange(updatedQrItem);\n }\n\n // If single-selection, uncheck open label\n if (!isRepeated) {\n setOpenLabelChecked(false);\n }\n }\n\n function handleOpenLabelChange(openLabelChecked: boolean, changedOpenLabelValue: string) {\n const updatedQrItem = updateOpenLabelAnswer(\n openLabelChecked,\n changedOpenLabelValue,\n answers,\n options,\n qrOpenChoiceCheckbox,\n isRepeated,\n answerKey\n );\n\n if (updatedQrItem) {\n onQrItemChange(updatedQrItem);\n }\n }\n\n function handleOpenLabelCheckedChange(checked: boolean) {\n handleOpenLabelChange(checked, openLabelValue);\n setOpenLabelChecked(checked);\n }\n\n function handleOpenLabelInputChange(newValue: string) {\n updateOpenLabelValueWithDebounce(newValue);\n setOpenLabelValue(newValue);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const updateOpenLabelValueWithDebounce = useCallback(\n debounce((input: string) => {\n handleOpenLabelChange(openLabelChecked, input);\n }, DEBOUNCE_DURATION),\n [handleOpenLabelChange]\n ); // Dependencies are tested, debounce is causing eslint to not recognise dependencies\n\n if (showMinimalView) {\n return (\n <>\n <OpenChoiceCheckboxAnswerOptionFields\n qItem={qItem}\n options={options}\n answers={answers}\n openLabelText={openLabelText}\n openLabelValue={openLabelValue}\n openLabelChecked={openLabelChecked}\n feedback={feedback}\n readOnly={readOnly}\n onOptionChange={handleOptionChange}\n onOpenLabelCheckedChange={handleOpenLabelCheckedChange}\n onOpenLabelInputChange={handleOpenLabelInputChange}\n />\n <DisplayInstructions readOnly={readOnly}>{displayInstructions}</DisplayInstructions>\n </>\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-open-choice-checkbox-answer-option-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <OpenChoiceCheckboxAnswerOptionFields\n qItem={qItem}\n options={options}\n answers={answers}\n openLabelText={openLabelText}\n openLabelValue={openLabelValue}\n openLabelChecked={openLabelChecked}\n feedback={feedback}\n readOnly={readOnly}\n onOptionChange={handleOptionChange}\n onOpenLabelCheckedChange={handleOpenLabelCheckedChange}\n onOpenLabelInputChange={handleOpenLabelInputChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default OpenChoiceCheckboxAnswerOptionItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getOldOpenLabelAnswer } from '../utils/openChoice';\nimport { useState } from 'react';\nimport type { QuestionnaireItemAnswerOption, QuestionnaireResponseItemAnswer } from 'fhir/r4';\n\nfunction useOpenLabel(\n options: QuestionnaireItemAnswerOption[],\n answers: QuestionnaireResponseItemAnswer[]\n) {\n let initialOpenLabelValue = '';\n let initialOpenLabelChecked = false;\n\n if (options.length > 0) {\n const oldLabelAnswer = getOldOpenLabelAnswer(answers, options);\n if (oldLabelAnswer && oldLabelAnswer.valueString) {\n initialOpenLabelValue = oldLabelAnswer.valueString;\n initialOpenLabelChecked = true;\n }\n }\n\n const [openLabelValue, setOpenLabelValue] = useState(initialOpenLabelValue);\n const [openLabelChecked, setOpenLabelChecked] = useState(initialOpenLabelChecked);\n\n return { openLabelValue, setOpenLabelValue, openLabelChecked, setOpenLabelChecked };\n}\n\nexport default useOpenLabel;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ChangeEvent } from 'react';\nimport React from 'react';\nimport Box from '@mui/material/Box';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport { useRendererStylingStore } from '../../../stores';\nimport { StandardCheckbox } from '../../Checkbox.styles';\nimport OpenLabelField from './OpenLabelField';\n\ninterface Props {\n value: string | null;\n label: string;\n isChecked: boolean;\n readOnly: boolean;\n onCheckedChange: (checked: boolean) => unknown;\n onInputChange: (input: string) => unknown;\n}\n\nfunction CheckboxSingleWithOpenLabel(props: Props) {\n const { value, label, isChecked, readOnly, onCheckedChange, onInputChange } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n\n function handleCheckedChange(event: ChangeEvent<HTMLInputElement>) {\n onCheckedChange(event.target.checked);\n }\n\n return (\n <Box data-test=\"q-item-checkbox-open-label-box\">\n <FormControlLabel\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n aria-readonly={readOnly && readOnlyVisualStyle === 'readonly'}\n control={\n <StandardCheckbox\n size=\"small\"\n checked={isChecked}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n onChange={handleCheckedChange}\n />\n }\n label={label + ':'}\n />\n <OpenLabelField\n value={value}\n readOnly={readOnly}\n openLabelOptionSelected={isChecked}\n onInputChange={onInputChange}\n />\n </Box>\n );\n}\n\nexport default CheckboxSingleWithOpenLabel;\n","import React, { type ChangeEvent } from 'react';\nimport { StandardTextField } from '../Textfield.styles';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface OpenLabelFieldProps {\n value: string | null;\n readOnly: boolean;\n openLabelOptionSelected: boolean;\n onInputChange: (input: string) => unknown;\n}\n\nfunction OpenLabelField(props: OpenLabelFieldProps) {\n const { value, readOnly, openLabelOptionSelected, onInputChange } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const fieldReadOnly = !openLabelOptionSelected || readOnly;\n\n function handleInputChange(event: ChangeEvent<HTMLInputElement>) {\n onInputChange(event.target.value);\n }\n\n return (\n <StandardTextField\n disabled={fieldReadOnly && readOnlyVisualStyle === 'disabled'}\n value={value}\n onChange={handleInputChange}\n fullWidth\n textFieldWidth={textFieldWidth}\n isTabled={false}\n size=\"small\"\n slotProps={{\n input: {\n readOnly: fieldReadOnly && readOnlyVisualStyle === 'readonly'\n }\n }}\n />\n );\n}\n\nexport default OpenLabelField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { ChoiceItemOrientation } from '../../../interfaces/choice.enum';\nimport CheckboxSingleWithOpenLabel from '../ItemParts/CheckboxSingleWithOpenLabel';\nimport type {\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport { getChoiceOrientation } from '../../../utils/choice';\nimport { StyledFormGroup, StyledRequiredTypography } from '../Item.styles';\nimport CheckboxOptionList from '../ChoiceItems/CheckboxOptionList';\nimport { Box } from '@mui/material';\n\ninterface OpenChoiceCheckboxAnswerOptionFieldsProps {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n answers: QuestionnaireResponseItemAnswer[];\n openLabelText: string | null;\n openLabelValue: string;\n openLabelChecked: boolean;\n feedback: string;\n readOnly: boolean;\n onOptionChange: (changedOptionValue: string) => void;\n onOpenLabelCheckedChange: (checked: boolean) => void;\n onOpenLabelInputChange: (input: string) => void;\n}\n\nfunction OpenChoiceCheckboxAnswerOptionFields(props: OpenChoiceCheckboxAnswerOptionFieldsProps) {\n const {\n qItem,\n options,\n answers,\n openLabelText,\n openLabelValue,\n openLabelChecked,\n feedback,\n readOnly,\n onOptionChange,\n onOpenLabelCheckedChange,\n onOpenLabelInputChange\n } = props;\n\n const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Vertical;\n\n return (\n <Box id={qItem.type + '-' + qItem.linkId}>\n <StyledFormGroup row={orientation === ChoiceItemOrientation.Horizontal}>\n <CheckboxOptionList\n options={options}\n answers={answers}\n readOnly={readOnly}\n onCheckedChange={onOptionChange}\n />\n\n {openLabelText !== null ? (\n <CheckboxSingleWithOpenLabel\n value={openLabelValue}\n label={openLabelText}\n readOnly={readOnly}\n isChecked={openLabelChecked}\n onCheckedChange={onOpenLabelCheckedChange}\n onInputChange={onOpenLabelInputChange}\n />\n ) : null}\n </StyledFormGroup>\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </Box>\n );\n}\n\nexport default OpenChoiceCheckboxAnswerOptionFields;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { getOpenLabelText } from '../../../utils/itemControl';\nimport { getOldOpenLabelAnswer } from '../../../utils/openChoice';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport { findInAnswerOptions, getQrChoiceValue } from '../../../utils/choice';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport OpenChoiceRadioAnswerOptionFields from './OpenChoiceRadioAnswerOptionFields';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface OpenChoiceRadioAnswerOptionItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction OpenChoiceRadioAnswerOptionItem(props: OpenChoiceRadioAnswerOptionItemProps) {\n const { qItem, qrItem, parentIsReadOnly, feedbackFromParent, onQrItemChange } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n // Init answers\n const answerKey = qrItem?.answer?.[0].id;\n const qrOpenChoiceRadio = qrItem ?? createEmptyQrItem(qItem, answerKey);\n let valueRadio: string | null = getQrChoiceValue(qrOpenChoiceRadio, true);\n const answers = qrOpenChoiceRadio.answer ?? [];\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n const openLabelText = getOpenLabelText(qItem);\n\n const options = qItem.answerOption ?? [];\n\n // Init empty open label\n let initialOpenLabelValue = '';\n let initialOpenLabelSelected = false;\n if (options) {\n const oldLabelAnswer = getOldOpenLabelAnswer(answers, options);\n if (oldLabelAnswer && oldLabelAnswer.valueString) {\n initialOpenLabelValue = oldLabelAnswer.valueString;\n initialOpenLabelSelected = true;\n valueRadio = initialOpenLabelValue;\n }\n }\n\n const [openLabelValue, setOpenLabelValue] = useState<string | null>(initialOpenLabelValue);\n const [openLabelSelected, setOpenLabelSelected] = useState(initialOpenLabelSelected);\n\n // Allow open label to remain selected even if its input was cleared\n if (openLabelSelected && valueRadio === null) {\n valueRadio = '';\n }\n\n // Event handlers\n function handleValueChange(\n changedOptionValue: string | null,\n changedOpenLabelValue: string | null\n ) {\n if (options.length === 0) {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n if (changedOptionValue !== null) {\n const qrAnswer = findInAnswerOptions(options, changedOptionValue);\n\n // If selected answer can be found in options, it is a non-open label selection\n if (qrAnswer) {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ ...qrAnswer, id: answerKey }]\n });\n setOpenLabelSelected(false);\n return;\n }\n\n // Otherwise, it is an open-label selection\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueString: changedOptionValue }]\n });\n setOpenLabelValue(changedOptionValue);\n setOpenLabelSelected(true);\n return;\n }\n\n if (changedOpenLabelValue !== null) {\n setOpenLabelValue(changedOpenLabelValue);\n\n // If open label is unchecked, remove it from answers\n if (changedOpenLabelValue === '') {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n // Otherwise, add open label to answers\n setOpenLabelValue(changedOpenLabelValue);\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueString: changedOpenLabelValue }]\n });\n }\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-open-choice-radio-answer-option-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <OpenChoiceRadioAnswerOptionFields\n qItem={qItem}\n options={options}\n valueRadio={valueRadio}\n openLabelText={openLabelText}\n openLabelValue={openLabelValue}\n openLabelSelected={openLabelSelected}\n feedback={feedback}\n readOnly={readOnly}\n onValueChange={handleValueChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default OpenChoiceRadioAnswerOptionItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Box from '@mui/material/Box';\nimport ChoiceRadioSingle from '../ChoiceItems/ChoiceRadioSingle';\nimport OpenLabelField from './OpenLabelField';\n\ninterface RadioButtonWithOpenLabelProps {\n value: string | null;\n label: string;\n readOnly: boolean;\n isSelected: boolean;\n onInputChange: (input: string) => unknown;\n}\n\nfunction RadioButtonWithOpenLabel(props: RadioButtonWithOpenLabelProps) {\n const { value, label, readOnly, isSelected, onInputChange } = props;\n\n return (\n <Box data-test=\"q-item-radio-open-label-box\">\n <ChoiceRadioSingle\n value={value ?? ''}\n label={label + ':'}\n readOnly={readOnly}\n fullWidth={false}\n />\n <OpenLabelField\n value={value}\n readOnly={readOnly}\n openLabelOptionSelected={isSelected}\n onInputChange={onInputChange}\n />\n </Box>\n );\n}\n\nexport default RadioButtonWithOpenLabel;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ChangeEvent } from 'react';\nimport React from 'react';\nimport { ChoiceItemOrientation } from '../../../interfaces/choice.enum';\nimport type { QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport { StyledRadioGroup, StyledRequiredTypography } from '../Item.styles';\nimport RadioButtonWithOpenLabel from '../ItemParts/RadioButtonWithOpenLabel';\nimport RadioOptionList from '../ItemParts/RadioOptionList';\nimport { getChoiceOrientation } from '../../../utils/choice';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface OpenChoiceRadioAnswerOptionFieldsProps {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n valueRadio: string | null;\n openLabelText: string | null;\n openLabelValue: string | null;\n openLabelSelected: boolean;\n feedback: string;\n readOnly: boolean;\n onValueChange: (changedOptionValue: string | null, changedOpenLabelValue: string | null) => void;\n}\n\nfunction OpenChoiceRadioAnswerOptionFields(props: OpenChoiceRadioAnswerOptionFieldsProps) {\n const {\n qItem,\n options,\n valueRadio,\n openLabelText,\n openLabelValue,\n openLabelSelected,\n feedback,\n readOnly,\n onValueChange\n } = props;\n\n const inputsFlexGrow = useRendererStylingStore.use.inputsFlexGrow();\n\n const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Vertical;\n\n return (\n <>\n <StyledRadioGroup\n id={qItem.type + '-' + qItem.linkId}\n row={orientation === ChoiceItemOrientation.Horizontal}\n sx={inputsFlexGrow ? { width: '100%', flexWrap: 'nowrap' } : {}}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n // If item.readOnly=true, do not allow any changes\n if (readOnly) {\n return;\n }\n\n onValueChange(e.target.value, null);\n }}\n value={valueRadio}\n data-test=\"q-item-radio-group\">\n <RadioOptionList options={options} readOnly={readOnly} fullWidth={inputsFlexGrow} />\n\n {openLabelText ? (\n <RadioButtonWithOpenLabel\n value={openLabelValue}\n label={openLabelText}\n readOnly={readOnly}\n isSelected={openLabelSelected}\n onInputChange={(input) => onValueChange(null, input)}\n />\n ) : null}\n </StyledRadioGroup>\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </>\n );\n}\n\nexport default OpenChoiceRadioAnswerOptionFields;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback, useMemo } from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { getOpenLabelText } from '../../../utils/itemControl';\nimport { updateOpenLabelAnswer } from '../../../utils/openChoice';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport debounce from 'lodash.debounce';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport { DEBOUNCE_DURATION } from '../../../utils/debounce';\nimport DisplayInstructions from '../DisplayItem/DisplayInstructions';\nimport OpenChoiceCheckboxAnswerValueSetFields from './OpenChoiceCheckboxAnswerValueSetFields';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useOpenLabel from '../../../hooks/useOpenLabel';\nimport { convertCodingsToAnswerOptions, updateChoiceCheckboxAnswers } from '../../../utils/choice';\nimport useValueSetCodings from '../../../hooks/useValueSetCodings';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface OpenChoiceCheckboxAnswerValueSetItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction OpenChoiceCheckboxAnswerValueSetItem(props: OpenChoiceCheckboxAnswerValueSetItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n renderingExtensions,\n showMinimalView = false,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrOpenChoiceCheckbox = qrItem ?? createEmptyQrItem(qItem, answerKey);\n const answers = qrOpenChoiceCheckbox.answer ?? [];\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n const { displayInstructions } = renderingExtensions;\n const openLabelText = getOpenLabelText(qItem);\n\n // Get codings/options from valueSet\n // TODO use dynamicCodingsUpdated to trigger a \"refresh\" icon when codings are dynamically updated\n const { codings, terminologyError } = useValueSetCodings(qItem);\n\n const options = useMemo(() => convertCodingsToAnswerOptions(codings), [codings]);\n\n const { openLabelValue, setOpenLabelValue, openLabelChecked, setOpenLabelChecked } = useOpenLabel(\n options,\n answers\n );\n\n // Event handlers\n\n // One of the options is changed\n // Processing is similar to a choice checkbox\n function handleOptionChange(changedOptionValue: string) {\n if (options.length === 0) {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n // Process as a choice checkbox\n const updatedQrItem = updateChoiceCheckboxAnswers(\n changedOptionValue,\n answers,\n options,\n qrOpenChoiceCheckbox,\n isRepeated,\n answerKey\n );\n\n if (updatedQrItem) {\n onQrItemChange(updatedQrItem);\n }\n\n // If single-selection, uncheck open label\n if (!isRepeated) {\n setOpenLabelChecked(false);\n }\n }\n\n function handleOpenLabelChange(openLabelChecked: boolean, changedOpenLabelValue: string) {\n const updatedQrItem = updateOpenLabelAnswer(\n openLabelChecked,\n changedOpenLabelValue,\n answers,\n options,\n qrOpenChoiceCheckbox,\n isRepeated,\n answerKey\n );\n\n if (updatedQrItem) {\n onQrItemChange(updatedQrItem);\n }\n }\n\n function handleOpenLabelCheckedChange(checked: boolean) {\n handleOpenLabelChange(checked, openLabelValue);\n setOpenLabelChecked(checked);\n }\n\n function handleOpenLabelInputChange(newValue: string) {\n updateOpenLabelValueWithDebounce(newValue);\n setOpenLabelValue(newValue);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const updateOpenLabelValueWithDebounce = useCallback(\n debounce((input: string) => {\n handleOpenLabelChange(openLabelChecked, input);\n }, DEBOUNCE_DURATION),\n [handleOpenLabelChange]\n ); // Dependencies are tested, debounce is causing eslint to not recognise dependencies\n\n if (showMinimalView) {\n return (\n <>\n <OpenChoiceCheckboxAnswerValueSetFields\n qItem={qItem}\n options={options}\n answers={answers}\n openLabelText={openLabelText}\n openLabelValue={openLabelValue}\n openLabelChecked={openLabelChecked}\n feedback={feedback}\n readOnly={readOnly}\n terminologyError={terminologyError}\n onOptionChange={handleOptionChange}\n onOpenLabelCheckedChange={handleOpenLabelCheckedChange}\n onOpenLabelInputChange={handleOpenLabelInputChange}\n />\n <DisplayInstructions readOnly={readOnly}>{displayInstructions}</DisplayInstructions>\n </>\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-open-choice-checkbox-answer-value-set-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <OpenChoiceCheckboxAnswerValueSetFields\n qItem={qItem}\n options={options}\n answers={answers}\n openLabelText={openLabelText}\n openLabelValue={openLabelValue}\n openLabelChecked={openLabelChecked}\n feedback={feedback}\n readOnly={readOnly}\n terminologyError={terminologyError}\n onOptionChange={handleOptionChange}\n onOpenLabelCheckedChange={handleOpenLabelCheckedChange}\n onOpenLabelInputChange={handleOpenLabelInputChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default OpenChoiceCheckboxAnswerValueSetItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { ChoiceItemOrientation } from '../../../interfaces/choice.enum';\nimport CheckboxSingleWithOpenLabel from '../ItemParts/CheckboxSingleWithOpenLabel';\nimport type {\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport { getChoiceOrientation } from '../../../utils/choice';\nimport { StyledFormGroup, StyledRequiredTypography } from '../Item.styles';\nimport CheckboxOptionList from '../ChoiceItems/CheckboxOptionList';\nimport { StyledAlert } from '../../Alert.styles';\nimport ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';\nimport Typography from '@mui/material/Typography';\nimport type { TerminologyError } from '../../../hooks/useValueSetCodings';\nimport { Box } from '@mui/material';\n\ninterface OpenChoiceCheckboxFieldsProps {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n answers: QuestionnaireResponseItemAnswer[];\n openLabelText: string | null;\n openLabelValue: string;\n openLabelChecked: boolean;\n feedback: string;\n readOnly: boolean;\n terminologyError: TerminologyError;\n onOptionChange: (changedOptionValue: string) => void;\n onOpenLabelCheckedChange: (checked: boolean) => void;\n onOpenLabelInputChange: (input: string) => void;\n}\n\nfunction OpenChoiceCheckboxAnswerValueSetFields(props: OpenChoiceCheckboxFieldsProps) {\n const {\n qItem,\n options,\n answers,\n openLabelText,\n openLabelValue,\n openLabelChecked,\n feedback,\n readOnly,\n terminologyError,\n onOptionChange,\n onOpenLabelCheckedChange,\n onOpenLabelInputChange\n } = props;\n\n const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Vertical;\n\n if (options.length > 0) {\n return (\n <Box id={qItem.type + '-' + qItem.linkId}>\n <StyledFormGroup row={orientation === ChoiceItemOrientation.Horizontal}>\n <CheckboxOptionList\n options={options}\n answers={answers}\n readOnly={readOnly}\n onCheckedChange={onOptionChange}\n />\n\n {openLabelText !== null ? (\n <CheckboxSingleWithOpenLabel\n value={openLabelValue}\n label={openLabelText}\n readOnly={readOnly}\n isChecked={openLabelChecked}\n onCheckedChange={onOpenLabelCheckedChange}\n onInputChange={onOpenLabelInputChange}\n />\n ) : null}\n </StyledFormGroup>\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </Box>\n );\n }\n\n if (terminologyError.error) {\n return (\n <StyledAlert color=\"error\">\n <ErrorOutlineIcon color=\"error\" sx={{ pr: 0.75 }} />\n <Typography>\n There was an error fetching options from the terminology server for{' '}\n {terminologyError.answerValueSet}\n </Typography>\n </StyledAlert>\n );\n }\n\n return (\n <StyledAlert color=\"error\">\n <ErrorOutlineIcon color=\"error\" sx={{ pr: 0.75 }} />\n <Typography>Unable to fetch options from the questionnaire or launch context</Typography>\n </StyledAlert>\n );\n}\n\nexport default OpenChoiceCheckboxAnswerValueSetFields;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo, useState } from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { getOpenLabelText } from '../../../utils/itemControl';\nimport { getOldOpenLabelAnswer } from '../../../utils/openChoice';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport {\n convertCodingsToAnswerOptions,\n findInAnswerOptions,\n getQrChoiceValue\n} from '../../../utils/choice';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport OpenChoiceRadioAnswerValueSetFields from './OpenChoiceRadioAnswerValueSetFields';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useValueSetCodings from '../../../hooks/useValueSetCodings';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface OpenChoiceRadioAnswerValueSetItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction OpenChoiceRadioAnswerValueSetItem(props: OpenChoiceRadioAnswerValueSetItemProps) {\n const { qItem, qrItem, parentIsReadOnly, feedbackFromParent, onQrItemChange } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n // Init answers\n const answerKey = qrItem?.answer?.[0].id;\n const qrOpenChoiceRadio = qrItem ?? createEmptyQrItem(qItem, answerKey);\n let valueRadio: string | null = getQrChoiceValue(qrOpenChoiceRadio, true);\n const answers = qrOpenChoiceRadio.answer ?? [];\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n const openLabelText = getOpenLabelText(qItem);\n\n // Get codings/options from valueSet\n // TODO use dynamicCodingsUpdated to trigger a \"refresh\" icon when codings are dynamically updated\n const { codings, terminologyError } = useValueSetCodings(qItem);\n\n const options = useMemo(() => convertCodingsToAnswerOptions(codings), [codings]);\n\n // Init empty open label\n let initialOpenLabelValue = '';\n let initialOpenLabelSelected = false;\n if (options) {\n const oldLabelAnswer = getOldOpenLabelAnswer(answers, options);\n if (oldLabelAnswer && oldLabelAnswer.valueString) {\n initialOpenLabelValue = oldLabelAnswer.valueString;\n initialOpenLabelSelected = true;\n valueRadio = initialOpenLabelValue;\n }\n }\n\n const [openLabelValue, setOpenLabelValue] = useState<string | null>(initialOpenLabelValue);\n const [openLabelSelected, setOpenLabelSelected] = useState(initialOpenLabelSelected);\n\n // Allow open label to remain selected even if its input was cleared\n if (openLabelSelected && valueRadio === null) {\n valueRadio = '';\n }\n\n // Event handlers\n function handleValueChange(\n changedOptionValue: string | null,\n changedOpenLabelValue: string | null\n ) {\n if (options.length === 0) {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n if (changedOptionValue !== null) {\n const qrAnswer = findInAnswerOptions(options, changedOptionValue);\n\n // If selected answer can be found in options, it is a non-open label selection\n if (qrAnswer) {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ ...qrAnswer, id: answerKey }]\n });\n setOpenLabelSelected(false);\n return;\n }\n\n // Otherwise, it is an open-label selection\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueString: changedOptionValue }]\n });\n setOpenLabelValue(changedOptionValue);\n setOpenLabelSelected(true);\n return;\n }\n\n if (changedOpenLabelValue !== null) {\n setOpenLabelValue(changedOpenLabelValue);\n\n // If open label is unchecked, remove it from answers\n if (changedOpenLabelValue === '') {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n // Otherwise, add open label to answers\n setOpenLabelValue(changedOpenLabelValue);\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueString: changedOpenLabelValue }]\n });\n }\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-open-choice-radio-answer-option-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <OpenChoiceRadioAnswerValueSetFields\n qItem={qItem}\n options={options}\n valueRadio={valueRadio}\n openLabelText={openLabelText}\n openLabelValue={openLabelValue}\n openLabelSelected={openLabelSelected}\n feedback={feedback}\n readOnly={readOnly}\n terminologyError={terminologyError}\n onValueChange={handleValueChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default OpenChoiceRadioAnswerValueSetItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ChangeEvent } from 'react';\nimport React from 'react';\nimport { ChoiceItemOrientation } from '../../../interfaces/choice.enum';\nimport type { QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport { StyledRadioGroup, StyledRequiredTypography } from '../Item.styles';\nimport RadioButtonWithOpenLabel from '../ItemParts/RadioButtonWithOpenLabel';\nimport RadioOptionList from '../ItemParts/RadioOptionList';\nimport { getChoiceOrientation } from '../../../utils/choice';\nimport type { TerminologyError } from '../../../hooks/useValueSetCodings';\nimport { StyledAlert } from '../../Alert.styles';\nimport ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';\nimport Typography from '@mui/material/Typography';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface OpenChoiceRadioAnswerValueSetFieldsProps {\n qItem: QuestionnaireItem;\n options: QuestionnaireItemAnswerOption[];\n valueRadio: string | null;\n openLabelText: string | null;\n openLabelValue: string | null;\n openLabelSelected: boolean;\n feedback: string;\n readOnly: boolean;\n terminologyError: TerminologyError;\n onValueChange: (changedOptionValue: string | null, changedOpenLabelValue: string | null) => void;\n}\n\nfunction OpenChoiceRadioAnswerValueSetFields(props: OpenChoiceRadioAnswerValueSetFieldsProps) {\n const {\n qItem,\n options,\n valueRadio,\n openLabelText,\n openLabelValue,\n openLabelSelected,\n feedback,\n readOnly,\n terminologyError,\n onValueChange\n } = props;\n\n const inputsFlexGrow = useRendererStylingStore.use.inputsFlexGrow();\n\n const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Vertical;\n\n if (options.length > 0) {\n return (\n <>\n <StyledRadioGroup\n id={qItem.type + '-' + qItem.linkId}\n row={orientation === ChoiceItemOrientation.Horizontal}\n sx={inputsFlexGrow ? { width: '100%', flexWrap: 'nowrap' } : {}}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n // If item.readOnly=true, do not allow any changes\n if (readOnly) {\n return;\n }\n\n onValueChange(e.target.value, null);\n }}\n value={valueRadio}\n data-test=\"q-item-radio-group\">\n <RadioOptionList options={options} readOnly={readOnly} fullWidth={inputsFlexGrow} />\n\n {openLabelText ? (\n <RadioButtonWithOpenLabel\n value={openLabelValue}\n label={openLabelText}\n readOnly={readOnly}\n isSelected={openLabelSelected}\n onInputChange={(input) => onValueChange(null, input)}\n />\n ) : null}\n </StyledRadioGroup>\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </>\n );\n }\n\n if (terminologyError.error) {\n return (\n <StyledAlert color=\"error\">\n <ErrorOutlineIcon color=\"error\" sx={{ pr: 0.75 }} />\n <Typography>\n There was an error fetching options from the terminology server for{' '}\n {terminologyError.answerValueSet}\n </Typography>\n </StyledAlert>\n );\n }\n\n return (\n <StyledAlert color=\"error\">\n <ErrorOutlineIcon color=\"error\" sx={{ pr: 0.75 }} />\n <Typography>Unable to fetch options from the questionnaire or launch context</Typography>\n </StyledAlert>\n );\n}\n\nexport default OpenChoiceRadioAnswerValueSetFields;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { OpenChoiceItemControl } from '../../../interfaces/choice.enum';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport OpenChoiceSelectAnswerOptionItem from './OpenChoiceSelectAnswerOptionItem';\nimport OpenChoiceSelectAnswerValueSetItem from './OpenChoiceSelectAnswerValueSetItem';\nimport OpenChoiceAutocompleteItem from './OpenChoiceAutocompleteItem';\nimport { getOpenChoiceControlType } from '../../../utils/openChoice';\nimport OpenChoiceCheckboxAnswerOptionItem from './OpenChoiceCheckboxAnswerOptionItem';\nimport OpenChoiceRadioAnswerOptionItem from './OpenChoiceRadioAnswerOptionItem';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentStylesAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport OpenChoiceCheckboxAnswerValueSetItem from './OpenChoiceCheckboxAnswerValueSetItem';\nimport OpenChoiceRadioAnswerValueSetItem from './OpenChoiceRadioAnswerValueSetItem';\n\ninterface OpenChoiceItemSwitcherProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute,\n PropsWithParentStylesAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction OpenChoiceItemSwitcher(props: OpenChoiceItemSwitcherProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n showMinimalView,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n switch (getOpenChoiceControlType(qItem)) {\n case OpenChoiceItemControl.Checkbox:\n if (qItem.answerValueSet) {\n return (\n <OpenChoiceCheckboxAnswerValueSetItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={qItem['repeats'] ?? false}\n renderingExtensions={renderingExtensions}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n } else {\n return (\n <OpenChoiceCheckboxAnswerOptionItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={qItem['repeats'] ?? false}\n renderingExtensions={renderingExtensions}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n case OpenChoiceItemControl.Radio:\n if (qItem.answerValueSet) {\n return (\n <OpenChoiceRadioAnswerValueSetItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={qItem['repeats'] ?? false}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n } else {\n return (\n <OpenChoiceRadioAnswerOptionItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={qItem['repeats'] ?? false}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n case OpenChoiceItemControl.Autocomplete:\n return (\n <OpenChoiceAutocompleteItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n case OpenChoiceItemControl.Select:\n if (qItem.answerValueSet) {\n return (\n <OpenChoiceSelectAnswerValueSetItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n } else {\n return (\n <OpenChoiceSelectAnswerOptionItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n default:\n return null;\n }\n}\n\nexport default OpenChoiceItemSwitcher;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport ChoiceItemSwitcher from '../ChoiceItems/ChoiceItemSwitcher';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport OpenChoiceItemSwitcher from '../OpenChoiceItems/OpenChoiceItemSwitcher';\nimport Typography from '@mui/material/Typography';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentStylesAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport StringItem from '../StringItem/StringItem';\nimport BooleanItem from '../BooleanItem/BooleanItem';\nimport TimeItem from '../TimeItem/TimeItem';\nimport TextItem from '../TextItem/TextItem';\nimport DisplayItem from '../DisplayItem/DisplayItem';\nimport DecimalItem from '../DecimalItem/DecimalItem';\nimport UrlItem from '../UrlItem/UrlItem';\nimport CustomDateItem from '../DateTimeItems/CustomDateItem/CustomDateItem';\nimport { isSpecificItemControl } from '../../../utils';\nimport SliderItem from '../SliderItem/SliderItem';\nimport IntegerItem from '../IntegerItem/IntegerItem';\nimport AttachmentItem from '../AttachmentItem/AttachmentItem';\nimport CustomDateTimeItem from '../DateTimeItems/CustomDateTimeItem/CustomDateTimeItem';\nimport QuantityItem from '../QuantityItem/QuantityItem';\nimport { useQuestionnaireStore } from '../../../stores';\n\ninterface SingleItemSwitcherProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute,\n PropsWithParentStylesAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction SingleItemSwitcher(props: SingleItemSwitcherProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n showMinimalView,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange,\n parentStyles\n } = props;\n\n const qItemOverrideComponents = useQuestionnaireStore.use.qItemOverrideComponents();\n const QItemOverrideComponent = qItemOverrideComponents[qItem.linkId];\n\n // If a qItem override component is defined for this item, render it\n // Don't get too strict with the \"typeof\" checks for now\n if (QItemOverrideComponent && typeof QItemOverrideComponent === 'function') {\n return (\n <QItemOverrideComponent\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n onQrRepeatGroupChange={() => {}} // Not needed for single items, use empty function\n />\n );\n }\n\n // Otherwise, render the default form component based on the item type\n switch (qItem.type) {\n case 'display':\n return (\n <DisplayItem\n qItem={qItem}\n qrItem={qrItem}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n parentStyles={parentStyles}\n />\n );\n case 'boolean':\n return (\n <BooleanItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'decimal':\n return (\n <DecimalItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'integer':\n if (isSpecificItemControl(qItem, 'slider')) {\n return (\n <SliderItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n }\n\n return (\n <IntegerItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'date':\n return (\n <CustomDateItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'dateTime':\n return (\n <CustomDateTimeItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'time':\n return (\n <TimeItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'string':\n return (\n <StringItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'text':\n return (\n <TextItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'url':\n return (\n <UrlItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'choice':\n return (\n <ChoiceItemSwitcher\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'open-choice':\n return (\n <OpenChoiceItemSwitcher\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'attachment':\n return (\n <AttachmentItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'reference':\n // FIXME reference item uses the same component as string item currently\n return (\n <StringItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n case 'quantity':\n return (\n <QuantityItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n parentIsReadOnly={parentIsReadOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n default:\n return (\n <Typography>\n Item type <b>{qItem.type}</b> not supported yet, or something has went wrong. If your\n questionnnaire is not a FHIR R4 resource, there might be issues rendering it.\n </Typography>\n );\n }\n}\n\nexport default SingleItemSwitcher;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback, useState } from 'react';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithRenderingExtensionsAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport debounce from 'lodash.debounce';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { DEBOUNCE_DURATION } from '../../../utils/debounce';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport StringField from './StringField';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport useStringCalculatedExpression from '../../../hooks/useStringCalculatedExpression';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface StringItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithRenderingExtensionsAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n parentStyles?: Record<string, string>;\n}\nfunction StringItem(props: StringItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange,\n parentStyles\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const { displayUnit, displayPrompt, entryFormat } = renderingExtensions;\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n let valueString = '';\n if (qrItem?.answer && qrItem?.answer[0].valueString) {\n valueString = qrItem.answer[0].valueString;\n }\n\n const [input, setInput] = useState(valueString);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, input);\n\n // Process calculated expressions\n const { calcExpUpdated } = useStringCalculatedExpression({\n qItem: qItem,\n inputValue: input,\n onChangeByCalcExpressionString: (newValueString: string) => {\n setInput(newValueString);\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueString: newValueString }]\n });\n },\n onChangeByCalcExpressionNull: () => {\n setInput('');\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n });\n\n // Event handlers\n function handleChange(newInput: string) {\n setInput(newInput);\n updateQrItemWithDebounce(newInput);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const updateQrItemWithDebounce = useCallback(\n debounce((input: string) => {\n const emptyQrItem = createEmptyQrItem(qItem, answerKey);\n if (input !== '') {\n onQrItemChange({ ...emptyQrItem, answer: [{ id: answerKey, valueString: input }] });\n } else {\n onQrItemChange(emptyQrItem);\n }\n }, DEBOUNCE_DURATION),\n [onQrItemChange, qItem]\n ); // Dependencies are tested, debounce is causing eslint to not recognise dependencies\n\n if (isRepeated) {\n return (\n <StringField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={input}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n onInputChange={handleChange}\n isTabled={isTabled}\n />\n );\n }\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-string-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} parentStyles={parentStyles} />}\n fieldChildren={\n <StringField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={input}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n onInputChange={handleChange}\n isTabled={isTabled}\n />\n }\n feedback={feedback}\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default StringItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport { StandardTextField } from '../Textfield.styles';\nimport FadingCheckIcon from '../ItemParts/FadingCheckIcon';\nimport { useRendererStylingStore } from '../../../stores';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\n\ninterface StringFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n input: string;\n feedback: string;\n displayPrompt: string;\n displayUnit: string;\n entryFormat: string;\n readOnly: boolean;\n calcExpUpdated: boolean;\n onInputChange: (value: string) => void;\n}\n\nfunction StringField(props: StringFieldProps) {\n const {\n linkId,\n itemType,\n input,\n feedback,\n displayPrompt,\n displayUnit,\n entryFormat,\n readOnly,\n isTabled,\n calcExpUpdated,\n onInputChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n return (\n <StandardTextField\n id={itemType + '-' + linkId}\n fullWidth\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n value={input}\n error={!!feedback}\n onChange={(event) => onInputChange(event.target.value)}\n label={displayPrompt}\n placeholder={entryFormat}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n size=\"small\"\n slotProps={{\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <InputAdornment position=\"end\">\n <FadingCheckIcon fadeIn={calcExpUpdated} disabled={readOnly} />\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </InputAdornment>\n )\n }\n }}\n helperText={feedback}\n data-test=\"q-item-string-field\"\n />\n );\n}\n\nexport default StringField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from 'react';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport { useQuestionnaireStore } from '../stores';\n\ninterface UseStringCalculatedExpression {\n calcExpUpdated: boolean;\n}\n\ninterface useStringCalculatedExpressionProps {\n qItem: QuestionnaireItem;\n inputValue: string;\n onChangeByCalcExpressionString: (newValueString: string) => void;\n onChangeByCalcExpressionNull: () => void;\n}\n\nfunction useStringCalculatedExpression(\n props: useStringCalculatedExpressionProps\n): UseStringCalculatedExpression {\n const { qItem, inputValue, onChangeByCalcExpressionString, onChangeByCalcExpressionNull } = props;\n\n const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();\n\n const [calcExpUpdated, setCalcExpUpdated] = useState(false);\n\n useEffect(\n () => {\n const calcExpression = calculatedExpressions[qItem.linkId]?.find(\n (exp) => exp.from === 'item'\n );\n\n if (!calcExpression) {\n return;\n }\n\n // If both input and calculated value are falsy, there is nothing to update\n const inputAndCalcValueAreBothFalsy = inputValue === '' && !calcExpression.value;\n if (inputAndCalcValueAreBothFalsy) {\n return;\n }\n\n // only update if calculated value is different from current value\n if (\n calcExpression.value !== inputValue &&\n (typeof calcExpression.value === 'string' ||\n typeof calcExpression.value === 'number' ||\n calcExpression.value === null)\n ) {\n // update ui to show calculated value changes\n setCalcExpUpdated(true);\n const timeoutId = setTimeout(() => {\n setCalcExpUpdated(false);\n }, 500);\n\n // calculatedExpression value is null\n if (calcExpression.value === null) {\n onChangeByCalcExpressionNull();\n return () => clearTimeout(timeoutId);\n }\n\n // calculatedExpression value is a string or number\n const newInputValue =\n typeof calcExpression.value === 'string'\n ? calcExpression.value\n : calcExpression.value.toString();\n\n onChangeByCalcExpressionString(newInputValue);\n return () => clearTimeout(timeoutId);\n }\n },\n // Only trigger this effect if calculatedExpression of item changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [calculatedExpressions]\n );\n\n return { calcExpUpdated: calcExpUpdated };\n}\n\nexport default useStringCalculatedExpression;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { memo } from 'react';\nimport Box from '@mui/material/Box';\nimport { ChoiceItemOrientation } from '../../../interfaces/choice.enum';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport ChoiceRadioSingle from '../ChoiceItems/ChoiceRadioSingle';\nimport { StyledRadioGroup, StyledRequiredTypography } from '../Item.styles';\nimport { getChoiceOrientation } from '../../../utils/choice';\nimport FadingCheckIcon from '../ItemParts/FadingCheckIcon';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport { isSpecificItemControl } from '../../../utils';\nimport ClearInputButton from '../ItemParts/ClearInputButton';\nimport { useRendererStylingStore } from '../../../stores';\nimport { StandardCheckbox } from '../../Checkbox.styles';\n\ninterface BooleanFieldProps {\n qItem: QuestionnaireItem;\n readOnly: boolean;\n valueBoolean: boolean | undefined;\n feedback: string;\n calcExpUpdated: boolean;\n onCheckedChange: (newValue: string) => void;\n onClear: () => void;\n}\n\nconst BooleanField = memo(function BooleanField(props: BooleanFieldProps) {\n const { qItem, readOnly, valueBoolean, feedback, calcExpUpdated, onCheckedChange, onClear } =\n props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const inputsFlexGrow = useRendererStylingStore.use.inputsFlexGrow();\n const reverseBooleanYesNo = useRendererStylingStore.use.reverseBooleanYesNo();\n const hideClearButton = useRendererStylingStore.use.hideClearButton();\n\n const booleanAsCheckbox = isSpecificItemControl(qItem, 'check-box');\n\n // defaults to horizontal, only set to vertical if explicitly set\n const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Horizontal;\n\n const selection = valueBoolean === undefined ? null : valueBoolean.toString();\n\n return (\n <>\n <Box\n display=\"flex\"\n sx={{\n justifyContent: 'space-between',\n alignItems: { xs: 'start', sm: 'center' },\n flexDirection: { xs: 'column', sm: 'row' }\n }}>\n {booleanAsCheckbox ? (\n <FormControlLabel\n id={qItem.type + '-' + qItem.linkId}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n aria-readonly={readOnly && readOnlyVisualStyle === 'readonly'}\n control={\n <StandardCheckbox\n size=\"small\"\n checked={selection === 'true'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n onChange={() => {\n // If item.readOnly=true, do not allow any changes\n if (readOnly) {\n return;\n }\n\n if (selection === 'true') {\n onCheckedChange('false');\n }\n\n if (selection === 'false' || selection === null) {\n onCheckedChange('true');\n }\n }}\n />\n }\n label=\"\"\n />\n ) : (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n sx={inputsFlexGrow ? { width: '100%', flexWrap: 'nowrap' } : {}}>\n <StyledRadioGroup\n id={qItem.type + '-' + qItem.linkId}\n row={orientation === ChoiceItemOrientation.Horizontal}\n sx={inputsFlexGrow ? { width: '100%', flexWrap: 'nowrap' } : {}}\n onChange={(e) => {\n // If item.readOnly=true, do not allow any changes\n if (readOnly) {\n return;\n }\n\n onCheckedChange(e.target.value);\n }}\n value={selection}>\n {reverseBooleanYesNo ? (\n <>\n <ChoiceRadioSingle\n value=\"false\"\n label=\"No\"\n readOnly={readOnly}\n fullWidth={inputsFlexGrow}\n />\n <ChoiceRadioSingle\n value=\"true\"\n label=\"Yes\"\n readOnly={readOnly}\n fullWidth={inputsFlexGrow}\n />\n </>\n ) : (\n <>\n <ChoiceRadioSingle\n value=\"true\"\n label=\"Yes\"\n readOnly={readOnly}\n fullWidth={inputsFlexGrow}\n />\n <ChoiceRadioSingle\n value=\"false\"\n label=\"No\"\n readOnly={readOnly}\n fullWidth={inputsFlexGrow}\n />\n </>\n )}\n </StyledRadioGroup>\n\n <Box flexGrow={1} />\n\n <FadingCheckIcon fadeIn={calcExpUpdated} disabled={readOnly} />\n </Box>\n )}\n\n {hideClearButton ? null : (\n <ClearInputButton\n buttonShown={valueBoolean !== undefined}\n readOnly={readOnly}\n onClear={onClear}\n />\n )}\n </Box>\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </>\n );\n});\n\nexport default BooleanField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { BaseItemProps } from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport BooleanField from './BooleanField';\nimport Box from '@mui/material/Box';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useBooleanCalculatedExpression from '../../../hooks/useBooleanCalculatedExpression';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface BooleanItemProps extends BaseItemProps {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction BooleanItem(props: BooleanItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks - there's no string-based input here\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n let valueBoolean: boolean | undefined = undefined;\n if (qrItem?.answer?.[0]?.valueBoolean !== undefined) {\n valueBoolean = qrItem.answer[0].valueBoolean;\n }\n\n // Process calculated expressions\n const { calcExpUpdated } = useBooleanCalculatedExpression({\n qItem: qItem,\n booleanValue: valueBoolean,\n onChangeByCalcExpressionBoolean: (newValueBoolean: boolean) => {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueBoolean: newValueBoolean }]\n });\n },\n onChangeByCalcExpressionNull: () => {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n });\n\n // Event handlers\n function handleValueChange(newValue: string) {\n switch (newValue) {\n case 'true':\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueBoolean: true }]\n });\n break;\n case 'false':\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueBoolean: false }]\n });\n break;\n default:\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n break;\n }\n }\n\n function handleClear() {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n\n if (isTabled) {\n return (\n <Box display=\"flex\" justifyContent=\"center\">\n <BooleanField\n qItem={qItem}\n readOnly={readOnly}\n valueBoolean={valueBoolean}\n feedback={feedback}\n calcExpUpdated={calcExpUpdated}\n onCheckedChange={handleValueChange}\n onClear={handleClear}\n />\n </Box>\n );\n }\n\n if (isRepeated) {\n return (\n <BooleanField\n qItem={qItem}\n readOnly={readOnly}\n valueBoolean={valueBoolean}\n feedback={feedback}\n calcExpUpdated={calcExpUpdated}\n onCheckedChange={handleValueChange}\n onClear={handleClear}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-boolean-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <BooleanField\n qItem={qItem}\n readOnly={readOnly}\n valueBoolean={valueBoolean}\n feedback={feedback}\n calcExpUpdated={calcExpUpdated}\n onCheckedChange={handleValueChange}\n onClear={handleClear}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default BooleanItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from 'react';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport { useQuestionnaireStore } from '../stores';\n\ninterface UseBooleanCalculatedExpression {\n calcExpUpdated: boolean;\n}\n\ninterface UseBooleanCalculatedExpressionProps {\n qItem: QuestionnaireItem;\n booleanValue: boolean | undefined;\n onChangeByCalcExpressionBoolean: (newValueBoolean: boolean) => void;\n onChangeByCalcExpressionNull: () => void;\n}\n\nfunction useBooleanCalculatedExpression(\n props: UseBooleanCalculatedExpressionProps\n): UseBooleanCalculatedExpression {\n const { qItem, booleanValue, onChangeByCalcExpressionBoolean, onChangeByCalcExpressionNull } =\n props;\n\n const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();\n\n const [calcExpUpdated, setCalcExpUpdated] = useState(false);\n\n useEffect(\n () => {\n const calcExpression = calculatedExpressions[qItem.linkId]?.find(\n (exp) => exp.from === 'item'\n );\n\n if (!calcExpression) {\n return;\n }\n\n // only update if calculated value is different from current value\n if (\n calcExpression.value !== booleanValue &&\n (typeof calcExpression.value === 'boolean' || calcExpression.value === null)\n ) {\n // update ui to show calculated value changes\n setCalcExpUpdated(true);\n const timeoutId = setTimeout(() => {\n setCalcExpUpdated(false);\n }, 500);\n\n // calculatedExpression value is null\n if (calcExpression.value === null) {\n onChangeByCalcExpressionNull();\n return () => clearTimeout(timeoutId);\n }\n\n // calculatedExpression value is boolean\n onChangeByCalcExpressionBoolean(calcExpression.value);\n return () => clearTimeout(timeoutId);\n }\n },\n // Only trigger this effect if calculatedExpression of item changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [calculatedExpressions]\n );\n\n return { calcExpUpdated: calcExpUpdated };\n}\n\nexport default useBooleanCalculatedExpression;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport type { Dayjs } from 'dayjs';\nimport { LocalizationProvider, TimePicker as MuiTimePicker } from '@mui/x-date-pickers';\nimport { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface TimeFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n value: Dayjs | null;\n displayPrompt: string;\n entryFormat: string;\n readOnly: boolean;\n onTimeChange: (newValue: Dayjs | null) => unknown;\n}\n\nfunction TimeField(props: TimeFieldProps) {\n const { linkId, itemType, value, displayPrompt, entryFormat, readOnly, isTabled, onTimeChange } =\n props;\n\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n return (\n <LocalizationProvider dateAdapter={AdapterDayjs}>\n <MuiTimePicker\n // TODO no way to add an id attribute to this time input field\n // TODO ignore this - we will be creating our own custom time field anyway\n name={itemType + '-' + linkId}\n format={entryFormat !== '' ? entryFormat : 'hh:mm a'}\n value={value}\n disabled={readOnly}\n label={displayPrompt}\n sx={{ maxWidth: !isTabled ? textFieldWidth : 3000, minWidth: 160 }}\n slotProps={{\n textField: {\n fullWidth: true\n }\n }}\n onChange={onTimeChange}\n />\n </LocalizationProvider>\n );\n}\n\nexport default TimeField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { BaseItemProps } from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport TimeField from './TimeField';\nimport type { Dayjs } from 'dayjs';\nimport dayjs from 'dayjs';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface TimeItemProps extends BaseItemProps {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction TimeItem(props: TimeItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n const { displayPrompt, entryFormat } = renderingExtensions;\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n let timeString: string | null = null;\n if (qrItem?.answer && qrItem?.answer[0].valueTime) {\n timeString = qrItem.answer[0].valueTime;\n }\n const timeDayJs = timeString ? dayjs(timeString) : null;\n\n // Event handlers\n function handleTimeChange(newValue: Dayjs | null) {\n const emptyQrItem = createEmptyQrItem(qItem, answerKey);\n if (newValue) {\n onQrItemChange({ ...emptyQrItem, answer: [{ id: answerKey, valueTime: newValue.format() }] });\n } else {\n onQrItemChange(emptyQrItem);\n }\n }\n\n if (isRepeated) {\n return (\n <TimeField\n linkId={qItem.linkId}\n itemType={qItem.type}\n value={timeDayJs}\n displayPrompt={displayPrompt}\n entryFormat={entryFormat}\n readOnly={readOnly}\n onTimeChange={handleTimeChange}\n isTabled={isTabled}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-time-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <TimeField\n linkId={qItem.linkId}\n itemType={qItem.type}\n value={timeDayJs}\n displayPrompt={displayPrompt}\n entryFormat={entryFormat}\n readOnly={readOnly}\n onTimeChange={handleTimeChange}\n isTabled={isTabled}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default TimeItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback, useState } from 'react';\nimport type { BaseItemProps } from '../../../interfaces/renderProps.interface';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport debounce from 'lodash.debounce';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { DEBOUNCE_DURATION } from '../../../utils/debounce';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport TextField from './TextField';\nimport useStringCalculatedExpression from '../../../hooks/useStringCalculatedExpression';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface TextItemProps extends BaseItemProps {}\n\nfunction TextItem(props: TextItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n renderingExtensions,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const { displayUnit, displayPrompt, entryFormat } = renderingExtensions;\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n let valueText = '';\n if (qrItem?.answer && qrItem?.answer[0].valueString) {\n valueText = qrItem.answer[0].valueString;\n }\n\n const [input, setInput] = useState(valueText);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, input);\n\n // Process calculated expressions\n const { calcExpUpdated } = useStringCalculatedExpression({\n qItem: qItem,\n inputValue: input,\n onChangeByCalcExpressionString: (newValueString: string) => {\n setInput(newValueString);\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueString: newValueString }]\n });\n },\n onChangeByCalcExpressionNull: () => {\n setInput('');\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n });\n\n // Event handlers\n function handleInputChange(newInput: string) {\n setInput(newInput);\n updateQrItemWithDebounce(newInput);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const updateQrItemWithDebounce = useCallback(\n debounce((input: string) => {\n const emptyQrItem = createEmptyQrItem(qItem, answerKey);\n if (input !== '') {\n onQrItemChange({ ...emptyQrItem, answer: [{ id: answerKey, valueString: input }] });\n } else {\n onQrItemChange(emptyQrItem);\n }\n }, DEBOUNCE_DURATION),\n [onQrItemChange, qItem]\n ); // Dependencies are tested, debounce is causing eslint to not recognise dependencies\n\n if (isRepeated) {\n return (\n <TextField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={input}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n onInputChange={handleInputChange}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-text-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <TextField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={input}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n onInputChange={handleInputChange}\n />\n }\n feedback={feedback}\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default TextItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport MuiTextField from './MuiTextField';\nimport FadingCheckIcon from '../ItemParts/FadingCheckIcon';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface TextFieldProps {\n linkId: string;\n itemType: string;\n input: string;\n feedback: string;\n displayPrompt: string;\n displayUnit: string;\n entryFormat: string;\n readOnly: boolean;\n calcExpUpdated: boolean;\n onInputChange: (value: string) => void;\n}\n\nfunction TextField(props: TextFieldProps) {\n const {\n linkId,\n itemType,\n input,\n feedback,\n displayPrompt,\n displayUnit,\n entryFormat,\n readOnly,\n calcExpUpdated,\n onInputChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n\n return (\n <MuiTextField\n id={itemType + '-' + linkId}\n value={input}\n error={!!feedback}\n onChange={(event) => onInputChange(event.target.value)}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n label={displayPrompt}\n placeholder={entryFormat}\n fullWidth\n multiline\n size=\"small\"\n minRows={3}\n slotProps={{\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <InputAdornment position=\"end\">\n <FadingCheckIcon fadeIn={calcExpUpdated} disabled={readOnly} />\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </InputAdornment>\n )\n }\n }}\n helperText={feedback}\n data-test=\"q-item-text-field\"\n />\n );\n}\n\nexport default TextField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport TextField from '@mui/material/TextField';\n\nconst MuiTextField = TextField;\n\nexport default MuiTextField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { memo } from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport { isSpecificItemControl } from '../../../utils';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentStylesAttribute\n} from '../../../interfaces/renderProps.interface';\nimport Divider from '@mui/material/Divider';\nimport ItemLabel from '../ItemParts/ItemLabel';\nimport type { RenderingExtensions } from '../../../hooks/useRenderingExtensions';\n\ninterface DisplayItemProps\n extends PropsWithParentIsReadOnlyAttribute,\n PropsWithParentStylesAttribute {\n qItem: QuestionnaireItem;\n qrItem?: QuestionnaireResponseItem | null;\n renderingExtensions?: RenderingExtensions;\n}\n\nconst DisplayItem = memo(function DisplayItem(props: DisplayItemProps) {\n const { qItem, parentIsReadOnly, parentStyles } = props;\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const isContextDisplay = isSpecificItemControl(qItem, 'context-display');\n if (isContextDisplay) {\n return null;\n }\n\n const isFlyover = isSpecificItemControl(qItem, 'flyover');\n if (isFlyover) {\n return null;\n }\n\n const isDivider = isSpecificItemControl(qItem, 'divider');\n if (isDivider) {\n return <Divider sx={{ mt: 1.5, mb: 1 }} />;\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-display-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemLabel\n qItem={qItem}\n readOnly={readOnly}\n isDisplayItem={true}\n parentStyles={parentStyles}\n />\n </FullWidthFormComponentBox>\n );\n});\n\nexport default DisplayItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback, useState } from 'react';\nimport type { BaseItemProps } from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport debounce from 'lodash.debounce';\nimport { DEBOUNCE_DURATION } from '../../../utils/debounce';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport DecimalField from './DecimalField';\nimport {\n parseDecimalStringToFloat,\n parseDecimalStringWithPrecision\n} from '../../../utils/parseInputs';\nimport { getDecimalPrecision } from '../../../utils/itemControl';\nimport useDecimalCalculatedExpression from '../../../hooks/useDecimalCalculatedExpression';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport Box from '@mui/material/Box';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface DecimalItemProps extends BaseItemProps {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction DecimalItem(props: DecimalItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const precision = getDecimalPrecision(qItem);\n const { displayUnit, displayPrompt, entryFormat } = renderingExtensions;\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n let valueDecimal = 0.0;\n let initialInput = '';\n if (qrItem?.answer) {\n if (qrItem?.answer[0].valueDecimal) {\n valueDecimal = qrItem.answer[0].valueDecimal;\n }\n\n if (qrItem?.answer[0].valueInteger) {\n valueDecimal = qrItem.answer[0].valueInteger;\n }\n\n initialInput = precision ? valueDecimal.toFixed(precision) : valueDecimal.toString();\n }\n\n const [input, setInput] = useState(initialInput);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks - there's no string-based input here\n const feedback = useValidationFeedback(qItem, feedbackFromParent, input);\n\n // Process calculated expressions\n const { calcExpUpdated } = useDecimalCalculatedExpression({\n qItem: qItem,\n inputValue: input,\n precision: precision,\n onChangeByCalcExpressionDecimal: (newValueDecimal: number) => {\n setInput(\n typeof precision === 'number'\n ? newValueDecimal.toFixed(precision)\n : newValueDecimal.toString()\n );\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueDecimal: newValueDecimal }]\n });\n },\n onChangeByCalcExpressionNull: () => {\n setInput('');\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n });\n\n // Event handlers\n function handleInputChange(newInput: string) {\n const parsedNewInput: string = parseDecimalStringWithPrecision(newInput, precision);\n\n setInput(parsedNewInput);\n updateQrItemWithDebounce(parsedNewInput);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const updateQrItemWithDebounce = useCallback(\n debounce((parsedNewInput: string) => {\n const emptyQrItem = createEmptyQrItem(qItem, answerKey);\n if (parsedNewInput === '') {\n onQrItemChange(emptyQrItem);\n } else {\n onQrItemChange({\n ...emptyQrItem,\n answer: precision\n ? [\n {\n id: answerKey,\n valueDecimal: parseDecimalStringToFloat(parsedNewInput, precision)\n }\n ]\n : [{ id: answerKey, valueDecimal: parseFloat(parsedNewInput) }]\n });\n }\n }, DEBOUNCE_DURATION),\n [onQrItemChange, qItem, displayUnit, precision]\n ); // Dependencies are tested, debounce is causing eslint to not recognise dependencies\n\n if (isRepeated) {\n return (\n <Box data-test=\"q-item-decimal-box\">\n <DecimalField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={input}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n isTabled={isTabled}\n onInputChange={handleInputChange}\n />\n </Box>\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-decimal-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <DecimalField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={input}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n isTabled={isTabled}\n onInputChange={handleInputChange}\n />\n }\n feedback={feedback}\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default DecimalItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport FadingCheckIcon from '../ItemParts/FadingCheckIcon';\nimport { StandardTextField } from '../Textfield.styles';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport { useRendererStylingStore } from '../../../stores';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\n\ninterface DecimalFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n input: string;\n feedback: string;\n displayPrompt: string;\n displayUnit: string;\n entryFormat: string;\n readOnly: boolean;\n calcExpUpdated: boolean;\n onInputChange: (value: string) => void;\n}\n\nfunction DecimalField(props: DecimalFieldProps) {\n const {\n linkId,\n itemType,\n input,\n feedback,\n displayPrompt,\n displayUnit,\n entryFormat,\n readOnly,\n calcExpUpdated,\n isTabled,\n onInputChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n return (\n <StandardTextField\n id={itemType + '-' + linkId}\n value={input}\n error={!!feedback}\n onChange={(event) => onInputChange(event.target.value)}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n label={displayPrompt}\n placeholder={entryFormat === '' ? '0.0' : entryFormat}\n textFieldWidth={textFieldWidth}\n fullWidth\n isTabled={isTabled}\n size=\"small\"\n slotProps={{\n htmlInput: { inputMode: 'numeric', pattern: '[0-9]*' },\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <InputAdornment position={'end'}>\n <FadingCheckIcon fadeIn={calcExpUpdated} disabled={readOnly} />\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </InputAdornment>\n )\n }\n }}\n helperText={feedback}\n data-test=\"q-item-decimal-field\"\n />\n );\n}\n\nexport default DecimalField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from 'react';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport { useQuestionnaireStore } from '../stores';\n\ninterface UseDecimalCalculatedExpression {\n calcExpUpdated: boolean;\n}\n\ninterface UseDecimalCalculatedExpressionProps {\n qItem: QuestionnaireItem;\n inputValue: string;\n precision: number | null;\n onChangeByCalcExpressionDecimal: (calcExpressionValue: number) => void;\n onChangeByCalcExpressionNull: () => void;\n}\n\nfunction useDecimalCalculatedExpression(\n props: UseDecimalCalculatedExpressionProps\n): UseDecimalCalculatedExpression {\n const {\n qItem,\n inputValue,\n precision,\n onChangeByCalcExpressionDecimal,\n onChangeByCalcExpressionNull\n } = props;\n\n const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();\n\n const [calcExpUpdated, setCalcExpUpdated] = useState(false);\n\n useEffect(\n () => {\n const calcExpression = calculatedExpressions[qItem.linkId]?.find(\n (exp) => exp.from === 'item'\n );\n\n if (!calcExpression) {\n return;\n }\n\n // only update if calculated value is different from current value\n if (\n calcExpression.value !== inputValue &&\n (typeof calcExpression.value === 'number' || calcExpression.value === null)\n ) {\n const calcExpressionValue =\n typeof calcExpression.value === 'number' && typeof precision === 'number'\n ? parseFloat(calcExpression.value.toFixed(precision))\n : calcExpression.value;\n\n // only update if calculated value is different from current value\n if (calcExpressionValue !== parseFloat(inputValue)) {\n // update ui to show calculated value changes\n setCalcExpUpdated(true);\n const timeoutId = setTimeout(() => {\n setCalcExpUpdated(false);\n }, 500);\n\n // calculatedExpression value is null\n if (calcExpressionValue === null) {\n onChangeByCalcExpressionNull();\n return () => clearTimeout(timeoutId);\n }\n\n // calculatedExpression value is a number\n onChangeByCalcExpressionDecimal(calcExpressionValue);\n return () => clearTimeout(timeoutId);\n }\n }\n },\n // Only trigger this effect if calculatedExpression of item changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [calculatedExpressions]\n );\n\n return { calcExpUpdated: calcExpUpdated };\n}\n\nexport default useDecimalCalculatedExpression;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback, useState } from 'react';\nimport type { BaseItemProps } from '../../../interfaces/renderProps.interface';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport debounce from 'lodash.debounce';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { DEBOUNCE_DURATION } from '../../../utils/debounce';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport UrlField from './UrlField';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface UrlItemProps extends BaseItemProps {}\n\nfunction UrlItem(props: UrlItemProps) {\n const {\n qItem,\n qrItem,\n renderingExtensions,\n isRepeated,\n isTabled,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const { displayUnit, displayPrompt, entryFormat } = renderingExtensions;\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n let valueUri = '';\n if (qrItem?.answer && qrItem?.answer[0].valueUri) {\n valueUri = qrItem.answer[0].valueUri;\n }\n\n const [input, setInput] = useState(valueUri);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, input);\n\n // Event handlers\n function handleChange(newInput: string) {\n setInput(newInput);\n updateQrItemWithDebounce(newInput);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const updateQrItemWithDebounce = useCallback(\n debounce((input: string) => {\n const emptyQrItem = createEmptyQrItem(qItem, answerKey);\n if (input !== '') {\n onQrItemChange({ ...emptyQrItem, answer: [{ id: answerKey, valueUri: input }] });\n } else {\n onQrItemChange(emptyQrItem);\n }\n }, DEBOUNCE_DURATION),\n [onQrItemChange, qItem]\n ); // Dependencies are tested, debounce is causing eslint to not recognise dependencies\n\n if (isRepeated) {\n return (\n <UrlField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={input}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n onInputChange={handleChange}\n isTabled={isTabled}\n />\n );\n }\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-url-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <UrlField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={input}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n onInputChange={handleChange}\n isTabled={isTabled}\n />\n }\n feedback={feedback}\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default UrlItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport { StandardTextField } from '../Textfield.styles';\nimport { useRendererStylingStore } from '../../../stores';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\n\ninterface UrlFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n input: string;\n feedback: string;\n displayPrompt: string;\n displayUnit: string;\n entryFormat: string;\n readOnly: boolean;\n onInputChange: (value: string) => void;\n}\n\nfunction UrlField(props: UrlFieldProps) {\n const {\n linkId,\n itemType,\n input,\n feedback,\n displayPrompt,\n displayUnit,\n entryFormat,\n readOnly,\n isTabled,\n onInputChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n return (\n <StandardTextField\n id={itemType + '-' + linkId}\n fullWidth\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n value={input}\n error={!!feedback}\n onChange={(event) => onInputChange(event.target.value)}\n label={displayPrompt}\n placeholder={entryFormat}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n size=\"small\"\n slotProps={{\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <InputAdornment position=\"end\">\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </InputAdornment>\n )\n }\n }}\n helperText={feedback}\n data-test=\"q-item-url-field\"\n />\n );\n}\n\nexport default UrlField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport type { BaseItemProps } from '../../../../interfaces/renderProps.interface';\nimport useReadOnly from '../../../../hooks/useReadOnly';\nimport { FullWidthFormComponentBox } from '../../../Box.styles';\nimport ItemFieldGrid from '../../ItemParts/ItemFieldGrid';\nimport {\n parseFhirDateToDisplayDate,\n parseInputDateToFhirDate,\n validateDateInput\n} from '../utils/parseDate';\nimport { createEmptyQrItem } from '../../../../utils/qrItem';\nimport useDateValidation from '../../../../hooks/useDateValidation';\nimport CustomDateField from './CustomDateField';\nimport { useQuestionnaireStore } from '../../../../stores';\nimport ItemLabel from '../../ItemParts/ItemLabel';\n\ninterface CustomDateItemProps extends BaseItemProps {}\n\nfunction CustomDateItem(props: CustomDateItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n const { displayPrompt, entryFormat } = renderingExtensions;\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrDate = qrItem ?? createEmptyQrItem(qItem, answerKey);\n\n let valueDate: string = '';\n if (qrDate.answer) {\n if (qrDate.answer[0].valueDate) {\n valueDate = qrDate.answer[0].valueDate;\n } else if (qrDate.answer[0].valueDateTime) {\n valueDate = qrDate.answer[0].valueDateTime;\n }\n }\n\n const { displayDate, dateParseFail } = parseFhirDateToDisplayDate(valueDate);\n\n const [input, setInput] = useState(displayDate);\n const [focused, setFocused] = useState(false);\n\n // Perform validation checks\n const errorFeedback = useDateValidation(input, dateParseFail);\n\n function handleSelectDate(selectedDate: string) {\n setInput(selectedDate);\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueDate: parseInputDateToFhirDate(selectedDate) }]\n });\n }\n\n function handleInputChange(newInput: string) {\n setInput(newInput);\n\n if (newInput === '') {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n\n if (!validateDateInput(newInput)) {\n return;\n }\n\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueDate: parseInputDateToFhirDate(newInput) }]\n });\n }\n\n if (isRepeated) {\n return (\n <CustomDateField\n linkId={qItem.linkId}\n itemType={qItem.type}\n valueDate={displayDate}\n input={input}\n feedback={errorFeedback ?? ''}\n isFocused={focused}\n displayPrompt={displayPrompt}\n entryFormat={entryFormat}\n readOnly={readOnly}\n isPartOfDateTime={false}\n isTabled={isTabled}\n setFocused={setFocused}\n onInputChange={handleInputChange}\n onSelectDate={handleSelectDate}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-date-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <CustomDateField\n linkId={qItem.linkId}\n itemType={qItem.type}\n valueDate={displayDate}\n input={input}\n feedback={errorFeedback ?? ''}\n isFocused={focused}\n displayPrompt={displayPrompt}\n entryFormat={entryFormat}\n readOnly={readOnly}\n isPartOfDateTime={false}\n isTabled={isTabled}\n setFocused={setFocused}\n onInputChange={handleInputChange}\n onSelectDate={handleSelectDate}\n />\n }\n feedback={errorFeedback ?? undefined}\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default CustomDateItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport dayjs from 'dayjs';\n\nconst inputMatchRegex = /(\\d{4}|\\d{3}|\\d{2})/g;\n\nexport function validateDateInput(input: string) {\n const matches = input.match(inputMatchRegex);\n\n if (!matches) {\n return false;\n }\n\n const separator = input.includes('/') ? '/' : null;\n\n if (matches.length === 1) {\n // separator not supposed to be present if only one match present\n if (separator) {\n return false;\n }\n\n return matches[0].length === 4;\n }\n\n // Invalid if separator is not present\n if (!separator) {\n return false;\n }\n\n // Invalid if num of slots don't match the number of regex matches\n const slotsMatched = input.split(separator);\n if (slotsMatched.length != matches.length) {\n return false;\n }\n\n // Handle MM/YYYY format\n if (matches.length === 2) {\n return validateTwoMatches(matches[0], matches[1]);\n }\n\n // Handle DD/MM/YYYY format\n if (matches.length === 3) {\n return validateThreeMatches(matches[0], matches[1], matches[2]);\n }\n\n return false;\n}\n\nexport function validateTwoMatches(monthInput: string, yearInput: string) {\n const monthNum = parseInt(monthInput, 10);\n if (monthNum < 1 || monthNum > 12) {\n return false;\n }\n\n return (monthInput.length === 1 || monthInput.length === 2) && yearInput.length === 4;\n}\n\nexport function validateThreeMatches(dayInput: string, monthInput: string, yearInput: string) {\n const dayNum = parseInt(dayInput, 10);\n if (dayNum < 1 || dayNum > 31) {\n return false;\n }\n\n const monthNum = parseInt(monthInput, 10);\n if (monthNum < 1 || monthNum > 12) {\n return false;\n }\n\n return (\n (dayInput.length === 1 || dayInput.length === 2) &&\n (monthInput.length === 1 || monthInput.length === 2) &&\n yearInput.length === 4\n );\n}\n\nexport function getNumOfSeparators(valueDate: string, seperator: string) {\n const regex = new RegExp(seperator, 'g');\n return [...valueDate.matchAll(regex)].length;\n}\n\n/**\n * Parse a FHIR date string to a date to be consumed and displayed by the DateItem component.\n *\n * @author Sean Fong\n */\nexport function parseFhirDateToDisplayDate(fhirDate: string): {\n displayDate: string;\n dateParseFail?: boolean;\n} {\n if (fhirDate.length === 0) {\n return { displayDate: '' };\n }\n\n const numOfSeparators = getNumOfSeparators(fhirDate, '-');\n\n if (numOfSeparators === 2) {\n const threeMatchesDate = dayjs(fhirDate, `YYYY-MM-DD`);\n if (threeMatchesDate.isValid()) {\n return { displayDate: threeMatchesDate.format('DD/MM/YYYY') };\n }\n }\n\n if (numOfSeparators === 1) {\n const twoMatchesDate = dayjs(fhirDate, `YYYY-MM`);\n if (twoMatchesDate.isValid()) {\n return { displayDate: twoMatchesDate.format('MM/YYYY') };\n }\n }\n\n const oneMatchDate = dayjs(fhirDate, `YYYY`);\n if (oneMatchDate.isValid()) {\n return { displayDate: oneMatchDate.format('YYYY') };\n }\n\n return { displayDate: fhirDate, dateParseFail: true };\n}\n\nexport function parseInputDateToFhirDate(displayDate: string) {\n const numOfSeparators = getNumOfSeparators(displayDate, '/');\n\n if (numOfSeparators === 2) {\n const threeMatchesDate = dayjs(displayDate, `DD/MM/YYYY`);\n if (threeMatchesDate.isValid()) {\n return threeMatchesDate.format('YYYY-MM-DD');\n }\n }\n\n if (numOfSeparators === 1) {\n const twoMatchesDate = dayjs(displayDate, `MM/YYYY`);\n if (twoMatchesDate.isValid()) {\n return twoMatchesDate.format('YYYY-MM');\n }\n }\n\n if (displayDate.length === 4) {\n const oneMatchDate = dayjs(displayDate, 'YYYY');\n if (oneMatchDate.isValid()) {\n return displayDate;\n }\n }\n\n // Default to YYYY-MM-DD format if all else fails\n return dayjs(displayDate).format('YYYY-MM-DD');\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n getNumOfSeparators,\n validateThreeMatches,\n validateTwoMatches\n} from '../components/FormComponents/DateTimeItems/utils/parseDate';\nimport dayjs from 'dayjs';\n\nfunction useDateValidation(input: string, parseFail: boolean = false): string | null {\n if (input === '') {\n return null;\n }\n\n if (input.includes('-')) {\n return 'Input does not match the required format with \"/\" as the separator.';\n }\n\n const numOfSeparators = getNumOfSeparators(input, '/');\n\n if (numOfSeparators === 2) {\n const threeMatchesDate = dayjs(input, `DD/MM/YYYY`);\n if (!threeMatchesDate.isValid()) {\n return 'Input does not match the format DD/MM/YYYY.';\n }\n\n const matches = input.split('/');\n if (!validateThreeMatches(matches[0], matches[1], matches[2])) {\n return 'Input is an invalid date.';\n }\n\n return null;\n }\n\n if (numOfSeparators === 1) {\n const twoMatchesDate = dayjs(input, `MM/YYYY`);\n if (!twoMatchesDate.isValid()) {\n return 'Input does not match the formats MM/YYYY or DD/MM/YYYY.';\n }\n\n const matches = input.split('/');\n\n if (!validateTwoMatches(matches[0], matches[1])) {\n return 'Input is an invalid date.';\n }\n\n return null;\n }\n\n if (input.length === 4) {\n const oneMatchDate = dayjs(input, 'YYYY');\n if (oneMatchDate.isValid()) {\n return null;\n }\n }\n\n if (parseFail) {\n return 'Input is an invalid date.';\n }\n\n return 'Input does not match any date format.';\n}\n\nexport default useDateValidation;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Dayjs } from 'dayjs';\nimport type { ChangeEvent, Dispatch, SetStateAction } from 'react';\nimport React, { useRef } from 'react';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../../interfaces/renderProps.interface';\nimport { StandardTextField } from '../../Textfield.styles';\nimport DatePicker from './DatePicker';\nimport Tooltip from '@mui/material/Tooltip';\nimport { useRendererStylingStore } from '../../../../stores';\n\ninterface CustomDateFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n valueDate: string;\n input: string;\n feedback: string;\n isFocused: boolean;\n displayPrompt: string;\n entryFormat: string;\n readOnly: boolean;\n isPartOfDateTime: boolean;\n setFocused: Dispatch<SetStateAction<boolean>>;\n onInputChange: (newInput: string) => void;\n onSelectDate: (newDateValue: string) => void;\n}\n\nfunction CustomDateField(props: CustomDateFieldProps) {\n const {\n linkId,\n itemType,\n valueDate,\n input,\n feedback,\n isFocused,\n displayPrompt,\n entryFormat,\n readOnly,\n isPartOfDateTime,\n isTabled,\n setFocused,\n onInputChange,\n onSelectDate\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const anchorRef = useRef<HTMLDivElement | null>(null);\n\n // If this reusable date field is part of a DateTime component, the id should be appended with '-date'\n const id = isPartOfDateTime ? itemType + '-' + linkId + '-date' : itemType + '-' + linkId;\n\n return (\n <Tooltip title={isTabled ? feedback : ''}>\n <StandardTextField\n id={id}\n ref={anchorRef}\n fullWidth\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n value={input}\n error={!!feedback}\n onChange={(e: ChangeEvent<HTMLInputElement>) => onInputChange(e.target.value)}\n label={displayPrompt}\n placeholder={entryFormat !== '' ? entryFormat : 'DD/MM/YYYY'}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n size=\"small\"\n focused={isFocused}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n slotProps={{\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <>\n <DatePicker\n valueString={valueDate}\n readOnly={readOnly}\n anchorEl={anchorRef.current}\n onSelectDate={(valueDayjs: Dayjs) => {\n onSelectDate(valueDayjs.format('DD/MM/YYYY'));\n }}\n onFocus={(focus) => setFocused(focus)}\n />\n </>\n )\n }\n }}\n helperText={isTabled ? '' : feedback}\n />\n </Tooltip>\n );\n}\n\nexport default CustomDateField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport type { Dayjs } from 'dayjs';\nimport dayjs from 'dayjs';\nimport { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';\nimport { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';\nimport MuiDatePicker from './MuiDatePicker';\nimport DatePickerButton from './DatePickerButton';\n\ninterface DatePickerProps {\n valueString: string;\n readOnly: boolean;\n anchorEl: HTMLElement | null;\n onSelectDate: (newValueDayjs: Dayjs) => void;\n onFocus: (focus: boolean) => void;\n}\n\nfunction DatePicker(props: DatePickerProps) {\n const { valueString, readOnly, anchorEl, onSelectDate, onFocus } = props;\n\n const [open, setOpen] = useState(false);\n\n const valueDayJs = valueString ? dayjs(valueString, 'DD/MM/YYYY') : null;\n\n return (\n <LocalizationProvider dateAdapter={AdapterDayjs}>\n <MuiDatePicker\n value={valueDayJs ?? null}\n slots={{ field: DatePickerButton }}\n slotProps={{\n field: {\n onOpen: () => {\n if (readOnly) {\n return;\n }\n\n setOpen(!open);\n onFocus(true);\n },\n readOnly: readOnly\n } as any,\n textField: {\n size: 'small'\n },\n popper: {\n anchorEl: () => anchorEl as HTMLElement\n }\n }}\n open={open}\n onClose={() => {\n setOpen(false);\n onFocus(false);\n }}\n onChange={(newValue) => {\n if (!newValue) {\n return;\n }\n\n onSelectDate(newValue);\n onFocus(false);\n }}\n />\n </LocalizationProvider>\n );\n}\n\nexport default DatePicker;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DatePicker } from '@mui/x-date-pickers/DatePicker';\n\nconst MuiDatePicker = DatePicker;\n\nexport default MuiDatePicker;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type {\n BaseSingleInputFieldProps,\n DateValidationError,\n FieldSection\n} from '@mui/x-date-pickers/models';\nimport type { Dayjs } from 'dayjs';\nimport IconButton from '@mui/material/IconButton';\nimport EventIcon from '@mui/icons-material/Event';\nimport { useRendererStylingStore } from '../../../../stores';\n\ninterface DatePickerButtonProps\n extends BaseSingleInputFieldProps<Dayjs | null, Dayjs, FieldSection, false, DateValidationError> {\n onOpen?: () => void;\n readOnly?: boolean;\n}\n\nfunction DatePickerButton(props: DatePickerButtonProps) {\n const { onOpen, readOnly } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n\n return (\n <IconButton\n sx={{ height: 30, width: 30, color: 'text.secondary' }}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n aria-readonly={readOnly && readOnlyVisualStyle === 'readonly'}\n tabIndex={readOnly ? -1 : 0}\n onClick={(e) => {\n e.stopPropagation();\n onOpen?.();\n }}>\n <EventIcon fontSize=\"small\" />\n </IconButton>\n );\n}\n\nexport default DatePickerButton;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Extension, QuestionnaireItem } from 'fhir/r4';\n\n/**\n * Get Questionnaire slider step value if its extension is present (http://hl7.org/fhir/StructureDefinition/questionnaire-sliderStepValue)\n *\n * @author Sean Fong\n */\nexport function getSliderStepValue(qItem: QuestionnaireItem): number | null {\n const itemControl = qItem.extension?.find(\n (extension: Extension) =>\n extension.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-sliderStepValue'\n );\n\n if (itemControl) {\n if (itemControl.valueInteger) {\n return itemControl.valueInteger;\n }\n }\n return null;\n}\n\n/**\n * Get minimum value if its extension is present (http://hl7.org/fhir/StructureDefinition/minValue)\n * Only supports valueInteger and valueDecimal for now\n *\n * @author Sean Fong\n */\nexport function getMinValue(qItem: QuestionnaireItem): number | null {\n const itemControl = qItem.extension?.find(\n (extension: Extension) => extension.url === 'http://hl7.org/fhir/StructureDefinition/minValue'\n );\n\n if (itemControl) {\n if (itemControl.valueInteger) {\n return itemControl.valueInteger;\n }\n\n if (itemControl.valueDecimal) {\n return itemControl.valueDecimal;\n }\n }\n return null;\n}\n\n/**\n * Get maximum value if its extension is present (http://hl7.org/fhir/StructureDefinition/maxValue)\n * Only supports valueInteger and valueDecimal for now\n *\n * @author Sean Fong\n */\nexport function getMaxValue(qItem: QuestionnaireItem): number | null {\n const itemControl = qItem.extension?.find(\n (extension: Extension) => extension.url === 'http://hl7.org/fhir/StructureDefinition/maxValue'\n );\n\n if (itemControl) {\n if (itemControl.valueInteger) {\n return itemControl.valueInteger;\n }\n\n if (itemControl.valueDecimal) {\n return itemControl.valueDecimal;\n }\n }\n return null;\n}\n\nexport function getSliderMarks(\n minValue: number,\n maxValue: number,\n minLabel: string,\n maxLabel: string,\n stepValue: number\n) {\n const numOfSteps = Math.ceil((maxValue - minValue) / stepValue);\n if (numOfSteps > 20) {\n return [\n {\n value: minValue,\n label: minLabel !== '' ? minLabel : minValue.toString()\n },\n {\n value: maxValue,\n label: maxLabel !== '' ? maxLabel : maxValue.toString()\n }\n ];\n }\n\n return Array.from({ length: numOfSteps + 1 }, (_, i) => minValue + i * stepValue).map(\n (value) => ({\n value: value,\n label: value\n })\n );\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport { getSliderMarks } from '../../../utils/slider';\nimport Stack from '@mui/material/Stack';\nimport SliderLabels from './SliderLabels';\nimport SliderDisplayValue from './SliderDisplayValue';\nimport { useRendererStylingStore } from '../../../stores';\nimport { StyledRequiredTypography } from '../Item.styles';\nimport { StandardSlider } from './Slider.styles';\n\ninterface SliderFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n value: number;\n minValue: number;\n minLabel: string;\n maxValue: number;\n maxLabel: string;\n stepValue: number;\n isInteracted: boolean;\n feedback: string;\n readOnly: boolean;\n onValueChange: (newValue: number) => void;\n}\n\nfunction SliderField(props: SliderFieldProps) {\n const {\n linkId,\n itemType,\n value,\n minValue,\n maxValue,\n stepValue,\n minLabel,\n maxLabel,\n isInteracted,\n feedback,\n readOnly,\n isTabled,\n onValueChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const sliderMarks = getSliderMarks(minValue, maxValue, minLabel, maxLabel, stepValue);\n\n const sliderSx = {\n maxWidth: !isTabled ? textFieldWidth : 3000,\n minWidth: 160\n };\n\n const hasLabels = !!(minLabel || maxLabel);\n\n return (\n <>\n <Stack sx={{ ...sliderSx }}>\n <SliderDisplayValue value={value} hasLabels={hasLabels} isInteracted={isInteracted} />\n {hasLabels ? <SliderLabels minLabel={minLabel} maxLabel={maxLabel} /> : null}\n <StandardSlider\n id={itemType + '-' + linkId}\n value={value}\n min={minValue}\n max={maxValue}\n step={stepValue}\n marks={sliderMarks}\n sx={{ ...sliderSx }}\n onChange={(_, newValue) => {\n // If item.readOnly=true, do not allow any changes\n if (readOnly) {\n return;\n }\n\n if (typeof newValue === 'number') {\n onValueChange(newValue);\n }\n }}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n aria-readonly={readOnly && readOnlyVisualStyle === 'readonly'}\n valueLabelDisplay=\"auto\"\n data-test=\"q-item-slider-field\"\n />\n </Stack>\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </>\n );\n}\n\nexport default SliderField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Typography from '@mui/material/Typography';\nimport Box from '@mui/material/Box';\n\ninterface SliderLabelsProps {\n minLabel: string;\n maxLabel: string;\n}\n\nfunction SliderLabels(props: SliderLabelsProps) {\n const { minLabel, maxLabel } = props;\n\n if (!minLabel && !maxLabel) {\n return null;\n }\n\n return (\n <Box display=\"flex\" justifyContent=\"space-between\" pb={0.5}>\n {[minLabel, maxLabel].map((label, index) => (\n <Typography\n key={index}\n fontWeight={600}\n fontSize=\"0.75rem\"\n color=\"text.secondary\"\n textAlign=\"center\"\n sx={{\n transform: `translateX(${index === 0 ? '-50%' : '50%'})`,\n wordWrap: 'break-word'\n }}>\n {label}\n </Typography>\n ))}\n </Box>\n );\n}\n\nexport default SliderLabels;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { alpha, styled } from '@mui/material/styles';\nimport { Box } from '@mui/material';\nimport Slider from '@mui/material/Slider';\n\nexport const SliderDisplayBox = styled(Box, {\n shouldForwardProp: (prop) => prop !== 'hasLabels'\n})<{ hasLabels: boolean }>(({ theme, hasLabels }) => ({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n margin: '0 auto',\n marginBottom: hasLabels ? -20 : 0,\n padding: theme.spacing(0.5),\n borderRadius: Number(theme.shape.borderRadius) * 0.5,\n border: `1px solid ${alpha(theme.palette.text.disabled, 0.5)}`,\n minWidth: 28,\n height: 20\n}));\n\nexport const StandardSlider = styled(Slider, {\n shouldForwardProp: (prop) => prop !== 'readOnly'\n})<{ readOnly: boolean }>(({ theme, readOnly }) => ({\n ...(readOnly && {\n '& .MuiSlider-thumb': {\n backgroundColor: theme.palette.text.disabled,\n '&:hover': {\n boxShadow: `0 0 0 8px ${alpha(theme.palette.text.secondary, 0.16)}` // Custom hover box-shadow with 0.16 opacity\n },\n '&.Mui-focusVisible': {\n boxShadow: `0 0 0 8px ${alpha(theme.palette.text.secondary, 0.16)}` // Focus box-shadow with 0.16 opacity\n }\n },\n '& .MuiSlider-track': {\n backgroundColor: theme.palette.text.disabled\n },\n '& .MuiSlider-rail': {\n backgroundColor: theme.palette.text.disabled\n },\n '& .MuiSlider-mark': {\n backgroundColor: theme.palette.text.disabled\n },\n '& .MuiSlider-markLabel': {\n color: theme.palette.text.disabled\n }\n })\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { SliderDisplayBox } from './Slider.styles';\nimport Typography from '@mui/material/Typography';\n\ninterface SliderDisplayValueProps {\n value: number;\n hasLabels: boolean;\n isInteracted: boolean;\n}\n\nfunction SliderDisplayValue(props: SliderDisplayValueProps) {\n const { value, hasLabels, isInteracted } = props;\n\n const valueToDisplay = isInteracted ? value : '-';\n\n return (\n <SliderDisplayBox hasLabels={hasLabels}>\n <Typography textAlign=\"center\" color=\"text.disabled\">\n {valueToDisplay}\n </Typography>\n </SliderDisplayBox>\n );\n}\n\nexport default SliderDisplayValue;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getTextDisplayLower, getTextDisplayUpper } from '../utils/itemControl';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport { getMaxValue, getMinValue, getSliderStepValue } from '../utils/slider';\n\nconst defaultMinValue = 0;\nconst defaultMinLabel = '0';\n\nconst defaultMaxValue = 100;\nconst defaultMaxLabel = '100';\n\nconst defaultStepValue = 1;\n\ninterface SliderExtensions {\n minValue: number;\n minLabel: string;\n maxValue: number;\n maxLabel: string;\n stepValue: number;\n}\n\nfunction useSliderExtensions(qItem: QuestionnaireItem): SliderExtensions {\n const minValue = getMinValue(qItem) ?? defaultMinValue;\n const maxValue = getMaxValue(qItem) ?? defaultMaxValue;\n return {\n minValue: minValue,\n minLabel: getTextDisplayLower(qItem) ?? minValue.toString() ?? defaultMinLabel,\n maxValue: maxValue,\n maxLabel: getTextDisplayUpper(qItem) ?? maxValue.toString() ?? defaultMaxLabel,\n stepValue: getSliderStepValue(qItem) ?? defaultStepValue\n };\n}\n\nexport default useSliderExtensions;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { BaseItemProps } from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport SliderField from './SliderField';\nimport useSliderExtensions from '../../../hooks/useSliderExtensions';\nimport Box from '@mui/material/Box';\nimport { useQuestionnaireStore } from '../../../stores';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface SliderItemProps extends BaseItemProps {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction SliderItem(props: SliderItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const { minValue, maxValue, stepValue, minLabel, maxLabel } = useSliderExtensions(qItem);\n\n const isInteracted = !!qrItem?.answer;\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n let valueInteger = 0;\n if (qrItem?.answer) {\n if (qrItem?.answer[0].valueInteger) {\n valueInteger = qrItem.answer[0].valueInteger;\n }\n if (qrItem?.answer[0].valueDecimal) {\n valueInteger = Math.round(qrItem.answer[0].valueDecimal);\n }\n }\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n // Event handlers\n function handleValueChange(newValue: number) {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueInteger: newValue }]\n });\n }\n\n if (isRepeated) {\n return (\n <Box px={4}>\n <SliderField\n linkId={qItem.linkId}\n itemType={qItem.type}\n value={valueInteger}\n minValue={minValue}\n maxValue={maxValue}\n stepValue={stepValue}\n minLabel={minLabel}\n maxLabel={maxLabel}\n isInteracted={isInteracted}\n feedback={feedback}\n readOnly={readOnly}\n isTabled={isTabled}\n onValueChange={handleValueChange}\n />\n </Box>\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-slider-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <Box px={4}>\n <SliderField\n linkId={qItem.linkId}\n itemType={qItem.type}\n value={valueInteger}\n minValue={minValue}\n maxValue={maxValue}\n stepValue={stepValue}\n minLabel={minLabel}\n maxLabel={maxLabel}\n isInteracted={isInteracted}\n feedback={feedback}\n readOnly={readOnly}\n isTabled={isTabled}\n onValueChange={handleValueChange}\n />\n </Box>\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default SliderItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback, useState } from 'react';\nimport type { BaseItemProps } from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport debounce from 'lodash.debounce';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { DEBOUNCE_DURATION } from '../../../utils/debounce';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport IntegerField from './IntegerField';\nimport useIntegerCalculatedExpression from '../../../hooks/useIntegerCalculatedExpression';\nimport { parseIntegerString } from '../../../utils/parseInputs';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface IntegerItemProps extends BaseItemProps {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction IntegerItem(props: IntegerItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const { displayUnit, displayPrompt, entryFormat } = renderingExtensions;\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n let valueInteger = 0;\n let initialInput = '';\n if (qrItem?.answer) {\n if (qrItem?.answer[0].valueInteger) {\n valueInteger = qrItem.answer[0].valueInteger;\n }\n\n if (qrItem?.answer[0].valueDecimal) {\n valueInteger = Math.round(qrItem.answer[0].valueDecimal);\n }\n\n initialInput = valueInteger.toString();\n }\n\n const [input, setInput] = useState(initialInput);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, input);\n\n // Process calculated expressions\n const { calcExpUpdated } = useIntegerCalculatedExpression({\n qItem: qItem,\n inputValue: input,\n onChangeByCalcExpressionInteger: (newValueInteger: number) => {\n setInput(newValueInteger.toString());\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueInteger: newValueInteger }]\n });\n },\n onChangeByCalcExpressionNull: () => {\n setInput('');\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n });\n\n // Event handlers\n function handleInputChange(newInput: string) {\n const parsedNewInput = parseIntegerString(newInput);\n\n setInput(parsedNewInput);\n updateQrItemWithDebounce(parsedNewInput);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const updateQrItemWithDebounce = useCallback(\n debounce((parsedNewInput: string) => {\n if (parsedNewInput === '') {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n } else {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueInteger: parseInt(parsedNewInput) }]\n });\n }\n }, DEBOUNCE_DURATION),\n [onQrItemChange, qItem, displayUnit]\n ); // Dependencies are tested, debounce is causing eslint to not recognise dependencies\n\n if (isRepeated) {\n return (\n <IntegerField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={input}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n isTabled={isTabled}\n onInputChange={handleInputChange}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-integer-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <IntegerField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={input}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n isTabled={isTabled}\n onInputChange={handleInputChange}\n />\n }\n feedback={feedback}\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default IntegerItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport { StandardTextField } from '../Textfield.styles';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport FadingCheckIcon from '../ItemParts/FadingCheckIcon';\nimport { useRendererStylingStore } from '../../../stores';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\n\ninterface IntegerFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n input: string;\n feedback: string;\n displayPrompt: string;\n displayUnit: string;\n entryFormat: string;\n readOnly: boolean;\n calcExpUpdated: boolean;\n onInputChange: (value: string) => void;\n}\n\nfunction IntegerField(props: IntegerFieldProps) {\n const {\n linkId,\n itemType,\n input,\n feedback,\n displayPrompt,\n displayUnit,\n entryFormat,\n readOnly,\n calcExpUpdated,\n isTabled,\n onInputChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n return (\n <StandardTextField\n id={itemType + '-' + linkId}\n value={input}\n error={!!feedback}\n helperText={feedback}\n onChange={(event) => onInputChange(event.target.value)}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n label={displayPrompt}\n placeholder={entryFormat === '' ? '0' : entryFormat}\n fullWidth\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n size=\"small\"\n slotProps={{\n htmlInput: { inputMode: 'numeric', pattern: '[0-9]*' },\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <InputAdornment position={'end'}>\n <FadingCheckIcon fadeIn={calcExpUpdated} disabled={readOnly} />\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </InputAdornment>\n )\n }\n }}\n data-test=\"q-item-integer-field\"\n />\n );\n}\n\nexport default IntegerField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from 'react';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport { useQuestionnaireStore } from '../stores';\n\ninterface UseIntegerCalculatedExpression {\n calcExpUpdated: boolean;\n}\n\ninterface useIntegerCalculatedExpressionProps {\n qItem: QuestionnaireItem;\n inputValue: string;\n onChangeByCalcExpressionInteger: (calcExpressionValue: number) => void;\n onChangeByCalcExpressionNull: () => void;\n}\n\nfunction useIntegerCalculatedExpression(\n props: useIntegerCalculatedExpressionProps\n): UseIntegerCalculatedExpression {\n const { qItem, inputValue, onChangeByCalcExpressionInteger, onChangeByCalcExpressionNull } =\n props;\n\n const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();\n\n const [calcExpUpdated, setCalcExpUpdated] = useState(false);\n\n useEffect(\n () => {\n const calcExpression = calculatedExpressions[qItem.linkId]?.find(\n (exp) => exp.from === 'item'\n );\n\n if (!calcExpression) {\n return;\n }\n\n // only update if calculated value is different from current value\n if (\n calcExpression.value !== inputValue &&\n (typeof calcExpression.value === 'number' || calcExpression.value === null)\n ) {\n const calcExpressionValue = calcExpression.value;\n\n if (calcExpressionValue !== parseInt(inputValue)) {\n // update ui to show calculated value changes\n setCalcExpUpdated(true);\n const timeoutId = setTimeout(() => {\n setCalcExpUpdated(false);\n }, 500);\n\n // calculatedExpression value is null\n if (calcExpressionValue === null) {\n onChangeByCalcExpressionNull();\n return () => clearTimeout(timeoutId);\n }\n\n // calculatedExpression value is a number\n onChangeByCalcExpressionInteger(calcExpressionValue);\n return () => clearTimeout(timeoutId);\n }\n }\n },\n // Only trigger this effect if calculatedExpression of item changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [calculatedExpressions]\n );\n\n return { calcExpUpdated: calcExpUpdated };\n}\n\nexport default useIntegerCalculatedExpression;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback, useState } from 'react';\nimport type { BaseItemProps } from '../../../interfaces/renderProps.interface';\nimport debounce from 'lodash.debounce';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { DEBOUNCE_DURATION } from '../../../utils/debounce';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport AttachmentFieldWrapper from './AttachmentFieldWrapper';\nimport { HTML5Backend } from 'react-dnd-html5-backend';\nimport { DndProvider } from 'react-dnd';\nimport { createAttachmentAnswer } from '../../../utils/fileUtils';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\n\nexport interface AttachmentValues {\n uploadedFile: File | null;\n url: string;\n fileName: string;\n}\n\ninterface AttachmentItemProps extends BaseItemProps {}\n\nfunction AttachmentItem(props: AttachmentItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n let valueString = '';\n if (qrItem?.answer && qrItem?.answer[0].valueString) {\n valueString = qrItem.answer[0].valueString;\n }\n\n const [uploadedFile, setUploadedFile] = useState<File | null>(null);\n const [url, setUrl] = useState(valueString);\n const [fileName, setFileName] = useState(valueString);\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, '');\n\n // Event handlers\n async function handleUploadFile(newUploadedFile: File | null) {\n setUploadedFile(newUploadedFile);\n\n const attachment = await createAttachmentAnswer(newUploadedFile, url, fileName);\n if (attachment) {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueAttachment: attachment }]\n });\n } else {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n }\n\n async function handleUrlChange(newUrl: string) {\n setUrl(newUrl);\n await updateQrItemWithDebounce(uploadedFile, newUrl, fileName);\n }\n\n async function handleFileNameChange(newFileName: string) {\n setFileName(newFileName);\n await updateQrItemWithDebounce(uploadedFile, url, newFileName);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const updateQrItemWithDebounce = useCallback(\n debounce(async (file: File | null, url: string, fileName: string) => {\n const attachment = await createAttachmentAnswer(file, url, fileName);\n\n if (attachment) {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueAttachment: attachment }]\n });\n } else {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n }, DEBOUNCE_DURATION),\n [onQrItemChange, qItem]\n ); // Dependencies are tested, debounce is causing eslint to not recognise dependencies\n\n return (\n <DndProvider backend={HTML5Backend} context={window}>\n <AttachmentFieldWrapper\n qItem={qItem}\n attachmentValues={{ uploadedFile: uploadedFile, url: url, fileName: fileName }}\n feedback={feedback}\n readOnly={readOnly}\n isRepeated={isRepeated}\n isTabled={isTabled}\n onUploadFile={handleUploadFile}\n onUrlChange={handleUrlChange}\n onFileNameChange={handleFileNameChange}\n />\n </DndProvider>\n );\n}\n\nexport default AttachmentItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ChangeEvent } from 'react';\nimport React, { memo, useCallback } from 'react';\nimport { Box, IconButton, Stack, Tooltip } from '@mui/material';\nimport AttachmentFileDropBox from './AttachmentFileDropBox';\nimport Iconify from '../../Iconify/Iconify';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\n\ninterface AttachmentFileCollectorProps extends PropsWithIsTabledRequiredAttribute {\n uploadedFile: File | null;\n readOnly: boolean;\n onUploadFile: (file: File | null) => void;\n}\n\nconst AttachmentFileCollector = memo(function AttachmentFileCollector(\n props: AttachmentFileCollectorProps\n) {\n const { uploadedFile, readOnly, isTabled, onUploadFile } = props;\n\n const handleFileDrop = useCallback(\n (item: { files: any[] }) => {\n if (readOnly) {\n return;\n }\n\n if (item) {\n const files = item.files;\n\n if (files[0] instanceof File) {\n const file = files[0];\n\n onUploadFile(file);\n }\n }\n },\n [onUploadFile]\n );\n\n function handleAttachFile(event: ChangeEvent<HTMLInputElement>) {\n const file = event.target.files?.[0];\n\n if (file instanceof File) {\n onUploadFile(file);\n }\n }\n\n return (\n <>\n <AttachmentFileDropBox\n onDrop={handleFileDrop}\n file={uploadedFile}\n errorMessage={''}\n readOnly={readOnly}\n isTabled={isTabled}\n />\n <Stack direction=\"row\" justifyContent=\"space-between\" pt={0.5}>\n <Box>\n <Tooltip title=\"Attach file\">\n <IconButton component=\"label\" size=\"small\" disabled={readOnly}>\n <Iconify icon=\"fluent:attach-24-regular\" />\n <input type=\"file\" hidden onChange={handleAttachFile} />\n </IconButton>\n </Tooltip>\n <Tooltip title=\"Remove file\">\n <span>\n <IconButton\n disabled={!uploadedFile || readOnly}\n color=\"error\"\n size=\"small\"\n onClick={() => onUploadFile(null)}>\n <Iconify icon=\"ant-design:delete\" />\n </IconButton>\n </span>\n </Tooltip>\n </Box>\n </Stack>\n </>\n );\n});\n\nexport default AttachmentFileCollector;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Box, Typography } from '@mui/material';\nimport useFileDrop from '../../../hooks/UseFileDrop';\nimport { AttachmentFileDropBoxWrapper } from './AttachmentFileDropBox.styles';\nimport React from 'react';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport { getFileSize } from '../../../utils/fileUtils';\nimport { useRendererStylingStore } from '../../../stores';\n\nexport interface AttachmentFileDropBoxProps extends PropsWithIsTabledRequiredAttribute {\n file: File | null;\n onDrop: (item: { files: any[] }) => void;\n errorMessage: string;\n readOnly: boolean;\n}\n\nfunction AttachmentFileDropBox(props: AttachmentFileDropBoxProps) {\n const { file, onDrop, errorMessage, readOnly, isTabled } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const readOnlyTextColor = readOnlyVisualStyle === 'disabled' ? 'text.disabled' : 'text.secondary';\n\n const { canDrop, isOver, dropTarget } = useFileDrop(onDrop);\n\n const isActive = canDrop && isOver;\n\n let boxMessage = 'No file selected';\n if (readOnly) {\n boxMessage = 'Attachment item is read only';\n } else if (isActive) {\n boxMessage = 'Release to drop file';\n } else if (errorMessage) {\n boxMessage = errorMessage;\n } else if (file) {\n boxMessage = file.name;\n }\n\n return (\n <AttachmentFileDropBoxWrapper\n ref={dropTarget as unknown as React.Ref<any>} // works in runtime, but produces error TS2322: Type 'ConnectDropTarget' is not assignable to type 'Ref<unknown> | undefined' at compile time\n display=\"flex\"\n isActive={isActive}\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}>\n <Box p={1.5}>\n <Typography color={readOnly ? readOnlyTextColor : 'text.primary'}>{boxMessage}</Typography>\n\n {file ? (\n <Box pt={1}>\n <Typography fontSize={10}>Size: {getFileSize(file.size.toString() ?? '0')}</Typography>\n <Typography fontSize={10}>Type: {file.type}</Typography>\n </Box>\n ) : null}\n </Box>\n </AttachmentFileDropBoxWrapper>\n );\n}\n\nexport default AttachmentFileDropBox;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ConnectDropTarget, DropTargetMonitor } from 'react-dnd';\nimport { useDrop } from 'react-dnd';\nimport { NativeTypes } from 'react-dnd-html5-backend';\n\ninterface UseFileDrop {\n canDrop: boolean;\n isOver: boolean;\n dropTarget: ConnectDropTarget;\n}\n\nfunction UseFileDrop(onDrop: (item: { files: any[] }) => void): UseFileDrop {\n const [{ canDrop, isOver }, drop] = useDrop(\n () => ({\n accept: [NativeTypes.FILE],\n drop(item: { files: any[] }) {\n if (onDrop) {\n onDrop(item);\n }\n },\n canDrop() {\n return true;\n },\n collect: (monitor: DropTargetMonitor) => {\n return {\n isOver: monitor.isOver(),\n canDrop: monitor.canDrop()\n };\n }\n }),\n [onDrop]\n );\n\n return { canDrop, isOver, dropTarget: drop };\n}\n\nexport default UseFileDrop;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { styled } from '@mui/material/styles';\nimport { Box } from '@mui/material';\n\nexport const AttachmentFileDropBoxWrapper = styled(Box, {\n shouldForwardProp: (prop) =>\n prop !== 'isActive' && prop !== 'isTabled' && prop !== 'textFieldWidth'\n})<{ isActive: boolean; isTabled: boolean; textFieldWidth: number }>(\n ({ theme, isActive, isTabled, textFieldWidth }) => ({\n backgroundColor: theme.palette.background.paper,\n border: '2px dashed',\n borderColor: isActive ? theme.palette.secondary.main : theme.palette.primary.main,\n borderRadius: '4px',\n maxWidth: !isTabled ? textFieldWidth : 3000,\n minWidth: 160,\n ref: HTMLElement\n })\n);\nAttachmentFileDropBoxWrapper.displayName = 'AttachmentFileDropBoxWrapper';\n\n// Forwarding ref to Box\n// export const AttachmentFileDropBoxWrapper = React.forwardRef<\n// HTMLDivElement,\n// { isActive: boolean; isTabled: boolean; textFieldWidth: number }\n// >(({ isActive, isTabled, textFieldWidth, ...props }, ref) => {\n// const StyledBox = styled(Box, {\n// shouldForwardProp: (prop) =>\n// prop !== 'isActive' && prop !== 'isTabled' && prop !== 'textFieldWidth'\n// })(({ theme }) => ({\n// backgroundColor: theme.palette.background.paper,\n// border: '2px dashed',\n// borderColor: isActive ? theme.palette.secondary.main : theme.palette.primary.main,\n// borderRadius: '4px',\n// maxWidth: !isTabled ? textFieldWidth : 3000,\n// minWidth: 160\n// }));\n\n// return <StyledBox ref={ref} {...props} />;\n// });\n\n// AttachmentFileDropBoxWrapper.displayName = 'AttachmentFileDropBoxWrapper';\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Attachment } from 'fhir/r4';\n\nexport function getFileSize(fileSizeString: string) {\n if (fileSizeString.length < 7) {\n return `${Math.round(+fileSizeString / 1024)}kb`;\n }\n\n return `${Math.round(+fileSizeString / 1024) / 1000}MB`;\n}\n\nconst fileToBase64 = (file: File) =>\n new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => resolve(reader.result);\n reader.onerror = reject;\n });\n\nexport async function createAttachmentAnswer(\n file: File | null,\n url: string,\n fileName: string\n): Promise<Attachment | null> {\n if (!file || url === '') {\n return null;\n }\n\n try {\n const base64Data = (await fileToBase64(file)) as string;\n const attachment: Attachment = {\n contentType: file.type,\n data: base64Data,\n size: file.size\n };\n\n if (url) {\n attachment.url = url;\n }\n\n if (fileName) {\n attachment.title = fileName;\n }\n\n return attachment;\n } catch (error) {\n console.error(error);\n return null;\n }\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport { StandardTextField } from '../Textfield.styles';\nimport AttachmentFileCollector from './AttachmentFileCollector';\nimport Typography from '@mui/material/Typography';\nimport Box from '@mui/material/Box';\nimport Stack from '@mui/material/Stack';\nimport type { AttachmentValues } from './AttachmentItem';\nimport AttachmentUrlField from './AttachmentUrlField';\nimport { useRendererStylingStore } from '../../../stores';\nimport { StyledRequiredTypography } from '../Item.styles';\n\ninterface AttachmentFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n attachmentValues: AttachmentValues;\n feedback: string;\n readOnly: boolean;\n onUploadFile: (file: File | null) => void;\n onUrlChange: (url: string) => void;\n onFileNameChange: (fileName: string) => void;\n}\n\nfunction AttachmentField(props: AttachmentFieldProps) {\n const {\n linkId,\n itemType,\n attachmentValues,\n feedback,\n readOnly,\n isTabled,\n onUploadFile,\n onUrlChange,\n onFileNameChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const readOnlyTextColor = readOnlyVisualStyle === 'disabled' ? 'text.disabled' : 'text.secondary';\n\n const { uploadedFile, url, fileName } = attachmentValues;\n\n return (\n <>\n <Stack rowGap={1} id={itemType + '-' + linkId}>\n <Typography color={readOnly ? readOnlyTextColor : 'text.primary'}>\n An attachment must either have a file or a URL, or both.\n </Typography>\n <Box>\n <AttachmentFileCollector\n uploadedFile={uploadedFile}\n readOnly={readOnly}\n isTabled={isTabled}\n onUploadFile={onUploadFile}\n />\n </Box>\n\n <AttachmentUrlField\n linkId={linkId}\n url={url}\n readOnly={readOnly}\n isTabled={isTabled}\n onUrlChange={onUrlChange}\n />\n\n <Box>\n <Typography variant=\"body2\" color={readOnly ? readOnlyTextColor : 'text.primary'}>\n File name (optional)\n </Typography>\n <StandardTextField\n fullWidth\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n id={linkId}\n value={fileName}\n onChange={(event) => onFileNameChange(event.target.value)}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n size=\"small\"\n data-test=\"q-item-attachment-field\"\n slotProps={{\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly'\n }\n }}\n />\n </Box>\n\n {uploadedFile && url ? (\n <Typography color={readOnly ? readOnlyTextColor : 'text.primary'}>\n Ensure that the attached file and URL has the same content.\n </Typography>\n ) : null}\n </Stack>\n\n {feedback ? <StyledRequiredTypography>{feedback}</StyledRequiredTypography> : null}\n </>\n );\n}\n\nexport default AttachmentField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport { StandardTextField } from '../Textfield.styles';\nimport Typography from '@mui/material/Typography';\nimport Box from '@mui/material/Box';\nimport Stack from '@mui/material/Stack';\nimport useAttachmentUrlValidation from '../../../hooks/useAttachmentUrlValidation';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport Tooltip from '@mui/material/Tooltip';\nimport CheckIcon from '@mui/icons-material/Check';\nimport DangerousIcon from '@mui/icons-material/Dangerous';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface AttachmentUrlFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n url: string;\n readOnly: boolean;\n onUrlChange: (url: string) => void;\n}\n\nfunction AttachmentUrlField(props: AttachmentUrlFieldProps) {\n const { linkId, url, readOnly, isTabled, onUrlChange } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n const urlIsValid = useAttachmentUrlValidation(url);\n\n return (\n <Box>\n <Typography variant=\"body2\" color={readOnly ? 'text.secondary' : 'text.primary'}>\n URL\n </Typography>\n <Stack direction=\"row\" alignItems=\"center\">\n <StandardTextField\n fullWidth\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n id={linkId}\n value={url}\n onChange={(event) => onUrlChange(event.target.value)}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n size=\"small\"\n data-test=\"q-item-attachment-field\"\n slotProps={{\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <InputAdornment position=\"end\">\n {url != '' ? (\n <Tooltip title={urlIsValid ? 'URL is valid!' : 'Invalid URL'} placement=\"right\">\n <Box mt={0.5}>\n {urlIsValid ? (\n <CheckIcon color=\"success\" fontSize=\"small\" />\n ) : (\n <DangerousIcon color=\"error\" fontSize=\"small\" />\n )}\n </Box>\n </Tooltip>\n ) : null}\n </InputAdornment>\n )\n }\n }}\n />\n </Stack>\n </Box>\n );\n}\n\nexport default AttachmentUrlField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nfunction useAttachmentUrlValidation(url: string): boolean {\n try {\n new URL(url);\n return true;\n } catch (error) {\n return false;\n }\n}\n\nexport default useAttachmentUrlValidation;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport AttachmentField from './AttachmentField';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport type {\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport type { AttachmentValues } from './AttachmentItem';\nimport { useQuestionnaireStore } from '../../../stores';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface AttachmentFieldWrapperProps\n extends PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute {\n qItem: QuestionnaireItem;\n attachmentValues: AttachmentValues;\n feedback: string;\n readOnly: boolean;\n onUploadFile: (file: File | null) => void;\n onUrlChange: (url: string) => void;\n onFileNameChange: (fileName: string) => void;\n}\n\nfunction AttachmentFieldWrapper(props: AttachmentFieldWrapperProps) {\n const {\n qItem,\n attachmentValues,\n feedback,\n readOnly,\n isRepeated,\n isTabled,\n onUploadFile,\n onUrlChange,\n onFileNameChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n if (isRepeated) {\n return (\n <AttachmentField\n linkId={qItem.linkId}\n itemType={qItem.type}\n attachmentValues={attachmentValues}\n feedback={feedback}\n readOnly={readOnly}\n isTabled={isTabled}\n onUploadFile={onUploadFile}\n onUrlChange={onUrlChange}\n onFileNameChange={onFileNameChange}\n />\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-attachment-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <AttachmentField\n linkId={qItem.linkId}\n itemType={qItem.type}\n attachmentValues={attachmentValues}\n feedback={feedback}\n readOnly={readOnly}\n isTabled={isTabled}\n onUploadFile={onUploadFile}\n onUrlChange={onUrlChange}\n onFileNameChange={onFileNameChange}\n />\n }\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default AttachmentFieldWrapper;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport type { BaseItemProps } from '../../../../interfaces/renderProps.interface';\nimport useReadOnly from '../../../../hooks/useReadOnly';\nimport { FullWidthFormComponentBox } from '../../../Box.styles';\nimport ItemFieldGrid from '../../ItemParts/ItemFieldGrid';\nimport { createEmptyQrItem } from '../../../../utils/qrItem';\nimport useDateValidation from '../../../../hooks/useDateValidation';\nimport { useQuestionnaireStore } from '../../../../stores';\nimport { parseFhirDateToDisplayDate } from '../utils';\nimport { parseInputDateToFhirDate, validateDateInput } from '../utils/parseDate';\nimport Stack from '@mui/material/Stack';\nimport type { Dayjs } from 'dayjs';\nimport dayjs from 'dayjs';\nimport {\n parseDateTimeToDisplayTime,\n parseInputDateTimeToFhirDateTime,\n validateTimeInput\n} from '../utils/parseTime';\nimport useTimeValidation from '../../../../hooks/useTimeValidation';\nimport useDateNonEmptyValidation from '../../../../hooks/useDateTimeNonEmpty';\nimport DateTimeField from './DateTimeField';\nimport ItemLabel from '../../ItemParts/ItemLabel';\n\ninterface CustomDateTimeItemProps extends BaseItemProps {}\n\nfunction CustomDateTimeItem(props: CustomDateTimeItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n const { displayPrompt, entryFormat } = renderingExtensions;\n\n // Init input value\n const answerKey = qrItem?.answer?.[0].id;\n const qrDateTime = qrItem ?? createEmptyQrItem(qItem, answerKey);\n\n let valueDate: string = '';\n let dateTimeDayJs: Dayjs | null = null;\n if (qrDateTime.answer) {\n let tempDateTime = '';\n if (qrDateTime.answer[0].valueDate) {\n tempDateTime = qrDateTime.answer[0].valueDate;\n } else if (qrDateTime.answer[0].valueDateTime) {\n tempDateTime = qrDateTime.answer[0].valueDateTime;\n }\n\n // split date and time at \"T\", 2015-02-07T13:28:17-05:00\n if (tempDateTime.includes('T')) {\n valueDate = tempDateTime.split('T')[0];\n dateTimeDayJs = dayjs(tempDateTime);\n } else {\n valueDate = tempDateTime;\n }\n }\n\n const { displayDate, dateParseFail } = parseFhirDateToDisplayDate(valueDate);\n const { displayTime, displayPeriod, timeParseFail } = parseDateTimeToDisplayTime(dateTimeDayJs);\n\n const [dateInput, setDateInput] = useState(displayDate);\n const [timeInput, setTimeInput] = useState(displayTime);\n const [periodInput, setPeriodInput] = useState(displayPeriod);\n const [dateFocused, setDateFocused] = useState(false);\n\n // Perform validation checks\n let dateFeedback = useDateValidation(dateInput, dateParseFail);\n const { timeFeedback, is24HourNotation } = useTimeValidation(\n timeInput,\n periodInput,\n timeParseFail\n );\n\n dateFeedback = useDateNonEmptyValidation(dateInput, timeInput, dateFeedback, timeFeedback);\n\n function handleSelectDate(selectedDate: string) {\n setDateInput(selectedDate);\n updateQRDateTime(selectedDate, timeInput, periodInput, is24HourNotation);\n }\n\n function handleDateInputChange(newDateInput: string) {\n setDateInput(newDateInput);\n\n if (newDateInput === '') {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n return;\n }\n\n if (!validateDateInput(newDateInput)) {\n return;\n }\n\n updateQRDateTime(newDateInput, timeInput, periodInput, is24HourNotation);\n }\n\n function handleTimeInputChange(newTimeInput: string, newPeriodInput: string) {\n setTimeInput(newTimeInput);\n setPeriodInput(newPeriodInput);\n\n if (newTimeInput === '') {\n updateQRDateTime(dateInput, '', '', false);\n return;\n }\n\n const { timeIsValid, is24HourNotation } = validateTimeInput(newTimeInput, newPeriodInput);\n if (!validateDateInput(dateInput) || !timeIsValid) {\n return;\n }\n\n updateQRDateTime(dateInput, newTimeInput, newPeriodInput, is24HourNotation);\n }\n\n function updateQRDateTime(\n dateInput: string,\n timeInput: string,\n periodInput: string,\n is24HourNotation: boolean\n ) {\n let fhirDateTime = '';\n if (timeInput) {\n fhirDateTime = parseInputDateTimeToFhirDateTime(\n parseInputDateToFhirDate(dateInput),\n timeInput,\n periodInput,\n is24HourNotation\n );\n } else {\n fhirDateTime = parseInputDateToFhirDate(dateInput);\n }\n\n if (fhirDateTime === 'Invalid Date') {\n return;\n }\n\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [{ id: answerKey, valueDateTime: fhirDateTime }]\n });\n }\n\n // FIXME entryFormat and displayPrompt, put them beneath the entire component instead of at the date field\n\n if (isRepeated) {\n return (\n <Stack>\n <DateTimeField\n linkId={qItem.linkId}\n itemType={qItem.type}\n displayDate={displayDate}\n dateInput={dateInput}\n timeInput={timeInput}\n periodInput={periodInput}\n is24HourNotation={is24HourNotation}\n dateFeedback={dateFeedback ?? ''}\n timeFeedback={timeFeedback ?? ''}\n dateFocused={dateFocused}\n displayPrompt={displayPrompt}\n entryFormat={entryFormat}\n readOnly={readOnly}\n isTabled={isTabled}\n onDateInputChange={handleDateInputChange}\n onSelectDate={handleSelectDate}\n setDateFocused={setDateFocused}\n onTimeInputChange={handleTimeInputChange}\n />\n </Stack>\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-datetime-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <DateTimeField\n linkId={qItem.linkId}\n itemType={qItem.type}\n displayDate={displayDate}\n dateInput={dateInput}\n timeInput={timeInput}\n periodInput={periodInput}\n is24HourNotation={is24HourNotation}\n dateFeedback={dateFeedback ?? ''}\n timeFeedback={timeFeedback ?? ''}\n dateFocused={dateFocused}\n displayPrompt={displayPrompt}\n entryFormat={entryFormat}\n readOnly={readOnly}\n isTabled={isTabled}\n onDateInputChange={handleDateInputChange}\n onSelectDate={handleSelectDate}\n setDateFocused={setDateFocused}\n onTimeInputChange={handleTimeInputChange}\n />\n }\n dateFeedback={dateFeedback ?? undefined}\n timeFeedback={timeFeedback ?? undefined}\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default CustomDateTimeItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Dayjs } from 'dayjs';\nimport dayjs from 'dayjs';\n\nconst inputMatchRegex = /^\\d{2}:\\d{2}$/;\n\nexport function getTimeSegments(timeInput: string): {\n hourSegment: string | null;\n minuteSegment: string | null;\n} {\n if (!inputMatchRegex.test(timeInput)) {\n return { hourSegment: null, minuteSegment: null };\n }\n\n const timeInputSegments = timeInput.split(':');\n if (timeInputSegments.length !== 2) {\n return { hourSegment: null, minuteSegment: null };\n }\n\n return { hourSegment: timeInputSegments[0], minuteSegment: timeInputSegments[1] };\n}\n\nexport function validateTimeInput(\n timeInput: string,\n periodInput: string\n): {\n timeIsValid: boolean;\n is24HourNotation: boolean;\n} {\n // Test time input is valid\n const { hourSegment, minuteSegment } = getTimeSegments(timeInput);\n\n if (!hourSegment || !minuteSegment) {\n return { timeIsValid: false, is24HourNotation: false };\n }\n\n const { hourSegmentValid, is24HourNotation } = validateHourSegment(hourSegment);\n const minuteSegmentValid = validateMinuteSegment(minuteSegment);\n\n if (!hourSegmentValid || !minuteSegmentValid) {\n return { timeIsValid: false, is24HourNotation: false };\n }\n\n // Test period input is valid\n if (!(periodInput === 'AM' || periodInput === 'PM' || is24HourNotation)) {\n return { timeIsValid: false, is24HourNotation: false };\n }\n\n return { timeIsValid: true, is24HourNotation: !!is24HourNotation };\n}\n\nexport function validateHourSegment(hourSegment: string): {\n hourSegmentValid: boolean;\n is24HourNotation: boolean | null;\n} {\n const hour = parseInt(hourSegment, 10);\n const hourSegmentValid = hour >= 0 && hour <= 23;\n const is24HourNotation = hourSegmentValid ? hour >= 13 && hour <= 23 : null;\n\n return { hourSegmentValid, is24HourNotation };\n}\n\nfunction validateMinuteSegment(minuteSegment: string) {\n const minutes = parseInt(minuteSegment, 10);\n return minutes >= 0 && minutes <= 59;\n}\n\nexport function parseDateTimeToDisplayTime(dateTime: Dayjs | null): {\n displayTime: string;\n displayPeriod: string;\n timeParseFail?: boolean;\n} {\n if (!dateTime) {\n return { displayTime: '', displayPeriod: '' };\n }\n\n if (!dateTime.isValid()) {\n return { displayTime: '', displayPeriod: '', timeParseFail: true };\n }\n\n const displayTime = dateTime.format('HH:mm');\n const displayPeriod = dateTime.format('A');\n\n return { displayTime, displayPeriod };\n}\n\nfunction convertTo12HourFormat(timeInput: string) {\n const timeSegments = timeInput.split(':');\n const hour = parseInt(timeSegments[0], 10);\n if (hour >= 12) {\n timeSegments[0] = `${hour - 12}`;\n }\n return `${timeSegments[0]}:${timeSegments[1]}`;\n}\n\nexport function parseInputDateTimeToFhirDateTime(\n dateInput: string,\n newTimeInput: string,\n periodInput: string,\n is24HourNotation: boolean\n) {\n periodInput = is24HourNotation ? 'PM' : periodInput;\n const new12HourTimeInput = convertTo12HourFormat(newTimeInput);\n\n const dateTimeDayJs = dayjs(\n `${dateInput} ${new12HourTimeInput} ${periodInput}`,\n `YYYY-MM-DD hh:mm A`\n );\n\n return dayjs(dateTimeDayJs).format('YYYY-MM-DDTHH:mm:ssZ');\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getNumOfSeparators } from '../components/FormComponents/DateTimeItems/utils/parseDate';\nimport dayjs from 'dayjs';\nimport { validateTimeInput } from '../components/FormComponents/DateTimeItems/utils/parseTime';\n\nfunction useTimeValidation(\n timeInput: string,\n periodInput: string,\n parseFail: boolean = false\n): { timeFeedback: string | null; is24HourNotation: boolean } {\n if (timeInput === '') {\n return { timeFeedback: null, is24HourNotation: false };\n }\n\n if (timeInput.includes('.')) {\n return {\n timeFeedback: 'Input does not match the required format with \":\" as the separator.',\n is24HourNotation: false\n };\n }\n\n if (timeInput.length !== 5 || !timeInput.includes(':')) {\n return { timeFeedback: 'Input does not match the format HH:MM.', is24HourNotation: false };\n }\n\n const numOfSeparators = getNumOfSeparators(timeInput, ':');\n\n if (numOfSeparators === 1) {\n const timeDayJs = dayjs(timeInput, `hh:mm`);\n if (!timeDayJs.isValid()) {\n return { timeFeedback: 'Input does not match the format hh:mm.', is24HourNotation: false };\n }\n\n const { timeIsValid, is24HourNotation } = validateTimeInput(timeInput, periodInput);\n\n if (periodInput === '' && !is24HourNotation) {\n return { timeFeedback: 'Specify the period as AM or PM.', is24HourNotation: false };\n }\n\n if (!timeIsValid) {\n return { timeFeedback: 'Input is an invalid time.', is24HourNotation: false };\n }\n\n return { timeFeedback: null, is24HourNotation };\n }\n\n if (parseFail) {\n return { timeFeedback: 'Input is an invalid time.', is24HourNotation: false };\n }\n\n return { timeFeedback: 'Input is an invalid time.', is24HourNotation: false };\n}\n\nexport default useTimeValidation;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nfunction useDateNonEmptyValidation(\n dateInput: string,\n timeInput: string,\n dateFeedback: string | null,\n timeFeedback: string | null\n): string | null {\n if (!dateFeedback && !timeFeedback && timeInput && dateInput === '') {\n return 'Date is required';\n }\n\n return dateFeedback;\n}\n\nexport default useDateNonEmptyValidation;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ChangeEvent } from 'react';\nimport React from 'react';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../../interfaces/renderProps.interface';\nimport Tooltip from '@mui/material/Tooltip';\nimport Box from '@mui/material/Box';\nimport Select from '@mui/material/Select';\nimport MenuItem from '@mui/material/MenuItem';\nimport MuiTextField from '../../TextItem/MuiTextField';\nimport { grey } from '@mui/material/colors';\nimport Typography from '@mui/material/Typography';\nimport { useRendererStylingStore } from '../../../../stores';\n\ninterface CustomTimeFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n timeInput: string;\n periodInput: string;\n is24HourNotation: boolean;\n feedback: string;\n displayPrompt: string;\n readOnly: boolean;\n isPartOfDateTime: boolean;\n onTimeInputChange: (newInput: string) => void;\n onPeriodChange: (newPeriod: string) => void;\n}\n\nfunction CustomTimeField(props: CustomTimeFieldProps) {\n const {\n linkId,\n itemType,\n timeInput,\n periodInput,\n is24HourNotation,\n feedback,\n displayPrompt,\n readOnly,\n isPartOfDateTime,\n isTabled,\n onTimeInputChange,\n onPeriodChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n // If this reusable time field is part of a DateTime component, do not assign an id to the wrapping <Box/>\n // If this reusable time field is from a Time component, the wrapping <Box/> should have an id\n const itemId = isPartOfDateTime ? undefined : itemType + '-' + linkId;\n\n const timeId = itemType + '-' + linkId + '-time';\n const periodId = itemType + '-' + linkId + '-period';\n\n return (\n <Tooltip title={isTabled ? feedback : ''}>\n <>\n <Box\n id={itemId}\n display=\"flex\"\n alignItems=\"center\"\n columnGap={1}\n sx={{ maxWidth: !isTabled ? textFieldWidth : 3000, minWidth: 160 }}>\n <MuiTextField\n id={timeId}\n value={timeInput}\n error={!!feedback}\n fullWidth\n sx={{ flex: 1 }}\n onChange={(e: ChangeEvent<HTMLInputElement>) => onTimeInputChange(e.target.value)}\n label={displayPrompt}\n placeholder=\"--:--\"\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n size=\"small\"\n slotProps={{\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly'\n }\n }}\n />\n <Select\n id={periodId}\n value={is24HourNotation ? '' : periodInput}\n error={!!feedback}\n disabled={(readOnly && readOnlyVisualStyle === 'disabled') || is24HourNotation}\n readOnly={(readOnly && readOnlyVisualStyle === 'readonly') || is24HourNotation}\n displayEmpty\n size=\"small\"\n sx={{ flex: 1 }}\n onChange={(e) => onPeriodChange(e.target.value)}>\n <MenuItem value=\"\">\n <span style={{ color: grey['500'] }}>{is24HourNotation ? '-' : 'AM/PM'}</span>\n </MenuItem>\n <MenuItem value=\"AM\">AM</MenuItem>\n <MenuItem value=\"PM\">PM</MenuItem>\n </Select>\n </Box>\n <Typography variant=\"caption\" color=\"error\" sx={{ ml: 1.75, mt: -0.5 }}>\n {isTabled ? '' : feedback}\n </Typography>\n </>\n </Tooltip>\n );\n}\n\nexport default CustomTimeField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Dispatch, SetStateAction } from 'react';\nimport React from 'react';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../../interfaces/renderProps.interface';\nimport CustomDateField from '../CustomDateItem/CustomDateField';\nimport CustomTimeField from './CustomTimeField';\nimport Stack from '@mui/material/Stack';\n\ninterface DateTimeFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n displayDate: string;\n dateInput: string;\n timeInput: string;\n periodInput: string;\n is24HourNotation: boolean;\n dateFeedback: string;\n timeFeedback: string;\n dateFocused: boolean;\n displayPrompt: string;\n entryFormat: string;\n readOnly: boolean;\n onDateInputChange: (newDateInput: string) => void;\n onSelectDate: (selectedDate: string) => void;\n setDateFocused: Dispatch<SetStateAction<boolean>>;\n onTimeInputChange: (newTimeInput: string, newPeriodInput: string) => void;\n}\n\nfunction DateTimeField(props: DateTimeFieldProps) {\n const {\n linkId,\n itemType,\n displayDate,\n dateInput,\n timeInput,\n periodInput,\n is24HourNotation,\n dateFeedback,\n timeFeedback,\n dateFocused,\n displayPrompt,\n entryFormat,\n readOnly,\n isTabled,\n onDateInputChange,\n onSelectDate,\n setDateFocused,\n onTimeInputChange\n } = props;\n\n return (\n <Stack id={itemType + '-' + linkId} rowGap={1}>\n <CustomDateField\n linkId={linkId}\n itemType={itemType}\n valueDate={displayDate}\n input={dateInput}\n feedback={dateFeedback ?? ''}\n isFocused={dateFocused}\n displayPrompt={displayPrompt}\n entryFormat={entryFormat}\n readOnly={readOnly}\n isPartOfDateTime={true}\n isTabled={isTabled}\n setFocused={setDateFocused}\n onInputChange={onDateInputChange}\n onSelectDate={onSelectDate}\n />\n <CustomTimeField\n linkId={linkId}\n itemType={itemType}\n timeInput={timeInput}\n periodInput={periodInput}\n is24HourNotation={is24HourNotation}\n feedback={timeFeedback ?? ''}\n displayPrompt={displayPrompt}\n readOnly={readOnly}\n isPartOfDateTime={true}\n isTabled={isTabled}\n onTimeInputChange={(newTimeInput) => onTimeInputChange(newTimeInput, periodInput)}\n onPeriodChange={(newPeriodInput) => onTimeInputChange(timeInput, newPeriodInput)}\n />\n </Stack>\n );\n}\n\nexport default DateTimeField;\n","import React, { useCallback, useMemo, useState } from 'react';\nimport type { BaseItemProps } from '../../../interfaces/renderProps.interface';\nimport type {\n Quantity,\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponseItem\n} from 'fhir/r4';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport useValidationFeedback from '../../../hooks/useValidationFeedback';\nimport debounce from 'lodash.debounce';\nimport { DEBOUNCE_DURATION } from '../../../utils/debounce';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport { parseDecimalStringWithPrecision } from '../../../utils/parseInputs';\nimport { getDecimalPrecision } from '../../../utils/itemControl';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport Box from '@mui/material/Box';\nimport QuantityField from './QuantityField';\nimport QuantityUnitField from './QuantityUnitField';\nimport {\n createQuantityItemAnswer,\n quantityComparators,\n stringIsComparator\n} from '../../../utils/quantity';\nimport QuantityComparatorField from './QuantityComparatorField';\nimport useQuantityCalculatedExpression from '../../../hooks/useQuantityCalculatedExpression';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface QuantityItemProps extends BaseItemProps {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n}\n\nfunction QuantityItem(props: QuantityItemProps) {\n const {\n qItem,\n qrItem,\n isRepeated,\n isTabled,\n renderingExtensions,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const precision = getDecimalPrecision(qItem);\n const { displayPrompt, entryFormat, quantityUnit } = renderingExtensions;\n let { displayUnit } = renderingExtensions;\n\n // Get units options if present\n const unitOptions = useMemo(\n () =>\n qItem.extension?.filter(\n (f) => f.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-unitOption'\n ) ?? [],\n [qItem]\n );\n if (displayUnit === '' && unitOptions.length === 1) {\n displayUnit = unitOptions[0].valueCoding?.display ?? '';\n }\n\n // Init inputs\n const answerKey = qrItem?.answer?.[0].id;\n let valueQuantity: Quantity = {};\n let initialValueInput = '';\n let initialComparatorInput: Quantity['comparator'] | null = null;\n let initialUnitInput: QuestionnaireItemAnswerOption | null =\n quantityUnit ?? unitOptions?.at(0) ?? null;\n if (qrItem?.answer) {\n if (qrItem?.answer[0].valueQuantity) {\n valueQuantity = qrItem.answer[0].valueQuantity;\n }\n\n initialValueInput =\n (precision ? valueQuantity.value?.toFixed(precision) : valueQuantity.value?.toString()) || '';\n\n if (valueQuantity.comparator && stringIsComparator(valueQuantity.comparator)) {\n initialComparatorInput = valueQuantity.comparator;\n }\n\n if (valueQuantity.code && valueQuantity.system) {\n initialUnitInput = {\n valueCoding: {\n code: valueQuantity.code,\n system: valueQuantity.system,\n display: valueQuantity.unit\n }\n };\n }\n }\n\n // input states\n const [valueInput, setValueInput] = useState(initialValueInput);\n const [comparatorInput, setComparatorInput] = useState<Quantity['comparator'] | null>(\n initialComparatorInput\n );\n const [unitInput, setUnitInput] = useState<QuestionnaireItemAnswerOption | null>(\n initialUnitInput\n );\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n // Perform validation checks\n const feedback = useValidationFeedback(qItem, feedbackFromParent, valueInput);\n\n // Process calculated expressions\n const { calcExpUpdated } = useQuantityCalculatedExpression({\n qItem: qItem,\n inputValue: valueInput,\n precision: precision,\n onChangeByCalcExpressionDecimal: (newValueDecimal: number) => {\n setValueInput(\n typeof precision === 'number'\n ? newValueDecimal.toFixed(precision)\n : newValueDecimal.toString()\n );\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [\n {\n id: answerKey,\n valueQuantity: {\n value: newValueDecimal,\n unit: unitInput?.valueCoding?.display,\n system: unitInput?.valueCoding?.system,\n code: unitInput?.valueCoding?.code\n }\n }\n ]\n });\n },\n onChangeByCalcExpressionQuantity: (\n newValueDecimal: number,\n newUnitSystem,\n newUnitCode,\n newUnitDisplay\n ) => {\n setValueInput(\n typeof precision === 'number'\n ? newValueDecimal.toFixed(precision)\n : newValueDecimal.toString()\n );\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: [\n {\n id: answerKey,\n valueQuantity: {\n value: newValueDecimal,\n unit: newUnitDisplay,\n system: newUnitSystem,\n code: newUnitCode\n }\n }\n ]\n });\n },\n onChangeByCalcExpressionNull: () => {\n setValueInput('');\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n }\n });\n\n // Event handlers\n function handleComparatorInputChange(newComparatorInput: Quantity['comparator'] | null) {\n setComparatorInput(newComparatorInput);\n\n if (!valueInput) return;\n\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: createQuantityItemAnswer(\n precision,\n valueInput,\n newComparatorInput,\n unitInput,\n answerKey\n )\n });\n }\n\n function handleUnitInputChange(newUnitInput: QuestionnaireItemAnswerOption | null) {\n setUnitInput(newUnitInput);\n\n if (!valueInput) return;\n\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: createQuantityItemAnswer(\n precision,\n valueInput,\n comparatorInput,\n newUnitInput,\n answerKey\n )\n });\n }\n\n function handleValueInputChange(newInput: string) {\n const parsedNewInput: string = parseDecimalStringWithPrecision(newInput, precision);\n\n setValueInput(parsedNewInput);\n updateQrItemWithDebounce(parsedNewInput);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const updateQrItemWithDebounce = useCallback(\n debounce((parsedNewInput: string) => {\n if (parsedNewInput === '') {\n onQrItemChange(createEmptyQrItem(qItem, answerKey));\n } else {\n onQrItemChange({\n ...createEmptyQrItem(qItem, answerKey),\n answer: createQuantityItemAnswer(\n precision,\n parsedNewInput,\n comparatorInput,\n unitInput,\n answerKey\n )\n });\n }\n }, DEBOUNCE_DURATION),\n [onQrItemChange, qItem, displayUnit, precision, comparatorInput, unitInput]\n ); // Dependencies are tested, debounce is causing eslint to not recognise dependencies\n\n const showUnitOptions = unitOptions.length > 0 && displayUnit === '';\n\n if (isRepeated) {\n return (\n <Box\n id={qItem.type + '-' + qItem.linkId}\n data-test=\"q-item-quantity-box\"\n display=\"flex\"\n gap={1}>\n <QuantityComparatorField\n linkId={qItem.linkId}\n itemType={qItem.type}\n options={quantityComparators}\n valueSelect={comparatorInput}\n readOnly={readOnly}\n isTabled={isTabled}\n onChange={handleComparatorInputChange}\n />\n <QuantityField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={valueInput}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n isTabled={isTabled}\n onInputChange={handleValueInputChange}\n />\n {showUnitOptions ? (\n <QuantityUnitField\n linkId={qItem.linkId}\n itemType={qItem.type}\n options={unitOptions}\n valueSelect={unitInput}\n readOnly={readOnly}\n isTabled={isTabled}\n onChange={handleUnitInputChange}\n />\n ) : null}\n </Box>\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-quantity-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <Box display=\"flex\" gap={1}>\n <QuantityComparatorField\n linkId={qItem.linkId}\n itemType={qItem.type}\n options={quantityComparators}\n valueSelect={comparatorInput}\n readOnly={readOnly}\n isTabled={isTabled}\n onChange={handleComparatorInputChange}\n />\n <QuantityField\n linkId={qItem.linkId}\n itemType={qItem.type}\n input={valueInput}\n feedback={feedback}\n displayPrompt={displayPrompt}\n displayUnit={displayUnit}\n entryFormat={entryFormat}\n readOnly={readOnly}\n calcExpUpdated={calcExpUpdated}\n isTabled={isTabled}\n onInputChange={handleValueInputChange}\n />\n {showUnitOptions ? (\n <QuantityUnitField\n linkId={qItem.linkId}\n itemType={qItem.type}\n options={unitOptions}\n valueSelect={unitInput}\n readOnly={readOnly}\n isTabled={isTabled}\n onChange={handleUnitInputChange}\n />\n ) : null}\n </Box>\n }\n feedback={feedback}\n />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default QuantityItem;\n","import React from 'react';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport FadingCheckIcon from '../ItemParts/FadingCheckIcon';\nimport { StandardTextField } from '../Textfield.styles';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport { useRendererStylingStore } from '../../../stores';\nimport DisplayUnitText from '../ItemParts/DisplayUnitText';\n\ninterface QuantityFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n input: string;\n feedback: string;\n displayPrompt: string;\n displayUnit: string;\n entryFormat: string;\n readOnly: boolean;\n calcExpUpdated: boolean;\n onInputChange: (value: string) => void;\n}\n\nfunction QuantityField(props: QuantityFieldProps) {\n const {\n linkId,\n itemType,\n input,\n feedback,\n displayPrompt,\n displayUnit,\n entryFormat,\n readOnly,\n calcExpUpdated,\n isTabled,\n onInputChange\n } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n return (\n <StandardTextField\n id={itemType + '-' + linkId + '-input'}\n value={input}\n error={!!feedback}\n onChange={(event) => onInputChange(event.target.value)}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n label={displayPrompt}\n placeholder={entryFormat === '' ? '0.0' : entryFormat}\n fullWidth\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n size=\"small\"\n slotProps={{\n htmlInput: { inputMode: 'numeric', pattern: '[0-9]*' },\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly',\n endAdornment: (\n <InputAdornment position={'end'}>\n <FadingCheckIcon fadeIn={calcExpUpdated} disabled={readOnly} />\n <DisplayUnitText readOnly={readOnly}>{displayUnit}</DisplayUnitText>\n </InputAdornment>\n )\n }\n }}\n helperText={feedback}\n data-test=\"q-item-quantity-field\"\n />\n );\n}\n\nexport default QuantityField;\n","import React from 'react';\nimport { getAnswerOptionLabel } from '../../../utils/openChoice';\nimport { StandardTextField } from '../Textfield.styles';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport type { QuestionnaireItemAnswerOption } from 'fhir/r4';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface QuantityUnitFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n options: QuestionnaireItemAnswerOption[];\n valueSelect: QuestionnaireItemAnswerOption | null;\n readOnly: boolean;\n onChange: (newValue: QuestionnaireItemAnswerOption | null) => void;\n}\n\nfunction QuantityUnitField(props: QuantityUnitFieldProps) {\n const { linkId, itemType, options, valueSelect, readOnly, isTabled, onChange } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const textFieldWidth = useRendererStylingStore.use.textFieldWidth();\n\n return (\n <Autocomplete\n id={itemType + '-' + linkId + '-unit'}\n value={valueSelect ?? null}\n isOptionEqualToValue={(option, value) =>\n option.valueCoding?.code === value?.valueCoding?.code\n }\n options={options}\n getOptionLabel={(option) => getAnswerOptionLabel(option)}\n onChange={(_, newValue) => onChange(newValue as QuestionnaireItemAnswerOption | null)}\n autoHighlight\n sx={{ maxWidth: !isTabled ? textFieldWidth : 3000, minWidth: 160, flexGrow: 1 }}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n size=\"small\"\n renderInput={(params) => (\n <StandardTextField\n textFieldWidth={textFieldWidth}\n isTabled={isTabled}\n {...params}\n slotProps={{\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly'\n }\n }}\n />\n )}\n />\n );\n}\n\nexport default QuantityUnitField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n Quantity,\n QuestionnaireItemAnswerOption,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport { parseDecimalStringToFloat } from './parseInputs';\n\nexport const quantityComparators: Quantity['comparator'][] = ['<', '<=', '>=', '>'];\n\nexport function stringIsComparator(str: string | undefined): str is Quantity['comparator'] {\n return str === '<' || str === '<=' || str === '>=' || str === '>';\n}\n\nexport function createQuantityItemAnswer(\n precision: number | null,\n parsedNewInput: string,\n comparatorInput: Quantity['comparator'] | null,\n unitInput: QuestionnaireItemAnswerOption | null,\n answerKey: string | undefined\n): QuestionnaireResponseItemAnswer[] {\n if (precision) {\n return [\n {\n id: answerKey,\n valueQuantity: {\n value: parseDecimalStringToFloat(parsedNewInput, precision),\n comparator: comparatorInput ?? undefined,\n unit: unitInput?.valueCoding?.display,\n system: unitInput?.valueCoding?.system,\n code: unitInput?.valueCoding?.code\n }\n }\n ];\n }\n\n return [\n {\n id: answerKey,\n valueQuantity: {\n value: parseFloat(parsedNewInput),\n comparator: comparatorInput ?? undefined,\n unit: unitInput?.valueCoding?.display,\n system: unitInput?.valueCoding?.system,\n code: unitInput?.valueCoding?.code\n }\n }\n ];\n}\n","import React from 'react';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport type { PropsWithIsTabledRequiredAttribute } from '../../../interfaces/renderProps.interface';\nimport MuiTextField from '../TextItem/MuiTextField';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport type { Quantity } from 'fhir/r4';\nimport { useRendererStylingStore } from '../../../stores';\n\ninterface QuantityComparatorFieldProps extends PropsWithIsTabledRequiredAttribute {\n linkId: string;\n itemType: string;\n options: Quantity['comparator'][];\n valueSelect: Quantity['comparator'] | null;\n readOnly: boolean;\n onChange: (newValue: Quantity['comparator'] | null) => void;\n}\n\nfunction QuantityComparatorField(props: QuantityComparatorFieldProps) {\n const { linkId, itemType, options, valueSelect, readOnly, onChange } = props;\n\n const readOnlyVisualStyle = useRendererStylingStore.use.readOnlyVisualStyle();\n const hideQuantityComparatorField = useRendererStylingStore.use.hideQuantityComparatorField();\n if (hideQuantityComparatorField) {\n return null;\n }\n\n return (\n <Box>\n <Autocomplete\n id={itemType + '-' + linkId + '-comparator'}\n value={valueSelect ?? null}\n options={options}\n onChange={(_, newValue) => onChange(newValue as Quantity['comparator'])}\n autoHighlight\n sx={{ width: 88 }}\n disabled={readOnly && readOnlyVisualStyle === 'disabled'}\n readOnly={readOnly && readOnlyVisualStyle === 'readonly'}\n size=\"small\"\n renderInput={(params) => (\n <MuiTextField\n sx={{ width: 88 }}\n {...params}\n slotProps={{\n input: {\n readOnly: readOnly && readOnlyVisualStyle === 'readonly'\n }\n }}\n />\n )}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n (optional)\n </Typography>\n </Box>\n );\n}\n\nexport default QuantityComparatorField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from 'react';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport { useQuestionnaireStore } from '../stores';\nimport { validateCodePromise } from '../utils/valueSet';\nimport { TERMINOLOGY_SERVER_URL } from '../globals';\nimport type {\n CodeParameter,\n DisplayParameter,\n SystemParameter\n} from '../interfaces/valueSet.interface';\n\ninterface UseQuantityCalculatedExpression {\n calcExpUpdated: boolean;\n}\n\ninterface UseQuantityCalculatedExpressionProps {\n qItem: QuestionnaireItem;\n inputValue: string;\n precision: number | null;\n onChangeByCalcExpressionDecimal: (newValue: number) => void;\n onChangeByCalcExpressionQuantity: (\n newValue: number,\n newUnitSystem: string,\n newUnitCode: string,\n newUnitDisplay: string\n ) => void;\n onChangeByCalcExpressionNull: () => void;\n}\n\nfunction useQuantityCalculatedExpression(\n props: UseQuantityCalculatedExpressionProps\n): UseQuantityCalculatedExpression {\n const {\n qItem,\n inputValue,\n precision,\n onChangeByCalcExpressionDecimal,\n onChangeByCalcExpressionQuantity,\n onChangeByCalcExpressionNull\n } = props;\n\n const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();\n\n const [calcExpUpdated, setCalcExpUpdated] = useState(false);\n\n useEffect(\n () => {\n const calcExpression = calculatedExpressions[qItem.linkId]?.find(\n (exp) => exp.from === 'item'\n );\n\n if (!calcExpression) {\n return;\n }\n\n // only update if calculated value is different from current value\n if (\n calcExpression.value !== inputValue &&\n (typeof calcExpression.value === 'number' ||\n typeof calcExpression.value === 'string' ||\n calcExpression.value === null)\n ) {\n // Null path\n if (calcExpression.value === null) {\n onChangeByCalcExpressionNull();\n return;\n }\n\n // Number path\n if (typeof calcExpression.value === 'number') {\n const calcExpressionValue =\n typeof precision === 'number'\n ? parseFloat(calcExpression.value.toFixed(precision))\n : calcExpression.value;\n\n // only update if calculated value is different from current value\n if (calcExpressionValue !== parseFloat(inputValue)) {\n // update ui to show calculated value changes\n setCalcExpUpdated(true);\n const timeoutId = setTimeout(() => {\n setCalcExpUpdated(false);\n }, 500);\n\n // calculatedExpression value is null\n if (calcExpressionValue === null) {\n onChangeByCalcExpressionNull();\n return () => clearTimeout(timeoutId);\n }\n\n // calculatedExpression value is a number\n onChangeByCalcExpressionDecimal(calcExpressionValue);\n return () => clearTimeout(timeoutId);\n }\n }\n\n // String path (quantity)\n if (typeof calcExpression.value === 'string') {\n try {\n const [value, unitCode] = calcExpression.value.split(' ');\n const unitCodeFormatted = unitCode.replace(/'/g, '');\n\n const ucumValueSet = 'http://hl7.org/fhir/ValueSet/ucum-units';\n const ucumSystem = 'http://unitsofmeasure.org';\n\n validateCodePromise(\n ucumValueSet,\n ucumSystem,\n unitCodeFormatted,\n TERMINOLOGY_SERVER_URL\n ).then((validateCodeResponse) => {\n // Return early if validate-code request fails\n if (!validateCodeResponse) {\n onChangeByCalcExpressionNull();\n return;\n }\n\n if (validateCodeResponse.parameter) {\n const systemParameter = validateCodeResponse.parameter.find(\n (p) => p.name === 'system'\n ) as SystemParameter;\n const codeParameter = validateCodeResponse.parameter.find(\n (p) => p.name === 'code'\n ) as CodeParameter;\n const displayParameter = validateCodeResponse.parameter.find(\n (p) => p.name === 'display'\n ) as DisplayParameter;\n if (\n systemParameter.valueUri &&\n codeParameter.valueCode &&\n displayParameter.valueString\n ) {\n // update ui to show calculated value changes\n setCalcExpUpdated(true);\n const timeoutId = setTimeout(() => {\n setCalcExpUpdated(false);\n }, 500);\n\n onChangeByCalcExpressionQuantity(\n parseFloat(value),\n systemParameter.valueUri,\n codeParameter.valueCode,\n displayParameter.valueString\n );\n return () => clearTimeout(timeoutId);\n }\n }\n });\n } catch (e) {\n console.error(e);\n onChangeByCalcExpressionNull();\n }\n }\n }\n },\n // Only trigger this effect if calculatedExpression of item changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [calculatedExpressions]\n );\n\n return { calcExpUpdated: calcExpUpdated };\n}\n\nexport default useQuantityCalculatedExpression;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { getQrItemsIndex, mapQItemsIndex } from '../../../utils/mapItem';\nimport GroupItemSwitcher from '../GroupItem/GroupItemSwitcher';\nimport { createEmptyQrGroup, updateQrItemsInGroup } from '../../../utils/qrItem';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler\n} from '../../../interfaces/renderProps.interface';\nimport type { QrRepeatGroup } from '../../../interfaces/repeatGroup.interface';\nimport Box from '@mui/material/Box';\n\ninterface SingleNestedItemsProps\n extends PropsWithQrItemChangeHandler,\n PropsWithParentIsReadOnlyAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n groupCardElevation: number;\n}\n\nfunction SingleNestedItems(props: SingleNestedItemsProps) {\n const { qItem, qrItem, groupCardElevation, parentIsReadOnly, onQrItemChange } = props;\n\n const qItemsIndexMap: Record<string, number> = useMemo(() => mapQItemsIndex(qItem), [qItem]);\n\n const qItems = qItem.item;\n const qrGroup = qrItem && qrItem.item ? qrItem : createEmptyQrGroup(qItem);\n const qrItems = qrGroup.item;\n\n // Event Handlers\n function handleQrItemChange(newQrItem: QuestionnaireResponseItem) {\n const updatedQrGroup: QuestionnaireResponseItem = { ...qrGroup };\n updateQrItemsInGroup(newQrItem, null, updatedQrGroup, qItemsIndexMap);\n onQrItemChange(updatedQrGroup);\n }\n\n function handleQrRepeatGroupChange(qrRepeatGroup: QrRepeatGroup) {\n const updatedQrGroup: QuestionnaireResponseItem = { ...qrGroup };\n updateQrItemsInGroup(null, qrRepeatGroup, updatedQrGroup, qItemsIndexMap);\n onQrItemChange(updatedQrGroup);\n }\n\n if (!qItems || !qrItems) {\n return <>Unable to load group, something has gone terribly wrong.</>;\n }\n\n const qrItemsByIndex = getQrItemsIndex(qItems, qrItems, qItemsIndexMap);\n\n // TODO - Add support for horizontal \"row\" layout\n return (\n <Box display=\"flex\">\n <Box ml={1.5} />\n <Box flexGrow={1}>\n {qItems.map((qItem: QuestionnaireItem, i) => {\n const qrItemOrItems = qrItemsByIndex[i];\n\n if (qItem.type === 'display') {\n return null;\n }\n\n return (\n <GroupItemSwitcher\n key={qItem.linkId}\n qItem={qItem}\n qrItemOrItems={qrItemOrItems}\n groupCardElevation={groupCardElevation + 1}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={handleQrItemChange}\n onQrRepeatGroupChange={handleQrRepeatGroupChange}\n />\n );\n })}\n </Box>\n <Box mr={2.25}></Box>\n </Box>\n );\n}\n\nexport default SingleNestedItems;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport type {\n PropsWithFeedbackFromParentAttribute,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport SingleItemSwitcher from './SingleItemSwitcher';\nimport SingleNestedItems from './SingleNestedItems';\nimport { GroupCard } from '../GroupItem/GroupItem.styles';\nimport { QGroupContainerBox } from '../../Box.styles';\nimport { getGroupCollapsible } from '../../../utils/qItem';\nimport ExpandMoreIcon from '@mui/icons-material/ExpandMore';\nimport AccordionDetails from '@mui/material/AccordionDetails';\nimport StopPropagationWrapper from './StopPropagationWrapper';\nimport {\n NestedSingleItemAccordion,\n NestedSingleItemAccordionSummary,\n NestedSingleItemAccordionWrapper\n} from './NestedSingleItemAccordion.styles';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport Box from '@mui/material/Box';\nimport useRenderingExtensions from '../../../hooks/useRenderingExtensions';\n\ninterface SingleItemViewProps\n extends PropsWithQrItemChangeHandler,\n PropsWithIsRepeatedAttribute,\n PropsWithIsTabledRequiredAttribute,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithFeedbackFromParentAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n itemIsHidden: boolean;\n itemHasNestedItems: boolean;\n groupCardElevation: number;\n onQrItemChangeWithNestedItems: (qrItem: QuestionnaireResponseItem) => void;\n parentStyles?: Record<string, string>;\n}\n\nfunction SingleItemView(props: SingleItemViewProps) {\n const {\n qItem,\n qrItem,\n itemIsHidden,\n itemHasNestedItems,\n isRepeated,\n isTabled,\n groupCardElevation,\n showMinimalView,\n parentIsReadOnly,\n feedbackFromParent,\n onQrItemChange,\n onQrItemChangeWithNestedItems,\n parentStyles\n } = props;\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n const renderingExtensions = useRenderingExtensions(qItem);\n const groupCollapsibleValue = getGroupCollapsible(qItem);\n\n // Item hidden, do not render\n if (itemIsHidden) {\n return null;\n }\n\n // Item has nested items and is collapsible\n if (itemHasNestedItems && groupCollapsibleValue) {\n const isDefaultOpen = groupCollapsibleValue === 'default-open';\n return (\n <NestedSingleItemAccordionWrapper isRepeated={isRepeated}>\n <NestedSingleItemAccordion\n disableGutters\n defaultExpanded={isDefaultOpen}\n elevation={groupCardElevation}\n slotProps={{\n transition: { unmountOnExit: true, timeout: 250 }\n }}>\n <NestedSingleItemAccordionSummary expandIcon={<ExpandMoreIcon />}>\n <Box width=\"100%\">\n <StopPropagationWrapper>\n <SingleItemSwitcher\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n showMinimalView={showMinimalView}\n parentIsReadOnly={readOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n </StopPropagationWrapper>\n </Box>\n </NestedSingleItemAccordionSummary>\n\n <AccordionDetails sx={{ pt: 0 }}>\n {/* This box with marginRight:\"24px\" below is to align the parent item with the nested child items (due to space taken by the expand button */}\n <Box mr={3}>\n <SingleNestedItems\n qItem={qItem}\n qrItem={qrItem}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={readOnly}\n onQrItemChange={onQrItemChangeWithNestedItems}\n />\n </Box>\n </AccordionDetails>\n </NestedSingleItemAccordion>\n </NestedSingleItemAccordionWrapper>\n );\n }\n\n // Item has nested items but is not collapsible\n if (itemHasNestedItems) {\n return (\n <QGroupContainerBox\n cardElevation={groupCardElevation}\n isRepeated={isRepeated}\n data-test=\"q-item-group-box\">\n <GroupCard elevation={groupCardElevation} isRepeated={isRepeated}>\n <SingleItemSwitcher\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n showMinimalView={showMinimalView}\n parentIsReadOnly={readOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n <SingleNestedItems\n qItem={qItem}\n qrItem={qrItem}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={readOnly}\n onQrItemChange={onQrItemChangeWithNestedItems}\n />\n </GroupCard>\n </QGroupContainerBox>\n );\n }\n\n return (\n <SingleItemSwitcher\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={isRepeated}\n isTabled={isTabled}\n renderingExtensions={renderingExtensions}\n showMinimalView={showMinimalView}\n parentIsReadOnly={readOnly}\n feedbackFromParent={feedbackFromParent}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n}\n\nexport default SingleItemView;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ReactNode } from 'react';\nimport React from 'react';\n\ninterface StopPropagationWrapperProps {\n children: ReactNode;\n}\n\nfunction StopPropagationWrapper(props: StopPropagationWrapperProps) {\n const { children } = props;\n\n return (\n <div\n onClick={(event) => {\n event.stopPropagation();\n }}>\n {children}\n </div>\n );\n}\n\nexport default StopPropagationWrapper;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { styled } from '@mui/material/styles';\nimport { AccordionSummary } from '@mui/material';\nimport Accordion from '@mui/material/Accordion';\nimport Box from '@mui/material/Box';\n\nexport const NestedSingleItemAccordionWrapper = styled(Box, {\n shouldForwardProp: (prop) => prop !== 'isRepeated'\n})<{ isRepeated: boolean }>(({ isRepeated }) => ({\n marginBottom: isRepeated ? 0 : '28px'\n}));\n\nexport const NestedSingleItemAccordion = styled(Accordion, {\n shouldForwardProp: (prop) => prop !== 'elevation'\n})<{ elevation: number }>(({ elevation }) => ({\n paddingTop: '8px',\n paddingBottom: '4px',\n paddingLeft: elevation === 1 ? '10px' : '8px',\n paddingRight: elevation === 1 ? '10px' : '8px'\n}));\n\nexport const NestedSingleItemAccordionSummary = styled(AccordionSummary)(() => ({\n minHeight: '28px',\n '.MuiAccordionSummary-expandIconWrapper': {\n '&:hover:not(.Mui-disabled)': {\n cursor: 'pointer'\n }\n },\n '.MuiAccordionSummary-content': {\n marginBottom: 0\n },\n '&.Mui-focusVisible': {\n backgroundColor: 'transparent'\n },\n '&:hover:not(.Mui-disabled)': {\n cursor: 'default'\n }\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrGroup, updateQrItemsInGroup } from '../../../utils/qrItem';\nimport SingleItem from '../SingleItem/SingleItem';\nimport { getQrItemsIndex } from '../../../utils/mapItem';\nimport { StandardTableCell } from './Table.styles';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler\n} from '../../../interfaces/renderProps.interface';\n\ninterface GroupTableRowCellsProps\n extends PropsWithQrItemChangeHandler,\n PropsWithParentIsReadOnlyAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n qItemsIndexMap: Record<string, number>;\n}\n\nfunction GroupTableRowCells(props: GroupTableRowCellsProps) {\n const { qItem, qrItem, qItemsIndexMap, parentIsReadOnly, onQrItemChange } = props;\n\n const rowItems = qItem.item;\n const row = qrItem && qrItem.item ? qrItem : createEmptyQrGroup(qItem);\n const rowQrItems = row.item;\n\n if (!rowItems || !rowQrItems) {\n return null;\n }\n\n function handleQrRowItemChange(newQrRowItem: QuestionnaireResponseItem) {\n const qrRow: QuestionnaireResponseItem = { ...row };\n updateQrItemsInGroup(newQrRowItem, null, qrRow, qItemsIndexMap);\n onQrItemChange(qrRow);\n }\n\n const qrItemsByIndex = getQrItemsIndex(rowItems, rowQrItems, qItemsIndexMap);\n\n return (\n <>\n {rowItems.map((rowItem, index) => {\n const qrItem = qrItemsByIndex[index];\n\n if (Array.isArray(qrItem)) {\n return null;\n }\n\n return (\n <StandardTableCell key={index} numOfColumns={rowItems.length}>\n <SingleItem\n key={qItem.linkId}\n qItem={rowItem}\n qrItem={qrItem ?? null}\n isRepeated={true}\n isTabled={true}\n groupCardElevation={1}\n showMinimalView={true}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={handleQrRowItemChange}\n />\n </StandardTableCell>\n );\n })}\n </>\n );\n}\n\nexport default GroupTableRowCells;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { DeleteButtonTableCell } from './Table.styles';\nimport IconButton from '@mui/material/IconButton';\nimport Tooltip from '@mui/material/Tooltip';\n\nimport RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline';\nimport type { QuestionnaireResponseItem } from 'fhir/r4';\n\ninterface RemoveRowButtonProps {\n nullableQrItem: QuestionnaireResponseItem | null;\n numOfRows: number;\n readOnly: boolean;\n onRemoveItem: () => void;\n}\n\nfunction RemoveRowButton(props: RemoveRowButtonProps) {\n const { nullableQrItem, numOfRows, readOnly, onRemoveItem } = props;\n\n const isDisabled = nullableQrItem === null || numOfRows === 1 || readOnly;\n return (\n <DeleteButtonTableCell>\n <Tooltip title=\"Remove item\">\n <span>\n <IconButton size=\"small\" color=\"error\" disabled={isDisabled} onClick={onRemoveItem}>\n <RemoveCircleOutlineIcon fontSize=\"small\" />\n </IconButton>\n </span>\n </Tooltip>\n </DeleteButtonTableCell>\n );\n}\n\nexport default RemoveRowButton;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport type { GroupTableRowModel } from '../../../interfaces/groupTable.interface';\nimport type {\n PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport GroupTableRow from './GroupTableRow';\nimport type { DropResult } from 'react-beautiful-dnd';\nimport { DragDropContext, Droppable } from 'react-beautiful-dnd';\nimport { reorderRows } from '../../../utils/groupTable';\nimport TableBody from '@mui/material/TableBody';\n\ninterface GroupTableBodyProps\n extends PropsWithIsRepeatedAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithShowMinimalViewAttribute {\n tableQItem: QuestionnaireItem;\n readOnly: boolean;\n tableRows: GroupTableRowModel[];\n selectedIds: string[];\n qItemsIndexMap: Record<string, number>;\n onRowChange: (newQrRow: QuestionnaireResponseItem, index: number) => void;\n onRemoveRow: (index: number) => void;\n onSelectRow: (rowId: string) => void;\n onReorderRows: (newTableRows: GroupTableRowModel[]) => void;\n}\n\nfunction GroupTableBody(props: GroupTableBodyProps) {\n const {\n tableQItem,\n readOnly,\n tableRows,\n selectedIds,\n qItemsIndexMap,\n isRepeated,\n showMinimalView,\n parentIsReadOnly,\n onRowChange,\n onRemoveRow,\n onSelectRow,\n onReorderRows\n } = props;\n\n function onDragEnd(result: DropResult) {\n if (!result.destination) {\n return;\n }\n\n if (result.destination.index === result.source.index) {\n return;\n }\n\n const reorderedRows = reorderRows(tableRows, result.source.index, result.destination.index);\n\n onReorderRows(reorderedRows);\n }\n\n return (\n <DragDropContext onDragEnd={onDragEnd}>\n <Droppable droppableId=\"gtable_rows\" direction=\"vertical\">\n {(droppableProvided, snapshot) => (\n <TableBody ref={droppableProvided.innerRef} {...droppableProvided.droppableProps}>\n {tableRows.map(({ id, qrItem: nullableQrItem }, index) => {\n const itemIsSelected = selectedIds.indexOf(id) !== -1;\n const answeredQrItem = createEmptyQrItem(tableQItem, undefined);\n if (nullableQrItem) {\n answeredQrItem.item = nullableQrItem.item;\n }\n\n return (\n <GroupTableRow\n key={id}\n index={index}\n rowId={id}\n tableQItem={tableQItem}\n answeredQrItem={answeredQrItem}\n nullableQrItem={nullableQrItem}\n readOnly={readOnly}\n isRepeated={isRepeated}\n hoverDisabled={snapshot.isDraggingOver}\n tableRows={tableRows}\n itemIsSelected={itemIsSelected}\n selectedIds={selectedIds}\n qItemsIndexMap={qItemsIndexMap}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n onRowChange={onRowChange}\n onRemoveRow={onRemoveRow}\n onSelectRow={onSelectRow}\n />\n );\n })}\n {droppableProvided.placeholder}\n </TableBody>\n )}\n </Droppable>\n </DragDropContext>\n );\n}\n\nexport default GroupTableBody;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { GroupTableRowModel } from '../interfaces/groupTable.interface';\n\nexport function reorderRows(\n rows: GroupTableRowModel[],\n sourceIndex: number,\n destinationIndex: number\n) {\n const result = Array.from(rows);\n const [removed] = result.splice(sourceIndex, 1);\n result.splice(destinationIndex, 0, removed);\n\n return result;\n}\n\nexport function getGroupTableItemsToUpdate(tableRows: GroupTableRowModel[], selectedIds: string[]) {\n return tableRows\n .filter((row) => selectedIds.includes(row.id))\n .flatMap((singleRow) => (singleRow.qrItem ? [structuredClone(singleRow.qrItem)] : []));\n}\n","import { styled } from '@mui/material/styles';\nimport Accordion from '@mui/material/Accordion';\n\nexport const GroupAccordion = styled(Accordion, {\n shouldForwardProp: (prop) => prop !== 'elevation'\n})<{ elevation: number }>(({ elevation }) => ({\n paddingTop: '8px',\n paddingBottom: '4px',\n paddingLeft: elevation === 1 ? '10px' : '8px',\n paddingRight: elevation === 1 ? '10px' : '8px',\n marginBottom: '28px'\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from 'react';\nimport type { GroupTableRowModel } from '../interfaces/groupTable.interface';\n\nfunction useGroupTableRows(valueFromProps: GroupTableRowModel[]) {\n const [tableRows, setTableRows] = useState(valueFromProps);\n const [selectedIds, setSelectedIds] = useState<string[]>(valueFromProps.map((row) => row.id));\n\n return { tableRows, selectedIds, setTableRows, setSelectedIds };\n}\n\nexport default useGroupTableRows;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { nanoid } from 'nanoid';\n\nexport function generateNewRepeatId(linkId: string): string {\n return `${linkId}-repeat-${nanoid()}`;\n}\n\nexport function generateExistingRepeatId(linkId: string, index: number): string {\n const paddedIndex = index.toString().padStart(6, '0');\n return `${linkId}-repeat-${paddedIndex}`;\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { QuestionnaireResponseItem } from 'fhir/r4';\nimport type { GroupTableRowModel } from '../interfaces/groupTable.interface';\nimport { generateExistingRepeatId, generateNewRepeatId } from '../utils/repeatId';\nimport { useMemo } from 'react';\n\nfunction useInitialiseGroupTableRows(\n linkId: string,\n qrItems: QuestionnaireResponseItem[]\n): GroupTableRowModel[] {\n return useMemo(() => {\n if (qrItems.length === 0) {\n return [{ id: generateNewRepeatId(linkId), qrItem: null, isSelected: true }];\n }\n\n return qrItems.map((qrItem, index) => {\n return {\n id: generateExistingRepeatId(linkId, index),\n qrItem: qrItem,\n isSelected: true\n };\n });\n }, [linkId, qrItems]);\n}\n\nexport default useInitialiseGroupTableRows;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute,\n PropsWithQrRepeatGroupChangeHandler,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport useInitialiseRepeatGroups from '../../../hooks/useInitialiseRepeatGroups';\nimport { useQuestionnaireStore } from '../../../stores';\nimport RepeatGroupView from './RepeatGroupView';\nimport { generateNewRepeatId } from '../../../utils/repeatId';\n\ninterface RepeatGroupProps\n extends PropsWithQrRepeatGroupChangeHandler,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute {\n qItem: QuestionnaireItem;\n qrItems: QuestionnaireResponseItem[];\n groupCardElevation: number;\n parentStyles?: Record<string, string>;\n}\n\n/**\n * Main component to render a repeating, group Questionnaire item.\n * Store and manages the state of multiple instances of GroupItem in a repeating group.\n *\n * @author Sean Fong\n */\nfunction RepeatGroup(props: RepeatGroupProps) {\n const {\n qItem,\n qrItems,\n groupCardElevation,\n showMinimalView,\n parentIsReadOnly,\n onQrRepeatGroupChange,\n parentStyles\n } = props;\n\n const mutateRepeatEnableWhenItems = useQuestionnaireStore.use.mutateRepeatEnableWhenItems();\n\n const initialRepeatGroups = useInitialiseRepeatGroups(qItem.linkId, qrItems);\n\n const [repeatGroups, setRepeatGroups] = useState(initialRepeatGroups);\n\n function handleAnswerChange(newQrItem: QuestionnaireResponseItem, index: number) {\n const updatedRepeatGroups = [...repeatGroups];\n\n if (newQrItem.item) {\n updatedRepeatGroups[index].qrItem = {\n linkId: newQrItem.linkId,\n text: newQrItem.text,\n item: newQrItem.item\n };\n }\n\n setRepeatGroups(updatedRepeatGroups);\n onQrRepeatGroupChange({\n linkId: qItem.linkId,\n qrItems: updatedRepeatGroups.flatMap((singleGroup) =>\n singleGroup.qrItem ? [structuredClone(singleGroup.qrItem)] : []\n )\n });\n }\n\n function handleDeleteItem(index: number) {\n const updatedRepeatGroups = [...repeatGroups];\n updatedRepeatGroups.splice(index, 1);\n\n const newLastItemIndex = repeatGroups.length;\n mutateRepeatEnableWhenItems(qItem.linkId, newLastItemIndex, 'remove');\n\n setRepeatGroups(updatedRepeatGroups);\n onQrRepeatGroupChange({\n linkId: qItem.linkId,\n qrItems: updatedRepeatGroups.flatMap((singleGroup) =>\n singleGroup.qrItem ? [structuredClone(singleGroup.qrItem)] : []\n )\n });\n }\n\n function handleAddItem() {\n const newLastItemIndex = repeatGroups.length;\n mutateRepeatEnableWhenItems(qItem.linkId, newLastItemIndex, 'add');\n setRepeatGroups([\n ...repeatGroups,\n {\n id: generateNewRepeatId(qItem.linkId),\n qrItem: null\n }\n ]);\n }\n\n return (\n <RepeatGroupView\n qItem={qItem}\n repeatGroups={repeatGroups}\n groupCardElevation={groupCardElevation}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n onAnswerChange={handleAnswerChange}\n onAddItem={handleAddItem}\n onDeleteItem={handleDeleteItem}\n parentStyles={parentStyles}\n />\n );\n}\n\nexport default RepeatGroup;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { QuestionnaireResponseItem } from 'fhir/r4';\nimport type { RepeatGroupSingleModel } from '../interfaces/repeatGroup.interface';\nimport { useMemo } from 'react';\nimport { generateExistingRepeatId, generateNewRepeatId } from '../utils/repeatId';\n\nfunction useInitialiseRepeatGroups(\n linkId: string,\n qrItems: QuestionnaireResponseItem[]\n): RepeatGroupSingleModel[] {\n return useMemo(() => {\n if (qrItems.length === 0) {\n return [{ id: generateNewRepeatId(linkId), qrItem: null }];\n }\n\n return qrItems.map((qrItem, index) => {\n return {\n id: generateExistingRepeatId(linkId, index),\n qrItem\n };\n });\n }, [linkId, qrItems]);\n}\n\nexport default useInitialiseRepeatGroups;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { QGroupContainerBox } from '../../Box.styles';\nimport Card from '@mui/material/Card';\nimport Collapse from '@mui/material/Collapse';\nimport Divider from '@mui/material/Divider';\nimport { TransitionGroup } from 'react-transition-group';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport RepeatGroupItem from './RepeatGroupItem';\nimport AddItemButton from './AddItemButton';\nimport type { RepeatGroupSingleModel } from '../../../interfaces/repeatGroup.interface';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { getGroupCollapsible } from '../../../utils/qItem';\nimport { GroupAccordion } from '../GroupItem/GroupAccordion.styles';\nimport AccordionSummary from '@mui/material/AccordionSummary';\nimport ExpandMoreIcon from '@mui/icons-material/ExpandMore';\nimport AccordionDetails from '@mui/material/AccordionDetails';\nimport GroupHeading from '../GroupItem/GroupHeading';\n\ninterface RepeatGroupViewProps\n extends PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute {\n qItem: QuestionnaireItem;\n repeatGroups: RepeatGroupSingleModel[];\n groupCardElevation: number;\n onAnswerChange: (newQrItem: QuestionnaireResponseItem, index: number) => void;\n onAddItem: () => void;\n onDeleteItem: (index: number) => void;\n parentStyles?: Record<string, string>;\n}\n\n/**\n * Main component to render a repeating, group Questionnaire item.\n * Store and manages the state of multiple instances of GroupItem in a repeating group.\n *\n * @author Sean Fong\n */\nfunction RepeatGroupView(props: RepeatGroupViewProps) {\n const {\n qItem,\n repeatGroups,\n groupCardElevation,\n showMinimalView,\n parentIsReadOnly,\n onAnswerChange,\n onAddItem,\n onDeleteItem,\n parentStyles\n } = props;\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n if (showMinimalView) {\n return (\n <QGroupContainerBox\n key={qItem.linkId}\n cardElevation={groupCardElevation}\n isRepeated={true}\n style={parentStyles || undefined}>\n <Card elevation={groupCardElevation} sx={{ p: 2 }}>\n {repeatGroups.map(({ id, qrItem: nullableQrItem }, index) => {\n const answeredQrItem = createEmptyQrItem(qItem, undefined);\n if (nullableQrItem) {\n answeredQrItem.item = nullableQrItem.item;\n }\n\n return (\n <RepeatGroupItem\n key={id}\n qItem={qItem}\n repeatGroupIndex={index}\n answeredQrItem={answeredQrItem}\n nullableQrItem={nullableQrItem}\n numOfRepeatGroups={repeatGroups.length}\n groupCardElevation={groupCardElevation}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n onDeleteItem={() => onDeleteItem(index)}\n onQrItemChange={(newQrItem) => onAnswerChange(newQrItem, index)}\n />\n );\n })}\n </Card>\n </QGroupContainerBox>\n );\n }\n\n const groupCollapsibleValue = getGroupCollapsible(qItem);\n if (groupCollapsibleValue) {\n const isDefaultOpen = groupCollapsibleValue === 'default-open';\n return (\n <GroupAccordion\n disableGutters\n defaultExpanded={isDefaultOpen}\n elevation={groupCardElevation}\n slotProps={{\n transition: { unmountOnExit: true, timeout: 250 }\n }}\n style={parentStyles || undefined}>\n <AccordionSummary expandIcon={<ExpandMoreIcon />} sx={{ minHeight: '28px' }}>\n {qItem.text ? (\n <GroupHeading\n qItem={qItem}\n readOnly={readOnly}\n groupCardElevation={groupCardElevation}\n />\n ) : null}\n </AccordionSummary>\n <AccordionDetails sx={{ pt: 0 }}>\n {qItem.text ? <Divider sx={{ mb: 1.5, opacity: 0.6 }} /> : null}\n <TransitionGroup>\n {repeatGroups.map(({ id, qrItem: nullableQrItem }, index) => {\n const answeredQrItem = createEmptyQrItem(qItem, undefined);\n if (nullableQrItem) {\n answeredQrItem.item = nullableQrItem.item;\n }\n\n return (\n <Collapse key={id} timeout={200}>\n <RepeatGroupItem\n qItem={qItem}\n repeatGroupIndex={index}\n answeredQrItem={answeredQrItem}\n nullableQrItem={nullableQrItem}\n numOfRepeatGroups={repeatGroups.length}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={parentIsReadOnly}\n onDeleteItem={() => onDeleteItem(index)}\n onQrItemChange={(newQrItem) => onAnswerChange(newQrItem, index)}\n />\n </Collapse>\n );\n })}\n </TransitionGroup>\n\n <AddItemButton repeatGroups={repeatGroups} readOnly={readOnly} onAddItem={onAddItem} />\n </AccordionDetails>\n </GroupAccordion>\n );\n }\n\n return (\n <QGroupContainerBox\n key={qItem.linkId}\n cardElevation={groupCardElevation}\n isRepeated={true}\n style={parentStyles || undefined}>\n <Card elevation={groupCardElevation} sx={{ p: 3, py: 2.5, mb: 3.5 }}>\n {qItem.text ? (\n <>\n <GroupHeading\n qItem={qItem}\n readOnly={readOnly}\n groupCardElevation={groupCardElevation}\n />\n <Divider sx={{ mt: 1, mb: 1.5, opacity: 0.6 }} />\n </>\n ) : null}\n <TransitionGroup>\n {repeatGroups.map(({ id, qrItem: nullableQrItem }, index) => {\n const answeredQrItem = createEmptyQrItem(qItem, undefined);\n if (nullableQrItem) {\n answeredQrItem.item = nullableQrItem.item;\n }\n\n return (\n <Collapse key={id} timeout={200}>\n <RepeatGroupItem\n qItem={qItem}\n repeatGroupIndex={index}\n answeredQrItem={answeredQrItem}\n nullableQrItem={nullableQrItem}\n numOfRepeatGroups={repeatGroups.length}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={parentIsReadOnly}\n onDeleteItem={() => onDeleteItem(index)}\n onQrItemChange={(newQrItem) => onAnswerChange(newQrItem, index)}\n />\n </Collapse>\n );\n })}\n </TransitionGroup>\n\n <AddItemButton repeatGroups={repeatGroups} readOnly={readOnly} onAddItem={onAddItem} />\n </Card>\n </QGroupContainerBox>\n );\n}\n\nexport default RepeatGroupView;\n","function _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\nexport { _extends as default };","function _objectWithoutPropertiesLoose(r, e) {\n if (null == r) return {};\n var t = {};\n for (var n in r) if ({}.hasOwnProperty.call(r, n)) {\n if (-1 !== e.indexOf(n)) continue;\n t[n] = r[n];\n }\n return t;\n}\nexport { _objectWithoutPropertiesLoose as default };","function _setPrototypeOf(t, e) {\n return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {\n return t.__proto__ = e, t;\n }, _setPrototypeOf(t, e);\n}\nexport { _setPrototypeOf as default };","import setPrototypeOf from \"./setPrototypeOf.js\";\nfunction _inheritsLoose(t, o) {\n t.prototype = Object.create(o.prototype), t.prototype.constructor = t, setPrototypeOf(t, o);\n}\nexport { _inheritsLoose as default };","import React from 'react';\nexport default React.createContext(null);","function _assertThisInitialized(e) {\n if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n return e;\n}\nexport { _assertThisInitialized as default };","import _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport TransitionGroupContext from './TransitionGroupContext';\nimport { getChildMapping, getInitialChildMapping, getNextChildMapping } from './utils/ChildMapping';\n\nvar values = Object.values || function (obj) {\n return Object.keys(obj).map(function (k) {\n return obj[k];\n });\n};\n\nvar defaultProps = {\n component: 'div',\n childFactory: function childFactory(child) {\n return child;\n }\n};\n/**\n * The `<TransitionGroup>` component manages a set of transition components\n * (`<Transition>` and `<CSSTransition>`) in a list. Like with the transition\n * components, `<TransitionGroup>` is a state machine for managing the mounting\n * and unmounting of components over time.\n *\n * Consider the example below. As items are removed or added to the TodoList the\n * `in` prop is toggled automatically by the `<TransitionGroup>`.\n *\n * Note that `<TransitionGroup>` does not define any animation behavior!\n * Exactly _how_ a list item animates is up to the individual transition\n * component. This means you can mix and match animations across different list\n * items.\n */\n\nvar TransitionGroup = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(TransitionGroup, _React$Component);\n\n function TransitionGroup(props, context) {\n var _this;\n\n _this = _React$Component.call(this, props, context) || this;\n\n var handleExited = _this.handleExited.bind(_assertThisInitialized(_this)); // Initial children should all be entering, dependent on appear\n\n\n _this.state = {\n contextValue: {\n isMounting: true\n },\n handleExited: handleExited,\n firstRender: true\n };\n return _this;\n }\n\n var _proto = TransitionGroup.prototype;\n\n _proto.componentDidMount = function componentDidMount() {\n this.mounted = true;\n this.setState({\n contextValue: {\n isMounting: false\n }\n });\n };\n\n _proto.componentWillUnmount = function componentWillUnmount() {\n this.mounted = false;\n };\n\n TransitionGroup.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, _ref) {\n var prevChildMapping = _ref.children,\n handleExited = _ref.handleExited,\n firstRender = _ref.firstRender;\n return {\n children: firstRender ? getInitialChildMapping(nextProps, handleExited) : getNextChildMapping(nextProps, prevChildMapping, handleExited),\n firstRender: false\n };\n } // node is `undefined` when user provided `nodeRef` prop\n ;\n\n _proto.handleExited = function handleExited(child, node) {\n var currentChildMapping = getChildMapping(this.props.children);\n if (child.key in currentChildMapping) return;\n\n if (child.props.onExited) {\n child.props.onExited(node);\n }\n\n if (this.mounted) {\n this.setState(function (state) {\n var children = _extends({}, state.children);\n\n delete children[child.key];\n return {\n children: children\n };\n });\n }\n };\n\n _proto.render = function render() {\n var _this$props = this.props,\n Component = _this$props.component,\n childFactory = _this$props.childFactory,\n props = _objectWithoutPropertiesLoose(_this$props, [\"component\", \"childFactory\"]);\n\n var contextValue = this.state.contextValue;\n var children = values(this.state.children).map(childFactory);\n delete props.appear;\n delete props.enter;\n delete props.exit;\n\n if (Component === null) {\n return /*#__PURE__*/React.createElement(TransitionGroupContext.Provider, {\n value: contextValue\n }, children);\n }\n\n return /*#__PURE__*/React.createElement(TransitionGroupContext.Provider, {\n value: contextValue\n }, /*#__PURE__*/React.createElement(Component, props, children));\n };\n\n return TransitionGroup;\n}(React.Component);\n\nTransitionGroup.propTypes = process.env.NODE_ENV !== \"production\" ? {\n /**\n * `<TransitionGroup>` renders a `<div>` by default. You can change this\n * behavior by providing a `component` prop.\n * If you use React v16+ and would like to avoid a wrapping `<div>` element\n * you can pass in `component={null}`. This is useful if the wrapping div\n * borks your css styles.\n */\n component: PropTypes.any,\n\n /**\n * A set of `<Transition>` components, that are toggled `in` and out as they\n * leave. the `<TransitionGroup>` will inject specific transition props, so\n * remember to spread them through if you are wrapping the `<Transition>` as\n * with our `<Fade>` example.\n *\n * While this component is meant for multiple `Transition` or `CSSTransition`\n * children, sometimes you may want to have a single transition child with\n * content that you want to be transitioned out and in when you change it\n * (e.g. routes, images etc.) In that case you can change the `key` prop of\n * the transition child as you change its content, this will cause\n * `TransitionGroup` to transition the child out and back in.\n */\n children: PropTypes.node,\n\n /**\n * A convenience prop that enables or disables appear animations\n * for all children. Note that specifying this will override any defaults set\n * on individual children Transitions.\n */\n appear: PropTypes.bool,\n\n /**\n * A convenience prop that enables or disables enter animations\n * for all children. Note that specifying this will override any defaults set\n * on individual children Transitions.\n */\n enter: PropTypes.bool,\n\n /**\n * A convenience prop that enables or disables exit animations\n * for all children. Note that specifying this will override any defaults set\n * on individual children Transitions.\n */\n exit: PropTypes.bool,\n\n /**\n * You may need to apply reactive updates to a child as it is exiting.\n * This is generally done by using `cloneElement` however in the case of an exiting\n * child the element has already been removed and not accessible to the consumer.\n *\n * If you do need to update a child as it leaves you can provide a `childFactory`\n * to wrap every child, even the ones that are leaving.\n *\n * @type Function(child: ReactElement) -> ReactElement\n */\n childFactory: PropTypes.func\n} : {};\nTransitionGroup.defaultProps = defaultProps;\nexport default TransitionGroup;","import { Children, cloneElement, isValidElement } from 'react';\n/**\n * Given `this.props.children`, return an object mapping key to child.\n *\n * @param {*} children `this.props.children`\n * @return {object} Mapping of key to child\n */\n\nexport function getChildMapping(children, mapFn) {\n var mapper = function mapper(child) {\n return mapFn && isValidElement(child) ? mapFn(child) : child;\n };\n\n var result = Object.create(null);\n if (children) Children.map(children, function (c) {\n return c;\n }).forEach(function (child) {\n // run the map function here instead so that the key is the computed one\n result[child.key] = mapper(child);\n });\n return result;\n}\n/**\n * When you're adding or removing children some may be added or removed in the\n * same render pass. We want to show *both* since we want to simultaneously\n * animate elements in and out. This function takes a previous set of keys\n * and a new set of keys and merges them with its best guess of the correct\n * ordering. In the future we may expose some of the utilities in\n * ReactMultiChild to make this easy, but for now React itself does not\n * directly have this concept of the union of prevChildren and nextChildren\n * so we implement it here.\n *\n * @param {object} prev prev children as returned from\n * `ReactTransitionChildMapping.getChildMapping()`.\n * @param {object} next next children as returned from\n * `ReactTransitionChildMapping.getChildMapping()`.\n * @return {object} a key set that contains all keys in `prev` and all keys\n * in `next` in a reasonable order.\n */\n\nexport function mergeChildMappings(prev, next) {\n prev = prev || {};\n next = next || {};\n\n function getValueForKey(key) {\n return key in next ? next[key] : prev[key];\n } // For each key of `next`, the list of keys to insert before that key in\n // the combined list\n\n\n var nextKeysPending = Object.create(null);\n var pendingKeys = [];\n\n for (var prevKey in prev) {\n if (prevKey in next) {\n if (pendingKeys.length) {\n nextKeysPending[prevKey] = pendingKeys;\n pendingKeys = [];\n }\n } else {\n pendingKeys.push(prevKey);\n }\n }\n\n var i;\n var childMapping = {};\n\n for (var nextKey in next) {\n if (nextKeysPending[nextKey]) {\n for (i = 0; i < nextKeysPending[nextKey].length; i++) {\n var pendingNextKey = nextKeysPending[nextKey][i];\n childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);\n }\n }\n\n childMapping[nextKey] = getValueForKey(nextKey);\n } // Finally, add the keys which didn't appear before any key in `next`\n\n\n for (i = 0; i < pendingKeys.length; i++) {\n childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);\n }\n\n return childMapping;\n}\n\nfunction getProp(child, prop, props) {\n return props[prop] != null ? props[prop] : child.props[prop];\n}\n\nexport function getInitialChildMapping(props, onExited) {\n return getChildMapping(props.children, function (child) {\n return cloneElement(child, {\n onExited: onExited.bind(null, child),\n in: true,\n appear: getProp(child, 'appear', props),\n enter: getProp(child, 'enter', props),\n exit: getProp(child, 'exit', props)\n });\n });\n}\nexport function getNextChildMapping(nextProps, prevChildMapping, onExited) {\n var nextChildMapping = getChildMapping(nextProps.children);\n var children = mergeChildMappings(prevChildMapping, nextChildMapping);\n Object.keys(children).forEach(function (key) {\n var child = children[key];\n if (!isValidElement(child)) return;\n var hasPrev = (key in prevChildMapping);\n var hasNext = (key in nextChildMapping);\n var prevChild = prevChildMapping[key];\n var isLeaving = isValidElement(prevChild) && !prevChild.props.in; // item is new (entering)\n\n if (hasNext && (!hasPrev || isLeaving)) {\n // console.log('entering', key)\n children[key] = cloneElement(child, {\n onExited: onExited.bind(null, child),\n in: true,\n exit: getProp(child, 'exit', nextProps),\n enter: getProp(child, 'enter', nextProps)\n });\n } else if (!hasNext && hasPrev && !isLeaving) {\n // item is old (exiting)\n // console.log('leaving', key)\n children[key] = cloneElement(child, {\n in: false\n });\n } else if (hasNext && hasPrev && isValidElement(prevChild)) {\n // item hasn't changed transition states\n // copy over the last transition props;\n // console.log('unchanged', key)\n children[key] = cloneElement(child, {\n onExited: onExited.bind(null, child),\n in: prevChild.props.in,\n exit: getProp(child, 'exit', nextProps),\n enter: getProp(child, 'enter', nextProps)\n });\n }\n });\n return children;\n}","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Stack from '@mui/material/Stack';\nimport { styled } from '@mui/material/styles';\nimport Tooltip from '@mui/material/Tooltip';\n\nexport const RepeatDeleteTooltip = styled(Tooltip)(() => ({\n marginLeft: 8\n}));\n\nexport const RepeatItemContainerStack = styled(Stack)(() => ({\n alignItems: 'center',\n paddingBottom: 8\n}));\n\nexport const RepeatGroupContainerStack = styled(Stack)(() => ({\n alignItems: 'center',\n paddingBottom: 16\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { RepeatGroupContainerStack } from '../RepeatItem/RepeatItem.styles';\nimport Box from '@mui/material/Box';\nimport GroupItem from '../GroupItem/GroupItem';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport DeleteItemButton from './DeleteItemButton';\nimport useReadOnly from '../../../hooks/useReadOnly';\n\ninterface RepeatGroupItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute {\n qItem: QuestionnaireItem;\n repeatGroupIndex: number;\n answeredQrItem: QuestionnaireResponseItem;\n nullableQrItem: QuestionnaireResponseItem | null;\n numOfRepeatGroups: number;\n groupCardElevation: number;\n onDeleteItem: () => void;\n}\n\nfunction RepeatGroupItem(props: RepeatGroupItemProps) {\n const {\n qItem,\n repeatGroupIndex,\n answeredQrItem,\n nullableQrItem,\n numOfRepeatGroups,\n groupCardElevation,\n showMinimalView,\n parentIsReadOnly,\n onDeleteItem,\n onQrItemChange\n } = props;\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly, repeatGroupIndex);\n\n return (\n <RepeatGroupContainerStack direction=\"row\" justifyContent=\"end\">\n <Box sx={{ flexGrow: 1 }}>\n <GroupItem\n qItem={qItem}\n qrItem={answeredQrItem}\n isRepeated={true}\n parentIsRepeatGroup={true}\n parentRepeatGroupIndex={repeatGroupIndex}\n parentIsReadOnly={parentIsReadOnly}\n groupCardElevation={groupCardElevation}\n onQrItemChange={onQrItemChange}\n />\n </Box>\n {showMinimalView ? null : (\n <DeleteItemButton\n nullableQrItem={nullableQrItem}\n numOfRepeatGroups={numOfRepeatGroups}\n readOnly={readOnly}\n onDeleteItem={onDeleteItem}\n />\n )}\n </RepeatGroupContainerStack>\n );\n}\n\nexport default RepeatGroupItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { RepeatDeleteTooltip } from '../RepeatItem/RepeatItem.styles';\nimport IconButton from '@mui/material/IconButton';\nimport RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline';\nimport type { QuestionnaireResponseItem } from 'fhir/r4';\n\ninterface DeleteItemButtonProps {\n nullableQrItem: QuestionnaireResponseItem | null;\n numOfRepeatGroups: number;\n readOnly: boolean;\n onDeleteItem: () => void;\n}\n\nfunction DeleteItemButton(props: DeleteItemButtonProps) {\n const { nullableQrItem, numOfRepeatGroups, readOnly, onDeleteItem } = props;\n\n const isDisabled = nullableQrItem === null || numOfRepeatGroups === 1 || readOnly;\n\n return (\n <RepeatDeleteTooltip className=\"repeat-group-delete\" title=\"Remove item\">\n <span>\n <IconButton size=\"small\" color=\"error\" disabled={isDisabled} onClick={onDeleteItem}>\n <RemoveCircleOutlineIcon />\n </IconButton>\n </span>\n </RepeatDeleteTooltip>\n );\n}\n\nexport default DeleteItemButton;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport AddIcon from '@mui/icons-material/Add';\nimport type { RepeatGroupSingleModel } from '../../../interfaces/repeatGroup.interface';\n\ninterface AddItemButtonProps {\n repeatGroups: RepeatGroupSingleModel[];\n readOnly: boolean;\n onAddItem: () => void;\n}\n\nfunction AddItemButton(props: AddItemButtonProps) {\n const { repeatGroups, readOnly, onAddItem } = props;\n\n const isDisabled = repeatGroups[repeatGroups.length - 1]?.qrItem === null || readOnly;\n\n return (\n <Box display=\"flex\" flexDirection=\"row-reverse\">\n <Button\n variant=\"contained\"\n size=\"small\"\n startIcon={<AddIcon />}\n disabled={isDisabled}\n onClick={onAddItem}\n data-test=\"button-add-repeat-item\">\n Add Item\n </Button>\n </Box>\n );\n}\n\nexport default AddItemButton;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport AddIcon from '@mui/icons-material/Add';\nimport type { QuestionnaireResponseItemAnswer } from 'fhir/r4';\n\ninterface AddItemButtonProps {\n repeatAnswers: (QuestionnaireResponseItemAnswer | null)[];\n readOnly: boolean;\n onAddItem: () => void;\n}\n\nfunction AddItemButton(props: AddItemButtonProps) {\n const { repeatAnswers, readOnly, onAddItem } = props;\n\n // Check if the last answer is null or does not have a value[x]\n // Also disables button if item is readOnly\n const lastAnswer = repeatAnswers[repeatAnswers.length - 1];\n const isDisabled =\n lastAnswer === null || Object.keys(lastAnswer ?? {}).join() === 'id' || readOnly;\n\n return (\n <Box display=\"flex\" flexDirection=\"row-reverse\">\n <Button\n variant=\"contained\"\n size=\"small\"\n startIcon={<AddIcon />}\n disabled={isDisabled}\n onClick={onAddItem}\n data-test=\"button-add-repeat-item\">\n Add Item\n </Button>\n </Box>\n );\n}\n\nexport default AddItemButton;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Box from '@mui/material/Box';\nimport { RepeatItemContainerStack } from './RepeatItem.styles';\nimport SingleItem from '../SingleItem/SingleItem';\nimport type {\n QuestionnaireItem,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer\n} from 'fhir/r4';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport RemoveItemButton from './RemoveItemButton';\nimport useReadOnly from '../../../hooks/useReadOnly';\n\ninterface RepeatFieldProps\n extends PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n answer: QuestionnaireResponseItemAnswer | null;\n numOfRepeatAnswers: number;\n groupCardElevation: number;\n onDeleteAnswer: () => void;\n}\n\nfunction RepeatField(props: RepeatFieldProps) {\n const {\n qItem,\n qrItem,\n answer,\n numOfRepeatAnswers,\n groupCardElevation,\n parentIsReadOnly,\n showMinimalView,\n onDeleteAnswer,\n onQrItemChange\n } = props;\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n return (\n <RepeatItemContainerStack direction=\"row\">\n <Box sx={{ flexGrow: 1 }}>\n <SingleItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={qItem.repeats ?? false}\n isTabled={false}\n groupCardElevation={groupCardElevation}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={onQrItemChange}\n />\n </Box>\n {showMinimalView ? null : (\n <RemoveItemButton\n answer={answer}\n numOfRepeatAnswers={numOfRepeatAnswers}\n readOnly={readOnly}\n onDeleteAnswer={onDeleteAnswer}\n />\n )}\n </RepeatItemContainerStack>\n );\n}\n\nexport default RepeatField;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { RepeatDeleteTooltip } from './RepeatItem.styles';\nimport IconButton from '@mui/material/IconButton';\nimport RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline';\nimport type { QuestionnaireResponseItemAnswer } from 'fhir/r4';\n\ninterface RemoveItemButtonProps {\n answer: QuestionnaireResponseItemAnswer | null;\n numOfRepeatAnswers: number;\n readOnly: boolean;\n onDeleteAnswer: () => void;\n}\n\nfunction RemoveItemButton(props: RemoveItemButtonProps) {\n const { answer, numOfRepeatAnswers, readOnly, onDeleteAnswer } = props;\n\n const isDisabled = answer === null || numOfRepeatAnswers === 1 || readOnly;\n\n return (\n <RepeatDeleteTooltip className=\"repeat-item-delete\" title=\"Remove item\">\n <span>\n <IconButton size=\"small\" color=\"error\" disabled={isDisabled} onClick={onDeleteAnswer}>\n <RemoveCircleOutlineIcon fontSize=\"small\" />\n </IconButton>\n </span>\n </RepeatDeleteTooltip>\n );\n}\n\nexport default RemoveItemButton;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { createEmptyQrItem } from '../../../utils/qrItem';\nimport { FullWidthFormComponentBox } from '../../Box.styles';\nimport AddItemButton from './AddItemButton';\nimport { TransitionGroup } from 'react-transition-group';\nimport RepeatField from './RepeatField';\nimport Collapse from '@mui/material/Collapse';\nimport useInitialiseRepeatAnswers from '../../../hooks/useInitialiseRepeatAnswers';\nimport ItemFieldGrid from '../ItemParts/ItemFieldGrid';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport { generateExistingRepeatId, generateNewRepeatId } from '../../../utils/repeatId';\nimport ItemLabel from '../ItemParts/ItemLabel';\n\ninterface RepeatItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n groupCardElevation: number;\n}\n\n/**\n * Main component to render a repeating, non-group Questionnaire item.\n *\n * @author Sean Fong\n */\nfunction RepeatItem(props: RepeatItemProps) {\n const { qItem, qrItem, groupCardElevation, showMinimalView, parentIsReadOnly, onQrItemChange } =\n props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n\n const repeatAnswers = useInitialiseRepeatAnswers(qItem.linkId, qrItem);\n\n // Event Handlers\n function handleAnswerChange(newQrItem: QuestionnaireResponseItem, index: number) {\n const updatedRepeatAnswers = [...repeatAnswers];\n updatedRepeatAnswers[index] = newQrItem.answer ? newQrItem.answer[0] : null;\n\n onQrItemChange({\n ...createEmptyQrItem(qItem, undefined),\n answer: updatedRepeatAnswers.flatMap((repeatAnswer) => (repeatAnswer ? [repeatAnswer] : []))\n });\n }\n\n function handleDeleteItem(index: number) {\n const updatedRepeatAnswers = [...repeatAnswers];\n\n updatedRepeatAnswers.splice(index, 1);\n\n onQrItemChange({\n ...createEmptyQrItem(qItem, undefined),\n answer: updatedRepeatAnswers.flatMap((repeatAnswer) => (repeatAnswer ? [repeatAnswer] : []))\n });\n }\n\n function handleAddItem() {\n const updatedRepeatAnswers = [...repeatAnswers, { id: generateNewRepeatId(qItem.linkId) }];\n\n onQrItemChange({\n ...createEmptyQrItem(qItem, undefined),\n answer: updatedRepeatAnswers.flatMap((repeatAnswer) => (repeatAnswer ? [repeatAnswer] : []))\n });\n }\n\n if (showMinimalView) {\n return (\n <>\n {repeatAnswers.map((answer, index) => {\n const repeatAnswerQrItem = createEmptyQrItem(qItem, answer?.id);\n if (answer) {\n repeatAnswerQrItem.answer = [answer];\n }\n\n return (\n <RepeatField\n key={answer?.id ?? generateExistingRepeatId(qItem.linkId, index)}\n qItem={qItem}\n qrItem={repeatAnswerQrItem}\n answer={answer}\n numOfRepeatAnswers={repeatAnswers.length}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={parentIsReadOnly}\n showMinimalView={showMinimalView}\n onDeleteAnswer={() => handleDeleteItem(index)}\n onQrItemChange={(newQrItem) => handleAnswerChange(newQrItem, index)}\n />\n );\n })}\n </>\n );\n }\n\n return (\n <FullWidthFormComponentBox\n data-test=\"q-item-repeat-box\"\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}>\n <ItemFieldGrid\n qItem={qItem}\n readOnly={readOnly}\n labelChildren={<ItemLabel qItem={qItem} readOnly={readOnly} />}\n fieldChildren={\n <TransitionGroup>\n {repeatAnswers.map((answer, index) => {\n const repeatAnswerQrItem = createEmptyQrItem(qItem, answer?.id);\n if (answer) {\n repeatAnswerQrItem.answer = [answer];\n }\n\n return (\n <Collapse\n key={answer?.id ?? generateExistingRepeatId(qItem.linkId, index)}\n timeout={200}>\n <RepeatField\n qItem={qItem}\n qrItem={repeatAnswerQrItem}\n answer={answer}\n numOfRepeatAnswers={repeatAnswers.length}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={parentIsReadOnly}\n showMinimalView={showMinimalView}\n onDeleteAnswer={() => handleDeleteItem(index)}\n onQrItemChange={(newQrItem) => handleAnswerChange(newQrItem, index)}\n />\n </Collapse>\n );\n })}\n </TransitionGroup>\n }\n />\n\n <AddItemButton repeatAnswers={repeatAnswers} readOnly={readOnly} onAddItem={handleAddItem} />\n </FullWidthFormComponentBox>\n );\n}\n\nexport default RepeatItem;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { QuestionnaireResponseItem, QuestionnaireResponseItemAnswer } from 'fhir/r4';\nimport { useMemo } from 'react';\nimport { generateExistingRepeatId, generateNewRepeatId } from '../utils/repeatId';\n\nfunction useInitialiseRepeatAnswers(\n linkId: string,\n qrItem: QuestionnaireResponseItem | null\n): (QuestionnaireResponseItemAnswer | null)[] {\n return useMemo(() => {\n if (!qrItem?.answer) {\n return [{ id: generateNewRepeatId(linkId) }];\n }\n\n return qrItem.answer.map((answer, index) => ({\n ...answer,\n id: answer.id ?? generateExistingRepeatId(linkId, index)\n }));\n }, [linkId, qrItem]);\n}\n\nexport default useInitialiseRepeatAnswers;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\nimport { createEmptyQrGroup, updateQrItemsInGroup } from '../../../utils/qrItem';\nimport useHidden from '../../../hooks/useHidden';\nimport { QGroupContainerBox } from '../../Box.styles';\nimport Divider from '@mui/material/Divider';\nimport Paper from '@mui/material/Paper';\nimport TableContainer from '@mui/material/TableContainer';\nimport { mapQItemsIndex } from '../../../utils/mapItem';\nimport GridTable from './GridTable';\nimport useReadOnly from '../../../hooks/useReadOnly';\nimport { useQuestionnaireStore } from '../../../stores';\nimport GroupHeading from '../GroupItem/GroupHeading';\n\ninterface GridGroupProps\n extends PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n groupCardElevation: number;\n parentStyles?: Record<string, string>;\n}\n\n/**\n * Main component to render a Group Grid (grid) Questionnaire item.\n * @see {@link https://hl7.org/fhir/extensions/CodeSystem-questionnaire-item-control.html}\n *\n * @author Sean Fong\n */\nfunction GridGroup(props: GridGroupProps) {\n const {\n qItem,\n qrItem,\n groupCardElevation,\n showMinimalView,\n parentIsReadOnly,\n onQrItemChange,\n parentStyles\n } = props;\n\n const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();\n\n const qRowItems = qItem.item;\n const qrGroup = qrItem && qrItem.item ? qrItem : createEmptyQrGroup(qItem);\n const qrRowItems = qrGroup.item;\n\n const qItemsIndexMap = useMemo(() => mapQItemsIndex(qItem), [qItem]);\n\n const columnLabels: string[] = useMemo(\n () => qRowItems?.[0].item?.map((firstItem) => firstItem.text ?? ' ') ?? [],\n [qRowItems]\n );\n\n const readOnly = useReadOnly(qItem, parentIsReadOnly);\n const itemIsHidden = useHidden(qItem);\n if (itemIsHidden) {\n return null;\n }\n\n if (!qRowItems || !qrRowItems) {\n return <>Unable to load group, something has gone terribly wrong.</>;\n }\n\n // Check if there are row within the grid\n if (qRowItems.length === 0) {\n return null;\n }\n\n // Event Handlers\n function handleRowChange(newQrItem: QuestionnaireResponseItem) {\n const updatedQrGroup: QuestionnaireResponseItem = { ...qrGroup };\n updateQrItemsInGroup(newQrItem, null, updatedQrGroup, qItemsIndexMap);\n onQrItemChange(updatedQrGroup);\n }\n\n if (showMinimalView) {\n return (\n <QGroupContainerBox\n cardElevation={groupCardElevation}\n isRepeated={false}\n py={1}\n style={parentStyles || undefined}>\n <TableContainer component={Paper} elevation={groupCardElevation}>\n <GridTable\n qItems={qRowItems}\n qrItems={qrRowItems}\n qItemsIndexMap={qItemsIndexMap}\n columnLabels={columnLabels}\n showMinimalView={showMinimalView}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={handleRowChange}\n />\n </TableContainer>\n </QGroupContainerBox>\n );\n }\n\n return (\n <QGroupContainerBox\n cardElevation={groupCardElevation}\n isRepeated={false}\n py={3}\n data-linkid={qItem.linkId}\n onClick={() => onFocusLinkId(qItem.linkId)}\n style={parentStyles || undefined}>\n {qItem.text ? (\n <>\n <GroupHeading qItem={qItem} readOnly={readOnly} groupCardElevation={groupCardElevation} />\n <Divider sx={{ my: 1, opacity: 0.6 }} />\n </>\n ) : null}\n\n <TableContainer component={Paper} elevation={groupCardElevation}>\n <GridTable\n qItems={qRowItems}\n qrItems={qrRowItems}\n qItemsIndexMap={qItemsIndexMap}\n columnLabels={columnLabels}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={handleRowChange}\n />\n </TableContainer>\n </QGroupContainerBox>\n );\n}\n\nexport default GridGroup;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Table from '@mui/material/Table';\nimport TableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableHead from '@mui/material/TableHead';\nimport TableRow from '@mui/material/TableRow';\nimport { HeaderTableCell } from '../Tables/Table.styles';\nimport GridRow from './GridRow';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { getQrItemsIndex } from '../../../utils/mapItem';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute\n} from '../../../interfaces/renderProps.interface';\n\ninterface GridTableProps\n extends PropsWithQrItemChangeHandler,\n PropsWithShowMinimalViewAttribute,\n PropsWithParentIsReadOnlyAttribute {\n qItems: QuestionnaireItem[];\n qrItems: QuestionnaireResponseItem[];\n qItemsIndexMap: Record<string, number>;\n columnLabels: string[];\n}\n\nfunction GridTable(props: GridTableProps) {\n const {\n qItems,\n qrItems,\n qItemsIndexMap,\n columnLabels,\n showMinimalView,\n parentIsReadOnly,\n onQrItemChange\n } = props;\n\n const qrItemsByIndex = getQrItemsIndex(qItems, qrItems, qItemsIndexMap);\n\n const numOfColumns = columnLabels.length;\n\n const minimalViewHeaderCellSx = showMinimalView ? { py: 2 } : null;\n\n return (\n <Table size={showMinimalView ? 'small' : 'medium'}>\n <TableHead>\n <TableRow>\n <HeaderTableCell />\n {columnLabels.map((label) => (\n <HeaderTableCell key={label} size=\"medium\" sx={{ ...minimalViewHeaderCellSx }}>\n {label}\n </HeaderTableCell>\n ))}\n <TableCell />\n </TableRow>\n </TableHead>\n <TableBody>\n {qItems.map((qItem, index) => {\n const qrItem = qrItemsByIndex[index];\n\n if (Array.isArray(qrItem)) {\n return null;\n }\n\n // In minimal view, don't display items with no answers\n if (showMinimalView && !qrItem) {\n return null;\n }\n\n return (\n <TableRow key={qItem.linkId}>\n <GridRow\n qItem={qItem}\n qrItem={qrItem ?? null}\n columnLabels={columnLabels}\n numOfColumns={numOfColumns}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={onQrItemChange}\n />\n </TableRow>\n );\n })}\n </TableBody>\n </Table>\n );\n}\n\nexport default GridTable;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler\n} from '../../../interfaces/renderProps.interface';\nimport { createEmptyQrGroup, updateQrItemsInGroup } from '../../../utils/qrItem';\nimport { GridAnswerTableCell, GridTextTableCell } from '../Tables/Table.styles';\nimport SingleItem from '../SingleItem/SingleItem';\nimport { getQrItemsIndex, mapQItemsIndex } from '../../../utils/mapItem';\nimport Typography from '@mui/material/Typography';\nimport useHidden from '../../../hooks/useHidden';\n\ninterface GridRowProps extends PropsWithQrItemChangeHandler, PropsWithParentIsReadOnlyAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n columnLabels: string[];\n numOfColumns: number;\n}\n\nfunction GridRow(props: GridRowProps) {\n const { qItem, qrItem, columnLabels, numOfColumns, parentIsReadOnly, onQrItemChange } = props;\n\n const rowQItems = qItem.item;\n const row = qrItem && qrItem.item ? qrItem : createEmptyQrGroup(qItem);\n const rowQrItems = row.item;\n\n const qItemsIndexMap = useMemo(() => mapQItemsIndex(qItem), [qItem]);\n\n const itemIsHidden = useHidden(qItem);\n if (itemIsHidden) {\n return null;\n }\n\n if (!rowQItems || !rowQrItems) {\n return null;\n }\n\n function handleQrRowItemChange(newQrRowItem: QuestionnaireResponseItem) {\n const qrRow: QuestionnaireResponseItem = { ...row };\n updateQrItemsInGroup(newQrRowItem, null, qrRow, qItemsIndexMap);\n onQrItemChange(qrRow);\n }\n\n const qrItemsByIndex = getQrItemsIndex(rowQItems, rowQrItems, qItemsIndexMap);\n\n return (\n <>\n <GridTextTableCell>\n <Typography fontWeight=\"bold\">{qItem.text}</Typography>\n </GridTextTableCell>\n {rowQItems.map((cellQItem, index) => {\n const cellQrItem = qrItemsByIndex[index];\n\n // Don't render cell if column label does not match - \"sparse-ness\" of grid\n if (columnLabels[index] !== cellQItem.text) {\n return null;\n }\n\n if (Array.isArray(cellQrItem)) {\n return null;\n }\n\n return (\n <GridAnswerTableCell key={index} numOfColumns={numOfColumns}>\n <SingleItem\n qItem={cellQItem}\n qrItem={cellQrItem ?? null}\n isRepeated={true}\n isTabled={true}\n groupCardElevation={1}\n showMinimalView={true}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={handleQrRowItemChange}\n />\n </GridAnswerTableCell>\n );\n })}\n </>\n );\n}\n\nexport default GridRow;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithQrRepeatGroupChangeHandler\n} from '../../../interfaces/renderProps.interface';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { isRepeatItemAndNotCheckbox, isSpecificItemControl } from '../../../utils';\nimport GroupTable from '../Tables/GroupTable';\nimport RepeatGroup from '../RepeatGroup/RepeatGroup';\nimport RepeatItem from '../RepeatItem/RepeatItem';\nimport SingleItem from '../SingleItem/SingleItem';\nimport useHidden from '../../../hooks/useHidden';\nimport GroupItem from './GroupItem';\nimport GridGroup from '../GridGroup/GridGroup';\nimport { useQuestionnaireStore } from '../../../stores';\n\ninterface GroupItemSwitcherProps\n extends PropsWithQrItemChangeHandler,\n PropsWithQrRepeatGroupChangeHandler,\n PropsWithParentIsReadOnlyAttribute,\n PropsWithParentIsRepeatGroupAttribute {\n qItem: QuestionnaireItem;\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | undefined;\n groupCardElevation: number;\n parentStyles?: Record<string, string>;\n}\n\nfunction GroupItemSwitcher(props: GroupItemSwitcherProps) {\n const {\n qItem,\n qrItemOrItems,\n groupCardElevation,\n parentIsReadOnly,\n parentIsRepeatGroup,\n parentRepeatGroupIndex,\n onQrItemChange,\n onQrRepeatGroupChange,\n parentStyles\n } = props;\n\n const qItemOverrideComponents = useQuestionnaireStore.use.qItemOverrideComponents();\n const QItemOverrideComponent = qItemOverrideComponents[qItem.linkId];\n\n const itemIsHidden = useHidden(qItem, parentRepeatGroupIndex);\n if (itemIsHidden) {\n return null;\n }\n\n // If a qItem (type=group) override component is defined for this item, render it\n // Don't get too strict with the \"typeof\" checks for now\n if (\n qItem.type === 'group' &&\n QItemOverrideComponent &&\n typeof QItemOverrideComponent === 'function'\n ) {\n return (\n <QItemOverrideComponent\n qItem={qItem}\n qrItem={qrItemOrItems ?? null}\n isRepeated={!!qItem.repeats}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={parentIsReadOnly}\n parentIsRepeatGroup={parentIsRepeatGroup}\n parentRepeatGroupIndex={parentRepeatGroupIndex}\n onQrItemChange={onQrItemChange}\n onQrRepeatGroupChange={onQrRepeatGroupChange}\n parentStyles={parentStyles}\n />\n );\n }\n\n // If there are multiple answers\n const hasMultipleAnswers = Array.isArray(qrItemOrItems);\n if (hasMultipleAnswers) {\n const qrItems = qrItemOrItems;\n\n // qItem should always be either a repeatGroup or a groupTable item\n // groupTables item have qItem.repeats = true and qItem.type = 'group' as well\n if (!qItem.repeats || qItem.type !== 'group') {\n return <>Something went wrong here</>;\n }\n\n if (isSpecificItemControl(qItem, 'gtable')) {\n return (\n <GroupTable\n qItem={qItem}\n qrItems={qrItems}\n groupCardElevation={groupCardElevation}\n isRepeated={true}\n parentIsReadOnly={parentIsReadOnly}\n onQrRepeatGroupChange={onQrRepeatGroupChange}\n parentStyles={parentStyles}\n />\n );\n }\n\n return (\n <RepeatGroup\n qItem={qItem}\n qrItems={qrItems}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={parentIsReadOnly}\n onQrRepeatGroupChange={onQrRepeatGroupChange}\n parentStyles={parentStyles}\n />\n );\n }\n\n // If there is only one answer\n const qrItem = qrItemOrItems;\n const itemIsGrid = isSpecificItemControl(qItem, 'grid');\n if (itemIsGrid) {\n return (\n <GridGroup\n qItem={qItem}\n qrItem={qrItem ?? null}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n }\n\n const itemRepeatsAndIsNotCheckbox = isRepeatItemAndNotCheckbox(qItem);\n if (itemRepeatsAndIsNotCheckbox) {\n if (qItem.type === 'group') {\n // If qItem is RepeatGroup or a groupTable item in this decision branch,\n // their qrItem array should always be empty\n if (isSpecificItemControl(qItem, 'gtable')) {\n return (\n <GroupTable\n qItem={qItem}\n qrItems={[]}\n groupCardElevation={groupCardElevation}\n isRepeated={true}\n parentIsReadOnly={parentIsReadOnly}\n onQrRepeatGroupChange={onQrRepeatGroupChange}\n parentStyles={parentStyles}\n />\n );\n }\n\n return (\n <RepeatGroup\n qItem={qItem}\n qrItems={[]}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={parentIsReadOnly}\n onQrRepeatGroupChange={onQrRepeatGroupChange}\n parentStyles={parentStyles}\n />\n );\n }\n\n return (\n <RepeatItem\n qItem={qItem}\n qrItem={qrItem ?? null}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n\n // if qItem is not a repeating question or is a checkbox\n if (qItem.type === 'group') {\n // GroupTable \"gtable\" can be rendered with either repeats:true or false\n if (isSpecificItemControl(qItem, 'gtable')) {\n return (\n <GroupTable\n qItem={qItem}\n qrItems={qrItem ? [qrItem] : []}\n groupCardElevation={groupCardElevation}\n isRepeated={false}\n parentIsReadOnly={parentIsReadOnly}\n onQrRepeatGroupChange={onQrRepeatGroupChange}\n parentStyles={parentStyles}\n />\n );\n }\n\n return (\n <GroupItem\n qItem={qItem}\n qrItem={qrItem ?? null}\n isRepeated={false}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={parentIsReadOnly}\n parentIsRepeatGroup={parentIsRepeatGroup}\n parentRepeatGroupIndex={parentRepeatGroupIndex}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n }\n\n // Defaults to a single, non-group item\n return (\n <SingleItem\n qItem={qItem}\n qrItem={qrItem ?? null}\n isRepeated={false}\n isTabled={false}\n groupCardElevation={groupCardElevation}\n parentIsReadOnly={parentIsReadOnly}\n parentIsRepeatGroup={parentIsRepeatGroup}\n parentRepeatGroupIndex={parentRepeatGroupIndex}\n onQrItemChange={onQrItemChange}\n parentStyles={parentStyles}\n />\n );\n}\n\nexport default GroupItemSwitcher;\n","import React, { memo } from 'react';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport type { Pages } from '../../../interfaces/page.interface';\nimport { useQuestionnaireStore } from '../../../stores';\nimport NextPageButton from './NextPageButton';\nimport PreviousPageButton from './PreviousPageButton';\nimport useNextAndPreviousVisiblePages from '../../../hooks/useNextAndPreviousVisiblePages';\nimport { useRendererStylingStore } from '../../../stores/rendererStylingStore';\n\ninterface PageButtonsWrapperProps {\n currentPageIndex?: number;\n pages?: Pages;\n}\n\nconst PageButtonsWrapper = memo(function PageButtonsWrapper(props: PageButtonsWrapperProps) {\n const { currentPageIndex, pages } = props;\n\n const switchPage = useQuestionnaireStore.use.switchPage();\n const disablePageButtons = useRendererStylingStore.use.disablePageButtons();\n\n const { previousPageIndex, nextPageIndex, numOfVisiblePages } = useNextAndPreviousVisiblePages(\n currentPageIndex,\n pages\n );\n\n const pagesNotDefined = currentPageIndex === undefined || pages === undefined;\n\n // Event handlers\n function handlePreviousPageButtonClick() {\n if (previousPageIndex === null) {\n return;\n }\n\n switchPage(previousPageIndex);\n\n // Scroll to top of page\n window.scrollTo(0, 0);\n }\n\n function handleNextPageButtonClick() {\n if (nextPageIndex === null) {\n return;\n }\n\n switchPage(nextPageIndex);\n\n // Scroll to top of page\n window.scrollTo(0, 0);\n }\n\n // No pages defined, do not render page buttons\n if (pagesNotDefined) {\n return null;\n }\n\n // Disable page buttons - currently only available via disablePageButtons API\n if (disablePageButtons) {\n return null;\n }\n\n const previousPageButtonHidden = previousPageIndex === null;\n const nextPageButtonHidden = nextPageIndex === null;\n\n // This is more of a fallback check to prevent the user from navigating to an invisble page if buttons are visble for some reason\n const pageButtonsDisabled = numOfVisiblePages <= 1;\n\n return (\n <Box display=\"flex\" mt={3} gap={2} alignItems=\"center\">\n <Box flexGrow={1} />\n <Typography color=\"text.secondary\">\n Page {`${currentPageIndex + 1} / ${numOfVisiblePages}`}\n </Typography>\n <PreviousPageButton\n isDisabled={pageButtonsDisabled || previousPageButtonHidden}\n onPreviousPageClick={handlePreviousPageButtonClick}\n />\n <NextPageButton\n isDisabled={pageButtonsDisabled || nextPageButtonHidden}\n onNextPageClick={handleNextPageButtonClick}\n />\n </Box>\n );\n});\n\nexport default PageButtonsWrapper;\n","import { styled } from '@mui/material/styles';\nimport Fab from '@mui/material/Fab';\n\nexport const SecondaryFab = styled(Fab)(({ theme }) => ({\n color: '#fff',\n background: theme.palette.secondary.main,\n '&:hover': {\n background: theme.palette.secondary.dark\n }\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Iconify from '../../Iconify/Iconify';\nimport { SecondaryFab } from '../Button.styles';\n\ninterface NextPageButtonProps {\n isDisabled: boolean;\n onNextPageClick: () => void;\n}\n\nfunction NextPageButton(props: NextPageButtonProps) {\n const { isDisabled, onNextPageClick } = props;\n\n return (\n <SecondaryFab size=\"small\" aria-label=\"next\" disabled={isDisabled} onClick={onNextPageClick}>\n <Iconify icon=\"material-symbols:chevron-right-rounded\" />\n </SecondaryFab>\n );\n}\n\nexport default NextPageButton;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Iconify from '../../Iconify/Iconify';\nimport { SecondaryFab } from '../Button.styles';\n\ninterface PreviousPageButtonProps {\n isDisabled: boolean;\n onPreviousPageClick: () => void;\n}\n\nfunction PreviousPageButton(props: PreviousPageButtonProps) {\n const { isDisabled, onPreviousPageClick } = props;\n\n return (\n <SecondaryFab\n size=\"small\"\n aria-label=\"back\"\n disabled={isDisabled}\n onClick={onPreviousPageClick}>\n <Iconify icon=\"material-symbols:chevron-left-rounded\" />\n </SecondaryFab>\n );\n}\n\nexport default PreviousPageButton;\n","import { useQuestionnaireStore } from '../stores';\nimport type { Pages } from '../interfaces/page.interface';\nimport { constructPagesWithVisibility } from '../utils/page';\n\nfunction useNextAndPreviousVisiblePages(\n currentPageIndex?: number,\n pages?: Pages\n): { previousPageIndex: number | null; nextPageIndex: number | null; numOfVisiblePages: number } {\n const enableWhenIsActivated = useQuestionnaireStore.use.enableWhenIsActivated();\n const enableWhenItems = useQuestionnaireStore.use.enableWhenItems();\n const enableWhenExpressions = useQuestionnaireStore.use.enableWhenExpressions();\n\n const pagesNotDefined = currentPageIndex === undefined || pages === undefined;\n\n if (pagesNotDefined) {\n return { previousPageIndex: null, nextPageIndex: null, numOfVisiblePages: 0 };\n }\n\n const pagesWithVisibility = constructPagesWithVisibility({\n pages,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions\n });\n\n return {\n previousPageIndex: getPreviousPageIndex(currentPageIndex, pagesWithVisibility),\n nextPageIndex: getNextPageIndex(currentPageIndex, pagesWithVisibility),\n numOfVisiblePages: pagesWithVisibility.filter((tab) => tab.isVisible).length\n };\n}\n\nfunction getPreviousPageIndex(\n currentPageIndex: number,\n pagesWithVisibility: { linkId: string; isVisible: boolean }[]\n): number | null {\n const previousPages = pagesWithVisibility.slice(0, currentPageIndex);\n const foundIndex = previousPages.reverse().findIndex((tab) => tab.isVisible);\n\n // Previous visible tab not found\n if (foundIndex === -1) {\n return null;\n }\n\n // Previous visible tab less than 0\n const previousPageIndex = currentPageIndex - foundIndex - 1;\n if (previousPageIndex < 0) {\n return null;\n }\n\n return previousPageIndex;\n}\n\nfunction getNextPageIndex(\n currentPageIndex: number,\n pagesWithVisibility: { linkId: string; isVisible: boolean }[]\n): number | null {\n const subsequentPages = pagesWithVisibility.slice(currentPageIndex + 1);\n const foundIndex = subsequentPages.findIndex((tab) => tab.isVisible);\n\n // Next visible tab not found, something is wrong\n if (foundIndex === -1) {\n return null;\n }\n\n return currentPageIndex + foundIndex + 1;\n}\n\nexport default useNextAndPreviousVisiblePages;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { memo, useState } from 'react';\nimport Box from '@mui/material/Box';\nimport Card from '@mui/material/Card';\nimport { PrimarySelectableList } from '../Lists.styles';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport type { Tabs } from '../../interfaces/tab.interface';\nimport Divider from '@mui/material/Divider';\nimport FormBodyTabList from './FormBodyTabList';\nimport ShowCompletedTabsSection from './ShowCompletedTabsSection';\nimport useContextDisplayItems from '../../hooks/useContextDisplayItems';\n\ninterface FormBodyTabListWrapperProps {\n topLevelItems: QuestionnaireItem[];\n currentTabIndex: number;\n tabs: Tabs;\n}\n\nconst FormBodyTabListWrapper = memo(function FormBodyTabListWrapper(\n props: FormBodyTabListWrapperProps\n) {\n const { topLevelItems, currentTabIndex, tabs } = props;\n\n const [completedTabsExpanded, setCompletedTabsExpanded] = useState(true);\n\n const { allContextDisplayItems, completedDisplayItemExists } =\n useContextDisplayItems(topLevelItems);\n\n return (\n <Card sx={{ p: 0.75, mb: 2 }}>\n <Box sx={{ flexGrow: 1 }}>\n <PrimarySelectableList\n dense\n disablePadding\n sx={{ mb: 0.5, mt: completedDisplayItemExists ? 0 : 0.5 }}\n data-test=\"renderer-tab-list\">\n {completedDisplayItemExists ? (\n <>\n <ShowCompletedTabsSection\n completedTabsExpanded={completedTabsExpanded}\n setCompletedTabsExpanded={setCompletedTabsExpanded}\n />\n <Divider sx={{ mx: 1, opacity: 0.6 }} />\n </>\n ) : null}\n <FormBodyTabList\n topLevelItems={topLevelItems}\n currentTabIndex={currentTabIndex}\n tabs={tabs}\n completedTabsCollapsed={!completedTabsExpanded}\n allContextDisplayItems={allContextDisplayItems}\n />\n </PrimarySelectableList>\n </Box>\n </Card>\n );\n});\n\nexport default FormBodyTabListWrapper;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport List from '@mui/material/List';\nimport { alpha, styled } from '@mui/material/styles';\n\nexport const PrimarySelectableList = styled(List)(({ theme }) => ({\n '&& .Mui-selected': {\n color: theme.palette.primary.dark,\n backgroundColor: alpha(theme.palette.primary.main, 0.2),\n borderRadius: 30,\n '& .MuiTypography-root': {\n fontWeight: 'bold'\n }\n },\n '& .MuiListItemButton-root': {\n color: '#444746',\n borderRadius: 30\n },\n '& .MuiListItemButton-root:hover': {\n color: theme.palette.primary.dark,\n backgroundColor: alpha(theme.palette.primary.main, 0.09),\n borderRadius: 30\n }\n}));\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { memo } from 'react';\nimport Collapse from '@mui/material/Collapse';\nimport { TransitionGroup } from 'react-transition-group';\nimport { getShortText } from '../../utils/itemControl';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport FormBodySingleTab from './FormBodySingleTab';\nimport type { Tabs } from '../../interfaces/tab.interface';\nimport { useQuestionnaireStore } from '../../stores';\nimport { isTabHidden } from '../../utils/tabs';\n\ninterface FormBodyTabListProps {\n topLevelItems: QuestionnaireItem[];\n currentTabIndex: number;\n tabs: Tabs;\n completedTabsCollapsed: boolean;\n allContextDisplayItems: QuestionnaireItem[][];\n}\n\nconst FormBodyTabList = memo(function FormBodyTabList(props: FormBodyTabListProps) {\n const { topLevelItems, currentTabIndex, tabs, completedTabsCollapsed, allContextDisplayItems } =\n props;\n\n const enableWhenIsActivated = useQuestionnaireStore.use.enableWhenIsActivated();\n const enableWhenItems = useQuestionnaireStore.use.enableWhenItems();\n const enableWhenExpressions = useQuestionnaireStore.use.enableWhenExpressions();\n\n return (\n <TransitionGroup>\n {topLevelItems.map((qItem, i) => {\n const contextDisplayItems = allContextDisplayItems[i];\n const isTab = !!tabs[qItem.linkId];\n\n if (\n isTabHidden({\n qItem,\n contextDisplayItems,\n isTab,\n enableWhenIsActivated,\n enableWhenItems,\n enableWhenExpressions,\n completedTabsCollapsed\n })\n ) {\n return null;\n }\n\n const tabIsSelected = currentTabIndex.toString() === i.toString();\n const tabLabel = getShortText(qItem) ?? qItem.text ?? '';\n\n return (\n <Collapse key={qItem.linkId} timeout={100}>\n <FormBodySingleTab\n contextDisplayItems={contextDisplayItems}\n selected={tabIsSelected}\n tabLabel={tabLabel}\n listIndex={i}\n />\n </Collapse>\n );\n })}\n </TransitionGroup>\n );\n});\n\nexport default FormBodyTabList;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { memo } from 'react';\nimport Box from '@mui/material/Box';\nimport ListItemButton from '@mui/material/ListItemButton';\nimport ListItemText from '@mui/material/ListItemText';\nimport Typography from '@mui/material/Typography';\nimport { useQuestionnaireStore } from '../../stores';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport ContextDisplayItem from '../FormComponents/ItemParts/ContextDisplayItem';\nimport { useFocusTabHeading } from '../../hooks/useFocusTabHeading';\n\ninterface FormBodySingleTabProps {\n contextDisplayItems: QuestionnaireItem[];\n selected: boolean;\n tabLabel: string;\n listIndex: number;\n}\n\nconst FormBodySingleTab = memo(function FormBodySingleTab(props: FormBodySingleTabProps) {\n const { contextDisplayItems, selected, tabLabel, listIndex } = props;\n\n const switchTab = useQuestionnaireStore.use.switchTab();\n const focusHeading = useFocusTabHeading();\n\n function handleTabClick() {\n switchTab(listIndex);\n window.scrollTo(0, 0);\n\n // Focus the first heading in the new tab panel\n setTimeout(() => {\n focusHeading(`tabpanel-${listIndex}`);\n }, 100); // Small delay to ensure panel is rendered\n }\n\n return (\n <>\n <ListItemButton\n selected={selected}\n sx={{ my: 0.1, minHeight: '36px' }}\n onClick={handleTabClick}>\n <ListItemText\n primary={\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\">\n <Typography fontWeight={600} fontSize=\"0.8125rem\">\n {tabLabel}\n </Typography>\n <Box display=\"flex\" minHeight={24} minWidth={24} ml={1}>\n {contextDisplayItems.map((item) => {\n return <ContextDisplayItem key={item.linkId} displayItem={item} />;\n })}\n </Box>\n </Box>\n }\n />\n </ListItemButton>\n </>\n );\n});\n\nexport default FormBodySingleTab;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport { IconButton } from '@mui/material';\nimport ExpandLess from '@mui/icons-material/ExpandLess';\nimport ExpandMore from '@mui/icons-material/ExpandMore';\n\ninterface ShowCompletedTabsSectionProps {\n completedTabsExpanded: boolean;\n setCompletedTabsExpanded: (newExpanded: boolean) => void;\n}\n\nfunction ShowCompletedTabsSection(props: ShowCompletedTabsSectionProps) {\n const { completedTabsExpanded, setCompletedTabsExpanded } = props;\n\n return (\n <Box display=\"flex\" justifyContent=\"center\" alignItems=\"center\" mx={2} columnGap={0.5}>\n <Typography\n variant=\"overline\"\n fontSize={8.5}\n color={completedTabsExpanded ? 'text.secondary' : 'text.disabled'}>\n Completed tabs {completedTabsExpanded ? 'shown' : 'hidden'}\n </Typography>\n <IconButton\n size=\"small\"\n onClick={() => {\n setCompletedTabsExpanded(!completedTabsExpanded);\n }}>\n {completedTabsExpanded ? <ExpandLess fontSize=\"small\" /> : <ExpandMore fontSize=\"small\" />}\n </IconButton>\n </Box>\n );\n}\n\nexport default ShowCompletedTabsSection;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useMemo } from 'react';\nimport { getContextDisplays } from '../utils/tabs';\nimport type { QuestionnaireItem } from 'fhir/r4';\n\nfunction useContextDisplayItems(topLevelItems: QuestionnaireItem[]) {\n return useMemo(() => {\n let completedDisplayItemExists = false;\n\n const allContextDisplayItems = topLevelItems.map((topLevelItem) =>\n getContextDisplays(topLevelItem)\n );\n\n completedDisplayItemExists = allContextDisplayItems.some((contextDisplayItems) => {\n return contextDisplayItems.some(\n (contextDisplayItem) => contextDisplayItem.text === 'Complete'\n );\n });\n\n return { allContextDisplayItems, completedDisplayItemExists };\n }, [topLevelItems]);\n}\n\nexport default useContextDisplayItems;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport Stack from '@mui/material/Stack';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport { getQrItemsIndex, mapQItemsIndex } from '../../utils/mapItem';\nimport { createEmptyQrGroup, updateQrItemsInGroup } from '../../utils/qrItem';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler\n} from '../../interfaces/renderProps.interface';\nimport { useQuestionnaireStore } from '../../stores';\nimport FormBodySingleCollapsibleWrapper from './FormBodySingleCollapsibleWrapper';\n\ninterface FormBodyCollapsibleProps\n extends PropsWithQrItemChangeHandler,\n PropsWithParentIsReadOnlyAttribute {\n topLevelQItem: QuestionnaireItem;\n topLevelQRItem: QuestionnaireResponseItem | null;\n}\n\nfunction FormBodyCollapsibleWrapper(props: FormBodyCollapsibleProps) {\n const { topLevelQItem, topLevelQRItem, parentIsReadOnly, onQrItemChange } = props;\n\n const tabs = useQuestionnaireStore.use.tabs();\n const currentTab = useQuestionnaireStore.use.currentTabIndex();\n const switchTab = useQuestionnaireStore.use.switchTab();\n\n const indexMap: Record<string, number> = useMemo(\n () => mapQItemsIndex(topLevelQItem),\n [topLevelQItem]\n );\n\n const nonNullTopLevelQRItem = topLevelQRItem ?? createEmptyQrGroup(topLevelQItem);\n\n const qItems = topLevelQItem.item;\n const qrItems = nonNullTopLevelQRItem.item;\n\n function handleQrGroupChange(qrItem: QuestionnaireResponseItem) {\n updateQrItemsInGroup(qrItem, null, nonNullTopLevelQRItem, indexMap);\n onQrItemChange(nonNullTopLevelQRItem);\n }\n\n if (!qItems || !qrItems) {\n return <>Unable to load form</>;\n }\n\n function handleToggleExpand(index: number) {\n switchTab(currentTab === index ? -1 : index);\n }\n\n if (!qItems || !qrItems) {\n return <>Unable to load form</>;\n }\n\n const qrItemsByIndex = getQrItemsIndex(qItems, qrItems, indexMap);\n\n return (\n <Stack rowGap={1}>\n {qItems.map((qItem, i) => {\n const qrItem = qrItemsByIndex[i];\n\n const isNotRepeatGroup = !Array.isArray(qrItem);\n const isTab = !!tabs[qItem.linkId];\n\n if (!isTab || !isNotRepeatGroup) {\n // Something has gone horribly wrong\n return null;\n }\n\n return (\n <FormBodySingleCollapsibleWrapper\n key={qItem.linkId}\n qItem={qItem}\n qrItem={qrItem ?? null}\n index={i}\n selectedIndex={currentTab}\n parentIsReadOnly={parentIsReadOnly}\n onToggleExpand={handleToggleExpand}\n onQrItemChange={handleQrGroupChange}\n />\n );\n })}\n </Stack>\n );\n}\n\nexport default FormBodyCollapsibleWrapper;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ReactNode } from 'react';\nimport React, { memo } from 'react';\nimport Accordion from '@mui/material/Accordion';\nimport AccordionDetails from '@mui/material/AccordionDetails';\nimport AccordionSummary from '@mui/material/AccordionSummary';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport ExpandMoreIcon from '@mui/icons-material/ExpandMore';\nimport { getContextDisplays } from '../../utils/tabs';\nimport type { QuestionnaireItem } from 'fhir/r4';\nimport { getShortText } from '../../utils/itemControl';\nimport ContextDisplayItem from '../FormComponents/ItemParts/ContextDisplayItem';\n\ninterface FormBodySingleCollapsibleProps {\n qItem: QuestionnaireItem;\n index: number;\n selectedIndex: number;\n onToggleExpand: (index: number) => void;\n children: ReactNode;\n}\n\nconst FormBodySingleCollapsible = memo(function FormBodySingleCollapsible(\n props: FormBodySingleCollapsibleProps\n) {\n const { qItem, index, selectedIndex, onToggleExpand, children } = props;\n\n const contextDisplayItems = getContextDisplays(qItem);\n\n const collapsibleLabel = getShortText(qItem) ?? qItem.text ?? '';\n\n const isExpanded = selectedIndex === index;\n\n return (\n <Accordion\n expanded={isExpanded}\n slotProps={{\n transition: { unmountOnExit: true, timeout: 250 }\n }}\n onChange={() => onToggleExpand(index)}>\n <AccordionSummary expandIcon={<ExpandMoreIcon />}>\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\" width=\"100%\" mr={3}>\n <Typography>{collapsibleLabel}</Typography>\n <Box display=\"flex\" columnGap={0.5}>\n {contextDisplayItems.map((item) => {\n return <ContextDisplayItem key={item.linkId} displayItem={item} />;\n })}\n </Box>\n </Box>\n </AccordionSummary>\n <AccordionDetails>\n <>{children}</>\n </AccordionDetails>\n </Accordion>\n );\n});\n\nexport default FormBodySingleCollapsible;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport GroupItem from '../FormComponents/GroupItem/GroupItem';\nimport FormBodySingleCollapsible from './FormBodySingleCollapsible';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler\n} from '../../interfaces/renderProps.interface';\nimport useHidden from '../../hooks/useHidden';\n\ninterface FormBodySingleCollapsibleProps\n extends PropsWithQrItemChangeHandler,\n PropsWithParentIsReadOnlyAttribute {\n qItem: QuestionnaireItem;\n qrItem: QuestionnaireResponseItem | null;\n index: number;\n selectedIndex: number;\n onToggleExpand: (index: number) => void;\n}\n\nfunction FormBodySingleCollapsibleWrapper(props: FormBodySingleCollapsibleProps) {\n const { qItem, qrItem, index, selectedIndex, parentIsReadOnly, onToggleExpand, onQrItemChange } =\n props;\n\n const itemIsHidden = useHidden(qItem);\n if (itemIsHidden) {\n return null;\n }\n\n return (\n <FormBodySingleCollapsible\n key={qItem.linkId}\n qItem={qItem}\n index={index}\n selectedIndex={selectedIndex}\n onToggleExpand={onToggleExpand}>\n <GroupItem\n qItem={qItem}\n qrItem={qrItem}\n isRepeated={true}\n groupCardElevation={1}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={onQrItemChange}\n />\n </FormBodySingleCollapsible>\n );\n}\n\nexport default FormBodySingleCollapsibleWrapper;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Breakpoint } from '@mui/material/styles';\nimport { useTheme } from '@mui/material/styles';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\n/**\n * Props for the useResponsive() hook - used to determine if the screen size matches a given breakpoint query.\n *\n * @param {'up' | 'down' | 'between' | 'only'} query - The type of query:\n * - `'up'`: Matches screen sizes above and including `start`.\n * - `'down'`: Matches screen sizes below and including `start`.\n * - `'between'`: Matches screen sizes between `start` and `end` (inclusive).\n * - `'only'`: Matches exactly the `start` size.\n * @param {'xs' | 'sm' | 'md' | 'lg' | 'xl'} start - The starting breakpoint - can be extended via MUI BreakpointOverrides.\n * @param {'xs' | 'sm' | 'md' | 'lg' | 'xl'} end - The ending breakpoint (required if `query` is `'between'`) - can be extended via MUI BreakpointOverrides.\n *\n * @example\n * // Check if the screen size is at least 'md' (medium)\n * const isMdUp = useResponsive({ query: 'up', start: 'md' });\n *\n * @example\n * // Check if the screen size is exactly 'lg' (large)\n * const isLgOnly = useResponsive({ query: 'only', start: 'lg' });\n *\n * @example\n * // Check if the screen size is at least 'tablet' - this is a custom breakpoint https://mui.com/material-ui/customization/breakpoints/#custom-breakpoints\n * const isTabletUp = useResponsive({ query: 'up', start: 'tablet' });\n **/\nexport interface UseResponsiveProps {\n query: 'up' | 'down' | 'between' | 'only';\n start: Breakpoint;\n end?: Breakpoint;\n}\n\n/**\n * A hook to determine if the screen size matches a given breakpoint query.\n *\n * @param props - The responsive query options.\n *\n * @returns {boolean} `true` if the current screen size matches the query, otherwise `false`.\n *\n * @example\n * // Check if the screen size is at least 'md' (medium)\n * const isMdUp = useResponsive({ query: 'up', start: 'md' });\n *\n * @example\n * // Check if the screen size is exactly 'lg' (large)\n * const isLgOnly = useResponsive({ query: 'only', start: 'lg' });\n *\n * @example\n * // Check if the screen size is at least 'tablet' - this is a custom breakpoint https://mui.com/material-ui/customization/breakpoints/#custom-breakpoints\n * const isTabletUp = useResponsive({ query: 'up', start: 'tablet' });\n */\nfunction useResponsive(props: UseResponsiveProps): boolean {\n const { query, start, end = 'xl' } = props;\n\n const theme = useTheme();\n\n const mediaUp = useMediaQuery(theme.breakpoints.up(start));\n\n const mediaDown = useMediaQuery(theme.breakpoints.down(start));\n\n const mediaBetween = useMediaQuery(theme.breakpoints.between(start, end));\n\n const mediaOnly = useMediaQuery(theme.breakpoints.only(start));\n\n if (query === 'up') {\n return mediaUp;\n }\n\n if (query === 'down') {\n return mediaDown;\n }\n\n if (query === 'between') {\n return mediaBetween;\n }\n\n return mediaOnly;\n}\n\nexport default useResponsive;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport FormBodyTabbed from './FormBodyTabbed';\nimport { containsTabs, isTabContainer } from '../../utils/tabs';\nimport GroupItem from '../FormComponents/GroupItem/GroupItem';\nimport SingleItem from '../FormComponents/SingleItem/SingleItem';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler,\n PropsWithQrRepeatGroupChangeHandler\n} from '../../interfaces/renderProps.interface';\nimport FormBodyCollapsible from './FormBodyCollapsible';\nimport useResponsive from '../../hooks/useResponsive';\nimport useHidden from '../../hooks/useHidden';\nimport GroupItemSwitcher from '../FormComponents/GroupItem/GroupItemSwitcher';\nimport useReadOnly from '../../hooks/useReadOnly';\nimport Box from '@mui/material/Box';\nimport { isRepeatItemAndNotCheckbox, isSpecificItemControl } from '../../utils';\nimport GroupTable from '../FormComponents/Tables/GroupTable';\nimport RepeatItem from '../FormComponents/RepeatItem/RepeatItem';\nimport GridGroup from '../FormComponents/GridGroup/GridGroup';\nimport { useRendererStylingStore } from '../../stores';\nimport { isPage } from '../../utils/page';\nimport FormBodyPageContainer from './FormBodyPageContainer';\n\ninterface FormTopLevelItemProps\n extends PropsWithQrItemChangeHandler,\n PropsWithQrRepeatGroupChangeHandler,\n PropsWithParentIsReadOnlyAttribute {\n topLevelQItem: QuestionnaireItem;\n topLevelQRItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null;\n wholeFormIsPaginated: boolean;\n}\n\nfunction FormTopLevelItem(props: FormTopLevelItemProps) {\n const {\n topLevelQItem,\n topLevelQRItemOrItems,\n parentIsReadOnly,\n wholeFormIsPaginated,\n onQrItemChange,\n onQrRepeatGroupChange\n } = props;\n\n const itemIsTabContainer = isTabContainer(topLevelQItem);\n const itemContainsTabs = containsTabs(topLevelQItem);\n\n // itemIsPageContainer is there for backwards compatibility only - see https://github.com/aehrc/smart-forms/issues/1041\n // The proper way to do it ATM is to make every single top-level item a page\n // Unfortunately, \"header\" and \"footer\" itemControl is not supported.\n const itemIsPageContainer = isPage(topLevelQItem);\n\n const showTabbedFormAt = useRendererStylingStore.use.showTabbedFormAt();\n const isTabbedForm = useResponsive(showTabbedFormAt);\n\n const itemIsGroup = topLevelQItem.type === 'group';\n\n const readOnly = useReadOnly(topLevelQItem, parentIsReadOnly);\n const itemIsHidden = useHidden(topLevelQItem);\n if (itemIsHidden) {\n return null;\n }\n\n // If item has multiple answers, use a group item switcher to determine how to render it.\n const hasMultipleAnswers = Array.isArray(topLevelQRItemOrItems);\n if (hasMultipleAnswers) {\n return (\n <GroupItemSwitcher\n qItem={topLevelQItem}\n qrItemOrItems={topLevelQRItemOrItems}\n groupCardElevation={1}\n parentIsReadOnly={readOnly}\n onQrItemChange={onQrItemChange}\n onQrRepeatGroupChange={onQrRepeatGroupChange}\n />\n );\n }\n\n // At this point, item only has one answer\n const topLevelQRItem = topLevelQRItemOrItems;\n\n // If form is tabbed, it is rendered as a tabbed form\n if (itemContainsTabs || itemIsTabContainer) {\n if (isTabbedForm) {\n return (\n <FormBodyTabbed\n key={topLevelQItem.linkId}\n topLevelQItem={topLevelQItem}\n topLevelQRItem={topLevelQRItem}\n parentIsReadOnly={readOnly}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n\n return (\n <FormBodyCollapsible\n key={topLevelQItem.linkId}\n topLevelQItem={topLevelQItem}\n topLevelQRItem={topLevelQRItem}\n parentIsReadOnly={readOnly}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n\n /* Using \"page\" item as a page-container - only preserved for backwards compatibility (not complaint with https://hl7.org/fhir/extensions/CodeSystem-questionnaire-item-control.html#questionnaire-item-control-page)\n * - The first \"page\" item in the questionnaire will be considered as a page-container, and all its children will be considered as pages\n * - All other pages will be ignored by the renderer\n * - You can have non-page items in the same level as the page-container to be used as faux headers or footers\n * - Ensure that only group items are in the page-container\n * Note: This will only be used if wholeFormIsPaginated=false\n */\n if (!wholeFormIsPaginated && itemIsPageContainer) {\n return (\n <FormBodyPageContainer\n key={topLevelQItem.linkId}\n topLevelQItem={topLevelQItem}\n topLevelQRItem={topLevelQRItem}\n parentIsReadOnly={readOnly}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n\n // If form is untabbed, it is rendered as a regular group\n if (itemIsGroup) {\n // Item is 'grid'\n const itemIsGrid = isSpecificItemControl(topLevelQItem, 'grid');\n if (itemIsGrid) {\n return (\n <GridGroup\n qItem={topLevelQItem}\n qrItem={topLevelQRItem}\n groupCardElevation={1}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n\n // GroupTable \"gtable\" can be rendered with either repeats:true or false\n if (isSpecificItemControl(topLevelQItem, 'gtable')) {\n return (\n <GroupTable\n key={topLevelQItem.linkId}\n qItem={topLevelQItem}\n qrItems={topLevelQRItem ? [topLevelQRItem] : []}\n groupCardElevation={1}\n isRepeated={false}\n parentIsReadOnly={parentIsReadOnly}\n onQrRepeatGroupChange={onQrRepeatGroupChange}\n />\n );\n }\n\n return (\n <GroupItem\n key={topLevelQItem.linkId}\n qItem={topLevelQItem}\n qrItem={topLevelQRItem}\n groupCardElevation={1}\n isRepeated={false}\n parentIsReadOnly={readOnly}\n onQrItemChange={onQrItemChange}\n />\n );\n }\n\n // Otherwise, it is rendered as a non-group item\n const itemRepeatsAndIsNotCheckbox = isRepeatItemAndNotCheckbox(topLevelQItem);\n if (itemRepeatsAndIsNotCheckbox) {\n return (\n <Box mt={1}>\n <RepeatItem\n key={topLevelQItem.linkId}\n qItem={topLevelQItem}\n qrItem={topLevelQRItem}\n groupCardElevation={1}\n parentIsReadOnly={readOnly}\n onQrItemChange={onQrItemChange}\n />\n </Box>\n );\n }\n\n return (\n <Box mt={1}>\n <SingleItem\n key={topLevelQItem.linkId}\n qItem={topLevelQItem}\n qrItem={topLevelQRItem}\n isRepeated={false}\n isTabled={false}\n groupCardElevation={1}\n parentIsReadOnly={readOnly}\n onQrItemChange={onQrItemChange}\n />\n </Box>\n );\n}\n\nexport default FormTopLevelItem;\n","import React, { useMemo } from 'react';\nimport { Grid } from '@mui/material';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport TabContext from '@mui/lab/TabContext';\nimport TabPanel from '@mui/lab/TabPanel';\nimport GroupItem from '../FormComponents/GroupItem/GroupItem';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler\n} from '../../interfaces/renderProps.interface';\nimport { useQuestionnaireStore } from '../../stores';\nimport { getQrItemsIndex, mapQItemsIndex } from '../../utils/mapItem';\nimport { createEmptyQrGroup, updateQrItemsInGroup } from '../../utils/qrItem';\n\ninterface FormBodyPageContainerProps\n extends PropsWithQrItemChangeHandler,\n PropsWithParentIsReadOnlyAttribute {\n topLevelQItem: QuestionnaireItem;\n topLevelQRItem: QuestionnaireResponseItem | null;\n}\n\n/* Using \"page\" item as a page-container - only preserved for backwards compatibility (not compliant with https://hl7.org/fhir/extensions/CodeSystem-questionnaire-item-control.html#questionnaire-item-control-page)\n * - The first \"page\" item in the questionnaire will be considered as a page-container, and all its children will be considered as pages\n * - All other pages will be ignored by the renderer\n * - You can have non-page items in the same level as the page-container to be used as faux headers or footers\n * - Ensure that only group items are in the page-container\n * Note: This will only be used if wholeFormIsPaginated=false\n */\nfunction FormBodyPageContainer(props: FormBodyPageContainerProps) {\n const { topLevelQItem, topLevelQRItem, parentIsReadOnly, onQrItemChange } = props;\n\n const pages = useQuestionnaireStore.use.pages();\n const currentPage = useQuestionnaireStore.use.currentPageIndex();\n\n const indexMap: Record<string, number> = useMemo(\n () => mapQItemsIndex(topLevelQItem),\n [topLevelQItem]\n );\n\n const nonNullTopLevelQRItem = topLevelQRItem ?? createEmptyQrGroup(topLevelQItem);\n\n const qItems = topLevelQItem.item;\n const qrItems = nonNullTopLevelQRItem.item;\n\n function handleQrGroupChange(qrItem: QuestionnaireResponseItem) {\n updateQrItemsInGroup(qrItem, null, nonNullTopLevelQRItem, indexMap);\n onQrItemChange(nonNullTopLevelQRItem);\n }\n\n if (!qItems || !qrItems) {\n return <>Unable to load form</>;\n }\n\n const qrItemsByIndex = getQrItemsIndex(qItems, qrItems, indexMap);\n\n return (\n <Grid container spacing={1.5}>\n <TabContext value={currentPage.toString()}>\n <Grid size={{ xs: 12, md: 12, lg: 12 }}>\n {qItems.map((qItem, i) => {\n const qrItem = qrItemsByIndex[i];\n\n const isNotRepeatGroup = !Array.isArray(qrItem);\n const isPage = !!pages[qItem.linkId];\n\n if (!isPage || !isNotRepeatGroup) {\n // This should never happen\n return null;\n }\n\n const isRepeated = qItem.repeats ?? false;\n const pageIsMarkedAsComplete = pages[qItem.linkId].isComplete ?? false;\n\n return (\n <TabPanel\n key={qItem.linkId}\n sx={{ p: 0 }}\n value={i.toString()}\n data-test=\"renderer-page-panel\">\n <GroupItem\n qItem={qItem}\n qrItem={qrItem ?? null}\n isRepeated={isRepeated}\n groupCardElevation={1}\n pageIsMarkedAsComplete={pageIsMarkedAsComplete}\n pages={pages}\n currentPageIndex={currentPage}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={handleQrGroupChange}\n />\n </TabPanel>\n );\n })}\n </Grid>\n </TabContext>\n </Grid>\n );\n}\n\nexport default FormBodyPageContainer;\n","import React, { useMemo } from 'react';\nimport Grid from '@mui/material/Grid';\nimport type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';\nimport TabContext from '@mui/lab/TabContext';\nimport TabPanel from '@mui/lab/TabPanel';\nimport GroupItem from '../FormComponents/GroupItem/GroupItem';\nimport type {\n PropsWithParentIsReadOnlyAttribute,\n PropsWithQrItemChangeHandler\n} from '../../interfaces/renderProps.interface';\nimport { useQuestionnaireStore } from '../../stores';\nimport { useRendererStylingStore } from '../../stores/rendererStylingStore';\nimport { SingleItem } from '../FormComponents';\nimport PageButtonsWrapper from '../FormComponents/GroupItem/PageButtonWrapper';\nimport { QGroupContainerBox } from '../Box.styles';\nimport { GroupCard } from '../FormComponents/GroupItem/GroupItem.styles';\nimport { isFooter, isHeader } from '../../utils/page';\n\ninterface FormBodyPaginatedProps\n extends PropsWithQrItemChangeHandler,\n PropsWithParentIsReadOnlyAttribute {\n topLevelQItems: QuestionnaireItem[];\n topLevelQRItems: (QuestionnaireResponseItem | QuestionnaireResponseItem[] | undefined)[];\n}\n\n// TODO This implementation doesnt take into account repeat items and repeat groups\n// TODO need to fix this before bringing it into release\n// Every group item in here is rendered as a page\nfunction FormBodyPaginated(props: FormBodyPaginatedProps) {\n const { topLevelQItems, topLevelQRItems, parentIsReadOnly, onQrItemChange } = props;\n\n const pages = useQuestionnaireStore.use.pages();\n const currentPage = useQuestionnaireStore.use.currentPageIndex();\n const disableCardView = useRendererStylingStore.use.disablePageCardView();\n\n const { headerQItems, pageQItems, footerQItems } = useMemo(() => {\n const headerQItems: [QuestionnaireItem, number][] = [];\n const pageQItems: [QuestionnaireItem, number][] = [];\n const footerQItems: [QuestionnaireItem, number][] = [];\n\n for (const [qrItemIndex, qItem] of topLevelQItems.entries()) {\n if (isHeader(qItem)) {\n headerQItems.push([qItem, qrItemIndex]);\n } else if (isFooter(qItem)) {\n footerQItems.push([qItem, qrItemIndex]);\n } else {\n pageQItems.push([qItem, qrItemIndex]);\n }\n }\n\n return { headerQItems, pageQItems, footerQItems };\n }, [topLevelQItems]);\n\n return (\n <>\n {headerQItems.map((headerQItem) => {\n const [qItem, qrItemIndex] = headerQItem;\n const qrItemOrItems = topLevelQRItems[qrItemIndex];\n\n const isRepeatGroup = Array.isArray(qrItemOrItems);\n if (isRepeatGroup) {\n // Does not work with repeat groups\n return null;\n }\n\n const isRepeated = qItem.repeats ?? false;\n\n return (\n <GroupItem\n key={qItem.linkId}\n qItem={qItem}\n qrItem={qrItemOrItems ?? null}\n isRepeated={isRepeated}\n groupCardElevation={1}\n disableCardView={disableCardView}\n currentPageIndex={currentPage}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={onQrItemChange}\n />\n );\n })}\n\n <Grid container spacing={1.5}>\n <TabContext value={currentPage.toString()}>\n <Grid size={{ xs: 12, md: 12, lg: 12 }}>\n {pageQItems.map((pageQItem, i) => {\n const [qItem, qrItemIndex] = pageQItem;\n const qrItem = topLevelQRItems[qrItemIndex];\n\n const isNotRepeatGroup = !Array.isArray(qrItem);\n const isPage = !!pages[qItem.linkId];\n\n const itemIsGroup = qItem.type === 'group';\n\n // const isHeader = qItem.itemControl?.type === 'header';\n\n if (!isPage || !isNotRepeatGroup) {\n // Something has gone horribly wrong\n return null;\n }\n\n const isRepeated = qItem.repeats ?? false;\n const pageIsMarkedAsComplete = pages[qItem.linkId].isComplete ?? false;\n\n // Render this page as a group\n if (itemIsGroup) {\n return (\n <TabPanel\n key={qItem.linkId}\n sx={{ p: 0 }}\n value={i.toString()}\n data-test=\"renderer-page-panel\">\n <GroupItem\n qItem={qItem}\n qrItem={qrItem ?? null}\n isRepeated={isRepeated}\n groupCardElevation={1}\n disableCardView={disableCardView}\n pageIsMarkedAsComplete={pageIsMarkedAsComplete}\n pages={pages}\n currentPageIndex={currentPage}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={onQrItemChange}\n />\n </TabPanel>\n );\n }\n\n // Page consists of a non-group item\n return (\n <TabPanel\n key={qItem.linkId}\n sx={{ p: 0 }}\n value={i.toString()}\n data-test=\"renderer-page-panel\">\n <QGroupContainerBox\n cardElevation={1}\n isRepeated={isRepeated}\n data-test=\"q-item-group-box\">\n {disableCardView ? (\n <>\n <SingleItem\n qItem={qItem}\n qrItem={qrItem ?? null}\n isRepeated={isRepeated}\n groupCardElevation={1}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={onQrItemChange}\n isTabled={false}\n />\n <PageButtonsWrapper currentPageIndex={currentPage} pages={pages} />\n </>\n ) : (\n <GroupCard elevation={1} isRepeated={isRepeated}>\n <SingleItem\n qItem={qItem}\n qrItem={qrItem ?? null}\n isRepeated={isRepeated}\n groupCardElevation={1}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={onQrItemChange}\n isTabled={false}\n />\n <PageButtonsWrapper currentPageIndex={currentPage} pages={pages} />\n </GroupCard>\n )}\n </QGroupContainerBox>\n </TabPanel>\n );\n })}\n </Grid>\n </TabContext>\n </Grid>\n\n {footerQItems.map((footerQItem) => {\n const [qItem, qrItemIndex] = footerQItem;\n const qrItemOrItems = topLevelQRItems[qrItemIndex];\n\n const isRepeatGroup = Array.isArray(qrItemOrItems);\n if (isRepeatGroup) {\n // Does not work with repeat groups\n return null;\n }\n\n const isRepeated = qItem.repeats ?? false;\n\n return (\n <GroupItem\n key={qItem.linkId}\n qItem={qItem}\n qrItem={qrItemOrItems ?? null}\n isRepeated={isRepeated}\n groupCardElevation={1}\n disableCardView={disableCardView}\n currentPageIndex={currentPage}\n parentIsReadOnly={parentIsReadOnly}\n onQrItemChange={onQrItemChange}\n />\n );\n })}\n </>\n );\n}\n\nexport default FormBodyPaginated;\n","import type {\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireResponse,\n QuestionnaireResponseItem\n} from 'fhir/r4';\nimport type { ComputedQRItemUpdates } from '../interfaces/computedUpdates.interface';\nimport { updateQuestionnaireResponse } from './genericRecursive';\nimport { getQrItemsIndex, mapQItemsIndex } from './mapItem';\nimport { updateQrItemsInGroup } from './qrItem';\n\nexport function applyComputedUpdates(\n questionnaire: Questionnaire,\n updatedResponse: QuestionnaireResponse,\n computedUpdates: ComputedQRItemUpdates\n): QuestionnaireResponse {\n if (Object.keys(computedUpdates).length === 0) {\n return updatedResponse;\n }\n\n return updateQuestionnaireResponse(\n questionnaire,\n updatedResponse,\n applyComputedUpdateRecursive,\n computedUpdates\n );\n}\n\n// Recursive function to apply updates for each item (and its children if applicable)\nfunction applyComputedUpdateRecursive(\n qItem: QuestionnaireItem,\n qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null,\n computedUpdates: ComputedQRItemUpdates\n): QuestionnaireResponseItem | QuestionnaireResponseItem[] | null {\n const update = computedUpdates[qItem.linkId];\n\n if (update === null) {\n // If update is null, remove the item (or group of items)\n return null;\n }\n\n const hasMultipleAnswers = Array.isArray(qrItemOrItems);\n if (hasMultipleAnswers) {\n // Process repeating groups: Apply updates to each item in the group\n return applyComputedUpdateFromRepeatGroup(qItem, qrItemOrItems, computedUpdates);\n }\n\n // At this point qrItemOrItems is a single QuestionnaireResponseItem\n const qrItem = qrItemOrItems;\n\n // Process items with child items\n const childQItems = qItem.item ?? [];\n const childQrItems = qrItem?.item ?? [];\n if (childQItems.length > 0) {\n const indexMap = mapQItemsIndex(qItem);\n const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap);\n\n // Iterate child items\n for (const [index, childQItem] of childQItems.entries()) {\n const childQRItemOrItems = qrItemsByIndex[index];\n\n const updatedChildQRItemOrItems = applyComputedUpdateRecursive(\n childQItem,\n childQRItemOrItems ?? null,\n computedUpdates\n );\n\n // For non-repeating child items, apply the update\n if (!Array.isArray(updatedChildQRItemOrItems)) {\n const updatedChildQRItem = updatedChildQRItemOrItems;\n if (updatedChildQRItem) {\n updateQrItemsInGroup(\n updatedChildQRItem,\n null,\n qrItem ?? { linkId: qItem.linkId, text: qItem.text, item: [] },\n indexMap\n );\n }\n }\n }\n\n return constructGroupItem(qItem, qrItem, computedUpdates);\n }\n\n // If it's a single item with no children, apply the computed update\n return constructSingleItem(qItem, qrItem, computedUpdates);\n}\n\nfunction applyComputedUpdateFromRepeatGroup(\n qItem: QuestionnaireItem,\n qrItems: QuestionnaireResponseItem[],\n computedUpdates: ComputedQRItemUpdates\n) {\n if (!qItem.item) {\n return [];\n }\n\n return qrItems\n .flatMap((childQrItem) => applyComputedUpdateRecursive(qItem, childQrItem, computedUpdates))\n .filter((childQRItem): childQRItem is QuestionnaireResponseItem => !!childQRItem);\n}\n\nfunction constructGroupItem(\n qItem: QuestionnaireItem,\n qrItem: QuestionnaireResponseItem | null,\n computedUpdates: ComputedQRItemUpdates\n): QuestionnaireResponseItem | null {\n const computedUpdate = computedUpdates[qItem.linkId];\n\n // If group item has an existing answer, do not overwrite it with computed update\n if (qrItem?.answer && qrItem?.answer.length > 0) {\n return qrItem ?? null;\n }\n\n if (!computedUpdate) {\n return qrItem ?? null;\n }\n\n if (qrItem) {\n return {\n ...qrItem,\n answer: computedUpdate.answer\n };\n }\n\n return {\n linkId: qItem.linkId,\n text: qItem.text,\n answer: computedUpdate.answer\n };\n}\n\nfunction constructSingleItem(\n qItem: QuestionnaireItem,\n qrItem: QuestionnaireResponseItem | null,\n computedUpdates: ComputedQRItemUpdates\n): QuestionnaireResponseItem | null {\n const computedUpdate = computedUpdates[qItem.linkId];\n if (!computedUpdate) {\n return qrItem ?? null;\n }\n\n return {\n linkId: qItem.linkId,\n text: qItem.text,\n answer: computedUpdate.answer\n };\n}\n","/*\n * Copyright 2025 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ReactNode } from 'react';\nimport React from 'react';\nimport {\n createTheme,\n StyledEngineProvider,\n ThemeProvider as MUIThemeProvider\n} from '@mui/material/styles';\nimport CustomGlobalStyles from './customGlobalStyles';\nimport componentsOverride from './overrides/Overrides';\nimport { themeOptions } from './themeOptions';\n\n/**\n * Default theme used by the renderer using Material UI. You can customise your own theme by defining a new ThemeProvider.\n * @see {@link https://mui.com/material-ui/customization/theming/}\n *\n * @author Sean Fong\n */\nexport function RendererThemeProvider({ children }: { children: ReactNode }) {\n const theme = createTheme(themeOptions);\n theme.components = componentsOverride(theme);\n\n return (\n <StyledEngineProvider injectFirst>\n <MUIThemeProvider theme={theme}>\n <CustomGlobalStyles />\n <>{children}</>\n </MUIThemeProvider>\n </StyledEngineProvider>\n );\n}\n\nexport default RendererThemeProvider;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport GlobalStyles from '@mui/material/GlobalStyles';\n\nexport default function CustomGlobalStyles() {\n return (\n <GlobalStyles\n styles={{\n '*': {\n boxSizing: 'border-box'\n },\n html: {\n margin: 0,\n padding: 0,\n width: '100%',\n height: '100%',\n WebkitOverflowScrolling: 'touch'\n },\n body: {\n margin: 0,\n padding: 0,\n width: '100%',\n height: '100%'\n },\n '#root': {\n width: '100%',\n height: '100%',\n textAlign: 'left'\n },\n input: {\n '&[type=number]': {\n MozAppearance: 'textfield',\n '&::-webkit-outer-spin-button': {\n margin: 0,\n WebkitAppearance: 'none'\n },\n '&::-webkit-inner-spin-button': {\n margin: 0,\n WebkitAppearance: 'none'\n }\n }\n },\n img: {\n display: 'block',\n maxWidth: '100%'\n }\n }}\n />\n );\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Theme } from '@mui/material';\nimport { alpha } from '@mui/material/styles';\nimport { grey } from '@mui/material/colors';\n\nexport default function Card(theme: Theme) {\n return {\n MuiCard: {\n styleOverrides: {\n root: {\n boxShadow: `0 0 2px 0 ${alpha(grey[500], 0.2)}, 0 12px 24px -4px ${alpha(\n grey[500],\n 0.16\n )}`,\n borderRadius: Number(theme.shape.borderRadius) * 2,\n position: 'relative',\n zIndex: 0 // Fix Safari overflow: hidden with border radius\n }\n }\n },\n MuiCardHeader: {\n defaultProps: {\n titleTypographyProps: { variant: 'h6' },\n subheaderTypographyProps: { variant: 'body2' }\n },\n styleOverrides: {\n root: {\n padding: theme.spacing(3, 3, 0)\n }\n }\n },\n MuiCardContent: {\n styleOverrides: {\n root: {\n padding: theme.spacing(3)\n }\n }\n }\n };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport default function Paper() {\n return {\n MuiPaper: {\n defaultProps: {\n elevation: 0\n },\n styleOverrides: {\n root: {\n backgroundImage: 'none'\n }\n }\n }\n };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Theme } from '@mui/material/styles';\nimport { alpha } from '@mui/material/styles';\n\nexport default function Input(theme: Theme) {\n return {\n MuiInputBase: {\n styleOverrides: {\n root: {\n '&.Mui-disabled': {\n '& svg': { color: theme.palette.text.disabled }\n }\n },\n input: {\n '&::placeholder': {\n opacity: 1,\n color: theme.palette.text.disabled\n }\n }\n }\n },\n MuiInput: {\n styleOverrides: {\n underline: {\n '&:before': {\n borderBottomColor: alpha(theme.palette.grey[500], 0.56)\n }\n }\n }\n },\n MuiFilledInput: {\n styleOverrides: {\n root: {\n backgroundColor: alpha(theme.palette.grey[500], 0.12),\n '&:hover': {\n backgroundColor: alpha(theme.palette.grey[500], 0.16)\n },\n '&.Mui-focused': {\n backgroundColor: theme.palette.action.focus\n },\n '&.Mui-disabled': {\n backgroundColor: theme.palette.action.disabledBackground\n }\n },\n underline: {\n '&:before': {\n borderBottomColor: alpha(theme.palette.grey[500], 0.56)\n }\n }\n }\n },\n MuiOutlinedInput: {\n styleOverrides: {\n root: {\n '&.Mui-disabled': {\n '& .MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.action.disabledBackground\n }\n },\n '&.Mui-readOnly': {\n '& .MuiOutlinedInput-notchedOutline': {\n borderColor: 'rgb(220, 223, 228)'\n },\n '&:hover .MuiOutlinedInput-notchedOutline': {\n borderColor: 'rgb(220, 223, 228)'\n },\n '&.Mui-focused .MuiOutlinedInput-notchedOutline': {\n borderColor: 'rgb(220, 223, 228)'\n },\n '&.Mui-visited .MuiOutlinedInput-notchedOutline': {\n borderColor: 'rgb(220, 223, 228)'\n }\n }\n }\n }\n }\n };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Theme } from '@mui/material/styles';\nimport { alpha } from '@mui/material/styles';\nimport { grey } from '@mui/material/colors';\n\nexport default function Table(theme: Theme) {\n return {\n MuiTableCell: {\n styleOverrides: {\n head: {\n color: theme.palette.text.secondary,\n backgroundColor: '#F4F6F8',\n borderBottom: '1px solid #e5e7eb'\n }\n }\n },\n MuiTableContainer: {\n styleOverrides: {\n root: {\n boxShadow: `0 0 2px 0 ${alpha(grey[500], 0.2)}, 0 12px 24px -4px ${alpha(\n grey[500],\n 0.16\n )}`\n }\n }\n }\n };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Theme } from '@mui/material/styles';\nimport { alpha } from '@mui/material/styles';\n\nexport default function Button(theme: Theme) {\n return {\n MuiButton: {\n styleOverrides: {\n root: {\n '&:hover': {\n boxShadow: 'none'\n }\n },\n sizeLarge: {\n height: 48\n },\n containedInherit: {\n color: theme.palette.grey[800],\n boxShadow: theme.shadows[8],\n '&:hover': {\n backgroundColor: theme.palette.grey[400]\n }\n },\n outlinedInherit: {\n border: `1px solid ${alpha(theme.palette.grey[500], 0.32)}`,\n '&:hover': {\n backgroundColor: theme.palette.action.hover\n }\n },\n textInherit: {\n '&:hover': {\n backgroundColor: theme.palette.action.hover\n }\n }\n }\n }\n };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Theme } from '@mui/material/styles';\n\nexport default function Autocomplete(theme: Theme) {\n return {\n MuiAutocomplete: {\n styleOverrides: {\n paper: {\n boxShadow: theme.shadows[12]\n }\n }\n }\n };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Theme } from '@mui/material';\nimport { alpha } from '@mui/material/styles';\nimport { grey } from '@mui/material/colors';\n\nexport default function Accordion(theme: Theme) {\n return {\n MuiAccordion: {\n styleOverrides: {\n root: {\n boxShadow: `0 0 2px 0 ${alpha(grey[500], 0.2)}, 0 12px 24px -4px ${alpha(\n grey[500],\n 0.16\n )}`,\n borderRadius: Number(theme.shape.borderRadius) * 2,\n '&:before': {\n display: 'none'\n }\n }\n }\n }\n };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Theme } from '@mui/material/styles';\n\nexport default function SpeedDial(theme: Theme) {\n return {\n MuiSpeedDialAction: {\n styleOverrides: {\n staticTooltipLabel: {\n backgroundColor: theme.palette.grey[600],\n color: theme.palette.common.white,\n fontSize: theme.typography.subtitle2.fontSize,\n fontWeight: theme.typography.subtitle2.fontWeight,\n boxShadow: theme.shadows[8],\n maxWidth: 200,\n whiteSpace: 'nowrap'\n }\n }\n }\n };\n}\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Card from './Card';\nimport Paper from './Paper';\nimport Input from './Input';\nimport Table from './Table';\nimport Button from './Button';\nimport Autocomplete from './Autocomplete';\nimport Accordion from './Accordion';\nimport SpeedDial from './SpeedDial';\nimport type { Theme } from '@mui/material/styles';\n\nfunction ComponentsOverrides(theme: Theme) {\n return Object.assign(\n Accordion(theme),\n Card(theme),\n Table(theme),\n Input(theme),\n Paper(),\n Button(theme),\n Autocomplete(theme),\n SpeedDial(theme)\n );\n}\n\nexport default ComponentsOverrides;\n","/*\n * Copyright 2025 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ThemeOptions } from '@mui/material/styles';\nimport { alpha } from '@mui/material/styles';\nimport typography from './typography';\nimport { grey } from '@mui/material/colors';\n\nexport const themeOptions: ThemeOptions = {\n palette: {\n secondary: {\n light: '#7ac298',\n main: '#229954',\n dark: '#145c32'\n },\n text: {\n primary: grey['800'],\n secondary: grey['600'],\n disabled: grey['500']\n },\n background: {\n paper: '#fff',\n default: '#fafafa'\n },\n action: {\n active: grey['600'],\n hover: alpha(grey['500'], 0.08),\n selected: alpha(grey['500'], 0.16),\n disabled: alpha(grey['500'], 0.8),\n disabledBackground: alpha(grey['500'], 0.24),\n focus: alpha(grey['500'], 0.24),\n hoverOpacity: 0.08,\n disabledOpacity: 0.48\n }\n },\n shape: { borderRadius: 6 },\n typography: typography,\n // 0 - shadow-none\n // 1-3 - shadow-2xs\n // 4-7 - shadow-xs\n // 8-11 - shadow-sm\n // 12-15 - shadow-md\n // 16-19 - shadow-lg\n // 20-23 - shadow-xl\n // 24 - shadow-2xl\n shadows: [\n 'none', // 0 - shadow-none\n '0 1px rgb(0 0 0 / 0.05)', // 1 - shadow-2xs\n '0 1px rgb(0 0 0 / 0.05)', // 2 - shadow-2xs\n '0 1px rgb(0 0 0 / 0.05)', // 3 - shadow-2xs\n '0 1px 2px 0 rgb(0 0 0 / 0.05)', // 4 - shadow-xs\n '0 1px 2px 0 rgb(0 0 0 / 0.05)', // 5 - shadow-xs\n '0 1px 2px 0 rgb(0 0 0 / 0.05)', // 6 - shadow-xs\n '0 1px 2px 0 rgb(0 0 0 / 0.05)', // 7 - shadow-xs\n '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)', // 8 - shadow-sm\n '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)', // 9 - shadow-sm\n '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)', // 10 - shadow-sm\n '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)', // 11 - shadow-sm\n '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)', // 12 - shadow-md\n '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)', // 13 - shadow-md\n '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)', // 14 - shadow-md\n '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)', // 15 - shadow-md\n '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)', // 16 - shadow-lg\n '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)', // 17 - shadow-lg\n '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)', // 18 - shadow-lg\n '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)', // 19 - shadow-lg\n '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)', // 20 - shadow-xl\n '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)', // 21 - shadow-xl\n '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)', // 22 - shadow-xl\n '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)', // 23 - shadow-xl\n '0 25px 50px -12px rgb(0 0 0 / 0.25)' // 24 - shadow-2xl\n ]\n};\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TypographyVariantsOptions } from '@mui/material';\nimport type { CSSProperties } from 'react';\n\ndeclare module '@mui/material/styles' {\n // noinspection JSUnusedGlobalSymbols\n interface TypographyVariants {\n label: CSSProperties;\n groupHeading: CSSProperties;\n }\n\n // noinspection JSUnusedGlobalSymbols\n interface TypographyVariantsOptions {\n label?: CSSProperties;\n groupHeading?: CSSProperties;\n }\n}\n\ndeclare module '@mui/material/Typography' {\n // noinspection JSUnusedGlobalSymbols\n interface TypographyPropsVariantOverrides {\n label: true;\n groupHeading: true;\n }\n}\n\n// ----------------------------------------------------------------------\n\nconst typography: TypographyVariantsOptions = {\n fontFamily: ['Inter', 'sans-serif', 'Helvetica', 'Arial', 'Roboto', '\"Helvetica Neue\"'].join(','),\n h1: {\n fontSize: '2rem', // 32px\n fontWeight: 700,\n lineHeight: '40px'\n },\n h2: {\n fontSize: '1.75rem', // 28px\n fontWeight: 600,\n lineHeight: '34px'\n },\n h3: {\n fontSize: '1.625rem', // 26px\n fontWeight: 600,\n lineHeight: '32px'\n },\n h4: {\n fontSize: '1.5rem', // 24px\n fontWeight: 700,\n lineHeight: '30px'\n },\n h5: {\n fontSize: '1.375rem', // 22px\n fontWeight: 700,\n lineHeight: '28px'\n },\n h6: {\n fontSize: '1.125rem', // 18px\n fontWeight: 700,\n lineHeight: '24px'\n },\n subtitle1: {\n fontSize: '1rem', // 16px\n fontWeight: 600,\n lineHeight: '20px'\n },\n subtitle2: {\n fontSize: '0.875rem', // 14px\n fontWeight: 600,\n lineHeight: '18px'\n },\n body1: {\n fontSize: '0.875rem', // 14px\n fontWeight: 400,\n lineHeight: '20px'\n },\n body2: {\n fontSize: '0.75rem', // 12px\n fontWeight: 400,\n lineHeight: '18px'\n },\n groupHeading: {\n fontSize: '0.875rem', // 14px\n fontWeight: 600,\n lineHeight: '20px'\n },\n label: {\n fontSize: '0.875rem', // 14px\n fontWeight: 400,\n lineHeight: '20px'\n },\n caption: {\n fontSize: '0.75rem', // 12px\n fontWeight: 500,\n lineHeight: '18px'\n },\n overline: {\n fontSize: '0.8125rem', // 13px\n fontWeight: 700,\n lineHeight: '20px'\n },\n button: {\n fontSize: '0.8125rem', // 13px\n fontWeight: 700,\n lineHeight: '20px'\n }\n};\n\nexport default typography;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ComponentType } from 'react';\nimport { useLayoutEffect, useState } from 'react';\nimport { buildForm } from '../utils';\nimport type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';\nimport type { RendererStyling } from '../stores/rendererStylingStore';\nimport { useRendererStylingStore } from '../stores/rendererStylingStore';\nimport type { QItemOverrideComponentProps, SdcUiOverrideComponentProps } from '../interfaces';\n\n/**\n * React hook wrapping around the buildForm() function to build a form from a questionnaire and an optional QuestionnaireResponse.\n * @see buildForm() for more information.\n *\n * @param questionnaire - Questionnaire to be rendered\n * @param questionnaireResponse - Pre-populated/draft/loaded QuestionnaireResponse to be rendered (optional)\n * @param readOnly - Applies read-only mode to all items in the form view\n * @param terminologyServerUrl - Terminology server url to fetch terminology. If not provided, the default terminology server will be used. (optional)\n * @param additionalVariables - Additional key-value pair of SDC variables `Record<name, variable extension>` for testing (optional)\n * @param rendererStylingOptions - Renderer styling to be applied to the form. See docs for styling options. (optional)\n * @param qItemOverrideComponents - FIXME add comment\n * @param sdcUiOverrideComponents - FIXME add comment\n *\n *\n * @author Sean Fong\n */\nfunction useBuildForm(\n questionnaire: Questionnaire,\n questionnaireResponse?: QuestionnaireResponse,\n readOnly?: boolean,\n terminologyServerUrl?: string,\n additionalVariables?: Record<string, object>,\n rendererStylingOptions?: RendererStyling,\n qItemOverrideComponents?: Record<string, ComponentType<QItemOverrideComponentProps>>,\n sdcUiOverrideComponents?: Record<string, ComponentType<SdcUiOverrideComponentProps>>\n) {\n const [isBuilding, setIsBuilding] = useState(true);\n\n const setRendererStyling = useRendererStylingStore.use.setRendererStyling();\n\n useLayoutEffect(() => {\n // Set optional renderer styling\n if (rendererStylingOptions) {\n setRendererStyling(rendererStylingOptions);\n }\n\n buildForm(\n questionnaire,\n questionnaireResponse,\n readOnly,\n terminologyServerUrl,\n additionalVariables,\n qItemOverrideComponents,\n sdcUiOverrideComponents\n ).then(() => {\n setIsBuilding(false);\n });\n }, [\n questionnaire,\n questionnaireResponse,\n readOnly,\n terminologyServerUrl,\n additionalVariables,\n rendererStylingOptions,\n qItemOverrideComponents,\n sdcUiOverrideComponents,\n setRendererStyling\n ]);\n\n return isBuilding;\n}\n\nexport default useBuildForm;\n","/*\n * Copyright 2024 Commonwealth Scientific and Industrial Research\n * Organisation (CSIRO) ABN 41 687 119 230.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// @ts-ignore\nimport React from 'react';\nimport type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';\nimport { BaseRenderer } from '../../components';\nimport { QueryClientProvider } from '@tanstack/react-query';\nimport useRendererQueryClient from '../../hooks/useRendererQueryClient';\nimport type Client from 'fhirclient/lib/Client';\nimport useInitialiseForm from '../../hooks/useInitialiseForm';\nimport Box from '@mui/material/Box';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport Typography from '@mui/material/Typography';\nimport RendererThemeProvider from '../../theme/RendererThemeProvider';\n\nexport interface InitialiseFormWrapperProps {\n questionnaire: Questionnaire;\n questionnaireResponse?: QuestionnaireResponse;\n readOnly?: boolean;\n terminologyServerUrl?: string;\n additionalVariables?: Record<string, object>;\n fhirClient?: Client;\n}\n\n/**\n * This is a one-to-one replacement for the SmartFormsRenderer for demo purposes.\n * Instead of using this React component, define your own wrapper component that uses the BaseRenderer directly.\n * Things to note:\n * - It is required to wrap the BaseRenderer with the QueryClientProvider to make requests.\n * - You can wrap the BaseRenderer with the RendererThemeProvider to apply the default renderer theme used in Smart Forms. Optionally, you can define your own ThemeProvider https://mui.com/material-ui/customization/theming/.\n * - Make your buildForm() call in a button click or other event handler. Alternatively, you can use the useInitialiseForm hook to initialise the form.\n * - Make your own initialiseFhirClient() call in a button click or other event handler. Alternatively, you can use the useInitialiseForm hook to initialise the form.\n * - The initialised FHIRClient is only used for further FHIR calls. It does not provide pre-population capabilities.\n *\n * For button click usage examples of buildForm(), see:\n * - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx\n * - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonForStorybook.tsx\n * - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopWrapperForStorybook.tsx\n * - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopButtonForStorybook.tsx\n *\n * @author Sean Fong\n */\nfunction InitialiseFormWrapperForStorybook(props: InitialiseFormWrapperProps) {\n const {\n questionnaire,\n questionnaireResponse,\n readOnly,\n terminologyServerUrl,\n additionalVariables,\n fhirClient\n } = props;\n\n // The renderer requires a @tanstack/react-query QueryClientProvider to make requests\n const queryClient = useRendererQueryClient();\n\n /**\n * The useInitialiseForm hook provides initialisation logic for the form\n * Alternatively (and recommended to do so), you can initialise your form via a button click or other event handler.\n *\n * @see {@link https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/BuildFormButtonForStorybook.tsx} for button click usage examples.\n */\n const isInitialising = useInitialiseForm(\n questionnaire,\n questionnaireResponse,\n readOnly,\n terminologyServerUrl,\n additionalVariables,\n fhirClient\n );\n\n // Free feel to customise your loading animation here\n if (isInitialising) {\n return (\n <Box display=\"flex\" alignItems=\"center\" columnGap={2}>\n <CircularProgress />\n <Typography>Loading questionnaire...</Typography>\n </Box>\n );\n }\n\n return (\n <RendererThemeProvider>\n <QueryClientProvider client={queryClient}>\n <BaseRenderer />\n </QueryClientProvider>\n </RendererThemeProvider>\n );\n}\n\nexport default InitialiseFormWrapperForStorybook;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,SAAA,UAAe;MACX;MACA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MAEA;MACA;;AAUJ,aAAgB,aAAa,SAAoC,KAAW;AACxE,UAAI,CAAC,WAAW,CAAC,QAAQ;AAAW,eAAO;AAC3C,UAAI,YAAY,QAAQ,UAAU,OAAO,CAAC,GAAG,GAAG,QAAO;AACnD,YAAI,EAAE,QAAQ;AAAK,iBAAO;AAC1B,eAAO;MACX,CAAC;AACD,UAAI,aAAa,UAAU,SAAS;AAAG,eAAO,UAAU,CAAC;AACzD,aAAO;IACX;AARA,IAAAA,SAAA,eAAA;AAgBA,aAAgB,cAAc,SAAoC,KAAW;AACzE,UAAI,CAAC,WAAW,CAAC,QAAQ;AAAW,eAAO;AAC3C,UAAI,YAAY,QAAQ,UAAU,OAAO,CAAC,GAAG,GAAG,QAAO;AACnD,YAAI,EAAE,QAAQ;AA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AgB,MAAM;AAEpB,QAAI,wBAAwB;AAC1B,yBAAmB,sBAAsB;AAAA,IAC3C;AAEA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,MAAM;AACX,oBAAc,KAAK;AAAA,IACrB,CAAC;AAAA,EACH,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEA,IAAO,uBAAQ;;;AClEf,IAAAC,sBAAoC;AAIpC,IAAAC,eAAgB;AAChB,IAAAC,2BAA6B;AAC7B,IAAAC,sBAAuB;AA6DjB,IAAAC,wBAAA;AA/BN,SAAS,kCAAkC,OAAmC;AAC5E,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAGJ,QAAM,cAAc,+BAAuB;AAQ3C,QAAM,iBAAiB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGA,MAAI,gBAAgB;AAClB,WACE,gDAAC,aAAAC,SAAA,EAAI,SAAQ,QAAO,YAAW,UAAS,WAAW,GACjD;AAAA,qDAAC,yBAAAC,SAAA,EAAiB;AAAA,MAClB,+CAAC,oBAAAC,SAAA,EAAW,sCAAwB;AAAA,OACtC;AAAA,EAEJ;AAEA,SACE,+CAAC,iCACC,yDAAC,2CAAoB,QAAQ,aAC3B,yDAAC,wBAAa,GAChB,GACF;AAEJ;AAEA,IAAO,4CAAQ;","names":["exports","_a","structuredDataCapture","getSliderStepValue","getChoiceOrientation","getPreferredTerminologyServer","exports","exports","exports","Fragment","exports","module","exports","module","exports","module","exports","module","exports","module","values","location","exports","module","isValidElement","location","i","checker","exports","module","location","exports","module","import_vanilla","item","import_fhirpath","import_r4","import_fhirpath","fhirpath","fhirpath_r4_model","import_fhirpath","import_r4","htmlParse","import_lodash","isEqual","_a","differenceWith","import_lodash","isEqual","fhirpath","fhirpath_r4_model","dayjs","import_fhirpath","import_r4","fhirpath","fhirpath_r4_model","location","import_fhirpath","import_r4","fhirpath","fhirpath_r4_model","fhirPathEvalResult","fhirpath","fhirpath_r4_model","import_fhir_sdc_helpers","isTab","import_fhir_sdc_helpers","_a","isTab","_a","_b","FHIR","import_vanilla","import_fhir_sdc_helpers","import_dayjs","dayjs","import_vanilla","client","import_vanilla","client","import_lodash","difference","intersection","isTab","qItem","isEqual","constructGroupItem","constructSingleItem","import_Box","import_CircularProgress","import_Typography","import_react_query","import_react","import_Fade","import_react","import_material","import_react","import_fhir_sdc_helpers","import_react","Box","FormControlLabel","import_react","import_Box","import_Typography","import_react","import_react","import_fhir_sdc_helpers","import_react","import_html_react_parser","htmlParse","import_jsx_runtime","ItemTextSwitcher","ReactMarkdown","parseStyleToJs","import_jsx_runtime","import_fhir_sdc_helpers","import_react","import_jsx_runtime","Typography","import_react","import_Typography","import_jsx_runtime","QuestionMarkOutlinedIcon","Popover","Typography","import_jsx_runtime","import_jsx_runtime","GroupHeading","Box","Typography","import_styles","Card","import_react","import_Box","import_react","import_Box","import_jsx_runtime","Iconify","Box","import_jsx_runtime","Button","import_Button","import_jsx_runtime","Button","import_react","import_jsx_runtime","TabButtonsWrapper","Box","import_react","import_Table","import_TableRow","import_styles","TableCell","TableRow","import_TableCell","import_TableBody","import_Divider","import_Box","import_Button","import_jsx_runtime","Box","Button","AddIcon","import_TableRow","import_TableCell","import_styles","Checkbox","import_jsx_runtime","TableCell","import_react","import_Typography","import_react","import_FormControlLabel","import_styles","Radio","import_jsx_runtime","FormControlLabel","import_jsx_runtime","import_styles","import_Typography","FormGroup","RadioGroup","Typography","import_Box","import_jsx_runtime","Fade","SyncIcon","import_material","import_Button","import_colors","import_Fade","import_jsx_runtime","Fade","Button","import_jsx_runtime","Box","import_react","import_Typography","import_Box","import_styles","Box","import_jsx_runtime","DisplayInstructions","Typography","import_jsx_runtime","Grid","import_react","import_Box","import_Typography","import_jsx_runtime","ItemLabel","Box","Typography","import_jsx_runtime","import_react","import_styles","TextField","import_Typography","import_jsx_runtime","Typography","import_jsx_runtime","Autocomplete","import_jsx_runtime","import_fhir_sdc_helpers","import_jsx_runtime","Typography","import_jsx_runtime","import_FormControlLabel","import_jsx_runtime","FormControlLabel","import_jsx_runtime","import_material","import_jsx_runtime","import_jsx_runtime","import_react","import_react","import_react_query","import_Autocomplete","import_Fade","import_jsx_runtime","Autocomplete","SearchIcon","CircularProgress","Fade","Tooltip","InfoIcon","WarningAmberIcon","DoneIcon","ErrorIcon","import_jsx_runtime","import_react","import_react","import_fhirpath","import_r4","_a","fhirpath","fhirpath_r4_model","import_Autocomplete","import_styles","import_Box","Box","ListItemIcon","import_Typography","import_jsx_runtime","Autocomplete","ErrorOutlineIcon","Typography","import_jsx_runtime","import_react","import_Typography","import_ErrorOutline","import_Box","import_jsx_runtime","Box","ErrorOutlineIcon","Typography","import_jsx_runtime","import_react","import_ErrorOutline","import_Typography","import_material","import_jsx_runtime","ErrorOutlineIcon","Typography","import_jsx_runtime","import_Typography","import_jsx_runtime","Typography","import_Autocomplete","import_jsx_runtime","Autocomplete","import_jsx_runtime","import_Autocomplete","import_Typography","import_jsx_runtime","Autocomplete","Typography","import_jsx_runtime","import_react","import_Box","import_Autocomplete","import_Search","import_CircularProgress","import_Fade","import_Tooltip","import_Info","import_WarningAmber","import_Done","import_Error","import_jsx_runtime","Box","Autocomplete","SearchIcon","CircularProgress","Fade","Tooltip","InfoIcon","WarningAmberIcon","DoneIcon","ErrorIcon","import_jsx_runtime","import_react","import_lodash","import_react","import_Box","import_FormControlLabel","import_jsx_runtime","import_jsx_runtime","Box","FormControlLabel","import_material","import_jsx_runtime","import_jsx_runtime","openLabelChecked","debounce","import_react","import_Box","import_jsx_runtime","Box","import_jsx_runtime","import_jsx_runtime","import_react","import_lodash","import_ErrorOutline","import_Typography","import_material","import_jsx_runtime","ErrorOutlineIcon","Typography","import_jsx_runtime","openLabelChecked","debounce","import_react","import_ErrorOutline","import_Typography","import_jsx_runtime","ErrorOutlineIcon","Typography","import_jsx_runtime","import_jsx_runtime","import_Typography","import_react","import_lodash","import_jsx_runtime","InputAdornment","import_react","import_jsx_runtime","debounce","input","import_react","import_Box","import_FormControlLabel","import_jsx_runtime","BooleanField","Box","FormControlLabel","import_Box","import_react","import_jsx_runtime","Box","import_jsx_runtime","MuiTimePicker","import_dayjs","import_jsx_runtime","dayjs","import_react","import_lodash","import_InputAdornment","import_TextField","TextField","import_jsx_runtime","TextField","InputAdornment","import_jsx_runtime","debounce","input","import_react","import_jsx_runtime","DisplayItem","Divider","import_react","import_lodash","import_InputAdornment","import_jsx_runtime","InputAdornment","import_react","import_Box","import_jsx_runtime","debounce","Box","import_react","import_lodash","import_InputAdornment","import_jsx_runtime","InputAdornment","import_jsx_runtime","debounce","input","import_react","import_dayjs","dayjs","import_dayjs","dayjs","import_react","import_react","import_dayjs","import_AdapterDayjs","import_jsx_runtime","IconButton","EventIcon","import_jsx_runtime","DatePicker","dayjs","import_Tooltip","import_jsx_runtime","Tooltip","import_jsx_runtime","getMinValue","getMaxValue","import_Typography","import_Box","import_jsx_runtime","Box","Typography","import_styles","import_material","Slider","import_Typography","import_jsx_runtime","Typography","import_jsx_runtime","Stack","getMinValue","getMaxValue","import_Box","import_jsx_runtime","Box","import_react","import_lodash","import_InputAdornment","import_jsx_runtime","InputAdornment","import_react","import_jsx_runtime","debounce","import_react","import_lodash","import_react","import_material","import_material","import_styles","import_material","import_jsx_runtime","import_jsx_runtime","AttachmentFileCollector","import_Typography","import_Box","import_Stack","import_Typography","import_Box","import_Stack","import_InputAdornment","import_Tooltip","import_jsx_runtime","Box","Typography","Stack","InputAdornment","Tooltip","CheckIcon","DangerousIcon","import_jsx_runtime","Stack","Typography","Box","import_jsx_runtime","import_react_dnd_html5_backend","import_react_dnd","import_jsx_runtime","debounce","url","fileName","import_react","import_Stack","import_dayjs","import_dayjs","inputMatchRegex","dayjs","import_dayjs","dayjs","import_Tooltip","import_Box","import_colors","import_Typography","import_jsx_runtime","Tooltip","Box","Select","MenuItem","Typography","import_Stack","import_jsx_runtime","Stack","import_jsx_runtime","dayjs","is24HourNotation","dateInput","timeInput","periodInput","Stack","import_react","import_lodash","import_Box","import_InputAdornment","import_jsx_runtime","InputAdornment","import_Autocomplete","import_jsx_runtime","Autocomplete","import_Autocomplete","import_Box","import_Typography","import_jsx_runtime","Box","Autocomplete","Typography","import_react","import_jsx_runtime","_a","_b","_c","debounce","Box","import_jsx_runtime","Typography","import_react","import_Box","import_jsx_runtime","Box","qItem","import_jsx_runtime","import_styles","import_material","import_Box","Box","Accordion","import_Box","import_jsx_runtime","ExpandMoreIcon","Box","AccordionDetails","import_jsx_runtime","import_jsx_runtime","qrItem","import_IconButton","import_Tooltip","import_jsx_runtime","Tooltip","IconButton","RemoveCircleOutlineIcon","import_TableCell","import_Box","import_jsx_runtime","TableCell","Box","DragIndicator","TableRow","import_react_beautiful_dnd","import_jsx_runtime","TableBody","import_styles","import_Accordion","Accordion","import_ExpandMore","import_AccordionDetails","import_jsx_runtime","AccordionSummary","ExpandMoreIcon","AccordionDetails","Divider","TableContainer","Paper","Table","TableHead","TableRow","TableCell","TableBody","import_react","import_react","import_jsx_runtime","_a","import_react","import_react","import_Card","import_Divider","t","e","import_react","React","import_react","import_react","mapper","TransitionGroup","childFactory","React","PropTypes","import_Stack","import_styles","import_Tooltip","Tooltip","Stack","import_Box","import_IconButton","import_RemoveCircleOutline","import_jsx_runtime","IconButton","RemoveCircleOutlineIcon","import_jsx_runtime","Box","import_Box","import_Button","import_Add","import_jsx_runtime","Box","Button","AddIcon","import_AccordionSummary","import_ExpandMore","import_AccordionDetails","import_jsx_runtime","Card","AccordionSummary","ExpandMoreIcon","AccordionDetails","Divider","Collapse","import_jsx_runtime","import_Box","import_Button","import_Add","import_jsx_runtime","AddItemButton","Box","Button","AddIcon","AddItemButton_default","import_Box","import_IconButton","import_RemoveCircleOutline","import_jsx_runtime","IconButton","RemoveCircleOutlineIcon","import_jsx_runtime","Box","import_Collapse","import_react","import_jsx_runtime","Collapse","AddItemButton_default","import_react","import_Divider","import_Paper","import_TableContainer","import_Table","import_TableBody","import_TableCell","import_TableHead","import_TableRow","import_react","import_Typography","import_jsx_runtime","Typography","import_jsx_runtime","Table","TableHead","TableRow","TableCell","TableBody","import_jsx_runtime","_a","TableContainer","Paper","Divider","import_jsx_runtime","import_AccordionSummary","import_ExpandMore","import_AccordionDetails","import_Divider","import_react","import_Box","import_Typography","import_styles","Fab","import_jsx_runtime","import_jsx_runtime","import_jsx_runtime","PageButtonsWrapper","Box","Typography","import_jsx_runtime","React","AccordionSummary","ExpandMoreIcon","AccordionDetails","Divider","qItem","import_jsx_runtime","import_react","import_Box","import_Card","import_styles","List","import_Divider","import_react","import_Collapse","import_react","import_Box","import_Typography","import_jsx_runtime","FormBodySingleTab","ListItemButton","ListItemText","Box","Typography","import_jsx_runtime","FormBodyTabList","isTab","Collapse","import_Box","import_Typography","import_material","import_ExpandMore","import_jsx_runtime","Box","Typography","ExpandLess","ExpandMore","import_react","import_jsx_runtime","FormBodyTabListWrapper","Card","Box","Divider","import_jsx_runtime","TabContext","isTab","TabPanel","import_react","import_Stack","import_react","import_Accordion","import_AccordionDetails","import_AccordionSummary","import_Box","import_Typography","import_ExpandMore","import_jsx_runtime","FormBodySingleCollapsible","Accordion","AccordionSummary","ExpandMoreIcon","Box","Typography","AccordionDetails","import_jsx_runtime","import_jsx_runtime","Stack","isTab","import_styles","useMediaQuery","import_Box","import_react","import_material","import_TabContext","import_TabPanel","import_jsx_runtime","TabContext","isPage","TabPanel","import_jsx_runtime","Box","import_react","import_Grid","import_TabContext","import_TabPanel","import_jsx_runtime","headerQItems","pageQItems","footerQItems","Grid","TabContext","isPage","TabPanel","import_material","constructGroupItem","constructSingleItem","import_jsx_runtime","Fade","import_styles","import_jsx_runtime","GlobalStyles","import_styles","import_colors","Card","Paper","import_styles","import_styles","import_colors","Table","import_styles","Button","Autocomplete","import_styles","import_colors","Accordion","Accordion","Card","Table","Paper","Button","Autocomplete","import_styles","import_colors","import_jsx_runtime","MUIThemeProvider","import_jsx_runtime","Box","CircularProgress","Typography","import_react","import_react_query","import_Box","import_CircularProgress","import_Typography","import_jsx_runtime","Box","CircularProgress","Typography"]}