Skip to main content

Getting Started

Download our Python client to get started.

Installation​

To install the Plasma FHIR Client into your project

pip install plasma-fhir-client-py

Or you may want to try it this way

pip install --no-cache-dir --upgrade plasma-fhir-client-py

Initialize the Plasma FHIR Client​

The Plasma FHIR Client is a module that helps you to communicate with a FHIR server. To initialize the client, we need two pieces of information:

  • Location of the FHIR server
  • Information about how to authenticate requests

There are multiple ways to initialize the client depending on your use case.


Initialization via Plasma​

Using Plasma to connect and initialize the Plasma FHIR Client is the recommended way to use the library, as it will provide you access to the Plasma engine and all of the cross-platform and convenient configuration management capabilities.

Initializing for Backend Application​

from plasma_fhir_client_py import PlasmaPlatformClient

plasma_base_url = "https://plasma.smart-on-fhir.com"
project_id = "my-project-id"
env_id = "my-evironment-id-for-example-epic"
project_secret = "my-project-secret"
plasma: PlasmaFHIRClient = await PlasmaPlatformClient.for_backend(plasma_base_url, project_id, env_id, project_secret)

Initialization via FHIR Server​

You can also use the Plasma FHIR Client to connect to a FHIR server without using Plasma. A few different methods are described below.

Initializing for Open Server (No Authentication)​

If you are working with an open server that does not require authentication (such as the SMART Health IT Sandbox):

from plasma_fhir_client_py import PlasmaPlatformClient

fhirUrl = "http://.../r4"
plasma = PlasmaPlatformClient.for_no_auth(fhirUrl)

Initializing for Basic Auth​

from plasma_fhir_client_py import PlasmaPlatformClient

fhirUrl = "http://.../r4"
plasma = PlasmaPlatformClient.for_basic_auth(fhirUrl, "my-user", "my-password")

Initializing for OAuth2 (with existing token)​

If you are using OAuth2 and already have an existing token, you can initialize the client with the code below. We describe additional modules that can help with requesting a token in a later section.

from plasma_fhir_client_py import PlasmaPlatformClient

fhirUrl = "http://.../r4"
plasma = PlasmaPlatformClient.for_bearer_token(fhirUrl, "my-user", "my-password")