Azure Health Data Services
An Azure offering that provides a suite of purpose-built technologies for protected health information in the cloud.
167 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am using $import operation to import data into Azure FHIR service. I am using ndjson format. Part of my code is below:
def import_data2FHIR(access_token, file_info):
# Azure FHIR service URL
fhir_service_url = "https://<my_fhir_service>.fhir.azurehealthcareapis.com"
# Set up the headers with the token
headers = {
"Authorization": f"Bearer {access_token}",
'Prefer': 'respond-async',
'Content-Type': 'application/fhir+json'
}
# Example FHIR resource (Patient)
fhir_resource = {
"resourceType": "Parameters",
"parameter": [
{
"name": "inputFormat",
"valueString": "application/fhir+ndjson"
},
{
"name": "mode",
"valueString": "InitialLoad",
},
{
"name": "input",
"part": [
{
"name": "url",
"valueUri": file_info["url"]
},
{
"name": "etag",
"valueUri": file_info["etag"]
}
]
}
]
}
# POST the FHIR resource to the FHIR server
response = requests.post(f"{fhir_service_url}/$import", json=fhir_resource, headers=headers)
# Check the response
if response.status_code == 201:
print("Resource created successfully")
print("Response:", response.json())
else:
print("Failed to create resource")
print("Status Code:", response.status_code)
print("Response:", response.json())
if __name__ == "__main__":
access_token = get_token() # I get my access token successfully
file_info = {"url": "https://<my_storage_account>.blob.core.windows.net/tmp-file-system/my-directory/patient-fhir-data-2019Jul10-0903.ndjson",
"etag": "0x8DC9402319782B2"}
import_data2FHIR(access_token, file_info8)
<my_fhir_service> has been already assigned to Contributor and Storage Blob Data Contributor role to <my_storage_account>. But I got status code 202 with error:
Traceback (most recent call last):
File "D:\code_for_python\FHIR_service_import.py", line 112, in <module>
import_data2FHIR(access_token, file_info8)
File "D:\code_for_python\FHIR_service_import.py", line 85, in import_data2FHIR
print("Response:", response.json())
File "D:\anaconda3\envs\Epic\lib\site-packages\requests\models.py", line 978, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Would you please help how to troubleshoot this issue? I really appreciate your help.