Skip to main content

Cumulus FHIR Support

This library holds FHIR support code for the Cumulus project as a whole.

Installing

pip install cumulus-fhir-support

API

list_multiline_json_in_dir

Lists available multiline JSON files in the target directory (allowing filtering by FHIR resource).

Files with the .jsonl or .ndjson suffixes are supported. Files with an additional .gz suffix will also be returned.

import cumulus_fhir_support as cfs

cfs.list_multiline_json_in_dir("/")
# {
#     "/con1.ndjson.gz": "Condition",
#     "/pat1.jsonl": "Patient",
#     "/random.jsonl": None,
# }

cfs.list_multiline_json_in_dir("/", "Patient")
# {
#     "/pat1.jsonl": "Patient",
# }

cfs.list_multiline_json_in_dir("/", ["Condition", "Patient"])
# {
#     "/con1.ndjson.gz": "Condition",
#     "/pat1.jsonl": "Patient",
# }

cfs.list_multiline_json_in_dir("/does-not-exist/")
# {}

cfs.list_multiline_json_in_dir("s3://mybucket/", fsspec_fs=s3_fs)
# {
#     "/mybucket/procs.ndjson": "Procedure",
# }

read_multiline_json

Iterates over a single multiline JSON file.

Files with the .gz extension are automatically uncompressed.

import cumulus_fhir_support as cfs

list(cfs.read_multiline_json("/pat1.jsonl"))
# [
#     {"resourceType": "Patient", "id": "pat1", "birthDate": "2020-10-16"},
#     {"resourceType": "Patient", "id": "pat2", "birthDate": "2013-04-18"},
# ]

list(cfs.read_multiline_json("/does-not-exist.ndjson"))
# []

list(cfs.read_multiline_json("/mybucket/procs.ndjson", fsspec_fs=s3_fs))
# [
#     {"resourceType": "Procedure", "id": "proc1", "status": "stopped"},
# ]

read_multiline_json_with_details

Lower level function to iterate over a single multiline JSON file, with extra line metadata.

Files with the .gz extension are automatically uncompressed.

import cumulus_fhir_support as cfs

list(cfs.read_multiline_json_with_details("/pat1.jsonl"))
# [
#     {
#         "json": {"resourceType": "Patient", "id": "pat1", "birthDate": "2020-10-16"},
#         "line_num": 0,
#         "byte_offset": 0,
#     },
#     {
#         "json": {"resourceType": "Patient", "id": "pat2", "birthDate": "2013-04-18"},
#         "line_num": 1,
#         "byte_offset": 69,
#     },
# ]

list(cfs.read_multiline_json_with_details("/pat1.jsonl"), offset=69)
# [
#     {
#         "json": {"resourceType": "Patient", "id": "pat2", "birthDate": "2013-04-18"},
#         "line_num": 0,
#         "byte_offset": 0,
#     },
# ]

read_multiline_json_from_dir

Iterates over every JSON object in a directory (allowing filtering by FHIR resource).

Files with the .gz extension are automatically uncompressed.

import cumulus_fhir_support as cfs

list(cfs.read_multiline_json_from_dir("/"))
# [
#     {"resourceType": "Condition", "id": "con1", "onsetDateTime": "2011-11-24"},
#     {"resourceType": "Patient", "id": "pat1", "birthDate": "2020-10-16"},
#     {"resourceType": "Patient", "id": "pat2", "birthDate": "2013-04-18"},
#     {"description": "not a fhir object"},
# ]

list(cfs.read_multiline_json_from_dir("/", "Condition"))
# [
#     {"resourceType": "Condition", "id": "con1", "onsetDateTime": "2011-11-24"},
# ]

list(cfs.read_multiline_json_from_dir("/", ["Condition", "Patient"]))
# [
#     {"resourceType": "Condition", "id": "con1", "onsetDateTime": "2011-11-24"},
#     {"resourceType": "Patient", "id": "pat1", "birthDate": "2020-10-16"},
#     {"resourceType": "Patient", "id": "pat2", "birthDate": "2013-04-18"},
# ]

list(cfs.read_multiline_json_from_dir("/does-not-exist/"))
# []

list(cfs.read_multiline_json_from_dir("/mybucket/", fsspec_fs=s3_fs))
# [
#     {"resourceType": "Procedure", "id": "proc1", "status": "stopped"},
# ]

pyarrow_schema_from_rows

Calculates a schema that can cover a given collection of FHIR objects.

import cumulus_fhir_support as cfs

rows = [
    {
        "resourceType": "Patient",
        "id": "1",
        "extension": [{
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
            "extension": [{
                "url": "ombCategory",
                "valueCoding": {
                    "code": "2135-2",
                    "display": "Hispanic or Latino",
                    "system": "urn:oid:2.16.840.1.113883.6.238",
                },
            }],
        }],
    },
]

# The resulting schema will be both wide (every toplevel column)
# and deep enough for every field in `rows`.
# That is, both the non-present toplevel field "telecom" and the deeper
# field "extension.extension.valueCoding.system" will be in the schema.
schema = cfs.pyarrow_schema_from_rows("Patient", rows)

FhirClient

Connect to a FHIR server with a variety of authentication options and retries built-in.

import cumulus_fhir_support as cfs

client = cfs.FhirClient("https://r4.smarthealthit.org", {"Patient"})

async with client:
    response = await client.request("GET", "Patient/2cda5aad-e409-4070-9a15-e1c35c46ed5a")
    print(response.json())

Metadata

Release files for cumulus-fhir-support 1.12.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cumulus-fhir-support 1.12.4
File Size Uploaded Provenance Actions
cumulus_fhir_support-1.12.4.tar.gz 53.5 kB With provenance Details for cumulus_fhir_support-1.12.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cumulus-fhir-support 1.12.4
File Interpreter ABI Platform Actions
cumulus_fhir_support-1.12.4-py3-none-any.whl Python 3 none any Details for cumulus_fhir_support-1.12.4-py3-none-any.whl

Total release size: 91.9 kB

Release files / cumulus_fhir_support-1.12.4.tar.gz

Download URL cumulus_fhir_support-1.12.4.tar.gz
Size 53.5 kB
Tags Source
SHA-256 checksum
How to use checksums
eee3d5cf36cfd0d7d38cd5082df858e5938a962eda5df78cd4e2929daac90c71
BLAKE2b-256 checksum
How to use checksums
5464595b64e2d33667e8273688ac5f5153b466786bf5436f61a971216bf08c39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / cumulus_fhir_support-1.12.4-py3-none-any.whl

Download URL cumulus_fhir_support-1.12.4-py3-none-any.whl
Size 38.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85964e3657899af1884f47e0f387d5cf1728f6b8992aa76ea1fa41b3cc3a53e3
BLAKE2b-256 checksum
How to use checksums
77ec6f5f29d863eeda6bc5ea5db341a7e53e72e43924393935d67990bef1f662
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for cumulus-fhir-support 1.12.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cumulus_fhir_support-1.12.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page