Skip to content
Alpha: see what works today →
Menu

View

clinical/allergies.ttl

https://pod.alex-rivera.example/clinical/allergies.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.

The rules of the spec that name this view: A15. The build writes a view once the pod holds a record of its kind, and at every build after.

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.

?file?named?rebuilt
settings/privateTypeIndex.ttltruefalse
clinical/allergies.ttl pagefalsetrue

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 -- alex-rivera "pod/Which file states each thing"

It prints the rows for every thing; this block keeps those whose ?thing is https://pod.alex-rivera.example/clinical/allergies.ttl.

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

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, after the derivations of the everyday lens had run.

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.

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.

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 -- alex-rivera "pod/Which view lists each kind"

It prints the rows for every view; this block keeps those whose ?view is https://pod.alex-rivera.example/clinical/allergies.ttl.

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

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
Allergy entry · Latexrdf:typeallergy or intolerance cascade:AllergyOrIntolerance
Allergy entry · Latexallergen code cascade:allergenCodeSNOMED CT 111088007Allergy · Latex · Meridian Health System · alg-latex-1 Turtletrue
Allergy entry · Latexallergen name cascade:allergenNameLatexAllergy · Latex · Meridian Health System · alg-latex-1 Turtletrue
Allergy entry · Latexallergy category cascade:allergyCategoryenvironmentAllergy · Latex · Meridian Health System · alg-latex-1 Turtletrue
Allergy entry · Latexallergy criticality cascade:allergyCriticalitylowAllergy · Latex · Meridian Health System · alg-latex-1 Turtletrue
Allergy entry · Latexclinical status cascade:clinicalStatusactiveAllergy · Latex · Meridian Health System · alg-latex-1 Turtletrue
Allergy entry · Latexentry member cascade:entryMemberAllergy · Latex · Meridian Health System · alg-latex-1 Turtle
Allergy entry · Latexlead member cascade:leadMember termAllergy · Latex · Meridian Health System · alg-latex-1 Turtle
Allergy entry · Latexreaction manifestation text cascade:reactionManifestationTextContact dermatitisAllergy · Latex · Meridian Health System · alg-latex-1 Turtletrue
Allergy entry · Latexstatus from cascade:statusFrom termAllergy · Latex · Meridian Health System · alg-latex-1 Turtle
Allergy entry · Peanutsrdf:typeallergy or intolerance cascade:AllergyOrIntolerance
Allergy entry · Peanutsallergen name cascade:allergenNamePeanutsAllergy · Peanuts · own entry Turtletrue
Allergy entry · Peanutsallergy criticality cascade:allergyCriticalityhighAllergy · Peanuts · own entry Turtletrue
Allergy entry · Peanutsentry member cascade:entryMemberAllergy · Peanuts · own entry Turtle
Allergy entry · Peanutslead member cascade:leadMember termAllergy · Peanuts · own entry Turtle
Allergy entry · Peanutsreaction manifestation text cascade:reactionManifestationTextAnaphylaxisAllergy · Peanuts · own entry Turtletrue
Allergy entry · Penicillinrdf:typeallergy or intolerance cascade:AllergyOrIntolerance
Allergy entry · Penicillinallergen code cascade:allergenCodeSNOMED CT 373270004Allergy · Penicillin · Larkspur Valley Health · lv-alg-101 Turtletrue
Allergy entry · Penicillinallergen code cascade:allergenCodeSNOMED CT 373270004Allergy · Penicillin · Larkspur Valley Health · al-8237461 Turtlefalse
Allergy entry · Penicillinallergen code cascade:allergenCodeRxNorm 7980Allergy · Penicillin G · Meridian Health System · alg-pcn-1 Turtlefalse
Allergy entry · Penicillinallergen name cascade:allergenNamePenicillinAllergy · Penicillin · Larkspur Valley Health · lv-alg-101 Turtletrue
Allergy entry · Penicillinallergen name cascade:allergenNamePenicillinAllergy · Penicillin · Larkspur Valley Health · al-8237461 Turtlefalse
Allergy entry · Penicillinallergen name cascade:allergenNamePenicillin GAllergy · Penicillin G · Meridian Health System · alg-pcn-1 Turtlefalse
Allergy entry · Penicillinallergy category cascade:allergyCategorymedicationAllergy · Penicillin · Larkspur Valley Health · lv-alg-101 Turtletrue
Allergy entry · Penicillinallergy category cascade:allergyCategorymedicationAllergy · Penicillin · Larkspur Valley Health · al-8237461 Turtlefalse
Allergy entry · Penicillinallergy category cascade:allergyCategorymedicationAllergy · Penicillin G · Meridian Health System · alg-pcn-1 Turtlefalse
Allergy entry · Penicillinallergy criticality cascade:allergyCriticalityhighAllergy · Penicillin G · Meridian Health System · alg-pcn-1 Turtlefalse
Allergy entry · Penicillinclinical status cascade:clinicalStatusactiveAllergy · Penicillin · Larkspur Valley Health · lv-alg-101 Turtletrue
Allergy entry · Penicillinclinical status cascade:clinicalStatusactiveAllergy · Penicillin · Larkspur Valley Health · al-8237461 Turtlefalse
Allergy entry · Penicillinclinical status cascade:clinicalStatusactiveAllergy · Penicillin G · Meridian Health System · alg-pcn-1 Turtlefalse
Allergy entry · Penicillinentry member cascade:entryMemberAllergy · Penicillin · Larkspur Valley Health · al-8237461 Turtle
Allergy entry · Penicillinentry member cascade:entryMemberAllergy · Penicillin · Larkspur Valley Health · lv-alg-101 Turtle
Allergy entry · Penicillinentry member cascade:entryMemberAllergy · Penicillin G · Meridian Health System · alg-pcn-1 Turtle
Allergy entry · Penicillinlead member cascade:leadMember termAllergy · Penicillin · Larkspur Valley Health · lv-alg-101 Turtle
Allergy entry · Penicillinonset date cascade:onsetDate2019-06-14Allergy · Penicillin G · Meridian Health System · alg-pcn-1 Turtlefalse
Allergy entry · Penicillinreaction manifestation text cascade:reactionManifestationTextHivesAllergy · Penicillin · Larkspur Valley Health · lv-alg-101 Turtletrue
Allergy entry · Penicillinreaction manifestation text cascade:reactionManifestationTextHivesAllergy · Penicillin · Larkspur Valley Health · al-8237461 Turtlefalse
Allergy entry · Penicillinreaction manifestation text cascade:reactionManifestationTextHivesAllergy · Penicillin G · Meridian Health System · alg-pcn-1 Turtlefalse
Allergy entry · Penicillinstatus from cascade:statusFrom termAllergy · Penicillin · Larkspur Valley Health · lv-alg-101 Turtle
Allergy entry · Sulfamethoxazolerdf:typeallergy or intolerance cascade:AllergyOrIntolerance
Allergy entry · Sulfamethoxazoleallergen code cascade:allergenCodeRxNorm 10180Allergy · Sulfamethoxazole · Larkspur Valley Health · lv-alg-102 Turtletrue
Allergy entry · Sulfamethoxazoleallergen code cascade:allergenCodeRxNorm 10180Allergy · Sulfamethoxazole · Meridian Health System · alg-sulfa-1 Turtlefalse
Allergy entry · Sulfamethoxazoleallergen code cascade:allergenCodeRxNorm 10180Allergy · Sulfamethoxazole · Larkspur Valley Health · al-8237462 Turtlefalse
Allergy entry · Sulfamethoxazoleallergen name cascade:allergenNameSulfamethoxazoleAllergy · Sulfamethoxazole · Larkspur Valley Health · lv-alg-102 Turtletrue
Allergy entry · Sulfamethoxazoleallergen name cascade:allergenNameSulfamethoxazoleAllergy · Sulfamethoxazole · Meridian Health System · alg-sulfa-1 Turtlefalse
Allergy entry · Sulfamethoxazoleallergen name cascade:allergenNameSulfamethoxazoleAllergy · Sulfamethoxazole · Larkspur Valley Health · al-8237462 Turtlefalse
Allergy entry · Sulfamethoxazoleallergy category cascade:allergyCategorymedicationAllergy · Sulfamethoxazole · Larkspur Valley Health · lv-alg-102 Turtletrue
Allergy entry · Sulfamethoxazoleallergy category cascade:allergyCategorymedicationAllergy · Sulfamethoxazole · Meridian Health System · alg-sulfa-1 Turtlefalse
Allergy entry · Sulfamethoxazoleallergy category cascade:allergyCategorymedicationAllergy · Sulfamethoxazole · Larkspur Valley Health · al-8237462 Turtlefalse
Allergy entry · Sulfamethoxazoleallergy criticality cascade:allergyCriticalityhighAllergy · Sulfamethoxazole · Larkspur Valley Health · lv-alg-102 Turtletrue
Allergy entry · Sulfamethoxazoleallergy criticality cascade:allergyCriticalityhighAllergy · Sulfamethoxazole · Larkspur Valley Health · al-8237462 Turtlefalse
Allergy entry · Sulfamethoxazoleallergy criticality cascade:allergyCriticalitylowAllergy · Sulfamethoxazole · Meridian Health System · alg-sulfa-1 Turtlefalse
Allergy entry · Sulfamethoxazoleclinical status cascade:clinicalStatusactiveAllergy · Sulfamethoxazole · Larkspur Valley Health · lv-alg-102 Turtletrue
Allergy entry · Sulfamethoxazoleclinical status cascade:clinicalStatusactiveAllergy · Sulfamethoxazole · Meridian Health System · alg-sulfa-1 Turtlefalse
Allergy entry · Sulfamethoxazoleclinical status cascade:clinicalStatusactiveAllergy · Sulfamethoxazole · Larkspur Valley Health · al-8237462 Turtlefalse
Allergy entry · Sulfamethoxazoleentry member cascade:entryMemberAllergy · Sulfamethoxazole · Meridian Health System · alg-sulfa-1 Turtle
Allergy entry · Sulfamethoxazoleentry member cascade:entryMemberAllergy · Sulfamethoxazole · Larkspur Valley Health · lv-alg-102 Turtle
Allergy entry · Sulfamethoxazoleentry member cascade:entryMemberAllergy · Sulfamethoxazole · Larkspur Valley Health · al-8237462 Turtle
Allergy entry · Sulfamethoxazolelead member cascade:leadMember termAllergy · Sulfamethoxazole · Larkspur Valley Health · lv-alg-102 Turtle
Allergy entry · Sulfamethoxazoleonset date cascade:onsetDate2022-05-03Allergy · Sulfamethoxazole · Meridian Health System · alg-sulfa-1 Turtlefalse
Allergy entry · Sulfamethoxazolereaction manifestation text cascade:reactionManifestationTextHivesAllergy · Sulfamethoxazole · Larkspur Valley Health · lv-alg-102 Turtletrue
Allergy entry · Sulfamethoxazolereaction manifestation text cascade:reactionManifestationTextHivesAllergy · Sulfamethoxazole · Larkspur Valley Health · al-8237462 Turtlefalse
Allergy entry · Sulfamethoxazolereaction manifestation text cascade:reactionManifestationTextItchingAllergy · Sulfamethoxazole · Meridian Health System · alg-sulfa-1 Turtlefalse
Allergy entry · Sulfamethoxazolereaction manifestation text cascade:reactionManifestationTextRashAllergy · Sulfamethoxazole · Meridian Health System · alg-sulfa-1 Turtlefalse
Allergy entry · Sulfamethoxazolestatus from cascade:statusFrom termAllergy · Sulfamethoxazole · Larkspur Valley Health · lv-alg-102 Turtle

65 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 -- alex-rivera "entry/What it shows"

It prints the rows for every view; this block keeps those whose ?view is https://pod.alex-rivera.example/clinical/allergies.ttl.

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