diff --git a/Care/Operations/stat_booked_arike.md b/Care/Operations/stat_booked_arike.md new file mode 100644 index 0000000..24d9365 --- /dev/null +++ b/Care/Operations/stat_booked_arike.md @@ -0,0 +1,43 @@ +# STAT Booked in - Arike + +> Count of urgent STAT appointments currently booked + +## Purpose + +This query provides a count of active STAT (urgent "Right Now") appointments that are currently booked. It's useful for monitoring urgent care demand and ensuring timely response to critical patient needs in the Arike program. + +## Parameters + +*This query has no parameters.* + +--- + +## Query + +```sql +SELECT COUNT(*) AS appointment_count +FROM emr_tokenbooking tb +JOIN emr_tokenslot ts + ON tb.token_slot_id = ts.id +JOIN emr_schedulableresource sr + ON ts.resource_id = sr.id +JOIN emr_tagconfig et + ON et.id = ANY(tb.tags) +WHERE tb.status = 'booked' + AND sr.facility_id = 2 + AND et.display = 'STAT - Right Now' + AND tb.deleted = FALSE + AND ts.deleted = FALSE + AND sr.deleted = FALSE; +``` + + +## Notes + +- Query is filtered to `facility_id = 2` - update this value as needed +- Only counts appointments tagged with 'STAT - Right Now' - verify this tag display value matches your setup +- Only includes bookings with status = 'booked' +- Uses ANY operator to check if 'STAT - Right Now' tag exists in the tags array +- All deleted records are excluded from the count + +*Last updated: 2026-01-09* diff --git a/Care/Operations/stat_checkedin_arike.md b/Care/Operations/stat_checkedin_arike.md new file mode 100644 index 0000000..03667af --- /dev/null +++ b/Care/Operations/stat_checkedin_arike.md @@ -0,0 +1,43 @@ +# STAT Checked In - Arike + +> Count of urgent STAT appointments that have checked in + +## Purpose + +This query provides a count of active STAT (urgent "Right Now") appointments that have checked in and are waiting to be seen. It's useful for monitoring patient flow, wait times for urgent care, and ensuring timely response to critical patient needs in the Arike program. + +## Parameters + +*This query has no parameters.* + +--- + +## Query + +```sql +SELECT COUNT(*) AS appointment_count +FROM emr_tokenbooking tb +JOIN emr_tokenslot ts + ON tb.token_slot_id = ts.id +JOIN emr_schedulableresource sr + ON ts.resource_id = sr.id +JOIN emr_tagconfig et + ON et.id = ANY(tb.tags) +WHERE tb.status = 'checked_in' + AND sr.facility_id = 2 + AND et.display = 'STAT - Right Now' + AND tb.deleted = FALSE + AND ts.deleted = FALSE + AND sr.deleted = FALSE; +``` + + +## Notes + +- Query is filtered to `facility_id = 2` - update this value as needed +- Only counts appointments tagged with 'STAT - Right Now' - verify this tag display value matches your setup +- Only includes bookings with status = 'checked_in' +- Uses ANY operator to check if 'STAT - Right Now' tag exists in the tags array +- All deleted records are excluded from the count + +*Last updated: 2026-01-09* diff --git a/Care/Operations/stat_fulfilled_arike.md b/Care/Operations/stat_fulfilled_arike.md new file mode 100644 index 0000000..6ea9a78 --- /dev/null +++ b/Care/Operations/stat_fulfilled_arike.md @@ -0,0 +1,43 @@ +# STAT Fulfilled - Arike + +> Count of urgent STAT appointments that have been fulfilled + +## Purpose + +This query provides a count of STAT (urgent "Right Now") appointments that have been fulfilled. It's useful for monitoring urgent care completion rates and tracking response to critical patient needs in the Arike program. + +## Parameters + +*This query has no parameters.* + +--- + +## Query + +```sql +SELECT COUNT(*) AS appointment_count +FROM emr_tokenbooking tb +JOIN emr_tokenslot ts + ON tb.token_slot_id = ts.id +JOIN emr_schedulableresource sr + ON ts.resource_id = sr.id +JOIN emr_tagconfig et + ON et.id = ANY(tb.tags) +WHERE tb.status = 'fulfilled' + AND sr.facility_id = 2 + AND et.display = 'STAT - Right Now' + AND tb.deleted = FALSE + AND ts.deleted = FALSE + AND sr.deleted = FALSE; +``` + + +## Notes + +- Query is filtered to `facility_id = 2` - update this value as needed +- Only counts appointments tagged with 'STAT - Right Now' - verify this tag display value matches your setup +- Only includes bookings with status = 'fulfilled' +- Uses ANY operator to check if 'STAT - Right Now' tag exists in the tags array +- All deleted records are excluded from the count + +*Last updated: 2026-01-09*