Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new SSMM operational analytics markdown query page to report per-doctor OP consultation volume for yesterday, split into new vs. revisit consultations, including a total row.
Changes:
- Introduces a new query doc: “Doctor-wise OP Count - SSMM”.
- Implements SQL to classify visits as new/revisit per (patient, doctor) pair and aggregates counts per doctor plus a Total row.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+71
to
+73
|
|
||
|
|
||
| ````` |
| FROM emr_tokenbooking tb | ||
| JOIN emr_tokenslot ts ON tb.token_slot_id = ts.id | ||
| JOIN emr_chargeitem ci ON tb.charge_item_id = ci.id | ||
| JOIN emr_chargeitemdefinition cd ON ci.charge_item_definition_id = cd.id |
Comment on lines
+46
to
+49
| COUNT(*) FILTER (WHERE visit_num > 1) AS revisit | ||
| FROM visits_ordered | ||
| WHERE start_datetime::date = CURRENT_DATE - INTERVAL '1 day' | ||
| GROUP BY doctor_name |
Comment on lines
+23
to
+30
| WITH visits_ordered AS ( | ||
| SELECT | ||
| tb.id AS booking_id, | ||
| ci.patient_id, | ||
| TRIM(COALESCE(u.prefix || ' ', '') || u.first_name || ' ' || COALESCE(u.last_name, '')) AS doctor_name, | ||
| ts.start_datetime, | ||
| ROW_NUMBER() OVER (PARTITION BY ci.patient_id, ci.performer_actor_id ORDER BY ts.start_datetime) AS visit_num | ||
| FROM emr_tokenbooking tb |
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.
https://data-public.ssmmhospital.com/question/369-doctorwise-op-count