Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/sdc pop #895

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/smart-forms-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,7 +42,7 @@ function RepopulateAction(props: RepopulateActionProps) {

const { smartClient, patient, user } = useSmartClient();

const [itemsToRepopulate, setItemsToRepopulate] = useState<Record<string, ItemToRepopulate>>({});
const setItemsToRepopulate = useRepopulationStore.use.setItemsToRepopulate();

const sourceQuestionnaire = useQuestionnaireStore.use.sourceQuestionnaire();
const fhirPathContext = useQuestionnaireStore.use.fhirPathContext();
Expand Down Expand Up @@ -175,7 +174,6 @@ function RepopulateAction(props: RepopulateActionProps) {

<RepopulateDialog
repopulateFetchingEnded={repopulateFetchEnded}
itemsToRepopulate={itemsToRepopulate}
onCloseDialog={() => onSpinnerChange({ isSpinning: false, status: null, message: '' })}
onSpinnerChange={onSpinnerChange}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, ItemToRepopulate>;
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<string, ItemToRepopulate>;
setItemsToRepopulate: (itemsToRepopulate: Record<string, ItemToRepopulate>) => void;
}

export const RepopulationStore = createStore<RepopulationStoreType>()((set) => ({
itemsToRepopulate: {},
setItemsToRepopulate: (itemsToRepopulate: Record<string, ItemToRepopulate>) =>
set(() => ({ itemsToRepopulate: itemsToRepopulate }))
}));

export const useRepopulationStore = createSelectors(RepopulationStore);
2 changes: 1 addition & 1 deletion packages/sdc-populate/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions packages/smart-forms-renderer/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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",
Expand Down
Loading