smart-on-fhir-client


Namesmart-on-fhir-client JSON
Version 1.0.4 PyPI version JSON
download
home_page
SummarySmart on fhir python client
upload_time2022-12-12 10:19:38
maintainer
docs_urlNone
authorMarc
requires_python>=3.10,<4.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.
```python
import os
from smart_on_fhir_client.partner import Partner
from smart_on_fhir_client.strategy import Strategy

class OauthFHIRProvider(Partner):
    name = 'PROVIDER'
    supported_strategies: set[Strategy] = {Strategy.M2M}
    client_id: str = os.getenv("PROVIDER_CLIENT_ID")
    client_secret: str = os.getenv("PROVIDER_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

FHIR_PROVIDER = OauthFHIRProvider()
```

```python
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_fhir_client_async(
            smart_client_factory.builder()
            .for_partner(FHIR_PROVIDER)
            .for_strategy(Strategy.M2M)
            # you can register special classes for specific fhir resources
            .register_cls_for('Patient', CustomPatientResource)
        )
        first_patient = await fhir_client_manager.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


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "smart-on-fhir-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Marc",
    "author_email": "marc@synapse-medicine.com",
    "download_url": "https://files.pythonhosted.org/packages/a7/2e/4c0371c0e639b758a4eecc3753d5b97954d94a21b175668c01245cd1c29a/smart_on_fhir_client-1.0.4.tar.gz",
    "platform": null,
    "description": "# smart-on-fhir-client \ud83d\udd25\n\nPackage allowing to request a fhir server with the smart-on-fhir protocol. \n\n> \u2139 Warning\n>\n> It is not a webserver providing a webserver with a callback url\n> usually involved in the smart-on-fhir procedure\n\n\n### Tutorial\n\nFirst, we will need to create a partner. We can do this easily subclassing the `Partner` class.\n```python\nimport os\nfrom smart_on_fhir_client.partner import Partner\nfrom smart_on_fhir_client.strategy import Strategy\n\nclass OauthFHIRProvider(Partner):\n    name = 'PROVIDER'\n    supported_strategies: set[Strategy] = {Strategy.M2M}\n    client_id: str = os.getenv(\"PROVIDER_CLIENT_ID\")\n    client_secret: str = os.getenv(\"PROVIDER_CLIENT_SECRET\")\n    token_url: str = ... # set the token url\n    fhir_url: str = ... # set the fhir url\n\n    # additional information\n    audience: str = ... # audience\n    database_reference: str = ... # optional \n    grant_type: str = \"client_credentials\" # set the credentials\n\nFHIR_PROVIDER = OauthFHIRProvider()\n```\n\n```python\nfrom smart_on_fhir_client.client import smart_client_factory\nfrom smart_on_fhir_client.requester.fhir_requester import fhir_client_manager\nfrom smart_on_fhir_client.strategy import Strategy\n\n# set up your own fhir server url\nfhir_client_manager.set_own_fhir_url(\"http://localhost:8080/fhir\")\n\n\nasync def register():\n    async with smart_client_factory:\n        await fhir_client_manager.register_fhir_client_async(\n            smart_client_factory.builder()\n            .for_partner(FHIR_PROVIDER)\n            .for_strategy(Strategy.M2M)\n            # you can register special classes for specific fhir resources\n            .register_cls_for('Patient', CustomPatientResource)\n        )\n        first_patient = await fhir_client_manager.patient.search().limit(10).first()\n        await first_patient.pipe_to_target_fhir_server()\n\n```\n\n\n### Features\n\nAllow to send some fetched fhir resources to another fhir server\nvia the `pipe_to_target_fhir_server`, making data transfer between two fhir\nservers easier.\n\n### Notes\nWork based heavily on fhir-py and fhir-resources python packages\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Smart on fhir python client",
    "version": "1.0.4",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "71a638a3dfe3b359725d4807ae69b9b3",
                "sha256": "7ab677e20fa2d76cc6ffd160cc6cf1e922f8073261bb2acf2deeb12095b0ccd5"
            },
            "downloads": -1,
            "filename": "smart_on_fhir_client-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "71a638a3dfe3b359725d4807ae69b9b3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 14473,
            "upload_time": "2022-12-12T10:19:35",
            "upload_time_iso_8601": "2022-12-12T10:19:35.912062Z",
            "url": "https://files.pythonhosted.org/packages/15/ad/e9839f9f56caea424741d1ff39564c57b5b7deb08dad205a3ee6d1cf99c4/smart_on_fhir_client-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "5b04a5cae193469087222b7cbdd87a3d",
                "sha256": "7422a89278d73503e64b2992a3f864c9651a52981bb8c4732a1d5dacf5bfae43"
            },
            "downloads": -1,
            "filename": "smart_on_fhir_client-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "5b04a5cae193469087222b7cbdd87a3d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 12302,
            "upload_time": "2022-12-12T10:19:38",
            "upload_time_iso_8601": "2022-12-12T10:19:38.096616Z",
            "url": "https://files.pythonhosted.org/packages/a7/2e/4c0371c0e639b758a4eecc3753d5b97954d94a21b175668c01245cd1c29a/smart_on_fhir_client-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-12 10:19:38",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "smart-on-fhir-client"
}
        
Elapsed time: 0.01690s