Skip to content

Instantly share code, notes, and snippets.

@rajvansia
Created June 15, 2020 00:08
Show Gist options
  • Save rajvansia/a73812dc902c84a15959025ebfdb7b72 to your computer and use it in GitHub Desktop.
Save rajvansia/a73812dc902c84a15959025ebfdb7b72 to your computer and use it in GitHub Desktop.
import json
import os
import requests
#fhir server endpoint
URL = "http://localhost:8080/hapi-fhir-jpaserver/fhir/"
#fhir server json header content
headers = {"Content-Type": "application/fhir+json;charset=utf-8"}
#loop over all files in the output folder in order to upload each json file for each patient.
for dirpath, dirnames, files in os.walk('/Users/rajvansia/Documents/GitHub/synthea/output/fhir'):
for file_name in files:
with open('/Users/rajvansia/Documents/GitHub/synthea/output/fhir/'+file_name, "r") as bundle_file:
data = bundle_file.read()
r = requests.post(url = URL, data = data, headers = headers)
#output file name that was processed
print(file_name)
@rafamayo
Copy link

Thanks. This saved my day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment