Named question about pod
My condition history
Read from the view alone, as an app would: each condition entry whatever its status, with its codes, its status, when it started and when it ended, each record's own status, each entry given for it as `pod/My active conditions` lists them ("<entry>, <name>", the entry IRI alone when it has no name, in code point order of name, then entry, and with a medication entered in error left out), how many records it joins, and each record with the document it was derived from, when that was retrieved, and the hospitals that wrote it and that keep it. The status is "ruled out" when the record the entry took its status from is refuted, whatever its clinical status, so a condition that was considered and refuted is never read as one that resolved; otherwise it is that record's clinical status, or none when it states none, and an entry ruled out has no abatement day. The verification status is as the source writes it. The entries whose status is active and not ruled out are the ones `pod/My active conditions` lists. A record's own status is its clinical status, "ruled out" alone when it is refuted; the day it abated follows a clinical status, never "ruled out". A list holds its values in order, separated by U+001F; a value's own parts are ended by ", ". Its code is the code IRI the entry states, in whichever listed system, the first in code point order when it states several, so that each entry is one row.
The query
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 ?condition ?conditionCode ?status ?verificationStatus ?onset ?abated ?statuses ?entriesForIt
(COUNT(?record) AS ?records) ?entry ?entryLabel ?sources
WHERE {
{ SELECT ?entry (REPLACE(GROUP_CONCAT(DISTINCT ?forLine; separator=""), "\u001F$", "") AS ?forIt)
WHERE {
{ SELECT ?entry ?forLine
WHERE {
?entry a cascade:ProblemOrDiagnosis ; cascade:entryMember ?conditionRecord .
OPTIONAL { ?forValues cascade:reasonCondition ?conditionRecord .
?forEntry cascade:memberCurrentValues ?forValues .
OPTIONAL { ?forEntry cascade:drugName ?drugName }
OPTIONAL { ?forEntry cascade:procedureName ?procedureName }
OPTIONAL { ?forEntry cascade:vaccineName ?vaccineName }
FILTER NOT EXISTS { ?forEntry cascade:lifecycle cascade:MedicationEnteredInError } }
BIND (COALESCE(?drugName, ?procedureName, ?vaccineName) AS ?forName)
BIND (IF(BOUND(?forEntry), CONCAT(STR(?forEntry), COALESCE(CONCAT(", ", ?forName), ""), "\u001F"), "") AS ?forLine)
}
ORDER BY ?entry ?forName ?forEntry }
}
GROUP BY ?entry }
{ SELECT ?entry (REPLACE(GROUP_CONCAT(DISTINCT CONCAT(?statusText, "\u001F"); separator=""), "\u001F$", "") AS ?statuses)
WHERE {
{ SELECT ?entry ?statusText
WHERE {
?entry a cascade:ProblemOrDiagnosis ; cascade:memberCurrentValues ?values .
?values cascade:valuesOfMember ?member .
OPTIONAL { ?values cascade:clinicalStatus ?memberClinicalStatus }
OPTIONAL { ?values cascade:verificationStatus ?memberVerificationStatus }
OPTIONAL { ?values cascade:abatementDate ?memberAbated }
BIND (BOUND(?memberVerificationStatus) && ?memberVerificationStatus = "refuted" AS ?memberRuledOut)
BIND (CONCAT(STR(?member), " ",
IF(?memberRuledOut, "ruled out", COALESCE(?memberClinicalStatus, "with no status")),
IF(?memberRuledOut, "", COALESCE(CONCAT(", abated ", STR(?memberAbated)), ""))) AS ?statusText)
}
ORDER BY ?entry ?statusText }
}
GROUP BY ?entry }
{ 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:ProblemOrDiagnosis ; 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:ProblemOrDiagnosis ; cascade:conditionName ?condition ; cascade:entryMember ?record .
OPTIONAL { ?entry cascade:clinicalStatus ?clinicalStatus }
OPTIONAL { ?entry cascade:verificationStatus ?verificationStatus }
OPTIONAL {
?entry cascade:conditionCode ?conditionCode .
FILTER NOT EXISTS {
?entry cascade:conditionCode ?earlier .
FILTER (STR(?earlier) < STR(?conditionCode))
}
}
OPTIONAL { ?entry cascade:onsetDate ?onset }
OPTIONAL { ?entry cascade:abatementDate ?abated
FILTER NOT EXISTS { ?entry cascade:verificationStatus "refuted" } }
OPTIONAL { ?entry rdfs:label ?entryLabel }
BIND (IF(BOUND(?verificationStatus) && ?verificationStatus = "refuted", "ruled out", ?clinicalStatus) AS ?status)
BIND (IF(?forIt = "", ?nothing, ?forIt) AS ?entriesForIt)
}
GROUP BY ?entry ?condition ?conditionCode ?status ?verificationStatus ?onset ?abated ?entryLabel ?statuses ?entriesForIt ?sources
ORDER BY ?condition ?entry
Terms it reads
cascade:AuthorRole · cascade:CustodianRole · cascade:MedicationEnteredInError · cascade:ProblemOrDiagnosis · cascade:abatementDate · cascade:clinicalStatus · cascade:conditionCode · cascade:conditionName · cascade:currentRevision · cascade:drugName · cascade:entryMember · cascade:lifecycle · cascade:memberCurrentValues · cascade:onsetDate · cascade:procedureName · cascade:reasonCondition · cascade:vaccineName · cascade:valuesOfMember · cascade:verificationStatus · pav:hasCurrentVersion · pav:retrievedOn · prov:agent · prov:hadRole · prov:wasGeneratedBy · rdfs:label
Rules and decision notes that name it
- C9. A condition its source refutes is an entry, ruled out, and an allergy so marked is still left out runtime/currency.feature
Its rows on Alex Rivera's pod
4 rows, as Alex Rivera's explorer shows them.
| condition | conditionCode | status | verificationStatus | onset | abated | statuses | records | entry | sources |
|---|---|---|---|---|---|---|---|---|---|
| Acute bronchitis | http:/ | resolved | confirmed | 2026-08-12 | 2026-09-20 | urn:uuid:427f6a98-faf9-8e37-bd5d-6dca2a812580 resolved, abated 2026-09-20 | 1 | Condition entry · Acute bronchitis · 2026-08-12 | urn:uuid:427f6a98-faf9-8e37-bd5d-6dca2a812580 from ni:/ |
| Asthma | http:/ | active | confirmed | 2008-09-01 | urn:uuid:3719cb66-c5be-8fac-a0bf-a6db7573fe71 active; urn:uuid:fdf1589d-bc02-8c0f-8874-4d377574cc8d active | 2 | Condition entry · Asthma · 2008-09-01 | urn:uuid:3719cb66-c5be-8fac-a0bf-a6db7573fe71 from ni:/ | |
| Essential hypertension | http:/ | active | confirmed | 2021-04-02 | urn:uuid:173c9663-2406-8025-843b-5f9b19c1b9f3 active; urn:uuid:e3889c3a-faa3-8a4f-a9f6-84d1dd1d85a4 active; urn:uuid:fb6ea0ec-3fbb-865c-a044-01b708d547f1 active | 3 | Condition entry · Essential hypertension · 2021-04-02 | urn:uuid:173c9663-2406-8025-843b-5f9b19c1b9f3 from ni:/ | |
| Low back pain | http:/ | active | confirmed | 2026-06-01 | urn:uuid:fc149b2f-bf16-816b-8beb-04ccaff3eade active | 1 | Condition entry · Low back pain · 2026-06-01 | urn:uuid:fc149b2f-bf16-816b-8beb-04ccaff3eade from ni:/ |