diff --git a/apps/smart-forms-app/package.json b/apps/smart-forms-app/package.json index dea00a25..d6985978 100644 --- a/apps/smart-forms-app/package.json +++ b/apps/smart-forms-app/package.json @@ -27,8 +27,8 @@ "homepage": "https://github.com/aehrc/smart-forms#readme", "dependencies": { "@aehrc/sdc-assemble": "^1.2.0", - "@aehrc/sdc-populate": "^2.2.3", - "@aehrc/smart-forms-renderer": "^0.35.8", + "@aehrc/sdc-populate": "^2.2.4", + "@aehrc/smart-forms-renderer": "^0.35.9", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", "@fontsource/material-icons": "^5.0.18", diff --git a/apps/smart-forms-app/src/features/playground/components/Playground.tsx b/apps/smart-forms-app/src/features/playground/components/Playground.tsx index 307d8b9f..074f1b3b 100644 --- a/apps/smart-forms-app/src/features/playground/components/Playground.tsx +++ b/apps/smart-forms-app/src/features/playground/components/Playground.tsx @@ -44,7 +44,7 @@ import type { Patient, Practitioner, Questionnaire } from 'fhir/r4'; import PlaygroundHeader from './PlaygroundHeader.tsx'; import { HEADERS } from '../../../api/headers.ts'; import { fetchTargetStructureMap } from '../api/extract.ts'; -import { useExtractOperationStore } from '../stores/smartConfigStore.ts'; +import { useExtractOperationStore } from '../stores/extractOperationStore.ts'; const defaultFhirServerUrl = 'https://hapi.fhir.org/baseR4'; const defaultExtractEndpoint = 'https://proxy.smartforms.io/fhir'; diff --git a/apps/smart-forms-app/src/features/playground/components/PlaygroundRenderer.tsx b/apps/smart-forms-app/src/features/playground/components/PlaygroundRenderer.tsx index 8c7c35c4..6b9ba543 100644 --- a/apps/smart-forms-app/src/features/playground/components/PlaygroundRenderer.tsx +++ b/apps/smart-forms-app/src/features/playground/components/PlaygroundRenderer.tsx @@ -25,7 +25,7 @@ import { Box, Typography } from '@mui/material'; import useLaunchContextNames from '../hooks/useLaunchContextNames.ts'; import { TERMINOLOGY_SERVER_URL } from '../../../globals.ts'; import ExtractButtonForPlayground from './ExtractButtonForPlayground.tsx'; -import { useExtractOperationStore } from '../stores/smartConfigStore.ts'; +import { useExtractOperationStore } from '../stores/extractOperationStore.ts'; interface PlaygroundRendererProps { endpointUrl: string | null; diff --git a/apps/smart-forms-app/src/features/playground/hooks/useShowExtractedOperationStoreProperty.ts b/apps/smart-forms-app/src/features/playground/hooks/useShowExtractedOperationStoreProperty.ts index 422137f5..6bc19fcc 100644 --- a/apps/smart-forms-app/src/features/playground/hooks/useShowExtractedOperationStoreProperty.ts +++ b/apps/smart-forms-app/src/features/playground/hooks/useShowExtractedOperationStoreProperty.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { useExtractOperationStore } from '../stores/smartConfigStore.ts'; +import { useExtractOperationStore } from '../stores/extractOperationStore.ts'; function useShowExtractedOperationStoreProperty(selectedProperty: string) { const extractedResource = useExtractOperationStore.use.extractedResource(); diff --git a/apps/smart-forms-app/src/features/playground/stores/smartConfigStore.ts b/apps/smart-forms-app/src/features/playground/stores/extractOperationStore.ts similarity index 96% rename from apps/smart-forms-app/src/features/playground/stores/smartConfigStore.ts rename to apps/smart-forms-app/src/features/playground/stores/extractOperationStore.ts index a2b68e4c..58ed5a35 100644 --- a/apps/smart-forms-app/src/features/playground/stores/smartConfigStore.ts +++ b/apps/smart-forms-app/src/features/playground/stores/extractOperationStore.ts @@ -17,7 +17,7 @@ import { createStore } from 'zustand/vanilla'; import type { StructureMap } from 'fhir/r4'; -import { createSelectors } from './selector'; +import { createSelectors } from '../../../stores/selector.ts'; export interface ExtractOperationStoreType { targetStructureMap: StructureMap | null; diff --git a/apps/smart-forms-app/src/features/renderer/components/RendererActions/RepopulateAction.tsx b/apps/smart-forms-app/src/features/renderer/components/RendererActions/RepopulateAction.tsx index 99926bed..31270dae 100644 --- a/apps/smart-forms-app/src/features/renderer/components/RendererActions/RepopulateAction.tsx +++ b/apps/smart-forms-app/src/features/renderer/components/RendererActions/RepopulateAction.tsx @@ -24,13 +24,12 @@ import type { SpeedDialActionProps } from '@mui/material'; import { SpeedDialAction, Tooltip } from '@mui/material'; import type { RendererSpinner } from '../../types/rendererSpinner.ts'; import useSmartClient from '../../../../hooks/useSmartClient.ts'; -import type { ItemToRepopulate } from '@aehrc/smart-forms-renderer'; import { generateItemsToRepopulate, useQuestionnaireStore } from '@aehrc/smart-forms-renderer'; import RepopulateDialog from '../../../repopulate/components/RepopulateDialog.tsx'; -import { useState } from 'react'; import type { Encounter, Patient, Practitioner } from 'fhir/r4'; import { useMutation } from '@tanstack/react-query'; import { readCommonLaunchContexts } from '../../../smartAppLaunch/utils/launch.ts'; +import { useRepopulationStore } from '../../../repopulate/stores/RepopulationStore.ts'; interface RepopulateActionProps extends SpeedDialActionProps { spinner: RendererSpinner; @@ -43,7 +42,7 @@ function RepopulateAction(props: RepopulateActionProps) { const { smartClient, patient, user } = useSmartClient(); - const [itemsToRepopulate, setItemsToRepopulate] = useState>({}); + const setItemsToRepopulate = useRepopulationStore.use.setItemsToRepopulate(); const sourceQuestionnaire = useQuestionnaireStore.use.sourceQuestionnaire(); const fhirPathContext = useQuestionnaireStore.use.fhirPathContext(); @@ -175,7 +174,6 @@ function RepopulateAction(props: RepopulateActionProps) { onSpinnerChange({ isSpinning: false, status: null, message: '' })} onSpinnerChange={onSpinnerChange} /> diff --git a/apps/smart-forms-app/src/features/repopulate/components/RepopulateDialog.tsx b/apps/smart-forms-app/src/features/repopulate/components/RepopulateDialog.tsx index 4259af2d..1fc3f466 100644 --- a/apps/smart-forms-app/src/features/repopulate/components/RepopulateDialog.tsx +++ b/apps/smart-forms-app/src/features/repopulate/components/RepopulateDialog.tsx @@ -15,20 +15,21 @@ * limitations under the License. */ -import type { ItemToRepopulate } from '@aehrc/smart-forms-renderer'; import RepopulateEmptyDialog from './RepopulateEmptyDialog.tsx'; import RepopulateSelectDialog from './RepopulateSelectDialog.tsx'; import type { RendererSpinner } from '../../renderer/types/rendererSpinner.ts'; +import { useRepopulationStore } from '../stores/RepopulationStore.ts'; interface RepopulateDialogProps { repopulateFetchingEnded: boolean; - itemsToRepopulate: Record; onCloseDialog: () => void; onSpinnerChange: (newSpinner: RendererSpinner) => void; } function RepopulateDialog(props: RepopulateDialogProps) { - const { repopulateFetchingEnded, itemsToRepopulate, onCloseDialog, onSpinnerChange } = props; + const { repopulateFetchingEnded, onCloseDialog, onSpinnerChange } = props; + + const itemsToRepopulate = useRepopulationStore.use.itemsToRepopulate(); if (!repopulateFetchingEnded) { return null; diff --git a/apps/smart-forms-app/src/features/repopulate/stores/RepopulationStore.ts b/apps/smart-forms-app/src/features/repopulate/stores/RepopulationStore.ts new file mode 100644 index 00000000..a9f884fb --- /dev/null +++ b/apps/smart-forms-app/src/features/repopulate/stores/RepopulationStore.ts @@ -0,0 +1,33 @@ +/* + * Copyright 2024 Commonwealth Scientific and Industrial Research + * Organisation (CSIRO) ABN 41 687 119 230. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { createStore } from 'zustand/vanilla'; +import { createSelectors } from '../../../stores/selector.ts'; +import type { ItemToRepopulate } from '@aehrc/smart-forms-renderer'; + +export interface RepopulationStoreType { + itemsToRepopulate: Record; + setItemsToRepopulate: (itemsToRepopulate: Record) => void; +} + +export const RepopulationStore = createStore()((set) => ({ + itemsToRepopulate: {}, + setItemsToRepopulate: (itemsToRepopulate: Record) => + set(() => ({ itemsToRepopulate: itemsToRepopulate })) +})); + +export const useRepopulationStore = createSelectors(RepopulationStore); diff --git a/apps/smart-forms-app/src/features/playground/stores/selector.ts b/apps/smart-forms-app/src/stores/selector.ts similarity index 100% rename from apps/smart-forms-app/src/features/playground/stores/selector.ts rename to apps/smart-forms-app/src/stores/selector.ts diff --git a/packages/sdc-populate/package.json b/packages/sdc-populate/package.json index a351bbd4..d7e69fe8 100644 --- a/packages/sdc-populate/package.json +++ b/packages/sdc-populate/package.json @@ -1,6 +1,6 @@ { "name": "@aehrc/sdc-populate", - "version": "2.2.3", + "version": "2.2.4", "description": "Performs the $populate operation from the HL7 FHIR SDC (Structured Data Capture) specification: http://hl7.org/fhir/uv/sdc", "main": "lib/index.js", "scripts": { diff --git a/packages/smart-forms-renderer/package.json b/packages/smart-forms-renderer/package.json index 92ca877f..0a8f73a1 100644 --- a/packages/smart-forms-renderer/package.json +++ b/packages/smart-forms-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@aehrc/smart-forms-renderer", - "version": "0.35.8", + "version": "0.35.9", "description": "FHIR Structured Data Captured (SDC) rendering engine for Smart Forms", "main": "lib/index.js", "scripts": { @@ -27,7 +27,7 @@ }, "homepage": "https://github.com/aehrc/smart-forms#readme", "dependencies": { - "@aehrc/sdc-populate": "^2.2.3", + "@aehrc/sdc-populate": "^2.2.4", "@iconify/react": "^4.1.1", "dayjs": "^1.11.10", "deep-diff": "^1.0.2",