diff --git a/src/containers/PatientDetails/PatientDocument/usePatientDocument.ts b/src/containers/PatientDetails/PatientDocument/usePatientDocument.ts index 9ecc8402..b2f5c73b 100644 --- a/src/containers/PatientDetails/PatientDocument/usePatientDocument.ts +++ b/src/containers/PatientDetails/PatientDocument/usePatientDocument.ts @@ -1,4 +1,5 @@ import { + Bundle, Encounter, Organization, ParametersParameter, @@ -74,6 +75,7 @@ function prepareFormInitialParams( props: Props & { provenance?: WithId; author?: WithId; + provenanceBundle?: Bundle>; }, ): QuestionnaireResponseFormProps { const { @@ -84,6 +86,7 @@ function prepareFormInitialParams( provenance, author, launchContextParameters = [], + provenanceBundle, } = props; const params = { @@ -110,6 +113,14 @@ function prepareFormInitialParams( }, ] : []), + ...(provenanceBundle + ? [ + { + name: 'ProvenanceBundle', + resource: provenanceBundle, + }, + ] + : []), ...launchContextParameters, ], initialQuestionnaireResponse: questionnaireResponse || { @@ -150,9 +161,16 @@ export function usePatientDocument(props: Props): { ); const lastProvenance = descSortedProvenances[0]; + const provenanceBundle: Bundle> = { + resourceType: 'Bundle', + type: 'collection', + entry: provenanceResponse.data.map((provenance) => ({ resource: provenance })), + }; + const formInitialParams = prepareFormInitialParams({ ...props, provenance: lastProvenance, + provenanceBundle: provenanceBundle, }); const onSubmit = async (formData: QuestionnaireResponseFormData) =>