Named question about entry
What needs review
Entries a person should look at, and why: its members disagree on how severe an allergy is, the matcher joined it for two different reasons, two records judged different are still joined in it, a matcher's Same of two records now in two entries has lapsed (an open adopted newer tables or rules and did not file it again, so the pair it joined is apart until a person judges it), a finding of the matcher judgments a rule list version no longer reaches names a lapsed matcher judgment of two records now in two entries (listed as one line, the finding, expanding to its pairs, each with the matcher judgment of least IRI that names it, until a person judges the pair, or files an acknowledgement of that kind naming both its records and no other, which takes the pair off; a lapsed Same such a finding names is listed with it, never alone), or two of its conditions, in two entries, carry one code and their dates cannot tell whether they are one condition: either has no onset, or one has an unknown end (no abatement that is a date ending on or after its onset begins, and no status that keeps it going: active, recurrence or relapse) and its onset begins on or before the other's end, the other's period counted as the matcher's rule R8 counts it, each date read as the days its precision covers. A condition with an unknown end that began after the other's end is apart from it: the two are two episodes, not joined and not listed, as are two whose periods are both known and apart. Two medications in two entries that share an RxNorm code or an NDC are possibly the same medication: a pod cannot tell which shared code names a product, and the matcher's rule R11 has already joined every pair that shares one the held drug products table knows, so what is left is a pair sharing an ingredient, a strength, a dose form, a brand name or a salt, a pair of which one carries more than one product code (R11 leaves it out, as A with X, B with X and Y, C with Y), a code no held table knows, which is every shared RxNorm code when no drug products table is held, or, from the rule list's version 18, a pair of one product or one NDC whose exposure periods share no day, or of which one has no exposure start: two courses, or one course with a gap, which a person can tell apart and the dates cannot (decisions/medication-matching.md). A pair is listed once, from the entry of its smaller record, unless a person judged it different or a lapsed Same of it is listed already. An entry joined by an NDC (R5) and a product code (R11) alone is joined through one kind of sameness, since both are exact identity, and so is an entry joined by a grown note (R19), one note sent twice (R20) and one document identifier (R21) alone, since each says the members are one note; any other two justifications are two kinds, with any of these included. A join by a shared business identifier within one organization (R18) is certain, so it adds no kind: an entry it joins with one other rule is joined through that rule's kind alone. An entry the matcher joined by the same result on one day (R15) is listed with that Same: at least one of the two results was stamped with a day alone or a time its source wrote short of the second, and two draws in one day are common, so the join is likely, not sure. Two lab results in two entries of one test code at one instant whose values' units differ once their UCUM annotations are dropped are listed too, once, from the entry of the smaller record, unless a person judged them different: mmol/L and mg/dL may measure one draw, and no rule converts one into the other. A finding of different result values at one instant (R16) is listed, as the finding with its two results, while both are at the versions it compared, until a person files an acknowledgement of its kind naming the two results and no other, or judges them different. A finding of different values or units is not listed while R18 joins the two, as sharing a business identifier within one organization, and the current version of one of them says it was corrected or amended: the source said the second value is its correction. Two results R18 joins that neither marks so are still listed, since two channels of one organization disagreeing is for a person to see. The build never settles these itself; a person does, with a judgment.
The query
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX oa: <http://www.w3.org/ns/oa#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?entry ?entryLabel ?needs ?finding ?judgment ?judgmentLabel ?record ?recordLabel ?otherRecord ?otherRecordLabel
WHERE {
{ { SELECT ?entry
WHERE {
?member ^cascade:entryMember ?entry ;
pav:hasCurrentVersion/cascade:allergyCriticality ?criticality .
}
GROUP BY ?entry
HAVING (COUNT(DISTINCT ?criticality) > 1) }
BIND ("members disagree on criticality" AS ?needs)
OPTIONAL { ?entry rdfs:label ?entryLabel } }
UNION
{ { SELECT ?entry
WHERE {
?same cascade:countsUnderLens true ; cascade:verdict cascade:Same ; cascade:justification ?why ;
prov:wasAttributedTo/a prov:SoftwareAgent ; prov:hadMember ?member .
?member ^cascade:entryMember ?entry .
FILTER (?why != cascade:SameBusinessIdentifierAndTestCodeWithinOneOrganization)
}
GROUP BY ?entry
HAVING (COUNT(DISTINCT ?why) > 1
&& SUM(IF(?why IN (cascade:SameMedicationCode, cascade:SameProductCode), 0, 1)) > 0
&& SUM(IF(?why IN (cascade:SameNoteTypeAndTextGrownWithinOneOrganization, cascade:SameNoteTypeAndText,
cascade:SameNoteOrDocumentMasterIdentifier), 0, 1)) > 0) }
BIND ("joined through two kinds of machine sameness" AS ?needs)
OPTIONAL { ?entry rdfs:label ?entryLabel } }
UNION
{ ?record cascade:currentlyDifferent ?otherRecord ; ^cascade:entryMember ?entry .
?otherRecord ^cascade:entryMember ?entry .
FILTER (STR(?record) < STR(?otherRecord))
BIND ("judged different, still joined" AS ?needs)
OPTIONAL { ?judgment cascade:countsUnderLens true ; cascade:verdict ?judgedVerdict ; prov:hadMember ?record , ?otherRecord
FILTER (?judgedVerdict = cascade:Different) }
OPTIONAL { ?entry rdfs:label ?entryLabel }
OPTIONAL { ?judgment rdfs:label ?judgmentLabel }
OPTIONAL { ?record rdfs:label ?recordLabel }
OPTIONAL { ?otherRecord rdfs:label ?otherRecordLabel } }
UNION
{ { SELECT ?record ?otherRecord (MIN(STR(?lapsed)) AS ?first)
WHERE {
?lapsed cascade:lapsed true ; prov:hadMember ?record , ?otherRecord .
FILTER (STR(?record) < STR(?otherRecord))
FILTER NOT EXISTS { ?naming oa:hasBody cascade:MatcherJudgmentsNoLongerReached ; oa:hasTarget ?lapsed }
}
GROUP BY ?record ?otherRecord }
?judgment cascade:lapsed true ; prov:hadMember ?record , ?otherRecord .
?record ^cascade:entryMember ?entry .
?otherRecord ^cascade:entryMember ?otherEntry .
FILTER (STR(?judgment) = ?first && ?entry != ?otherEntry
&& !EXISTS { ?record cascade:currentlyDifferent ?otherRecord })
BIND ("joined before, apart under newer tables or rules" AS ?needs)
OPTIONAL { ?entry rdfs:label ?entryLabel }
OPTIONAL { ?judgment rdfs:label ?judgmentLabel }
OPTIONAL { ?record rdfs:label ?recordLabel }
OPTIONAL { ?otherRecord rdfs:label ?otherRecordLabel } }
UNION
{ { { SELECT ?finding ?record ?otherRecord (MIN(STR(?lapsedJudgment)) AS ?first)
WHERE {
?finding oa:hasBody cascade:MatcherJudgmentsNoLongerReached ; oa:hasTarget ?lapsedJudgment .
?lapsedJudgment cascade:lapsed true ; prov:hadMember ?record , ?otherRecord .
FILTER (STR(?record) < STR(?otherRecord))
}
GROUP BY ?finding ?record ?otherRecord }
FILTER (BOUND(?first)) }
BIND (IRI(?first) AS ?judgment)
?record ^cascade:entryMember ?entry .
?otherRecord ^cascade:entryMember ?otherEntry .
FILTER (?entry != ?otherEntry
&& !EXISTS { ?record cascade:currentlyDifferent ?otherRecord })
MINUS { ?acknowledgement cascade:countsUnderLens true ; cascade:verdict cascade:Acknowledged ;
cascade:answersWarningOfKind cascade:MatcherJudgmentsNoLongerReached ;
prov:hadMember ?record , ?otherRecord .
FILTER NOT EXISTS { ?acknowledgement prov:hadMember ?third . FILTER (?third NOT IN (?record, ?otherRecord)) } }
BIND ("no longer joined under a newer rule list version" AS ?needs)
OPTIONAL { ?entry rdfs:label ?entryLabel }
OPTIONAL { ?judgment rdfs:label ?judgmentLabel }
OPTIONAL { ?record rdfs:label ?recordLabel }
OPTIONAL { ?otherRecord rdfs:label ?otherRecordLabel } }
UNION
{
{ SELECT ?record ?entry ?property ?code ?dated ?from ?to ?open
WHERE {
VALUES ?property { cascade:conditionCode }
?record cascade:recordKind "Condition" ; pav:hasCurrentVersion ?version ; ^cascade:entryMember ?entry .
?version ?property ?code .
OPTIONAL { ?version cascade:displayDate ?onset }
OPTIONAL { ?version cascade:abatementDate ?end }
OPTIONAL { ?version cascade:clinicalStatus ?status }
BIND (IF(DATATYPE(?onset) = xsd:gYear, CONCAT(SUBSTR(STR(?onset), 1, 4), "-01-01"),
IF(DATATYPE(?onset) = xsd:gYearMonth, CONCAT(SUBSTR(STR(?onset), 1, 7), "-01"), SUBSTR(STR(?onset), 1, 10))) AS ?from)
BIND (IF(DATATYPE(?onset) = xsd:gYear, CONCAT(SUBSTR(STR(?onset), 1, 4), "-12-31"),
IF(DATATYPE(?onset) = xsd:gYearMonth, CONCAT(SUBSTR(STR(?onset), 1, 7), "-31"), SUBSTR(STR(?onset), 1, 10))) AS ?onsetTo)
BIND (IF(BOUND(?end) && isLiteral(?end) && DATATYPE(?end) IN (xsd:date, xsd:dateTime), SUBSTR(STR(?end), 1, 10),
IF(BOUND(?end) && isLiteral(?end) && DATATYPE(?end) = xsd:gYearMonth, CONCAT(SUBSTR(STR(?end), 1, 7), "-31"),
IF(BOUND(?end) && isLiteral(?end) && DATATYPE(?end) = xsd:gYear, CONCAT(SUBSTR(STR(?end), 1, 4), "-12-31"), ""))) AS ?endTo)
BIND (COALESCE(?status, "") IN ("active", "recurrence", "relapse") AS ?keepsGoing)
BIND (BOUND(?onset) AS ?dated)
BIND (IF(?endTo != "" && ?endTo >= ?from, ?endTo, IF(?keepsGoing, "9999-12-31", ?onsetTo)) AS ?to)
BIND (!(?endTo != "" && ?endTo >= ?from) && !?keepsGoing AS ?open)
} }
{ SELECT ?otherRecord ?otherEntry ?property ?code ?otherDated ?otherFrom ?otherTo ?otherOpen
WHERE {
VALUES ?property { cascade:conditionCode }
?otherRecord cascade:recordKind "Condition" ; pav:hasCurrentVersion ?otherVersion ; ^cascade:entryMember ?otherEntry .
?otherVersion ?property ?code .
OPTIONAL { ?otherVersion cascade:displayDate ?otherOnset }
OPTIONAL { ?otherVersion cascade:abatementDate ?otherEnd }
OPTIONAL { ?otherVersion cascade:clinicalStatus ?otherStatus }
BIND (IF(DATATYPE(?otherOnset) = xsd:gYear, CONCAT(SUBSTR(STR(?otherOnset), 1, 4), "-01-01"),
IF(DATATYPE(?otherOnset) = xsd:gYearMonth, CONCAT(SUBSTR(STR(?otherOnset), 1, 7), "-01"), SUBSTR(STR(?otherOnset), 1, 10))) AS ?otherFrom)
BIND (IF(DATATYPE(?otherOnset) = xsd:gYear, CONCAT(SUBSTR(STR(?otherOnset), 1, 4), "-12-31"),
IF(DATATYPE(?otherOnset) = xsd:gYearMonth, CONCAT(SUBSTR(STR(?otherOnset), 1, 7), "-31"), SUBSTR(STR(?otherOnset), 1, 10))) AS ?otherOnsetTo)
BIND (IF(BOUND(?otherEnd) && isLiteral(?otherEnd) && DATATYPE(?otherEnd) IN (xsd:date, xsd:dateTime), SUBSTR(STR(?otherEnd), 1, 10),
IF(BOUND(?otherEnd) && isLiteral(?otherEnd) && DATATYPE(?otherEnd) = xsd:gYearMonth, CONCAT(SUBSTR(STR(?otherEnd), 1, 7), "-31"),
IF(BOUND(?otherEnd) && isLiteral(?otherEnd) && DATATYPE(?otherEnd) = xsd:gYear, CONCAT(SUBSTR(STR(?otherEnd), 1, 4), "-12-31"), ""))) AS ?otherEndTo)
BIND (COALESCE(?otherStatus, "") IN ("active", "recurrence", "relapse") AS ?otherKeepsGoing)
BIND (BOUND(?otherOnset) AS ?otherDated)
BIND (IF(?otherEndTo != "" && ?otherEndTo >= ?otherFrom, ?otherEndTo, IF(?otherKeepsGoing, "9999-12-31", ?otherOnsetTo)) AS ?otherTo)
BIND (!(?otherEndTo != "" && ?otherEndTo >= ?otherFrom) && !?otherKeepsGoing AS ?otherOpen)
} }
MINUS { ?record cascade:currentlyDifferent ?otherRecord }
FILTER (STR(?record) < STR(?otherRecord) && ?entry != ?otherEntry
&& (!?dated || !?otherDated || (?open && ?from <= ?otherTo) || (?otherOpen && ?otherFrom <= ?to)))
BIND ("same code, dates cannot tell" AS ?needs)
OPTIONAL { ?entry rdfs:label ?entryLabel }
OPTIONAL { ?record rdfs:label ?recordLabel }
OPTIONAL { ?otherRecord rdfs:label ?otherRecordLabel } }
UNION
{ VALUES ?codeProperty { cascade:rxNormCode cascade:ndcCode }
?version ?codeProperty ?code .
?otherVersion ?codeProperty ?code .
?record cascade:recordKind "Medication" ; pav:hasCurrentVersion ?version ; ^cascade:entryMember ?entry .
?otherRecord cascade:recordKind "Medication" ; pav:hasCurrentVersion ?otherVersion ; ^cascade:entryMember ?otherEntry .
FILTER (STR(?record) < STR(?otherRecord) && ?entry != ?otherEntry)
MINUS { ?record cascade:currentlyDifferent ?otherRecord }
MINUS { ?lapsed cascade:lapsed true ; prov:hadMember ?record , ?otherRecord }
BIND ("possibly the same medication" AS ?needs)
OPTIONAL { ?entry rdfs:label ?entryLabel }
OPTIONAL { ?record rdfs:label ?recordLabel }
OPTIONAL { ?otherRecord rdfs:label ?otherRecordLabel } }
UNION
{ ?judgment cascade:countsUnderLens true ; cascade:verdict cascade:Same ; cascade:justification cascade:SameResultOnOneDay ;
prov:hadMember ?member .
?member ^cascade:entryMember ?entry .
BIND ("joined on one day, with no time to tell two draws apart" AS ?needs)
OPTIONAL { ?entry rdfs:label ?entryLabel }
OPTIONAL { ?judgment rdfs:label ?judgmentLabel } }
UNION
{ VALUES (?kind ?needs) {
(cascade:DifferentResultValuesAtOneInstant "one test at one instant, two values")
(cascade:DifferentResultUnitsAtOneInstant "one test at one instant, in units that differ")
}
?finding oa:hasBody ?kind ; oa:hasTarget ?record , ?otherRecord ; prov:wasDerivedFrom ?version , ?otherVersion .
?record pav:hasCurrentVersion ?version ; ^cascade:entryMember ?entry .
?otherRecord pav:hasCurrentVersion ?otherVersion .
FILTER (STR(?record) < STR(?otherRecord))
MINUS { ?record cascade:currentlyDifferent ?otherRecord }
MINUS { ?acknowledgement cascade:countsUnderLens true ; cascade:verdict cascade:Acknowledged ;
cascade:answersWarningOfKind ?kind ; prov:hadMember ?record , ?otherRecord .
FILTER NOT EXISTS { ?acknowledgement prov:hadMember ?third . FILTER (?third NOT IN (?record, ?otherRecord)) } }
MINUS { ?same cascade:countsUnderLens true ; cascade:verdict cascade:Same ; prov:hadMember ?record , ?otherRecord .
FILTER NOT EXISTS { ?same prov:wasAttributedTo/a prov:SoftwareAgent } }
MINUS { ?certain cascade:countsUnderLens true ; cascade:verdict cascade:Same ;
cascade:justification cascade:SameBusinessIdentifierAndTestCodeWithinOneOrganization ;
prov:hadMember ?record , ?otherRecord , ?corrected .
?corrected pav:hasCurrentVersion/cascade:workflowStatus ?status .
FILTER (?corrected IN (?record, ?otherRecord) && ?status IN ("corrected", "amended")) }
OPTIONAL { ?entry rdfs:label ?entryLabel }
OPTIONAL { ?record rdfs:label ?recordLabel }
OPTIONAL { ?otherRecord rdfs:label ?otherRecordLabel } }
}
ORDER BY ?needs ?finding ?entryLabel ?entry ?judgment ?record ?otherRecord
Terms it reads
cascade:Acknowledged · cascade:Different · cascade:DifferentResultUnitsAtOneInstant · cascade:DifferentResultValuesAtOneInstant · cascade:MatcherJudgmentsNoLongerReached · cascade:Same · cascade:SameBusinessIdentifierAndTestCodeWithinOneOrganization · cascade:SameMedicationCode · cascade:SameNoteOrDocumentMasterIdentifier · cascade:SameNoteTypeAndText · cascade:SameNoteTypeAndTextGrownWithinOneOrganization · cascade:SameProductCode · cascade:SameResultOnOneDay · cascade:abatementDate · cascade:answersWarningOfKind · cascade:clinicalStatus · cascade:conditionCode · cascade:countsUnderLens · cascade:currentlyDifferent · cascade:displayDate · cascade:entryMember · cascade:justification · cascade:lapsed · cascade:ndcCode · cascade:recordKind · cascade:rxNormCode · cascade:verdict · oa:hasBody · oa:hasTarget · pav:hasCurrentVersion · prov:SoftwareAgent · prov:hadMember · prov:wasAttributedTo · prov:wasDerivedFrom · rdfs:label
Rules and decision notes that name it
- Medication matching: which copies are one medication decisions/medication-matching.md
Its rows on Alex Rivera's pod
2 rows, as Alex Rivera's explorer shows them.
| entry | needs |
|---|---|
| Immunization entry · Influenza, injectable, quadrivalent, preservative free · 2025-10-15 | joined through two kinds of machine sameness |
| Allergy entry · Sulfamethoxazole | members disagree on criticality |