Code Monkey home page Code Monkey logo

aidbox-python's Introduction

Aidbox-Py

Install

pip install git+https://github.com/Aidbox/aidbox-python

Auth

Environment has to contain three variables AIDBOX_URL, AIDBOX_CLIENT_USERNAME and AIDBOX_CLIENT_PASSWORD (username and password from aidbox basic client). It can be solved with code below that loads variables from the .env file.

from dotenv import load_dotenv
from os.path import join, dirname

dotenv_path = join(dirname(__file__), ".env")
load_dotenv(dotenv_path)

Example

from aidbox.resource.appointment import Appointment, Appointment_Participant
from aidbox.resource.patient import Patient
from aidbox.resource.practitioner import Practitioner
from aidbox.base import Reference, HumanName

import requests

patient = Patient(name=[HumanName(family="Bourne", given=["Jason"])])
practitioner = Practitioner(name=[HumanName(family="Smith", given=["John"])])

patient.save()
practitioner.save()

try:
    Appointment(
        status="booked",
        participant=[
            Appointment_Participant(
                status="accepted",
                actor=Reference(reference="Practitioner/" + (practitioner.id or "")),
            ),
            Appointment_Participant(
                status="accepted",
                actor=Reference(reference="Patient/" + (patient.id or "")),
            ),
        ],
    ).save()
except requests.exceptions.RequestException as e:
    if e.response is not None:
        print(e.response.json())

API

Save resource to aidbox .save()

from aidbox.resource.patient import Patient
from aidbox.base import HumanName

patient = Patient()
patient.name = [HumanName(family="Bourne", given=["Jason"])]

patient.save()

Delete resource by id .delete()

from aidbox.resource.patient import Patient

patient = Patient(id="patient-1")
patient.delete()

Get resource by id .from_id()

from aidbox.resource.patient import Patient

patient = Patient.from_id("patient-1")

Get resource list .get()

from aidbox.resource.patient import Patient
from aidbox.base import Page, Count, Sort, Where

patients = Patient.get(Where('active', True), Count(10), Page(3), Sort('created_at', 'desc'))

Authorized request to any of Aidbox endpoints .make_request()

from aidbox.base import API

API.make_request(endpoint="/AidboxTask", method="GET")

API.make_request(
    endpoint="/rpc",
    method="POST",
    json={
        "method": "awf.task/list",
        "params": { "filter": { "excludeDefinitions": ["awf.workflow/decision-task"] }},
    },
)

Serialize to JSON dumps()

from aidbox.resource.patient import Patient
from aidbox.base import Page, Count, Sort, Where

patient = Patient.from_id('patient-1')
patient_json = patient.dumps(exclude_unset=True)

Bundle .bundle()

from aidbox.base import API

entry = []

entry.append(
    {
        "resource": patient.dumps(exclude_unset=True),
        "request": {"method": "POST", "url": "Patient"},
    },
    {
        "resource": patient.dumps(exclude_unset=True),
        "request": {"method": "POST", "url": "Patient"},
    },
)

try:
    API.bundle(entry=entry, type="transaction")
except requests.exceptions.RequestException as e:
    if e.response is not None:
        print(e.response.json())

aidbox-python's People

Contributors

genarazmakhnin avatar letzabelin avatar randr97 avatar

Stargazers

Nikolaus Schlemm avatar Satyam Tiwary avatar

Watchers

Nikolai Ryzhikov avatar Maksym avatar Aleksandr Penskoi avatar Alexandra Pavlyshina avatar Farid Bagishev avatar Marat Surmashev avatar Igor Kislitsyn avatar Mike Ryzhikov avatar Vitaly Banchenko avatar Mikhail Kulakov avatar  avatar Alexander Streltsov avatar HealthSamurai Deployer Bot avatar Andrey Osipenko avatar  avatar Ivan Bagrov avatar

aidbox-python's Issues

License for aidbox-Py

Do you plan on providing a license for this package (MIT/GPL, etc)?

Thanks in advance.

The example in Readme is incorrect

Currentlly under example it shows

Example

from aidbox.resource.appointment import Appointment, Appointment_Participant
_from aidbox.resource import Patient, Practitioner_
from aidbox.base import Reference, HumanName

I this should be replaced with as this resource available in the packages within the resources 
----
from aidbox.resource.patient import Patient
from aidbox.resource.practitioner import Practitioner
----

Could you please update the readme ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.