@aehrc/smart-forms-renderer 0.9.2 → 0.10.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/.swcrc +11 -0
- package/lib/components/FormComponents/GroupItem/NextTabButtonWrapper.js +5 -5
- package/lib/components/FormComponents/GroupItem/NextTabButtonWrapper.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/DeleteItemButton.js +1 -1
- package/lib/components/FormComponents/RepeatItem/RemoveItemButton.d.ts +10 -0
- package/lib/components/FormComponents/RepeatItem/RemoveItemButton.js +30 -0
- package/lib/components/FormComponents/RepeatItem/RemoveItemButton.js.map +1 -0
- package/lib/components/FormComponents/RepeatItem/RepeatField.js +2 -2
- package/lib/components/FormComponents/SingleItem/SingleItem.js +2 -2
- package/lib/components/FormComponents/SingleItem/SingleItem.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTable.d.ts +1 -2
- package/lib/components/FormComponents/Tables/GroupTable.js +44 -59
- package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTableBody.d.ts +17 -0
- package/lib/components/FormComponents/Tables/GroupTableBody.js +48 -0
- package/lib/components/FormComponents/Tables/GroupTableBody.js.map +1 -0
- package/lib/components/FormComponents/Tables/GroupTableRow.d.ts +18 -5
- package/lib/components/FormComponents/Tables/GroupTableRow.js +17 -25
- package/lib/components/FormComponents/Tables/GroupTableRow.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTableRowCells.d.ts +11 -0
- package/lib/components/FormComponents/Tables/GroupTableRowCells.js +57 -0
- package/lib/components/FormComponents/Tables/GroupTableRowCells.js.map +1 -0
- package/lib/components/FormComponents/Tables/GroupTableRows.d.ts +17 -0
- package/lib/components/FormComponents/Tables/GroupTableRows.js +45 -0
- package/lib/components/FormComponents/Tables/GroupTableRows.js.map +1 -0
- package/lib/components/FormComponents/Tables/GroupTableTestRow.d.ts +22 -0
- package/lib/components/FormComponents/Tables/GroupTableTestRow.js +43 -0
- package/lib/components/FormComponents/Tables/GroupTableTestRow.js.map +1 -0
- package/lib/components/FormComponents/Tables/GroupTableView.d.ts +21 -0
- package/lib/components/FormComponents/Tables/GroupTableView.js +65 -0
- package/lib/components/FormComponents/Tables/GroupTableView.js.map +1 -0
- package/lib/components/FormComponents/Tables/RemoveRowButton.d.ts +10 -0
- package/lib/components/FormComponents/Tables/RemoveRowButton.js +32 -0
- package/lib/components/FormComponents/Tables/RemoveRowButton.js.map +1 -0
- package/lib/components/FormComponents/Tables/SelectRowButton.d.ts +7 -0
- package/lib/components/FormComponents/Tables/SelectRowButton.js +26 -0
- package/lib/components/FormComponents/Tables/SelectRowButton.js.map +1 -0
- package/lib/components/FormComponents/Tables/Table.styles.d.ts +8 -0
- package/lib/components/FormComponents/Tables/Table.styles.js +17 -0
- package/lib/components/FormComponents/Tables/Table.styles.js.map +1 -1
- package/lib/components/Renderer/BaseRenderer.js +5 -6
- package/lib/components/Renderer/BaseRenderer.js.map +1 -1
- package/lib/components/Renderer/FormBodyCollapsible.js +4 -4
- package/lib/components/Renderer/FormBodyCollapsible.js.map +1 -1
- package/lib/components/Renderer/FormBodyTabbed.js +3 -3
- package/lib/components/Renderer/FormBodyTabbed.js.map +1 -1
- package/lib/components/Tabs/CompleteTabButton.js +2 -2
- package/lib/components/Tabs/CompleteTabButton.js.map +1 -1
- package/lib/components/Tabs/FormBodySingleTab.js +2 -2
- package/lib/components/Tabs/FormBodySingleTab.js.map +1 -1
- package/lib/components/Tabs/FormBodyTabList.js +4 -4
- package/lib/components/Tabs/FormBodyTabList.js.map +1 -1
- package/lib/hooks/useDecimalCalculatedExpression.js +2 -2
- package/lib/hooks/useDecimalCalculatedExpression.js.map +1 -1
- package/lib/hooks/useHidden.js +4 -4
- package/lib/hooks/useHidden.js.map +1 -1
- package/lib/hooks/useInitialiseGroupTable.d.ts +2 -2
- package/lib/hooks/useInitialiseGroupTable.js.map +1 -1
- package/lib/hooks/useInitialiseRenderer.js +11 -14
- package/lib/hooks/useInitialiseRenderer.js.map +1 -1
- package/lib/hooks/useIntegerCalculatedExpression.js +2 -2
- package/lib/hooks/useIntegerCalculatedExpression.js.map +1 -1
- package/lib/hooks/useMinimalStringCalculatedExpression.js +25 -13
- package/lib/hooks/useStringCalculatedExpression.js +2 -2
- package/lib/hooks/useStringCalculatedExpression.js.map +1 -1
- package/lib/hooks/useTerminologyServerQuery.js +3 -4
- package/lib/hooks/useTerminologyServerQuery.js.map +1 -1
- package/lib/hooks/useValueSetCodings.js +10 -12
- package/lib/hooks/useValueSetCodings.js.map +1 -1
- package/lib/index.js +19 -20
- package/lib/index.js.map +1 -1
- package/lib/interfaces/groupTable.interface.d.ts +1 -1
- package/lib/setup-jest.js +1 -0
- package/lib/setup-jest.js.map +1 -0
- package/lib/stores/index.d.ts +4 -3
- package/lib/stores/index.js +4 -3
- package/lib/stores/index.js.map +1 -1
- package/lib/stores/questionnaireResponseStore.d.ts +28 -0
- package/lib/stores/questionnaireResponseStore.js +64 -0
- package/lib/stores/questionnaireResponseStore.js.map +1 -0
- package/lib/stores/questionnaireStore.d.ts +65 -0
- package/lib/stores/questionnaireStore.js +172 -0
- package/lib/stores/questionnaireStore.js.map +1 -0
- package/lib/stores/smartConfigStore.d.ts +25 -0
- package/lib/stores/smartConfigStore.js +30 -0
- package/lib/stores/smartConfigStore.js.map +1 -0
- package/lib/stores/terminologyServerStore.d.ts +14 -0
- package/lib/stores/terminologyServerStore.js +26 -0
- package/lib/stores/terminologyServerStore.js.map +1 -0
- package/lib/stores/useQuestionnaireResponseStore.d.ts +14 -2
- package/lib/stores/useQuestionnaireResponseStore.js +4 -2
- package/lib/stores/useQuestionnaireResponseStore.js.map +1 -1
- package/lib/stores/useQuestionnaireStore.d.ts +30 -2
- package/lib/stores/useQuestionnaireStore.js +4 -2
- package/lib/stores/useQuestionnaireStore.js.map +1 -1
- package/lib/stories/MedicalHistoryTable.stories.js +49 -0
- package/lib/stories/MedicalHistoryTable.stories.js.map +1 -0
- package/lib/stories/SmartFormsRenderer.stories.js +103 -0
- package/lib/stories/SmartFormsRenderer.stories.js.map +1 -0
- package/lib/theme/overrides/Table.d.ts +1 -0
- package/lib/theme/overrides/Table.js +2 -1
- package/lib/theme/overrides/Table.js.map +1 -1
- package/lib/utils/calculatedExpression.js +1 -2
- package/lib/utils/calculatedExpression.js.map +1 -1
- package/lib/utils/groupTable.d.ts +3 -0
- package/lib/utils/groupTable.js +29 -0
- package/lib/utils/groupTable.js.map +1 -0
- package/package.json +10 -5
- package/src/components/FormComponents/GroupItem/NextTabButtonWrapper.tsx +5 -5
- package/src/components/FormComponents/RepeatGroup/DeleteItemButton.tsx +1 -1
- package/src/components/FormComponents/RepeatItem/{DeleteItemButton.tsx → RemoveItemButton.tsx} +4 -4
- package/src/components/FormComponents/RepeatItem/RepeatField.tsx +2 -2
- package/src/components/FormComponents/SingleItem/SingleItem.tsx +2 -2
- package/src/components/FormComponents/Tables/GroupTable.tsx +71 -120
- package/src/components/FormComponents/Tables/GroupTableBody.tsx +116 -0
- package/src/components/FormComponents/Tables/GroupTableRow.tsx +89 -49
- package/src/components/FormComponents/Tables/GroupTableRowCells.tsx +87 -0
- package/src/components/FormComponents/Tables/GroupTableView.tsx +169 -0
- package/src/components/FormComponents/Tables/{DeleteRowButton.tsx → RemoveRowButton.tsx} +7 -7
- package/src/components/FormComponents/Tables/SelectRowButton.tsx +37 -0
- package/src/components/FormComponents/Tables/Table.styles.tsx +25 -0
- package/src/components/Renderer/BaseRenderer.tsx +5 -6
- package/src/components/Renderer/FormBodyCollapsible.tsx +4 -5
- package/src/components/Renderer/FormBodyTabbed.tsx +3 -3
- package/src/components/Tabs/CompleteTabButton.tsx +2 -2
- package/src/components/Tabs/FormBodySingleTab.tsx +2 -3
- package/src/components/Tabs/FormBodyTabList.tsx +4 -4
- package/src/hooks/useDecimalCalculatedExpression.ts +2 -2
- package/src/hooks/useHidden.ts +4 -4
- package/src/hooks/useInitialiseGroupTable.ts +3 -3
- package/src/hooks/useInitialiseRenderer.ts +17 -18
- package/src/hooks/useIntegerCalculatedExpression.ts +2 -2
- package/src/hooks/useStringCalculatedExpression.ts +2 -2
- package/src/hooks/useTerminologyServerQuery.ts +3 -4
- package/src/hooks/useValueSetCodings.ts +10 -12
- package/src/index.ts +19 -20
- package/src/interfaces/groupTable.interface.ts +1 -1
- package/src/stores/index.ts +7 -3
- package/src/stores/questionnaireResponseStore.ts +83 -0
- package/src/stores/{useQuestionnaireStore.ts → questionnaireStore.ts} +7 -6
- package/src/stores/smartConfigStore.ts +45 -0
- package/src/stores/{useTerminologyServerStore.ts → terminologyServerStore.ts} +5 -4
- package/src/stories/MedicalHistoryTable.stories.tsx +61 -0
- package/src/stories/SmartFormsRenderer.stories.ts +15 -5
- package/src/stories/assets/QItems-and-QRItems/QR_GTableMedicalHistory.json +80 -0
- package/src/stories/assets/QItems-and-QRItems/Q_GTableMedicalHistory.json +109 -0
- package/src/stories/assets/Qs-and-QRs/QDev715.json +16081 -0
- package/src/theme/overrides/Table.ts +2 -1
- package/src/utils/calculatedExpression.ts +1 -2
- package/src/utils/groupTable.ts +37 -0
- package/src/stores/useQuestionnaireResponseStore.ts +0 -63
- package/src/stores/useSmartConfigStore.ts +0 -27
- /package/src/stories/assets/{Q715.json → Qs-and-QRs/Q715.json} +0 -0
- /package/src/stories/assets/{QTestGrid.json → Qs-and-QRs/QTestGrid.json} +0 -0
- /package/src/stories/assets/{R715.json → Qs-and-QRs/R715.json} +0 -0
- /package/src/stories/assets/{RTestGrid.json → Qs-and-QRs/RTestGrid.json} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHidden.js","sourceRoot":"","sources":["../../src/hooks/useHidden.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,qBAAqB,MAAM,
|
|
1
|
+
{"version":3,"file":"useHidden.js","sourceRoot":"","sources":["../../src/hooks/useHidden.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,SAAS,SAAS,CAAC,KAAwB;IACzC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC;IAChF,MAAM,eAAe,GAAG,qBAAqB,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;IACpE,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC;IAEhF,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE;QAC7B,OAAO,IAAI,CAAC;KACb;IAED,OAAO,qBAAqB,CAAC;QAC3B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,qBAAqB;QACrB,eAAe;QACf,qBAAqB;KACtB,CAAC,CAAC;AACL,CAAC;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { QuestionnaireResponseItem } from 'fhir/r4';
|
|
2
|
-
import type {
|
|
3
|
-
declare function useInitialiseGroupTable(qrItems: QuestionnaireResponseItem[]):
|
|
2
|
+
import type { GroupTableRowModel } from '../interfaces/groupTable.interface';
|
|
3
|
+
declare function useInitialiseGroupTable(qrItems: QuestionnaireResponseItem[]): GroupTableRowModel[];
|
|
4
4
|
export default useInitialiseGroupTable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitialiseGroupTable.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseGroupTable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,SAAS,uBAAuB,CAAC,OAAoC;IACnE,IAAI,qBAAqB,
|
|
1
|
+
{"version":3,"file":"useInitialiseGroupTable.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseGroupTable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,SAAS,uBAAuB,CAAC,OAAoC;IACnE,IAAI,qBAAqB,GAAyB;QAChD;YACE,MAAM,EAAE,MAAM,EAAE;YAChB,MAAM,EAAE,IAAI;SACb;KACF,CAAC;IAEF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YAC7C,OAAO;gBACL,MAAM,EAAE,MAAM,EAAE;gBAChB,MAAM;aACP,CAAC;QACJ,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -16,22 +16,19 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { useLayoutEffect, useState } from 'react';
|
|
18
18
|
import { createEmptyQuestionnaireResponse } from '../utils/qrItem';
|
|
19
|
-
import useQuestionnaireStore from '../stores/useQuestionnaireStore';
|
|
20
|
-
import useQuestionnaireResponseStore from '../stores/useQuestionnaireResponseStore';
|
|
21
|
-
import useSmartConfigStore from '../stores/useSmartConfigStore';
|
|
22
19
|
import { readEncounter, readPatient, readUser } from '../api/smartClient';
|
|
23
|
-
import useTerminologyServerStore from '../stores
|
|
20
|
+
import { useQuestionnaireResponseStore, useQuestionnaireStore, useSmartConfigStore, useTerminologyServerStore } from '../stores';
|
|
24
21
|
function useInitialiseRenderer(questionnaire, questionnaireResponse, additionalVariables, terminologyServerUrl, fhirClient) {
|
|
25
|
-
const buildSourceQuestionnaire = useQuestionnaireStore
|
|
26
|
-
const updatePopulatedProperties = useQuestionnaireStore
|
|
27
|
-
const buildSourceResponse = useQuestionnaireResponseStore
|
|
28
|
-
const setUpdatableResponseAsPopulated = useQuestionnaireResponseStore
|
|
29
|
-
const setTerminologyServerUrl = useTerminologyServerStore
|
|
30
|
-
const resetTerminologyServerUrl = useTerminologyServerStore
|
|
31
|
-
const setSmartClient = useSmartConfigStore
|
|
32
|
-
const setPatient = useSmartConfigStore
|
|
33
|
-
const setUser = useSmartConfigStore
|
|
34
|
-
const setEncounter = useSmartConfigStore
|
|
22
|
+
const buildSourceQuestionnaire = useQuestionnaireStore.use.buildSourceQuestionnaire();
|
|
23
|
+
const updatePopulatedProperties = useQuestionnaireStore.use.updatePopulatedProperties();
|
|
24
|
+
const buildSourceResponse = useQuestionnaireResponseStore.use.buildSourceResponse();
|
|
25
|
+
const setUpdatableResponseAsPopulated = useQuestionnaireResponseStore.use.setUpdatableResponseAsPopulated();
|
|
26
|
+
const setTerminologyServerUrl = useTerminologyServerStore.use.setUrl();
|
|
27
|
+
const resetTerminologyServerUrl = useTerminologyServerStore.use.resetUrl();
|
|
28
|
+
const setSmartClient = useSmartConfigStore.use.setClient();
|
|
29
|
+
const setPatient = useSmartConfigStore.use.setPatient();
|
|
30
|
+
const setUser = useSmartConfigStore.use.setUser();
|
|
31
|
+
const setEncounter = useSmartConfigStore.use.setEncounter();
|
|
35
32
|
const [loading, setLoading] = useState(true);
|
|
36
33
|
useLayoutEffect(() => {
|
|
37
34
|
setLoading(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitialiseRenderer.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"useInitialiseRenderer.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRenderer.ts"],"names":[],"mappings":"AAAA;;;;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IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { useEffect, useState } from 'react';
|
|
18
18
|
import { createEmptyQrItem } from '../utils/qrItem';
|
|
19
|
-
import useQuestionnaireStore from '../stores/
|
|
19
|
+
import { useQuestionnaireStore } from '../stores/questionnaireStore';
|
|
20
20
|
function useIntegerCalculatedExpression(props) {
|
|
21
21
|
const { qItem, inputValue, setInputValue, onQrItemChange } = props;
|
|
22
|
-
const calculatedExpressions = useQuestionnaireStore
|
|
22
|
+
const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();
|
|
23
23
|
const [calcExpUpdated, setCalcExpUpdated] = useState(false);
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
const calcExpression = calculatedExpressions[qItem.linkId];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntegerCalculatedExpression.js","sourceRoot":"","sources":["../../src/hooks/useIntegerCalculatedExpression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,qBAAqB,MAAM,
|
|
1
|
+
{"version":3,"file":"useIntegerCalculatedExpression.js","sourceRoot":"","sources":["../../src/hooks/useIntegerCalculatedExpression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAarE,SAAS,8BAA8B,CACrC,KAA0C;IAE1C,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAEnE,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC;IAEhF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5D,SAAS,CACP,GAAG,EAAE;QACH,MAAM,cAAc,GAAG,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAE3D,kEAAkE;QAClE,IAAI,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,MAAK,UAAU,IAAI,OAAO,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,CAAA,KAAK,QAAQ,EAAE;YACrF,6CAA6C;YAC7C,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACxB,UAAU,CAAC,GAAG,EAAE;gBACd,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC,EAAE,GAAG,CAAC,CAAC;YAER,+BAA+B;YAC/B,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACpC,cAAc,iCACT,iBAAiB,CAAC,KAAK,CAAC,KAC3B,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,cAAc,CAAC,KAAK,EAAE,CAAC,IAChD,CAAC;SACJ;IACH,CAAC;IACD,mEAAmE;IACnE,uDAAuD;IACvD,CAAC,qBAAqB,CAAC,CACxB,CAAC;IAEF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAC5C,CAAC;AAED,eAAe,8BAA8B,CAAC"}
|
|
@@ -18,20 +18,32 @@ import { useEffect } from 'react';
|
|
|
18
18
|
import { createEmptyQrItem } from '../utils/qrItem';
|
|
19
19
|
import useQuestionnaireStore from '../stores/useQuestionnaireStore';
|
|
20
20
|
function useMinimalStringCalculatedExpression(props) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
const { qItem, inputValue, onQrItemChange } = props;
|
|
22
|
+
const calculatedExpressions = useQuestionnaireStore((state) => state.calculatedExpressions);
|
|
23
|
+
useEffect(
|
|
24
|
+
() => {
|
|
25
|
+
const calcExpression = calculatedExpressions[qItem.linkId];
|
|
26
|
+
// only update if calculated value is different from current value
|
|
27
|
+
if (
|
|
28
|
+
(calcExpression === null || calcExpression === void 0 ? void 0 : calcExpression.value) !==
|
|
29
|
+
inputValue &&
|
|
30
|
+
typeof (calcExpression === null || calcExpression === void 0
|
|
31
|
+
? void 0
|
|
32
|
+
: calcExpression.value) === 'string'
|
|
33
|
+
) {
|
|
34
|
+
// update questionnaireResponse
|
|
35
|
+
onQrItemChange(
|
|
36
|
+
Object.assign(Object.assign({}, createEmptyQrItem(qItem)), {
|
|
37
|
+
answer: [{ valueString: calcExpression.value }]
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
31
42
|
// Only trigger this effect if calculatedExpression of item changes
|
|
32
43
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
-
[calculatedExpressions]
|
|
34
|
-
|
|
44
|
+
[calculatedExpressions]
|
|
45
|
+
);
|
|
46
|
+
return { calcExpUpdated: false };
|
|
35
47
|
}
|
|
36
48
|
export default useMinimalStringCalculatedExpression;
|
|
37
|
-
//# sourceMappingURL=useMinimalStringCalculatedExpression.js.map
|
|
49
|
+
//# sourceMappingURL=useMinimalStringCalculatedExpression.js.map
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { useEffect, useState } from 'react';
|
|
18
18
|
import { createEmptyQrItem } from '../utils/qrItem';
|
|
19
|
-
import useQuestionnaireStore from '../stores/
|
|
19
|
+
import { useQuestionnaireStore } from '../stores/questionnaireStore';
|
|
20
20
|
function useStringCalculatedExpression(props) {
|
|
21
21
|
const { qItem, inputValue, setInputValue, onQrItemChange } = props;
|
|
22
|
-
const calculatedExpressions = useQuestionnaireStore
|
|
22
|
+
const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();
|
|
23
23
|
const [calcExpUpdated, setCalcExpUpdated] = useState(false);
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
const calcExpression = calculatedExpressions[qItem.linkId];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStringCalculatedExpression.js","sourceRoot":"","sources":["../../src/hooks/useStringCalculatedExpression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,qBAAqB,MAAM,
|
|
1
|
+
{"version":3,"file":"useStringCalculatedExpression.js","sourceRoot":"","sources":["../../src/hooks/useStringCalculatedExpression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAarE,SAAS,6BAA6B,CACpC,KAAyC;IAEzC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAEnE,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC;IAEhF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5D,SAAS,CACP,GAAG,EAAE;QACH,MAAM,cAAc,GAAG,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAE3D,kEAAkE;QAClE,IAAI,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,MAAK,UAAU,IAAI,OAAO,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,CAAA,KAAK,QAAQ,EAAE;YACrF,6CAA6C;YAC7C,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACxB,UAAU,CAAC,GAAG,EAAE;gBACd,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC,EAAE,GAAG,CAAC,CAAC;YAER,+BAA+B;YAC/B,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACpC,cAAc,iCACT,iBAAiB,CAAC,KAAK,CAAC,KAC3B,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,cAAc,CAAC,KAAK,EAAE,CAAC,IAC/C,CAAC;SACJ;IACH,CAAC;IACD,mEAAmE;IACnE,uDAAuD;IACvD,CAAC,qBAAqB,CAAC,CACxB,CAAC;IAEF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAC5C,CAAC;AAED,eAAe,6BAA6B,CAAC"}
|
|
@@ -16,12 +16,11 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { useQuery } from '@tanstack/react-query';
|
|
18
18
|
import { getTerminologyServerUrl, getValueSetCodings, getValueSetPromise } from '../utils/valueSet';
|
|
19
|
-
import useQuestionnaireStore from '../stores
|
|
20
|
-
import useTerminologyServerStore from '../stores/useTerminologyServerStore';
|
|
19
|
+
import { useQuestionnaireStore, useTerminologyServerStore } from '../stores';
|
|
21
20
|
function useTerminologyServerQuery(qItem, maxList, input, searchTerm) {
|
|
22
21
|
var _a, _b;
|
|
23
|
-
const processedValueSetUrls = useQuestionnaireStore
|
|
24
|
-
const defaultTerminologyServerUrl = useTerminologyServerStore
|
|
22
|
+
const processedValueSetUrls = useQuestionnaireStore.use.processedValueSetUrls();
|
|
23
|
+
const defaultTerminologyServerUrl = useTerminologyServerStore.use.url();
|
|
25
24
|
let fullUrl = '';
|
|
26
25
|
let options = [];
|
|
27
26
|
let feedback;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTerminologyServerQuery.js","sourceRoot":"","sources":["../../src/hooks/useTerminologyServerQuery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGpG,OAAO,qBAAqB,
|
|
1
|
+
{"version":3,"file":"useTerminologyServerQuery.js","sourceRoot":"","sources":["../../src/hooks/useTerminologyServerQuery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGpG,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE7E,SAAS,yBAAyB,CAChC,KAAwB,EACxB,OAAe,EACf,KAAa,EACb,UAAkB;;IAElB,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC;IAChF,MAAM,2BAA2B,GAAG,yBAAyB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IAExE,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,OAAO,GAAa,EAAE,CAAC;IAC3B,IAAI,QAA4D,CAAC;IAEjE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,QAAQ,GAAG,SAAS,CAAC;KACtB;IAED,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;QAClD,QAAQ,GAAG,EAAE,OAAO,EAAE,oDAAoD,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;KAC7F;IAED,yDAAyD;IACzD,IAAI,i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B,CAAC,IAAI,CAAC,CAAC;SACpC;aAAM;YACL,QAAQ,GAAG;gBACT,OAAO,EAAE,wEAAwE;gBACjF,KAAK,EAAE,SAAS;aACjB,CAAC;SACH;KACF;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AACpD,CAAC;AACD,eAAe,yBAAyB,CAAC"}
|
|
@@ -19,20 +19,18 @@ import { getResourceFromLaunchContext, getTerminologyServerUrl, getValueSetCodin
|
|
|
19
19
|
import { getAnswerExpression } from '../utils/itemControl';
|
|
20
20
|
import fhirpath from 'fhirpath';
|
|
21
21
|
import fhirpath_r4_model from 'fhirpath/fhir-context/r4';
|
|
22
|
-
import useSmartConfigStore from '../stores
|
|
23
|
-
import useQuestionnaireStore from '../stores/useQuestionnaireStore';
|
|
24
|
-
import useTerminologyServerStore from '../stores/useTerminologyServerStore';
|
|
22
|
+
import { useQuestionnaireStore, useSmartConfigStore, useTerminologyServerStore } from '../stores';
|
|
25
23
|
function useValueSetCodings(qItem) {
|
|
26
24
|
var _a;
|
|
27
|
-
const patient = useSmartConfigStore
|
|
28
|
-
const user = useSmartConfigStore
|
|
29
|
-
const encounter = useSmartConfigStore
|
|
30
|
-
const launchContexts = useQuestionnaireStore
|
|
31
|
-
const processedValueSetCodings = useQuestionnaireStore
|
|
32
|
-
const cachedValueSetCodings = useQuestionnaireStore
|
|
33
|
-
const addCodingToCache = useQuestionnaireStore
|
|
34
|
-
const { xFhirQueryVariables } = useQuestionnaireStore
|
|
35
|
-
const defaultTerminologyServerUrl = useTerminologyServerStore
|
|
25
|
+
const patient = useSmartConfigStore.use.patient();
|
|
26
|
+
const user = useSmartConfigStore.use.user();
|
|
27
|
+
const encounter = useSmartConfigStore.use.encounter();
|
|
28
|
+
const launchContexts = useQuestionnaireStore.use.launchContexts();
|
|
29
|
+
const processedValueSetCodings = useQuestionnaireStore.use.processedValueSetCodings();
|
|
30
|
+
const cachedValueSetCodings = useQuestionnaireStore.use.cachedValueSetCodings();
|
|
31
|
+
const addCodingToCache = useQuestionnaireStore.use.addCodingToCache();
|
|
32
|
+
const { xFhirQueryVariables } = useQuestionnaireStore.use.variables();
|
|
33
|
+
const defaultTerminologyServerUrl = useTerminologyServerStore.use.url();
|
|
36
34
|
const valueSetUrl = qItem.answerValueSet;
|
|
37
35
|
let initialCodings = useMemo(() => {
|
|
38
36
|
// set options from cached answer options if present
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useValueSetCodings.js","sourceRoot":"","sources":["../../src/hooks/useValueSetCodings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"useValueSetCodings.js","sourceRoot":"","sources":["../../src/hooks/useValueSetCodings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAElG,SAA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AC;iBACrB;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;gBACtB,cAAc,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;SACN;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,eAAe,kBAAkB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -7,9 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import
|
|
10
|
+
import { questionnaireResponseStore, questionnaireStore } from './stores';
|
|
11
11
|
import { createEmptyQuestionnaireResponse } from './utils/qrItem';
|
|
12
|
-
import useQuestionnaireResponseStore from './stores/useQuestionnaireResponseStore';
|
|
13
12
|
import { removeHiddenAnswers } from './utils/removeHidden';
|
|
14
13
|
import { getItemsToRepopulate } from './utils/repopulateItems';
|
|
15
14
|
import { repopulateItemsIntoResponse } from './utils/repopulateIntoResponse';
|
|
@@ -25,15 +24,15 @@ export * from './utils';
|
|
|
25
24
|
*/
|
|
26
25
|
export function buildForm(questionnaire, questionnaireResponse) {
|
|
27
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
yield
|
|
27
|
+
yield questionnaireStore.getState().buildSourceQuestionnaire(questionnaire);
|
|
29
28
|
if (!questionnaireResponse) {
|
|
30
|
-
|
|
29
|
+
questionnaireResponseStore
|
|
31
30
|
.getState()
|
|
32
31
|
.buildSourceResponse(createEmptyQuestionnaireResponse(questionnaire));
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
questionnaireResponseStore.getState().buildSourceResponse(questionnaireResponse);
|
|
35
|
+
questionnaireStore.getState().updatePopulatedProperties(questionnaireResponse);
|
|
37
36
|
});
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
@@ -42,8 +41,8 @@ export function buildForm(questionnaire, questionnaireResponse) {
|
|
|
42
41
|
* @author Sean Fong
|
|
43
42
|
*/
|
|
44
43
|
export function destroyForm() {
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
questionnaireStore.getState().destroySourceQuestionnaire();
|
|
45
|
+
questionnaireResponseStore.getState().destroySourceResponse();
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
48
|
* Get the filled QuestionnaireResponse at its current state.
|
|
@@ -52,7 +51,7 @@ export function destroyForm() {
|
|
|
52
51
|
* @author Sean Fong
|
|
53
52
|
*/
|
|
54
53
|
export function getResponse() {
|
|
55
|
-
return
|
|
54
|
+
return questionnaireResponseStore.getState().updatableResponse;
|
|
56
55
|
}
|
|
57
56
|
/**
|
|
58
57
|
* Remove all hidden answers from the filled QuestionnaireResponse.
|
|
@@ -61,9 +60,9 @@ export function getResponse() {
|
|
|
61
60
|
* @author Sean Fong
|
|
62
61
|
*/
|
|
63
62
|
export function removeHiddenAnswersFromResponse(questionnaire, questionnaireResponse) {
|
|
64
|
-
const enableWhenIsActivated =
|
|
65
|
-
const enableWhenItems =
|
|
66
|
-
const enableWhenExpressions =
|
|
63
|
+
const enableWhenIsActivated = questionnaireStore.getState().enableWhenIsActivated;
|
|
64
|
+
const enableWhenItems = questionnaireStore.getState().enableWhenItems;
|
|
65
|
+
const enableWhenExpressions = questionnaireStore.getState().enableWhenExpressions;
|
|
67
66
|
return removeHiddenAnswers({
|
|
68
67
|
questionnaire,
|
|
69
68
|
questionnaireResponse,
|
|
@@ -78,12 +77,12 @@ export function removeHiddenAnswersFromResponse(questionnaire, questionnaireResp
|
|
|
78
77
|
* @author Sean Fong
|
|
79
78
|
*/
|
|
80
79
|
export function generateItemsToRepopulate(populatedResponse) {
|
|
81
|
-
const sourceQuestionnaire =
|
|
82
|
-
const tabs =
|
|
83
|
-
const updatableResponse =
|
|
84
|
-
const enableWhenIsActivated =
|
|
85
|
-
const enableWhenItems =
|
|
86
|
-
const enableWhenExpressions =
|
|
80
|
+
const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;
|
|
81
|
+
const tabs = questionnaireStore.getState().tabs;
|
|
82
|
+
const updatableResponse = questionnaireResponseStore.getState().updatableResponse;
|
|
83
|
+
const enableWhenIsActivated = questionnaireStore.getState().enableWhenIsActivated;
|
|
84
|
+
const enableWhenItems = questionnaireStore.getState().enableWhenItems;
|
|
85
|
+
const enableWhenExpressions = questionnaireStore.getState().enableWhenExpressions;
|
|
87
86
|
return getItemsToRepopulate({
|
|
88
87
|
sourceQuestionnaire,
|
|
89
88
|
tabs,
|
|
@@ -100,8 +99,8 @@ export function generateItemsToRepopulate(populatedResponse) {
|
|
|
100
99
|
* @author Sean Fong
|
|
101
100
|
*/
|
|
102
101
|
export function repopulateResponse(checkedItemsToRepopulate) {
|
|
103
|
-
const sourceQuestionnaire =
|
|
104
|
-
const updatableResponse =
|
|
102
|
+
const sourceQuestionnaire = questionnaireStore.getState().sourceQuestionnaire;
|
|
103
|
+
const updatableResponse = questionnaireResponseStore.getState().updatableResponse;
|
|
105
104
|
return repopulateItemsIntoResponse(sourceQuestionnaire, updatableResponse, checkedItemsToRepopulate);
|
|
106
105
|
}
|
|
107
106
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE1E,OAAO,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,E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mB,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,kBAAkB,CAAC,QAAQ,EAAE,CAAC,mBAAmB,CAAC;IAC9E,MAAM,IAAI,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;IAChD,MAAM,iBAAiB,GAAG,0BAA0B,CAAC,QAAQ,EAAE,CAAC,iBAAiB,CAAC;IAClF,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAC,qBAAqB,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,oBAAoB,CAAC;QAC1B,mBAAmB;QACnB,IAAI;QACJ,iBAAiB;QACjB,iBAAiB;QACjB,qBAAqB;QACrB,eAAe;QACf,qBAAqB;KACtB,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,wBAA0D;IAC3F,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAC,mBAAmB,CAAC;IAC9E,MAAM,iBAAiB,GAAG,0BAA0B,CAAC,QAAQ,EAAE,CAAC,iBAAiB,CAAC;IAElF,OAAO,2BAA2B,CAChC,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/setup-jest.ts"],"sourcesContent":["import '@testing-library/jest-dom';\n"],"names":[],"mappings":"AAAA,OAAO,4BAA4B"}
|
package/lib/stores/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { questionnaireStore, useQuestionnaireStore } from './questionnaireStore';
|
|
2
|
+
export { questionnaireResponseStore, useQuestionnaireResponseStore } from './questionnaireResponseStore';
|
|
3
|
+
export { smartConfigStore, useSmartConfigStore } from './smartConfigStore';
|
|
4
|
+
export { terminologyServerStore, useTerminologyServerStore } from './terminologyServerStore';
|
package/lib/stores/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { questionnaireStore, useQuestionnaireStore } from './questionnaireStore';
|
|
2
|
+
export { questionnaireResponseStore, useQuestionnaireResponseStore } from './questionnaireResponseStore';
|
|
3
|
+
export { smartConfigStore, useSmartConfigStore } from './smartConfigStore';
|
|
4
|
+
export { terminologyServerStore, useTerminologyServerStore } from './terminologyServerStore';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
package/lib/stores/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
+
import type { Diff } from 'deep-diff';
|
|
3
|
+
interface QuestionnaireResponseStoreType {
|
|
4
|
+
sourceResponse: QuestionnaireResponse;
|
|
5
|
+
updatableResponse: QuestionnaireResponse;
|
|
6
|
+
formChangesHistory: (Diff<QuestionnaireResponse, QuestionnaireResponse>[] | null)[];
|
|
7
|
+
buildSourceResponse: (response: QuestionnaireResponse) => void;
|
|
8
|
+
setUpdatableResponseAsPopulated: (populatedResponse: QuestionnaireResponse) => void;
|
|
9
|
+
updateResponse: (updatedResponse: QuestionnaireResponse) => void;
|
|
10
|
+
setUpdatableResponseAsSaved: (savedResponse: QuestionnaireResponse) => void;
|
|
11
|
+
setUpdatableResponseAsEmpty: (clearedResponse: QuestionnaireResponse) => void;
|
|
12
|
+
destroySourceResponse: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const questionnaireResponseStore: import("zustand/vanilla").StoreApi<QuestionnaireResponseStoreType>;
|
|
15
|
+
export declare const useQuestionnaireResponseStore: import("zustand/vanilla").StoreApi<QuestionnaireResponseStoreType> & {
|
|
16
|
+
use: {
|
|
17
|
+
sourceResponse: () => QuestionnaireResponse;
|
|
18
|
+
updatableResponse: () => QuestionnaireResponse;
|
|
19
|
+
formChangesHistory: () => (Diff<QuestionnaireResponse, QuestionnaireResponse>[] | null)[];
|
|
20
|
+
buildSourceResponse: () => (response: QuestionnaireResponse) => void;
|
|
21
|
+
setUpdatableResponseAsPopulated: () => (populatedResponse: QuestionnaireResponse) => void;
|
|
22
|
+
updateResponse: () => (updatedResponse: QuestionnaireResponse) => void;
|
|
23
|
+
setUpdatableResponseAsSaved: () => (savedResponse: QuestionnaireResponse) => void;
|
|
24
|
+
setUpdatableResponseAsEmpty: () => (clearedResponse: QuestionnaireResponse) => void;
|
|
25
|
+
destroySourceResponse: () => () => void;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { createStore } from 'zustand/vanilla';
|
|
18
|
+
import { emptyResponse } from '../utils/emptyResource';
|
|
19
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
20
|
+
import { diff } from 'deep-diff';
|
|
21
|
+
import { createSelectors } from './selector';
|
|
22
|
+
export const questionnaireResponseStore = createStore()((set, get) => ({
|
|
23
|
+
sourceResponse: cloneDeep(emptyResponse),
|
|
24
|
+
updatableResponse: cloneDeep(emptyResponse),
|
|
25
|
+
formChangesHistory: [],
|
|
26
|
+
buildSourceResponse: (questionnaireResponse) => {
|
|
27
|
+
set(() => ({
|
|
28
|
+
sourceResponse: questionnaireResponse,
|
|
29
|
+
updatableResponse: questionnaireResponse
|
|
30
|
+
}));
|
|
31
|
+
},
|
|
32
|
+
setUpdatableResponseAsPopulated: (populatedResponse) => {
|
|
33
|
+
var _a;
|
|
34
|
+
const formChanges = (_a = diff(get().updatableResponse, populatedResponse)) !== null && _a !== void 0 ? _a : null;
|
|
35
|
+
set(() => ({
|
|
36
|
+
updatableResponse: populatedResponse,
|
|
37
|
+
formChangesHistory: [...get().formChangesHistory, formChanges]
|
|
38
|
+
}));
|
|
39
|
+
},
|
|
40
|
+
updateResponse: (updatedResponse) => {
|
|
41
|
+
var _a;
|
|
42
|
+
const formChanges = (_a = diff(get().updatableResponse, updatedResponse)) !== null && _a !== void 0 ? _a : null;
|
|
43
|
+
set(() => ({
|
|
44
|
+
updatableResponse: updatedResponse,
|
|
45
|
+
formChangesHistory: [...get().formChangesHistory, formChanges]
|
|
46
|
+
}));
|
|
47
|
+
},
|
|
48
|
+
setUpdatableResponseAsSaved: (savedResponse) => set(() => ({
|
|
49
|
+
sourceResponse: savedResponse,
|
|
50
|
+
updatableResponse: savedResponse,
|
|
51
|
+
formChangesHistory: []
|
|
52
|
+
})),
|
|
53
|
+
setUpdatableResponseAsEmpty: (clearedResponse) => set(() => ({
|
|
54
|
+
updatableResponse: clearedResponse,
|
|
55
|
+
formChangesHistory: []
|
|
56
|
+
})),
|
|
57
|
+
destroySourceResponse: () => set(() => ({
|
|
58
|
+
sourceResponse: cloneDeep(emptyResponse),
|
|
59
|
+
updatableResponse: cloneDeep(emptyResponse),
|
|
60
|
+
formChangesHistory: []
|
|
61
|
+
}))
|
|
62
|
+
}));
|
|
63
|
+
export const useQuestionnaireResponseStore = createSelectors(questionnaireResponseStore);
|
|
64
|
+
//# sourceMappingURL=questionnaireResponseStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"questionnaireResponseStore.js","sourceRoot":"","sources":["../../src/stores/questionnaireResponseStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAc7C,MAAM,CAAC,MAAM,0BAA0B,GAAG,WAAW,EAAkC,CACrF,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IACb,cAAc,EAAE,SAAS,CAAC,aA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BAAkB,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,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,eAAe,CAAC,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Coding, Questionnaire, QuestionnaireResponse, QuestionnaireResponseItemAnswer } from 'fhir/r4';
|
|
2
|
+
import type { Variables } from '../interfaces/variables.interface';
|
|
3
|
+
import type { LaunchContext } from '../interfaces/populate.interface';
|
|
4
|
+
import type { CalculatedExpression } from '../interfaces/calculatedExpression.interface';
|
|
5
|
+
import type { EnableWhenExpression, EnableWhenItems } from '../interfaces/enableWhen.interface';
|
|
6
|
+
import type { AnswerExpression } from '../interfaces/answerExpression.interface';
|
|
7
|
+
import type { Tabs } from '../interfaces/tab.interface';
|
|
8
|
+
interface QuestionnaireStoreType {
|
|
9
|
+
sourceQuestionnaire: Questionnaire;
|
|
10
|
+
itemTypes: Record<string, string>;
|
|
11
|
+
tabs: Tabs;
|
|
12
|
+
currentTabIndex: number;
|
|
13
|
+
variables: Variables;
|
|
14
|
+
launchContexts: Record<string, LaunchContext>;
|
|
15
|
+
enableWhenItems: EnableWhenItems;
|
|
16
|
+
enableWhenLinkedQuestions: Record<string, string[]>;
|
|
17
|
+
enableWhenIsActivated: boolean;
|
|
18
|
+
enableWhenExpressions: Record<string, EnableWhenExpression>;
|
|
19
|
+
calculatedExpressions: Record<string, CalculatedExpression>;
|
|
20
|
+
answerExpressions: Record<string, AnswerExpression>;
|
|
21
|
+
processedValueSetCodings: Record<string, Coding[]>;
|
|
22
|
+
processedValueSetUrls: Record<string, string>;
|
|
23
|
+
cachedValueSetCodings: Record<string, Coding[]>;
|
|
24
|
+
fhirPathContext: Record<string, any>;
|
|
25
|
+
buildSourceQuestionnaire: (questionnaire: Questionnaire, questionnaireResponse?: QuestionnaireResponse, additionalVariables?: Record<string, object>, terminologyServerUrl?: string) => Promise<void>;
|
|
26
|
+
destroySourceQuestionnaire: () => void;
|
|
27
|
+
switchTab: (newTabIndex: number) => void;
|
|
28
|
+
markTabAsComplete: (tabLinkId: string) => void;
|
|
29
|
+
updateEnableWhenItem: (linkId: string, newAnswer: QuestionnaireResponseItemAnswer[]) => void;
|
|
30
|
+
toggleEnableWhenActivation: (isActivated: boolean) => void;
|
|
31
|
+
updateExpressions: (updatedResponse: QuestionnaireResponse) => void;
|
|
32
|
+
addCodingToCache: (valueSetUrl: string, codings: Coding[]) => void;
|
|
33
|
+
updatePopulatedProperties: (populatedResponse: QuestionnaireResponse, persistTabIndex?: boolean) => QuestionnaireResponse;
|
|
34
|
+
}
|
|
35
|
+
export declare const questionnaireStore: import("zustand/vanilla").StoreApi<QuestionnaireStoreType>;
|
|
36
|
+
export declare const useQuestionnaireStore: import("zustand/vanilla").StoreApi<QuestionnaireStoreType> & {
|
|
37
|
+
use: {
|
|
38
|
+
sourceQuestionnaire: () => Questionnaire;
|
|
39
|
+
itemTypes: () => Record<string, string>;
|
|
40
|
+
tabs: () => Tabs;
|
|
41
|
+
currentTabIndex: () => number;
|
|
42
|
+
variables: () => Variables;
|
|
43
|
+
launchContexts: () => Record<string, LaunchContext>;
|
|
44
|
+
enableWhenItems: () => EnableWhenItems;
|
|
45
|
+
enableWhenLinkedQuestions: () => Record<string, string[]>;
|
|
46
|
+
enableWhenIsActivated: () => boolean;
|
|
47
|
+
enableWhenExpressions: () => Record<string, EnableWhenExpression>;
|
|
48
|
+
calculatedExpressions: () => Record<string, CalculatedExpression>;
|
|
49
|
+
answerExpressions: () => Record<string, AnswerExpression>;
|
|
50
|
+
processedValueSetCodings: () => Record<string, Coding[]>;
|
|
51
|
+
processedValueSetUrls: () => Record<string, string>;
|
|
52
|
+
cachedValueSetCodings: () => Record<string, Coding[]>;
|
|
53
|
+
fhirPathContext: () => Record<string, any>;
|
|
54
|
+
buildSourceQuestionnaire: () => (questionnaire: Questionnaire, questionnaireResponse?: QuestionnaireResponse, additionalVariables?: Record<string, object>, terminologyServerUrl?: string) => Promise<void>;
|
|
55
|
+
destroySourceQuestionnaire: () => () => void;
|
|
56
|
+
switchTab: () => (newTabIndex: number) => void;
|
|
57
|
+
markTabAsComplete: () => (tabLinkId: string) => void;
|
|
58
|
+
updateEnableWhenItem: () => (linkId: string, newAnswer: QuestionnaireResponseItemAnswer[]) => void;
|
|
59
|
+
toggleEnableWhenActivation: () => (isActivated: boolean) => void;
|
|
60
|
+
updateExpressions: () => (updatedResponse: QuestionnaireResponse) => void;
|
|
61
|
+
addCodingToCache: () => (valueSetUrl: string, codings: Coding[]) => void;
|
|
62
|
+
updatePopulatedProperties: () => (populatedResponse: QuestionnaireResponse, persistTabIndex?: boolean) => QuestionnaireResponse;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export {};
|