@aehrc/smart-forms-renderer 0.27.2 → 0.27.4

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 (179) hide show
  1. package/.storybook/main.ts +2 -1
  2. package/.storybook/preview.ts +6 -1
  3. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.d.ts +3 -2
  4. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js +9 -17
  5. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js.map +1 -1
  6. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js +12 -9
  7. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js.map +1 -1
  8. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.d.ts +2 -2
  9. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js +7 -9
  10. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js.map +1 -1
  11. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +12 -8
  12. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -1
  13. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.d.ts +2 -1
  14. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js +3 -3
  15. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js.map +1 -1
  16. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js +6 -4
  17. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js.map +1 -1
  18. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.d.ts +2 -1
  19. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.js +3 -3
  20. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.js.map +1 -1
  21. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.d.ts +2 -2
  22. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js +5 -7
  23. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js.map +1 -1
  24. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js +4 -4
  25. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js.map +1 -1
  26. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.d.ts +2 -1
  27. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js +2 -3
  28. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js.map +1 -1
  29. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js +5 -3
  30. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js.map +1 -1
  31. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.d.ts +2 -1
  32. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.js +3 -3
  33. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.js.map +1 -1
  34. package/lib/components/FormComponents/DecimalItem/DecimalItem.js +1 -1
  35. package/lib/components/FormComponents/GroupItem/TabButtonsWrapper.js +20 -20
  36. package/lib/components/FormComponents/GroupItem/TabButtonsWrapper.js.map +1 -1
  37. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.d.ts +3 -2
  38. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js +7 -19
  39. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js.map +1 -1
  40. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js +40 -40
  41. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js.map +1 -1
  42. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js +15 -3
  43. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js.map +1 -1
  44. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.d.ts +2 -1
  45. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js +3 -3
  46. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js.map +1 -1
  47. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js +27 -26
  48. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js.map +1 -1
  49. package/lib/components/FormComponents/StringItem/StringField.js +1 -1
  50. package/lib/components/FormComponents/StringItem/StringField.js.map +1 -1
  51. package/lib/hooks/useInitialiseRenderer.js +1 -1
  52. package/lib/hooks/useInitialiseRenderer.js.map +1 -1
  53. package/lib/hooks/useNextAndPreviousVisibleTabs.d.ts +7 -0
  54. package/lib/hooks/useNextAndPreviousVisibleTabs.js +63 -0
  55. package/lib/hooks/useNextAndPreviousVisibleTabs.js.map +1 -0
  56. package/lib/hooks/useNextPreviousVisibleTabs.d.ts +6 -0
  57. package/lib/hooks/useNextPreviousVisibleTabs.js +63 -0
  58. package/lib/hooks/useNextPreviousVisibleTabs.js.map +1 -0
  59. package/lib/index.d.ts +0 -7
  60. package/lib/index.js +0 -24
  61. package/lib/index.js.map +1 -1
  62. package/lib/utils/choice.d.ts +1 -7
  63. package/lib/utils/choice.js +10 -20
  64. package/lib/utils/choice.js.map +1 -1
  65. package/lib/utils/enableWhen.js +5 -7
  66. package/lib/utils/enableWhen.js.map +1 -1
  67. package/lib/utils/index.d.ts +1 -0
  68. package/lib/utils/index.js +1 -0
  69. package/lib/utils/index.js.map +1 -1
  70. package/lib/utils/openChoice.d.ts +9 -4
  71. package/lib/utils/openChoice.js +47 -78
  72. package/lib/utils/openChoice.js.map +1 -1
  73. package/lib/utils/tabs.d.ts +0 -21
  74. package/lib/utils/tabs.js +0 -51
  75. package/lib/utils/tabs.js.map +1 -1
  76. package/package.json +4 -4
  77. package/src/components/FormComponents/ChoiceItems/CheckboxOptionList.tsx +82 -0
  78. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.tsx +23 -52
  79. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.tsx +15 -9
  80. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.tsx +17 -19
  81. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx +13 -8
  82. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.tsx +5 -4
  83. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx +6 -2
  84. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.tsx +5 -1
  85. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx +9 -16
  86. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +4 -4
  87. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.tsx +4 -3
  88. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx +5 -2
  89. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.tsx +5 -1
  90. package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +1 -1
  91. package/src/components/FormComponents/GroupItem/TabButtonsWrapper.tsx +28 -25
  92. package/src/components/FormComponents/ItemParts/{RadioAnswerOptionButtons.tsx → RadioOptionList.tsx} +7 -7
  93. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.tsx +18 -50
  94. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx +70 -68
  95. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.tsx +110 -0
  96. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.tsx +188 -0
  97. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.tsx +46 -19
  98. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.tsx +5 -3
  99. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.tsx +37 -29
  100. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.tsx +104 -0
  101. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetItem.tsx +156 -0
  102. package/src/components/FormComponents/StringItem/StringField.tsx +1 -1
  103. package/src/hooks/useInitialiseRenderer.ts +1 -1
  104. package/src/hooks/useNextAndPreviousVisibleTabs.ts +86 -0
  105. package/src/hooks/useOpenLabel.ts +43 -0
  106. package/src/index.ts +0 -21
  107. package/src/stories/BuildFormWrapper.tsx +57 -0
  108. package/src/stories/assets/questionnaires/QAdvancedAdditionalDisplayContent.ts +83 -0
  109. package/src/stories/assets/questionnaires/QAdvancedControlAppearance.ts +294 -0
  110. package/src/stories/assets/questionnaires/QAdvancedOther.ts +495 -0
  111. package/src/stories/assets/questionnaires/QAdvancedTextApperance.ts +188 -0
  112. package/src/stories/assets/questionnaires/QAttachment.ts +38 -0
  113. package/src/stories/assets/questionnaires/QBehaviorCalculations.ts +645 -0
  114. package/src/stories/assets/questionnaires/QBehaviorChoiceRestriction.ts +281 -0
  115. package/src/stories/assets/questionnaires/QBehaviorOther.ts +1149 -0
  116. package/src/stories/assets/questionnaires/QBehaviorValueConstraints.ts +508 -0
  117. package/src/stories/assets/questionnaires/QBoolean.ts +130 -0
  118. package/src/stories/assets/questionnaires/QChoice.ts +137 -0
  119. package/src/stories/assets/questionnaires/QDate.ts +56 -0
  120. package/src/stories/assets/questionnaires/QDateTime.ts +56 -0
  121. package/src/stories/assets/questionnaires/QDecimal.ts +56 -0
  122. package/src/stories/assets/questionnaires/QDisplay.ts +38 -0
  123. package/src/stories/assets/questionnaires/QGroup.ts +52 -0
  124. package/src/stories/assets/questionnaires/QInteger.ts +119 -0
  125. package/src/stories/assets/questionnaires/QItemControlDisplay.ts +114 -0
  126. package/src/stories/assets/questionnaires/QItemControlGroup.ts +419 -0
  127. package/src/stories/assets/questionnaires/QItemControlQuestion.ts +1271 -0
  128. package/src/stories/assets/questionnaires/QOpenChoice.ts +151 -0
  129. package/src/stories/assets/questionnaires/QQuantity.ts +38 -0
  130. package/src/stories/assets/questionnaires/QReference.ts +38 -0
  131. package/src/stories/assets/questionnaires/QSingleItems.ts +251 -0
  132. package/src/stories/assets/questionnaires/QString.ts +131 -0
  133. package/src/stories/assets/questionnaires/QText.ts +169 -0
  134. package/src/stories/assets/questionnaires/QTime.ts +38 -0
  135. package/src/stories/assets/questionnaires/QUrl.ts +38 -0
  136. package/src/stories/assets/questionnaires/index.ts +44 -0
  137. package/src/stories/itemTypes/Attachment.stories.tsx +39 -0
  138. package/src/stories/itemTypes/Boolean.stories.tsx +72 -0
  139. package/src/stories/{MedicalHistoryTable.stories.tsx → itemTypes/Choice.stories.tsx} +32 -26
  140. package/src/stories/itemTypes/Date.stories.tsx +46 -0
  141. package/src/stories/itemTypes/DateTime.stories.tsx +45 -0
  142. package/src/stories/itemTypes/Decimal.stories.tsx +56 -0
  143. package/src/stories/itemTypes/Display.stories.tsx +39 -0
  144. package/src/stories/itemTypes/Group.stories.tsx +39 -0
  145. package/src/stories/itemTypes/Integer.stories.tsx +55 -0
  146. package/src/stories/itemTypes/OpenChoice.stories.tsx +64 -0
  147. package/src/stories/itemTypes/Quantity.stories.tsx +39 -0
  148. package/src/stories/itemTypes/Reference.stories.tsx +39 -0
  149. package/src/stories/itemTypes/String.stories.tsx +51 -0
  150. package/src/stories/itemTypes/Text.stories.tsx +51 -0
  151. package/src/stories/itemTypes/Time.stories.tsx +39 -0
  152. package/src/stories/itemTypes/Url.stories.tsx +39 -0
  153. package/src/stories/sdc/AdvancedAdditionalDisplayContent.stories.tsx +45 -0
  154. package/src/stories/sdc/AdvancedControlAppearance.stories.tsx +51 -0
  155. package/src/stories/sdc/AdvancedOther.stories.tsx +76 -0
  156. package/src/stories/sdc/AdvancedTextAppearance.stories.tsx +69 -0
  157. package/src/stories/sdc/BehaviorCalculations.stories.tsx +69 -0
  158. package/src/stories/sdc/BehaviorChoiceRestriction.stories.tsx +76 -0
  159. package/src/stories/sdc/BehaviorOther.stories.tsx +90 -0
  160. package/src/stories/sdc/BehaviorValueConstraints.stories.tsx +88 -0
  161. package/src/stories/sdc/ItemControlDisplay.stories.tsx +39 -0
  162. package/src/stories/sdc/ItemControlGroup.stories.tsx +55 -0
  163. package/src/stories/sdc/ItemControlQuestion.stories.tsx +118 -0
  164. package/src/utils/buildForm.ts +23 -0
  165. package/src/utils/choice.ts +16 -23
  166. package/src/utils/enableWhen.ts +5 -7
  167. package/src/utils/index.ts +1 -0
  168. package/src/utils/openChoice.ts +83 -98
  169. package/src/utils/tabs.ts +0 -75
  170. package/vite.config.ts +23 -0
  171. package/doctor-storybook.log +0 -18
  172. package/src/stories/SmartFormsRenderer.stories.ts +0 -139
  173. package/src/stories/assets/QItems-and-QRItems/QR_GTableMedicalHistory.json +0 -80
  174. package/src/stories/assets/QItems-and-QRItems/Q_GTableMedicalHistory.json +0 -109
  175. package/src/stories/assets/Qs-and-QRs/Q715.json +0 -15086
  176. package/src/stories/assets/Qs-and-QRs/QDev715.json +0 -16081
  177. package/src/stories/assets/Qs-and-QRs/QTestGrid.json +0 -411
  178. package/src/stories/assets/Qs-and-QRs/R715.json +0 -311
  179. package/src/stories/assets/Qs-and-QRs/RTestGrid.json +0 -34
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Copyright 2024 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import type { Meta, StoryObj } from '@storybook/react';
19
+ import BuildFormWrapper from '../BuildFormWrapper';
20
+ import {
21
+ qCalculatedExpressionBMICalculator,
22
+ qCalculatedExpressionCvdRiskCalculator,
23
+ qInitialExpression,
24
+ qLaunchContext,
25
+ qVariable
26
+ } from '../assets/questionnaires';
27
+
28
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
29
+ const meta = {
30
+ title: 'Component/SDC/9.1.3 Form Behavior Calculations',
31
+ component: BuildFormWrapper,
32
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
33
+ tags: []
34
+ } satisfies Meta<typeof BuildFormWrapper>;
35
+
36
+ export default meta;
37
+ type Story = StoryObj<typeof meta>;
38
+
39
+ // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
40
+
41
+ export const LaunchContext: Story = {
42
+ args: {
43
+ questionnaire: qLaunchContext
44
+ }
45
+ };
46
+
47
+ export const Variable: Story = {
48
+ args: {
49
+ questionnaire: qVariable
50
+ }
51
+ };
52
+
53
+ export const InitialExpression: Story = {
54
+ args: {
55
+ questionnaire: qInitialExpression
56
+ }
57
+ };
58
+
59
+ export const CalculatedExpressionBMICalculator: Story = {
60
+ args: {
61
+ questionnaire: qCalculatedExpressionBMICalculator
62
+ }
63
+ };
64
+
65
+ export const CalculatedExpressionCvdRiskCalculator: Story = {
66
+ args: {
67
+ questionnaire: qCalculatedExpressionCvdRiskCalculator
68
+ }
69
+ };
@@ -0,0 +1,76 @@
1
+ /*
2
+ * Copyright 2024 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import type { Meta, StoryObj } from '@storybook/react';
19
+ import BuildFormWrapper from '../BuildFormWrapper';
20
+ import {
21
+ qAnswerExpression,
22
+ qAnswerOption,
23
+ qAnswerValueSet,
24
+ qReadOnlyDuplicate,
25
+ qRepeatsDuplicate,
26
+ qRequiredDuplicate
27
+ } from '../assets/questionnaires';
28
+
29
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
30
+ const meta = {
31
+ title: 'Component/SDC/9.1.2 Form Behavior Choice Restriction',
32
+ component: BuildFormWrapper,
33
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
34
+ tags: ['autodocs']
35
+ } satisfies Meta<typeof BuildFormWrapper>;
36
+
37
+ export default meta;
38
+ type Story = StoryObj<typeof meta>;
39
+
40
+ // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
41
+
42
+ export const AnswerOption: Story = {
43
+ args: {
44
+ questionnaire: qAnswerOption
45
+ }
46
+ };
47
+
48
+ export const AnswerValueSet: Story = {
49
+ args: {
50
+ questionnaire: qAnswerValueSet
51
+ }
52
+ };
53
+
54
+ export const AnswerExpression: Story = {
55
+ args: {
56
+ questionnaire: qAnswerExpression
57
+ }
58
+ };
59
+
60
+ export const Required: Story = {
61
+ args: {
62
+ questionnaire: qRequiredDuplicate
63
+ }
64
+ };
65
+
66
+ export const Repeats: Story = {
67
+ args: {
68
+ questionnaire: qRepeatsDuplicate
69
+ }
70
+ };
71
+
72
+ export const ReadOnly: Story = {
73
+ args: {
74
+ questionnaire: qReadOnlyDuplicate
75
+ }
76
+ };
@@ -0,0 +1,90 @@
1
+ /*
2
+ * Copyright 2024 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import type { Meta, StoryObj } from '@storybook/react';
19
+ import BuildFormWrapper from '../BuildFormWrapper';
20
+ import {
21
+ qEnableBehaviorAll,
22
+ qEnableBehaviorAny,
23
+ qEnableWhen,
24
+ qEnableWhenExpressionSimple,
25
+ qEnableWhenExpressionTabs,
26
+ qInitialRepeats,
27
+ qInitialSingle,
28
+ qText
29
+ } from '../assets/questionnaires'; // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
30
+
31
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
32
+ const meta = {
33
+ title: 'Component/SDC/9.1.4 Form Behavior Other Control',
34
+ component: BuildFormWrapper,
35
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
36
+ tags: []
37
+ } satisfies Meta<typeof BuildFormWrapper>;
38
+
39
+ export default meta;
40
+ type Story = StoryObj<typeof meta>;
41
+
42
+ // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
43
+
44
+ export const InitialSingle: Story = {
45
+ args: {
46
+ questionnaire: qInitialSingle
47
+ }
48
+ };
49
+
50
+ export const InitialRepeats: Story = {
51
+ args: {
52
+ questionnaire: qInitialRepeats
53
+ }
54
+ };
55
+
56
+ export const EnableWhen: Story = {
57
+ args: {
58
+ questionnaire: qEnableWhen
59
+ }
60
+ };
61
+
62
+ export const EnableBehaviorAll: Story = {
63
+ args: {
64
+ questionnaire: qEnableBehaviorAll
65
+ }
66
+ };
67
+
68
+ export const EnableBehaviorAny: Story = {
69
+ args: {
70
+ questionnaire: qEnableBehaviorAny
71
+ }
72
+ };
73
+
74
+ export const EnableWhenExpressionSimple: Story = {
75
+ args: {
76
+ questionnaire: qEnableWhenExpressionSimple
77
+ }
78
+ };
79
+
80
+ export const EnableWhenExpressionTabs: Story = {
81
+ args: {
82
+ questionnaire: qEnableWhenExpressionTabs
83
+ }
84
+ };
85
+
86
+ export const Text: Story = {
87
+ args: {
88
+ questionnaire: qText
89
+ }
90
+ };
@@ -0,0 +1,88 @@
1
+ /*
2
+ * Copyright 2024 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import type { Meta, StoryObj } from '@storybook/react';
19
+ import BuildFormWrapper from '../BuildFormWrapper';
20
+ import {
21
+ qMaxDecimalPlaces,
22
+ qMaxLength,
23
+ qMaxValue,
24
+ qMinLength,
25
+ qMinValue,
26
+ qRegex,
27
+ qrMaxDecimalPlaces,
28
+ qrMaxLength,
29
+ qrMaxValue,
30
+ qrMinLength,
31
+ qrMinValue,
32
+ qrRegex
33
+ } from '../assets/questionnaires'; // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
34
+
35
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
36
+ const meta = {
37
+ title: 'Component/SDC/9.1.1 Form Behavior Value Constraints',
38
+ component: BuildFormWrapper,
39
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
40
+ tags: []
41
+ } satisfies Meta<typeof BuildFormWrapper>;
42
+
43
+ export default meta;
44
+ type Story = StoryObj<typeof meta>;
45
+
46
+ // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
47
+
48
+ export const MaxLength: Story = {
49
+ args: {
50
+ questionnaire: qMaxLength,
51
+ questionnaireResponse: qrMaxLength
52
+ }
53
+ };
54
+
55
+ export const MinLength: Story = {
56
+ args: {
57
+ questionnaire: qMinLength,
58
+ questionnaireResponse: qrMinLength
59
+ }
60
+ };
61
+
62
+ export const Regex: Story = {
63
+ args: {
64
+ questionnaire: qRegex,
65
+ questionnaireResponse: qrRegex
66
+ }
67
+ };
68
+
69
+ export const MinValue: Story = {
70
+ args: {
71
+ questionnaire: qMinValue,
72
+ questionnaireResponse: qrMinValue
73
+ }
74
+ };
75
+
76
+ export const MaxValue: Story = {
77
+ args: {
78
+ questionnaire: qMaxValue,
79
+ questionnaireResponse: qrMaxValue
80
+ }
81
+ };
82
+
83
+ export const MaxDecimalPlaces: Story = {
84
+ args: {
85
+ questionnaire: qMaxDecimalPlaces,
86
+ questionnaireResponse: qrMaxDecimalPlaces
87
+ }
88
+ };
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright 2024 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import type { Meta, StoryObj } from '@storybook/react';
19
+ import BuildFormWrapper from '../BuildFormWrapper';
20
+ import { qItemControlDisplayLowerAndUpper } from '../assets/questionnaires'; // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
21
+
22
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
23
+ const meta = {
24
+ title: 'Component/SDC/8.1.2 Advanced Control Appearance - Item Control Display',
25
+ component: BuildFormWrapper,
26
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
27
+ tags: []
28
+ } satisfies Meta<typeof BuildFormWrapper>;
29
+
30
+ export default meta;
31
+ type Story = StoryObj<typeof meta>;
32
+
33
+ // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
34
+
35
+ export const LowerAndUpper: Story = {
36
+ args: {
37
+ questionnaire: qItemControlDisplayLowerAndUpper
38
+ }
39
+ };
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Copyright 2024 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import type { Meta, StoryObj } from '@storybook/react';
19
+ import BuildFormWrapper from '../BuildFormWrapper';
20
+ import {
21
+ qItemControlDisplayTabContainer,
22
+ qItemControlGroupGrid,
23
+ qItemControlGroupGTable
24
+ } from '../assets/questionnaires';
25
+
26
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
27
+ const meta = {
28
+ title: 'Component/SDC/8.1.2 Advanced Control Appearance - Item Control Group',
29
+ component: BuildFormWrapper,
30
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
31
+ tags: []
32
+ } satisfies Meta<typeof BuildFormWrapper>;
33
+
34
+ export default meta;
35
+ type Story = StoryObj<typeof meta>;
36
+
37
+ // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
38
+
39
+ export const Gtable: Story = {
40
+ args: {
41
+ questionnaire: qItemControlGroupGTable
42
+ }
43
+ };
44
+
45
+ export const Grid: Story = {
46
+ args: {
47
+ questionnaire: qItemControlGroupGrid
48
+ }
49
+ };
50
+
51
+ export const TabContainer: Story = {
52
+ args: {
53
+ questionnaire: qItemControlDisplayTabContainer
54
+ }
55
+ };
@@ -0,0 +1,118 @@
1
+ /*
2
+ * Copyright 2024 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import type { Meta, StoryObj } from '@storybook/react';
19
+ import BuildFormWrapper from '../BuildFormWrapper';
20
+ import {
21
+ qChoiceCheckboxAnswerOption,
22
+ qChoiceCheckboxAnswerValueSet,
23
+ qChoiceDropDownAnswerOption,
24
+ qChoiceDropDownAnswerValueSet,
25
+ qChoiceRadioAnswerOption,
26
+ qChoiceRadioAnswerValueSet,
27
+ qOpenChoiceAutocomplete,
28
+ qOpenChoiceCheckboxAnswerOption,
29
+ qOpenChoiceCheckboxAnswerValueSet,
30
+ qOpenChoiceRadioAnswerOption,
31
+ qOpenChoiceRadioAnswerValueSet,
32
+ qSliderStepValue
33
+ } from '../assets/questionnaires';
34
+
35
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
36
+ const meta = {
37
+ title: 'Component/SDC/8.1.2 Advanced Control Appearance - Item Control Question',
38
+ component: BuildFormWrapper,
39
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
40
+ tags: []
41
+ } satisfies Meta<typeof BuildFormWrapper>;
42
+
43
+ export default meta;
44
+ type Story = StoryObj<typeof meta>;
45
+
46
+ // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
47
+
48
+ export const AutocompleteOpenChoice: Story = {
49
+ args: {
50
+ questionnaire: qOpenChoiceAutocomplete
51
+ }
52
+ };
53
+
54
+ export const DropDownChoiceAnswerOption: Story = {
55
+ args: {
56
+ questionnaire: qChoiceDropDownAnswerOption
57
+ }
58
+ };
59
+
60
+ export const DropDownChoiceAnswerValueSet: Story = {
61
+ args: {
62
+ questionnaire: qChoiceDropDownAnswerValueSet
63
+ }
64
+ };
65
+
66
+ export const CheckboxChoiceAnswerOption: Story = {
67
+ args: {
68
+ questionnaire: qChoiceCheckboxAnswerOption
69
+ }
70
+ };
71
+
72
+ export const CheckboxChoiceAnswerValueSet: Story = {
73
+ args: {
74
+ questionnaire: qChoiceCheckboxAnswerValueSet
75
+ }
76
+ };
77
+
78
+ export const CheckboxOpenChoiceAnswerOption: Story = {
79
+ args: {
80
+ questionnaire: qOpenChoiceCheckboxAnswerOption
81
+ }
82
+ };
83
+
84
+ export const CheckboxOpenChoiceAnswerValueSet: Story = {
85
+ args: {
86
+ questionnaire: qOpenChoiceCheckboxAnswerValueSet
87
+ }
88
+ };
89
+
90
+ export const RadioChoiceAnswerOption: Story = {
91
+ args: {
92
+ questionnaire: qChoiceRadioAnswerOption
93
+ }
94
+ };
95
+
96
+ export const RadioChoiceAnswerValueSet: Story = {
97
+ args: {
98
+ questionnaire: qChoiceRadioAnswerValueSet
99
+ }
100
+ };
101
+
102
+ export const RadioOpenChoiceAnswerOption: Story = {
103
+ args: {
104
+ questionnaire: qOpenChoiceRadioAnswerOption
105
+ }
106
+ };
107
+
108
+ export const RadioOpenChoiceAnswerValueSet: Story = {
109
+ args: {
110
+ questionnaire: qOpenChoiceRadioAnswerValueSet
111
+ }
112
+ };
113
+
114
+ export const SliderInteger: Story = {
115
+ args: {
116
+ questionnaire: qSliderStepValue
117
+ }
118
+ };
@@ -0,0 +1,23 @@
1
+ import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
2
+ import { questionnaireResponseStore, questionnaireStore } from '../stores';
3
+ import { initialiseQuestionnaireResponse } from './initialise';
4
+
5
+ /**
6
+ * Build the form with an initial Questionnaire and an optional filled QuestionnaireResponse.
7
+ * If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse.
8
+ *
9
+ * @author Sean Fong
10
+ */
11
+ export async function buildForm(
12
+ questionnaire: Questionnaire,
13
+ questionnaireResponse?: QuestionnaireResponse
14
+ ): Promise<void> {
15
+ await questionnaireStore.getState().buildSourceQuestionnaire(questionnaire);
16
+
17
+ const initialisedQuestionnaireResponse = initialiseQuestionnaireResponse(
18
+ questionnaire,
19
+ questionnaireResponse
20
+ );
21
+ questionnaireResponseStore.getState().buildSourceResponse(initialisedQuestionnaireResponse);
22
+ questionnaireStore.getState().updatePopulatedProperties(initialisedQuestionnaireResponse);
23
+ }
@@ -149,17 +149,20 @@ export function getQrChoiceValue(
149
149
  *
150
150
  * @author Sean Fong
151
151
  */
152
- export function updateQrCheckboxAnswers(
152
+ export function updateChoiceCheckboxAnswers(
153
153
  changedValue: string,
154
154
  answers: QuestionnaireResponseItemAnswer[],
155
- answerOptions: QuestionnaireItemAnswerOption[],
156
- qrChoiceCheckbox: QuestionnaireResponseItem,
155
+ options: QuestionnaireItemAnswerOption[],
156
+ oldQrItem: QuestionnaireResponseItem,
157
157
  isMultiSelection: boolean
158
158
  ): QuestionnaireResponseItem | null {
159
159
  // search for answer item of changedValue from list of answer options
160
- const newAnswer = findInAnswerOptions(answerOptions, changedValue);
161
- if (!newAnswer) return null;
160
+ const newAnswer = findInAnswerOptions(options, changedValue);
161
+ if (!newAnswer) {
162
+ return null;
163
+ }
162
164
 
165
+ // Process multi-selection
163
166
  if (isMultiSelection && answers.length > 0) {
164
167
  // check and filter if new answer exists in existing qrAnswers
165
168
  const updatedAnswers = answers.filter(
@@ -171,12 +174,15 @@ export function updateQrCheckboxAnswers(
171
174
  updatedAnswers.push(newAnswer);
172
175
  }
173
176
 
174
- return { ...qrChoiceCheckbox, answer: updatedAnswers };
175
- } else {
176
- return answers.some((answer) => JSON.stringify(answer) === JSON.stringify(newAnswer))
177
- ? { ...qrChoiceCheckbox, answer: [] }
178
- : { ...qrChoiceCheckbox, answer: [newAnswer] };
177
+ return { ...oldQrItem, answer: updatedAnswers };
179
178
  }
179
+
180
+ // Process single selection
181
+ // If answer already exists, remove it from the array. Otherwise, add it to the array
182
+ const answerExists = answers.some(
183
+ (answer) => JSON.stringify(answer) === JSON.stringify(newAnswer)
184
+ );
185
+ return answerExists ? { ...oldQrItem, answer: [] } : { ...oldQrItem, answer: [newAnswer] };
180
186
  }
181
187
 
182
188
  /**
@@ -203,16 +209,3 @@ export function getChoiceOrientation(qItem: QuestionnaireItem): ChoiceItemOrient
203
209
 
204
210
  return null;
205
211
  }
206
-
207
- /**
208
- * Converts an array of codings to an array of valueCodings which can use the QuestionnaireItemAnswerOption type
209
- *
210
- * @author Sean Fong
211
- */
212
- export function mapCodingsToOptions(codings: Coding[]): QuestionnaireItemAnswerOption[] {
213
- return codings.map((coding) => {
214
- return {
215
- valueCoding: coding
216
- };
217
- });
218
- }
@@ -349,18 +349,16 @@ export function checkItemIsEnabledSingle(
349
349
  );
350
350
 
351
351
  // In a repeat item, if at least one answer satisfies the condition, the item is enabled
352
- if (isEnabledForThisLinkedItem) {
353
- checkedIsEnabledItems.push(isEnabledAnswerTypeSwitcher(linkedItem.enableWhen, answer));
354
- break;
355
- }
352
+ // FIXME need to look further at this
353
+ checkedIsEnabledItems.push(isEnabledForThisLinkedItem);
354
+ break;
356
355
  }
357
356
  continue;
358
357
  }
359
358
 
360
359
  // Linked item doesn't have any answers, but we still have to check for unanswered booleans
361
- if (evaluateNonExistentAnswers(linkedItem.enableWhen)) {
362
- checkedIsEnabledItems.push(true);
363
- }
360
+ const checkedNonExistentAnswer = evaluateNonExistentAnswers(linkedItem.enableWhen);
361
+ checkedIsEnabledItems.push(checkedNonExistentAnswer);
364
362
  }
365
363
 
366
364
  if (checkedIsEnabledItems.length === 0) {
@@ -23,3 +23,4 @@ export {
23
23
  setInitialAnswers
24
24
  } from './enableWhen';
25
25
  export { initialiseQuestionnaireResponse } from './initialise';
26
+ export { buildForm } from './buildForm';