Conversation
amjithtitus09
requested
a balanced review from Copilot
and removed request for
Copilot
August 17, 2026 07:51
There was a problem hiding this comment.
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; | ||
| ``` | ||
|
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.