Skip to content
Alpha: see what works today →
Menu

Matcher rule

same-one-to-one-conversion-key-joined-first

Two records of one kind match when one version of a code conversion table converts an ICD-10-CM code of one's current version to a different ICD-10-CM code of the other's, either way round, by a dct:isReplacedBy row whose cardinality is 1:1. A split (1:n), a merge (n:1) and an n:n row match none of the codes they name, and neither does a row of the earlier form, skos:exactMatch with no cardinality. Each ordered pair is a row, with the version whose rows joined it; a graph that is not a version of a code conversion table is never read for rows.

The query

PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX sssom: <https://w3id.org/sssom/>

SELECT DISTINCT ?record ?other ?origin
WHERE {
  ?origin prov:specializationOf/cascade:tableKind cascade:CodeConversions .
  ?record pav:hasCurrentVersion ?version .
  ?version cascade:conditionCode ?code .
  GRAPH ?origin {
    ?row owl:annotatedSource|owl:annotatedTarget ?code ;
      owl:annotatedProperty dct:isReplacedBy ;
      sssom:mapping_cardinality "1:1" ;
      owl:annotatedSource|owl:annotatedTarget ?otherCode .
  }
  FILTER (!sameTerm(?code, ?otherCode) && STRSTARTS(STR(?code), "https://ns.cascadeprotocol.org/codes/icd10cm/") && STRSTARTS(STR(?otherCode), "https://ns.cascadeprotocol.org/codes/icd10cm/"))
  ?otherVersion cascade:conditionCode ?otherCode .
  ?other pav:hasCurrentVersion ?otherVersion .
  ?record cascade:recordKind ?kind .
  ?other cascade:recordKind ?otherKind .
  FILTER (?record != ?other && sameTerm(?kind, ?otherKind))
}

Terms it reads

cascade:CodeConversions · cascade:conditionCode · cascade:recordKind · dct:isReplacedBy · owl:annotatedProperty · owl:annotatedSource · owl:annotatedTarget · pav:hasCurrentVersion · prov:specializationOf · sssom:mapping_cardinality

Rules and decision notes that name it

queries/matcher/same-one-to-one-conversion-key-joined-first.rq on GitHub ↗