withClause

A join-style inclusion clause that restricts the primary query to rows for which at least one row from the secondary source satisfies the such that condition. Equivalent to a semi-join.

Examples

Semi-join on encounter/condition overlap

from [Encounter: "Inpatient Encounter"] E
  with [Condition: "Diabetes Mellitus"] C
    such that C.onset during E.period

Semi-join filtering by medication start date

from [Encounter] E
  with [MedicationRequest] M
    such that M.authoredOn during E.period
      and M.status = 'active'
Railroad Diagram
100%
with aliasedQuerySource such that expression

scroll to zoom · drag to pan · click green rules or blue tokens to navigate

EBNF

withClause
  : 'with' aliasedQuerySource 'such that' expression
  ;

Used In