Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to fix Azure FHIR service import failure #123515

Open
BGDSW opened this issue Jun 25, 2024 · 3 comments
Open

How to fix Azure FHIR service import failure #123515

BGDSW opened this issue Jun 25, 2024 · 3 comments

Comments

@BGDSW
Copy link

BGDSW commented Jun 25, 2024

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.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

@PesalaPavan
Copy link
Contributor

@BGDSW
It would be great if you could add a link to the documentation you are following for these steps? This would help us redirect the issue to the appropriate team. Thanks!!

@BGDSW
Copy link
Author

BGDSW commented Jun 25, 2024

@PesalaPavan
Thank you for your reply. I am following this document.
https://learn.microsoft.com/en-us/azure/healthcare-apis/fhir/import-data

@PesalaPavan
Copy link
Contributor

@BGDSW
Thanks for your feedback! I've assigned this issue to the author who will investigate and update as appropriate.

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

No branches or pull requests

4 participants
@EXPEkesheth @BGDSW @PesalaPavan and others