Skip to content

Commit 5b1a9e6

Browse files
committed
Add documentation for JIC box Tag Issued Patients report
1 parent cd1d68c commit 5b1a9e6

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
# JIC box Tag Issued Patients
3+
4+
> Patients tagged with the JIC box tag, including ADM identifier, zone, and deceased status
5+
6+
## Purpose
7+
8+
Lists patients at Arike who carry the **JIC** box tag (`tag_id = 68`) along with their ADM identifier, contact details, deceased status, and zone.
9+
10+
---
11+
12+
## Query
13+
14+
```sql
15+
SELECT
16+
emr_patient.name,
17+
emr_patient.phone_number,
18+
emr_patient.year_of_birth,
19+
emr_patient.gender,
20+
pi.value AS ADM,
21+
emr_patient.created_date,
22+
CASE
23+
WHEN emr_patient.deceased_datetime IS NULL THEN 'No'
24+
ELSE 'Yes'
25+
END AS deceased,
26+
COALESCE(
27+
(SELECT et.display
28+
FROM unnest(emr_patient.instance_tags) AS tag_id
29+
LEFT JOIN emr_tagconfig et ON et.id = tag_id
30+
WHERE et.parent_id = 55),
31+
'unassigned'
32+
) AS zone
33+
FROM emr_patient
34+
LEFT JOIN emr_patientidentifier pi
35+
ON emr_patient.id = pi.patient_id
36+
AND pi.config_id = 2
37+
LEFT JOIN LATERAL unnest(emr_patient.instance_tags) AS tag_id ON TRUE
38+
WHERE tag_id = 68
39+
ORDER BY emr_patient.name ASC;
40+
```
41+
42+
## Notes
43+
44+
- Results are ordered alphabetically by patient name.
45+
46+
*Last updated: 2026-07-06*

0 commit comments

Comments
 (0)