Skip to content
Alpha: see what works today →
Menu

Named question about pod

What was seen more than once

Each entry that holds more than one record, once for each place its records came from: how many of its records came from that place, and from how many places they came. A record's place is read from its current revision: a hospital that wrote or keeps the document it was derived from, by its label or its organization record's current name, or, when it has none, the label of the import or session that generated it. A place is told apart by that text alone: a hospital with two names is two places, and a hospital and an import that share a name are one. A record with two hospitals counts at each, so an entry's records can add up to more than it holds; a record with no hospital and no labelled import or session is given no place, and is not counted in places. Entries seen at more than one place come first.

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 ?entry ?entryLabel ?place (COUNT(DISTINCT ?record) AS ?records) ?places
WHERE {
  { SELECT ?entry (COUNT(DISTINCT ?somewhere) AS ?places)
    WHERE {
      ?member a cascade:Record ; ^cascade:entryMember ?entry ; cascade:currentRevision ?memberRevision .
      OPTIONAL { ?memberRevision prov:wasGeneratedBy/rdfs:label ?memberImportLabel }
      OPTIONAL { ?memberRevision prov:wasDerivedFrom/prov:wasAttributedTo/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?memberHospital }
      BIND (COALESCE(?memberHospital, ?memberImportLabel) AS ?somewhere)
    }
    GROUP BY ?entry
    HAVING (COUNT(DISTINCT ?member) > 1) }
  ?record ^cascade:entryMember ?entry ; cascade:currentRevision ?revision .
  OPTIONAL { ?entry rdfs:label ?entryLabel }
  OPTIONAL { ?revision prov:wasGeneratedBy/rdfs:label ?importLabel }
  OPTIONAL { ?revision prov:wasDerivedFrom/prov:wasAttributedTo/(rdfs:label|pav:hasCurrentVersion/foaf:name) ?hospital }
  BIND (COALESCE(?hospital, ?importLabel) AS ?place)
}
GROUP BY ?entry ?entryLabel ?place ?places
ORDER BY DESC(?places) ?entryLabel ?entry ?place

Terms it reads

cascade:Record · cascade:currentRevision · cascade:entryMember · pav:hasCurrentVersion · prov:wasDerivedFrom · 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

10 rows, as Alex Rivera's explorer shows them.

entryplacerecordsplaces
Allergy entry · PenicillinLarkspur Valley Health22
Allergy entry · PenicillinMeridian Health System12
Allergy entry · SulfamethoxazoleLarkspur Valley Health22
Allergy entry · SulfamethoxazoleMeridian Health System12
Condition entry · Essential hypertension · 2021-04-02Larkspur Valley Health22
Condition entry · Essential hypertension · 2021-04-02Meridian Health System12
Immunization entry · Influenza, injectable, quadrivalent, preservative free · 2025-10-15Larkspur Valley Health22
Immunization entry · Influenza, injectable, quadrivalent, preservative free · 2025-10-15Meridian Health System12
Condition entry · Asthma · 2008-09-01Larkspur Valley Health21
Procedure entry · Colonoscopy · 2026-08-19Larkspur Valley Health21

queries/questions/pod/What was seen more than once.rq on GitHub ↗