Skip to content
Alpha: see what works today →
Menu

Named question about pod

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.

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 ?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

Terms it reads

cascade:AuthorRole · cascade:CustodianRole · cascade:Vaccination · cascade:currentRevision · cascade:entryMember · cascade:vaccinationOccurrenceTime · cascade:vaccineCode · cascade:vaccineName · cascade:workflowStatus · pav:hasCurrentVersion · pav:retrievedOn · prov:agent · prov:hadRole · prov:wasGeneratedBy · rdfs:label

Rules and decision notes that name it

No rule or decision note writes its path.

Its rows on Alex Rivera's pod

1 row, as Alex Rivera's explorer shows them.

givenvaccinecodestatusrecordsentrysources
2025-10-15Influenza, injectable, quadrivalent, preservative freehttps://ns.cascadeprotocol.org/codes/cvx/150completed3Immunization entry · Influenza, injectable, quadrivalent, preservative free · 2025-10-15urn:uuid:7d77d9e0-5457-86f2-8d9d-827c65c11b21 from ni:///sha-256;P6xPAvjVjqgUn9UXSeFZnWc52vDAAQZnCfb5xytEMFQ, retrieved 2026-09-01T10:00:00Z, written by Meridian Health System; urn:uuid:7e3decf1-6e9a-8e95-b982-c2e7d18be3f1 from ni:///sha-256;LVAYE3hro7inQx9KKeCT54MbpvAkcQihcjALweOmbNI, retrieved 2026-10-14T15:40:00Z, written by Larkspur Valley Health; urn:uuid:c0a85df6-e2ef-85a1-ac62-b6b454bac0c5 from ni:///sha-256;ssSLEj6SMsYuwpHfAjdgeqmUMA75jzmwX_4oimVUuyM, retrieved 2027-03-18T12:00:00Z, written by Larkspur Valley Health

queries/questions/pod/My immunizations.rq on GitHub ↗