Skip to content

Commit

Permalink
Add ability to display documents based on communicationRequest subject
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlipovka committed Nov 25, 2024
1 parent 07c744b commit ac762a9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions resources/seeds/Search/subject-id-or-communication-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: subject-id-or-communication-request
where: |-
{{table}}.id IN
(
SELECT t.id from
(
SELECT qr.id from questionnaireresponse as qr
WHERE resource#>>'{subject,id}' = {{param}}
OR
resource#>>'{subject,id}' IN
(
SELECT id from communicationrequest
WHERE resource#>>'{subject,id}'={{param}}
)
) as t
)
format: "?"
resource:
id: QuestionnaireResponse
resourceType: Entity
id: QuestionnaireResponse.subject-id-or-communication-request
resourceType: Search
2 changes: 1 addition & 1 deletion src/containers/DocumentsList/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function usePatientDocuments(patient: Patient, encounter?: Reference, con
}
}
const qrResponse = await getFHIRResources<QuestionnaireResponse>('QuestionnaireResponse', {
subject: patient.id,
'subject-id-or-communication-request': patient.id,
questionnaire: questionnaires.join(','),
encounter: encounter ? parseFHIRReference(encounter).id : undefined,
_sort: '-authored',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function usePatientDocumentDetails(patientId: string) {
const mappedResponse = mapSuccess(
await getFHIRResources<QuestionnaireResponse | Encounter>('QuestionnaireResponse', {
id: qrId,
subject: patientId,
'subject-id-or-communication-request': patientId,
_include: ['QuestionnaireResponse:encounter:Encounter'],
}),
(bundle) => ({
Expand Down

0 comments on commit ac762a9

Please sign in to comment.