Search code examples
hl7-fhirfhir-server-for-azure

Bulk Import Request for FHIR


https://github.com/smart-on-fhir/bulk-import/blob/master/import.md

I used above link for reference and tried to run import using the following code

import requests

url = "https://<fhir-server-name>.azurehealthcareapis.com/$import"

payload = "{\r\n\t\"inputFormat\": \"application/fhir+ndjson\",\r\n\t\"inputSource\": \"https://localhost\",\r\n\t\"storageDetail\": { \"type\": \"https\" },\r\n\t\"input\": [\r\n\t{\r\n\t\t\"type\": \"Patient\",\r\n\t\t\"url\": \"https://localhost/patient_ndjson.ndjson\"\r\n\t}\r\n\t]\r\n}"
headers = {
  'Accept': 'application/fhir+json',
  'Prefer': 'respond-async',
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <Auth Token>'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))

i am receiving 400 Bad Request . i tried posting to both

url = "https://<fhir-server-name>.azurehealthcareapis.com/$import"
url = "https://<fhir-server-name>.azurehealthcareapis.com/Patient/$import"

I used apache for hosting the file and the file is accessible with both http and https.. Instead of importing it using http server, is there any way to directly point to my local ndjson file ?

patient_ndjson.ndjson contains

{"resourceType":"Patient","id":"8c76dfe7-2b94-497b-9837-8315b150ac0e","meta":{"versionId":"1","lastUpdated":"2020-04-27T11:08:10.611+00:00"},"active":true,"name":[{"use":"official","family":"p000001"}],"gender":"female","birthDate":"2020-04-27T11:00:00+05:30"}
{"resourceType":"Patient","id":"bfab05c7-d36a-4b5a-a0d6-6efb1da0fb3d","meta":{"versionId":"1","lastUpdated":"2020-04-27T11:34:43.83+00:00"},"active":true,"name":[{"use":"official","family":"p000001"}],"gender":"female","birthDate":"2020-04-27T11:00:00+05:30"}
{"resourceType":"Patient","id":"4c314eb1-6309-424b-affc-197fb0131cf6","meta":{"versionId":"1","lastUpdated":"2020-04-27T12:09:20.777+00:00"},"active":true,"name":[{"use":"official","family":"p000002"}],"gender":"female","birthDate":"2020-04-27T03:00:00+05:30"}

Can you please provide some sample request . it would be helpful.


Solution

  • $import is a draft spec and it is not supported (yet) on the Azure API for FHIR.