Skip to content
Alpha: see what works today →
Menu

Matcher rule

same-code-key-joined-first

Two records of one kind match when their current versions share a code under one property: an allergen's code, or a procedure's or a condition's SNOMED CT code. Any dates are ignored. Each ordered pair is a row.

The query

PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>

SELECT DISTINCT ?record ?other
WHERE {
  ?record pav:hasCurrentVersion ?version .
  ?version ?property ?code .
  FILTER (?property IN (cascade:conditionCode, cascade:procedureCode, cascade:allergenCode) &&
                 (?property = cascade:allergenCode || STRSTARTS(STR(?code), "http://snomed.info/id/")))
  ?otherVersion ?property ?code .
  ?other pav:hasCurrentVersion ?otherVersion .
  ?record cascade:recordKind ?kind .
  ?other cascade:recordKind ?otherKind .
  FILTER (?record != ?other && sameTerm(?kind, ?otherKind))
}

Terms it reads

cascade:allergenCode · cascade:conditionCode · cascade:procedureCode · cascade:recordKind · pav:hasCurrentVersion

Rules and decision notes that name it

queries/matcher/same-code-key-joined-first.rq on GitHub ↗