@aehrc/smart-forms-renderer 0.28.0 → 0.30.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/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.js +2 -1
- package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.js.map +1 -1
- package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js +4 -3
- package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +3 -2
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js +3 -2
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
- package/lib/components/FormComponents/UrlItem/UrlItem.js +3 -2
- package/lib/components/FormComponents/UrlItem/UrlItem.js.map +1 -1
- package/lib/hooks/useInitialiseRepeatAnswers.js +2 -2
- package/lib/hooks/useInitialiseRepeatAnswers.js.map +1 -1
- package/lib/hooks/useInitialiseRepeatGroups.d.ts +1 -2
- package/lib/hooks/useInitialiseRepeatGroups.js +2 -2
- package/lib/hooks/useInitialiseRepeatGroups.js.map +1 -1
- package/lib/hooks/useRepeatAnswers.d.ts +4 -0
- package/lib/hooks/useRepeatAnswers.js +34 -0
- package/lib/hooks/useRepeatAnswers.js.map +1 -0
- package/lib/hooks/useRepeatGroups.d.ts +4 -0
- package/lib/hooks/useRepeatGroups.js +34 -0
- package/lib/hooks/useRepeatGroups.js.map +1 -0
- package/lib/hooks/useRepeatitemState.d.ts +0 -0
- package/lib/hooks/useRepeatitemState.js +2 -0
- package/lib/hooks/useRepeatitemState.js.map +1 -0
- package/lib/utils/calculatedExpression.js +3 -3
- package/lib/utils/calculatedExpression.js.map +1 -1
- package/package.json +2 -1
- package/src/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.tsx +2 -1
- package/src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.tsx +4 -3
- package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +3 -2
- package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +3 -2
- package/src/components/FormComponents/UrlItem/UrlItem.tsx +3 -2
- package/src/hooks/useInitialiseRepeatAnswers.ts +2 -2
- package/src/hooks/useInitialiseRepeatGroups.ts +3 -4
- package/src/hooks/useRepeatAnswers.ts +45 -0
- package/src/hooks/useRepeatGroups.ts +47 -0
- package/src/stories/BuildFormButtonForStorybook.tsx +41 -0
- package/src/stories/BuildFormButtonTesterWrapper.tsx +61 -0
- package/src/stories/BuildFormWrapper.tsx +6 -11
- package/src/stories/PrePopButtonForStorybook.tsx +54 -0
- package/src/stories/PrePopWrapper.tsx +92 -0
- package/src/stories/assets/fhirClient/mockFhirClient.ts +52 -0
- package/src/stories/assets/patients/PatSmartForm.ts +281 -0
- package/src/stories/assets/practitioners/PracPrimaryPeter.ts +38 -0
- package/src/stories/assets/questionnaires/QBehaviorCalculations.ts +17 -19
- package/src/stories/assets/questionnaires/QBuildFormButtonTester.ts +270 -0
- package/src/stories/assets/questionnaires/QFormPopulation.ts +1349 -0
- package/src/stories/populateCallbackForStorybook.ts +56 -0
- package/src/stories/populateUtilsForStorybook.ts +545 -0
- package/src/stories/rebuildForm/BuildFormTesterWrapper.stories.tsx +43 -0
- package/src/stories/sdc/FormPopulation.stories.tsx +97 -0
- package/src/stories/useBuildFormForStorybook.ts +37 -0
- package/src/utils/calculatedExpression.ts +3 -2
- package/storybook.log +6 -0
- package/vite.config.ts +11 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
19
|
+
import PrePopWrapper from '../PrePopWrapper';
|
|
20
|
+
import {
|
|
21
|
+
qCalculatedExpressionBMICalculatorPrepop,
|
|
22
|
+
qCalculatedExpressionCvdRiskCalculatorPrepop,
|
|
23
|
+
qInitialExpressionBasic,
|
|
24
|
+
qItemPopulationContextHomeAddress,
|
|
25
|
+
qItemPopulationContextMedicalHistory,
|
|
26
|
+
qSourceQueriesBMICalculator
|
|
27
|
+
} from '../assets/questionnaires/QFormPopulation';
|
|
28
|
+
import { mockFhirClient } from '../assets/fhirClient/mockFhirClient';
|
|
29
|
+
import { patSmartForm } from '../assets/patients/PatSmartForm';
|
|
30
|
+
import { pracPrimaryPeter } from '../assets/practitioners/PracPrimaryPeter';
|
|
31
|
+
|
|
32
|
+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
33
|
+
const meta = {
|
|
34
|
+
title: 'Component/SDC/12 Form Population',
|
|
35
|
+
component: PrePopWrapper,
|
|
36
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
|
|
37
|
+
tags: []
|
|
38
|
+
} satisfies Meta<typeof PrePopWrapper>;
|
|
39
|
+
|
|
40
|
+
export default meta;
|
|
41
|
+
type Story = StoryObj<typeof meta>;
|
|
42
|
+
|
|
43
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
44
|
+
|
|
45
|
+
export const InitialExpression: Story = {
|
|
46
|
+
args: {
|
|
47
|
+
questionnaire: qInitialExpressionBasic,
|
|
48
|
+
fhirClient: mockFhirClient,
|
|
49
|
+
patient: patSmartForm,
|
|
50
|
+
user: pracPrimaryPeter
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const CalculatedExpressionBMICalculatorPrepop: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
questionnaire: qCalculatedExpressionBMICalculatorPrepop,
|
|
57
|
+
fhirClient: mockFhirClient,
|
|
58
|
+
patient: patSmartForm,
|
|
59
|
+
user: pracPrimaryPeter
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const CalculatedExpressionCvdRiskCalculatorPrepop: Story = {
|
|
64
|
+
args: {
|
|
65
|
+
questionnaire: qCalculatedExpressionCvdRiskCalculatorPrepop,
|
|
66
|
+
fhirClient: mockFhirClient,
|
|
67
|
+
patient: patSmartForm,
|
|
68
|
+
user: pracPrimaryPeter
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const ItemPopulationContextHomeAddress: Story = {
|
|
73
|
+
args: {
|
|
74
|
+
questionnaire: qItemPopulationContextHomeAddress,
|
|
75
|
+
fhirClient: mockFhirClient,
|
|
76
|
+
patient: patSmartForm,
|
|
77
|
+
user: pracPrimaryPeter
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const ItemPopulationContextMedicalHistory: Story = {
|
|
82
|
+
args: {
|
|
83
|
+
questionnaire: qItemPopulationContextMedicalHistory,
|
|
84
|
+
fhirClient: mockFhirClient,
|
|
85
|
+
patient: patSmartForm,
|
|
86
|
+
user: pracPrimaryPeter
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const SourceQueriesBMICalculator: Story = {
|
|
91
|
+
args: {
|
|
92
|
+
questionnaire: qSourceQueriesBMICalculator,
|
|
93
|
+
fhirClient: mockFhirClient,
|
|
94
|
+
patient: patSmartForm,
|
|
95
|
+
user: pracPrimaryPeter
|
|
96
|
+
}
|
|
97
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { useLayoutEffect, useState } from 'react';
|
|
19
|
+
import { buildForm } from '../utils';
|
|
20
|
+
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
21
|
+
|
|
22
|
+
function useBuildFormForStorybook(
|
|
23
|
+
questionnaire: Questionnaire,
|
|
24
|
+
questionnaireResponse?: QuestionnaireResponse
|
|
25
|
+
) {
|
|
26
|
+
const [isBuilding, setIsBuilding] = useState(true);
|
|
27
|
+
|
|
28
|
+
useLayoutEffect(() => {
|
|
29
|
+
buildForm(questionnaire, questionnaireResponse).then(() => {
|
|
30
|
+
setIsBuilding(false);
|
|
31
|
+
});
|
|
32
|
+
}, [questionnaire, questionnaireResponse]);
|
|
33
|
+
|
|
34
|
+
return isBuilding;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default useBuildFormForStorybook;
|
|
@@ -267,7 +267,7 @@ function initialiseItemCalculatedExpressionValueRecursive(
|
|
|
267
267
|
return constructGroupItem(qItem, qrItem, calculatedExpressions);
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
return constructSingleItem(qItem, calculatedExpressions);
|
|
270
|
+
return constructSingleItem(qItem, qrItem, calculatedExpressions);
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
function getCalculatedExpressionAnswer(
|
|
@@ -317,11 +317,12 @@ function constructGroupItem(
|
|
|
317
317
|
|
|
318
318
|
function constructSingleItem(
|
|
319
319
|
qItem: QuestionnaireItem,
|
|
320
|
+
qrItem: QuestionnaireResponseItem | undefined,
|
|
320
321
|
calculatedExpressions: Record<string, CalculatedExpression[]>
|
|
321
322
|
): QuestionnaireResponseItem | null {
|
|
322
323
|
const calculatedExpressionAnswer = getCalculatedExpressionAnswer(qItem, calculatedExpressions);
|
|
323
324
|
if (!calculatedExpressionAnswer) {
|
|
324
|
-
return null;
|
|
325
|
+
return qrItem ?? null;
|
|
325
326
|
}
|
|
326
327
|
|
|
327
328
|
return {
|
package/storybook.log
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
npm ERR! code ETARGET
|
|
2
|
+
npm ERR! notarget No matching version found for @storybook/addon-queryparams@^8.0.10.
|
|
3
|
+
npm ERR! notarget In most cases you or one of your dependencies are requesting
|
|
4
|
+
npm ERR! notarget a package version that doesn't exist.
|
|
5
|
+
|
|
6
|
+
npm ERR! A complete log of this run can be found in: /Users/fon026/.npm/_logs/2024-05-17T03_53_47_310Z-debug-0.log
|
package/vite.config.ts
CHANGED
|
@@ -17,7 +17,17 @@
|
|
|
17
17
|
|
|
18
18
|
import { defineConfig } from 'vite';
|
|
19
19
|
|
|
20
|
+
// This Vite config is for storybook usage only.
|
|
20
21
|
// https://vitejs.dev/config/
|
|
21
22
|
export default defineConfig({
|
|
22
|
-
plugins: []
|
|
23
|
+
plugins: [],
|
|
24
|
+
optimizeDeps: {
|
|
25
|
+
include: ['@aehrc/sdc-populate']
|
|
26
|
+
},
|
|
27
|
+
build: {
|
|
28
|
+
commonjsOptions: {
|
|
29
|
+
include: [/node_modules/, '@aehrc/sdc-populate']
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
resolve: { preserveSymlinks: true }
|
|
23
33
|
});
|