{"id":19664220,"url":"https://github.com/beda-software/aidbox-py","last_synced_at":"2025-04-28T21:33:18.801Z","repository":{"id":57408666,"uuid":"174103925","full_name":"beda-software/aidbox-py","owner":"beda-software","description":"Aidbox client for Aidbox FHIR server","archived":false,"fork":false,"pushed_at":"2023-11-25T15:36:54.000Z","size":44,"stargazers_count":6,"open_issues_count":3,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-07T11:48:30.749Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beda-software.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-06T08:29:50.000Z","updated_at":"2022-06-08T17:43:52.000Z","dependencies_parsed_at":"2022-09-26T17:10:22.229Z","dependency_job_id":null,"html_url":"https://github.com/beda-software/aidbox-py","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beda-software%2Faidbox-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beda-software%2Faidbox-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beda-software%2Faidbox-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beda-software%2Faidbox-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beda-software","download_url":"https://codeload.github.com/beda-software/aidbox-py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224133813,"owners_count":17261303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T16:16:59.668Z","updated_at":"2024-11-11T16:16:59.766Z","avatar_url":"https://github.com/beda-software.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/beda-software/aidbox-py.svg?branch=master)](https://travis-ci.org/beda-software/aidbox-py)\n[![codecov](https://codecov.io/gh/beda-software/aidbox-py/branch/master/graph/badge.svg)](https://codecov.io/gh/beda-software/aidbox-py)\n[![pypi](https://img.shields.io/pypi/v/aidboxpy.svg)](https://pypi.python.org/pypi/aidboxpy)\n\n# aidbox-py\nAidbox client for python.\nThis package provides an API for CRUD operations over Aidbox resources.\n\nThe library is based on [fhir-py](https://github.com/beda-software/fhir-py) and the main difference between libraries in our case is the way they represent resource references (read more about [differences](https://docs.aidbox.app/basic-concepts/aidbox-and-fhir-formats)).\n\nAidbox-py also going to support some Aidbox features like _assoc operation, AidboxQuery and so on.\n\nMost examples from [fhir-py readme](https://github.com/beda-software/fhir-py/blob/master/README.md) also work for aidbox-py (but you need to replace FHIR client with AsyncAidboxClient/SyncAidboxClient). See base aidbox-py example below.\n\n\n# Getting started\n## Install\nMost recent version:\n`pip install git+https://github.com/beda-software/aidbox-py.git`\nPyPi:\n`pip install aidboxpy`\n\n## Async example\n```Python\nimport asyncio\nfrom aidboxpy import AsyncAidboxClient\nfrom fhirpy.base.exceptions import (\n    OperationOutcome, ResourceNotFound, MultipleResourcesFound\n)\n\n\nasync def main():\n    # Create an instance\n    client = AsyncAidboxClient(\n        'http://localhost:8080',\n        authorization='Bearer TOKEN'\n    )\n\n    # Search for patients\n    resources = client.resources('Patient')  # Return lazy search set\n    resources = resources.search(name='John').limit(10).page(2).sort('name')\n    patients = await resources.fetch()  # Returns a list of AsyncAidboxResource\n\n    # Get exactly one resource\n    try:\n        patient = await client.resources('Practitioner') \\\n            .search(id='id').get()\n    except ResourceNotFound:\n        pass\n    except MultipleResourcesFound:\n        pass\n\n    # Validate resource\n    try:\n        await client.resource(\n            'Person',\n            custom_prop='123',\n            telecom=True\n        ).is_valid()\n    except OperationOutcome as e:\n        print('Error: {}'.format(e))\n\n    # Create Organization resource\n    organization = client.resource(\n        'Organization',\n        name='beda.software',\n        active=False\n    )\n    await organization.save()\n\n    # Get patient resource by reference and delete\n    patient_ref = client.reference('Patient', 'new_patient')\n    patient_res = await patient_ref.to_resource()\n    await patient_res.delete()\n\n    # Iterate over search set and change organization\n    org_resources = client.resources('Organization').search(active=False)\n    async for org_resource in org_resources:\n        org_resource['active'] = True\n        await org_resource.save()\n\n\nif __name__ == '__main__':\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n```\n\n\n# API\nImport library:\n\n`from aidboxpy import SyncAidboxClient`\n\nor\n\n`from aidboxpy import AsyncAidboxClient`\n\nTo create AidboxClient instance use:\n\n`SyncAidboxClient(url, authorization='', extra_headers={})`\n\nor\n\n`AsyncAidboxClient(url, authorization='', extra_headers={})`\n\nReturns an instance of the connection to the server which provides:\n* .reference(resource_type, id, reference, **kwargs) - returns `SyncAidboxReference`/`AsyncAidboxReference` to the resource\n* .resource(resource_type, **kwargs) - returns `SyncAidboxResource`/`AsyncAidboxResource` which described below\n* .resources(resource_type) - returns `SyncAidboxSearchSet`/`AsyncAidboxSearchSet`\n\n`SyncAidboxResource`/`AsyncAidboxResource`\n\nprovides:\n* .serialize() - serializes resource\n* .get_by_path(path, default=None) – gets the value at path of resource\n* .save() - creates or updates resource instance\n* .delete() - deletes resource instance\n* .to_reference(**kwargs) - returns  `SyncAidboxReference`/`AsyncAidboxReference` for this resource\n\n`SyncAidboxReference`/`AsyncAidboxReference`\n\nprovides:\n* .to_resource() - returns `SyncAidboxResource`/`AsyncAidboxResource` for this reference\n\n`SyncAidboxSearchSet`/`AsyncAidboxSearchSet`\n\nprovides:\n* .search(param=value)\n* .limit(count)\n* .page(page)\n* .sort(*args)\n* .elements(*args, exclude=False)\n* .include(resource_type, attr=None, recursive=False, iterate=False)\n* .revinclude(resource_type, attr=None, recursive=False, iterate=False)\n* .has(*args, **kwargs)\n* .assoc(elements)\n* `async` .fetch() - makes query to the server and returns a list of `Resource` filtered by resource type\n* `async` .fetch_all() - makes query to the server and returns a full list of `Resource` filtered by resource type\n* `async` .fetch_raw() - makes query to the server and returns a raw Bundle `Resource`\n* `async` .first() - returns `Resource` or None\n* `async` .get(id=None) - returns `Resource` or raises `ResourceNotFound` when no resource found or MultipleResourcesFound when more than one resource found (parameter 'id' is deprecated)\n* `async` .count() - makes query to the server and returns the total number of resources that match the SearchSet\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeda-software%2Faidbox-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeda-software%2Faidbox-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeda-software%2Faidbox-py/lists"}