In [ ]:
import pysolr
# Connect to Solr instance.
solr = pysolr.Solr('http://192.168.99.100:8983/solr/radiology')
# query for pulmonary embolism
solrquery = '(REASON_t:pe OR REASON_t:pes OR (REASON_t:pul* AND REASON_t:embo*)) OR (IMPRESSION_t:pul* AND IMPRESSION_t:embo*)'
# just impression
# solrquery = 'IMPRESSION_t:pul* AND IMPRESSION_t:embo*'
# just reason
# solrquery = 'REASON_t:pe OR REASON_t:pes OR (REASON_t:pul* AND REASON_t:embo*)'
counter = 0
missing = 0
page = 0
rows = 100
peList = []
while True:
params = {
'rows': rows,
'start': page * rows,
'sort': 'ROW_ID_i asc',
}
results = solr.search(solrquery, **params)
for result in results:
#peList.append(result['id'])
if 'REASON_t' in result.keys():
print(result['id'], 'REASON_t:', result['REASON_t'])
_ = 1
elif 'IMPRESSION_t' in result.keys():
print(result['id'], 'IMPRESSION_t:', result['IMPRESSION_t'])
_ = 1
else:
print(result['id'], '---------------------- no reason nor impression -------------------')
missing += 1
counter += 1
page += 1
if results.hits < (page * rows):
break
print('PE Records Found:', counter)
print('Missing reason/impression:', missing)
'''
from random import shuffle
x = [[i] for i in peList]
shuffle(x)
for i in x:
print(i)
'''
In [ ]:
import pysolr
# Connect to Solr instance.
solr = pysolr.Solr('http://192.168.99.100:8983/solr/radiology')
# query for PAH
solrquery = '{!complexphrase inOrder=true}IMPRESSION_t:"pul* hype*" OR IMPRESSION_t:"pul* art* hyp*" OR REASON_t:"pul* htn" OR REASON_t:"pul* hype*" OR REASON_t:"pul* art* hyp*" OR REASON_t:pah'
# just reason
#solrquery = '{!complexphrase inOrder=true}REASON_t:"pul* htn" OR REASON_t:"pul* hype*" OR REASON_t:"pul* art* hyp*" OR REASON_t:pah'
# just impression
#solrquery = '{!complexphrase inOrder=true}IMPRESSION_t:"pul* hype*" OR IMPRESSION_t:"pul* art* hyp*"'
# this will get items such as pulmonary venous hypertension which is left side rather than right side...
### solrquery = 'IMPRESSION_t:"pulmonary hypertension"~2'
counter = 0
missing = 0
page = 0
rows = 100
while True:
params = {
'rows': rows,
'start': page * rows,
'sort': 'ROW_ID_i asc',
}
results = solr.search(solrquery, **params)
for result in results:
if 'REASON_t' in result.keys():
print(result['id'], 'REASON_t:', result['REASON_t'])
_ = 1
elif 'IMPRESSION_t' in result.keys():
print(result['id'], 'IMPRESSION_t:', result['IMPRESSION_t'])
_ = 1
else:
print(result['id'], '---------------------- no reason nor impression -------------------')
missing += 1
counter += 1
page += 1
if results.hits < (page * rows):
break
print('PAH Records Found:', counter)
print('Missing reason/impression:', missing)
In [ ]: