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 22, 2025
1 parent 9172f61 commit 9a47643
Showing 1 changed file with 18 additions and 0 deletions.
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

0 comments on commit 9a47643

Please sign in to comment.