Skip to content

Add Doctor-wise OP Count report with new vs. revisit consultations#101

Open
sonzsara wants to merge 1 commit into
mainfrom
ENG-321
Open

Add Doctor-wise OP Count report with new vs. revisit consultations#101
sonzsara wants to merge 1 commit into
mainfrom
ENG-321

Conversation

@sonzsara
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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
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