Skip to content

Commit aa57d63

Browse files
committed
Add encounters per patient documentation for Pallium
1 parent e923fc1 commit aa57d63

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
# Encounters Per Patient - Pallium
3+
4+
> Total number of encounters per patient with MRN (patient identifier)
5+
6+
## Purpose
7+
8+
Shows the total encounter count per patient at Pallium along with their MRN.
9+
10+
## Parameters
11+
12+
| Parameter | Type | Description | Example |
13+
|-----------|------|-------------|---------|
14+
| `created_date` | DATE / range | Metabase date filter (bound to `e.created_date`) | `'2026-05-25'` |
15+
| `mrn` | TEXT | Filter by patient MRN (exact match on `emr_patientidentifier.value`) | `'PAL-1023'` |
16+
17+
---
18+
19+
## Query
20+
21+
```sql
22+
SELECT
23+
p.name AS patient_name,
24+
pi.value AS mrn,
25+
COUNT(e.id) AS total_encounters
26+
FROM emr_encounter e
27+
JOIN emr_patient p
28+
ON e.patient_id = p.id
29+
LEFT JOIN emr_patientidentifier pi
30+
ON p.id = pi.patient_id
31+
AND pi.config_id = 4
32+
WHERE e.status NOT IN ('cancelled','entered_in_error')
33+
--[[AND {{created_date}}]]
34+
--[[AND pi.value = {{mrn}}]]
35+
GROUP BY p.id, p.name, pi.value
36+
ORDER BY total_encounters DESC, p.name;
37+
```
38+
39+
## Notes
40+
41+
- **Metabase filters:**
42+
- `[[AND {{created_date}}]]` is a field filter — bind it to `e.created_date` in the Metabase variable settings.
43+
- `[[AND pi.value = {{mrn}}]]` is an exact-match text filter on the patient's MRN.
44+
- `pi.config_id = 4` selects the MRN identifier configuration for Pallium — update if the MRN config id differs in another environment.
45+
- Encounters with status `cancelled` or `entered_in_error` are excluded.
46+
47+
*Last updated: 2026-06-09*

0 commit comments

Comments
 (0)