diff --git a/Care/Clinical/users_by_role_ssmm.md b/Care/Clinical/users_by_role_ssmm.md new file mode 100644 index 0000000..8072052 --- /dev/null +++ b/Care/Clinical/users_by_role_ssmm.md @@ -0,0 +1,34 @@ + +# Users by Role - SSMM + +> Lookup of users assigned to a specific facility-organization role + +## Purpose + +Returns the list of users assigned to a specific role (`emr_facilityorganizationuser.role_id`) at SSMM, along with their formatted display name (`prefix + first_name + last_name`). + +--- + +## Query + +```sql +SELECT DISTINCT + TRIM(COALESCE(u.prefix || ' ', '') || u.first_name || ' ' || u.last_name, '') AS username, + sr.name AS role_name +FROM emr_facilityorganizationuser efu +JOIN users_user u + ON efu.user_id = u.id +JOIN security_rolemodel sr + ON efu.role_id = sr.id +WHERE sr.name = 'Nurse' + AND efu.deleted = FALSE +ORDER BY username; +``` + +## Notes + +- `efu.role_id = 3` is hardcoded — change this value to look up users assigned to a different role. +- Only active (`efu.deleted = FALSE`) role assignments are included. +- Results are ordered alphabetically by `username`. + +*Last updated: 2026-06-29*