Skip to content

Commit

Permalink
Merge pull request #434 from beda-software/patient-document-provenanc…
Browse files Browse the repository at this point in the history
…e-bundle

Add ProvenanceBundle resource to launchContext when opening PatientDocument
  • Loading branch information
ir4y authored Jan 23, 2025
2 parents 9172f61 + 5fb7265 commit 5b89dfa
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<WithId<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<WithId<Provenance>> = {
resourceType: 'Bundle',
type: 'collection',
entry: provenanceResponse.data.map((provenance) => ({ resource: provenance })),
};

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

const onSubmit = async (formData: QuestionnaireResponseFormData) =>
Expand Down

0 comments on commit 5b89dfa

Please sign in to comment.