Skip to content

error fetching HAPI open FHIR R4 server? #145

@DiTo97

Description

@DiTo97

Hello,

when I try to the fetch the HAPI open FHIR R4 server using the latest version of the library:

from fhirclient import client
from fhirclient.models import patient


settings = {
    "app_id": "fhir",
    "api_base": "https://hapi.fhir.org/baseR4"
}


smart = client.FHIRClient(settings=settings)

if not smart.prepare():
    # TODO: authorize
    pass

assert smart.ready is True

search_patients = patient.Patient.where(
      struct={"active": "true"}
)

patients = search_patients.perform_resources(smart.server)

if patients:
    print(patients[0].birthDate.isostring)
    print(smart.human_name(patients[0].name[0]))

I get the following error in the response due to the formatting of the FHIR resource itself:

FHIRValidationError: {root}:
  entry.5:
    resource:
      text:
        'Non-optional property "div" on <fhirclient.models.narrative.Narrative object at 0x7f11a1d31ff0> is missing'

I guess the error comes from the built-in pydantic validation, but is there a way to filter out all the responses matching the search pattern that violate the validation, while still letting all the others through, instead of blocking them all?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions