Skip to content
Alpha: see what works today →
Menu

View

clinical/notes-and-documents.ttl

https://pod.priya-natarajan.example/clinical/notes-and-documents.ttl

A view is a file the build writes. An app reads it to show a list, and never needs to know about records, revisions or judgments. Nobody edits a view: delete it and the build writes the same file again from the pod's records and judgments. Below are the files that state it, the query that wrote it, and every entry it lists.

Which file states each thing

The store loads each file twice: into the default graph, which the other questions read, and into a graph named by its address, which GRAPH ?file reads. A file states a thing when it says something about it, or names it as the value of a statement: a patient profile has no file of its own, so the files that name it are where it is stated. Named marks a row for a file that names the thing, and rebuilt a view or the labels, which the build writes. Files the build did not write come first, and among them the file a thing arrived in, if it has one.

Only the rows whose ?thing is this one.

2 rows

The query: queries/questions/pod/Which file states each thing.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pim: <http://www.w3.org/ns/pim/space#>

SELECT DISTINCT ?thing ?file ?named ?rebuilt
WHERE {
  { { SELECT DISTINCT ?file ?thing
      WHERE {
        ?owner pim:storage ?root .
        GRAPH ?file { ?thing ?property ?value }
        FILTER (isIRI(?thing) && STRSTARTS(STR(?file), STR(?root)))
      } }
    BIND (false AS ?named)
    BIND (EXISTS { ?file a cascade:View } AS ?rebuilt) }
  UNION
  { { SELECT DISTINCT ?file ?thing
      WHERE {
        ?owner pim:storage ?root .
        GRAPH ?file { ?subject ?property ?thing }
        FILTER (isIRI(?thing) && STRSTARTS(STR(?file), STR(?root)))
      } }
    BIND (true AS ?named)
    BIND (EXISTS { ?file a cascade:View } AS ?rebuilt) }
}
ORDER BY ?thing ?rebuilt ?named ?file

The terms it uses: pim:storage, cascade:View.

Run it yourself, from the runtime's root:

npm run ask -- priya-natarajan "pod/Which file states each thing"

It prints the rows for every thing; this block keeps those whose ?thing is https://pod.priya-natarajan.example/clinical/notes-and-documents.ttl.

Or in GraphDB, open the saved query pod/Which file states each thing in the repository priya-natarajan.

notes-and-documents

Each entry takes the type, type name, title, date, content status, text and organization of its lead and the status of the member chosen for status. The organization is the record itself, not an entry. 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. An attachment stays a node of its version.

It wrote clinical/notes-and-documents.ttl, 75 statements, after the derivations of the everyday lens had run.

