Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new markdown query doc for identifying SSMM OP encounters created without linked appointments.
Changes:
- Introduces
Care/Encounter/encounters_without_appointments_ssmm.mddocumentation page. - Documents purpose, parameters, and a SQL query for “encounters without appointments”.
Comments suppressed due to low confidence (1)
Care/Encounter/encounters_without_appointments_ssmm.md:42
- This note references
DISTINCT ON, but the query (as written in this PR) doesn’t use it; the note should match the actual SQL. If you adoptDISTINCT ON (e.patient_id) ... ORDER BY e.patient_id, e.created_date, clarify that it selects the earliest encounter per patient.
- Results are effectively ordered by patient (via `DISTINCT ON`), then earliest encounter date within each patient.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (5)
Care/Encounter/encounters_without_appointments_ssmm.md:8
- There’s an extra space before the period, and “op” is inconsistent with other Encounter docs that use “out-patient (OP)”. Tightening this sentence improves readability.
Identifies op (`encounter_class = 'amb'`) encounters at SSMM that were created **without** a linked appointment (`appointment_id IS NULL`) .
Care/Encounter/encounters_without_appointments_ssmm.md:14
- The date filter is commented out in the SQL, so describing it as “required” is misleading. Update the parameter description to reflect that it’s optional (or remove the “required” wording).
| `date` | DATE / range | Metabase date filter (required, bound to `e.created_date`) | `'2026-07-01'` |
Care/Encounter/encounters_without_appointments_ssmm.md:25
TRIM(expr, '')is not valid PostgreSQL syntax (it’s a MySQL-style signature). Other SSMM Encounter queries in this repo use the 1-argumentTRIM(...)form; also COALESCE both name parts to handle the LEFT JOIN case.
TRIM(COALESCE(u.first_name, '') || ' ' || u.last_name, '') AS created_by
Care/Encounter/encounters_without_appointments_ssmm.md:36
- Other SSMM Encounter queries consistently filter out soft-deleted encounters (
e.deleted = FALSE). Without it, deleted encounters can appear in results unexpectedly.
WHERE e.encounter_class = 'amb'
AND e.appointment_id IS NULL
--[[AND {{date}}]]
Care/Encounter/encounters_without_appointments_ssmm.md:42
- The note references
DISTINCT ONand selecting the earliest encounter per patient, but the query doesn’t useDISTINCT ONand will return all matching encounters. Update the note to match the actual query behavior (or change the SQL to implement the per-patient earliest-row logic).
- Results are effectively ordered by patient (via `DISTINCT ON`), then earliest encounter date within each patient.
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.