query-7dec9ef652902d0bba931e2c12cbbc86
ICD10 handling, case of "oncology". Output consists of items without "medical specialty" and indicated class 2, initial C, or D followed by 0, ..., 4. SELECT DISTINCT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q12136 . ?item wdt:P494 ?icd . OPTIONAL { ?item wdt:P1995 ?dummy0 } FILTER(!bound(?dummy0)) BIND(SUBSTR(?icd,1,2) AS ?icd1) FILTER REGEX(?icd1,'C|D') BIND(SUBSTR(?icd,2,3) AS ?number) BIND(CONCAT("1",?number) AS ?number1) BIND(xsd:integer(?number1) AS ?number2) FILTER (STRSTARTS(?icd1, 'C')||(99 < ?number2 && ?number2 < 150)) SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } }
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#ICD10 handling, case of "oncology". Output consists of items without "medical specialty" and indicated class 2, initial C, or D followed by 0, ..., 4.
SELECT DISTINCT ?item ?itemLabel
WHERE {
?item wdt:P31 wd:Q12136 .
?item wdt:P494 ?icd .
OPTIONAL { ?item wdt:P1995 ?dummy0 }
FILTER(!bound(?dummy0))
BIND(SUBSTR(?icd,1,2) AS ?icd1)
FILTER REGEX(?icd1,'C|D')
BIND(SUBSTR(?icd,2,3) AS ?number)
BIND(CONCAT("1",?number) AS ?number1)
BIND(xsd:integer(?number1) AS ?number2)
FILTER (STRSTARTS(?icd1, 'C')||(99 < ?number2 && ?number2 < 150))
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?dummy0")
v5("?icd")
v6("?icd1")
v4("?item"):::projected
v6("?number")
v7("?number1")
v8("?number2")
c10(["bd:serviceParam"]):::iri
c12(["en"]):::literal
c6(["wd:Q12136"]):::iri
f0[["(starts-with(?icd1,'C') || '99^^xsd:integer' < ?number2?number2 < '150^^xsd:integer')"]]
f0 --> v6
f0 --> v8
f1[["regex(?icd1,'C|D')"]]
f1 --> v6
f2[["not bound(?dummy0)"]]
f2 --> v3
v4 --"wdt:P31"--> c6
v4 --"wdt:P494"--> v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P1995".-> v3
end
bind3[/"substring(?icd,'1^^xsd:integer','2^^xsd:integer')"/]
v5 --o bind3
bind3 --as--o v6
bind4[/"substring(?icd,'2^^xsd:integer','3^^xsd:integer')"/]
v5 --o bind4
bind4 --as--o v6
bind5[/"concat('1',?number)"/]
v6 --o bind5
bind5 --as--o v7
bind6[/"http://www.w3.org/2001/XMLSchema#integer(?number1)"/]
v7 --o bind6
bind6 --as--o v8
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end