FHIR Client for python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
fhirpy
jupyter-aidbox
tests
.gitignore
.travis.yml
CHANGELOG.md
LICENSE.md
MANIFEST.in
README.md
requirements.txt
setup.cfg
setup.py
tox.ini

README.md

Build Status codecov pypi

fhir-py

FHIR client for python. This package provides an API for CRUD operations over FHIR resources

API

Import library:

from fhirpy import FHIRClient

To create FHIR instance use:

FHIRClient(url, authorization='', version='3.0.1', without_cache=False)

Returns an instance of the connection to the server which provides:

  • .reference(resource_type, id, reference, **kwargs) - returns FHIRReference to the resource
  • .resource(resource_type, **kwargs) - returns FHIRResource which described below
  • .resources(resource_type) - returns FHIRSearchSet

FHIRResource

provides:

  • .save() - creates or updates resource instance
  • .delete() - deletes resource instance
  • .to_reference(**kwargs) - returns FHIRReference for this resource

FHIRReference

provides:

  • .to_resource(nocache=False) - returns FHIRResource for this reference

FHIRSearchSet

provides:

  • .search(param=value)
  • .limit(count)
  • .page(page)
  • .sort(*args)
  • .elements(*args, exclude=False)
  • .include(resource_type, attr)
  • .fetch() - makes query to the server and returns a list of FHIRResource
  • .fetch_all() - makes query to the server and returns a full list of FHIRResource
  • .first() - returns FHIRResource or None
  • .get(id=id) - returns FHIRResource or raises FHIRResourceNotFound

Usage

Create an instance

client = FHIRClient(url='http://path-to-fhir-server', authorization='Bearer TOKEN')

Fetch list of resource's instances

resources = client.resources('Patient')  # Return lazy search set
resources = resources.search(name='John').limit(10).page(2).sort('name')

resources.fetch()  # Returns list of FHIRResource

Get the particular instance of resource

res = client.resources('Patient').get(id='ID')