query-bb46ec4a29ff04530257dc907aef593e

rq turtle/ttl

ICD9 handling SELECT ?item ?itemLabel ?icd ?icd2 ?icd3 WHERE { ?item wdt:P31 wd:Q12136 . ?item wdt:P493 ?icd . BIND(SUBSTR(?icd,1,3) AS ?icd1) BIND(CONCAT("1",?icd1) AS ?icd2) BIND(xsd:integer(?icd2) AS ?icd3) FILTER(1000 < ?icd3 && ?icd3 <1139) SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } }

Use at

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#>
#ICD9 handling
SELECT ?item ?itemLabel ?icd ?icd2 ?icd3
WHERE {
 ?item wdt:P31 wd:Q12136 .
  ?item wdt:P493 ?icd  .
  BIND(SUBSTR(?icd,1,3) AS ?icd1)
  BIND(CONCAT("1",?icd1) AS ?icd2)
  BIND(xsd:integer(?icd2) AS ?icd3)
  FILTER(1000 < ?icd3 && ?icd3 <1139)
  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("?icd"):::projected v4("?icd1") v5("?icd2"):::projected v6("?icd3"):::projected v2("?item"):::projected c7(["bd:serviceParam"]):::iri c9(["en"]):::literal c4(["wd:Q12136"]):::iri f0[["'1000^^xsd:integer' < ?icd3?icd3 < '1139^^xsd:integer'"]] f0 --> v6 v2 --"wdt:P31"--> c4 v2 --"wdt:P493"--> v3 bind1[/"substring(?icd,'1^^xsd:integer','3^^xsd:integer')"/] v3 --o bind1 bind1 --as--o v4 bind2[/"concat('1',?icd1)"/] v4 --o bind2 bind2 --as--o v5 bind3[/"http://www.w3.org/2001/XMLSchema#integer(?icd2)"/] v5 --o bind3 bind3 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end