@aehrc/smart-forms-renderer 0.30.2 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/lib/components/FormComponents/BooleanItem/BooleanField.js +5 -4
- package/lib/components/FormComponents/BooleanItem/BooleanField.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js +5 -4
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js +5 -4
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js.map +1 -1
- package/lib/components/FormComponents/DateTimeItems/index.d.ts +1 -1
- package/lib/components/FormComponents/DateTimeItems/index.js +1 -1
- package/lib/components/FormComponents/DateTimeItems/index.js.map +1 -1
- package/lib/components/FormComponents/DateTimeItems/utils/parseDate.d.ts +5 -0
- package/lib/components/FormComponents/DateTimeItems/utils/parseDate.js +5 -0
- package/lib/components/FormComponents/DateTimeItems/utils/parseDate.js.map +1 -1
- package/lib/components/FormComponents/GridGroup/GridGroup.d.ts +6 -0
- package/lib/components/FormComponents/GridGroup/GridGroup.js +6 -0
- package/lib/components/FormComponents/GridGroup/GridGroup.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.d.ts +6 -0
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +6 -0
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
- package/lib/components/FormComponents/RepeatItem/RepeatItem.d.ts +5 -0
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js +5 -0
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
- package/lib/components/FormComponents/SingleItem/SingleItem.d.ts +6 -0
- package/lib/components/FormComponents/SingleItem/SingleItem.js +6 -0
- package/lib/components/FormComponents/SingleItem/SingleItem.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTable.d.ts +6 -0
- package/lib/components/FormComponents/Tables/GroupTable.js +6 -0
- package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -1
- package/lib/components/FormComponents/index.d.ts +6 -6
- package/lib/components/FormComponents/index.js +6 -6
- package/lib/components/FormComponents/index.js.map +1 -1
- package/lib/components/Renderer/BaseRenderer.d.ts +7 -0
- package/lib/components/Renderer/BaseRenderer.js +7 -0
- package/lib/components/Renderer/BaseRenderer.js.map +1 -1
- package/lib/components/Renderer/SmartFormsRenderer.d.ts +22 -1
- package/lib/components/Renderer/SmartFormsRenderer.js +16 -6
- package/lib/components/Renderer/SmartFormsRenderer.js.map +1 -1
- package/lib/components/Renderer/index.d.ts +1 -0
- package/lib/components/Renderer/index.js.map +1 -1
- package/lib/components/index.d.ts +3 -2
- package/lib/components/index.js +2 -2
- package/lib/components/index.js.map +1 -1
- package/lib/hooks/index.d.ts +2 -0
- package/lib/hooks/index.js +2 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useBuildForm.d.ts +15 -0
- package/lib/hooks/useBuildForm.js +41 -0
- package/lib/hooks/useBuildForm.js.map +1 -0
- package/lib/hooks/useHidden.d.ts +6 -0
- package/lib/hooks/useHidden.js +6 -0
- package/lib/hooks/useHidden.js.map +1 -1
- package/lib/hooks/useInitaliseFhirClient.d.ts +1 -0
- package/lib/hooks/useInitaliseFhirClient.js +55 -0
- package/lib/hooks/useInitaliseFhirClient.js.map +1 -0
- package/lib/hooks/useInitialiseForm.d.ts +20 -0
- package/lib/hooks/useInitialiseForm.js +72 -0
- package/lib/hooks/useInitialiseForm.js.map +1 -0
- package/lib/hooks/useInitialiseRenderer.d.ts +1 -1
- package/lib/hooks/useInitialiseRenderer.js +8 -31
- package/lib/hooks/useInitialiseRenderer.js.map +1 -1
- package/lib/hooks/useRendererQueryClient.d.ts +10 -0
- package/lib/hooks/useRendererQueryClient.js +36 -0
- package/lib/hooks/useRendererQueryClient.js.map +1 -0
- package/lib/hooks/useValueSetCodings.js +1 -0
- package/lib/hooks/useValueSetCodings.js.map +1 -1
- package/lib/index.d.ts +10 -40
- package/lib/index.js +8 -77
- package/lib/index.js.map +1 -1
- package/lib/interfaces/calculatedExpression.interface.d.ts +7 -0
- package/lib/interfaces/calculatedExpression.interface.js +16 -0
- package/lib/interfaces/calculatedExpression.interface.js.map +1 -1
- package/lib/interfaces/enableWhen.interface.d.ts +12 -0
- package/lib/interfaces/index.d.ts +4 -1
- package/lib/interfaces/index.js +16 -0
- package/lib/interfaces/index.js.map +1 -1
- package/lib/interfaces/populate.interface.d.ts +6 -0
- package/lib/interfaces/repopulateItems.interface.d.ts +0 -0
- package/lib/interfaces/repopulateItems.interface.js +2 -0
- package/lib/interfaces/repopulateItems.interface.js.map +1 -0
- package/lib/interfaces/tab.interface.d.ts +10 -0
- package/lib/interfaces/tab.interface.js +16 -0
- package/lib/interfaces/tab.interface.js.map +1 -1
- package/lib/interfaces/variables.interface.d.ts +12 -0
- package/lib/stores/index.d.ts +4 -0
- package/lib/stores/index.js.map +1 -1
- package/lib/stores/questionnaireResponseStore.d.ts +37 -2
- package/lib/stores/questionnaireResponseStore.js +72 -22
- package/lib/stores/questionnaireResponseStore.js.map +1 -1
- package/lib/stores/questionnaireStore.d.ts +59 -3
- package/lib/stores/questionnaireStore.js +18 -0
- package/lib/stores/questionnaireStore.js.map +1 -1
- package/lib/stores/smartConfigStore.d.ts +37 -0
- package/lib/stores/smartConfigStore.js +21 -0
- package/lib/stores/smartConfigStore.js.map +1 -1
- package/lib/stores/terminologyServerStore.d.ts +28 -2
- package/lib/stores/terminologyServerStore.js +16 -0
- package/lib/stores/terminologyServerStore.js.map +1 -1
- package/lib/stories/InitialiseFormWrapperForStorybook.d.ts +29 -0
- package/lib/stories/InitialiseFormWrapperForStorybook.js +65 -0
- package/lib/stories/InitialiseFormWrapperForStorybook.js.map +1 -0
- package/lib/stories/StorybookWrappers/BuildFormButtonForStorybook.d.ts +8 -0
- package/lib/stories/StorybookWrappers/BuildFormButtonForStorybook.js +44 -0
- package/lib/stories/StorybookWrappers/BuildFormButtonForStorybook.js.map +1 -0
- package/lib/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.d.ts +18 -0
- package/lib/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.js +48 -0
- package/lib/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.js.map +1 -0
- package/lib/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.d.ts +31 -0
- package/lib/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.js +67 -0
- package/lib/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.js.map +1 -0
- package/lib/stories/StorybookWrappers/PrePopButtonForStorybook.d.ts +7 -0
- package/lib/stories/StorybookWrappers/PrePopButtonForStorybook.js +32 -0
- package/lib/stories/StorybookWrappers/PrePopButtonForStorybook.js.map +1 -0
- package/lib/stories/StorybookWrappers/PrePopWrapperForStorybook.d.ts +21 -0
- package/lib/stories/StorybookWrappers/PrePopWrapperForStorybook.js +83 -0
- package/lib/stories/StorybookWrappers/PrePopWrapperForStorybook.js.map +1 -0
- package/lib/stories/StorybookWrappers/index.d.ts +3 -0
- package/lib/stories/StorybookWrappers/index.js +20 -0
- package/lib/stories/StorybookWrappers/index.js.map +1 -0
- package/lib/stories/StorybookWrappers/populateCallbackForStorybook.d.ts +8 -0
- package/lib/stories/StorybookWrappers/populateCallbackForStorybook.js +46 -0
- package/lib/stories/StorybookWrappers/populateCallbackForStorybook.js.map +1 -0
- package/lib/stories/index.d.ts +1 -0
- package/lib/stories/index.js +18 -0
- package/lib/stories/index.js.map +1 -0
- package/lib/theme/Theme.d.ts +8 -2
- package/lib/theme/Theme.js +8 -2
- package/lib/theme/Theme.js.map +1 -1
- package/lib/theme/index.d.ts +1 -0
- package/lib/theme/index.js +2 -0
- package/lib/theme/index.js.map +1 -0
- package/lib/utils/enableWhen.d.ts +1 -1
- package/lib/utils/enableWhenExpression.d.ts +1 -1
- package/lib/utils/fhirpath.d.ts +1 -1
- package/lib/utils/index.d.ts +5 -3
- package/lib/utils/index.js +4 -3
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/initialise.d.ts +2 -2
- package/lib/utils/initialise.js +1 -1
- package/lib/utils/manageForm.d.ts +45 -0
- package/lib/utils/manageForm.js +101 -0
- package/lib/utils/manageForm.js.map +1 -0
- package/lib/utils/qItem.d.ts +1 -1
- package/lib/utils/questionnaireStoreUtils/extractOtherExtensions.d.ts +1 -1
- package/lib/utils/removeEmptyAnswers.d.ts +1 -1
- package/lib/utils/repopulateIntoResponse.d.ts +6 -0
- package/lib/utils/repopulateIntoResponse.js +11 -0
- package/lib/utils/repopulateIntoResponse.js.map +1 -1
- package/lib/utils/repopulateItems.d.ts +19 -1
- package/lib/utils/repopulateItems.js +23 -0
- package/lib/utils/repopulateItems.js.map +1 -1
- package/lib/utils/tabs.d.ts +2 -2
- package/lib/utils/tabs.js +1 -1
- package/lib/utils/validateQuestionnaire.d.ts +0 -4
- package/lib/utils/validateQuestionnaire.js +9 -5
- package/lib/utils/validateQuestionnaire.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FormComponents/BooleanItem/BooleanField.tsx +11 -9
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.tsx +11 -9
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx +11 -9
- package/src/components/FormComponents/DateTimeItems/index.ts +1 -1
- package/src/components/FormComponents/DateTimeItems/utils/parseDate.ts +5 -0
- package/src/components/FormComponents/GridGroup/GridGroup.tsx +6 -0
- package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +6 -0
- package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +5 -0
- package/src/components/FormComponents/SingleItem/SingleItem.tsx +6 -0
- package/src/components/FormComponents/Tables/GroupTable.tsx +6 -0
- package/src/components/FormComponents/index.ts +6 -6
- package/src/components/Renderer/BaseRenderer.tsx +7 -0
- package/src/components/Renderer/SmartFormsRenderer.tsx +34 -11
- package/src/components/Renderer/index.ts +1 -0
- package/src/components/index.ts +10 -2
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useBuildForm.ts +58 -0
- package/src/hooks/useHidden.ts +6 -0
- package/src/hooks/useInitialiseForm.ts +93 -0
- package/src/hooks/{useQueryClient.ts → useRendererQueryClient.ts} +9 -2
- package/src/hooks/useValueSetCodings.ts +1 -0
- package/src/index.ts +59 -96
- package/src/interfaces/calculatedExpression.interface.ts +24 -0
- package/src/interfaces/enableWhen.interface.ts +12 -0
- package/src/interfaces/index.ts +21 -10
- package/src/interfaces/populate.interface.ts +6 -0
- package/src/interfaces/tab.interface.ts +12 -0
- package/src/interfaces/variables.interface.ts +12 -0
- package/src/stores/index.ts +7 -0
- package/src/stores/questionnaireResponseStore.ts +90 -19
- package/src/stores/questionnaireStore.ts +62 -2
- package/src/stores/smartConfigStore.ts +37 -0
- package/src/stores/terminologyServerStore.ts +28 -1
- package/src/stories/{BuildFormButtonForStorybook.tsx → StorybookWrappers/BuildFormButtonForStorybook.tsx} +12 -5
- package/src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx +70 -0
- package/src/stories/{BuildFormWrapper.tsx → StorybookWrappers/BuildFormWrapperForStorybook.tsx} +11 -12
- package/src/stories/{BuildFormButtonTesterWrapper.tsx → StorybookWrappers/FormValidationTesterWrapperForStorybook.tsx} +22 -19
- package/src/stories/{useBuildFormForStorybook.ts → StorybookWrappers/FormValidationViewerForStorybook.tsx} +7 -16
- package/src/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.tsx +105 -0
- package/src/stories/{PrePopButtonForStorybook.tsx → StorybookWrappers/PrePopButtonForStorybook.tsx} +12 -10
- package/src/stories/{PrePopWrapper.tsx → StorybookWrappers/PrePopWrapperForStorybook.tsx} +22 -14
- package/src/stories/StorybookWrappers/ValidateFormButtonForStorybook.tsx +41 -0
- package/src/stories/StorybookWrappers/index.ts +20 -0
- package/src/stories/{populateCallbackForStorybook.ts → StorybookWrappers/populateCallbackForStorybook.ts} +8 -2
- package/src/stories/assets/questionnaires/QButtonTester.ts +380 -0
- package/src/stories/assets/questionnaires/QValidateTester.ts +118 -0
- package/src/stories/itemTypes/Attachment.stories.tsx +3 -3
- package/src/stories/itemTypes/Boolean.stories.tsx +3 -3
- package/src/stories/itemTypes/Choice.stories.tsx +3 -3
- package/src/stories/itemTypes/Date.stories.tsx +3 -3
- package/src/stories/itemTypes/DateTime.stories.tsx +3 -3
- package/src/stories/itemTypes/Decimal.stories.tsx +3 -3
- package/src/stories/itemTypes/Display.stories.tsx +3 -3
- package/src/stories/itemTypes/Group.stories.tsx +3 -3
- package/src/stories/itemTypes/Integer.stories.tsx +3 -3
- package/src/stories/itemTypes/OpenChoice.stories.tsx +3 -3
- package/src/stories/itemTypes/Quantity.stories.tsx +3 -3
- package/src/stories/itemTypes/Reference.stories.tsx +3 -3
- package/src/stories/itemTypes/String.stories.tsx +3 -3
- package/src/stories/itemTypes/Text.stories.tsx +3 -3
- package/src/stories/itemTypes/Time.stories.tsx +3 -3
- package/src/stories/itemTypes/Url.stories.tsx +3 -3
- package/src/stories/sdc/AdvancedAdditionalDisplayContent.stories.tsx +3 -3
- package/src/stories/sdc/AdvancedControlAppearance.stories.tsx +3 -3
- package/src/stories/sdc/AdvancedOther.stories.tsx +3 -3
- package/src/stories/sdc/AdvancedTextAppearance.stories.tsx +3 -3
- package/src/stories/sdc/BehaviorCalculations.stories.tsx +3 -3
- package/src/stories/sdc/BehaviorChoiceRestriction.stories.tsx +3 -3
- package/src/stories/sdc/BehaviorOther.stories.tsx +3 -3
- package/src/stories/sdc/BehaviorValueConstraints.stories.tsx +3 -3
- package/src/stories/sdc/FormPopulation.stories.tsx +3 -3
- package/src/stories/sdc/ItemControlDisplay.stories.tsx +3 -3
- package/src/stories/sdc/ItemControlGroup.stories.tsx +3 -3
- package/src/stories/sdc/ItemControlQuestion.stories.tsx +3 -3
- package/src/stories/{rebuildForm/BuildFormTesterWrapper.stories.tsx → testing/BuildFormButtonTesterWrapper.stories.tsx} +6 -9
- package/src/stories/testing/PrePopButtonTesterWrapper.stories.tsx +45 -0
- package/src/stories/testing/ValidateFormTesterWrapper.stories.tsx +39 -0
- package/src/tests/enableWhen.test.ts +6 -2
- package/src/theme/Theme.tsx +8 -2
- package/src/theme/index.ts +1 -0
- package/src/utils/enableWhen.ts +1 -1
- package/src/utils/enableWhenExpression.ts +1 -1
- package/src/utils/fhirpath.ts +1 -1
- package/src/utils/index.ts +5 -7
- package/src/utils/initialise.ts +2 -2
- package/src/utils/manageForm.ts +110 -0
- package/src/utils/qItem.ts +1 -1
- package/src/utils/questionnaireStoreUtils/extractOtherExtensions.ts +1 -1
- package/src/utils/removeEmptyAnswers.ts +1 -1
- package/src/utils/repopulateIntoResponse.ts +17 -0
- package/src/utils/repopulateItems.ts +38 -1
- package/src/utils/tabs.ts +2 -2
- package/src/utils/validateQuestionnaire.ts +12 -17
- package/vite.config.ts +1 -1
- package/src/hooks/useInitialiseRenderer.ts +0 -114
- package/src/stories/assets/questionnaires/QBuildFormButtonTester.ts +0 -270
- package/src/stories/populateUtilsForStorybook.ts +0 -545
- package/src/utils/buildForm.ts +0 -23
- /package/.storybook/{preview.ts → preview.tsx} +0 -0
|
@@ -73,6 +73,7 @@ function useValueSetCodings(qItem: QuestionnaireItem): {
|
|
|
73
73
|
return [];
|
|
74
74
|
}, [cachedValueSetCodings, processedValueSetCodings, valueSetUrl]);
|
|
75
75
|
|
|
76
|
+
// Attempt to get codings from answer expression
|
|
76
77
|
const answerExpression = getAnswerExpression(qItem)?.expression;
|
|
77
78
|
initialCodings = useMemo(() => {
|
|
78
79
|
if (initialCodings.length === 0 && answerExpression) {
|
package/src/index.ts
CHANGED
|
@@ -1,96 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*
|
|
61
|
-
* @author Sean Fong
|
|
62
|
-
*/
|
|
63
|
-
export function generateItemsToRepopulate(populatedResponse: QuestionnaireResponse) {
|
|
64
|
-
const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;
|
|
65
|
-
const tabs = questionnaireStore.getState().tabs;
|
|
66
|
-
const updatableResponse = questionnaireResponseStore.getState().updatableResponse;
|
|
67
|
-
const enableWhenIsActivated = questionnaireStore.getState().enableWhenIsActivated;
|
|
68
|
-
const enableWhenItems = questionnaireStore.getState().enableWhenItems;
|
|
69
|
-
const enableWhenExpressions = questionnaireStore.getState().enableWhenExpressions;
|
|
70
|
-
|
|
71
|
-
return getItemsToRepopulate({
|
|
72
|
-
sourceQuestionnaire,
|
|
73
|
-
tabs,
|
|
74
|
-
populatedResponse,
|
|
75
|
-
updatableResponse,
|
|
76
|
-
enableWhenIsActivated,
|
|
77
|
-
enableWhenItems,
|
|
78
|
-
enableWhenExpressions
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Re-populate checked items in the re-population dialog into the current QuestionnaireResponse.
|
|
84
|
-
*
|
|
85
|
-
* @author Sean Fong
|
|
86
|
-
*/
|
|
87
|
-
export function repopulateResponse(checkedItemsToRepopulate: Record<string, ItemToRepopulate>) {
|
|
88
|
-
const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;
|
|
89
|
-
const updatableResponse = questionnaireResponseStore.getState().updatableResponse;
|
|
90
|
-
|
|
91
|
-
return repopulateItemsIntoResponse(
|
|
92
|
-
sourceQuestionnaire,
|
|
93
|
-
updatableResponse,
|
|
94
|
-
checkedItemsToRepopulate
|
|
95
|
-
);
|
|
96
|
-
}
|
|
1
|
+
// interface exports
|
|
2
|
+
export type { Tab, Tabs, Variables, VariableXFhirQuery, LaunchContext } from './interfaces';
|
|
3
|
+
|
|
4
|
+
// component exports
|
|
5
|
+
export type { SmartFormsRendererProps } from './components';
|
|
6
|
+
export {
|
|
7
|
+
SmartFormsRenderer,
|
|
8
|
+
BaseRenderer,
|
|
9
|
+
SingleItem,
|
|
10
|
+
RepeatItem,
|
|
11
|
+
RepeatGroup,
|
|
12
|
+
GroupTable,
|
|
13
|
+
GridGroup,
|
|
14
|
+
parseFhirDateToDisplayDate
|
|
15
|
+
} from './components';
|
|
16
|
+
|
|
17
|
+
// state management store exports
|
|
18
|
+
export type {
|
|
19
|
+
QuestionnaireStoreType,
|
|
20
|
+
QuestionnaireResponseStoreType,
|
|
21
|
+
SmartConfigStoreType,
|
|
22
|
+
TerminologyServerStoreType
|
|
23
|
+
} from './stores';
|
|
24
|
+
export {
|
|
25
|
+
questionnaireStore,
|
|
26
|
+
useQuestionnaireStore,
|
|
27
|
+
questionnaireResponseStore,
|
|
28
|
+
useQuestionnaireResponseStore,
|
|
29
|
+
smartConfigStore,
|
|
30
|
+
useSmartConfigStore,
|
|
31
|
+
terminologyServerStore,
|
|
32
|
+
useTerminologyServerStore
|
|
33
|
+
} from './stores';
|
|
34
|
+
|
|
35
|
+
// hooks exports
|
|
36
|
+
export { useHidden, useBuildForm, useRendererQueryClient } from './hooks';
|
|
37
|
+
|
|
38
|
+
// utils exports
|
|
39
|
+
export type { ItemToRepopulate } from './utils';
|
|
40
|
+
export {
|
|
41
|
+
buildForm,
|
|
42
|
+
destroyForm,
|
|
43
|
+
getResponse,
|
|
44
|
+
removeEmptyAnswersFromResponse,
|
|
45
|
+
isSpecificItemControl,
|
|
46
|
+
isRepeatItemAndNotCheckbox,
|
|
47
|
+
initialiseQuestionnaireResponse,
|
|
48
|
+
generateItemsToRepopulate,
|
|
49
|
+
repopulateResponse
|
|
50
|
+
} from './utils';
|
|
51
|
+
|
|
52
|
+
// theme provider exports
|
|
53
|
+
export { RendererThemeProvider } from './theme';
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
InitialiseFormWrapperForStorybook,
|
|
57
|
+
BuildFormButtonTesterWrapperForStorybook,
|
|
58
|
+
PrePopWrapperForStorybook
|
|
59
|
+
} from './stories/StorybookWrappers';
|
|
@@ -1,3 +1,27 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* CalculatedExpression interface
|
|
20
|
+
*
|
|
21
|
+
* @property expression - CalculatedExpression FHIRPath expression
|
|
22
|
+
* @property from - Whether the expressions is for the item itself or for item._text
|
|
23
|
+
* @property value - Evaluated value of the expression via FHIRPath
|
|
24
|
+
*/
|
|
1
25
|
export interface CalculatedExpression {
|
|
2
26
|
expression: string;
|
|
3
27
|
from: 'item' | 'item._text';
|
|
@@ -21,6 +21,12 @@ import type {
|
|
|
21
21
|
QuestionnaireResponseItemAnswer
|
|
22
22
|
} from 'fhir/r4';
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* EnableWhenExpressions interface
|
|
26
|
+
*
|
|
27
|
+
* @property singleExpressions - Key-value pair of non-repeat group enableWhen expressions `Record<linkId, enableWhenExpression properties>`
|
|
28
|
+
* @property repeatExpressions - Key-value pair of repeat group enableWhen expressions `Record<linkId, enableWhenExpression properties>`
|
|
29
|
+
*/
|
|
24
30
|
export interface EnableWhenExpressions {
|
|
25
31
|
singleExpressions: Record<string, EnableWhenSingleExpression>;
|
|
26
32
|
repeatExpressions: Record<string, EnableWhenRepeatExpression>;
|
|
@@ -37,6 +43,12 @@ export interface EnableWhenRepeatExpression {
|
|
|
37
43
|
enabledIndexes: boolean[];
|
|
38
44
|
}
|
|
39
45
|
|
|
46
|
+
/**
|
|
47
|
+
* EnableWhenItems interface
|
|
48
|
+
*
|
|
49
|
+
* @property singleItems - Key-value pair of non-repeat group enableWhen items `Record<linkId, enableWhen properties>`
|
|
50
|
+
* @property repeatItems - Key-value pair of repeat group enableWhen items `Record<linkId, enableWhen properties>`
|
|
51
|
+
*/
|
|
40
52
|
export interface EnableWhenItems {
|
|
41
53
|
singleItems: Record<string, EnableWhenSingleItemProperties>;
|
|
42
54
|
repeatItems: Record<string, EnableWhenRepeatItemProperties>;
|
package/src/interfaces/index.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
export type { Tab, Tabs } from './tab.interface';
|
|
19
|
+
export type { Variables, VariableXFhirQuery } from './variables.interface';
|
|
20
|
+
export type { LaunchContext } from './populate.interface';
|
|
21
|
+
export type { EnableWhenItems, EnableWhenExpressions } from './enableWhen.interface';
|
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
|
|
18
18
|
import type { Coding, Expression, Extension, Reference } from 'fhir/r4';
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* LaunchContext interface
|
|
22
|
+
*
|
|
23
|
+
* @property url - Launch context URL
|
|
24
|
+
* @property extension - Possible contents of the launch context as an array of extensions
|
|
25
|
+
*/
|
|
20
26
|
export interface LaunchContext extends Extension {
|
|
21
27
|
url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-launchContext';
|
|
22
28
|
extension: LaunchContextExtensions;
|
|
@@ -14,5 +14,17 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Tab interface
|
|
20
|
+
*
|
|
21
|
+
* @property tabIndex - The index of the tab
|
|
22
|
+
* @property isComplete - Whether the tab is marked as complete
|
|
23
|
+
* @property isHidden - Whether the tab is hidden
|
|
24
|
+
*/
|
|
17
25
|
export type Tab = { tabIndex: number; isComplete: boolean; isHidden: boolean };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Key-value pair of tabs `Record<linkId, Tab>`
|
|
29
|
+
*/
|
|
18
30
|
export type Tabs = Record<string, Tab>;
|
|
@@ -17,11 +17,23 @@
|
|
|
17
17
|
|
|
18
18
|
import type { Expression, FhirResource } from 'fhir/r4';
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Variables interface
|
|
22
|
+
*
|
|
23
|
+
* @property fhirPathVariables - Key-value pair of FHIRPath variable expressions in a Questionnaire item `Record<linkId, array of FHIRPath expressions>`
|
|
24
|
+
* @property xFhirQueryVariables - Key-value pair of x-fhir-query variables `Record<variable name, x-fhir-query variable properties>`
|
|
25
|
+
*/
|
|
20
26
|
export interface Variables {
|
|
21
27
|
fhirPathVariables: Record<string, Expression[]>;
|
|
22
28
|
xFhirQueryVariables: Record<string, VariableXFhirQuery>;
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
/**
|
|
32
|
+
* VariableXFhirQuery interface
|
|
33
|
+
*
|
|
34
|
+
* @property valueExpression - FHIRPath Expression of the variable
|
|
35
|
+
* @property result - FHIR resource result of the executed query
|
|
36
|
+
*/
|
|
25
37
|
export interface VariableXFhirQuery {
|
|
26
38
|
valueExpression: Expression;
|
|
27
39
|
result?: FhirResource;
|
package/src/stores/index.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
export type { QuestionnaireStoreType } from './questionnaireStore';
|
|
1
2
|
export { questionnaireStore, useQuestionnaireStore } from './questionnaireStore';
|
|
3
|
+
|
|
4
|
+
export type { QuestionnaireResponseStoreType } from './questionnaireResponseStore';
|
|
2
5
|
export {
|
|
3
6
|
questionnaireResponseStore,
|
|
4
7
|
useQuestionnaireResponseStore
|
|
5
8
|
} from './questionnaireResponseStore';
|
|
9
|
+
|
|
10
|
+
export type { SmartConfigStoreType } from './smartConfigStore';
|
|
6
11
|
export { smartConfigStore, useSmartConfigStore } from './smartConfigStore';
|
|
12
|
+
|
|
13
|
+
export type { TerminologyServerStoreType } from './terminologyServerStore';
|
|
7
14
|
export { terminologyServerStore, useTerminologyServerStore } from './terminologyServerStore';
|
|
@@ -31,7 +31,28 @@ import { validateQuestionnaire } from '../utils/validateQuestionnaire';
|
|
|
31
31
|
import { questionnaireStore } from './questionnaireStore';
|
|
32
32
|
import { createQuestionnaireResponseItemMap } from '../utils/questionnaireResponseStoreUtils/updatableResponseItems';
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* QuestionnaireResponseStore properties and methods
|
|
36
|
+
* Properties can be accessed for fine-grain details.
|
|
37
|
+
* Methods are usually used internally, using them from an external source is not recommended.
|
|
38
|
+
*
|
|
39
|
+
* @property sourceResponse - The original response created when the form is first initialised i.e. empty, pre-populated, opened saved draft
|
|
40
|
+
* @property updatableResponse - The current state of the response that is being updated via form fields
|
|
41
|
+
* @property updatableResponseItems - Key-value pair of updatableResponse items `Record<linkId, QR.item(s)>`
|
|
42
|
+
* @property formChangesHistory - Array of form changes history in the form of deep-diff objects
|
|
43
|
+
* @property invalidItems - Key-value pair of invalid items based on defined value constraints in the questionnaire `Record<linkId, OperationOutcome>`
|
|
44
|
+
* @property responseIsValid - Whether there are any invalid items in the response
|
|
45
|
+
* @method validateQuestionnaire - Used to validate the questionnaire response based on the questionnaire
|
|
46
|
+
* @method buildSourceResponse - Used to build the source response when the form is first initialised
|
|
47
|
+
* @method setUpdatableResponseAsPopulated - Used to set a pre-populated response as the current response
|
|
48
|
+
* @method updateResponse - Used to update the current response
|
|
49
|
+
* @method setUpdatableResponseAsSaved - Used to set a saved response as the current response
|
|
50
|
+
* @method setUpdatableResponseAsEmpty - Used to set an empty response as the current response
|
|
51
|
+
* @method destroySourceResponse - Used to destroy the source response and reset all properties
|
|
52
|
+
*
|
|
53
|
+
* @author Sean Fong
|
|
54
|
+
*/
|
|
55
|
+
export interface QuestionnaireResponseStoreType {
|
|
35
56
|
sourceResponse: QuestionnaireResponse;
|
|
36
57
|
updatableResponse: QuestionnaireResponse;
|
|
37
58
|
updatableResponseItems: Record<string, QuestionnaireResponseItem[]>;
|
|
@@ -50,6 +71,13 @@ interface QuestionnaireResponseStoreType {
|
|
|
50
71
|
destroySourceResponse: () => void;
|
|
51
72
|
}
|
|
52
73
|
|
|
74
|
+
/**
|
|
75
|
+
* QuestionnaireResponse state management store which contains all properties and methods to manage the state of the questionnaireResponse.
|
|
76
|
+
* This is the vanilla version of the store which can be used in non-React environments.
|
|
77
|
+
* @see {QuestionnaireResponseStoreType} for available properties and methods.
|
|
78
|
+
*
|
|
79
|
+
* @author Sean Fong
|
|
80
|
+
*/
|
|
53
81
|
export const questionnaireResponseStore = createStore<QuestionnaireResponseStoreType>()(
|
|
54
82
|
(set, get) => ({
|
|
55
83
|
sourceResponse: cloneDeep(emptyResponse),
|
|
@@ -62,16 +90,9 @@ export const questionnaireResponseStore = createStore<QuestionnaireResponseStore
|
|
|
62
90
|
questionnaire: Questionnaire,
|
|
63
91
|
updatedResponse: QuestionnaireResponse
|
|
64
92
|
) => {
|
|
65
|
-
const enableWhenIsActivated = questionnaireStore.getState().enableWhenIsActivated;
|
|
66
|
-
const enableWhenItems = questionnaireStore.getState().enableWhenItems;
|
|
67
|
-
const enableWhenExpressions = questionnaireStore.getState().enableWhenExpressions;
|
|
68
|
-
|
|
69
93
|
const updatedInvalidItems = validateQuestionnaire({
|
|
70
94
|
questionnaire,
|
|
71
|
-
questionnaireResponse: updatedResponse
|
|
72
|
-
enableWhenIsActivated,
|
|
73
|
-
enableWhenItems,
|
|
74
|
-
enableWhenExpressions
|
|
95
|
+
questionnaireResponse: updatedResponse
|
|
75
96
|
});
|
|
76
97
|
|
|
77
98
|
set(() => ({
|
|
@@ -80,49 +101,99 @@ export const questionnaireResponseStore = createStore<QuestionnaireResponseStore
|
|
|
80
101
|
}));
|
|
81
102
|
},
|
|
82
103
|
buildSourceResponse: (questionnaireResponse: QuestionnaireResponse) => {
|
|
104
|
+
const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;
|
|
105
|
+
const initialInvalidItems = validateQuestionnaire({
|
|
106
|
+
questionnaire: sourceQuestionnaire,
|
|
107
|
+
questionnaireResponse: questionnaireResponse
|
|
108
|
+
});
|
|
109
|
+
|
|
83
110
|
set(() => ({
|
|
84
111
|
sourceResponse: questionnaireResponse,
|
|
85
112
|
updatableResponse: questionnaireResponse,
|
|
86
|
-
updatableResponseItems: createQuestionnaireResponseItemMap(questionnaireResponse)
|
|
113
|
+
updatableResponseItems: createQuestionnaireResponseItemMap(questionnaireResponse),
|
|
114
|
+
invalidItems: initialInvalidItems,
|
|
115
|
+
responseIsValid: Object.keys(initialInvalidItems).length === 0
|
|
87
116
|
}));
|
|
88
117
|
},
|
|
89
118
|
setUpdatableResponseAsPopulated: (populatedResponse: QuestionnaireResponse) => {
|
|
119
|
+
const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;
|
|
90
120
|
const formChanges = diff(get().updatableResponse, populatedResponse) ?? null;
|
|
121
|
+
const updatedInvalidItems = validateQuestionnaire({
|
|
122
|
+
questionnaire: sourceQuestionnaire,
|
|
123
|
+
questionnaireResponse: populatedResponse
|
|
124
|
+
});
|
|
91
125
|
set(() => ({
|
|
92
126
|
updatableResponse: populatedResponse,
|
|
93
127
|
updatableResponseItems: createQuestionnaireResponseItemMap(populatedResponse),
|
|
94
|
-
formChangesHistory: [...get().formChangesHistory, formChanges]
|
|
128
|
+
formChangesHistory: [...get().formChangesHistory, formChanges],
|
|
129
|
+
invalidItems: updatedInvalidItems,
|
|
130
|
+
responseIsValid: Object.keys(updatedInvalidItems).length === 0
|
|
95
131
|
}));
|
|
96
132
|
},
|
|
97
133
|
updateResponse: (updatedResponse: QuestionnaireResponse) => {
|
|
134
|
+
const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;
|
|
98
135
|
const formChanges = diff(get().updatableResponse, updatedResponse) ?? null;
|
|
136
|
+
const updatedInvalidItems = validateQuestionnaire({
|
|
137
|
+
questionnaire: sourceQuestionnaire,
|
|
138
|
+
questionnaireResponse: updatedResponse
|
|
139
|
+
});
|
|
99
140
|
set(() => ({
|
|
100
141
|
updatableResponse: updatedResponse,
|
|
101
142
|
updatableResponseItems: createQuestionnaireResponseItemMap(updatedResponse),
|
|
102
|
-
formChangesHistory: [...get().formChangesHistory, formChanges]
|
|
143
|
+
formChangesHistory: [...get().formChangesHistory, formChanges],
|
|
144
|
+
invalidItems: updatedInvalidItems,
|
|
145
|
+
responseIsValid: Object.keys(updatedInvalidItems).length === 0
|
|
103
146
|
}));
|
|
104
147
|
},
|
|
105
|
-
setUpdatableResponseAsSaved: (savedResponse: QuestionnaireResponse) =>
|
|
148
|
+
setUpdatableResponseAsSaved: (savedResponse: QuestionnaireResponse) => {
|
|
149
|
+
const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;
|
|
150
|
+
const updatedInvalidItems = validateQuestionnaire({
|
|
151
|
+
questionnaire: sourceQuestionnaire,
|
|
152
|
+
questionnaireResponse: savedResponse
|
|
153
|
+
});
|
|
154
|
+
|
|
106
155
|
set(() => ({
|
|
107
156
|
sourceResponse: savedResponse,
|
|
108
157
|
updatableResponse: savedResponse,
|
|
109
158
|
updatableResponseItems: createQuestionnaireResponseItemMap(savedResponse),
|
|
110
|
-
formChangesHistory: []
|
|
111
|
-
|
|
112
|
-
|
|
159
|
+
formChangesHistory: [],
|
|
160
|
+
invalidItems: updatedInvalidItems,
|
|
161
|
+
responseIsValid: Object.keys(updatedInvalidItems).length === 0
|
|
162
|
+
}));
|
|
163
|
+
},
|
|
164
|
+
setUpdatableResponseAsEmpty: (clearedResponse: QuestionnaireResponse) => {
|
|
165
|
+
const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;
|
|
166
|
+
const updatedInvalidItems = validateQuestionnaire({
|
|
167
|
+
questionnaire: sourceQuestionnaire,
|
|
168
|
+
questionnaireResponse: clearedResponse
|
|
169
|
+
});
|
|
170
|
+
|
|
113
171
|
set(() => ({
|
|
114
172
|
updatableResponse: clearedResponse,
|
|
115
173
|
updatableResponseItems: createQuestionnaireResponseItemMap(clearedResponse),
|
|
116
|
-
formChangesHistory: []
|
|
117
|
-
|
|
174
|
+
formChangesHistory: [],
|
|
175
|
+
invalidItems: updatedInvalidItems,
|
|
176
|
+
responseIsValid: Object.keys(updatedInvalidItems).length === 0
|
|
177
|
+
}));
|
|
178
|
+
},
|
|
118
179
|
destroySourceResponse: () =>
|
|
119
180
|
set(() => ({
|
|
120
181
|
sourceResponse: cloneDeep(emptyResponse),
|
|
121
182
|
updatableResponse: cloneDeep(emptyResponse),
|
|
122
183
|
updatableResponseItems: createQuestionnaireResponseItemMap(cloneDeep(emptyResponse)),
|
|
123
|
-
formChangesHistory: []
|
|
184
|
+
formChangesHistory: [],
|
|
185
|
+
invalidItems: {},
|
|
186
|
+
responseIsValid: true
|
|
124
187
|
}))
|
|
125
188
|
})
|
|
126
189
|
);
|
|
127
190
|
|
|
191
|
+
/**
|
|
192
|
+
* QuestionnaireResponse state management store which contains all properties and methods to manage the state of the questionnaire.
|
|
193
|
+
* This is the React version of the store which can be used as React hooks in React functional components.
|
|
194
|
+
* @see {QuestionnaireResponseStoreType} for available properties and methods.
|
|
195
|
+
* @see {questionnaireResponseStore} for the vanilla store.
|
|
196
|
+
*
|
|
197
|
+
* @author Sean Fong
|
|
198
|
+
*/
|
|
128
199
|
export const useQuestionnaireResponseStore = createSelectors(questionnaireResponseStore);
|
|
@@ -25,7 +25,7 @@ import type {
|
|
|
25
25
|
import type { Variables } from '../interfaces/variables.interface';
|
|
26
26
|
import type { LaunchContext } from '../interfaces/populate.interface';
|
|
27
27
|
import type { CalculatedExpression } from '../interfaces/calculatedExpression.interface';
|
|
28
|
-
import type { EnableWhenExpressions, EnableWhenItems } from '../interfaces';
|
|
28
|
+
import type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';
|
|
29
29
|
import type { AnswerExpression } from '../interfaces/answerExpression.interface';
|
|
30
30
|
import type { Tabs } from '../interfaces/tab.interface';
|
|
31
31
|
import {
|
|
@@ -47,7 +47,47 @@ import { mutateRepeatEnableWhenExpressionInstances } from '../utils/enableWhenEx
|
|
|
47
47
|
import { questionnaireResponseStore } from './questionnaireResponseStore';
|
|
48
48
|
import { createQuestionnaireResponseItemMap } from '../utils/questionnaireResponseStoreUtils/updatableResponseItems';
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
/**
|
|
51
|
+
* QuestionnaireStore properties and methods
|
|
52
|
+
* Properties can be accessed for fine-grain details.
|
|
53
|
+
* Methods are usually used internally, using them from an external source is not recommended.
|
|
54
|
+
*
|
|
55
|
+
* @property sourceQuestionnaire - FHIR R4 Questionnaire to render
|
|
56
|
+
* @property itemTypes - Key-value pair of item types `Record<linkId, item.type>`
|
|
57
|
+
* @property tabs - Key-value pair of tabs `Record<linkId, Tab>`
|
|
58
|
+
* @property currentTabIndex - Index of the current tab
|
|
59
|
+
* @property variables - Questionnaire variables object containing FHIRPath and x-fhir-query variables
|
|
60
|
+
* @property launchContexts - Key-value pair of launch contexts `Record<launch context name, launch context properties>`
|
|
61
|
+
* @property enableWhenItems - EnableWhenItems object containing enableWhen items and their linked questions
|
|
62
|
+
* @property enableWhenLinkedQuestions - Key-value pair of linked questions to enableWhen items `Record<linkId, linkIds of linked questions>`
|
|
63
|
+
* @property enableWhenIsActivated - Flag to turn enableWhen checks on/off
|
|
64
|
+
* @property enableWhenExpressions - EnableWhenExpressions object containing enableWhen expressions
|
|
65
|
+
* @property calculatedExpressions - Key-value pair of calculated expressions `Record<linkId, array of calculated expression properties>`
|
|
66
|
+
* @property answerExpressions - Key-value pair of answer expressions `Record<linkId, answer expression properties>`
|
|
67
|
+
* @property processedValueSetCodings - Key-value pair of processed value set codings `Record<valueSetUrl, codings>`
|
|
68
|
+
* @property processedValueSetUrls - Key-value pair of contained value set urls `Record<valueSetName, valueSetUrl>`
|
|
69
|
+
* @property cachedValueSetCodings - Key-value pair of cached value set codings `Record<valueSetUrl, codings>`
|
|
70
|
+
* @property fhirPathContext - Key-value pair of evaluated FHIRPath values `Record<variable name, evaluated value(s)>`
|
|
71
|
+
* @property populatedContext - Key-value pair of one-off pre-populated FHIRPath values `Record<variable/launchContext/sourceQueries batch name, evaluated value(s)>`
|
|
72
|
+
* @property focusedLinkId - LinkId of the currently focused item
|
|
73
|
+
* @property readOnly - Flag to set the form to read-only mode
|
|
74
|
+
* @method buildSourceQuestionnaire - Used to build the source questionnaire with the provided questionnaire and optionally questionnaire response, additional variables, terminology server url and readyOnly flag
|
|
75
|
+
* @method destroySourceQuestionnaire - Used to destroy the source questionnaire and reset all properties
|
|
76
|
+
* @method switchTab - Used to switch the current tab index
|
|
77
|
+
* @method markTabAsComplete - Used to mark a tab index as complete
|
|
78
|
+
* @method updateEnableWhenItem - Used to update linked enableWhen items by updating a question with a new answer
|
|
79
|
+
* @method mutateRepeatEnableWhenItems - Used to add or remove instances of repeating enableWhen items
|
|
80
|
+
* @method toggleEnableWhenActivation - Used to toggle enableWhen checks on/off
|
|
81
|
+
* @method updateExpressions - Used to update all SDC expressions based on the updated questionnaire response
|
|
82
|
+
* @method addCodingToCache - Used to add a coding to the cached value set codings
|
|
83
|
+
* @method updatePopulatedProperties - Used to update all SDC expressions based on a pre-populated questionnaire response
|
|
84
|
+
* @method onFocusLinkId - Used to set the focused linkId
|
|
85
|
+
* @method setPopulatedContext - Used to set the populated contexts (launchContext, sourceQueries, x-fhir-query vars) for debugging purposes
|
|
86
|
+
* @method setFormAsReadOnly - Used to set the form as read-only
|
|
87
|
+
*
|
|
88
|
+
* @author Sean Fong
|
|
89
|
+
*/
|
|
90
|
+
export interface QuestionnaireStoreType {
|
|
51
91
|
sourceQuestionnaire: Questionnaire;
|
|
52
92
|
itemTypes: Record<string, string>;
|
|
53
93
|
tabs: Tabs;
|
|
@@ -97,8 +137,16 @@ interface QuestionnaireStoreType {
|
|
|
97
137
|
) => QuestionnaireResponse;
|
|
98
138
|
onFocusLinkId: (linkId: string) => void;
|
|
99
139
|
setPopulatedContext: (newPopulatedContext: Record<string, any>) => void;
|
|
140
|
+
setFormAsReadOnly: (readOnly: boolean) => void;
|
|
100
141
|
}
|
|
101
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Questionnaire state management store which contains all properties and methods to manage the state of the questionnaire.
|
|
145
|
+
* This is the vanilla version of the store which can be used in non-React environments.
|
|
146
|
+
* @see {QuestionnaireStoreType} for available properties and methods.
|
|
147
|
+
*
|
|
148
|
+
* @author Sean Fong
|
|
149
|
+
*/
|
|
102
150
|
export const questionnaireStore = createStore<QuestionnaireStoreType>()((set, get) => ({
|
|
103
151
|
sourceQuestionnaire: cloneDeep(emptyQuestionnaire),
|
|
104
152
|
itemTypes: {},
|
|
@@ -349,7 +397,19 @@ export const questionnaireStore = createStore<QuestionnaireStoreType>()((set, ge
|
|
|
349
397
|
setPopulatedContext: (newPopulatedContext: Record<string, any>) =>
|
|
350
398
|
set(() => ({
|
|
351
399
|
populatedContext: newPopulatedContext
|
|
400
|
+
})),
|
|
401
|
+
setFormAsReadOnly: (readOnly: boolean) =>
|
|
402
|
+
set(() => ({
|
|
403
|
+
readOnly: readOnly
|
|
352
404
|
}))
|
|
353
405
|
}));
|
|
354
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Questionnaire state management store which contains all properties and methods to manage the state of the questionnaire.
|
|
409
|
+
* This is the React version of the store which can be used as React hooks in React functional components.
|
|
410
|
+
* @see {QuestionnaireStoreType} for available properties and methods.
|
|
411
|
+
* @see {questionnaireStore} for the vanilla store.
|
|
412
|
+
*
|
|
413
|
+
* @author Sean Fong
|
|
414
|
+
*/
|
|
355
415
|
export const useQuestionnaireStore = createSelectors(questionnaireStore);
|
|
@@ -20,6 +20,22 @@ import type { Encounter, Patient, Practitioner } from 'fhir/r4';
|
|
|
20
20
|
import type Client from 'fhirclient/lib/Client';
|
|
21
21
|
import { createSelectors } from './selector';
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* SmartConfigStore properties and methods
|
|
25
|
+
* Properties can be accessed for fine-grain details.
|
|
26
|
+
* Methods are usually used internally, using them from an external source is not recommended.
|
|
27
|
+
*
|
|
28
|
+
* @property client - The FHIRClient object (https://github.com/smart-on-fhir/client-js)
|
|
29
|
+
* @property patient - The patient resource in context
|
|
30
|
+
* @property user - The user resource in context
|
|
31
|
+
* @property encounter - The encounter resource in context
|
|
32
|
+
* @method setClient - Set the FHIRClient object when launching via SMART App Launch
|
|
33
|
+
* @method setPatient - Set the patient resource in context
|
|
34
|
+
* @method setUser - Set the user resource in context
|
|
35
|
+
* @method setEncounter - Set the encounter resource in context
|
|
36
|
+
*
|
|
37
|
+
* @author Sean Fong
|
|
38
|
+
*/
|
|
23
39
|
export interface SmartConfigStoreType {
|
|
24
40
|
client: Client | null;
|
|
25
41
|
patient: Patient | null;
|
|
@@ -31,6 +47,16 @@ export interface SmartConfigStoreType {
|
|
|
31
47
|
setEncounter: (encounter: Encounter) => void;
|
|
32
48
|
}
|
|
33
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Smart Config state management store. This is only used for answerExpressions.
|
|
52
|
+
* 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.
|
|
53
|
+
* Will be deprecated in version 1.0.0.
|
|
54
|
+
*
|
|
55
|
+
* This is the vanilla version of the store which can be used in non-React environments.
|
|
56
|
+
* @see {SmartConfigStoreType} for available properties and methods.
|
|
57
|
+
*
|
|
58
|
+
* @author Sean Fong
|
|
59
|
+
*/
|
|
34
60
|
export const smartConfigStore = createStore<SmartConfigStoreType>()((set) => ({
|
|
35
61
|
client: null,
|
|
36
62
|
patient: null,
|
|
@@ -42,4 +68,15 @@ export const smartConfigStore = createStore<SmartConfigStoreType>()((set) => ({
|
|
|
42
68
|
setEncounter: (encounter: Encounter) => set(() => ({ encounter: encounter }))
|
|
43
69
|
}));
|
|
44
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Smart Config state management store. This is only used for answerExpressions.
|
|
73
|
+
* 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.
|
|
74
|
+
* Will be deprecated in version 1.0.0.
|
|
75
|
+
*
|
|
76
|
+
* This is the React version of the store which can be used as React hooks in React functional components.
|
|
77
|
+
* @see {SmartConfigStoreType} for available properties and methods.
|
|
78
|
+
* @see {smartConfigStore} for the vanilla store.
|
|
79
|
+
*
|
|
80
|
+
* @author Sean Fong
|
|
81
|
+
*/
|
|
45
82
|
export const useSmartConfigStore = createSelectors(smartConfigStore);
|