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
Built Distribution
Close
Hashes for smart-on-fhir-client-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 801bfe01cec4f252b28c1ef69d609c5b20e4edbe2dd7a4a464121cd9a664e375 |
|
MD5 | 1f3c7b4526624769aa2dda4166dac241 |
|
BLAKE2b-256 | b33e1748bf450d39d88bfcd616f2a840e1ecfa23bd395f881ccbed76ccd877ca |
Close
Hashes for smart_on_fhir_client-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a62dadb308f46c61275a9f59349f59ec00b5e1545389defc6c7182502889b663 |
|
MD5 | 831eca3ca6a624fd53c71df713fd9e85 |
|
BLAKE2b-256 | 029f971818244b1fa7100c88bba163c7231db12d71daad7fcbf87cbb6a8a8f5d |