Aidbox client for python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
aidbox
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

aidbox-py

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

API

To create Aidbox instance use:

Aidbox(url, authorization)

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

  • .reference(resourceType, id, **kwargs) - returns AidboxReference to the resource
  • .resource(resourceType, **kwargs) - returns AidboxResource which described below
  • .resources(resourceType) - returns AidboxSearchSet

AidboxResource

provides:

  • .save() - creates or updates resource instance
  • .delete() - deletes resource instance
  • .to_reference(**kwargs) - returns AidboxReference for this resource
  • setattr/getattr using dot operator

AidboxReference

provides:

  • .to_resource() - returns AidboxResource for this reference

AidboxSearchSet

provides:

  • .search(param=value)
  • .limit(count)
  • .page(page)
  • .sort(*args)
  • .elements(*args, exclude=False)
  • .include(resourceType, attr)
  • .execute() - makes query to the server and returns a list of AidboxResource
  • .first() - returns AidboxResource or None
  • .get(id=id) - returns AidboxResource or raises AidboxResourceNotFound

Usage

Create an instance

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

Fetch list of resource's instances

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

resources.execute()  # Returns list of AidboxResource

Get the particular instance of resource

res = ab.resources('Entity').get(id='ID')

Create new resource's instance

res = ab.resource('Entity')
res.name = 'Chat'
res.save()  # Creates new instance

res.name = 'Chat2'
res.save()  # Updates the instance

res.delete()  # Deletes the instance