@aehrc/smart-forms-renderer 0.7.0 → 0.7.2
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 +5 -5
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js.map +1 -1
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js +3 -2
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js.map +1 -1
- package/lib/components/FormComponents/GridGroup/GridGroup.js +2 -2
- package/lib/components/FormComponents/GridGroup/GridGroup.js.map +1 -1
- package/lib/components/FormComponents/GridGroup/GridRow.js +2 -2
- package/lib/components/FormComponents/GridGroup/GridRow.js.map +1 -1
- package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.d.ts +10 -0
- package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.js +73 -0
- package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.js.map +1 -0
- package/lib/components/FormComponents/GroupItem/GroupItem.js +3 -3
- package/lib/components/FormComponents/GroupItem/GroupItem.js.map +1 -1
- package/lib/components/FormComponents/GroupItem/ItemSwitcher.d.ts +10 -0
- package/lib/components/FormComponents/GroupItem/ItemSwitcher.js +81 -0
- package/lib/components/FormComponents/GroupItem/ItemSwitcher.js.map +1 -0
- package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.d.ts +10 -0
- package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.js +45 -0
- package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.js.map +1 -0
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js +3 -2
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js +2 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +4 -3
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/index.d.ts +1 -0
- package/lib/{theme/overrides/Typography.js → components/FormComponents/RepeatGroup/index.js} +2 -15
- package/lib/components/FormComponents/RepeatGroup/index.js.map +1 -0
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js +1 -1
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
- package/lib/components/FormComponents/SingleItem/index.d.ts +1 -0
- package/lib/components/FormComponents/SingleItem/index.js +18 -0
- package/lib/components/FormComponents/SingleItem/index.js.map +1 -0
- package/lib/components/FormComponents/StringItem/StringItem.js +3 -2
- package/lib/components/FormComponents/StringItem/StringItem.js.map +1 -1
- package/lib/components/FormComponents/Tables/QItemGroupTable.js +7 -5
- package/lib/components/FormComponents/Tables/QItemGroupTable.js.map +1 -1
- package/lib/components/FormComponents/Tables/QItemGroupTableRow.js +2 -2
- package/lib/components/FormComponents/Tables/QItemGroupTableRow.js.map +1 -1
- package/lib/components/FormComponents/Tables/index.d.ts +1 -0
- package/lib/components/FormComponents/Tables/index.js +18 -0
- package/lib/components/FormComponents/Tables/index.js.map +1 -0
- package/lib/components/FormComponents/TextItem/TextItem.js +3 -2
- package/lib/components/FormComponents/TextItem/TextItem.js.map +1 -1
- package/lib/components/FormComponents/index.d.ts +3 -0
- package/lib/components/FormComponents/index.js +20 -0
- package/lib/components/FormComponents/index.js.map +1 -0
- package/lib/components/Renderer/BaseRenderer.js +26 -14
- package/lib/components/Renderer/BaseRenderer.js.map +1 -1
- package/lib/components/Renderer/FormBodyCollapsible.js +2 -2
- package/lib/components/Renderer/FormBodyCollapsible.js.map +1 -1
- package/lib/components/Renderer/FormBodyTabbed.js +2 -2
- package/lib/components/Renderer/FormBodyTabbed.js.map +1 -1
- package/lib/components/Renderer/FormTopLevelItem.d.ts +4 -4
- package/lib/components/Renderer/FormTopLevelItem.js +14 -1
- package/lib/components/Renderer/FormTopLevelItem.js.map +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/index.js.map +1 -1
- package/lib/hooks/useDecimalUpdateFromProp.d.ts +2 -0
- package/lib/{utils/isHidden.js → hooks/useDecimalUpdateFromProp.js} +12 -13
- package/lib/hooks/useDecimalUpdateFromProp.js.map +1 -0
- package/lib/hooks/useInitialiseRepeatAnswers.d.ts +2 -2
- package/lib/hooks/useInitialiseRepeatAnswers.js +21 -15
- package/lib/hooks/useInitialiseRepeatAnswers.js.map +1 -1
- package/lib/hooks/useInitialiseRepeatGroups.d.ts +2 -1
- package/lib/hooks/useInitialiseRepeatGroups.js +21 -15
- package/lib/hooks/useInitialiseRepeatGroups.js.map +1 -1
- package/lib/hooks/useIntegerUpdateFromProp.d.ts +2 -0
- package/lib/hooks/useIntegerUpdateFromProp.js +29 -0
- package/lib/hooks/useIntegerUpdateFromProp.js.map +1 -0
- package/lib/hooks/useNumberInput.d.ts +3 -0
- package/lib/hooks/useNumberInput.js +31 -0
- package/lib/hooks/useNumberInput.js.map +1 -0
- package/lib/hooks/useNumberUpdateFromProp.d.ts +2 -0
- package/lib/hooks/useNumberUpdateFromProp.js +29 -0
- package/lib/hooks/useNumberUpdateFromProp.js.map +1 -0
- package/lib/hooks/useRepeatItemState.d.ts +5 -0
- package/lib/hooks/useRepeatItemState.js +35 -0
- package/lib/hooks/useRepeatItemState.js.map +1 -0
- package/lib/hooks/useRepeatItemUpdateFromProp.d.ts +2 -0
- package/lib/hooks/useRepeatItemUpdateFromProp.js +29 -0
- package/lib/hooks/useRepeatItemUpdateFromProp.js.map +1 -0
- package/lib/hooks/useStringField.d.ts +2 -0
- package/lib/hooks/useStringField.js +29 -0
- package/lib/hooks/useStringField.js.map +1 -0
- package/lib/hooks/useStringInput.d.ts +3 -0
- package/lib/hooks/useStringInput.js +31 -0
- package/lib/hooks/useStringInput.js.map +1 -0
- package/lib/hooks/useStringUpdateFromProp.d.ts +2 -0
- package/lib/hooks/useStringUpdateFromProp.js +29 -0
- package/lib/hooks/useStringUpdateFromProp.js.map +1 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +27 -0
- package/lib/index.js.map +1 -1
- package/lib/interfaces/questionnaireStore.interface.d.ts +1 -0
- package/lib/stores/useQuestionnaireResponseStore.d.ts +1 -1
- package/lib/stores/useQuestionnaireResponseStore.js +15 -10
- package/lib/stores/useQuestionnaireResponseStore.js.map +1 -1
- package/lib/stores/useQuestionnaireStore.d.ts +2 -1
- package/lib/stores/useQuestionnaireStore.js +5 -2
- package/lib/stores/useQuestionnaireStore.js.map +1 -1
- package/lib/theme/overrides/Overrides.js +1 -2
- package/lib/theme/overrides/Overrides.js.map +1 -1
- package/lib/utils/calculatedExpression.js +2 -2
- package/lib/utils/calculatedExpression.js.map +1 -1
- package/lib/utils/formChanges.d.ts +18 -0
- package/lib/utils/formChanges.js +91 -0
- package/lib/utils/formChanges.js.map +1 -0
- package/lib/utils/formChangesOld.d.ts +18 -0
- package/lib/utils/formChangesOld.js +91 -0
- package/lib/utils/formChangesOld.js.map +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +18 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/mapItem.d.ts +2 -2
- package/lib/utils/mapItem.js +3 -3
- package/lib/utils/mapItem.js.map +1 -1
- package/lib/utils/qItem.d.ts +2 -0
- package/lib/utils/qItem.js +22 -0
- package/lib/utils/qItem.js.map +1 -1
- package/lib/utils/qrItem.d.ts +1 -1
- package/lib/utils/qrItem.js +92 -93
- package/lib/utils/qrItem.js.map +1 -1
- package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js +4 -0
- package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js.map +1 -1
- package/lib/utils/repopulate.d.ts +9 -0
- package/lib/utils/repopulate.js +133 -0
- package/lib/utils/repopulate.js.map +1 -0
- package/lib/utils/repopulateGenerateItems.d.ts +9 -0
- package/lib/utils/repopulateGenerateItems.js +133 -0
- package/lib/utils/repopulateGenerateItems.js.map +1 -0
- package/lib/utils/repopulateIntoResponse.d.ts +3 -0
- package/lib/utils/repopulateIntoResponse.js +92 -0
- package/lib/utils/repopulateIntoResponse.js.map +1 -0
- package/lib/utils/repopulateItems.d.ts +9 -0
- package/lib/utils/repopulateItems.js +131 -0
- package/lib/utils/repopulateItems.js.map +1 -0
- package/lib/utils/repopulateRepeatGroup.d.ts +4 -0
- package/lib/utils/repopulateRepeatGroup.js +54 -0
- package/lib/utils/repopulateRepeatGroup.js.map +1 -0
- package/package.json +3 -1
- package/src/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.tsx +1 -1
- package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +3 -2
- package/src/components/FormComponents/GridGroup/GridGroup.tsx +2 -2
- package/src/components/FormComponents/GridGroup/GridRow.tsx +2 -2
- package/src/components/FormComponents/GroupItem/GroupItem.tsx +3 -3
- package/src/components/FormComponents/IntegerItem/IntegerItem.tsx +3 -2
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.tsx +1 -1
- package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +4 -3
- package/src/{theme/overrides/Backdrop.ts → components/FormComponents/RepeatGroup/index.ts} +1 -17
- package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +1 -1
- package/src/components/FormComponents/SingleItem/index.ts +18 -0
- package/src/components/FormComponents/StringItem/StringItem.tsx +3 -2
- package/src/components/FormComponents/Tables/QItemGroupTable.tsx +15 -6
- package/src/components/FormComponents/Tables/QItemGroupTableRow.tsx +2 -2
- package/src/components/FormComponents/Tables/index.ts +18 -0
- package/src/components/FormComponents/TextItem/TextItem.tsx +3 -2
- package/src/components/FormComponents/index.ts +20 -0
- package/src/components/Renderer/BaseRenderer.tsx +39 -18
- package/src/components/Renderer/FormBodyCollapsible.tsx +2 -2
- package/src/components/Renderer/FormBodyTabbed.tsx +2 -2
- package/src/components/Renderer/FormTopLevelItem.tsx +33 -4
- package/src/components/index.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useInitialiseRepeatAnswers.ts +28 -17
- package/src/hooks/useInitialiseRepeatGroups.ts +28 -17
- package/src/hooks/useNumberInput.ts +37 -0
- package/src/hooks/useStringInput.ts +37 -0
- package/src/index.ts +43 -0
- package/src/interfaces/questionnaireStore.interface.ts +1 -0
- package/src/stores/useQuestionnaireResponseStore.ts +14 -10
- package/src/stores/useQuestionnaireStore.ts +10 -3
- package/src/theme/overrides/Overrides.ts +0 -2
- package/src/utils/calculatedExpression.ts +2 -2
- package/src/utils/formChanges.ts +141 -0
- package/src/utils/index.ts +18 -0
- package/src/utils/mapItem.ts +6 -4
- package/src/utils/qItem.ts +29 -0
- package/src/utils/qrItem.ts +104 -94
- package/src/utils/questionnaireStoreUtils/createQuestionaireModel.ts +4 -0
- package/src/utils/repopulateIntoResponse.ts +153 -0
- package/src/utils/repopulateItems.ts +207 -0
- package/src/utils/repopulateRepeatGroup.ts +68 -0
- package/lib/theme/overrides/Typography.d.ts +0 -13
- package/lib/theme/overrides/Typography.js.map +0 -1
- package/lib/utils/isHidden.d.ts +0 -3
- package/lib/utils/isHidden.js.map +0 -1
|
@@ -15,22 +15,28 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { nanoid } from 'nanoid';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
if (qrItem === null || qrItem === void 0 ? void 0 : qrItem.answer) {
|
|
26
|
-
initialRepeatAnswers = qrItem.answer.map((answer) => {
|
|
27
|
-
return {
|
|
18
|
+
import { useMemo } from 'react';
|
|
19
|
+
function useInitialiseRepeatAnswers(qItem, qrItem) {
|
|
20
|
+
return useMemo(() => {
|
|
21
|
+
let initialRepeatAnswers = [
|
|
22
|
+
{
|
|
28
23
|
nanoId: nanoid(),
|
|
29
|
-
answer
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
answer: null
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
if (qrItem === null || qrItem === void 0 ? void 0 : qrItem.answer) {
|
|
28
|
+
initialRepeatAnswers = qrItem.answer.map((answer) => {
|
|
29
|
+
return {
|
|
30
|
+
nanoId: nanoid(),
|
|
31
|
+
answer
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return initialRepeatAnswers;
|
|
36
|
+
},
|
|
37
|
+
// init initialRepeatAnswers on first render only, leave dependency array empty
|
|
38
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
+
[qItem]);
|
|
34
40
|
}
|
|
35
41
|
export default useInitialiseRepeatAnswers;
|
|
36
42
|
//# sourceMappingURL=useInitialiseRepeatAnswers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitialiseRepeatAnswers.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRepeatAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,SAAS,0BAA0B,
|
|
1
|
+
{"version":3,"file":"useInitialiseRepeatAnswers.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRepeatAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,SAAS,0BAA0B,CACjC,KAAwB,EACxB,MAAiC;IAEjC,OAAO,OAAO,CACZ,GAAG,EAAE;QACH,IAAI,oBAAoB,GAAmB;YACzC;gBACE,MAAM,EAAE,MAAM,EAAE;gBAChB,MAAM,EAAE,IAAI;aACb;SACF,CAAC;QAEF,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;YAClB,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;gBAClD,OAAO;oBACL,MAAM,EAAE,MAAM,EAAE;oBAChB,MAAM;iBACP,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,+EAA+E;IAC/E,uDAAuD;IACvD,CAAC,KAAK,CAAC,CACR,CAAC;AACJ,CAAC;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { QuestionnaireResponseItem } from 'fhir/r4';
|
|
2
|
+
import { QuestionnaireItem } from 'fhir/r4';
|
|
2
3
|
import type { RepeatGroupSingle } from '../interfaces/repeatGroup.interface';
|
|
3
|
-
declare function useInitialiseRepeatGroups(qrItems: QuestionnaireResponseItem[]): RepeatGroupSingle[];
|
|
4
|
+
declare function useInitialiseRepeatGroups(qItem: QuestionnaireItem, qrItems: QuestionnaireResponseItem[]): RepeatGroupSingle[];
|
|
4
5
|
export default useInitialiseRepeatGroups;
|
|
@@ -15,22 +15,28 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { nanoid } from 'nanoid';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
if (qrItems.length > 0) {
|
|
26
|
-
initialRepeatGroupAnswers = qrItems.map((qrItem) => {
|
|
27
|
-
return {
|
|
18
|
+
import { useMemo } from 'react';
|
|
19
|
+
function useInitialiseRepeatGroups(qItem, qrItems) {
|
|
20
|
+
return useMemo(() => {
|
|
21
|
+
let initialRepeatGroupAnswers = [
|
|
22
|
+
{
|
|
28
23
|
nanoId: nanoid(),
|
|
29
|
-
qrItem
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
qrItem: null
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
if (qrItems.length > 0) {
|
|
28
|
+
initialRepeatGroupAnswers = qrItems.map((qrItem) => {
|
|
29
|
+
return {
|
|
30
|
+
nanoId: nanoid(),
|
|
31
|
+
qrItem
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return initialRepeatGroupAnswers;
|
|
36
|
+
},
|
|
37
|
+
// init initialRepeatAnswers on first render only, leave dependency array empty
|
|
38
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
+
[qItem]);
|
|
34
40
|
}
|
|
35
41
|
export default useInitialiseRepeatGroups;
|
|
36
42
|
//# sourceMappingURL=useInitialiseRepeatGroups.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitialiseRepeatGroups.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRepeatGroups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"useInitialiseRepeatGroups.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRepeatGroups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,SAAS,yBAAyB,CAChC,KAAwB,EACxB,OAAoC;IAEpC,OAAO,OAAO,CACZ,GAAG,EAAE;QACH,IAAI,yBAAyB,GAAwB;YACnD;gBACE,MAAM,EAAE,MAAM,EAAE;gBAChB,MAAM,EAAE,IAAI;aACb;SACF,CAAC;QAEF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACtB,yBAAyB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;gBACjD,OAAO;oBACL,MAAM,EAAE,MAAM,EAAE;oBAChB,MAAM;iBACP,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,yBAAyB,CAAC;IACnC,CAAC;IACD,+EAA+E;IAC/E,uDAAuD;IACvD,CAAC,KAAK,CAAC,CACR,CAAC;AACJ,CAAC;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 { useEffect } from 'react';
|
|
18
|
+
function useIntegerUpdateFromProp(stateValue, propValue, setInputValue) {
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (stateValue !== propValue) {
|
|
21
|
+
setInputValue(propValue);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
// Only trigger this effect if prop value changes
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
[propValue]);
|
|
27
|
+
}
|
|
28
|
+
export default useIntegerUpdateFromProp;
|
|
29
|
+
//# sourceMappingURL=useIntegerUpdateFromProp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntegerUpdateFromProp.js","sourceRoot":"","sources":["../../src/hooks/useIntegerUpdateFromProp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,SAAS,wBAAwB,CAC/B,UAAkB,EAClB,SAAiB,EACjB,aAAsC;IAEtC,SAAS,CACP,GAAG,EAAE;QACH,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,aAAa,CAAC,SAAS,CAAC,CAAC;SAC1B;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,SAAS,CAAC,CACZ,CAAC;AACJ,CAAC;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 { useEffect, useState } from 'react';
|
|
18
|
+
function useNumberInput(valueFromProps) {
|
|
19
|
+
const [value, setValue] = useState(valueFromProps);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (value !== valueFromProps) {
|
|
22
|
+
setValue(valueFromProps);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
// Only trigger this effect if prop value changes
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
+
[valueFromProps]);
|
|
28
|
+
return [value, setValue];
|
|
29
|
+
}
|
|
30
|
+
export default useNumberInput;
|
|
31
|
+
//# sourceMappingURL=useNumberInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNumberInput.js","sourceRoot":"","sources":["../../src/hooks/useNumberInput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAA4B,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtE,SAAS,cAAc,CAAC,cAAsB;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEnD,SAAS,CACP,GAAG,EAAE;QACH,IAAI,KAAK,KAAK,cAAc,EAAE;YAC5B,QAAQ,CAAC,cAAc,CAAC,CAAC;SAC1B;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 { useEffect } from 'react';
|
|
18
|
+
function useNumberUpdateFromProp(stateValue, propValue, setInputValue) {
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (stateValue !== propValue) {
|
|
21
|
+
setInputValue(propValue);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
// Only trigger this effect if prop value changes
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
[propValue]);
|
|
27
|
+
}
|
|
28
|
+
export default useNumberUpdateFromProp;
|
|
29
|
+
//# sourceMappingURL=useNumberUpdateFromProp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNumberUpdateFromProp.js","sourceRoot":"","sources":["../../src/hooks/useNumberUpdateFromProp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,SAAS,uBAAuB,CAC9B,UAAkB,EAClB,SAAiB,EACjB,aAAsC;IAEtC,SAAS,CACP,GAAG,EAAE;QACH,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,aAAa,CAAC,SAAS,CAAC,CAAC;SAC1B;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,SAAS,CAAC,CACZ,CAAC;AACJ,CAAC;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { RepeatAnswer } from '../interfaces/repeatItem.interface';
|
|
3
|
+
import { QuestionnaireResponseItem } from 'fhir/r4';
|
|
4
|
+
declare function useRepeatItemState(qrItem: QuestionnaireResponseItem, initialRepeatAnswers: RepeatAnswer[]): [RepeatAnswer[], Dispatch<SetStateAction<RepeatAnswer[]>>];
|
|
5
|
+
export default useRepeatItemState;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 { useEffect, useState } from 'react';
|
|
18
|
+
function useRepeatItemState(qrItem, initialRepeatAnswers) {
|
|
19
|
+
const [repeatAnswers, setRepeatAnswers] = useState(initialRepeatAnswers);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
var _a;
|
|
22
|
+
if (qrItem === null || qrItem === void 0 ? void 0 : qrItem.answer) {
|
|
23
|
+
if (repeatAnswers.length !== ((_a = qrItem.answer) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
24
|
+
repeatAnswers !== initialRepeatAnswers) {
|
|
25
|
+
setRepeatAnswers(initialRepeatAnswers);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
// Only trigger this effect if prop value changes
|
|
30
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
+
[qrItem]);
|
|
32
|
+
return [repeatAnswers, setRepeatAnswers];
|
|
33
|
+
}
|
|
34
|
+
export default useRepeatItemState;
|
|
35
|
+
//# sourceMappingURL=useRepeatItemState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRepeatItemState.js","sourceRoot":"","sources":["../../src/hooks/useRepeatItemState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAA4B,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAItE,SAAS,kBAAkB,CACzB,MAAiC,EACjC,oBAAoC;IAEpC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAEzE,SAAS,CACP,GAAG,EAAE;;QACH,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;YAClB,IACE,aAAa,CAAC,MAAM,MAAK,MAAA,MAAM,CAAC,MAAM,0CAAE,MAAM,CAAA;gBAC9C,aAAa,KAAK,oBAAoB,EACtC;gBACA,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;aACxC;SACF;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AAC3C,CAAC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 { useEffect } from 'react';
|
|
18
|
+
function useRepeatItemUpdateFromProp(stateValue, propValue, setInputValue) {
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (stateValue !== propValue) {
|
|
21
|
+
setInputValue(propValue);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
// Only trigger this effect if prop value changes
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
[propValue]);
|
|
27
|
+
}
|
|
28
|
+
export default useRepeatItemUpdateFromProp;
|
|
29
|
+
//# sourceMappingURL=useRepeatItemUpdateFromProp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRepeatItemUpdateFromProp.js","sourceRoot":"","sources":["../../src/hooks/useRepeatItemUpdateFromProp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,SAAS,2BAA2B,CAClC,UAAkB,EAClB,SAAiB,EACjB,aAAsC;IAEtC,SAAS,CACP,GAAG,EAAE;QACH,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,aAAa,CAAC,SAAS,CAAC,CAAC;SAC1B;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,SAAS,CAAC,CACZ,CAAC;AACJ,CAAC;AAED,eAAe,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 { useEffect } from 'react';
|
|
18
|
+
function useStringUpdateFromProp(stateValue, propValue, setInputValue) {
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (stateValue !== propValue) {
|
|
21
|
+
setInputValue(propValue);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
// Only trigger this effect if prop value changes
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
[propValue]);
|
|
27
|
+
}
|
|
28
|
+
export default useStringUpdateFromProp;
|
|
29
|
+
//# sourceMappingURL=useStringField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStringField.js","sourceRoot":"","sources":["../../src/hooks/useStringField.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,SAAS,uBAAuB,CAC9B,UAAkB,EAClB,SAAiB,EACjB,aAAsC;IAEtC,SAAS,CACP,GAAG,EAAE;QACH,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,aAAa,CAAC,SAAS,CAAC,CAAC;SAC1B;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,SAAS,CAAC,CACZ,CAAC;AACJ,CAAC;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 { useEffect, useState } from 'react';
|
|
18
|
+
function useStringInput(valueFromProps) {
|
|
19
|
+
const [input, setInput] = useState(valueFromProps);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (input !== valueFromProps) {
|
|
22
|
+
setInput(valueFromProps);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
// Only trigger this effect if prop value changes
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
+
[valueFromProps]);
|
|
28
|
+
return [input, setInput];
|
|
29
|
+
}
|
|
30
|
+
export default useStringInput;
|
|
31
|
+
//# sourceMappingURL=useStringInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStringInput.js","sourceRoot":"","sources":["../../src/hooks/useStringInput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAA4B,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtE,SAAS,cAAc,CAAC,cAAsB;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEnD,SAAS,CACP,GAAG,EAAE;QACH,IAAI,KAAK,KAAK,cAAc,EAAE;YAC5B,QAAQ,CAAC,cAAc,CAAC,CAAC;SAC1B;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 { useEffect } from 'react';
|
|
18
|
+
function useStringUpdateFromProp(stateValue, propValue, setInputValue) {
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (stateValue !== propValue) {
|
|
21
|
+
setInputValue(propValue);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
// Only trigger this effect if prop value changes
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
[propValue]);
|
|
27
|
+
}
|
|
28
|
+
export default useStringUpdateFromProp;
|
|
29
|
+
//# sourceMappingURL=useStringUpdateFromProp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStringUpdateFromProp.js","sourceRoot":"","sources":["../../src/hooks/useStringUpdateFromProp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,SAAS,uBAAuB,CAC9B,UAAkB,EAClB,SAAiB,EACjB,aAAsC;IAEtC,SAAS,CACP,GAAG,EAAE;QACH,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,aAAa,CAAC,SAAS,CAAC,CAAC;SAC1B;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,SAAS,CAAC,CACZ,CAAC;AACJ,CAAC;AAED,eAAe,uBAAuB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
+
import type { ItemToRepopulate } from './utils/repopulateItems';
|
|
2
3
|
export * from './components';
|
|
3
4
|
export * from './stores';
|
|
5
|
+
export * from './hooks';
|
|
6
|
+
export * from './utils';
|
|
7
|
+
export type { ItemToRepopulate };
|
|
4
8
|
/**
|
|
5
9
|
* Build the form with an initial Questionnaire and an optional filled QuestionnaireResponse.
|
|
6
10
|
* If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse.
|
|
@@ -28,3 +32,15 @@ export declare function getResponse(): QuestionnaireResponse;
|
|
|
28
32
|
* @author Sean Fong
|
|
29
33
|
*/
|
|
30
34
|
export declare function removeHiddenAnswersFromResponse(questionnaire: Questionnaire, questionnaireResponse: QuestionnaireResponse): QuestionnaireResponse;
|
|
35
|
+
/**
|
|
36
|
+
* Re-populate stuff
|
|
37
|
+
*
|
|
38
|
+
* @author Sean Fong
|
|
39
|
+
*/
|
|
40
|
+
export declare function generateItemsToRepopulate(populatedResponse: QuestionnaireResponse): Record<string, ItemToRepopulate>;
|
|
41
|
+
/**
|
|
42
|
+
* Re-populate stuff
|
|
43
|
+
*
|
|
44
|
+
* @author Sean Fong
|
|
45
|
+
*/
|
|
46
|
+
export declare function repopulate(checkedItemsToRepopulate: Record<string, ItemToRepopulate>): QuestionnaireResponse;
|
package/lib/index.js
CHANGED
|
@@ -11,8 +11,12 @@ import useQuestionnaireStore from './stores/useQuestionnaireStore';
|
|
|
11
11
|
import { createQuestionnaireResponse } from './utils/qrItem';
|
|
12
12
|
import useQuestionnaireResponseStore from './stores/useQuestionnaireResponseStore';
|
|
13
13
|
import { removeHiddenAnswers } from './utils/removeHidden';
|
|
14
|
+
import { getItemsToRepopulate } from './utils/repopulateItems';
|
|
15
|
+
import { repopulateItemsIntoResponse } from './utils/repopulateIntoResponse';
|
|
14
16
|
export * from './components';
|
|
15
17
|
export * from './stores';
|
|
18
|
+
export * from './hooks';
|
|
19
|
+
export * from './utils';
|
|
16
20
|
/**
|
|
17
21
|
* Build the form with an initial Questionnaire and an optional filled QuestionnaireResponse.
|
|
18
22
|
* If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse.
|
|
@@ -68,4 +72,27 @@ export function removeHiddenAnswersFromResponse(questionnaire, questionnaireResp
|
|
|
68
72
|
enableWhenExpressions
|
|
69
73
|
});
|
|
70
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Re-populate stuff
|
|
77
|
+
*
|
|
78
|
+
* @author Sean Fong
|
|
79
|
+
*/
|
|
80
|
+
export function generateItemsToRepopulate(populatedResponse) {
|
|
81
|
+
const sourceQuestionnaire = useQuestionnaireStore.getState().sourceQuestionnaire;
|
|
82
|
+
const itemTypes = useQuestionnaireStore.getState().itemTypes;
|
|
83
|
+
const tabs = useQuestionnaireStore.getState().tabs;
|
|
84
|
+
const updatableResponse = useQuestionnaireResponseStore.getState().updatableResponse;
|
|
85
|
+
console.log(updatableResponse);
|
|
86
|
+
return getItemsToRepopulate(sourceQuestionnaire, itemTypes, tabs, populatedResponse, updatableResponse);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Re-populate stuff
|
|
90
|
+
*
|
|
91
|
+
* @author Sean Fong
|
|
92
|
+
*/
|
|
93
|
+
export function repopulate(checkedItemsToRepopulate) {
|
|
94
|
+
const sourceQuestionnaire = useQuestionnaireStore.getState().sourceQuestionnaire;
|
|
95
|
+
const updatableResponse = useQuestionnaireResponseStore.getState().updatableResponse;
|
|
96
|
+
return repopulateItemsIntoResponse(sourceQuestionnaire, updatableResponse, checkedItemsToRepopulate);
|
|
97
|
+
}
|
|
71
98
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,qBAAqB,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,6BAA6B,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,qBAAqB,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,6BAA6B,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAE7E,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAGxB;;;;;GAKG;AACH,MAAM,UAAgB,SAAS,CAC7B,aAA4B,EAC5B,qBAA6C;;QAE7C,MAAM,qBAAqB,CAAC,QAAQ,EAAE,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAC;QAE/E,IAAI,CAAC,qBAAqB,EAAE;YAC1B,6BAA6B;iBAC1B,QAAQ,EAAE;iBACV,mBAAmB,CAAC,2BAA2B,CAAC,aAAa,CAAC,CAAC,CAAC;YACnE,OAAO;SACR;QAED,6BAA6B,CAAC,QAAQ,EAAE,CAAC,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;QACpF,qBAAqB,CAAC,QAAQ,EAAE,CAAC,yBAAyB,CAAC,qBAAqB,CAAC,CAAC;IACpF,CAAC;CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,qBAAqB,CAAC,QAAQ,EAAE,CAAC,0BAA0B,EAAE,CAAC;IAC9D,6BAA6B,CAAC,QAAQ,EAAE,CAAC,qBAAqB,EAAE,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,6BAA6B,CAAC,QAAQ,EAAE,CAAC,iBAAiB,CAAC;AACpE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAC7C,aAA4B,EAC5B,qBAA4C;IAE5C,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,QAAQ,EAAE,CAAC,qBAAqB,CAAC;IACrF,MAAM,eAAe,GAAG,qBAAqB,CAAC,QAAQ,EAAE,CAAC,eAAe,CAAC;IACzE,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,QAAQ,EAAE,CAAC,qBAAqB,CAAC;IAErF,OAAO,mBAAmB,CAAC;QACzB,aAAa;QACb,qBAAqB;QACrB,qBAAqB;QACrB,eAAe;QACf,qBAAqB;KACtB,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,iBAAwC;IAChF,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,QAAQ,EAAE,CAAC,mBAAmB,CAAC;IACjF,MAAM,SAAS,GAAG,qBAAqB,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC;IAC7D,MAAM,IAAI,GAAG,qBAAqB,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;IACnD,MAAM,iBAAiB,GAAG,6BAA6B,CAAC,QAAQ,EAAE,CAAC,iBAAiB,CAAC;IACrF,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAE/B,OAAO,oBAAoB,CACzB,mBAAmB,EACnB,SAAS,EACT,IAAI,EACJ,iBAAiB,EACjB,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,wBAA0D;IACnF,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,QAAQ,EAAE,CAAC,mBAAmB,CAAC;IACjF,MAAM,iBAAiB,GAAG,6BAA6B,CAAC,QAAQ,EAAE,CAAC,iBAAiB,CAAC;IAErF,OAAO,2BAA2B,CAChC,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -6,6 +6,7 @@ import type { CalculatedExpression } from './calculatedExpression.interface';
|
|
|
6
6
|
import type { AnswerExpression } from './answerExpression.interface';
|
|
7
7
|
import type { Coding } from 'fhir/r4';
|
|
8
8
|
export interface QuestionnaireModel {
|
|
9
|
+
itemTypes: Record<string, string>;
|
|
9
10
|
tabs: Tabs;
|
|
10
11
|
variables: Variables;
|
|
11
12
|
launchContexts: Record<string, LaunchContext>;
|
|
@@ -2,7 +2,7 @@ import type { QuestionnaireResponse } from 'fhir/r4';
|
|
|
2
2
|
export interface UseQuestionnaireResponseStoreType {
|
|
3
3
|
sourceResponse: QuestionnaireResponse;
|
|
4
4
|
updatableResponse: QuestionnaireResponse;
|
|
5
|
-
|
|
5
|
+
formChangesHistory: object[];
|
|
6
6
|
buildSourceResponse: (response: QuestionnaireResponse) => void;
|
|
7
7
|
setUpdatableResponseAsPopulated: (populatedResponse: QuestionnaireResponse) => void;
|
|
8
8
|
updateResponse: (updatedResponse: QuestionnaireResponse) => void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
import { emptyResponse } from '../utils/emptyResource';
|
|
3
3
|
import cloneDeep from 'lodash.clonedeep';
|
|
4
|
-
|
|
4
|
+
import { diff } from 'json-diff';
|
|
5
|
+
const useQuestionnaireResponseStore = create()((set, get) => ({
|
|
5
6
|
sourceResponse: cloneDeep(emptyResponse),
|
|
6
7
|
updatableResponse: cloneDeep(emptyResponse),
|
|
7
|
-
|
|
8
|
+
formChangesHistory: [],
|
|
8
9
|
buildSourceResponse: (questionnaireResponse) => {
|
|
9
10
|
set(() => ({
|
|
10
11
|
sourceResponse: questionnaireResponse,
|
|
@@ -12,28 +13,32 @@ const useQuestionnaireResponseStore = create()((set) => ({
|
|
|
12
13
|
}));
|
|
13
14
|
},
|
|
14
15
|
setUpdatableResponseAsPopulated: (populatedResponse) => {
|
|
16
|
+
const formChanges = diff(get().updatableResponse, populatedResponse, { full: true });
|
|
15
17
|
set(() => ({
|
|
16
18
|
updatableResponse: populatedResponse,
|
|
17
|
-
|
|
19
|
+
formChangesHistory: [...get().formChangesHistory, formChanges]
|
|
20
|
+
}));
|
|
21
|
+
},
|
|
22
|
+
updateResponse: (updatedResponse) => {
|
|
23
|
+
const formChanges = diff(get().updatableResponse, updatedResponse, { full: true });
|
|
24
|
+
set(() => ({
|
|
25
|
+
updatableResponse: updatedResponse,
|
|
26
|
+
formChangesHistory: [...get().formChangesHistory, formChanges]
|
|
18
27
|
}));
|
|
19
28
|
},
|
|
20
|
-
updateResponse: (updatedResponse) => set(() => ({
|
|
21
|
-
updatableResponse: updatedResponse,
|
|
22
|
-
hasChanges: true
|
|
23
|
-
})),
|
|
24
29
|
setUpdatableResponseAsSaved: (savedResponse) => set(() => ({
|
|
25
30
|
sourceResponse: savedResponse,
|
|
26
31
|
updatableResponse: savedResponse,
|
|
27
|
-
|
|
32
|
+
formChangesHistory: []
|
|
28
33
|
})),
|
|
29
34
|
setUpdatableResponseAsEmpty: (clearedResponse) => set(() => ({
|
|
30
35
|
updatableResponse: clearedResponse,
|
|
31
|
-
|
|
36
|
+
formChangesHistory: []
|
|
32
37
|
})),
|
|
33
38
|
destroySourceResponse: () => set(() => ({
|
|
34
39
|
sourceResponse: cloneDeep(emptyResponse),
|
|
35
40
|
updatableResponse: cloneDeep(emptyResponse),
|
|
36
|
-
|
|
41
|
+
formChangesHistory: []
|
|
37
42
|
}))
|
|
38
43
|
}));
|
|
39
44
|
export default useQuestionnaireResponseStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuestionnaireResponseStore.js","sourceRoot":"","sources":["../../src/stores/useQuestionnaireResponseStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,SAAS,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"useQuestionnaireResponseStore.js","sourceRoot":"","sources":["../../src/stores/useQuestionnaireResponseStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAcjC,MAAM,6BAA6B,GAAG,MAAM,EAAqC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAC/F,cAAc,EAAE,SAAS,CAAC,aAAa,CAAC;IACxC,iBAAiB,EAAE,SAAS,CAAC,aAAa,CAAC;IAC3C,kBAAkB,EAAE,EAAE;IACtB,mBAAmB,EAAE,CAAC,qBAA4C,EAAE,EAAE;QACpE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YACT,cAAc,EAAE,qBAAqB;YACrC,iBAAiB,EAAE,qBAAqB;SACzC,CAAC,CAAC,CAAC;IACN,CAAC;IACD,+BAA+B,EAAE,CAAC,iBAAwC,EAAE,EAAE;QAC5E,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACrF,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YACT,iBAAiB,EAAE,iBAAiB;YACpC,kBAAkB,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,kBAAkB,EAAE,WAAW,CAAC;SAC/D,CAAC,CAAC,CAAC;IACN,CAAC;IACD,cAAc,EAAE,CAAC,eAAsC,EAAE,EAAE;QACzD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAiB,EAAE,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACnF,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YACT,iBAAiB,EAAE,eAAe;YAClC,kBAAkB,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,kBAAkB,EAAE,WAAW,CAAC;SAC/D,CAAC,CAAC,CAAC;IACN,CAAC;IACD,2BAA2B,EAAE,CAAC,aAAoC,EAAE,EAAE,CACpE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;QACT,cAAc,EAAE,aAAa;QAC7B,iBAAiB,EAAE,aAAa;QAChC,kBAAkB,EAAE,EAAE;KACvB,CAAC,CAAC;IACL,2BAA2B,EAAE,CAAC,eAAsC,EAAE,EAAE,CACtE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;QACT,iBAAiB,EAAE,eAAe;QAClC,kBAAkB,EAAE,EAAE;KACvB,CAAC,CAAC;IACL,qBAAqB,EAAE,GAAG,EAAE,CAC1B,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;QACT,cAAc,EAAE,SAAS,CAAC,aAAa,CAAC;QACxC,iBAAiB,EAAE,SAAS,CAAC,aAAa,CAAC;QAC3C,kBAAkB,EAAE,EAAE;KACvB,CAAC,CAAC;CACN,CAAC,CAAC,CAAC;AAEJ,eAAe,6BAA6B,CAAC"}
|
|
@@ -7,6 +7,7 @@ import type { AnswerExpression } from '../interfaces/answerExpression.interface'
|
|
|
7
7
|
import type { Tabs } from '../interfaces/tab.interface';
|
|
8
8
|
export interface UseQuestionnaireStoreType {
|
|
9
9
|
sourceQuestionnaire: Questionnaire;
|
|
10
|
+
itemTypes: Record<string, string>;
|
|
10
11
|
tabs: Tabs;
|
|
11
12
|
currentTabIndex: number;
|
|
12
13
|
variables: Variables;
|
|
@@ -28,7 +29,7 @@ export interface UseQuestionnaireStoreType {
|
|
|
28
29
|
toggleEnableWhenActivation: (isActivated: boolean) => void;
|
|
29
30
|
updateExpressions: (updatedResponse: QuestionnaireResponse) => void;
|
|
30
31
|
addCodingToCache: (valueSetUrl: string, codings: Coding[]) => void;
|
|
31
|
-
updatePopulatedProperties: (populatedResponse: QuestionnaireResponse) => QuestionnaireResponse;
|
|
32
|
+
updatePopulatedProperties: (populatedResponse: QuestionnaireResponse, persistTabIndex?: boolean) => QuestionnaireResponse;
|
|
32
33
|
}
|
|
33
34
|
declare const useQuestionnaireStore: import("zustand").UseBoundStore<import("zustand").StoreApi<UseQuestionnaireStoreType>>;
|
|
34
35
|
export default useQuestionnaireStore;
|