Skip to main content

FHIR client for python

Project description

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='', fhir_version='4.0.0', 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')

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

fhirpy-0.2.1.tar.gz (171.6 kB view hashes)

Uploaded Source

Built Distribution

fhirpy-0.2.1-py3-none-any.whl (182.7 kB view hashes)

Uploaded Python 3

Supported by

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