The query: queries/views/notes-and-documents.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:ClinicalNoteOrDocument ;
    cascade:noteOrDocumentTypeName ?name ;
    cascade:noteOrDocumentTypeCode ?type ;
    cascade:noteOrDocumentTypeCodeInOtherSystem ?otherType ;
    cascade:noteOrDocumentTitle ?title ;
    cascade:noteOrDocumentDate ?date ;
    cascade:noteOrDocumentContentStatus ?contentStatus ;
    cascade:narrativeText ?text ;
    prov:wasAttributedTo ?organization ;
    cascade:workflowStatus ?status ;
    cascade:leadMember ?lead ;
    cascade:statusFrom ?statusFrom ;
    cascade:entryMember ?record .
  ?entry cascade:memberCurrentValues ?memberValues .
  ?memberValues cascade:valuesOfMember ?member ;
    cascade:noteOrDocumentTypeName ?memberNoteOrDocumentTypeName ;
    cascade:noteOrDocumentTypeCode ?memberNoteOrDocumentType ;
    cascade:noteOrDocumentTypeCodeInOtherSystem ?memberNoteOrDocumentTypeInOtherSystem ;
    cascade:noteOrDocumentTitle ?memberNoteOrDocumentTitle ;
    cascade:noteOrDocumentDate ?memberNoteOrDocumentDate ;
    cascade:noteOrDocumentContentStatus ?memberNoteOrDocumentContentStatus ;
    cascade:narrativeText ?memberNarrativeText ;
    prov:wasAttributedTo ?memberWasAttributedTo ;
    cascade:workflowStatus ?memberWorkflowStatus .
  ?entry cascade:paddedDateTime ?datePadded .
  ?datePadded cascade:paddedDateTimeProperty cascade:noteOrDocumentDate ; cascade:timeAsWritten ?dateWritten .
  ?memberValues cascade:paddedDateTime ?memberPadded .
  ?memberPadded cascade:paddedDateTimeProperty ?memberPaddedProperty ; cascade:timeAsWritten ?memberWritten .
}
WHERE {
  { ?record a cascade:ClinicalNoteOrDocument ; cascade:inEntry ?entry .
    ?entry cascade:leadMember ?lead .
    OPTIONAL { ?lead pav:hasCurrentVersion/cascade:noteOrDocumentTypeName ?name }
    OPTIONAL { ?lead pav:hasCurrentVersion/cascade:noteOrDocumentTypeCode ?type }
    OPTIONAL { ?lead pav:hasCurrentVersion/cascade:noteOrDocumentTypeCodeInOtherSystem ?otherType }
    OPTIONAL { ?lead pav:hasCurrentVersion/cascade:noteOrDocumentTitle ?title }
    OPTIONAL { ?lead pav:hasCurrentVersion/cascade:noteOrDocumentDate ?date }
    OPTIONAL { ?lead pav:hasCurrentVersion/cascade:noteOrDocumentContentStatus ?contentStatus }
    OPTIONAL { ?lead pav:hasCurrentVersion/cascade:narrativeText ?text }
    OPTIONAL { ?lead pav:hasCurrentVersion/prov:wasAttributedTo ?organization }
    OPTIONAL { ?entry cascade:statusFrom ?statusFrom .
               ?statusFrom pav:hasCurrentVersion/cascade:workflowStatus ?status }
    OPTIONAL { ?lead pav:hasCurrentVersion/cascade:paddedDateTime ?datePaddedAt .
               ?datePaddedAt cascade:paddedDateTimeProperty ?datePaddedProperty ; cascade:timeAsWritten ?dateWritten
               FILTER (?datePaddedProperty = cascade:noteOrDocumentDate) }
    BIND (IF(BOUND(?dateWritten), IRI(CONCAT(STR(?entry), "-padded-noteOrDocumentDate")), 1/0) AS ?datePadded) }
  UNION
  { ?member a cascade:ClinicalNoteOrDocument ; cascade:inEntry ?entry ; pav:hasCurrentVersion ?memberVersion .
    BIND (IRI(CONCAT(STR(?entry), "-", SHA256(STR(?member)))) AS ?memberValues)
    OPTIONAL { ?memberVersion cascade:noteOrDocumentTypeName ?memberNoteOrDocumentTypeName }
    OPTIONAL { ?memberVersion cascade:noteOrDocumentTypeCode ?memberNoteOrDocumentType }
    OPTIONAL { ?memberVersion cascade:noteOrDocumentTypeCodeInOtherSystem ?memberNoteOrDocumentTypeInOtherSystem }
    OPTIONAL { ?memberVersion cascade:noteOrDocumentTitle ?memberNoteOrDocumentTitle }
    OPTIONAL { ?memberVersion cascade:noteOrDocumentDate ?memberNoteOrDocumentDate }
    OPTIONAL { ?memberVersion cascade:noteOrDocumentContentStatus ?memberNoteOrDocumentContentStatus }
    OPTIONAL { ?memberVersion cascade:narrativeText ?memberNarrativeText }
    OPTIONAL { ?memberVersion prov:wasAttributedTo ?memberWasAttributedTo }
    OPTIONAL { ?memberVersion cascade:workflowStatus ?memberWorkflowStatus }
    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:ClinicalNoteOrDocument, cascade:noteOrDocumentTypeName, cascade:noteOrDocumentTypeCode, cascade:noteOrDocumentTypeCodeInOtherSystem, cascade:noteOrDocumentTitle, cascade:noteOrDocumentDate, cascade:noteOrDocumentContentStatus, cascade:narrativeText, prov:wasAttributedTo, cascade:workflowStatus, cascade:leadMember, cascade:statusFrom, cascade:entryMember, cascade:memberCurrentValues, cascade:valuesOfMember, cascade:paddedDateTime, cascade:paddedDateTimeProperty, cascade:timeAsWritten, cascade:inEntry, pav:hasCurrentVersion.

Which view lists each kind

An app finds a Solid pod's data through its type index: each registration names a type and the file that lists things of that type. Here each of those files is a view, and the entries are the things it lists. A view is never edited by hand; the build writes it from the records and the judgments.

Only the rows whose ?view is this one.

?title?type?entries
Notes and documentsclinical note or document cascade:ClinicalNoteOrDocument4

1 row

The query: queries/questions/pod/Which view lists each kind.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX solid: <http://www.w3.org/ns/solid/terms#>

SELECT ?title ?type ?view (COUNT(DISTINCT ?entry) AS ?entries)
WHERE {
  ?registration a solid:TypeRegistration ; solid:forClass ?type ; solid:instance ?view ; dct:title ?title .
  OPTIONAL { ?entry a ?type ; cascade:entryMember [] }
}
GROUP BY ?title ?type ?view
ORDER BY ?title ?view

The terms it uses: solid:TypeRegistration, solid:forClass, solid:instance, dct:title, cascade:entryMember.

Run it yourself, from the runtime's root:

npm run ask -- priya-natarajan "pod/Which view lists each kind"

It prints the rows for every view; this block keeps those whose ?view is https://pod.priya-natarajan.example/clinical/notes-and-documents.ttl.

Or in GraphDB, open the saved query pod/Which view lists each kind in the repository priya-natarajan.

What it shows

What each entry shows: every value its view states of it and every value its members' current versions state of the fields the view shows, each with From, the member whose current version states it, and Lead, whether that member is the entry's lead (cascade:leadMember), whose values come first. An entry is what an app shows: one allergy, one condition, one vaccination; no merged record is stored, so the view holds each member's current values as a node of its own (cascade:memberCurrentValues) and this reads the view alone. The view takes the entry's name and codes from its lead, and its status and dates from the members the derivations chose for them (cascade:statusFrom, cascade:dateFrom and, for a medication, cascade:medicationUseStartDateFrom, cascade:prescriptionWrittenDateFrom and cascade:dosageFrom, and for an allergy cascade:allergyCategoryFrom and cascade:onsetDateFrom). A value no member states, such as the highest criticality among them, has no From. A padded time is shown as the time, and a reference range as its text, its bounds being nodes of the view of their own; the node saying a time was written short of the second is no value of its own.

Only the rows whose ?view is this one.

?entry?field?value?from?lead
Note or document entry · Social history Narrative · 2025-05-05T17:42:33Zrdf:typeclinical note or document cascade:ClinicalNoteOrDocument
Note or document entry · Social history Narrative · 2025-05-05T17:42:33Zentry member cascade:entryMemberNote or document · Social history Narrative · Kestrel Harbor Hospital · received 2025-05-05 Turtle
Note or document entry · Social history Narrative · 2025-05-05T17:42:33Zlead member cascade:leadMember termNote or document · Social history Narrative · Kestrel Harbor Hospital · received 2025-05-05 Turtle
Note or document entry · Social history Narrative · 2025-05-05T17:42:33Znarrative text cascade:narrativeTextSmoking status Recorded Never smoker March 27, 2025Note or document · Social history Narrative · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Social history Narrative · 2025-05-05T17:42:33Znote or document date cascade:noteOrDocumentDate2025-05-05 17:42 UTCNote or document · Social history Narrative · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Social history Narrative · 2025-05-05T17:42:33Znote or document title cascade:noteOrDocumentTitleSocial HistoryNote or document · Social history Narrative · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Social history Narrative · 2025-05-05T17:42:33Znote or document type code cascade:noteOrDocumentTypeCodeLOINC 29762-2Note or document · Social history Narrative · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Social history Narrative · 2025-05-05T17:42:33Znote or document type name cascade:noteOrDocumentTypeNameSocial history NarrativeNote or document · Social history Narrative · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Social history Narrative · 2025-05-05T17:42:33Zstatus from cascade:statusFrom termNote or document · Social history Narrative · Kestrel Harbor Hospital · received 2025-05-05 Turtle
Note or document entry · Social history Narrative · 2025-05-05T17:42:33Zworkflow status cascade:workflowStatuscurrentNote or document · Social history Narrative · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Social history Narrative · 2025-08-12T19:02:37Zrdf:typeclinical note or document cascade:ClinicalNoteOrDocument
Note or document entry · Social history Narrative · 2025-08-12T19:02:37Zentry member cascade:entryMemberNote or document · Social history Narrative · Fernhill Family Clinic · received 2025-08-12 Turtle
Note or document entry · Social history Narrative · 2025-08-12T19:02:37Zlead member cascade:leadMember termNote or document · Social history Narrative · Fernhill Family Clinic · received 2025-08-12 Turtle
Note or document entry · Social history Narrative · 2025-08-12T19:02:37Znarrative text cascade:narrativeTextNever smoker, recorded May 20, 2025Note or document · Social history Narrative · Fernhill Family Clinic · received 2025-08-12 Turtletrue
Note or document entry · Social history Narrative · 2025-08-12T19:02:37Znote or document date cascade:noteOrDocumentDate2025-08-12 19:02 UTCNote or document · Social history Narrative · Fernhill Family Clinic · received 2025-08-12 Turtletrue
Note or document entry · Social history Narrative · 2025-08-12T19:02:37Znote or document title cascade:noteOrDocumentTitleSocial HistoryNote or document · Social history Narrative · Fernhill Family Clinic · received 2025-08-12 Turtletrue
Note or document entry · Social history Narrative · 2025-08-12T19:02:37Znote or document type code cascade:noteOrDocumentTypeCodeLOINC 29762-2Note or document · Social history Narrative · Fernhill Family Clinic · received 2025-08-12 Turtletrue
Note or document entry · Social history Narrative · 2025-08-12T19:02:37Znote or document type name cascade:noteOrDocumentTypeNameSocial history NarrativeNote or document · Social history Narrative · Fernhill Family Clinic · received 2025-08-12 Turtletrue
Note or document entry · Social history Narrative · 2025-08-12T19:02:37Zstatus from cascade:statusFrom termNote or document · Social history Narrative · Fernhill Family Clinic · received 2025-08-12 Turtle
Note or document entry · Social history Narrative · 2025-08-12T19:02:37Zworkflow status cascade:workflowStatuscurrentNote or document · Social history Narrative · Fernhill Family Clinic · received 2025-08-12 Turtletrue
Note or document entry · Vital signs · 2025-05-05T17:42:33Zrdf:typeclinical note or document cascade:ClinicalNoteOrDocument
Note or document entry · Vital signs · 2025-05-05T17:42:33Zentry member cascade:entryMemberNote or document · Vital signs · Kestrel Harbor Hospital · received 2025-05-05 Turtle
Note or document entry · Vital signs · 2025-05-05T17:42:33Zlead member cascade:leadMember termNote or document · Vital signs · Kestrel Harbor Hospital · received 2025-05-05 Turtle
Note or document entry · Vital signs · 2025-05-05T17:42:33Znarrative text cascade:narrativeTextTaken Blood pressure March 27, 2025 11:40 UTC 148/92 mm[Hg]Note or document · Vital signs · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Vital signs · 2025-05-05T17:42:33Znote or document date cascade:noteOrDocumentDate2025-05-05 17:42 UTCNote or document · Vital signs · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Vital signs · 2025-05-05T17:42:33Znote or document title cascade:noteOrDocumentTitleVital SignsNote or document · Vital signs · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Vital signs · 2025-05-05T17:42:33Znote or document type code cascade:noteOrDocumentTypeCodeLOINC 8716-3Note or document · Vital signs · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Vital signs · 2025-05-05T17:42:33Znote or document type name cascade:noteOrDocumentTypeNameVital signsNote or document · Vital signs · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Vital signs · 2025-05-05T17:42:33Zstatus from cascade:statusFrom termNote or document · Vital signs · Kestrel Harbor Hospital · received 2025-05-05 Turtle
Note or document entry · Vital signs · 2025-05-05T17:42:33Zworkflow status cascade:workflowStatuscurrentNote or document · Vital signs · Kestrel Harbor Hospital · received 2025-05-05 Turtletrue
Note or document entry · Vital signs · 2025-08-12T19:02:37Zrdf:typeclinical note or document cascade:ClinicalNoteOrDocument
Note or document entry · Vital signs · 2025-08-12T19:02:37Zentry member cascade:entryMemberNote or document · Vital signs · Fernhill Family Clinic · received 2025-08-12 Turtle
Note or document entry · Vital signs · 2025-08-12T19:02:37Zlead member cascade:leadMember termNote or document · Vital signs · Fernhill Family Clinic · received 2025-08-12 Turtle
Note or document entry · Vital signs · 2025-08-12T19:02:37Znarrative text cascade:narrativeTextMay 20, 2025: blood pressure 132/84 mm[Hg]Note or document · Vital signs · Fernhill Family Clinic · received 2025-08-12 Turtletrue
Note or document entry · Vital signs · 2025-08-12T19:02:37Znote or document date cascade:noteOrDocumentDate2025-08-12 19:02 UTCNote or document · Vital signs · Fernhill Family Clinic · received 2025-08-12 Turtletrue
Note or document entry · Vital signs · 2025-08-12T19:02:37Znote or document title cascade:noteOrDocumentTitleVital SignsNote or document · Vital signs · Fernhill Family Clinic · received 2025-08-12 Turtletrue
Note or document entry · Vital signs · 2025-08-12T19:02:37Znote or document type code cascade:noteOrDocumentTypeCodeLOINC 8716-3Note or document · Vital signs · Fernhill Family Clinic · received 2025-08-12 Turtletrue
Note or document entry · Vital signs · 2025-08-12T19:02:37Znote or document type name cascade:noteOrDocumentTypeNameVital signsNote or document · Vital signs · Fernhill Family Clinic · received 2025-08-12 Turtletrue
Note or document entry · Vital signs · 2025-08-12T19:02:37Zstatus from cascade:statusFrom termNote or document · Vital signs · Fernhill Family Clinic · received 2025-08-12 Turtle
Note or document entry · Vital signs · 2025-08-12T19:02:37Zworkflow status cascade:workflowStatuscurrentNote or document · Vital signs · Fernhill Family Clinic · received 2025-08-12 Turtletrue

40 rows

The query: queries/questions/entry/What it shows.rq on GitHub
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?entry ?entryLabel ?view ?field ?value ?valueLabel ?from ?fromLabel ?lead
WHERE {
  { GRAPH ?view { ?entry cascade:entryMember [] ; cascade:leadMember ?leader ; cascade:memberCurrentValues ?values .
                  ?values cascade:valuesOfMember ?from ; ?field ?value .
                  FILTER (?field NOT IN (cascade:valuesOfMember, cascade:paddedDateTime, cascade:referenceRangeLow, cascade:referenceRangeHigh)) }
    BIND (?from = ?leader AS ?lead)
    OPTIONAL { ?from rdfs:label ?fromLabel }
    OPTIONAL { ?entry rdfs:label ?entryLabel }
    OPTIONAL { ?value rdfs:label ?valueLabel } }
  UNION
  { GRAPH ?view { ?entry cascade:entryMember [] ; ?field ?value
                  FILTER (?field NOT IN (cascade:memberCurrentValues, cascade:paddedDateTime, cascade:referenceRangeLow, cascade:referenceRangeHigh))
                  FILTER NOT EXISTS { ?entry cascade:memberCurrentValues ?held . ?held ?field ?value } }
    OPTIONAL { ?entry rdfs:label ?entryLabel }
    OPTIONAL { ?value rdfs:label ?valueLabel } }
}
ORDER BY ?entryLabel ?entry ?field DESC(?lead) STR(?value) ?from

The terms it uses: cascade:entryMember, cascade:leadMember, cascade:memberCurrentValues, cascade:valuesOfMember, cascade:paddedDateTime, cascade:referenceRangeLow, cascade:referenceRangeHigh, rdfs:label.

Run it yourself, from the runtime's root:

npm run ask -- priya-natarajan "entry/What it shows"

It prints the rows for every view; this block keeps those whose ?view is https://pod.priya-natarajan.example/clinical/notes-and-documents.ttl.

Or in GraphDB, open the saved query entry/What it shows in the repository priya-natarajan.