Skip to main content

Generates synthetic FHIR resources.

Project description

codecov Pipeline PyPI version

:fire: FHIR Kindling

CRUD library for fhir servers, with resource validation and parsing powered by the pydantic models created by fhir.resources. More details in the Documentation.

Features

  • Create, Read, Update, Delete using a server's REST API
  • Bundle creation, validation and data management on a FHIR server via the REST API
  • Supports Hapi, Blaze and IBM FHIR servers

Installation

Install the package using pip:

pip install fhir_kindling --user

Usage

Connecting to a FHIR server

from fhir_kindling import FhirServer

# Connect with basic auth 
basic_auth_server = FhirServer("https://fhir.server/fhir", username="admin", password="admin")
# Connect with static token
token_server = FhirServer("https://fhir.server/fhir", token="your_token")

# Connect using oauth2/oidc
oidc_server = FhirServer("https://fhir.server/fhir", client_id="client_id", client_secret="secret", 
                         oidc_provider_url="url")

# Print the server's capability statement
print(basic_auth_server.capabilities)

Query resources from the server

from fhir_kindling import FhirServer
from fhir.resources.patient import Patient


# Connect using oauth2/oidc
oidc_server = FhirServer("https://fhir.server/fhir", client_id="client_id", client_secret="secret",
                         oidc_provider_url="url")

# query all patients on the server
query = oidc_server.query(Patient, output_format="json").all()
print(query.response)

# Query resources based on name of resource
query = oidc_server.query("Patient", output_format="json").all()
print(query.response)

CLI

With the virtual environment activated you can use the CLI directly in the terminal

CLI - Uploading a bundle to a server

fhir_kindling upload <path-to-bundle.json> --url <base-url-fhir-api> -u <username> -p <password> --token <token>

CLI - Querying a server

For an overview of the options of the CLI query command

fhir_kindling query --help

Examples

To query all instances of a resource use the -r option. This command queries all Patients from the server and stores the results as csv into the query_results.json file.

fhir_kindling query -r Patient --url <base-url-fhir-api> -u <username> -p <password> --token <token> -f "query_results.csv" -o csv

This example uses the -q option to execute a predefined url query string against the server and also stores the output as csv in a file called query_results.csv

fhir_kindling query -q "/MolecularSequence?patient.organization.name=DEMO_HIV&_format=json" --url <base-url-fhir-api> -u <username> -p <password> --token <token> -f "query_results.csv" -o csv

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Change Log

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

[0.3.0] - 2021-10-30

Response classes, reference parsing and basic xml support

Added

XML output format and resolving xml pagination. Response objects containig resources and references

Changed

Outsourced resolving of response pagination into response classes

Fixed

[0.2.0] - 2021-09-18

FHIR server and query API

Added

Classes for fhir servers and queries. Oauth2/OIDC support.

Changed

Moved location of cli

Fixed

[0.1.0] - 2021-08-24

Initial cli

Added

Changed

Fixed

Hashing order guarantees the right index of the query.json file in the hash

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fhir_kindling-0.4.0.tar.gz (37.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fhir_kindling-0.4.0-py2.py3-none-any.whl (33.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file fhir_kindling-0.4.0.tar.gz.

File metadata

  • Download URL: fhir_kindling-0.4.0.tar.gz
  • Upload date:
  • Size: 37.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for fhir_kindling-0.4.0.tar.gz
Algorithm Hash digest
SHA256 38ae817849dbf8c55ddd602fb43abfb9b85a16849faf23aba61bc32437abbe5b
MD5 ddd87da342b9dd1e7c0e1e32b9837015
BLAKE2b-256 21e6367b97c37732f2246a3a5e345754a6819aebb5953c4e89dd14ba0067182a

See more details on using hashes here.

File details

Details for the file fhir_kindling-0.4.0-py2.py3-none-any.whl.

File metadata

  • Download URL: fhir_kindling-0.4.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for fhir_kindling-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6b55e70522e0189a20c8604e319adf05665ff7e9f5d822f57c274380c05a8786
MD5 0c5158ca2e9c8b88ec1ff8ae28c60728
BLAKE2b-256 1b6fce8a6433a98f8c5e4cd459645b703a798a235011b508a3d7b162774fdb5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page