-
Notifications
You must be signed in to change notification settings - Fork 1
Add Nursing Care Report with Patient Tags documentation #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sonzsara
wants to merge
1
commit into
main
Choose a base branch
from
ENG-665
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
Care/Clinical/nursing_care_report_with_patient_tags_arike.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
|
|
||
| # Nursing Care Report with Patient Tags | ||
|
|
||
| > Nursing care questionnaire responses with patient tags for zone and place-of-care | ||
|
|
||
| ## Purpose | ||
|
|
||
| Lists nursing-care questionnaire responses (`questionnaire_id = 17`) alongside patient identity (name, phone, gender, ADM identifier) and two patient tags | ||
|
|
||
| ## Parameters | ||
|
|
||
| | Parameter | Type | Description | Example | | ||
| |-----------|------|-------------|---------| | ||
| | `visit_date` | DATE / range | Metabase date filter (typically bound to `emr_questionnaireresponse.created_date`) | `'2026-06-01'` | | ||
| | `patient_name` | TEXT | Metabase text filter (typically bound to `emr_patient.name`) | `'John Doe'` | | ||
| | `zone_filter` | TEXT | Filter by resolved zone tag display (exact match) | `'Zone A'` | | ||
| | `place_of_care` | TEXT | Filter by resolved place-of-care tag display (exact match) | `'Home'` | | ||
|
|
||
| --- | ||
|
|
||
| ## Query | ||
|
|
||
| ```sql | ||
| WITH forms AS ( | ||
| SELECT | ||
| emr_questionnaire.title AS form_name, | ||
| emr_patient.name AS patient_name, | ||
| emr_patient.phone_number, | ||
| emr_patient.gender, | ||
| emr_patientidentifier.value AS adm, | ||
| COALESCE( | ||
| (SELECT emr_tagconfig.display | ||
| FROM unnest(emr_patient.instance_tags) AS tag_id | ||
| JOIN emr_tagconfig ON emr_tagconfig.id = tag_id | ||
| WHERE emr_tagconfig.parent_id = 55 | ||
| LIMIT 1), | ||
| 'unassigned' | ||
| ) AS zone, | ||
| COALESCE( | ||
| (SELECT emr_tagconfig.display | ||
| FROM unnest(emr_patient.instance_tags) AS tag_id | ||
| JOIN emr_tagconfig ON emr_tagconfig.id = tag_id | ||
| WHERE emr_tagconfig.parent_id = 71 | ||
| LIMIT 1), | ||
|
sonzsara marked this conversation as resolved.
|
||
| 'unassigned' | ||
| ) AS place_of_care, | ||
| emr_questionnaireresponse.created_date AS date | ||
| FROM emr_questionnaireresponse | ||
| JOIN emr_questionnaire | ||
| ON emr_questionnaireresponse.questionnaire_id = emr_questionnaire.id | ||
| JOIN emr_patient | ||
| ON emr_questionnaireresponse.patient_id = emr_patient.id | ||
| LEFT JOIN emr_patientidentifier | ||
| ON emr_patient.id = emr_patientidentifier.patient_id | ||
| AND emr_patientidentifier.config_id = 2 | ||
| WHERE emr_questionnaire.id = 17 | ||
| --[[AND {{visit_date}}]] | ||
| --[[AND {{patient_name}}]] | ||
|
sonzsara marked this conversation as resolved.
|
||
| ) | ||
| SELECT * | ||
| FROM forms | ||
| WHERE 1=1 | ||
| --[[AND zone = {{zone_filter}}]] | ||
| --[[AND place_of_care = {{place_of_care}}]] | ||
| ORDER BY patient_name; | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| - **Hardcoded IDs:** | ||
| - `emr_questionnaire.id = 17` — the nursing-care questionnaire at Arike. Update if the questionnaire id changes. | ||
| - `emr_patientidentifier.config_id = 2` — the ADM identifier configuration at Arike. | ||
| - `parent_id = 55` — parent tag for **zone**. | ||
| - `parent_id = 71` — parent tag for **place of care**. | ||
| Update any of these if the underlying configuration changes. | ||
| - **Metabase filters:** | ||
| - `[[AND {{visit_date}}]]` — field filter, bind to `emr_questionnaireresponse.created_date`. | ||
| - `[[AND {{patient_name}}]]` — text filter, bind to `emr_patient.name`. | ||
|
sonzsara marked this conversation as resolved.
|
||
| - `[[AND zone = {{zone_filter}}]]` and `[[AND place_of_care = {{place_of_care}}]]` — exact-match filters applied on the resolved tag columns | ||
| - Results are ordered alphabetically by patient name. | ||
|
|
||
| *Last updated: 2026-07-07* | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.