Skip to content

SPARQL Queries

Guoqian Jiang edited this page Mar 25, 2020 · 13 revisions

Co-occurrence of Condition and Medication Instances

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fhir: <http://hl7.org/fhir/>
select ?codingsystemvalue ?codingcodevalue ?textvalue ?mcodingsystemvalue ?mcodingcodevalue ?mtextvalue where { 
    ?composition fhir:Composition.section ?section .
    ?section fhir:Composition.section.entry ?sectionentry .
    ?sectionentry fhir:link ?link .
    ?link rdf:type fhir:Condition .
    ?link fhir:Condition.code ?code .
    ?code fhir:CodeableConcept.coding ?coding .
    ?coding fhir:Coding.code ?codingcode .
    ?codingcode fhir:value ?codingcodevalue  .
    ?coding fhir:Coding.system ?codingsystem .
    ?codingsystem fhir:value ?codingsystemvalue .
    ?code fhir:CodeableConcept.text ?text .
    ?text fhir:value ?textvalue .
    ?section fhir:Composition.section.entry ?msectionentry .
    ?msectionentry fhir:link ?mlink .
    ?mlink rdf:type fhir:Medication .
    ?mlink fhir:Medication.code ?mcode .
    ?mcode fhir:CodeableConcept.coding ?mcoding .
    ?mcoding fhir:Coding.code ?mcodingcode .
    ?mcodingcode fhir:value ?mcodingcodevalue  .
    ?mcoding fhir:Coding.system ?mcodingsystem .
    ?mcodingsystem fhir:value ?mcodingsystemvalue .
    ?mcode fhir:CodeableConcept.text ?mtext .
    ?mtext fhir:value ?mtextvalue .    
    
    
} LIMIT 100

Top Condition Instances

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fhir: <http://hl7.org/fhir/>
select ?textvalue (count(?textvalue) AS ?count) where { 
	?s rdf:type fhir:Condition .
    ?s fhir:Condition.code ?code .
    ?code fhir:CodeableConcept.coding ?coding .
    ?coding fhir:Coding.code ?codingcode .
    ?codingcode fhir:value ?codingcodevalue  .
    ?coding fhir:Coding.system ?codingsystem .
    ?codingsystem fhir:value ?codingsystemvalue .
    ?code fhir:CodeableConcept.text ?text .
    ?text fhir:value ?textvalue .
    
} group by ?textvalue order by DESC(?count)
?textvalue	?count
infection	10154
disease	6185
influenza	4576
infections	3772
SARS	3402
MERS	3102
diseases	2919
infectious	2825
strains	2001
syndrome	1757
HIV	1663
strain	1437
pneumonia	1344
Influenza	995
cancer	911
Ebola	874
Infection	841
Disease	647
dengue	639
viral infection	636
exposure	633
hepatitis	627
virus infection	622
Infectious	613
H5N1	583
tumor	563
Syndrome	536
viral infections	530
adenovirus	503
severe acute respiratory syndrome	493
Middle East respiratory syndrome	483
Diseases	450
injury	446
respiratory infections	446
pneumoniae	432
H7N9	398
asthma	386
HBV	368
HSV	360
epidemic diarrhea	359
bronchitis	340
Infections	310
rabies	310
encephalitis	305
respiratory disease	303
avian influenza	295
malaria	295
Middle East Respiratory Syndrome	285
ARDS	283
respiratory tract infections	280

Top Medication Instances

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fhir: <http://hl7.org/fhir/>
select ?textvalue (count(?textvalue) AS ?count) where { 
	?s rdf:type fhir:Medication .
    ?s fhir:Medication.code ?code .
    ?code fhir:CodeableConcept.coding ?coding .
    ?coding fhir:Coding.code ?codingcode .
    ?codingcode fhir:value ?codingcodevalue  .
    ?coding fhir:Coding.system ?codingsystem .
    ?codingsystem fhir:value ?codingsystemvalue .
    ?code fhir:CodeableConcept.text ?text .
    ?text fhir:value ?textvalue .
    
} group by ?textvalue order by DESC(?count)
?textvalue	?count
Carbon Monoxide	1297
Amino Acids	882
Endopeptidases	652
Peptide Hydrolases	444
Immunoglobulin G	426
Escherichia coli	417
RNA	415
fig allergenic extract	386
rabies immune globulin, human	261
Polysaccharides	236
placebo	190
Immunoglobulins	186
Urban tradename	177
Influenza virus vaccine	137
Precise	136
Cysteine	134
Ferret brand of ferrous fumarate	133
Serine	131
inorganic phosphate	128
Adenosine Triphosphate	125
duck allergenic extract	119
Chloroquine	118
Mannose	111
Sodium	110
Ribavirin	104
Zinc	103
TRYPSIN	99
Quercetin	97
rabbit allergenic extract	94
Sodium Chloride	88
Calcium	87
Oseltamivir	85
Nitric Oxide	84
Glycyrrhizic Acid	82
Papain	81
Tyrosine	80
Niclosamide	79
Antifungal Agents	71
Saccharomyces cerevisiae	70
Alanine	69
Lactate	68
Collagen	67
Arginine	66
Hydrogen	66
Mucins	64
Diethylstilbestrol	63
Interferon Type II	63
Leader	62
Immunoglobulins, Intravenous	60
Potassium	60

List Procedure Instances

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fhir: <http://hl7.org/fhir/>
select ?textvalue (count(?textvalue) AS ?count) where { 
	?s rdf:type fhir:Procedure .
    ?s fhir:Procedure.code ?code .
    ?code fhir:CodeableConcept.coding ?coding .
    ?coding fhir:Coding.code ?codingcode .
    ?codingcode fhir:value ?codingcodevalue  .
    ?coding fhir:Coding.system ?codingsystem .
    ?codingsystem fhir:value ?codingsystemvalue .
    ?code fhir:CodeableConcept.text ?text .
    ?text fhir:value ?textvalue .
    
} group by ?textvalue order by DESC(?count)

Counts on Condition Instances

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fhir: <http://hl7.org/fhir/>
select (count(?s) AS ?count) where { 
	?s rdf:type fhir:Condition .
} 

Clone this wiki locally