How a view is built
The pod's own files hold only what arrived and what was decided: records, their revisions and versions, the documents they came from, and judgments. Everything an app shows is worked out from those by queries that run in a fixed order. Each is a CONSTRUCT: it reads the store and adds statements to it, and the next one can read them.
Together the statements they add are the derived state. It is never written into the pod. A store that loads the pod
runs the queries again and keeps their statements as a graph of its own, urn:cascade:derived:everyday; the GraphDB
loader loads it the same way, so every question can read it.
One step, the lens, decides which judgments count. It is the only step that can be swapped; this site is built with the everyday lens, and the other lens is shown beside it. Under each step is what it added to this pod: each term, and how many statements.
Reading what arrived 6
records
The first table is the one place that says which types are records and, for each kind, the word for it and whether its status comes only from documents; the tables after it give, by kind, the properties that hold a version's name and date. A thing of one of those types the pod holds a revision or a version of becomes a cascade:Record, and every version of one gets cascade:displayName and cascade:displayDate, so later steps read any record alike. A medication's date is its start of use, else the day its prescription was written, and a dispense's the time it was handed over, else the time it was prepared.
The query: queries/derivations/records.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT {
?record a cascade:Record ; cascade:recordKind ?kind ; cascade:statusOnlyFromDocuments ?statusOnlyFromDocuments .
?version cascade:displayName ?name ; cascade:displayDate ?date .
}
WHERE {
{
VALUES (?type ?kind ?statusOnlyFromDocuments) {
(cascade:AllergyOrIntolerance "Allergy" true)
(cascade:ProblemOrDiagnosis "Condition" false)
(cascade:Vaccination "Immunization" false)
(cascade:MedicalProcedure "Procedure" false)
(cascade:PrescribedOrReportedMedication "Medication" false)
(cascade:LaboratoryTestResult "Lab result" false)
(cascade:GeneticVariantFinding "Variant" false)
(cascade:VariantInterpretation "Variant interpretation" false)
(cascade:DiagnosticReport "Report" false)
(cascade:ClinicalNoteOrDocument "Note or document" false)
(cascade:MedicationDispense "Medication dispense" false)
}
?record a ?type .
FILTER (EXISTS { [] cascade:revisionOf ?record } || EXISTS { [] prov:specializationOf ?record })
} UNION {
VALUES (?type ?nameProperty) {
(cascade:AllergyOrIntolerance cascade:allergenName)
(cascade:ProblemOrDiagnosis cascade:conditionName)
(cascade:Vaccination cascade:vaccineName)
(cascade:MedicalProcedure cascade:procedureName)
(cascade:PrescribedOrReportedMedication cascade:drugName)
(cascade:LaboratoryTestResult cascade:testName)
(cascade:GeneticVariantFinding cascade:hgvsCodingDnaExpression)
(cascade:DiagnosticReport cascade:reportName)
(cascade:ClinicalNoteOrDocument cascade:noteOrDocumentTypeName)
(cascade:MedicationDispense cascade:drugName)
}
?record a ?type .
?version prov:specializationOf ?record ; ?nameProperty ?name .
} UNION {
VALUES (?type ?dateProperty) {
(cascade:ProblemOrDiagnosis cascade:onsetDate)
(cascade:Vaccination cascade:vaccinationOccurrenceTime)
(cascade:MedicalProcedure cascade:procedureDate)
(cascade:PrescribedOrReportedMedication cascade:medicationUseStartDate)
(cascade:LaboratoryTestResult cascade:resultClinicallyRelevantTime)
(cascade:VariantInterpretation cascade:variantInterpretationDate)
(cascade:DiagnosticReport cascade:reportEffectiveTime)
(cascade:ClinicalNoteOrDocument cascade:noteOrDocumentDate)
(cascade:MedicationDispense cascade:dispenseHandedOverTime)
}
?record a ?type .
?version prov:specializationOf ?record ; ?dateProperty ?date .
} UNION {
VALUES (?type ?dateProperty ?fallbackDateProperty) {
(cascade:PrescribedOrReportedMedication cascade:medicationUseStartDate cascade:prescriptionWrittenDate)
(cascade:MedicationDispense cascade:dispenseHandedOverTime cascade:dispensePreparedTime)
}
?record a ?type .
?version prov:specializationOf ?record ; ?fallbackDateProperty ?date .
FILTER NOT EXISTS { ?version ?dateProperty ?firstDate }
}
}
The terms it uses: cascade:Record, cascade:recordKind, cascade:statusOnlyFromDocuments, cascade:displayName, cascade:displayDate, cascade:AllergyOrIntolerance, cascade:ProblemOrDiagnosis, cascade:Vaccination, cascade:MedicalProcedure, cascade:PrescribedOrReportedMedication, cascade:LaboratoryTestResult, cascade:GeneticVariantFinding, cascade:VariantInterpretation, cascade:DiagnosticReport, cascade:ClinicalNoteOrDocument, cascade:MedicationDispense, cascade:revisionOf, prov:specializationOf, cascade:allergenName, cascade:conditionName, cascade:vaccineName, cascade:procedureName, cascade:drugName, cascade:testName, cascade:hgvsCodingDnaExpression, cascade:reportName, cascade:noteOrDocumentTypeName, cascade:onsetDate, cascade:vaccinationOccurrenceTime, cascade:procedureDate, cascade:medicationUseStartDate, cascade:resultClinicallyRelevantTime, cascade:variantInterpretationDate, cascade:reportEffectiveTime, cascade:noteOrDocumentDate, cascade:dispenseHandedOverTime, cascade:prescriptionWrittenDate, cascade:dispensePreparedTime.
revision-judgments
The judgments the ladder reads before the lens: a Before or an Erroneous over revisions is a person's, and stands while no activity invalidates it and no judgment that stands replaces it, as every lens counts a person's judgment. The ladder runs before the lens because a lens counts a matcher's Same by its members' current versions (M7). A Before places the member it names earlier before its other member: the ladder removes the earlier of two revisions of one record, and the lead passes over the earlier of two members' current revisions. A Before between two revisions of one record is also said apart, so that the ladder looks for a cycle among that record's revisions alone. An Erroneous removes each revision it names. A ClockDiscounted over an act leaves every revision the act generated ranked as carrying no cascade:observedAsOf.
It added nothing to this pod.
The query: queries/derivations/revision-judgments.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT {
?earlier cascade:judgedBefore ?later . ?earlierOfTheRecord cascade:judgedBeforeRevisionOfSameRecord ?later .
?wrong cascade:revisionJudgedErroneousBy ?judgment . ?discounted cascade:observationTimeDiscountedBy ?judgment .
}
WHERE {
{ ?judgment cascade:verdict cascade:Before ; cascade:earlierMember ?earlier ; prov:hadMember ?later ;
prov:wasAttributedTo/a prov:Person .
FILTER (?later != ?earlier)
OPTIONAL { ?earlier cascade:revisionOf ?record . ?later cascade:revisionOf ?record BIND (?earlier AS ?earlierOfTheRecord) }
FILTER NOT EXISTS {
?replacing dct:replaces ?judgment
OPTIONAL { ?undoing prov:invalidated ?replacing }
FILTER (!BOUND(?undoing))
}
FILTER NOT EXISTS { ?retraction prov:invalidated ?judgment } }
UNION
{ ?judgment cascade:verdict cascade:Erroneous ; prov:hadMember ?wrong ; prov:wasAttributedTo/a prov:Person .
?wrong a cascade:Revision .
FILTER NOT EXISTS {
?replacing dct:replaces ?judgment
OPTIONAL { ?undoing prov:invalidated ?replacing }
FILTER (!BOUND(?undoing))
}
FILTER NOT EXISTS { ?retraction prov:invalidated ?judgment } }
UNION
{ ?judgment cascade:verdict cascade:ClockDiscounted ; prov:hadMember ?act ; prov:wasAttributedTo/a prov:Person .
?discounted prov:wasGeneratedBy ?act ; a cascade:Revision .
FILTER NOT EXISTS {
?replacing dct:replaces ?judgment
OPTIONAL { ?undoing prov:invalidated ?replacing }
FILTER (!BOUND(?undoing))
}
FILTER NOT EXISTS { ?retraction prov:invalidated ?judgment } }
}
The terms it uses: cascade:judgedBefore, cascade:judgedBeforeRevisionOfSameRecord, cascade:revisionJudgedErroneousBy, cascade:observationTimeDiscountedBy, cascade:verdict, cascade:Before, cascade:earlierMember, prov:hadMember, prov:wasAttributedTo, prov:Person, cascade:revisionOf, dct:replaces, prov:invalidated, cascade:Erroneous, cascade:Revision, cascade:ClockDiscounted, prov:wasGeneratedBy.
current-revision-candidates
The ladder's first three steps over a record's revisions. A revision an Erroneous that stands names is out. So is one a Before that stands places before another revision of the record that no such Erroneous names, unless that other is placed before it in turn, directly or through the record's other revisions: Befores that form a cycle remove nothing. Of what is left, the revisions at the latest source change time stay, and so does every one carrying none: the first instant xsd:dateTime can write stands for none, so a record none of whose revisions carries one keeps them all.
| Term | Statements added |
|---|---|
current revision candidate cascade:currentRevisionCandidate term | 27 |
The query: queries/derivations/current-revision-candidates.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
CONSTRUCT { ?record cascade:currentRevisionCandidate ?r }
WHERE {
{ SELECT ?record (MAX(COALESCE(?changed0, "0001-01-01T00:00:00Z"^^xsd:dateTime)) AS ?latest)
WHERE {
?r0 cascade:revisionOf ?record .
MINUS { ?r0 cascade:revisionJudgedErroneousBy ?wrong0 }
MINUS {
?r0 cascade:judgedBeforeRevisionOfSameRecord ?later0 .
FILTER NOT EXISTS { ?later0 cascade:revisionJudgedErroneousBy ?laterWrong0 }
FILTER NOT EXISTS { ?later0 cascade:judgedBeforeRevisionOfSameRecord+ ?r0 }
}
OPTIONAL { ?r0 pav:lastUpdateOn ?changed0 }
}
GROUP BY ?record }
?r cascade:revisionOf ?record .
MINUS { ?r cascade:revisionJudgedErroneousBy ?wrong }
MINUS {
?r cascade:judgedBeforeRevisionOfSameRecord ?later .
FILTER NOT EXISTS { ?later cascade:revisionJudgedErroneousBy ?laterWrong }
FILTER NOT EXISTS { ?later cascade:judgedBeforeRevisionOfSameRecord+ ?r }
}
OPTIONAL { ?r pav:lastUpdateOn ?changed }
FILTER (!BOUND(?changed) || ?changed = ?latest)
}
The terms it uses: cascade:currentRevisionCandidate, cascade:revisionOf, cascade:revisionJudgedErroneousBy, cascade:judgedBeforeRevisionOfSameRecord, pav:lastUpdateOn.
candidates-ordered-by-ancestry
Of two candidates for a record's current revision from two live pulls of one source, the one whose act's snapshot descends from the other's is the later, whatever their clocks say. A live pull is a document retrieved on a date (pav:retrievedOn) that answers as of no other instant (cascade:answeredAsOf), as an export does; two pulls are of one source when both name one transmitter, the same agent, or neither names one. Ancestry is asked once for each two acts, and the pairs of documents and of candidates are joined to the acts it orders.
It added nothing to this pod.
The query: queries/derivations/candidates-ordered-by-ancestry.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?later cascade:laterInAncestryThan ?earlier }
WHERE {
{ SELECT ?earlierAct ?laterAct
WHERE {
{ SELECT DISTINCT ?earlierAct ?laterAct
WHERE {
{ SELECT DISTINCT ?earlierAct ?laterAct ?earlierDocument1 ?laterDocument1
WHERE {
?record1 cascade:currentRevisionCandidate ?earlier1 , ?later1 .
?earlier1 prov:wasGeneratedBy ?earlierAct ; prov:wasDerivedFrom ?earlierDocument1 .
?later1 prov:wasGeneratedBy ?laterAct ; prov:wasDerivedFrom ?laterDocument1 .
FILTER (?laterAct != ?earlierAct)
?earlierDocument1 pav:retrievedOn ?earlierRetrieved1 .
?laterDocument1 pav:retrievedOn ?laterRetrieved1 .
FILTER NOT EXISTS { ?earlierDocument1 cascade:answeredAsOf ?earlierAnswered1 }
FILTER NOT EXISTS { ?laterDocument1 cascade:answeredAsOf ?laterAnswered1 }
} }
OPTIONAL { ?earlierDocument1 prov:wasGeneratedBy/prov:qualifiedAssociation ?earlierVia1 .
?earlierVia1 prov:hadRole ?earlierRole1 ; prov:agent ?earlierTransmitter1
FILTER (?earlierRole1 = cascade:TransmitterRole) }
OPTIONAL { ?laterDocument1 prov:wasGeneratedBy/prov:qualifiedAssociation ?laterVia1 .
?laterVia1 prov:hadRole ?laterRole1 ; prov:agent ?laterTransmitter1
FILTER (?laterRole1 = cascade:TransmitterRole) }
FILTER (COALESCE(?earlierTransmitter1 = ?laterTransmitter1,
!BOUND(?earlierTransmitter1) && !BOUND(?laterTransmitter1)))
} }
?earlierSnapshot a cascade:Snapshot ; prov:wasGeneratedBy ?earlierAct .
?laterSnapshot a cascade:Snapshot ; prov:wasGeneratedBy ?laterAct .
FILTER EXISTS { ?laterSnapshot (cascade:firstParentSnapshot|cascade:mergedParentSnapshot)+ ?earlierSnapshot }
} }
{ SELECT DISTINCT ?earlierAct ?laterAct ?earlierDocument ?laterDocument
WHERE {
{ SELECT DISTINCT ?earlierAct ?laterAct ?earlierDocument ?laterDocument
WHERE {
?record0 cascade:currentRevisionCandidate ?earlier0 , ?later0 .
?earlier0 prov:wasGeneratedBy ?earlierAct ; prov:wasDerivedFrom ?earlierDocument .
?later0 prov:wasGeneratedBy ?laterAct ; prov:wasDerivedFrom ?laterDocument .
FILTER (?laterAct != ?earlierAct)
?earlierDocument pav:retrievedOn ?earlierRetrieved0 .
?laterDocument pav:retrievedOn ?laterRetrieved0 .
FILTER NOT EXISTS { ?earlierDocument cascade:answeredAsOf ?earlierAnswered0 }
FILTER NOT EXISTS { ?laterDocument cascade:answeredAsOf ?laterAnswered0 }
} }
OPTIONAL { ?earlierDocument prov:wasGeneratedBy/prov:qualifiedAssociation ?earlierVia0 .
?earlierVia0 prov:hadRole ?earlierRole0 ; prov:agent ?earlierTransmitter0
FILTER (?earlierRole0 = cascade:TransmitterRole) }
OPTIONAL { ?laterDocument prov:wasGeneratedBy/prov:qualifiedAssociation ?laterVia0 .
?laterVia0 prov:hadRole ?laterRole0 ; prov:agent ?laterTransmitter0
FILTER (?laterRole0 = cascade:TransmitterRole) }
FILTER (COALESCE(?earlierTransmitter0 = ?laterTransmitter0,
!BOUND(?earlierTransmitter0) && !BOUND(?laterTransmitter0)))
} }
?record cascade:currentRevisionCandidate ?earlier , ?later .
?earlier prov:wasGeneratedBy ?earlierAct ; prov:wasDerivedFrom ?earlierDocument .
?later prov:wasGeneratedBy ?laterAct ; prov:wasDerivedFrom ?laterDocument .
}
The terms it uses: cascade:laterInAncestryThan, cascade:currentRevisionCandidate, prov:wasGeneratedBy, prov:wasDerivedFrom, pav:retrievedOn, cascade:answeredAsOf, prov:hadRole, prov:agent, cascade:TransmitterRole, cascade:Snapshot, cascade:firstParentSnapshot, cascade:mergedParentSnapshot.
current-revisions
The ladder's last two steps pick a record's current revision from its candidates, and its version is the record's current version. A candidate a later one in ancestry follows is out; of what is left, the greatest cascade:observedAsOf, beside every candidate a ClockDiscounted leaves carrying none, then the least IRI, which is arbitrary and only there so that two writers agree. Every later step reads a record through these.
| Term | Statements added |
|---|---|
Has current version pav:hasCurrentVersion term | 27 |
current revision cascade:currentRevision term | 27 |
The query: queries/derivations/current-revisions.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
CONSTRUCT { ?record cascade:currentRevision ?r ; pav:hasCurrentVersion ?v }
WHERE {
{ SELECT ?record (MIN(STR(?c)) AS ?first)
WHERE {
{ SELECT ?record (MAX(?seen0) AS ?latestSeen)
WHERE {
?record cascade:currentRevisionCandidate ?c0 .
?c0 cascade:observedAsOf ?observed0 .
MINUS { ?anyLater0 cascade:laterInAncestryThan ?c0 }
OPTIONAL { ?c0 cascade:observationTimeDiscountedBy ?discount0 }
BIND (IF(BOUND(?discount0), "0001-01-01T00:00:00Z"^^xsd:dateTime, ?observed0) AS ?seen0)
}
GROUP BY ?record }
?record cascade:currentRevisionCandidate ?c .
?c cascade:observedAsOf ?seen .
MINUS { ?anyLater cascade:laterInAncestryThan ?c }
OPTIONAL { ?c cascade:observationTimeDiscountedBy ?discount }
FILTER (?seen = ?latestSeen || BOUND(?discount))
}
GROUP BY ?record }
?r cascade:revisionOf ?record ; cascade:version ?v .
FILTER (STR(?r) = ?first)
}
The terms it uses: cascade:currentRevision, pav:hasCurrentVersion, cascade:currentRevisionCandidate, cascade:observedAsOf, cascade:laterInAncestryThan, cascade:observationTimeDiscountedBy, cascade:revisionOf, cascade:version.
current-reference-versions
A reference table's current version is the one no newer version revises.
| Term | Statements added |
|---|---|
Has current version pav:hasCurrentVersion term | 2 |
The query: queries/derivations/current-reference-versions.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?series pav:hasCurrentVersion ?v }
WHERE {
?series a cascade:ReferenceSeries .
?v prov:specializationOf ?series .
FILTER NOT EXISTS { ?newer prov:wasRevisionOf ?v }
}
The terms it uses: pav:hasCurrentVersion, cascade:ReferenceSeries, prov:specializationOf, prov:wasRevisionOf.
Which judgments count 1
everyday
The lens decides which judgments count, and is the one step of the build that can be swapped. This one counts a person's judgment not retracted, nor replaced by a judgment not itself retracted. A matcher judgment counts on the same terms when the Cascade matcher made it, every reference version it used is current or has a current version whose rows join its members as its rule reads them (M7), and the current version of a rule list has a row for its rule with the query hash of that rule's row in a version it is asserted under by an assertion no retraction invalidates: its rule runs now the query it was asserted with, and no release declared that assertion wrong. A retracted judgment replaces nothing.
This step is the lens.
| Term | Statements added |
|---|---|
counts under lens cascade:countsUnderLens term | 18 |
The query: queries/lenses/everyday.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?j cascade:countsUnderLens true }
WHERE {
{ ?j a cascade:Judgment ; prov:wasAttributedTo/a prov:Person .
FILTER NOT EXISTS {
?replacing dct:replaces ?j
OPTIONAL { ?undoing prov:invalidated ?replacing }
FILTER (!BOUND(?undoing))
}
FILTER NOT EXISTS { ?retraction prov:invalidated ?j } }
UNION
{ { SELECT DISTINCT ?j
WHERE {
{ SELECT DISTINCT ?rule ?hash
WHERE { ?ruleList pav:hasCurrentVersion ?current .
?currentRow cascade:rowOfRuleListVersion ?current ; cascade:matcherRule ?rule ; cascade:queryHash ?hash } }
?assertedRow cascade:matcherRule ?rule ; cascade:queryHash ?hash ; cascade:rowOfRuleListVersion ?asserted .
?assertion cascade:assertedUnderRuleListVersion ?asserted ; cascade:assertedJudgment ?j .
FILTER NOT EXISTS { ?assertionRetraction prov:invalidated ?assertion }
?j cascade:matcherRule ?rule .
} }
?j a cascade:Judgment ; prov:wasAttributedTo cascade:CascadeMatcher .
FILTER NOT EXISTS {
?replacing dct:replaces ?j
OPTIONAL { ?undoing prov:invalidated ?replacing }
FILTER (!BOUND(?undoing))
}
FILTER NOT EXISTS { ?retraction prov:invalidated ?j }
MINUS {
?j prov:wasDerivedFrom ?input .
?input prov:specializationOf ?series .
?series a cascade:ReferenceSeries ; pav:hasCurrentVersion ?now .
FILTER (?now != ?input)
FILTER NOT EXISTS { ?j cascade:membersJoinedByCurrentTableVersion ?now }
} }
}
The terms it uses: cascade:countsUnderLens, cascade:Judgment, prov:wasAttributedTo, prov:Person, dct:replaces, prov:invalidated, pav:hasCurrentVersion, cascade:rowOfRuleListVersion, cascade:matcherRule, cascade:queryHash, cascade:assertedUnderRuleListVersion, cascade:assertedJudgment, cascade:CascadeMatcher, prov:wasDerivedFrom, prov:specializationOf, cascade:ReferenceSeries, cascade:membersJoinedByCurrentTableVersion.
export
A stricter lens, for records sent elsewhere: a person's judgment counts unless retracted or replaced, and a matcher judgment only when the Cascade matcher made it resting on the same code, or code and date, or code and period, made with current reference versions, and asserted under a version whose row for its rule has the query hash of the current rule list version's row for it, by an assertion no retraction invalidates. A retracted judgment replaces nothing.
The other lens. Had the pod been built with it, it would have added this instead.
| Term | Statements added |
|---|---|
counts under lens cascade:countsUnderLens term | 17 |
The query: queries/lenses/export.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?j cascade:countsUnderLens true }
WHERE {
{ ?j a cascade:Judgment ; prov:wasAttributedTo/a prov:Person .
FILTER NOT EXISTS {
?replacing dct:replaces ?j
OPTIONAL { ?undoing prov:invalidated ?replacing }
FILTER (!BOUND(?undoing))
}
FILTER NOT EXISTS { ?retraction prov:invalidated ?j } }
UNION
{ { SELECT DISTINCT ?j
WHERE {
{ SELECT DISTINCT ?rule ?hash
WHERE { ?ruleList pav:hasCurrentVersion ?current .
?currentRow cascade:rowOfRuleListVersion ?current ; cascade:matcherRule ?rule ; cascade:queryHash ?hash } }
?assertedRow cascade:matcherRule ?rule ; cascade:queryHash ?hash ; cascade:rowOfRuleListVersion ?asserted .
?assertion cascade:assertedUnderRuleListVersion ?asserted ; cascade:assertedJudgment ?j .
FILTER NOT EXISTS { ?assertionRetraction prov:invalidated ?assertion }
?j cascade:matcherRule ?rule .
} }
?j a cascade:Judgment ; prov:wasAttributedTo cascade:CascadeMatcher ; cascade:justification ?why .
FILTER (?why IN (cascade:SameCode, cascade:SameCodeAndDate, cascade:SameCodeAndPeriod))
FILTER NOT EXISTS {
?replacing dct:replaces ?j
OPTIONAL { ?undoing prov:invalidated ?replacing }
FILTER (!BOUND(?undoing))
}
FILTER NOT EXISTS { ?retraction prov:invalidated ?j }
MINUS {
?j prov:wasDerivedFrom ?input .
?input prov:specializationOf ?series .
?series a cascade:ReferenceSeries ; pav:hasCurrentVersion ?now .
FILTER (?now != ?input)
} }
}
The terms it uses: cascade:countsUnderLens, cascade:Judgment, prov:wasAttributedTo, prov:Person, dct:replaces, prov:invalidated, pav:hasCurrentVersion, cascade:rowOfRuleListVersion, cascade:matcherRule, cascade:queryHash, cascade:assertedUnderRuleListVersion, cascade:assertedJudgment, cascade:CascadeMatcher, cascade:justification, cascade:SameCode, cascade:SameCodeAndDate, cascade:SameCodeAndPeriod, prov:wasDerivedFrom, prov:specializationOf, cascade:ReferenceSeries.
Which records are the same 4
different-pairs
Two records named together by a counting Different judgment are currently different, unless no person made the Different and a person's counting Same names both: a person outranks every machine, so the pair stays joined.
| Term | Statements added |
|---|---|
currently different cascade:currentlyDifferent term | 4 |
The query: queries/derivations/different-pairs.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?a cascade:currentlyDifferent ?b }
WHERE {
?d cascade:countsUnderLens true ; cascade:verdict cascade:Different ; prov:hadMember ?a , ?b .
FILTER (?a != ?b)
BIND (EXISTS { ?d prov:wasAttributedTo/a prov:Person } AS ?byAPerson)
MINUS {
VALUES ?byAPerson { false }
?s cascade:countsUnderLens true ; cascade:verdict cascade:Same ; prov:wasAttributedTo/a prov:Person ;
prov:hadMember ?a , ?b .
}
}
The terms it uses: cascade:currentlyDifferent, cascade:countsUnderLens, cascade:verdict, cascade:Different, prov:hadMember, prov:wasAttributedTo, prov:Person, cascade:Same.
same-pairs
Two records named together by a counting Same judgment are currently the same, unless they are also currently different: a Different judgment wins. A Same none of whose members are currently different joins each member with its least, in code point order of the IRI, both ways: a star, 2(n - 1) pairs for n members, which makes the entries every pair would. A Same two of whose members are currently different joins every other pair of its members, so a Different pair is still joined through a third member.
| Term | Statements added |
|---|---|
currently same cascade:currentlySame term | 20 |
The query: queries/derivations/same-pairs.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?a cascade:currentlySame ?b }
WHERE {
{ { SELECT ?j (IRI(MIN(STR(?m))) AS ?least)
WHERE { ?j cascade:countsUnderLens true ; cascade:verdict cascade:Same ; prov:hadMember ?m }
GROUP BY ?j }
MINUS { ?x cascade:currentlyDifferent ?y . ?j prov:hadMember ?x , ?y }
?j prov:hadMember ?member .
FILTER (?member != ?least)
VALUES ?toLeast { true false }
BIND (IF(?toLeast, ?member, ?least) AS ?a)
BIND (IF(?toLeast, ?least, ?member) AS ?b) }
UNION
{ { SELECT DISTINCT ?j
WHERE {
?x cascade:currentlyDifferent ?y .
?j cascade:countsUnderLens true ; cascade:verdict cascade:Same ; prov:hadMember ?x , ?y } }
?j prov:hadMember ?a , ?b .
FILTER (?a != ?b)
FILTER NOT EXISTS { ?a cascade:currentlyDifferent ?b } }
}
The terms it uses: cascade:currentlySame, cascade:countsUnderLens, cascade:verdict, cascade:Same, prov:hadMember, cascade:currentlyDifferent.
same-records-under-same-servers
Two servers that are currently the same, directly or through other servers, have one record wherever each has a record of one type and id. A server's records are those with a revision derived from a document it served (cascade:serverBaseUrl); a record's type and id are what its cascade:sourceUrl holds after that base URL and a /, and its cascade:sourceRecordId is that id. The two are joined both ways, as a counting Same joins them, and only within one organization: not when the documents their revisions come from name custodians that are neither one organization nor currently the same, and not when a counting Different separates them.
It added nothing to this pod.
The query: queries/derivations/same-records-under-same-servers.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?a cascade:currentlySame ?b }
WHERE {
?one a cascade:Server ; cascade:serverBaseUrl ?oneBase ; cascade:currentlySame+ ?two .
?two a cascade:Server ; cascade:serverBaseUrl ?twoBase .
?aDocument cascade:serverBaseUrl ?oneBase .
?aRevision prov:wasDerivedFrom ?aDocument ; cascade:revisionOf ?a .
?a cascade:sourceRecordId ?id ; cascade:sourceUrl ?aUrl .
?b cascade:sourceRecordId ?id ; cascade:sourceUrl ?bUrl .
?bRevision cascade:revisionOf ?b ; prov:wasDerivedFrom ?bDocument .
?bDocument cascade:serverBaseUrl ?twoBase .
FILTER (?one != ?two && STRAFTER(STR(?aUrl), CONCAT(?oneBase, "/")) = STRAFTER(STR(?bUrl), CONCAT(?twoBase, "/")))
FILTER NOT EXISTS { ?a cascade:currentlyDifferent ?b }
MINUS {
{ SELECT ?aServer WHERE { ?aServer a cascade:Server ; cascade:currentlySame ?bServer . ?bServer a cascade:Server }
LIMIT 1 }
?a cascade:sourceRecordId ?id ; ^cascade:revisionOf/prov:wasDerivedFrom/prov:wasGeneratedBy/prov:qualifiedAssociation ?aCustody .
?aCustody prov:hadRole cascade:CustodianRole ; prov:agent ?aOrganization .
?b cascade:sourceRecordId ?id ; ^cascade:revisionOf/prov:wasDerivedFrom/prov:wasGeneratedBy/prov:qualifiedAssociation ?bCustody .
?bCustody prov:hadRole cascade:CustodianRole ; prov:agent ?bOrganization .
FILTER (?aOrganization != ?bOrganization)
FILTER NOT EXISTS { ?aOrganization cascade:currentlySame+ ?bOrganization }
}
}
The terms it uses: cascade:currentlySame, cascade:Server, cascade:serverBaseUrl, prov:wasDerivedFrom, cascade:revisionOf, cascade:sourceRecordId, cascade:sourceUrl, cascade:currentlyDifferent, prov:hadRole, cascade:CustodianRole, prov:agent.
same-organizations
Two organization records named together by a counting Same judgment are currently the same organization, unless they are also currently different. Only a judgment joins two organizations here: two organizations pulled from servers a counting Same joins are one record to currentlySame (same-records-under-same-servers.rq), but not one organization, since a server serving many organizations says nothing of whose records are whose.
It added nothing to this pod.
The query: queries/derivations/same-organizations.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?a cascade:currentlySameOrganization ?b }
WHERE {
?same cascade:countsUnderLens true ; cascade:verdict cascade:Same ; prov:hadMember ?a , ?b .
FILTER (?a != ?b)
?a a cascade:Organization .
?b a cascade:Organization .
FILTER NOT EXISTS { ?a cascade:currentlyDifferent ?b }
}
The terms it uses: cascade:currentlySameOrganization, cascade:countsUnderLens, cascade:verdict, cascade:Same, prov:hadMember, cascade:Organization, cascade:currentlyDifferent.
What no view shows 5
excluded-at-source
A record whose current version its source marks entered in error is left out of every view, and so is an allergy it marks refuted: by its verification status, or, for an immunization, a lab result, a procedure, a variant, a variant interpretation, a report, a note or document or a medication dispense, which state entered in error as their status, by its workflow status, and a note or document also by the status of its content. A condition it marks refuted is an entry, ruled out. The table is the one place that lists those statuses, each with the reason it gives.
| Term | Statements added |
|---|---|
left out for cascade:leftOutFor term | 1 |
left out reason cascade:leftOutReason term | 1 |
The query: queries/derivations/excluded-at-source.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
CONSTRUCT { ?record cascade:leftOutFor ?leftOut . ?leftOut cascade:leftOutReason ?reason }
WHERE {
VALUES (?property ?status ?kind ?reason) {
(cascade:verificationStatus "entered-in-error" UNDEF cascade:EnteredInErrorAtSource)
(cascade:verificationStatus "refuted" "Allergy" cascade:RefutedAtSource)
(cascade:workflowStatus "entered-in-error" "Immunization" cascade:EnteredInErrorAtSource)
(cascade:workflowStatus "entered-in-error" "Lab result" cascade:EnteredInErrorAtSource)
(cascade:workflowStatus "entered-in-error" "Procedure" cascade:EnteredInErrorAtSource)
(cascade:workflowStatus "entered-in-error" "Variant" cascade:EnteredInErrorAtSource)
(cascade:workflowStatus "entered-in-error" "Variant interpretation" cascade:EnteredInErrorAtSource)
(cascade:workflowStatus "entered-in-error" "Report" cascade:EnteredInErrorAtSource)
(cascade:workflowStatus "entered-in-error" "Note or document" cascade:EnteredInErrorAtSource)
(cascade:noteOrDocumentContentStatus "entered-in-error" "Note or document" cascade:EnteredInErrorAtSource)
(cascade:workflowStatus "entered-in-error" "Medication dispense" cascade:EnteredInErrorAtSource)
}
?record cascade:recordKind ?recordKind ; pav:hasCurrentVersion ?version .
?version ?property ?status .
FILTER (!BOUND(?kind) || ?kind = ?recordKind)
BIND (IRI(CONCAT("urn:cascade:left-out:", SHA256(CONCAT(STR(?record), " ", STR(?reason))))) AS ?leftOut)
}
The terms it uses: cascade:leftOutFor, cascade:leftOutReason, cascade:verificationStatus, cascade:workflowStatus, cascade:noteOrDocumentContentStatus, cascade:recordKind, pav:hasCurrentVersion.
excluded-by-judgment
A record named by a counting Erroneous judgment is left out of every view, because of that judgment; so is a record every revision of which an Erroneous that stands names, since it has no current state, because of each of those judgments.
| Term | Statements added |
|---|---|
left out because of cascade:leftOutBecauseOf term | 1 |
left out for cascade:leftOutFor term | 1 |
left out reason cascade:leftOutReason term | 1 |
The query: queries/derivations/excluded-by-judgment.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?record cascade:leftOutFor ?leftOut . ?leftOut cascade:leftOutReason cascade:JudgedErroneous ; cascade:leftOutBecauseOf ?e }
WHERE {
{ ?e cascade:countsUnderLens true ; cascade:verdict cascade:Erroneous ; prov:hadMember ?record .
?record pav:hasCurrentVersion ?v .
BIND (IRI(CONCAT("urn:cascade:left-out:",
SHA256(CONCAT(STR(?record), " ", STR(cascade:JudgedErroneous), " ", STR(?e))))) AS ?leftOut) }
UNION
{ ?revision cascade:revisionJudgedErroneousBy ?e ; cascade:revisionOf ?record .
FILTER NOT EXISTS { ?record cascade:currentRevision [] }
BIND (IRI(CONCAT("urn:cascade:left-out:",
SHA256(CONCAT(STR(?record), " ", STR(cascade:JudgedErroneous), " ", STR(?e))))) AS ?leftOut) }
}
The terms it uses: cascade:leftOutFor, cascade:leftOutReason, cascade:leftOutBecauseOf, cascade:countsUnderLens, cascade:verdict, cascade:Erroneous, prov:hadMember, pav:hasCurrentVersion, cascade:revisionJudgedErroneousBy, cascade:revisionOf, cascade:currentRevision.
excluded-with-their-activity
Every record whose current revision an import brought is left out of every view when a counting Erroneous judgment names that import, because of that judgment.
It added nothing to this pod.
The query: queries/derivations/excluded-with-their-activity.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?record cascade:leftOutFor ?leftOut . ?leftOut cascade:leftOutReason cascade:ImportJudgedErroneous ; cascade:leftOutBecauseOf ?e }
WHERE {
?e cascade:countsUnderLens true ; cascade:verdict cascade:Erroneous ; prov:hadMember ?act .
?r prov:wasGeneratedBy ?act .
?record cascade:currentRevision ?r .
BIND (IRI(CONCAT("urn:cascade:left-out:",
SHA256(CONCAT(STR(?record), " ", STR(cascade:ImportJudgedErroneous), " ", STR(?e))))) AS ?leftOut)
}
The terms it uses: cascade:leftOutFor, cascade:leftOutReason, cascade:leftOutBecauseOf, cascade:countsUnderLens, cascade:verdict, cascade:Erroneous, prov:hadMember, prov:wasGeneratedBy, cascade:currentRevision.
subjects
A record is about the subject when its current version names a patient profile a counting About judgment ties to them and no counting NotAbout over it for them outranks, or names the subject directly. A NotAbout outranks every About: one a person filed after it, or another person's, holds the profile back for review, and lifts nothing.
| Term | Statements added |
|---|---|
subject cascade:subject term | 23 |
The query: queries/derivations/subjects.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?record cascade:subject ?s }
WHERE {
{ ?record pav:hasCurrentVersion/cascade:patient ?profile .
?j cascade:countsUnderLens true ; cascade:verdict cascade:About ; prov:hadMember ?profile ; cascade:subject ?s .
MINUS { ?denial cascade:countsUnderLens true ; cascade:verdict cascade:NotAbout ; prov:hadMember ?profile ;
cascade:subject ?s . } }
UNION
{ ?record pav:hasCurrentVersion/cascade:patient ?s .
?s a cascade:Subject . }
}
The terms it uses: cascade:subject, pav:hasCurrentVersion, cascade:countsUnderLens, cascade:verdict, cascade:About, prov:hadMember, cascade:NotAbout, cascade:Subject.
excluded-for-their-patient
A record about no one known to be the subject is left out of every view, and the reason rests on the patient profile its current version names: a person's About stands against a counting NotAbout over the profile, which holds it back for review; or a counting NotAbout names the profile; or no counting About ties the profile to the subject. A person's About stands against a NotAbout for its subject unless a counting NotAbout of the same maker was made after it. A record whose current version names no patient, or that has no current version, is left out for that.
| Term | Statements added |
|---|---|
left out because of cascade:leftOutBecauseOf term | 3 |
left out for cascade:leftOutFor term | 4 |
left out reason cascade:leftOutReason term | 4 |
The query: queries/derivations/excluded-for-their-patient.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?record cascade:leftOutFor ?leftOut . ?leftOut cascade:leftOutReason ?reason ; cascade:leftOutBecauseOf ?profile }
WHERE {
{ { SELECT DISTINCT ?profile ?reason
WHERE {
?denial cascade:countsUnderLens true ; cascade:verdict cascade:NotAbout ; prov:hadMember ?profile .
OPTIONAL {
?opposed cascade:countsUnderLens true ; cascade:verdict ?opposedVerdict ; prov:hadMember ?profile ;
cascade:subject ?s .
?against cascade:countsUnderLens true ; cascade:verdict ?againstVerdict ; prov:hadMember ?profile ;
cascade:subject ?s ; prov:wasAttributedTo ?by ; prov:generatedAtTime ?made .
?by a ?byKind .
MINUS {
?outranking cascade:countsUnderLens true ; cascade:verdict ?outrankingVerdict ; prov:hadMember ?profile ;
cascade:subject ?s ; prov:wasAttributedTo ?by ; prov:generatedAtTime ?later .
?against cascade:verdict ?againstAgainVerdict ; prov:hadMember ?profile ; cascade:subject ?s ;
prov:wasAttributedTo ?by ; prov:generatedAtTime ?made .
FILTER (?later > ?made && ?outrankingVerdict = cascade:NotAbout && ?againstAgainVerdict = cascade:About)
}
FILTER (?opposedVerdict = cascade:NotAbout && ?againstVerdict = cascade:About && ?byKind = prov:Person)
}
BIND (IF(BOUND(?against), cascade:PatientProfileJudgedBothAboutAndNotAbout, cascade:PatientProfileJudgedNotAbout)
AS ?reason)
} }
?record pav:hasCurrentVersion/cascade:patient ?profile ; a cascade:Record .
FILTER NOT EXISTS { ?record cascade:subject [] }
BIND (IRI(CONCAT("urn:cascade:left-out:", SHA256(CONCAT(STR(?record), " ", STR(?reason), " ", STR(?profile))))) AS ?leftOut) }
UNION
{ ?record a cascade:Record .
FILTER NOT EXISTS { ?record cascade:subject [] }
OPTIONAL { ?record pav:hasCurrentVersion/cascade:patient ?profile }
MINUS { ?denial cascade:countsUnderLens true ; cascade:verdict cascade:NotAbout ; prov:hadMember ?profile }
BIND (IF(BOUND(?profile), cascade:PatientProfileNotClaimed, cascade:NoPatient) AS ?reason)
BIND (IRI(CONCAT("urn:cascade:left-out:",
SHA256(CONCAT(STR(?record), " ", STR(?reason), COALESCE(CONCAT(" ", STR(?profile)), ""))))) AS ?leftOut) }
}
The terms it uses: cascade:leftOutFor, cascade:leftOutReason, cascade:leftOutBecauseOf, cascade:countsUnderLens, cascade:verdict, cascade:NotAbout, prov:hadMember, cascade:subject, prov:wasAttributedTo, prov:generatedAtTime, cascade:About, prov:Person, pav:hasCurrentVersion, cascade:Record.
Joining records into entries 7
entries
Records of one kind, not left out, that are currently the same, directly or through each other, make one entry. It is named from its smallest member, so the same records always make the same entry.
| Term | Statements added |
|---|---|
in entry cascade:inEntry term | 21 |
The query: queries/derivations/entries.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
CONSTRUCT { ?record cascade:inEntry ?entry }
WHERE {
{ SELECT ?record (IRI(CONCAT("urn:cascade:entry:", SHA256(MIN(STR(?m))))) AS ?entry)
WHERE {
?record cascade:recordKind ?kind ; cascade:currentlySame* ?m .
?m cascade:recordKind ?kind .
FILTER NOT EXISTS { ?record cascade:leftOutFor [] }
FILTER NOT EXISTS { ?m cascade:leftOutFor [] }
}
GROUP BY ?record }
}
The terms it uses: cascade:inEntry, cascade:recordKind, cascade:currentlySame, cascade:leftOutFor.
lead-member-candidates
The lead of an entry is chosen from its members' current revisions as a record's current revision is from its revisions. A record the person entered, whose current revision is derived from no document, leads any entry it is in, so where an entry holds one, a member derived from a document is out. Of the members left, one is out when a Before that stands places its current revision before another such member's, unless that one is placed before it in turn, directly or through others. Of what is left, the members at the latest source change time stay, and so does every one carrying none: the first instant xsd:dateTime can write stands for none.
| Term | Statements added |
|---|---|
lead member candidate cascade:leadMemberCandidate term | 11 |
The query: queries/derivations/lead-member-candidates.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
CONSTRUCT { ?entry cascade:leadMemberCandidate ?member }
WHERE {
{ SELECT ?entry (MAX(COALESCE(?changed0, "0001-01-01T00:00:00Z"^^xsd:dateTime)) AS ?latest)
WHERE {
?member0 cascade:inEntry ?entry ; cascade:currentRevision ?r0 .
MINUS {
{ SELECT DISTINCT ?entry WHERE {
?entered0 cascade:inEntry ?entry ; cascade:currentRevision ?enteredRevision0 .
FILTER NOT EXISTS { ?enteredRevision0 prov:wasDerivedFrom [] }
} }
?shadowed0 cascade:inEntry ?entry ; cascade:currentRevision ?r0 .
?r0 prov:wasDerivedFrom [] .
}
MINUS {
?r0 cascade:judgedBefore ?later0 .
?other0 cascade:inEntry ?entry ; cascade:currentRevision ?later0 .
FILTER (NOT EXISTS { ?later0 prov:wasDerivedFrom [] } || EXISTS { ?r0 prov:wasDerivedFrom [] })
FILTER NOT EXISTS { ?later0 cascade:judgedBefore+ ?r0 }
}
OPTIONAL { ?r0 pav:lastUpdateOn ?changed0 }
}
GROUP BY ?entry }
?member cascade:inEntry ?entry ; cascade:currentRevision ?r .
MINUS {
{ SELECT DISTINCT ?entry WHERE {
?entered cascade:inEntry ?entry ; cascade:currentRevision ?enteredRevision .
FILTER NOT EXISTS { ?enteredRevision prov:wasDerivedFrom [] }
} }
?shadowed cascade:inEntry ?entry ; cascade:currentRevision ?r .
?r prov:wasDerivedFrom [] .
}
MINUS {
?r cascade:judgedBefore ?later .
?other cascade:inEntry ?entry ; cascade:currentRevision ?later .
FILTER (NOT EXISTS { ?later prov:wasDerivedFrom [] } || EXISTS { ?r prov:wasDerivedFrom [] })
FILTER NOT EXISTS { ?later cascade:judgedBefore+ ?r }
}
OPTIONAL { ?r pav:lastUpdateOn ?changed }
FILTER (!BOUND(?changed) || ?changed = ?latest)
}
The terms it uses: cascade:leadMemberCandidate, cascade:inEntry, cascade:currentRevision, prov:wasDerivedFrom, cascade:judgedBefore, pav:lastUpdateOn.
lead-members
An entry's lead is the candidate whose current revision has the greatest cascade:observedAsOf, beside every candidate whose current revision a ClockDiscounted leaves carrying none, then the least IRI. The entry shows every member's fields, the lead's first.
| Term | Statements added |
|---|---|
lead member cascade:leadMember term | 11 |
The query: queries/derivations/lead-members.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
CONSTRUCT { ?entry cascade:leadMember ?lead }
WHERE {
{ SELECT ?entry (IRI(MIN(STR(?member))) AS ?lead)
WHERE {
{ SELECT ?entry (MAX(?seen0) AS ?latestSeen)
WHERE {
?entry cascade:leadMemberCandidate/cascade:currentRevision ?revision0 .
?revision0 cascade:observedAsOf ?observed0 .
OPTIONAL { ?revision0 cascade:observationTimeDiscountedBy ?discount0 }
BIND (IF(BOUND(?discount0), "0001-01-01T00:00:00Z"^^xsd:dateTime, ?observed0) AS ?seen0)
}
GROUP BY ?entry }
?entry cascade:leadMemberCandidate ?member .
?member cascade:currentRevision ?revision .
?revision cascade:observedAsOf ?seen .
OPTIONAL { ?revision cascade:observationTimeDiscountedBy ?discount }
FILTER (?seen = ?latestSeen || BOUND(?discount))
}
GROUP BY ?entry }
}
The terms it uses: cascade:leadMember, cascade:leadMemberCandidate, cascade:observedAsOf, cascade:observationTimeDiscountedBy, cascade:currentRevision.
status-sources
An entry takes its status from a member that states one, chosen as the lead is from the members' current revisions: of those at the latest source change time, with those carrying none, the greatest cascade:observedAsOf beside those a ClockDiscounted leaves carrying none, then the least IRI. A kind whose status comes only from documents, as an allergy's does, never takes it from a member the person entered. A member states a status by its clinical status or its workflow status, and also by a verification status of refuted, which rules the record out.
| Term | Statements added |
|---|---|
status from cascade:statusFrom term | 10 |
The query: queries/derivations/status-sources.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
CONSTRUCT { ?entry cascade:statusFrom ?from }
WHERE {
{ SELECT ?entry (IRI(MIN(STR(?r))) AS ?from)
WHERE {
{ SELECT ?entry ?latest (MAX(?seen1) AS ?seen)
WHERE {
{ SELECT ?entry (MAX(COALESCE(?changed2, "0001-01-01T00:00:00Z"^^xsd:dateTime)) AS ?latest)
WHERE {
?r2 cascade:inEntry ?entry ; cascade:statusOnlyFromDocuments ?documentsOnly2 ;
cascade:currentRevision ?rev2 ; pav:hasCurrentVersion ?version2 .
OPTIONAL { ?version2 cascade:clinicalStatus|cascade:workflowStatus ?stated2 }
OPTIONAL { ?version2 cascade:verificationStatus ?ruledOut2 FILTER (?ruledOut2 = "refuted") }
FILTER (BOUND(?stated2) || BOUND(?ruledOut2))
FILTER (!?documentsOnly2 || EXISTS { ?rev2 prov:wasDerivedFrom [] })
OPTIONAL { ?rev2 pav:lastUpdateOn ?changed2 }
}
GROUP BY ?entry }
?r1 cascade:inEntry ?entry ; cascade:statusOnlyFromDocuments ?documentsOnly1 ;
cascade:currentRevision ?rev1 ; pav:hasCurrentVersion ?version1 .
OPTIONAL { ?version1 cascade:clinicalStatus|cascade:workflowStatus ?stated1 }
OPTIONAL { ?version1 cascade:verificationStatus ?ruledOut1 FILTER (?ruledOut1 = "refuted") }
FILTER (BOUND(?stated1) || BOUND(?ruledOut1))
?rev1 cascade:observedAsOf ?observed1 .
OPTIONAL { ?rev1 cascade:observationTimeDiscountedBy ?discount1 }
BIND (IF(BOUND(?discount1), "0001-01-01T00:00:00Z"^^xsd:dateTime, ?observed1) AS ?seen1)
FILTER (!?documentsOnly1 || EXISTS { ?rev1 prov:wasDerivedFrom [] })
OPTIONAL { ?rev1 pav:lastUpdateOn ?changed1 }
FILTER (!BOUND(?changed1) || ?changed1 = ?latest)
}
GROUP BY ?entry ?latest }
?r cascade:inEntry ?entry ; cascade:statusOnlyFromDocuments ?documentsOnly ;
cascade:currentRevision ?rev ; pav:hasCurrentVersion ?version .
OPTIONAL { ?version cascade:clinicalStatus|cascade:workflowStatus ?stated }
OPTIONAL { ?version cascade:verificationStatus ?ruledOut FILTER (?ruledOut = "refuted") }
FILTER (BOUND(?stated) || BOUND(?ruledOut))
?rev cascade:observedAsOf ?observed .
OPTIONAL { ?rev cascade:observationTimeDiscountedBy ?discount }
FILTER (?observed = ?seen || BOUND(?discount))
FILTER (!?documentsOnly || EXISTS { ?rev prov:wasDerivedFrom [] })
OPTIONAL { ?rev pav:lastUpdateOn ?changed }
FILTER (!BOUND(?changed) || ?changed = ?latest)
}
GROUP BY ?entry }
}
The terms it uses: cascade:statusFrom, cascade:inEntry, cascade:statusOnlyFromDocuments, cascade:currentRevision, pav:hasCurrentVersion, cascade:clinicalStatus, cascade:workflowStatus, cascade:verificationStatus, prov:wasDerivedFrom, pav:lastUpdateOn, cascade:observedAsOf, cascade:observationTimeDiscountedBy.
date-sources
An entry takes its date from a member that states one, chosen as the lead is from the members' current revisions: of those at the latest source change time, with those carrying none, the greatest cascade:observedAsOf beside those a ClockDiscounted leaves carrying none, then the least IRI. A medication entry takes its start of use and the day its prescription was written each the same way, among the members that state that date, so it shows both when no one member states both. A medication entry takes its dosage text the same way, so an entry whose lead states none shows the dosage of the member chosen so. An allergy entry takes its onset date and its category the same way.
| Term | Statements added |
|---|---|
allergy category from cascade:allergyCategoryFrom term | 3 |
date from cascade:dateFrom term | 7 |
onset date from cascade:onsetDateFrom term | 6 |
The query: queries/derivations/date-sources.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
CONSTRUCT { ?entry ?pointer ?from }
WHERE {
{ SELECT ?entry ?pointer (IRI(MIN(STR(?r))) AS ?from)
WHERE {
{ SELECT ?entry ?pointer ?dateProperty ?latest (MAX(?seen1) AS ?seen)
WHERE {
{ SELECT ?entry ?pointer ?dateProperty
(MAX(COALESCE(?changed2, "0001-01-01T00:00:00Z"^^xsd:dateTime)) AS ?latest)
WHERE {
VALUES (?dateProperty ?pointer) {
(cascade:displayDate cascade:dateFrom)
(cascade:medicationUseStartDate cascade:medicationUseStartDateFrom)
(cascade:prescriptionWrittenDate cascade:prescriptionWrittenDateFrom)
(cascade:dosageInstructionText cascade:dosageFrom)
(cascade:onsetDate cascade:onsetDateFrom)
(cascade:allergyCategory cascade:allergyCategoryFrom)
}
?r2 cascade:inEntry ?entry ; cascade:currentRevision ?rev2 ; pav:hasCurrentVersion ?v2 .
?v2 ?dateProperty [] .
OPTIONAL { ?rev2 pav:lastUpdateOn ?changed2 }
}
GROUP BY ?entry ?pointer ?dateProperty }
?r1 cascade:inEntry ?entry ; cascade:currentRevision ?rev1 ; pav:hasCurrentVersion ?v1 .
?v1 ?dateProperty [] .
?rev1 cascade:observedAsOf ?observed1 .
OPTIONAL { ?rev1 cascade:observationTimeDiscountedBy ?discount1 }
BIND (IF(BOUND(?discount1), "0001-01-01T00:00:00Z"^^xsd:dateTime, ?observed1) AS ?seen1)
OPTIONAL { ?rev1 pav:lastUpdateOn ?changed1 }
FILTER (!BOUND(?changed1) || ?changed1 = ?latest)
}
GROUP BY ?entry ?pointer ?dateProperty ?latest }
?r cascade:inEntry ?entry ; cascade:currentRevision ?rev ; pav:hasCurrentVersion ?v .
?v ?dateProperty [] .
?rev cascade:observedAsOf ?observed .
OPTIONAL { ?rev cascade:observationTimeDiscountedBy ?discount }
FILTER (?observed = ?seen || BOUND(?discount))
OPTIONAL { ?rev pav:lastUpdateOn ?changed }
FILTER (!BOUND(?changed) || ?changed = ?latest)
}
GROUP BY ?entry ?pointer }
}
The terms it uses: cascade:displayDate, cascade:dateFrom, cascade:medicationUseStartDate, cascade:medicationUseStartDateFrom, cascade:prescriptionWrittenDate, cascade:prescriptionWrittenDateFrom, cascade:dosageInstructionText, cascade:dosageFrom, cascade:onsetDate, cascade:onsetDateFrom, cascade:allergyCategory, cascade:allergyCategoryFrom, cascade:inEntry, cascade:currentRevision, pav:hasCurrentVersion, pav:lastUpdateOn, cascade:observedAsOf, cascade:observationTimeDiscountedBy.
top-criticalities
An entry shows the highest criticality any member states: high over low over unable to assess. Only allergies state one.
| Term | Statements added |
|---|---|
top criticality cascade:topCriticality term | 4 |
The query: queries/derivations/top-criticalities.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
CONSTRUCT { ?entry cascade:topCriticality ?top }
WHERE {
{ SELECT ?entry (MAX(?rank) AS ?topRank)
WHERE {
?r cascade:inEntry ?entry ;
pav:hasCurrentVersion/cascade:allergyCriticality ?c .
BIND (IF(?c = "high", 2, IF(?c = "low", 1, 0)) AS ?rank)
}
GROUP BY ?entry }
BIND (IF(?topRank = 2, "high", IF(?topRank = 1, "low", "unable-to-assess")) AS ?top)
}
The terms it uses: cascade:topCriticality, cascade:inEntry, pav:hasCurrentVersion.
lapsed-sames
A matcher's judgment has lapsed when it does not count, nothing retracts it, no judgment not itself retracted replaces it, and a newer version stopped it counting: a reference version it used has a newer current one whose rows do not join its members (M7), or no current version of a rule list has a row for its rule with the query hash of that rule's row in a version it is asserted under. A matcher judgment is read by its assertions no retraction invalidates: one each of whose assertions a release retracted neither counts nor lapses, since the release declared its rule wrong. An open adopted newer tables or rules and did not file or assert it again, so the pair it joined may now be two entries.
It added nothing to this pod.
The query: queries/derivations/lapsed-sames.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT { ?j cascade:lapsed true }
WHERE {
{ ?j cascade:verdict cascade:Same ; prov:wasAttributedTo cascade:CascadeMatcher ; prov:wasDerivedFrom ?input .
?keptAssertion cascade:assertedJudgment ?j .
FILTER NOT EXISTS { ?keptRetraction prov:invalidated ?keptAssertion }
?input prov:specializationOf ?series .
?series a cascade:ReferenceSeries ; pav:hasCurrentVersion ?now .
FILTER (?now != ?input)
FILTER NOT EXISTS { ?j cascade:countsUnderLens true }
FILTER NOT EXISTS {
?replacing dct:replaces ?j
OPTIONAL { ?undoing prov:invalidated ?replacing }
FILTER (!BOUND(?undoing))
}
FILTER NOT EXISTS { ?retraction prov:invalidated ?j } }
UNION
{ ?j cascade:verdict cascade:Same ; prov:wasAttributedTo cascade:CascadeMatcher .
?keptAssertion cascade:assertedJudgment ?j .
FILTER NOT EXISTS { ?keptRetraction prov:invalidated ?keptAssertion }
FILTER NOT EXISTS { ?j cascade:countsUnderLens true }
FILTER NOT EXISTS {
?replacing dct:replaces ?j
OPTIONAL { ?undoing prov:invalidated ?replacing }
FILTER (!BOUND(?undoing))
}
FILTER NOT EXISTS { ?retraction prov:invalidated ?j }
MINUS { SELECT DISTINCT ?j
WHERE {
{ SELECT DISTINCT ?rule ?hash
WHERE { ?ruleList pav:hasCurrentVersion ?current .
?currentRow cascade:rowOfRuleListVersion ?current ; cascade:matcherRule ?rule ; cascade:queryHash ?hash } }
?assertedRow cascade:matcherRule ?rule ; cascade:queryHash ?hash ; cascade:rowOfRuleListVersion ?asserted .
?assertion cascade:assertedUnderRuleListVersion ?asserted ; cascade:assertedJudgment ?j .
FILTER NOT EXISTS { ?assertionRetraction prov:invalidated ?assertion }
?j cascade:matcherRule ?rule .
} } }
}
The terms it uses: cascade:lapsed, cascade:verdict, cascade:Same, prov:wasAttributedTo, cascade:CascadeMatcher, prov:wasDerivedFrom, cascade:assertedJudgment, prov:invalidated, prov:specializationOf, cascade:ReferenceSeries, pav:hasCurrentVersion, cascade:countsUnderLens, dct:replaces, cascade:rowOfRuleListVersion, cascade:matcherRule, cascade:queryHash, cascade:assertedUnderRuleListVersion.
Medications and notes 4
medication-lifecycles
The status of each medication record's current version, however its source wrote it, is classed by the first step of runtime rule L1 that holds, and the step is recorded; an entry has the class and step of the record it takes its status from, and one no member gives a status to is unknown at step 2. The key is the status lower-cased, each run of other characters than a-z and 0-9 made one space, trimmed. A step-2 to step-4 row holds when it equals the key, or equals it with the spaces of both removed ('d/c' is dc). A step-5 row, a fragment, holds when the compact key contains the fragment with its spaces removed (so NotActive is read as not active), and the class among those that do is the most conservative: the lowest precedence. Step 6 holds always, so every record has a class and 'unmatched' is step 6. The FHIR rows are the codes of R4's MedicationRequest.status and MedicationStatement.status (a code in both has one row), 'aborted' and 'nullified' are HL7 v3 ActStatus codes mapped by the C-CDA on FHIR ConceptMap CF-MedicationStatus 2.0.0, and the rest are cascade-knowledge's medication-status-synonym rows. A negated hold ('no longer on hold') is a reader's job, not a row's.
It added nothing to this pod.
The query: queries/derivations/medication-lifecycles.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
CONSTRUCT {
?record cascade:currentVersionStatusLifecycle ?class ; cascade:currentVersionStatusLifecycleStep ?step .
?shown cascade:statusLifecycle ?shownClass ; cascade:statusLifecycleStep ?shownStep .
}
WHERE {
{ { SELECT ?record (MIN(?score) AS ?best)
WHERE {
?record a cascade:PrescribedOrReportedMedication ; cascade:inEntry [] .
OPTIONAL { ?record pav:hasCurrentVersion/cascade:workflowStatus ?stated }
BIND (REPLACE(REPLACE(LCASE(STR(COALESCE(?stated, ""))), "[^a-z0-9]+", " "), "^ +| +$", "") AS ?key)
BIND (REPLACE(?key, " ", "") AS ?compact)
VALUES (?by ?text ?kind) {
(2 "" cascade:MedicationUnknown)
(3 "active" cascade:MedicationActive)
(3 "cancelled" cascade:MedicationStopped)
(3 "completed" cascade:MedicationStopped)
(3 "draft" cascade:MedicationUnknown)
(3 "entered in error" cascade:MedicationEnteredInError)
(3 "intended" cascade:MedicationUnknown)
(3 "not taken" cascade:MedicationStopped)
(3 "on hold" cascade:MedicationPaused)
(3 "stopped" cascade:MedicationStopped)
(3 "unknown" cascade:MedicationUnknown)
(4 "aborted" cascade:MedicationStopped)
(4 "canceled" cascade:MedicationStopped)
(4 "cont" cascade:MedicationActive)
(4 "continue" cascade:MedicationActive)
(4 "continued" cascade:MedicationActive)
(4 "continuing" cascade:MedicationActive)
(4 "current" cascade:MedicationActive)
(4 "dc" cascade:MedicationStopped)
(4 "dcd" cascade:MedicationStopped)
(4 "discontinued" cascade:MedicationStopped)
(4 "held" cascade:MedicationPaused)
(4 "hold" cascade:MedicationPaused)
(4 "inactive" cascade:MedicationStopped)
(4 "nullified" cascade:MedicationEnteredInError)
(4 "off" cascade:MedicationStopped)
(4 "on" cascade:MedicationActive)
(4 "ongoing" cascade:MedicationActive)
(4 "stop" cascade:MedicationStopped)
(4 "suspended" cascade:MedicationPaused)
(4 "taking" cascade:MedicationActive)
(5 "active" cascade:MedicationActive)
(5 "cancel" cascade:MedicationStopped)
(5 "entered in error" cascade:MedicationEnteredInError)
(5 "ceased" cascade:MedicationStopped)
(5 "completed" cascade:MedicationStopped)
(5 "continu" cascade:MedicationActive)
(5 "continued off" cascade:MedicationStopped)
(5 "current" cascade:MedicationActive)
(5 "did not start" cascade:MedicationStopped)
(5 "discontinu" cascade:MedicationStopped)
(5 "expired" cascade:MedicationStopped)
(5 "finished" cascade:MedicationStopped)
(5 "former" cascade:MedicationStopped)
(5 "historical" cascade:MedicationStopped)
(5 "history of" cascade:MedicationStopped)
(5 "hx of" cascade:MedicationStopped)
(5 "in the past" cascade:MedicationStopped)
(5 "inactive" cascade:MedicationStopped)
(5 "never started" cascade:MedicationStopped)
(5 "never taken" cascade:MedicationStopped)
(5 "non active" cascade:MedicationStopped)
(5 "no longer" cascade:MedicationStopped)
(5 "not active" cascade:MedicationStopped)
(5 "not current" cascade:MedicationStopped)
(5 "not continu" cascade:MedicationStopped)
(5 "not ongoing" cascade:MedicationStopped)
(5 "not started" cascade:MedicationStopped)
(5 "not taking" cascade:MedicationStopped)
(5 "on hold" cascade:MedicationPaused)
(5 "ongoing" cascade:MedicationActive)
(5 "past med" cascade:MedicationStopped)
(5 "presently" cascade:MedicationActive)
(5 "previously" cascade:MedicationStopped)
(5 "prior med" cascade:MedicationStopped)
(5 "started" cascade:MedicationActive)
(5 "stopped" cascade:MedicationStopped)
(5 "stop taking" cascade:MedicationStopped)
(5 "suspended" cascade:MedicationPaused)
(5 "taking" cascade:MedicationActive)
(6 "" cascade:MedicationUnknown)
}
VALUES (?kind ?precedence) {
(cascade:MedicationEnteredInError 0) (cascade:MedicationStopped 1) (cascade:MedicationPaused 2)
(cascade:MedicationUnknown 3) (cascade:MedicationActive 4)
}
FILTER (?by = 6 || IF(?by = 5, CONTAINS(?compact, REPLACE(?text, " ", "")), ?compact = REPLACE(?text, " ", "")))
BIND (?by * 10 + ?precedence AS ?score)
}
GROUP BY ?record }
BIND (xsd:integer(FLOOR(?best / 10)) AS ?step)
VALUES (?class ?held) {
(cascade:MedicationEnteredInError 0) (cascade:MedicationStopped 1) (cascade:MedicationPaused 2)
(cascade:MedicationUnknown 3) (cascade:MedicationActive 4)
}
FILTER (?held = ?best - 10 * ?step)
OPTIONAL { ?record cascade:inEntry ?shown . ?shown cascade:statusFrom ?record }
BIND (?class AS ?shownClass)
BIND (?step AS ?shownStep) }
UNION
{ ?record a cascade:PrescribedOrReportedMedication ; cascade:inEntry ?shown .
FILTER NOT EXISTS { ?shown cascade:statusFrom [] }
BIND (cascade:MedicationUnknown AS ?shownClass)
BIND (2 AS ?shownStep) }
}
The terms it uses: cascade:currentVersionStatusLifecycle, cascade:currentVersionStatusLifecycleStep, cascade:statusLifecycle, cascade:statusLifecycleStep, cascade:PrescribedOrReportedMedication, cascade:inEntry, pav:hasCurrentVersion, cascade:statusFrom.
medication-dispense-lifecycles
The status of each medication dispense's current version is classed by runtime rule L2, and an entry has the class of the record it takes its status from, or unknown when no member gives one. The key is the status lower-cased with every character other than a-z and 0-9 removed, so "in-progress", "In Progress" and "inprogress" are one key. The rows are the codes of FHIR R4's MedicationDispense.status: completed is completed; preparation, in-progress and on-hold are in progress; cancelled, declined and stopped are not completed; entered-in-error is entered-in-error; unknown, an absent status and any other are unknown. A dispense is never classed by L1's table: completed means picked up, not stopped.
It added nothing to this pod.
The query: queries/derivations/medication-dispense-lifecycles.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
CONSTRUCT {
?record cascade:currentVersionStatusLifecycle ?class .
?shown cascade:statusLifecycle ?shownClass .
}
WHERE {
{ ?record a cascade:MedicationDispense ; cascade:inEntry [] .
OPTIONAL { ?record pav:hasCurrentVersion/cascade:workflowStatus ?stated }
BIND (REPLACE(LCASE(STR(COALESCE(?stated, ""))), "[^a-z0-9]", "") AS ?key)
BIND (IF(?key = "completed", cascade:MedicationDispenseCompleted,
IF(?key IN ("preparation", "inprogress", "onhold"), cascade:MedicationDispenseInProgress,
IF(?key IN ("cancelled", "declined", "stopped"), cascade:MedicationDispenseNotCompleted,
IF(?key = "enteredinerror", cascade:MedicationDispenseEnteredInError, cascade:MedicationDispenseUnknown)))) AS ?class)
OPTIONAL { ?record cascade:inEntry ?shown . ?shown cascade:statusFrom ?record }
BIND (?class AS ?shownClass) }
UNION
{ ?record a cascade:MedicationDispense ; cascade:inEntry ?shown .
MINUS { ?shown cascade:statusFrom [] }
BIND (cascade:MedicationDispenseUnknown AS ?shownClass) }
}
The terms it uses: cascade:currentVersionStatusLifecycle, cascade:statusLifecycle, cascade:MedicationDispense, cascade:inEntry, pav:hasCurrentVersion, cascade:statusFrom.
medication-exposure-periods
Each medication record in an entry is given the exposure its own current version shows, as the eCQM library CumulativeMedicationDuration 4.1.000 gives a medication's period: from its start of use, else its one dosage's bounds' start, else the day its prescription was written, else the start of its dispensing window; to its end of use, else its start plus its supply times one plus its repeats, less a day, in whole days, else its one dosage's bounds' end (the library reads what the copy states, and a rule filters intent and status, as the library's callers do). A version with several dosages is read from its own dates and supply without any dosage's bounds, where the library's `singleton from` raises an error and gives no period. A supply under a day ends on its start. A start given only to the year or month is read as its last day and an end as its first, a time as its day, and a supply counted from the start's first day, so exposure is never overstated; a supply that is a bound, or not in a UCUM unit of time, is not read. The supply end is added twice because the two Oxigraph builds disagree on adding a computed duration to a date: pyoxigraph adds it only once bound to a variable, Oxigraph JS only written inline; rdflib adds both. With no end, the exposure is ongoing when the record's own lifecycle is active, and is neither ended nor ongoing otherwise. A record with no start, or whose end so read falls before its start, has no exposure, as the library gives no period. Copies are never collapsed here: an entry's exposure is a rule's, over every member.
It added nothing to this pod.
The query: queries/derivations/medication-exposure-periods.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
CONSTRUCT {
?record cascade:medicationExposureStart ?start ; cascade:medicationExposureEnd ?end ;
cascade:medicationExposureOngoing ?ongoing .
}
WHERE {
?record a cascade:PrescribedOrReportedMedication ; cascade:inEntry [] ; pav:hasCurrentVersion ?version .
OPTIONAL { ?version cascade:medicationUseStartDate ?useStart }
OPTIONAL { ?version cascade:structuredDosage ?startDosage . ?startDosage cascade:dosageBoundsPeriodStart ?boundsStart
FILTER NOT EXISTS { ?version cascade:structuredDosage ?otherStartDosage FILTER (!sameTerm(?otherStartDosage, ?startDosage)) } }
OPTIONAL { ?version cascade:prescriptionWrittenDate ?written }
OPTIONAL { ?version cascade:dispenseRequestValidityPeriodStart ?validFrom }
OPTIONAL { ?version cascade:medicationUseEndDate ?useEnd }
OPTIONAL { ?version cascade:structuredDosage ?endDosage . ?endDosage cascade:dosageBoundsPeriodEnd ?boundsEnd
FILTER NOT EXISTS { ?version cascade:structuredDosage ?otherEndDosage FILTER (!sameTerm(?otherEndDosage, ?endDosage)) } }
OPTIONAL { ?version cascade:expectedSupplyDuration ?supply . ?supply cascade:decimalValue ?supplyValue ; cascade:ucumUnit ?supplyUnit
FILTER NOT EXISTS { ?supply cascade:quantityComparator ?supplyComparator } }
OPTIONAL { ?version cascade:numberOfRepeatsAllowed ?repeats }
OPTIONAL { ?record cascade:currentVersionStatusLifecycle ?lifecycle }
BIND (COALESCE(?useStart, ?boundsStart, ?written, ?validFrom) AS ?from)
BIND (xsd:integer(SUBSTR(STR(?from), 1, 4)) AS ?year)
BIND (SUBSTR(STR(?from), 6, 2) AS ?month)
BIND (?year - 4 * FLOOR(?year / 4) = 0 && (?year - 100 * FLOOR(?year / 100) != 0 || ?year - 400 * FLOOR(?year / 400) = 0)
AS ?leap)
BIND (IF(BOUND(?from),
STRDT(IF(sameTerm(DATATYPE(?from), xsd:gYear), CONCAT(SUBSTR(STR(?from), 1, 4), "-12-31"),
IF(sameTerm(DATATYPE(?from), xsd:gYearMonth),
CONCAT(SUBSTR(STR(?from), 1, 7), "-",
IF(?month IN ("04", "06", "09", "11"), "30", IF(?month = "02", IF(?leap, "29", "28"), "31"))),
SUBSTR(STR(?from), 1, 10))), xsd:date),
1/0) AS ?start)
BIND (IF(BOUND(?from),
STRDT(IF(sameTerm(DATATYPE(?from), xsd:gYear), CONCAT(SUBSTR(STR(?from), 1, 4), "-01-01"),
IF(sameTerm(DATATYPE(?from), xsd:gYearMonth), CONCAT(SUBSTR(STR(?from), 1, 7), "-01"),
SUBSTR(STR(?from), 1, 10))), xsd:date),
1/0) AS ?firstDayFrom)
BIND (IF(BOUND(?supplyValue),
IF(?supplyUnit = "d", ?supplyValue, IF(?supplyUnit = "wk", ?supplyValue * 7,
IF(?supplyUnit = "mo", IF(?supplyValue = 0, 0.0, ?supplyValue * 30.4375),
IF(?supplyUnit = "a", IF(?supplyValue = 0, 0.0, ?supplyValue * 365.25),
IF(?supplyUnit = "h", ?supplyValue / 24, IF(?supplyUnit = "min", ?supplyValue / 1440,
IF(?supplyUnit = "s", ?supplyValue / 86400, 1/0))))))),
1/0) AS ?supplyDays)
BIND (IF(BOUND(?supplyDays),
xsd:integer(FLOOR(?supplyDays * (1 + IF(BOUND(?repeats), xsd:integer(STR(?repeats)), 0)))),
1/0) AS ?suppliedDays)
BIND (IF(BOUND(?suppliedDays), IF(?suppliedDays >= 1, ?suppliedDays - 1, 0), 1/0) AS ?daysAfterTheFirst)
BIND (IF(BOUND(?daysAfterTheFirst), STRDT(CONCAT("P", STR(?daysAfterTheFirst), "D"), xsd:dayTimeDuration), 1/0)
AS ?suppliedDaysAfterTheFirst)
BIND (COALESCE(?firstDayFrom + ?suppliedDaysAfterTheFirst,
IF(BOUND(?suppliedDaysAfterTheFirst),
?firstDayFrom + STRDT(CONCAT("P", STR(?daysAfterTheFirst), "D"), xsd:dayTimeDuration), 1/0)) AS ?supplyEnd)
BIND (IF(BOUND(?useEnd), ?useEnd, IF(BOUND(?supplyEnd) || !BOUND(?boundsEnd), 1/0, ?boundsEnd)) AS ?statedEnd)
BIND (IF(BOUND(?statedEnd),
STRDT(IF(sameTerm(DATATYPE(?statedEnd), xsd:gYear), CONCAT(SUBSTR(STR(?statedEnd), 1, 4), "-01-01"),
IF(sameTerm(DATATYPE(?statedEnd), xsd:gYearMonth), CONCAT(SUBSTR(STR(?statedEnd), 1, 7), "-01"),
SUBSTR(STR(?statedEnd), 1, 10))), xsd:date),
IF(BOUND(?supplyEnd), ?supplyEnd, 1/0)) AS ?end)
FILTER (BOUND(?start) && (!BOUND(?end) || ?end >= ?start))
BIND (IF(!BOUND(?end) && sameTerm(?lifecycle, cascade:MedicationActive), true, 1/0) AS ?ongoing)
}
The terms it uses: cascade:medicationExposureStart, cascade:medicationExposureEnd, cascade:medicationExposureOngoing, cascade:PrescribedOrReportedMedication, cascade:inEntry, pav:hasCurrentVersion, cascade:medicationUseStartDate, cascade:structuredDosage, cascade:dosageBoundsPeriodStart, cascade:prescriptionWrittenDate, cascade:dispenseRequestValidityPeriodStart, cascade:medicationUseEndDate, cascade:dosageBoundsPeriodEnd, cascade:expectedSupplyDuration, cascade:decimalValue, cascade:ucumUnit, cascade:quantityComparator, cascade:numberOfRepeatsAllowed, cascade:currentVersionStatusLifecycle.
narrative-texts-as-trimmed-lines
The current version of each note, document or report with a narrative text gives its text as trimmed lines: each run of spaces, tabs and carriage returns in a line one space, each line trimmed, and blank lines dropped. The matcher's note rules compare these, so the text is worked out once per version and not again in every comparison, bound or not. No other kind's text is: the matcher never reads it, and a lab result's would be worked out for every version.
It added nothing to this pod.
The query: queries/derivations/narrative-texts-as-trimmed-lines.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
CONSTRUCT { ?version cascade:narrativeTextAsTrimmedLines ?lines }
WHERE {
VALUES ?kind { "Report" "Note or document" }
?record cascade:recordKind ?kind ; pav:hasCurrentVersion ?version .
?version cascade:narrativeText ?written .
BIND (REPLACE(REPLACE(REPLACE(STR(?written), "[ \t\r]+", " "), " ?\n[ \n]*", "\n"), "^[ \n]+|[ \n]+$", "") AS ?lines)
}
The terms it uses: cascade:narrativeTextAsTrimmedLines, cascade:recordKind, pav:hasCurrentVersion, cascade:narrativeText.
What the lens changes
The same questions, asked of the pod built under each lens, side by side. A judgment that counts under one lens and not the other can join records into one entry or leave them apart, so a view can change with the lens. Compare the two counts of judgments row by row: a row one lens has and the other lacks is a kind of judgment only one counts, and the view below them shows what that does to the entries.
How many judgments count
The lens decides which judgments count, and only those shape the views. Here they are by verdict, by the reason a machine gave for it, and by whether a person or a machine made them; a retraction has no verdict. Asked under each lens, the rows show which kinds one lens counts and the other does not.
Under the everyday lens.
8 rows
The query: queries/questions/pod/How many judgments count.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT ?verdict ?justification ?madeBy (COUNT(DISTINCT ?judgment) AS ?judgments)
WHERE {
VALUES ?madeBy { prov:Person prov:SoftwareAgent }
?judgment cascade:countsUnderLens true ; prov:wasAttributedTo ?agent .
FILTER EXISTS { ?agent a ?madeBy }
OPTIONAL { ?judgment cascade:verdict ?verdict }
OPTIONAL { ?judgment cascade:justification ?justification }
}
GROUP BY ?verdict ?justification ?madeBy
ORDER BY ?verdict ?justification ?madeBy
The terms it uses: prov:Person, prov:SoftwareAgent, cascade:countsUnderLens, prov:wasAttributedTo, cascade:verdict, cascade:justification.
Run it yourself, from the runtime's root:
npm run ask -- alex-rivera "pod/How many judgments count"
Or in GraphDB, open the saved query pod/How many judgments count in the repository alex-rivera.
How many judgments count
The lens decides which judgments count, and only those shape the views. Here they are by verdict, by the reason a machine gave for it, and by whether a person or a machine made them; a retraction has no verdict. Asked under each lens, the rows show which kinds one lens counts and the other does not.
Under the export lens.
7 rows
The query: queries/questions/pod/How many judgments count.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT ?verdict ?justification ?madeBy (COUNT(DISTINCT ?judgment) AS ?judgments)
WHERE {
VALUES ?madeBy { prov:Person prov:SoftwareAgent }
?judgment cascade:countsUnderLens true ; prov:wasAttributedTo ?agent .
FILTER EXISTS { ?agent a ?madeBy }
OPTIONAL { ?judgment cascade:verdict ?verdict }
OPTIONAL { ?judgment cascade:justification ?justification }
}
GROUP BY ?verdict ?justification ?madeBy
ORDER BY ?verdict ?justification ?madeBy
The terms it uses: prov:Person, prov:SoftwareAgent, cascade:countsUnderLens, prov:wasAttributedTo, cascade:verdict, cascade:justification.
Run it yourself, from the runtime's root:
npm run ask -- alex-rivera "pod/How many judgments count" --lens export
GraphDB holds the pod under the everyday lens only.
My immunizations
Read from the view alone, as an app would, newest first by the date as written, so a year follows its months and days, with how many records each entry joins, each CVX code the entry states, a row for each, and each record it joins with the document it was derived from, when that was retrieved, and the hospitals that wrote it and that keep it, in order, separated by U+001F, its own parts by ", ". Times written with a zone are ordered by their wall time as written, not as instants: 23:00-05:00 sorts before 01:00Z the next day, though it is later.
Under the everyday lens.
| ?given | ?vaccine | ?code | ?status | ?records | ?entry | ?sources |
|---|---|---|---|---|---|---|
| 2025-10-15 | Influenza, injectable, quadrivalent, preservative free | CVX 150 | completed | 3 | Immunization entry · Influenza, injectable, quadrivalent, preservative free · 2025-10-15 | urn:uuid:7d77d9e0-5457-86f2-8d9d-827c65c11b21 from ni:///sha-256;P6xPAvjVjqgUn9UXSeFZnWc52vDAAQZnCfb5xytEMFQ, retrieved 2026-09-01T10:00:00Z, written by Meridian Health Systemurn:uuid:7e3decf1-6e9a-8e95-b982-c2e7d18be3f1 from ni:///sha-256;LVAYE3hro7inQx9KKeCT54MbpvAkcQihcjALweOmbNI, retrieved 2026-10-14T15:40:00Z, written by Larkspur Valley Healthurn:uuid:c0a85df6-e2ef-85a1-ac62-b6b454bac0c5 from ni:///sha-256;ssSLEj6SMsYuwpHfAjdgeqmUMA75jzmwX_4oimVUuyM, retrieved 2027-03-18T12:00:00Z, written by Larkspur Valley Health |
1 row
The query: queries/questions/pod/My immunizations.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?given ?vaccine ?code ?status (COUNT(?record) AS ?records) ?entry ?entryLabel ?sources
WHERE {
{ SELECT ?entry (REPLACE(GROUP_CONCAT(DISTINCT CONCAT(?sourceText, "\u001F"); separator=""), "\u001F$", "") AS ?sources)
WHERE {
{ SELECT ?entry ?sourceText
WHERE {
{ SELECT ?entry ?sourceRecord ?document ?retrievedOn
(REPLACE(GROUP_CONCAT(DISTINCT COALESCE(CONCAT(?hospital, ", "), ""); separator=""), ", $", "") AS ?hospitals)
WHERE {
{ SELECT ?entry ?sourceRecord ?document ?retrievedOn ?hospital
WHERE {
?entry a cascade:Vaccination ; cascade:entryMember ?sourceRecord .
OPTIONAL { ?sourceRecord cascade:currentRevision/prov:wasDerivedFrom ?document .
OPTIONAL { ?document pav:retrievedOn ?retrievedOn }
OPTIONAL { ?document prov:wasGeneratedBy/prov:qualifiedAssociation ?association .
?association prov:hadRole ?hospitalRole ; prov:agent ?agent
FILTER (?hospitalRole IN (cascade:AuthorRole, cascade:CustodianRole))
OPTIONAL { ?agent rdfs:label ?agentLabel }
OPTIONAL { ?agent pav:hasCurrentVersion/foaf:name ?agentName }
BIND (CONCAT(IF(?hospitalRole = cascade:AuthorRole, "written by ", "kept by "),
COALESCE(?agentLabel, ?agentName)) AS ?hospital) } }
}
ORDER BY ?entry ?sourceRecord ?document ?hospital }
}
GROUP BY ?entry ?sourceRecord ?document ?retrievedOn }
BIND (CONCAT(STR(?sourceRecord), COALESCE(CONCAT(" from ", STR(?document)), ""),
COALESCE(CONCAT(", retrieved ", STR(?retrievedOn)), ""),
IF(?hospitals = "", "", CONCAT(", ", ?hospitals))) AS ?sourceText)
}
ORDER BY ?entry ?sourceText }
}
GROUP BY ?entry }
?entry a cascade:Vaccination ; cascade:entryMember ?record .
OPTIONAL { ?entry cascade:vaccinationOccurrenceTime ?given }
OPTIONAL { ?entry cascade:vaccineName ?vaccine }
OPTIONAL { ?entry cascade:vaccineCode ?code }
OPTIONAL { ?entry cascade:workflowStatus ?status }
OPTIONAL { ?entry rdfs:label ?entryLabel }
}
GROUP BY ?entry ?given ?vaccine ?code ?status ?entryLabel ?sources
ORDER BY DESC(COALESCE(STR(?given), "")) ?vaccine ?entry ?code
The terms it uses: cascade:Vaccination, cascade:entryMember, cascade:currentRevision, pav:retrievedOn, prov:wasGeneratedBy, prov:hadRole, prov:agent, cascade:AuthorRole, cascade:CustodianRole, rdfs:label, pav:hasCurrentVersion, cascade:vaccinationOccurrenceTime, cascade:vaccineName, cascade:vaccineCode, cascade:workflowStatus.
Run it yourself, from the runtime's root:
npm run ask -- alex-rivera "pod/My immunizations"
Or in GraphDB, open the saved query pod/My immunizations in the repository alex-rivera.
My immunizations
Read from the view alone, as an app would, newest first by the date as written, so a year follows its months and days, with how many records each entry joins, each CVX code the entry states, a row for each, and each record it joins with the document it was derived from, when that was retrieved, and the hospitals that wrote it and that keep it, in order, separated by U+001F, its own parts by ", ". Times written with a zone are ordered by their wall time as written, not as instants: 23:00-05:00 sorts before 01:00Z the next day, though it is later.
Under the export lens.
| ?given | ?vaccine | ?code | ?status | ?records | ?entry | ?sources |
|---|---|---|---|---|---|---|
| 2025-10-15 | Influenza, injectable, quadrivalent, preservative free | CVX 150 | completed | 1 | Immunization entry · Influenza, injectable, quadrivalent, preservative free · 2025-10-15 | urn:uuid:c0a85df6-e2ef-85a1-ac62-b6b454bac0c5 from ni:///sha-256;ssSLEj6SMsYuwpHfAjdgeqmUMA75jzmwX_4oimVUuyM, retrieved 2027-03-18T12:00:00Z, written by Larkspur Valley Health |
| 2025-10-15 | Influenza, seasonal | CVX 141 | completed | 2 | Immunization entry · Influenza, seasonal · 2025-10-15 | urn:uuid:7d77d9e0-5457-86f2-8d9d-827c65c11b21 from ni:///sha-256;P6xPAvjVjqgUn9UXSeFZnWc52vDAAQZnCfb5xytEMFQ, retrieved 2026-09-01T10:00:00Z, written by Meridian Health Systemurn:uuid:7e3decf1-6e9a-8e95-b982-c2e7d18be3f1 from ni:///sha-256;LVAYE3hro7inQx9KKeCT54MbpvAkcQihcjALweOmbNI, retrieved 2026-10-14T15:40:00Z, written by Larkspur Valley Health |
2 rows
The query: queries/questions/pod/My immunizations.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?given ?vaccine ?code ?status (COUNT(?record) AS ?records) ?entry ?entryLabel ?sources
WHERE {
{ SELECT ?entry (REPLACE(GROUP_CONCAT(DISTINCT CONCAT(?sourceText, "\u001F"); separator=""), "\u001F$", "") AS ?sources)
WHERE {
{ SELECT ?entry ?sourceText
WHERE {
{ SELECT ?entry ?sourceRecord ?document ?retrievedOn
(REPLACE(GROUP_CONCAT(DISTINCT COALESCE(CONCAT(?hospital, ", "), ""); separator=""), ", $", "") AS ?hospitals)
WHERE {
{ SELECT ?entry ?sourceRecord ?document ?retrievedOn ?hospital
WHERE {
?entry a cascade:Vaccination ; cascade:entryMember ?sourceRecord .
OPTIONAL { ?sourceRecord cascade:currentRevision/prov:wasDerivedFrom ?document .
OPTIONAL { ?document pav:retrievedOn ?retrievedOn }
OPTIONAL { ?document prov:wasGeneratedBy/prov:qualifiedAssociation ?association .
?association prov:hadRole ?hospitalRole ; prov:agent ?agent
FILTER (?hospitalRole IN (cascade:AuthorRole, cascade:CustodianRole))
OPTIONAL { ?agent rdfs:label ?agentLabel }
OPTIONAL { ?agent pav:hasCurrentVersion/foaf:name ?agentName }
BIND (CONCAT(IF(?hospitalRole = cascade:AuthorRole, "written by ", "kept by "),
COALESCE(?agentLabel, ?agentName)) AS ?hospital) } }
}
ORDER BY ?entry ?sourceRecord ?document ?hospital }
}
GROUP BY ?entry ?sourceRecord ?document ?retrievedOn }
BIND (CONCAT(STR(?sourceRecord), COALESCE(CONCAT(" from ", STR(?document)), ""),
COALESCE(CONCAT(", retrieved ", STR(?retrievedOn)), ""),
IF(?hospitals = "", "", CONCAT(", ", ?hospitals))) AS ?sourceText)
}
ORDER BY ?entry ?sourceText }
}
GROUP BY ?entry }
?entry a cascade:Vaccination ; cascade:entryMember ?record .
OPTIONAL { ?entry cascade:vaccinationOccurrenceTime ?given }
OPTIONAL { ?entry cascade:vaccineName ?vaccine }
OPTIONAL { ?entry cascade:vaccineCode ?code }
OPTIONAL { ?entry cascade:workflowStatus ?status }
OPTIONAL { ?entry rdfs:label ?entryLabel }
}
GROUP BY ?entry ?given ?vaccine ?code ?status ?entryLabel ?sources
ORDER BY DESC(COALESCE(STR(?given), "")) ?vaccine ?entry ?code
The terms it uses: cascade:Vaccination, cascade:entryMember, cascade:currentRevision, pav:retrievedOn, prov:wasGeneratedBy, prov:hadRole, prov:agent, cascade:AuthorRole, cascade:CustodianRole, rdfs:label, pav:hasCurrentVersion, cascade:vaccinationOccurrenceTime, cascade:vaccineName, cascade:vaccineCode, cascade:workflowStatus.
Run it yourself, from the runtime's root:
npm run ask -- alex-rivera "pod/My immunizations" --lens export
GraphDB holds the pod under the everyday lens only.
The files it writes
Last, a query for each view reads the pod and the derived state and writes one file, and one more writes a name for everything. These are the pod's only files the build writes, and each says it is a view.
Each of the 6 files
allergies
Each entry takes the allergen, code, reactions and severity of its lead, its category and onset from its lead, and from the members the derivations chose for them (cascade:allergyCategoryFrom, cascade:onsetDateFrom) when its lead states none, the status of the member chosen for status, and the highest criticality any member states. Each member's current values are a node of the view of their own, named after the entry and the member, which says the member they came from. An onset its source wrote short of the second keeps the node saying so (cascade:PaddedDateTime), named after the entry or the member's values and -padded-, so the view never shows a padded time as exact.
It wrote clinical/allergies.ttl, 107 statements.
The view's page shows its entries.
The query: queries/views/allergies.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
CONSTRUCT {
?entry a cascade:AllergyOrIntolerance ;
cascade:allergenName ?allergenName ;
cascade:allergenCode ?code ;
cascade:allergyCategory ?category ;
cascade:onsetDate ?onset ;
cascade:reactionManifestationText ?reaction ;
cascade:reactionManifestationCode ?reactionCode ;
cascade:allergySeverity ?severity ;
cascade:clinicalStatus ?status ;
cascade:allergyCriticality ?criticality ;
cascade:leadMember ?lead ;
cascade:statusFrom ?statusFrom ;
cascade:entryMember ?record .
?entry cascade:memberCurrentValues ?memberValues .
?memberValues cascade:valuesOfMember ?member ;
cascade:allergenName ?memberAllergen ;
cascade:allergenCode ?memberAllergenCode ;
cascade:reactionManifestationText ?memberReaction ;
cascade:reactionManifestationCode ?memberReactionCode ;
cascade:allergySeverity ?memberSeverity ;
cascade:clinicalStatus ?memberClinicalStatus ;
cascade:allergyCriticality ?memberAllergyCriticality ;
cascade:allergyCategory ?memberCategory ;
cascade:onsetDate ?memberOnsetDate .
?entry cascade:paddedDateTime ?onsetPadded .
?onsetPadded cascade:paddedDateTimeProperty cascade:onsetDate ; cascade:timeAsWritten ?onsetWritten .
?memberValues cascade:paddedDateTime ?memberPadded .
?memberPadded cascade:paddedDateTimeProperty cascade:onsetDate ; cascade:timeAsWritten ?memberWritten .
}
WHERE {
{ ?record a cascade:AllergyOrIntolerance ; cascade:inEntry ?entry .
?entry cascade:leadMember ?lead .
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:allergenName ?allergenName }
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:allergenCode ?code }
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:allergyCategory ?leadCategory }
OPTIONAL { ?entry cascade:allergyCategoryFrom/pav:hasCurrentVersion/cascade:allergyCategory ?fromCategory }
BIND (COALESCE(?leadCategory, ?fromCategory) AS ?category)
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:onsetDate ?leadOnset }
OPTIONAL { ?entry cascade:onsetDateFrom/pav:hasCurrentVersion/cascade:onsetDate ?fromOnset }
BIND (COALESCE(?leadOnset, ?fromOnset) AS ?onset)
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:paddedDateTime ?leadPaddedAt .
?leadPaddedAt cascade:paddedDateTimeProperty ?leadPaddedProperty ; cascade:timeAsWritten ?leadWritten
FILTER (?leadPaddedProperty = cascade:onsetDate) }
OPTIONAL { ?entry cascade:onsetDateFrom/pav:hasCurrentVersion/cascade:paddedDateTime ?fromPaddedAt .
?fromPaddedAt cascade:paddedDateTimeProperty ?fromPaddedProperty ; cascade:timeAsWritten ?fromWritten
FILTER (?fromPaddedProperty = cascade:onsetDate) }
BIND (IF(BOUND(?leadOnset), ?leadWritten, ?fromWritten) AS ?onsetWritten)
BIND (IF(BOUND(?onsetWritten),IRI(CONCAT(STR(?entry), "-padded-onsetDate")), 1/0) AS ?onsetPadded)
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:reactionManifestationText ?reaction }
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:reactionManifestationCode ?reactionCode }
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:allergySeverity ?severity }
OPTIONAL { ?entry cascade:statusFrom ?statusFrom .
?statusFrom pav:hasCurrentVersion/cascade:clinicalStatus ?status }
OPTIONAL { ?entry cascade:topCriticality ?criticality } }
UNION
{ ?member a cascade:AllergyOrIntolerance ; cascade:inEntry ?entry ; pav:hasCurrentVersion ?memberVersion .
BIND (IRI(CONCAT(STR(?entry), "-", SHA256(STR(?member)))) AS ?memberValues)
OPTIONAL { ?memberVersion cascade:allergenName ?memberAllergen }
OPTIONAL { ?memberVersion cascade:allergenCode ?memberAllergenCode }
OPTIONAL { ?memberVersion cascade:reactionManifestationText ?memberReaction }
OPTIONAL { ?memberVersion cascade:reactionManifestationCode ?memberReactionCode }
OPTIONAL { ?memberVersion cascade:allergySeverity ?memberSeverity }
OPTIONAL { ?memberVersion cascade:clinicalStatus ?memberClinicalStatus }
OPTIONAL { ?memberVersion cascade:allergyCriticality ?memberAllergyCriticality }
OPTIONAL { ?memberVersion cascade:allergyCategory ?memberCategory }
OPTIONAL { ?memberVersion cascade:onsetDate ?memberOnsetDate }
OPTIONAL { ?memberVersion cascade:paddedDateTime ?memberPaddedAt .
?memberPaddedAt cascade:paddedDateTimeProperty ?memberPaddedProperty ; cascade:timeAsWritten ?memberWritten
FILTER (?memberPaddedProperty = cascade:onsetDate) }
BIND (IF(BOUND(?memberWritten), IRI(CONCAT(STR(?memberValues), "-padded-onsetDate")), 1/0) AS ?memberPadded) }
}
The terms it uses: cascade:AllergyOrIntolerance, cascade:allergenName, cascade:allergenCode, cascade:allergyCategory, cascade:onsetDate, cascade:reactionManifestationText, cascade:reactionManifestationCode, cascade:allergySeverity, cascade:clinicalStatus, cascade:allergyCriticality, cascade:leadMember, cascade:statusFrom, cascade:entryMember, cascade:memberCurrentValues, cascade:valuesOfMember, cascade:paddedDateTime, cascade:paddedDateTimeProperty, cascade:timeAsWritten, cascade:inEntry, pav:hasCurrentVersion, cascade:allergyCategoryFrom, cascade:onsetDateFrom, cascade:topCriticality.
conditions
Each entry takes the name and codes of its lead, the clinical status, verification status and abatement date of the member chosen for status, and the onset of the member chosen for the date. Each member's current values are a node of the view of their own, named after the entry and the member, which says the member they came from. A time its source wrote short of the second keeps the node saying so (cascade:PaddedDateTime), named after the entry or the member's values and -padded-, so the view never shows a padded time as exact.
It wrote clinical/conditions.ttl, 93 statements.
The view's page shows its entries.
The query: queries/views/conditions.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
CONSTRUCT {
?entry a cascade:ProblemOrDiagnosis ;
cascade:conditionName ?name ;
cascade:conditionCode ?code ;
cascade:clinicalStatus ?status ;
cascade:verificationStatus ?verification ;
cascade:abatementDate ?abatement ;
cascade:onsetDate ?onset ;
cascade:leadMember ?lead ;
cascade:statusFrom ?statusFrom ;
cascade:entryMember ?record .
?entry cascade:memberCurrentValues ?memberValues .
?memberValues cascade:valuesOfMember ?member ;
cascade:conditionName ?memberConditionName ;
cascade:conditionCode ?memberConditionCode ;
cascade:clinicalStatus ?memberClinicalStatus ;
cascade:verificationStatus ?memberVerificationStatus ;
cascade:abatementDate ?memberAbatementDate ;
cascade:onsetDate ?memberOnsetDate .
?entry cascade:paddedDateTime ?onsetPadded .
?onsetPadded cascade:paddedDateTimeProperty cascade:onsetDate ; cascade:timeAsWritten ?onsetWritten .
?entry cascade:paddedDateTime ?abatementPadded .
?abatementPadded cascade:paddedDateTimeProperty cascade:abatementDate ; cascade:timeAsWritten ?abatementWritten .
?memberValues cascade:paddedDateTime ?memberPadded .
?memberPadded cascade:paddedDateTimeProperty ?memberPaddedProperty ; cascade:timeAsWritten ?memberWritten .
}
WHERE {
{ ?record a cascade:ProblemOrDiagnosis ; cascade:inEntry ?entry .
?entry cascade:leadMember ?lead .
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:conditionName ?name }
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:conditionCode ?code }
OPTIONAL { ?entry cascade:statusFrom ?statusFrom .
?statusFrom pav:hasCurrentVersion/cascade:clinicalStatus ?status }
OPTIONAL { ?entry cascade:statusFrom/pav:hasCurrentVersion/cascade:verificationStatus ?verification }
OPTIONAL { ?entry cascade:statusFrom/pav:hasCurrentVersion/cascade:abatementDate ?abatement }
OPTIONAL { ?entry cascade:dateFrom/pav:hasCurrentVersion/cascade:onsetDate ?onset }
OPTIONAL { ?entry cascade:dateFrom/pav:hasCurrentVersion/cascade:paddedDateTime ?onsetPaddedAt .
?onsetPaddedAt cascade:paddedDateTimeProperty ?onsetPaddedProperty ; cascade:timeAsWritten ?onsetWritten
FILTER (?onsetPaddedProperty = cascade:onsetDate) }
BIND (IF(BOUND(?onsetWritten), IRI(CONCAT(STR(?entry), "-padded-onsetDate")), 1/0) AS ?onsetPadded)
OPTIONAL { ?entry cascade:statusFrom/pav:hasCurrentVersion/cascade:paddedDateTime ?abatementPaddedAt .
?abatementPaddedAt cascade:paddedDateTimeProperty ?abatementPaddedProperty ; cascade:timeAsWritten ?abatementWritten
FILTER (?abatementPaddedProperty = cascade:abatementDate) }
BIND (IF(BOUND(?abatementWritten), IRI(CONCAT(STR(?entry), "-padded-abatementDate")), 1/0) AS ?abatementPadded) }
UNION
{ ?member a cascade:ProblemOrDiagnosis ; cascade:inEntry ?entry ; pav:hasCurrentVersion ?memberVersion .
BIND (IRI(CONCAT(STR(?entry), "-", SHA256(STR(?member)))) AS ?memberValues)
OPTIONAL { ?memberVersion cascade:conditionName ?memberConditionName }
OPTIONAL { ?memberVersion cascade:conditionCode ?memberConditionCode }
OPTIONAL { ?memberVersion cascade:clinicalStatus ?memberClinicalStatus }
OPTIONAL { ?memberVersion cascade:verificationStatus ?memberVerificationStatus }
OPTIONAL { ?memberVersion cascade:abatementDate ?memberAbatementDate }
OPTIONAL { ?memberVersion cascade:onsetDate ?memberOnsetDate }
OPTIONAL { ?memberVersion cascade:paddedDateTime ?memberPaddedAt .
?memberPaddedAt cascade:paddedDateTimeProperty ?memberPaddedProperty ; cascade:timeAsWritten ?memberWritten }
BIND (IF(BOUND(?memberWritten), IRI(CONCAT(STR(?memberValues), "-padded-", STRAFTER(STR(?memberPaddedProperty), "#"))), 1/0)
AS ?memberPadded) }
}
The terms it uses: cascade:ProblemOrDiagnosis, cascade:conditionName, cascade:conditionCode, cascade:clinicalStatus, cascade:verificationStatus, cascade:abatementDate, cascade:onsetDate, cascade:leadMember, cascade:statusFrom, cascade:entryMember, cascade:memberCurrentValues, cascade:valuesOfMember, cascade:paddedDateTime, cascade:paddedDateTimeProperty, cascade:timeAsWritten, cascade:inEntry, pav:hasCurrentVersion, cascade:dateFrom.
immunizations
Each entry takes the vaccine and code of its lead, the status of the member chosen for status, and the date of the member chosen for the date. Each member's current values are a node of the view of their own, named after the entry and the member, which says the member they came from and what it was given for: each condition's record it names (cascade:reasonCondition) and each code of its reason, whether in a system the vocabulary lists (cascade:reasonCode) or in another (cascade:reasonCodeInOtherSystem). A time its source wrote short of the second keeps the node saying so (cascade:PaddedDateTime), named after the entry or the member's values and -padded-, so the view never shows a padded time as exact.
It wrote clinical/immunizations.ttl, 31 statements.
The view's page shows its entries.
The query: queries/views/immunizations.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
CONSTRUCT {
?entry a cascade:Vaccination ;
cascade:vaccineName ?name ;
cascade:vaccineCode ?code ;
cascade:workflowStatus ?status ;
cascade:vaccinationOccurrenceTime ?date ;
cascade:leadMember ?lead ;
cascade:statusFrom ?statusFrom ;
cascade:entryMember ?record .
?entry cascade:memberCurrentValues ?memberValues .
?memberValues cascade:valuesOfMember ?member ;
cascade:vaccineName ?memberVaccineName ;
cascade:vaccineCode ?memberVaccineCode ;
cascade:workflowStatus ?memberWorkflowStatus ;
cascade:vaccinationOccurrenceTime ?memberVaccinationOccurrenceTime ;
cascade:reasonCondition ?memberReasonCondition ;
cascade:reasonCode ?memberReasonCode ;
cascade:reasonCodeInOtherSystem ?memberReasonCodeInOtherSystem .
?entry cascade:paddedDateTime ?datePadded .
?datePadded cascade:paddedDateTimeProperty cascade:vaccinationOccurrenceTime ; cascade:timeAsWritten ?dateWritten .
?memberValues cascade:paddedDateTime ?memberPadded .
?memberPadded cascade:paddedDateTimeProperty ?memberPaddedProperty ; cascade:timeAsWritten ?memberWritten .
}
WHERE {
{ ?record a cascade:Vaccination ; cascade:inEntry ?entry .
?entry cascade:leadMember ?lead .
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:vaccineName ?name }
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:vaccineCode ?code }
OPTIONAL { ?entry cascade:statusFrom ?statusFrom .
?statusFrom pav:hasCurrentVersion/cascade:workflowStatus ?status }
OPTIONAL { ?entry cascade:dateFrom/pav:hasCurrentVersion/cascade:vaccinationOccurrenceTime ?date }
OPTIONAL { ?entry cascade:dateFrom/pav:hasCurrentVersion/cascade:paddedDateTime ?datePaddedAt .
?datePaddedAt cascade:paddedDateTimeProperty ?datePaddedProperty ; cascade:timeAsWritten ?dateWritten
FILTER (?datePaddedProperty = cascade:vaccinationOccurrenceTime) }
BIND (IF(BOUND(?dateWritten), IRI(CONCAT(STR(?entry), "-padded-vaccinationOccurrenceTime")), 1/0) AS ?datePadded) }
UNION
{ ?member a cascade:Vaccination ; cascade:inEntry ?entry ; pav:hasCurrentVersion ?memberVersion .
BIND (IRI(CONCAT(STR(?entry), "-", SHA256(STR(?member)))) AS ?memberValues)
OPTIONAL { ?memberVersion cascade:vaccineName ?memberVaccineName }
OPTIONAL { ?memberVersion cascade:vaccineCode ?memberVaccineCode }
OPTIONAL { ?memberVersion cascade:workflowStatus ?memberWorkflowStatus }
OPTIONAL { ?memberVersion cascade:vaccinationOccurrenceTime ?memberVaccinationOccurrenceTime }
OPTIONAL { ?memberVersion cascade:reasonCondition ?memberReasonCondition }
OPTIONAL { ?memberVersion cascade:reasonCode ?memberReasonCode }
OPTIONAL { ?memberVersion cascade:reasonCodeInOtherSystem ?memberReasonCodeInOtherSystem }
OPTIONAL { ?memberVersion cascade:paddedDateTime ?memberPaddedAt .
?memberPaddedAt cascade:paddedDateTimeProperty ?memberPaddedProperty ; cascade:timeAsWritten ?memberWritten }
BIND (IF(BOUND(?memberWritten), IRI(CONCAT(STR(?memberValues), "-padded-", STRAFTER(STR(?memberPaddedProperty), "#"))), 1/0)
AS ?memberPadded) }
}
The terms it uses: cascade:Vaccination, cascade:vaccineName, cascade:vaccineCode, cascade:workflowStatus, cascade:vaccinationOccurrenceTime, cascade:leadMember, cascade:statusFrom, cascade:entryMember, cascade:memberCurrentValues, cascade:valuesOfMember, cascade:reasonCondition, cascade:reasonCode, cascade:reasonCodeInOtherSystem, cascade:paddedDateTime, cascade:paddedDateTimeProperty, cascade:timeAsWritten, cascade:inEntry, pav:hasCurrentVersion, cascade:dateFrom.
labels
A name for every record, version, revision, document, judgment, retraction, reference version, entry and patient profile, made from what each says: its kind, its name, where it came from and when; a matcher judgment, which gives no time, by the start of its name instead. Names only help people read; nothing depends on them. An entry is labelled as the view holding it names it: a view is built before this file, and its graph holds each entry resolved against the view's address (N13), so the placeholder only the derived state holds is never labelled.
It wrote clinical/labels.ttl, 169 statements.
The query: queries/labels.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
CONSTRUCT { ?thing rdfs:label ?label }
WHERE {
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
?thing cascade:recordKind ?kind ; pav:hasCurrentVersion ?v ; cascade:currentRevision ?r .
FILTER NOT EXISTS { ?thing rdfs:label [] }
OPTIONAL { ?v cascade:displayName ?name }
OPTIONAL { ?r prov:wasDerivedFrom ?doc }
OPTIONAL { ?r prov:wasDerivedFrom/pav:retrievedFrom ?from }
OPTIONAL { ?r prov:wasDerivedFrom/prov:wasGeneratedBy/prov:qualifiedAssociation ?authorVia .
?authorVia prov:hadRole ?authorRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?authorName
FILTER (?authorRole = cascade:AuthorRole) }
OPTIONAL { ?r prov:wasDerivedFrom/prov:wasGeneratedBy/prov:qualifiedAssociation ?custodianVia .
?custodianVia prov:hadRole ?custodianRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?custodianName
FILTER (?custodianRole = cascade:CustodianRole) }
BIND (COALESCE(?authorName, ?custodianName) AS ?author)
OPTIONAL { ?r prov:generatedAtTime ?t }
BIND (CONCAT(?kind, " · ", COALESCE(?name, "no name"), " · ",
COALESCE(CONCAT(?author, " · ", REPLACE(STR(?from), "^.*/", "")),
CONCAT(?author, " · received ", SUBSTR(STR(?t), 1, 10)),
?author,
IF(BOUND(?doc), "unknown source", "own entry"))) AS ?l)
}
GROUP BY ?thing }
UNION
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
?thing prov:specializationOf/cascade:recordKind ?kind .
?revision cascade:version ?thing ; prov:generatedAtTime ?t .
FILTER NOT EXISTS { ?thing rdfs:label [] }
OPTIONAL { ?thing cascade:displayName ?name }
OPTIONAL { ?thing cascade:clinicalStatus|cascade:workflowStatus ?status }
OPTIONAL { ?thing cascade:verificationStatus ?verification }
OPTIONAL { ?thing cascade:allergyCriticality ?c }
OPTIONAL { ?thing cascade:displayDate ?date }
OPTIONAL { ?revision prov:wasDerivedFrom ?doc }
OPTIONAL { ?revision prov:wasDerivedFrom/pav:retrievedFrom ?from }
OPTIONAL { ?revision prov:wasDerivedFrom/prov:wasGeneratedBy/prov:qualifiedAssociation ?authorVia .
?authorVia prov:hadRole ?authorRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?authorName
FILTER (?authorRole = cascade:AuthorRole) }
OPTIONAL { ?revision prov:wasDerivedFrom/prov:wasGeneratedBy/prov:qualifiedAssociation ?custodianVia .
?custodianVia prov:hadRole ?custodianRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?custodianName
FILTER (?custodianRole = cascade:CustodianRole) }
BIND (COALESCE(?authorName, ?custodianName) AS ?author)
BIND (CONCAT(?kind, " version · ", COALESCE(?name, "no name"), " · ",
COALESCE(IF(?verification = "refuted", "ruled out", ?status), ?status, ?verification, CONCAT("criticality ", ?c), STR(?date), "nothing stated"), " · ",
COALESCE(REPLACE(STR(?from), "^.*/", ""), ?author, IF(BOUND(?doc), "unknown source", "own entry")),
" · first received ", SUBSTR(STR(?t), 1, 10)) AS ?l)
}
GROUP BY ?thing }
UNION
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
?thing a cascade:Revision ; cascade:version ?v ; prov:generatedAtTime ?t .
FILTER NOT EXISTS { ?thing rdfs:label [] }
OPTIONAL { ?v cascade:displayName ?name }
OPTIONAL { ?thing prov:wasDerivedFrom ?doc }
OPTIONAL { ?thing prov:wasDerivedFrom/pav:retrievedFrom ?from }
OPTIONAL { ?thing prov:wasDerivedFrom/prov:wasGeneratedBy/prov:qualifiedAssociation ?authorVia .
?authorVia prov:hadRole ?authorRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?authorName
FILTER (?authorRole = cascade:AuthorRole) }
OPTIONAL { ?thing prov:wasDerivedFrom/prov:wasGeneratedBy/prov:qualifiedAssociation ?custodianVia .
?custodianVia prov:hadRole ?custodianRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?custodianName
FILTER (?custodianRole = cascade:CustodianRole) }
BIND (COALESCE(?authorName, ?custodianName) AS ?author)
BIND (CONCAT("Revision · ", COALESCE(?name, "no name"), " · ",
COALESCE(REPLACE(STR(?from), "^.*/", ""), ?author, IF(BOUND(?doc), "unknown source", "own entry")),
" · received ", SUBSTR(STR(?t), 1, 10)) AS ?l)
}
GROUP BY ?thing }
UNION
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
{ SELECT DISTINCT ?thing WHERE { ?revision a cascade:Revision ; prov:wasDerivedFrom ?thing } }
FILTER NOT EXISTS { ?thing rdfs:label [] }
OPTIONAL { ?thing prov:wasGeneratedBy/prov:qualifiedAssociation ?authorVia .
?authorVia prov:hadRole ?authorRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?authorName
FILTER (?authorRole = cascade:AuthorRole) }
OPTIONAL { ?thing prov:wasGeneratedBy/prov:qualifiedAssociation ?custodianVia .
?custodianVia prov:hadRole ?custodianRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?custodianName
FILTER (?custodianRole = cascade:CustodianRole) }
BIND (COALESCE(?authorName, ?custodianName) AS ?author)
OPTIONAL { ?thing pav:retrievedFrom ?from }
OPTIONAL { ?thing pav:retrievedOn ?on }
BIND (CONCAT("Document · ", COALESCE(?author, "unknown source"),
COALESCE(CONCAT(" · ", REPLACE(STR(?from), "^.*/([^/]+/[^/]+)$", "$1")), ""),
COALESCE(CONCAT(" · retrieved ", SUBSTR(STR(?on), 1, 10)), "")) AS ?l)
}
GROUP BY ?thing }
UNION
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
?thing a prov:Entity .
FILTER NOT EXISTS { ?thing prov:specializationOf [] }
FILTER NOT EXISTS { ?thing a cascade:Revision }
FILTER NOT EXISTS { ?thing rdfs:label [] }
OPTIONAL { ?thing prov:wasGeneratedBy/prov:qualifiedAssociation ?authorVia .
?authorVia prov:hadRole ?authorRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?authorName
FILTER (?authorRole = cascade:AuthorRole) }
OPTIONAL { ?thing prov:wasGeneratedBy/prov:qualifiedAssociation ?custodianVia .
?custodianVia prov:hadRole ?custodianRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?custodianName
FILTER (?custodianRole = cascade:CustodianRole) }
BIND (COALESCE(?authorName, ?custodianName) AS ?author)
OPTIONAL { ?thing pav:retrievedFrom ?from }
OPTIONAL { ?thing pav:retrievedOn ?on }
BIND (CONCAT("Document · ", COALESCE(?author, "unknown source"),
COALESCE(CONCAT(" · ", REPLACE(STR(?from), "^.*/([^/]+/[^/]+)$", "$1")), ""),
COALESCE(CONCAT(" · retrieved ", SUBSTR(STR(?on), 1, 10)), "")) AS ?l)
}
GROUP BY ?thing }
UNION
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
{ SELECT ?who (MIN(?name) AS ?machine)
WHERE {
{ SELECT DISTINCT ?who WHERE { ?judgment a cascade:Judgment ; prov:wasAttributedTo ?who } }
OPTIONAL { ?who rdfs:label ?name }
}
GROUP BY ?who }
?thing a cascade:Judgment ; prov:wasAttributedTo ?who .
FILTER NOT EXISTS { ?thing rdfs:label [] }
OPTIONAL { ?thing prov:generatedAtTime ?t }
OPTIONAL { ?thing cascade:verdict ?verdict }
OPTIONAL { ?thing prov:wasGeneratedBy/prov:qualifiedAssociation [ prov:agent ?who ; prov:hadRole ?role ] }
OPTIONAL { ?thing prov:hadMember/^prov:specializationOf/cascade:displayName ?about }
BIND (CONCAT(REPLACE(STR(?verdict), "^.*#", ""), " · ",
COALESCE(?machine, IF(?role = cascade:PatientRole, "the patient", "a person")), " · ",
IF(BOUND(?t), SUBSTR(STR(?t), 1, 10), SUBSTR(REPLACE(STR(?thing), "^.*[:/#]", ""), 1, 8)), " · ",
COALESCE(?about, "a patient profile")) AS ?l)
}
GROUP BY ?thing }
UNION
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
?thing a prov:Activity ; prov:invalidated ?retracted .
FILTER NOT EXISTS { ?thing rdfs:label [] }
OPTIONAL { ?thing prov:wasAssociatedWith ?who
OPTIONAL { ?who rdfs:label ?named }
OPTIONAL { ?thing prov:qualifiedAssociation [ prov:agent ?who ; prov:hadRole ?role ] } }
OPTIONAL { ?thing prov:startedAtTime ?t }
OPTIONAL { ?retracted cascade:assertedJudgment?/cascade:verdict ?retractedVerdict }
OPTIONAL { ?retracted cascade:assertedJudgment?/prov:hadMember/^prov:specializationOf/cascade:displayName ?retractedAbout }
BIND (CONCAT("Retraction · ",
COALESCE(?named, IF(BOUND(?who), IF(BOUND(?role) && ?role = cascade:PatientRole, "the patient", "a person"), "a release")), " · ",
IF(BOUND(?t), SUBSTR(STR(?t), 1, 10), SUBSTR(REPLACE(STR(?thing), "^.*[:/#]", ""), 1, 8)), " · of ",
COALESCE(REPLACE(STR(?retractedVerdict), "^.*#", ""), "a judgment"), " · ",
COALESCE(?retractedAbout, "a patient profile")) AS ?l)
}
GROUP BY ?thing }
UNION
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
?thing prov:specializationOf ?series ; pav:version ?version .
?series a cascade:ReferenceSeries ; rdfs:label ?name .
FILTER NOT EXISTS { ?thing rdfs:label [] }
BIND (CONCAT(?name, " · ", ?version) AS ?l)
}
GROUP BY ?thing }
UNION
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
GRAPH ?view { ?view a cascade:View . ?thing cascade:leadMember ?lead }
?lead cascade:recordKind ?kind .
FILTER NOT EXISTS { ?thing rdfs:label [] }
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:displayName ?name }
OPTIONAL { ?lead cascade:inEntry/cascade:dateFrom/pav:hasCurrentVersion/cascade:displayDate ?date }
BIND (CONCAT(?kind, " entry", COALESCE(CONCAT(" · ", ?name), ""), COALESCE(CONCAT(" · ", STR(?date)), "")) AS ?l)
}
GROUP BY ?thing }
UNION
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
GRAPH ?view { ?view a cascade:View . ?thing a cascade:PatientProfile ; cascade:entryMember [] }
FILTER NOT EXISTS { ?thing rdfs:label [] }
BIND ("Patient entry" AS ?l)
}
GROUP BY ?thing }
UNION
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
?version cascade:patient ?thing .
?revision cascade:version ?version ; prov:generatedAtTime ?t .
FILTER NOT EXISTS { ?thing a cascade:Subject }
FILTER NOT EXISTS { ?thing rdfs:label [] }
OPTIONAL { ?revision prov:wasDerivedFrom/prov:wasGeneratedBy/prov:qualifiedAssociation ?authorVia .
?authorVia prov:hadRole ?authorRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?authorName
FILTER (?authorRole = cascade:AuthorRole) }
OPTIONAL { ?revision prov:wasDerivedFrom/prov:wasGeneratedBy/prov:qualifiedAssociation ?custodianVia .
?custodianVia prov:hadRole ?custodianRole ; prov:agent/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?custodianName
FILTER (?custodianRole = cascade:CustodianRole) }
BIND (COALESCE(?authorName, ?custodianName) AS ?author)
BIND (CONCAT("Patient profile · ", COALESCE(?author, "unknown source"),
" · first received ", SUBSTR(STR(?t), 1, 10)) AS ?l)
}
GROUP BY ?thing }
UNION
{ SELECT ?thing (MIN(?l) AS ?label)
WHERE {
?thing a cascade:Subject .
FILTER NOT EXISTS { ?thing rdfs:label [] }
BIND ("The person this pod is about" AS ?l)
}
GROUP BY ?thing }
}
The terms it uses: rdfs:label, cascade:recordKind, pav:hasCurrentVersion, cascade:currentRevision, cascade:displayName, prov:wasDerivedFrom, prov:hadRole, prov:agent, cascade:AuthorRole, cascade:CustodianRole, prov:generatedAtTime, prov:specializationOf, cascade:version, cascade:clinicalStatus, cascade:workflowStatus, cascade:verificationStatus, cascade:allergyCriticality, cascade:displayDate, cascade:Revision, prov:wasGeneratedBy, pav:retrievedFrom, pav:retrievedOn, prov:Entity, cascade:Judgment, prov:wasAttributedTo, cascade:verdict, prov:hadMember, cascade:PatientRole, prov:Activity, prov:invalidated, prov:wasAssociatedWith, prov:qualifiedAssociation, prov:startedAtTime, cascade:assertedJudgment, pav:version, cascade:ReferenceSeries, cascade:View, cascade:leadMember, cascade:inEntry, cascade:PatientProfile, cascade:entryMember, cascade:patient, cascade:Subject.
patient-profile
One entry for the person, joining every patient profile a counting About judgment ties to them and no counting NotAbout over it for them outranks, named as every entry is, from its least member. Profiles are joined by About, not by Same, so the entry has no lead and states no value of its own: each profile's current values are a node of the view of their own, named after the entry and the profile, which says the profile they came from, so each source's date of birth, gender and death stand beside the others'.
It wrote clinical/patient-profile.ttl, 7 statements.
The view's page shows its entries.
The query: queries/views/patient-profile.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
CONSTRUCT {
?entry a cascade:PatientProfile ;
cascade:entryMember ?profile .
?entry cascade:memberCurrentValues ?memberValues .
?memberValues cascade:valuesOfMember ?profile ;
cascade:dateOfBirth ?memberDateOfBirth ;
cascade:administrativeGender ?memberAdministrativeGender ;
cascade:deceased ?memberDeceased ;
cascade:dateOfDeath ?memberDateOfDeath .
}
WHERE {
{ SELECT ?s (IRI(CONCAT("urn:cascade:entry:", SHA256(MIN(STR(?member))))) AS ?entry)
WHERE { ?about cascade:countsUnderLens true ; cascade:verdict cascade:About ; prov:hadMember ?member ;
cascade:subject ?s .
MINUS { ?denial cascade:countsUnderLens true ; cascade:verdict cascade:NotAbout ; prov:hadMember ?member ;
cascade:subject ?s . } }
GROUP BY ?s }
?j cascade:countsUnderLens true ; cascade:verdict cascade:About ; prov:hadMember ?profile ; cascade:subject ?s .
MINUS { ?notAbout cascade:countsUnderLens true ; cascade:verdict cascade:NotAbout ; prov:hadMember ?profile ;
cascade:subject ?s . }
OPTIONAL { ?profile pav:hasCurrentVersion ?memberVersion .
OPTIONAL { ?memberVersion cascade:dateOfBirth ?memberDateOfBirth }
OPTIONAL { ?memberVersion cascade:administrativeGender ?memberAdministrativeGender }
OPTIONAL { ?memberVersion cascade:deceased ?memberDeceased }
OPTIONAL { ?memberVersion cascade:dateOfDeath ?memberDateOfDeath } }
BIND (IF(BOUND(?memberVersion), IRI(CONCAT(STR(?entry), "-", SHA256(STR(?profile)))), 1/0) AS ?memberValues)
}
The terms it uses: cascade:PatientProfile, cascade:entryMember, cascade:memberCurrentValues, cascade:valuesOfMember, cascade:dateOfBirth, cascade:administrativeGender, cascade:deceased, cascade:dateOfDeath, cascade:countsUnderLens, cascade:verdict, cascade:About, prov:hadMember, cascade:subject, cascade:NotAbout, pav:hasCurrentVersion.
procedures
Each entry takes the name, code and text of its lead, the status of the member chosen for status, and the date of the member chosen for the date. Each member's current values are a node of the view of their own, named after the entry and the member, which says the member they came from, with the text that member's source wrote for it: an entry whose lead states none shows none, and the member that does shows it there; and what it was done for: each condition's record it names (cascade:reasonCondition) and each code of its reason, whether in a system the vocabulary lists (cascade:reasonCode) or in another (cascade:reasonCodeInOtherSystem).
It wrote clinical/procedures.ttl, 38 statements.
The view's page shows its entries.
The query: queries/views/procedures.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
CONSTRUCT {
?entry a cascade:MedicalProcedure ;
cascade:procedureName ?name ;
cascade:procedureCode ?code ;
cascade:narrativeText ?text ;
cascade:workflowStatus ?status ;
cascade:procedureDate ?date ;
cascade:leadMember ?lead ;
cascade:statusFrom ?statusFrom ;
cascade:entryMember ?record .
?entry cascade:memberCurrentValues ?memberValues .
?memberValues cascade:valuesOfMember ?member ;
cascade:procedureName ?memberProcedureName ;
cascade:procedureCode ?memberProcedureCode ;
cascade:narrativeText ?memberNarrativeText ;
cascade:workflowStatus ?memberWorkflowStatus ;
cascade:procedureDate ?memberProcedureDate ;
cascade:reasonCondition ?memberReasonCondition ;
cascade:reasonCode ?memberReasonCode ;
cascade:reasonCodeInOtherSystem ?memberReasonCodeInOtherSystem .
}
WHERE {
{ ?record a cascade:MedicalProcedure ; cascade:inEntry ?entry .
?entry cascade:leadMember ?lead .
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:procedureName ?name }
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:procedureCode ?code }
OPTIONAL { ?lead pav:hasCurrentVersion/cascade:narrativeText ?text }
OPTIONAL { ?entry cascade:statusFrom ?statusFrom .
?statusFrom pav:hasCurrentVersion/cascade:workflowStatus ?status }
OPTIONAL { ?entry cascade:dateFrom/pav:hasCurrentVersion/cascade:procedureDate ?date } }
UNION
{ ?member a cascade:MedicalProcedure ; cascade:inEntry ?entry ; pav:hasCurrentVersion ?memberVersion .
BIND (IRI(CONCAT(STR(?entry), "-", SHA256(STR(?member)))) AS ?memberValues)
OPTIONAL { ?memberVersion cascade:procedureName ?memberProcedureName }
OPTIONAL { ?memberVersion cascade:procedureCode ?memberProcedureCode }
OPTIONAL { ?memberVersion cascade:narrativeText ?memberNarrativeText }
OPTIONAL { ?memberVersion cascade:workflowStatus ?memberWorkflowStatus }
OPTIONAL { ?memberVersion cascade:procedureDate ?memberProcedureDate }
OPTIONAL { ?memberVersion cascade:reasonCondition ?memberReasonCondition }
OPTIONAL { ?memberVersion cascade:reasonCode ?memberReasonCode }
OPTIONAL { ?memberVersion cascade:reasonCodeInOtherSystem ?memberReasonCodeInOtherSystem } }
}
The terms it uses: cascade:MedicalProcedure, cascade:procedureName, cascade:procedureCode, cascade:narrativeText, cascade:workflowStatus, cascade:procedureDate, cascade:leadMember, cascade:statusFrom, cascade:entryMember, cascade:memberCurrentValues, cascade:valuesOfMember, cascade:reasonCondition, cascade:reasonCode, cascade:reasonCodeInOtherSystem, cascade:inEntry, pav:hasCurrentVersion, cascade:dateFrom.
Every page of this site names a thing by the label the labels file gives it. What everything is called lists them: 176 labels.