Smart on fhir python client
Project description
smart-on-fhir-client 🔥
Package allowing to request a fhir server with the smart-on-fhir protocol.
ℹ Warning
It is not a webserver providing a webserver with a callback url usually involved in the smart-on-fhir procedure
Tutorial
First, we will need to create a partner. We can do this easily subclassing the Partner
class.
import os
from smart_on_fhir_client.partner import Partner
from typing import Set
from smart_on_fhir_client.strategy import Strategy
class Lifen(Partner):
name = 'LIFEN'
supported_strategies: Set[Strategy] = {Strategy.M2M}
client_id: str = os.getenv("LIFEN_CLIENT_ID")
client_secret: str = os.getenv("LIFEN_CLIENT_SECRET")
token_url: str = ... # set the token url
fhir_url: str = ... # set the fhir url
# additional information
audience: str = ... # audience
database_reference: str = ... # optional
grant_type: str = "client_credentials" # set the credentials
LIFEN = Lifen()
from smart_on_fhir_client.client import smart_client_factory
from smart_on_fhir_client.requester.fhir_requester import fhir_client_manager
from smart_on_fhir_client.strategy import Strategy
# set up your own fhir server url
fhir_client_manager.set_own_fhir_url("http://localhost:8080/fhir")
async def register():
async with smart_client_factory:
await fhir_client_manager.register_partner_async(
smart_client_factory.builder()
.for_partner(LIFEN)
.for_strategy(Strategy.M2M)
# you can register special classes for specific fhir resources
.register_cls_for('Patient', LifenPatientResource)
)
first_patient = await fhir_client_manager.LIFEN.Patient.search().limit(10).first()
await first_patient.pipe_to_target_fhir_server()
Features
Allow to send some fetched fhir resources to another fhir server
via the pipe_to_target_fhir_server
, making data transfer between two fhir
servers easier.
Notes
Work based heavily on fhir-py and fhir-resources python packages
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
smart-on-fhir-client-1.0.0.tar.gz
(11.7 kB
view hashes)
Built Distribution
Close
Hashes for smart-on-fhir-client-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63070a2d955b8611b3e5017a6dddb1df70ffcada50e0c3d4e6ed876419a48747 |
|
MD5 | 701773774438ec551fea1cf21f324adc |
|
BLAKE2b-256 | 40fb8838dedcac19e071c6e6fc3cb6a8d83df0c7ed948d2a2ec01e7100b3df27 |
Close
Hashes for smart_on_fhir_client-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efc6496ed94deaf4687f6a274c9407f13d30252250fa6190ff891463ea30da25 |
|
MD5 | 941d23649bf1770a7e5d220329af9a06 |
|
BLAKE2b-256 | 2c4a692745015236c08c86b75e33f7c06615b6f9b9a01d2be31915c5866f41da |