Skip to content

Add documentation for encounters without appointments query - #138

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

Add documentation for encounters without appointments query#138
sonzsara wants to merge 2 commits into
mainfrom
ENG-805

Conversation

@sonzsara

Copy link
Copy Markdown
Contributor

No description provided.

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

Adds a new markdown query doc for identifying SSMM OP encounters created without linked appointments.

Changes:

  • Introduces Care/Encounter/encounters_without_appointments_ssmm.md documentation 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 adopt DISTINCT 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.

Comment thread Care/Encounter/encounters_without_appointments_ssmm.md
Comment thread Care/Encounter/encounters_without_appointments_ssmm.md
Comment thread Care/Encounter/encounters_without_appointments_ssmm.md

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

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-argument TRIM(...) 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 ON and selecting the earliest encounter per patient, but the query doesn’t use DISTINCT ON and 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.

Comment thread Care/Encounter/encounters_without_appointments_ssmm.md
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