Skip to content

Add documentation for counting patients with high RBS - #142

Open
sonzsara wants to merge 2 commits into
mainfrom
ENG-884
Open

Add documentation for counting patients with high RBS#142
sonzsara wants to merge 2 commits into
mainfrom
ENG-884

Conversation

@sonzsara

Copy link
Copy Markdown
Contributor

No description provided.

@sonzsara
sonzsara requested a lite review from Copilot August 12, 2026 11:16
@amjithtitus09
amjithtitus09 requested a balanced review from Copilot and removed request for Copilot August 17, 2026 07:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Documents a SQL query for counting patients whose latest RBS exceeds 150.

Changes:

  • Adds the RBS-count query and Metabase date parameter.
  • Documents hardcoded questionnaire identifiers.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

WHERE emr_questionnaireresponse.status = 'completed'
AND emr_questionnaireresponse.questionnaire_id IN (115)
AND response_element->>'question_id' = 'b000f459-1efb-4e1b-9579-2e568f9aa510'
--[[AND {{date_filter}}]]
Comment on lines +21 to +36
WITH latest_sbp AS (
SELECT DISTINCT ON (emr_questionnaireresponse.patient_id)
emr_questionnaireresponse.patient_id AS patient_id,
(answer_element->>'value')::numeric AS systolic_bp
FROM emr_questionnaireresponse
CROSS JOIN LATERAL jsonb_array_elements(emr_questionnaireresponse.responses) AS response_element
CROSS JOIN LATERAL jsonb_array_elements(response_element->'values') AS answer_element
WHERE emr_questionnaireresponse.status = 'completed'
AND emr_questionnaireresponse.questionnaire_id IN (115)
AND response_element->>'question_id' = 'b000f459-1efb-4e1b-9579-2e568f9aa510'
--[[AND {{date_filter}}]]
ORDER BY emr_questionnaireresponse.patient_id, emr_questionnaireresponse.created_date DESC
)
SELECT COUNT(*) AS patients_with_rbs
FROM latest_sbp
WHERE latest_sbp.systolic_bp > 150;
FROM latest_sbp
WHERE latest_sbp.systolic_bp > 150;
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants