|
| 1 | + |
| 2 | +# Patients Visited by Physiotherapists |
| 3 | + |
| 4 | +> Count of unique living patients who received a physiotherapist visit |
| 5 | +
|
| 6 | +## Purpose |
| 7 | + |
| 8 | +Returns the total count of patients who got a physiotherapist visit. Filterable by facility, date, and the staff member who recorded the response. |
| 9 | + |
| 10 | +## Parameters |
| 11 | + |
| 12 | +| Parameter | Type | Description | Example | |
| 13 | +|-----------|------|-------------|---------| |
| 14 | +| `facility_id` | TEXT | Filter by facility external ID (exact match on `facility_facility.external_id`) | `'facility-uuid-1234'` | |
| 15 | +| `date` | DATE / range | Metabase date filter (typically bound to `emr_questionnaireresponse.created_date`) | `'2026-07-01'` | |
| 16 | +| `staff_name` | TEXT | Filter by the full name of the staff who recorded the response (prefix + first + last) | `'Dr. Jane Smith'` | |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## Query |
| 21 | + |
| 22 | +```sql |
| 23 | +WITH nurse_responses AS ( |
| 24 | + SELECT |
| 25 | + emr_questionnaireresponse.patient_id |
| 26 | + FROM emr_questionnaireresponse |
| 27 | + JOIN emr_encounter |
| 28 | + ON emr_encounter.id = emr_questionnaireresponse.encounter_id |
| 29 | + JOIN facility_facility |
| 30 | + ON facility_facility.id = emr_encounter.facility_id |
| 31 | + JOIN emr_patient |
| 32 | + ON emr_patient.id = emr_questionnaireresponse.patient_id |
| 33 | + JOIN users_user |
| 34 | + ON users_user.id = emr_questionnaireresponse.created_by_id |
| 35 | + WHERE emr_questionnaireresponse.questionnaire_id = 265 |
| 36 | + AND emr_questionnaireresponse.status = 'completed' |
| 37 | + AND emr_questionnaireresponse.encounter_id IS NOT NULL |
| 38 | + AND emr_patient.deceased_datetime IS NULL |
| 39 | + --[[AND facility_facility.external_id::text = {{facility_id}}]] |
| 40 | + --[[AND {{date}}]] |
| 41 | + --[[AND TRIM(COALESCE(users_user.prefix || ' ', '') || users_user.first_name || ' ' || users_user.last_name, '') = {{staff_name}}]] |
| 42 | +) |
| 43 | +SELECT |
| 44 | + COUNT(patient_id) AS homecare_patient_count |
| 45 | +FROM nurse_responses; |
| 46 | +``` |
| 47 | + |
| 48 | +## Notes |
| 49 | + |
| 50 | +- **Questionnaire filter:** `questionnaire_id = 265` is the physio home-care questionnaire. Update if the questionnaire id changes. |
| 51 | +- **Completed responses only:** `status = 'completed'` |
| 52 | + |
| 53 | +*Last updated: 2026-07-15* |
0 commit comments