Skip to content

Commit

Permalink
Add ProvenanceBundle resource to launchContext when opening PatientDo…
Browse files Browse the repository at this point in the history
…cument
  • Loading branch information
alexlipovka committed Jan 21, 2025
1 parent 77f5840 commit 1ee4f75
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Bundle,
Encounter,
Organization,
ParametersParameter,
Expand Down Expand Up @@ -74,6 +75,7 @@ function prepareFormInitialParams(
props: Props & {
provenance?: WithId<Provenance>;
author?: WithId<Practitioner | Patient | Organization>;
provenanceBundle?: Bundle<Provenance>;
},
): QuestionnaireResponseFormProps {
const {
Expand All @@ -84,6 +86,7 @@ function prepareFormInitialParams(
provenance,
author,
launchContextParameters = [],
provenanceBundle,
} = props;

const params = {
Expand All @@ -110,6 +113,14 @@ function prepareFormInitialParams(
},
]
: []),
...(provenanceBundle
? [
{
name: 'ProvenanceBundle',
resource: provenanceBundle,
},
]
: []),
...launchContextParameters,
],
initialQuestionnaireResponse: questionnaireResponse || {
Expand Down Expand Up @@ -150,9 +161,16 @@ export function usePatientDocument(props: Props): {
);
const lastProvenance = descSortedProvenances[0];

const provenanceBundle: Bundle<Provenance> = {
resourceType: 'Bundle',
type: 'collection',
entry: provenanceResponse.data,
};

const formInitialParams = prepareFormInitialParams({
...props,
provenance: lastProvenance,
provenanceBundle: provenanceBundle,
});

const onSubmit = async (formData: QuestionnaireResponseFormData) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PrinterOutlined } from '@ant-design/icons';
import { t, Trans } from '@lingui/macro';
import { Button, notification } from 'antd';
import { Encounter, Organization, Patient, Practitioner, Provenance, QuestionnaireResponse } from 'fhir/r4b';
import { Bundle, Encounter, Organization, Patient, Practitioner, Provenance, QuestionnaireResponse } from 'fhir/r4b';

Check failure on line 4 in src/containers/PatientDetails/PatientDocumentDetails/index.tsx

View workflow job for this annotation

GitHub Actions / Tests

'Bundle' is declared but its value is never read.
import { ReactElement } from 'react';
import { NavigateFunction, Outlet, Route, Routes, useLocation, useNavigate, useParams } from 'react-router-dom';
import { QuestionnaireResponseFormData } from 'sdc-qrf';
Expand Down

0 comments on commit 1ee4f75

Please sign in to comment.