def main(): endpoint = 'https://ncpi-api-fhir-service-dev.kidsfirstdrc.org' # Create an instance client = SyncFHIRClient(endpoint) # Search for patients resources = client.resources('Patient') resources = resources.search(gender='female').limit(1000) patients = resources.fetch() print("# of patients:{}".format(len(patients)))
def main(): endpoint = 'https://ncpi-api-fhir-service-dev.kidsfirstdrc.org' full_cookie_path = os.path.expanduser('~/.keys/kf_cookies.json') print(full_cookie_path) with open(full_cookie_path) as f: cookies = json.load(f) client = SyncFHIRClient(endpoint, extra_headers=cookies) # Search for patients resources = client.resources('Patient') resources = resources.search(gender='female').limit(10) patients = resources.fetch() print("# of patients:{}".format(len(patients)))
def main(): endpoint = 'https://ncpi-api-fhir-service-dev.kidsfirstdrc.org' full_cookie_path = os.path.expanduser('~/.keys/kf_cookies.json') print(full_cookie_path) with open(full_cookie_path) as f: cookies = json.load(f) client = SyncFHIRClient(endpoint, extra_headers=cookies) document_references = client.resources("DocumentReference") document_references.search(_profile='http://fhir.ncpi-project-forge.io/StructureDefinition/ncpi-drs-document-reference') drs_ids = document_references.fetch() print("# of ids:{}".format(len(drs_ids))) for d in drs_ids: print(d['content'][0]['attachment']['url'])
from fhirpy import SyncFHIRClient from fhir.resources.patient import Patient from fhir.resources.observation import Observation from fhir.resources.humanname import HumanName from fhir.resources.contactpoint import ContactPoint import json client = SyncFHIRClient( url='https://dh9fytkn0e.execute-api.eu-west-2.amazonaws.com/dev', extra_headers={ "x-api-key": "EzAVxFOjEqagIbYVHK2Mz7RUp1GOpRHMVTTxVQk9", "Authorization": "eyJraWQiOiJ2ZXZ0cUNYZitiUzNBM3hNWm5IVFhRbDlucTFZaDloRzJZNkxVXC94bTd0ST0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJmOWU4YmI3OC04MjRlLTRhZGQtOTZjNS1iZjVmMGY3YTlkNTUiLCJjb2duaXRvOmdyb3VwcyI6WyJwcmFjdGl0aW9uZXIiXSwiZW1haWxfdmVyaWZpZWQiOnRydWUsImlzcyI6Imh0dHBzOlwvXC9jb2duaXRvLWlkcC5ldS13ZXN0LTIuYW1hem9uYXdzLmNvbVwvZXUtd2VzdC0yX0JiTkFoUTVzTSIsImNvZ25pdG86dXNlcm5hbWUiOiJmaGlyYXBpdGVzdCIsIm9yaWdpbl9qdGkiOiIxZWQ0NmU1NS1jNmE1LTQ3MjMtYTEyZi04OTYzOWQzZGVjYWMiLCJhdWQiOiIxdXJkaWlmZjJlbWMzcGgzamdiZ3AxYm43ayIsImV2ZW50X2lkIjoiYjQ4MDM0NjctMjRjYy00OWZlLTg3NTYtNTgzZDEzNDZmOGE3IiwidG9rZW5fdXNlIjoiaWQiLCJhdXRoX3RpbWUiOjE2NTgyNDQ0MDUsImV4cCI6MTY1ODMzMDgwNSwiaWF0IjoxNjU4MjQ0NDA1LCJqdGkiOiJjNjJkNTc3Zi01NWJmLTQwNjQtYjYwOC0xMzA1MTQ1ODM0M2QiLCJlbWFpbCI6ImFsbWE1Lm5oc2RAZ21haWwuY29tIn0.XxflQNEL_N8XWut2MxGNTZfnjei4qCsbvEBs31n1RMemY9DneEU1haYGGaHp4T3CyBy2-eLeaDbfI16dhEnh_5D6qSgRoMPWv5ScZop2uvoqujkufsp-C6lZsRtetyowETrcaSs46jvumqzpONUO5F5i7UdEg2lh9N0iKfUi67MepgMy9gBJMZkKQhTl6S0BRNHfyGhUT5kbN2EeFeDltiSOaDZKk7IbRoUO0OnZYNFcqmDNAjPYzLFKNnYyGcsMlPSKZaULHt3P7EhAS-e5EOG5c8-Sqp7fPOZ3cpq2QHr5RF4hZcyZiUwoyYoeW4_MDvhkdew2tdnyEsFQHwuO2g" }) patients_resources = client.resources('Patient') patient0 = Patient.parse_obj( patients_resources.search(family='Jameson', given='Matt').first().serialize()) print("Our paitent:", patient0.name)
def __init__(self, fhir_server, fhir_port, split='train', input_size=256): """ Args: fhir_server (string): Address of FHIR Server. fhir_port (string): Port of FHIR Server. """ self.fhir_server = fhir_server self.fhir_port = fhir_port self.split = split self.input_size = input_size # Create an instance client = SyncFHIRClient('http://{}:{}/fhir'.format( fhir_server, fhir_port)) # Search for patients patients = client.resources('Patient') # Return lazy search set patients_data = [] for patient in patients: patient_birthDate = None try: patient_birthDate = patient.birthDate except: pass # patinet_id, gender, birthDate patients_data.append( [patient.id, patient.gender, patient_birthDate]) patients_df = pd.DataFrame( patients_data, columns=["patient_id", "gender", "birthDate"]) # Search for media media_list = client.resources('Media').include('Patient', 'subject') media_data = [] for media in media_list: media_bodySite = None media_reasonCode = None media_note = None try: media_bodySite = media.bodySite.text except: pass try: media_reasonCode = media.reasonCode[0].text except: pass try: media_note = media.note[0].text except: pass media_data.append([ media.subject.id, media.id, media_bodySite, media_reasonCode, media_note, media.content.url ]) media_df = pd.DataFrame(media_data, columns=[ "patient_id", "media_id", "bodySite", "reasonCode", "note", "image_url" ]) self.data_df = pd.merge(patients_df, media_df, on='patient_id', how='outer') self.data_df = self.data_df[self.data_df['note'].notna()].reset_index() self.trans = transforms.Compose([ transforms.RandomHorizontalFlip(), transforms.RandomVerticalFlip(), transforms.ColorJitter(brightness=32. / 255., saturation=0.5), transforms.Resize(self.input_size), transforms.ToTensor() ])
## Load aggregated results from previous stations # if run_id > 0: # prev_experiment_dir = osp.join(out_dir, 'run_{}'.format(str(run_id - 1))) # if osp.exists(osp.join(prev_experiment_dir, '')): # pass # else: # pass # else: # pass ## Collect Data Statistic # Create an instance client = SyncFHIRClient('http://{}:{}/fhir'.format(fhir_server, fhir_port)) # Search for patients patients = client.resources('Patient') # Return lazy search set patients_data = [] for patient in patients: patient_birthDate = None try: patient_birthDate = patient.birthDate except: pass # patinet_id, gender, birthDate patients_data.append([patient.id, patient.gender, patient_birthDate]) patients_df = pd.DataFrame(patients_data, columns=["patient_id", "gender", "birthDate"]) # Search for media media_list = client.resources('Media').include('Patient', 'subject') media_data = [] for media in media_list: