@aehrc/smart-forms-renderer 0.30.1 → 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/ItemParts/ItemLabelText.js +2 -2
- package/lib/components/FormComponents/ItemParts/ItemLabelText.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/useDisplayCqfAndCalculatedExpression.d.ts +3 -0
- package/lib/hooks/useDisplayCqfAndCalculatedExpression.js +40 -0
- package/lib/hooks/useDisplayCqfAndCalculatedExpression.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/debounce.d.ts +1 -1
- package/lib/utils/debounce.js +1 -1
- 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/getExpressionsFromItem.js +16 -3
- package/lib/utils/getExpressionsFromItem.js.map +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/ItemParts/ItemLabelText.tsx +2 -2
- 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/{useDisplayCalculatedExpression.ts → useDisplayCqfAndCalculatedExpression.ts} +11 -11
- 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/QDisplay.ts +77 -0
- package/src/stories/assets/questionnaires/QValidateTester.ts +118 -0
- package/src/stories/assets/questionnaires/index.ts +0 -2
- 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 +10 -4
- 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/debounce.ts +1 -1
- package/src/utils/enableWhen.ts +1 -1
- package/src/utils/enableWhenExpression.ts +1 -1
- package/src/utils/fhirpath.ts +1 -1
- package/src/utils/getExpressionsFromItem.ts +16 -4
- 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.log +0 -6
- /package/.storybook/{preview.ts → preview.tsx} +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
import React, { useState } from 'react';
|
|
28
|
+
import { BaseRenderer } from '../../components';
|
|
29
|
+
import { QueryClientProvider } from '@tanstack/react-query';
|
|
30
|
+
import { RendererThemeProvider } from '../../theme';
|
|
31
|
+
import { useBuildForm, useRendererQueryClient } from '../../hooks';
|
|
32
|
+
import PrePopButtonForStorybook from './PrePopButtonForStorybook';
|
|
33
|
+
import { populateQuestionnaire } from '@aehrc/sdc-populate';
|
|
34
|
+
import { fetchResourceCallback } from './populateCallbackForStorybook';
|
|
35
|
+
import { buildForm } from '../../utils';
|
|
36
|
+
/**
|
|
37
|
+
* This is a demo wrapper which initialises the BaseRenderer with the passed in questionnaire using useBuildForm.
|
|
38
|
+
* It also provides a button to pre-populate the questionnaire on the fly using populateQuestionnaire() from '@aehrc/sdc-populate'.
|
|
39
|
+
* This does in-app population and you have to define your own callback function to retrieve resources from your source server.
|
|
40
|
+
*
|
|
41
|
+
* Use this pattern if you do not have a pre-populated/pre-filled/draft response and want to pre-populate on the fly.
|
|
42
|
+
* If you already have a questionnaireResponse, see https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx instead
|
|
43
|
+
*
|
|
44
|
+
* @author Sean Fong
|
|
45
|
+
*/
|
|
46
|
+
function PrePopWrapperForStorybook(props) {
|
|
47
|
+
const { questionnaire, fhirClient, patient, user } = props;
|
|
48
|
+
const [isPopulating, setIsPopulating] = useState(false);
|
|
49
|
+
const isBuilding = useBuildForm(questionnaire);
|
|
50
|
+
const queryClient = useRendererQueryClient();
|
|
51
|
+
function handlePrepopulate() {
|
|
52
|
+
setIsPopulating(true);
|
|
53
|
+
populateQuestionnaire({
|
|
54
|
+
questionnaire: questionnaire,
|
|
55
|
+
fetchResourceCallback: fetchResourceCallback,
|
|
56
|
+
requestConfig: {
|
|
57
|
+
clientEndpoint: fhirClient.state.serverUrl,
|
|
58
|
+
authToken: null
|
|
59
|
+
},
|
|
60
|
+
patient: patient,
|
|
61
|
+
user: user
|
|
62
|
+
}).then(({ populateSuccess, populateResult }) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
if (!populateSuccess || !populateResult) {
|
|
64
|
+
setIsPopulating(false);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const { populatedResponse } = populateResult;
|
|
68
|
+
// Call to buildForm to pre-populate the QR which repaints the entire BaseRenderer view
|
|
69
|
+
yield buildForm(questionnaire, populatedResponse);
|
|
70
|
+
setIsPopulating(false);
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
if (isBuilding) {
|
|
74
|
+
return React.createElement("div", null, "Loading...");
|
|
75
|
+
}
|
|
76
|
+
return (React.createElement(RendererThemeProvider, null,
|
|
77
|
+
React.createElement(QueryClientProvider, { client: queryClient },
|
|
78
|
+
React.createElement("div", null,
|
|
79
|
+
React.createElement(PrePopButtonForStorybook, { isPopulating: isPopulating, onPopulate: handlePrepopulate }),
|
|
80
|
+
isPopulating ? null : React.createElement(BaseRenderer, null)))));
|
|
81
|
+
}
|
|
82
|
+
export default PrePopWrapperForStorybook;
|
|
83
|
+
//# sourceMappingURL=PrePopWrapperForStorybook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrePopWrapperForStorybook.js","sourceRoot":"","sources":["../../../src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;AAEH,aAAa;AACb,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,O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I;gBACtF,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAC,YAAY,OAAG,CACnC,CACc,CACA,CACzB,CAAC;AACJ,CAAC;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { default as InitialiseFormWrapperForStorybook } from './InitialiseFormWrapperForStorybook';
|
|
2
|
+
export { default as BuildFormButtonTesterWrapperForStorybook } from './BuildFormButtonTesterWrapperForStorybook';
|
|
3
|
+
export { default as PrePopWrapperForStorybook } from './PrePopWrapperForStorybook';
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
export { default as InitialiseFormWrapperForStorybook } from './InitialiseFormWrapperForStorybook';
|
|
18
|
+
export { default as BuildFormButtonTesterWrapperForStorybook } from './BuildFormButtonTesterWrapperForStorybook';
|
|
19
|
+
export { default as PrePopWrapperForStorybook } from './PrePopWrapperForStorybook';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stories/StorybookWrappers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,IAAI,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAAE,OAAO,IAAI,wCAAwC,EAAE,MAAM,4CAA4C,CAAC;AACjH,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FetchResourceCallback } from '@aehrc/sdc-populate';
|
|
2
|
+
/**
|
|
3
|
+
* Sample callback function to fetch resources from your source server when using populate() or populateQuestionnaire() from @aehrc/sdc-populate.
|
|
4
|
+
* See https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx#L50-L59 for usage.
|
|
5
|
+
*
|
|
6
|
+
* @author Sean Fong
|
|
7
|
+
*/
|
|
8
|
+
export declare const fetchResourceCallback: FetchResourceCallback;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
import axios from 'axios';
|
|
18
|
+
const ABSOLUTE_URL_REGEX = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/;
|
|
19
|
+
/**
|
|
20
|
+
* Sample callback function to fetch resources from your source server when using populate() or populateQuestionnaire() from @aehrc/sdc-populate.
|
|
21
|
+
* See https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx#L50-L59 for usage.
|
|
22
|
+
*
|
|
23
|
+
* @author Sean Fong
|
|
24
|
+
*/
|
|
25
|
+
export const fetchResourceCallback = (query, requestConfig) => {
|
|
26
|
+
let { clientEndpoint } = requestConfig;
|
|
27
|
+
const { authToken } = requestConfig;
|
|
28
|
+
const headers = {
|
|
29
|
+
Accept: 'application/json;charset=utf-8'
|
|
30
|
+
};
|
|
31
|
+
if (authToken) {
|
|
32
|
+
headers['Authorization'] = `Bearer ${authToken}`;
|
|
33
|
+
}
|
|
34
|
+
if (!clientEndpoint.endsWith('/')) {
|
|
35
|
+
clientEndpoint += '/';
|
|
36
|
+
}
|
|
37
|
+
if (ABSOLUTE_URL_REGEX.test(query)) {
|
|
38
|
+
return axios.get(query, {
|
|
39
|
+
headers: headers
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return axios.get(clientEndpoint + query, {
|
|
43
|
+
headers: headers
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=populateCallbackForStorybook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"populateCallbackForStorybook.js","sourceRoot":"","sources":["../../../src/stories/StorybookWrappers/populateCallbackForStorybook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;AAOlE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA0B,CAC1D,KAAa,EACb,aAA4B,EAC5B,EAAE;IACF,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC;IACvC,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC;IAEpC,MAAM,OAAO,GAAQ;QACnB,MAAM,EAAE,gCAAgC;KACzC,CAAC;IAEF,IAAI,SAAS,EAAE;QACb,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,SAAS,EAAE,CAAC;KAClD;IAED,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACjC,cAAc,IAAI,GAAG,CAAC;KACvB;IAED,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QAClC,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE;YACtB,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;KACJ;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,GAAG,KAAK,EAAE;QACvC,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as InitialiseFormWrapperForStorybook } from './InitialiseFormWrapperForStorybook';
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export { default as InitialiseFormWrapperForStorybook } from './InitialiseFormWrapperForStorybook';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stories/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,IAAI,iCAAiC,EAAE,MAAM,qCAAqC,CAAC"}
|
package/lib/theme/Theme.d.ts
CHANGED
|
@@ -32,7 +32,13 @@ declare module '@mui/material/styles' {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
export declare const themeOptions: ThemeOptions;
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Default Material UI theme used by the renderer. You can customise your own theme by defining a new ThemeProvider.
|
|
37
|
+
* @see {@link https://mui.com/material-ui/customization/theming/}
|
|
38
|
+
*
|
|
39
|
+
* @author Sean Fong
|
|
40
|
+
*/
|
|
41
|
+
export declare function RendererThemeProvider({ children }: {
|
|
36
42
|
children: ReactNode;
|
|
37
43
|
}): React.JSX.Element;
|
|
38
|
-
export default
|
|
44
|
+
export default RendererThemeProvider;
|
package/lib/theme/Theme.js
CHANGED
|
@@ -26,7 +26,13 @@ export const themeOptions = {
|
|
|
26
26
|
dropdown: `0 0 2px 0 ${alpha(grey[500], 0.24)}, -20px 20px 40px -4px ${alpha(grey[500], 0.24)}`
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Default Material UI theme used by the renderer. You can customise your own theme by defining a new ThemeProvider.
|
|
31
|
+
* @see {@link https://mui.com/material-ui/customization/theming/}
|
|
32
|
+
*
|
|
33
|
+
* @author Sean Fong
|
|
34
|
+
*/
|
|
35
|
+
export function RendererThemeProvider({ children }) {
|
|
30
36
|
const theme = createTheme(themeOptions);
|
|
31
37
|
theme.components = componentsOverride(theme);
|
|
32
38
|
return (React.createElement(StyledEngineProvider, { injectFirst: true },
|
|
@@ -35,5 +41,5 @@ function ThemeProvider({ children }) {
|
|
|
35
41
|
React.createElement(CustomGlobalStyles, null),
|
|
36
42
|
children)));
|
|
37
43
|
}
|
|
38
|
-
export default
|
|
44
|
+
export default RendererThemeProvider;
|
|
39
45
|
//# sourceMappingURL=Theme.js.map
|
package/lib/theme/Theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Theme.js","sourceRoot":"","sources":["../../src/theme/Theme.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,KAAK,EACL,WAAW,EACX,oBAAoB,EACpB,aAAa,IAAI,gBAAgB,EAClC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,WAAW,MAAM,2BAA2B,CAAC;AACpD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAsC5C,yEAAyE;AAEzE,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,OAAO;IACP,KAAK,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE;IAC1B,UAAU;IACV,aAAa,EAAE;QACb,EAAE,EAAE,eAAe,WAAW,EAAE;QAChC,EAAE,EAAE,eAAe,WAAW,EAAE;QAChC,EAAE,EAAE,gBAAgB,WAAW,EAAE;QACjC,GAAG,EAAE,oBAAoB,WAAW,EAAE;QACtC,GAAG,EAAE,oBAAoB,WAAW,EAAE;QACtC,GAAG,EAAE,oBAAoB,WAAW,EAAE;QACtC,GAAG,EAAE,iBAAiB,WAAW,EAAE;QACnC,EAAE;QACF,IAAI,EAAE,aAAa,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,sBAAsB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAA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,IAAI,EAAE,aAAa,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,sBAAsB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE;QACtF,MAAM,EAAE,wBAAwB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE;QACxD,QAAQ,EAAE,aAAa,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,0BAA0B,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE;KAChG;CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,EAAE,QAAQ,EAA2B;IACzE,MAAM,KAAK,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;IACxC,KAAK,CAAC,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAE7C,OAAO,CACL,oBAAC,oBAAoB,IAAC,WAAW;QAC/B,oBAAC,gBAAgB,IAAC,KAAK,EAAE,KAAK;YAC5B,oBAAC,WAAW,OAAG;YACf,oBAAC,kBAAkB,OAAG;YACrB,QAAQ,CACQ,CACE,CACxB,CAAC;AACJ,CAAC;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RendererThemeProvider } from './Theme';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
|
package/lib/utils/debounce.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const DEBOUNCE_DURATION =
|
|
1
|
+
export declare const DEBOUNCE_DURATION = 300;
|
|
2
2
|
export declare const AUTOCOMPLETE_DEBOUNCE_DURATION = 300;
|
package/lib/utils/debounce.js
CHANGED
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
export const DEBOUNCE_DURATION =
|
|
17
|
+
export const DEBOUNCE_DURATION = 300;
|
|
18
18
|
export const AUTOCOMPLETE_DEBOUNCE_DURATION = 300;
|
|
19
19
|
//# sourceMappingURL=debounce.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { QuestionnaireItemEnableWhen, QuestionnaireResponse, QuestionnaireResponseItemAnswer } from 'fhir/r4';
|
|
2
|
-
import type { EnableWhenItems, EnableWhenRepeatItemProperties, EnableWhenSingleItemProperties } from '../interfaces';
|
|
2
|
+
import type { EnableWhenItems, EnableWhenRepeatItemProperties, EnableWhenSingleItemProperties } from '../interfaces/enableWhen.interface';
|
|
3
3
|
/**
|
|
4
4
|
* Create a linkedQuestionsMap that contains linked items of enableWhen items
|
|
5
5
|
* mapped to an array containing all its respective enableWhen items' linkIds
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Expression, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';
|
|
2
|
-
import type { EnableWhenExpressions, EnableWhenRepeatExpression } from '../interfaces';
|
|
2
|
+
import type { EnableWhenExpressions, EnableWhenRepeatExpression } from '../interfaces/enableWhen.interface';
|
|
3
3
|
interface EvaluateInitialEnableWhenExpressionsParams {
|
|
4
4
|
initialResponse: QuestionnaireResponse;
|
|
5
5
|
initialResponseItemMap: Record<string, QuestionnaireResponseItem[]>;
|
package/lib/utils/fhirpath.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Expression, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';
|
|
2
2
|
import type { CalculatedExpression } from '../interfaces/calculatedExpression.interface';
|
|
3
|
-
import type { EnableWhenExpressions } from '../interfaces';
|
|
3
|
+
import type { EnableWhenExpressions } from '../interfaces/enableWhen.interface';
|
|
4
4
|
interface EvaluateUpdatedExpressionsParams {
|
|
5
5
|
updatedResponse: QuestionnaireResponse;
|
|
6
6
|
updatedResponseItemMap: Record<string, QuestionnaireResponseItem[]>;
|
|
@@ -38,7 +38,8 @@ export function getEnableWhenExpression(qItem) {
|
|
|
38
38
|
* @author Sean Fong
|
|
39
39
|
*/
|
|
40
40
|
export function getCalculatedExpressions(qItem) {
|
|
41
|
-
var _a, _b, _c;
|
|
41
|
+
var _a, _b, _c, _d, _e;
|
|
42
|
+
// For questions - calculatedExpressions
|
|
42
43
|
const calculatedExpressionsInItem = findCalculatedExpressionsInExtensions((_a = qItem.extension) !== null && _a !== void 0 ? _a : [])
|
|
43
44
|
.map((calculatedExpression) => {
|
|
44
45
|
var _a, _b;
|
|
@@ -48,7 +49,12 @@ export function getCalculatedExpressions(qItem) {
|
|
|
48
49
|
});
|
|
49
50
|
})
|
|
50
51
|
.filter((calculatedExpression) => calculatedExpression.expression !== '');
|
|
51
|
-
|
|
52
|
+
// For item._text - calculatedExpressions and cqfExpressions
|
|
53
|
+
// FIXME this is a band aid addition, eventually we want to fully support cqfExpressions
|
|
54
|
+
const calculatedAndCqfExpressionsInText = [
|
|
55
|
+
...findCqfExpressionsInExtensions((_c = (_b = qItem._text) === null || _b === void 0 ? void 0 : _b.extension) !== null && _c !== void 0 ? _c : []),
|
|
56
|
+
...findCalculatedExpressionsInExtensions((_e = (_d = qItem._text) === null || _d === void 0 ? void 0 : _d.extension) !== null && _e !== void 0 ? _e : [])
|
|
57
|
+
]
|
|
52
58
|
.map((calculatedExpression) => {
|
|
53
59
|
var _a, _b;
|
|
54
60
|
return ({
|
|
@@ -57,7 +63,7 @@ export function getCalculatedExpressions(qItem) {
|
|
|
57
63
|
});
|
|
58
64
|
})
|
|
59
65
|
.filter((calculatedExpression) => calculatedExpression.expression !== '');
|
|
60
|
-
return [...calculatedExpressionsInItem, ...
|
|
66
|
+
return [...calculatedExpressionsInItem, ...calculatedAndCqfExpressionsInText];
|
|
61
67
|
}
|
|
62
68
|
function findCalculatedExpressionsInExtensions(extensions) {
|
|
63
69
|
return extensions.filter((extension) => {
|
|
@@ -67,6 +73,13 @@ function findCalculatedExpressionsInExtensions(extensions) {
|
|
|
67
73
|
((_a = extension.valueExpression) === null || _a === void 0 ? void 0 : _a.language) === 'text/fhirpath';
|
|
68
74
|
});
|
|
69
75
|
}
|
|
76
|
+
function findCqfExpressionsInExtensions(extensions) {
|
|
77
|
+
return extensions.filter((extension) => {
|
|
78
|
+
var _a;
|
|
79
|
+
return extension.url === 'http://hl7.org/fhir/StructureDefinition/cqf-expression' &&
|
|
80
|
+
((_a = extension.valueExpression) === null || _a === void 0 ? void 0 : _a.language) === 'text/fhirpath';
|
|
81
|
+
});
|
|
82
|
+
}
|
|
70
83
|
/**
|
|
71
84
|
* Get answerExpression.valueExpression if its present in item
|
|
72
85
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExpressionsFromItem.js","sourceRoot":"","sources":["../../src/utils/getExpressionsFromItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAwB;;IAC9D,MAAM,oBAAoB,GAAG,MAAA,KAAK,CAAC,SAAS,0CAAE,IAAI,CAChD,CAAC,SAAoB,EAAE,EAAE;;QACvB,OAAA,SAAS,CAAC,GAAG;YACX,uFAAuF;YACzF,CAAA,MAAA,SAAS,CAAC,eAAe,0CAAE,QAAQ,MAAK,eAAe,CAAA;KAAA,CAC1D,CAAC;IAEF,IAAI,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAE,eAAe,EAAE;QACzC,OAAO,oBAAoB,CAAC,eAAe,CAAC;KAC7C;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAwB;;IAC/D,MAAM,2BAA2B,GAAG,qCAAqC,CAAC,MAAA,KAAK,CAAC,SAAS,mCAAI,EAAE,CAAC;SAC7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AAA,KAAK,CAAC,SAAS,0CAAE,IAAI,CACvC,CAAC,SAAoB,EAAE,EAAE;;QACvB,OAAA,SAAS,CAAC,GAAG;YACX,mFAAmF;YACrF,CAAA,MAAA,SAAS,CAAC,eAAe,0CAAE,QAAQ,MAAK,eAAe,CAAA;KAAA,CAC1D,CAAC;IACF,IAAI,WAAW,EAAE;QACf,IAAI,WAAW,CAAC,eAAe,EAAE;YAC/B,OAAO,WAAW,CAAC,eAAe,CAAC;SACpC;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export { buildForm, destroyForm, getResponse, removeEmptyAnswersFromResponse } from './manageForm';
|
|
2
|
+
export { initialiseQuestionnaireResponse } from './initialise';
|
|
1
3
|
export { isSpecificItemControl } from './itemControl';
|
|
2
4
|
export { isRepeatItemAndNotCheckbox } from './qItem';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
5
|
+
export type { ItemToRepopulate } from './repopulateItems';
|
|
6
|
+
export { generateItemsToRepopulate } from './repopulateItems';
|
|
7
|
+
export { repopulateResponse } from './repopulateIntoResponse';
|
package/lib/utils/index.js
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
export { buildForm, destroyForm, getResponse, removeEmptyAnswersFromResponse } from './manageForm';
|
|
18
|
+
export { initialiseQuestionnaireResponse } from './initialise';
|
|
17
19
|
export { isSpecificItemControl } from './itemControl';
|
|
18
20
|
export { isRepeatItemAndNotCheckbox } from './qItem';
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export { buildForm } from './buildForm';
|
|
21
|
+
export { generateItemsToRepopulate } from './repopulateItems';
|
|
22
|
+
export { repopulateResponse } from './repopulateIntoResponse';
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AACnG,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Expression, Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
-
import type { EnableWhenExpressions, EnableWhenItems } from '../interfaces';
|
|
2
|
+
import type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';
|
|
3
3
|
import type { Tabs } from '../interfaces/tab.interface';
|
|
4
4
|
import type { CalculatedExpression } from '../interfaces/calculatedExpression.interface';
|
|
5
5
|
/**
|
|
6
|
-
* Initialise a
|
|
6
|
+
* Initialise a questionnaireResponse from a given questionnaire
|
|
7
7
|
* optionally takes in an existing questionnaireResponse to be initialised
|
|
8
8
|
*
|
|
9
9
|
* @author Sean Fong
|
package/lib/utils/initialise.js
CHANGED
|
@@ -20,7 +20,7 @@ import { assignPopulatedAnswersToEnableWhen } from './enableWhen';
|
|
|
20
20
|
import { evaluateInitialCalculatedExpressions } from './calculatedExpression';
|
|
21
21
|
import { createQuestionnaireResponseItemMap } from './questionnaireResponseStoreUtils/updatableResponseItems';
|
|
22
22
|
/**
|
|
23
|
-
* Initialise a
|
|
23
|
+
* Initialise a questionnaireResponse from a given questionnaire
|
|
24
24
|
* optionally takes in an existing questionnaireResponse to be initialised
|
|
25
25
|
*
|
|
26
26
|
* @author Sean Fong
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
+
import type Client from 'fhirclient/lib/Client';
|
|
3
|
+
/**
|
|
4
|
+
* Build the form with an initial Questionnaire and an optional filled QuestionnaireResponse.
|
|
5
|
+
* If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse.
|
|
6
|
+
* There are other optional properties such as applying readOnly, providing a terminology server url and additional variables.
|
|
7
|
+
*
|
|
8
|
+
* @param questionnaire - Questionnaire to be rendered
|
|
9
|
+
* @param questionnaireResponse - Pre-populated/draft/loaded QuestionnaireResponse to be rendered (optional)
|
|
10
|
+
* @param readOnly - Applies read-only mode to all items in the form view
|
|
11
|
+
* @param terminologyServerUrl - Terminology server url to fetch terminology. If not provided, the default terminology server will be used. (optional)
|
|
12
|
+
* @param additionalVariables - Additional key-value pair of SDC variables `Record<name, variable extension>` for testing (optional)
|
|
13
|
+
*
|
|
14
|
+
* @author Sean Fong
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildForm(questionnaire: Questionnaire, questionnaireResponse?: QuestionnaireResponse, readOnly?: boolean, terminologyServerUrl?: string, additionalVariables?: Record<string, object>): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Destroy the form to clean up the questionnaire and questionnaireResponse stores.
|
|
19
|
+
*
|
|
20
|
+
* @author Sean Fong
|
|
21
|
+
*/
|
|
22
|
+
export declare function destroyForm(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Initialise the FHIRClient object to make further FHIR calls in the renderer.
|
|
25
|
+
* Note that this does not provide pre-population capabilities.
|
|
26
|
+
*
|
|
27
|
+
* @param fhirClient - FHIRClient object to perform further FHIR calls. At the moment it's only used in answerExpressions
|
|
28
|
+
*
|
|
29
|
+
* @author Sean Fong
|
|
30
|
+
*/
|
|
31
|
+
export declare function initialiseFhirClient(fhirClient: Client): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the filled QuestionnaireResponse at its current state.
|
|
34
|
+
* If no changes have been made to the form, the initial QuestionnaireResponse is returned.
|
|
35
|
+
*
|
|
36
|
+
* @author Sean Fong
|
|
37
|
+
*/
|
|
38
|
+
export declare function getResponse(): QuestionnaireResponse;
|
|
39
|
+
/**
|
|
40
|
+
* Remove all hidden answers from the filled QuestionnaireResponse.
|
|
41
|
+
* This takes into account enableWhens, enableWhenExpressions, items without item.answer, empty item.answer arrays and empty strings.
|
|
42
|
+
*
|
|
43
|
+
* @author Sean Fong
|
|
44
|
+
*/
|
|
45
|
+
export declare function removeEmptyAnswersFromResponse(questionnaire: Questionnaire, questionnaireResponse: QuestionnaireResponse): QuestionnaireResponse;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { questionnaireResponseStore, questionnaireStore, smartConfigStore } from '../stores';
|
|
11
|
+
import { initialiseQuestionnaireResponse } from './initialise';
|
|
12
|
+
import { removeEmptyAnswers } from './removeEmptyAnswers';
|
|
13
|
+
import { readEncounter, readPatient, readUser } from '../api/smartClient';
|
|
14
|
+
/**
|
|
15
|
+
* Build the form with an initial Questionnaire and an optional filled QuestionnaireResponse.
|
|
16
|
+
* If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse.
|
|
17
|
+
* There are other optional properties such as applying readOnly, providing a terminology server url and additional variables.
|
|
18
|
+
*
|
|
19
|
+
* @param questionnaire - Questionnaire to be rendered
|
|
20
|
+
* @param questionnaireResponse - Pre-populated/draft/loaded QuestionnaireResponse to be rendered (optional)
|
|
21
|
+
* @param readOnly - Applies read-only mode to all items in the form view
|
|
22
|
+
* @param terminologyServerUrl - Terminology server url to fetch terminology. If not provided, the default terminology server will be used. (optional)
|
|
23
|
+
* @param additionalVariables - Additional key-value pair of SDC variables `Record<name, variable extension>` for testing (optional)
|
|
24
|
+
*
|
|
25
|
+
* @author Sean Fong
|
|
26
|
+
*/
|
|
27
|
+
export function buildForm(questionnaire, questionnaireResponse, readOnly, terminologyServerUrl, additionalVariables) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
// QR is set to undefined here to prevent it from being initialised twice. This is defined like that for backward compatibility purposes.
|
|
30
|
+
yield questionnaireStore
|
|
31
|
+
.getState()
|
|
32
|
+
.buildSourceQuestionnaire(questionnaire, undefined, additionalVariables, terminologyServerUrl);
|
|
33
|
+
const initialisedQuestionnaireResponse = initialiseQuestionnaireResponse(questionnaire, questionnaireResponse);
|
|
34
|
+
questionnaireResponseStore.getState().buildSourceResponse(initialisedQuestionnaireResponse);
|
|
35
|
+
questionnaireStore.getState().updatePopulatedProperties(initialisedQuestionnaireResponse);
|
|
36
|
+
if (readOnly) {
|
|
37
|
+
questionnaireStore.getState().setFormAsReadOnly(readOnly);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Destroy the form to clean up the questionnaire and questionnaireResponse stores.
|
|
43
|
+
*
|
|
44
|
+
* @author Sean Fong
|
|
45
|
+
*/
|
|
46
|
+
export function destroyForm() {
|
|
47
|
+
questionnaireStore.getState().destroySourceQuestionnaire();
|
|
48
|
+
questionnaireResponseStore.getState().destroySourceResponse();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Initialise the FHIRClient object to make further FHIR calls in the renderer.
|
|
52
|
+
* Note that this does not provide pre-population capabilities.
|
|
53
|
+
*
|
|
54
|
+
* @param fhirClient - FHIRClient object to perform further FHIR calls. At the moment it's only used in answerExpressions
|
|
55
|
+
*
|
|
56
|
+
* @author Sean Fong
|
|
57
|
+
*/
|
|
58
|
+
export function initialiseFhirClient(fhirClient) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
smartConfigStore.getState().setClient(fhirClient);
|
|
61
|
+
const patientPromise = readPatient(fhirClient);
|
|
62
|
+
const userPromise = readUser(fhirClient);
|
|
63
|
+
const encounterPromise = readEncounter(fhirClient);
|
|
64
|
+
const [patient, user, encounter] = yield Promise.all([
|
|
65
|
+
patientPromise,
|
|
66
|
+
userPromise,
|
|
67
|
+
encounterPromise
|
|
68
|
+
]);
|
|
69
|
+
smartConfigStore.getState().setPatient(patient);
|
|
70
|
+
smartConfigStore.getState().setUser(user);
|
|
71
|
+
smartConfigStore.getState().setEncounter(encounter);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the filled QuestionnaireResponse at its current state.
|
|
76
|
+
* If no changes have been made to the form, the initial QuestionnaireResponse is returned.
|
|
77
|
+
*
|
|
78
|
+
* @author Sean Fong
|
|
79
|
+
*/
|
|
80
|
+
export function getResponse() {
|
|
81
|
+
return questionnaireResponseStore.getState().updatableResponse;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Remove all hidden answers from the filled QuestionnaireResponse.
|
|
85
|
+
* This takes into account enableWhens, enableWhenExpressions, items without item.answer, empty item.answer arrays and empty strings.
|
|
86
|
+
*
|
|
87
|
+
* @author Sean Fong
|
|
88
|
+
*/
|
|
89
|
+
export function removeEmptyAnswersFromResponse(questionnaire, questionnaireResponse) {
|
|
90
|
+
const enableWhenIsActivated = questionnaireStore.getState().enableWhenIsActivated;
|
|
91
|
+
const enableWhenItems = questionnaireStore.getState().enableWhenItems;
|
|
92
|
+
const enableWhenExpressions = questionnaireStore.getState().enableWhenExpressions;
|
|
93
|
+
return removeEmptyAnswers({
|
|
94
|
+
questionnaire,
|
|
95
|
+
questionnaireResponse,
|
|
96
|
+
enableWhenIsActivated,
|
|
97
|
+
enableWhenItems,
|
|
98
|
+
enableWhenExpressions
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=manageForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manageForm.js","sourceRoot":"","sources":["../../src/utils/manageForm.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7F,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG1E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAgB,SAAS,CAC7B,aAA4B,EAC5B,qBAA6C,EAC7C,QAAkB,EAClB,oBAA6B,EAC7B,mBAA4C;;QAE5C,yIAAyI;QACzI,MAAM,kBAAkB;aACrB,QAAQ,EAAE;aACV,wBAAwB,CAAC,aAAa,EAAE,SAAS,EAAE,mBAAmB,EAAE,oBAAoB,CAAC,CAAC;QAEjG,MAAM,gCAAgC,GAAG,+BAA+B,CACtE,aAAa,EACb,qBAAqB,CACtB,CAAC;QACF,0BAA0B,CAAC,QAAQ,EAAE,CAAC,mBAAmB,CAAC,gCAAgC,CAAC,CAAC;QAC5F,kBAAkB,CAAC,QAAQ,EAAE,CAAC,yBAAyB,CAAC,g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qB,CAAC;IAClF,MAAM,eAAe,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAC,eAAe,CAAC;IACtE,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAC,qBAAqB,CAAC;IAElF,OAAO,kBAAkB,CAAC;QACxB,aAAa;QACb,qBAAqB;QACrB,qBAAqB;QACrB,eAAe;QACf,qBAAqB;KACtB,CAAC,CAAC;AACL,CAAC"}
|
package/lib/utils/qItem.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Questionnaire, QuestionnaireItem } from 'fhir/r4';
|
|
2
|
-
import type { EnableWhenExpressions, EnableWhenItems } from '../interfaces';
|
|
2
|
+
import type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';
|
|
3
3
|
interface isHiddenByEnableWhensParams {
|
|
4
4
|
linkId: string;
|
|
5
5
|
enableWhenIsActivated: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Questionnaire, QuestionnaireItem, QuestionnaireItemEnableWhen } from 'fhir/r4';
|
|
2
2
|
import type { CalculatedExpression } from '../../interfaces/calculatedExpression.interface';
|
|
3
|
-
import type { EnableWhenExpressions, EnableWhenItems, EnableWhenRepeatItemProperties, EnableWhenSingleItemProperties } from '../../interfaces';
|
|
3
|
+
import type { EnableWhenExpressions, EnableWhenItems, EnableWhenRepeatItemProperties, EnableWhenSingleItemProperties } from '../../interfaces/enableWhen.interface';
|
|
4
4
|
import type { AnswerExpression } from '../../interfaces/answerExpression.interface';
|
|
5
5
|
import type { ValueSetPromise } from '../../interfaces/valueSet.interface';
|
|
6
6
|
import type { Variables } from '../../interfaces/variables.interface';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
-
import type { EnableWhenExpressions, EnableWhenItems } from '../interfaces';
|
|
2
|
+
import type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface';
|
|
3
3
|
interface removeEmptyAnswersParams {
|
|
4
4
|
questionnaire: Questionnaire;
|
|
5
5
|
questionnaireResponse: QuestionnaireResponse;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
2
2
|
import type { ItemToRepopulate } from './repopulateItems';
|
|
3
|
+
/**
|
|
4
|
+
* Re-populate checked items in the re-population dialog into the current QuestionnaireResponse
|
|
5
|
+
*
|
|
6
|
+
* @author Sean Fong
|
|
7
|
+
*/
|
|
8
|
+
export declare function repopulateResponse(checkedItemsToRepopulate: Record<string, ItemToRepopulate>): QuestionnaireResponse;
|
|
3
9
|
export declare function repopulateItemsIntoResponse(questionnaire: Questionnaire, updatableResponse: QuestionnaireResponse, checkedItemsToRepopulate: Record<string, ItemToRepopulate>): QuestionnaireResponse;
|