Skip to content

Commit ec092ab

Browse files
authored
Merge pull request #62 from projkov/update-readme
Add SQL snippet for retrieving patient demographics and responses
2 parents 2716524 + 51e6f56 commit ec092ab

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
type: sql
2+
command: |
3+
SELECT
4+
patient.resource#>>'{name,0,given,0}' AS given,
5+
patient.resource#>>'{name,0,family}' AS family,
6+
patient.resource#>>'{gender}' AS gender,
7+
patient.resource#>>'{birthDate}' AS birthdate,
8+
(
9+
SELECT t->>'value'
10+
FROM jsonb_array_elements(patient.resource->'telecom') AS t
11+
WHERE t->>'system' = 'email'
12+
LIMIT 1
13+
) AS email,
14+
(
15+
SELECT t->>'value'
16+
FROM jsonb_array_elements(patient.resource->'telecom') AS t
17+
WHERE t->>'system' = 'phone'
18+
LIMIT 1
19+
) AS phone,
20+
(
21+
SELECT qr.resource
22+
FROM questionnaireresponse qr
23+
WHERE qr.resource->'subject'->>'id' = patient.id
24+
AND qr.resource->>'questionnaire' = 'patient-informed-consent'
25+
LIMIT 1
26+
) AS informed_consent,
27+
(
28+
SELECT qr.resource
29+
FROM questionnaireresponse qr
30+
WHERE qr.resource->'subject'->>'id' = patient.id
31+
AND qr.resource->>'questionnaire' = 'authorization-for-release-of-medical-images'
32+
LIMIT 1
33+
) AS auth_medical_images,
34+
(
35+
SELECT qr.resource
36+
FROM questionnaireresponse qr
37+
WHERE qr.resource->'subject'->>'id' = patient.id
38+
AND qr.resource->>'questionnaire' = 'breast-cancer-study-survey'
39+
LIMIT 1
40+
) AS breast_cancer_survey
41+
FROM patient
42+
id: patients-demographic-and-questionnaire-responses
43+
resourceType: ui_snippet

0 commit comments

Comments
 (0)