Skip to content
Alpha: see what works today →
Menu

Matcher rule

same-vaccine-group-and-day-or-exact-time-key-joined-first

Two records of one kind match when their current versions give two different vaccine codes that one version of a vaccine group table puts in one group, and one date, the same term, that is a day or a time its source wrote to the second: a year or a month is a span, and a time the version holds padded (cascade:PaddedDateTime) was written to the hour or the minute, so two of either may be two events. A record's vaccine code, a CVX code's IRI, joins a row whose code is that IRI. Each ordered pair is a row, with the version whose rows joined it; a graph that is not a version of a vaccine group table is never read for rows.

The query

PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT DISTINCT ?record ?other ?origin
WHERE {
  ?origin prov:specializationOf/cascade:tableKind cascade:VaccineGroups .
  ?record pav:hasCurrentVersion ?version .
  ?version cascade:vaccineCode ?code ; cascade:displayDate ?date .
  FILTER (DATATYPE(?date) IN (xsd:date, xsd:dateTime))
  FILTER NOT EXISTS { ?version cascade:paddedDateTime ?padded }
  GRAPH ?origin {
    ?row owl:annotatedSource ?code ; owl:annotatedProperty obo:RO_0002350 ; owl:annotatedTarget ?group .
    ?otherRow owl:annotatedTarget ?group ; owl:annotatedProperty obo:RO_0002350 ; owl:annotatedSource ?otherCode .
  }
  FILTER (!sameTerm(?code, ?otherCode))
  ?otherVersion cascade:vaccineCode ?otherCode ; cascade:displayDate ?date .
  FILTER NOT EXISTS { ?otherVersion cascade:paddedDateTime ?otherPadded }
  ?other pav:hasCurrentVersion ?otherVersion .
  ?record cascade:recordKind ?kind .
  ?other cascade:recordKind ?otherKind .
  FILTER (?record != ?other && sameTerm(?kind, ?otherKind))
}

Terms it reads

cascade:VaccineGroups · cascade:displayDate · cascade:paddedDateTime · cascade:recordKind · cascade:vaccineCode · obo:RO_0002350 · owl:annotatedProperty · owl:annotatedSource · owl:annotatedTarget · pav:hasCurrentVersion · prov:specializationOf

Rules and decision notes that name it

queries/matcher/same-vaccine-group-and-day-or-exact-time-key-joined-first.rq on GitHub ↗