Skip to main content

No project description provided

Project description

Metriport Python Library

pypi fern shield

Documentation

API reference documentation is available here.

Installation

Add this dependency to your project's build file:

pip install metriport
# or
poetry add metriport

Usage

import os
from dotenv import load_dotenv
from metriport.client import Metriport
from metriport.medical import BasePatient, PersonalIdentifier_DriversLicense
from metriport.commons import Address, UsState

load_dotenv()

facility_id = os.environ.get("FACILITY_ID")
api_key = os.environ.get("API_KEY")
base_url = os.environ.get("BASE_URL") ## optional param to base to client if want to point to sandbox url.

client = Metriport(api_key=api_key)
patient_data = BasePatient(
    first_name="John",
    last_name="Doe",
    dob="1980-01-01",
    gender_at_birth="M",
    personal_identifiers=[
        PersonalIdentifier_DriversLicense(
            type="driversLicense",
            state=UsState.CA,
            value="12345678",
        )
    ],
    address=[Address(
        address_line_1="123 Main St",
        city="Los Angeles",
        state=UsState.CA,
        zip="90001",
        country="USA"
    )]
)
response = client.medical.patient.create(facility_id=facility_id, request=patient_data)

Async Client

Our Python SDK exports an async client that you can use with asyncio.

import os
from dotenv import load_dotenv
from metriport.client import AsyncMetriport
from metriport.medical import BasePatient, PersonalIdentifier_DriversLicense
from metriport.commons import Address, UsState
import asyncio

load_dotenv()

facility_id = os.environ.get("FACILITY_ID")
api_key = os.environ.get("API_KEY")

metriport_client = AsyncMetriport(api_key="YOUR_API_KEY")

async def create_patient():
  patient_data = BasePatient(
    first_name="John",
    last_name="Doe",
    dob="1980-01-01",
    gender_at_birth="M",
    personal_identifiers=[
        PersonalIdentifier_DriversLicense(
            type="driversLicense",
            state=UsState.CA,
            value="12345678",
        )
    ],
    address=[Address(
        address_line_1="123 Main St",
        city="Los Angeles",
        state=UsState.CA,
        zip="90001",
        country="USA"
    )]
  )
  response = client.medical.patient.create(facility_id=facility_id, request=patient_data)

asyncio.run(create_patient())

Error Handling

All exceptions thrown by the SDK will sublcass ApiError.

from metriport.core import ApiError

try:
  client.medical.patient.create(facility_id='bad_id', request="bad_req")
except ApiError as e:  
  print(e) 
  # handle any api related error

Timeouts

By default, the client is configured to have a timeout of 60 seconds. You can customize this value at client instantiation.

from metriport.client import Metriport

metriport_client = Metriport(api_key="YOUR_API_KEY", timeout=15)

Beta status

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version in your pyproject.toml file. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

            ,▄,
          ▄▓███▌
      ▄▀╙   ▀▓▀    ²▄
    ▄└               ╙▌
  ,▀                   ╨▄
  ▌                     ║
                         ▌
                         ▌
,▓██▄                 ╔███▄
╙███▌                 ▀███▀
    ▀▄
      ▀╗▄         ,▄
         '╙▀▀▀▀▀╙''


      by Metriport Inc.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metriport-8.0.2b0.tar.gz (447.6 kB view details)

Uploaded Source

Built Distribution

metriport-8.0.2b0-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file metriport-8.0.2b0.tar.gz.

File metadata

  • Download URL: metriport-8.0.2b0.tar.gz
  • Upload date:
  • Size: 447.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1054-azure

File hashes

Hashes for metriport-8.0.2b0.tar.gz
Algorithm Hash digest
SHA256 5bc75d25bede2a13cb7ed303dce9e633d7c4e4fea44fb900ac745d7c214dbf2b
MD5 74fb5876420d3a8c28e43815033fcb60
BLAKE2b-256 30863da93b3a475f0aa670c5d64b3664e8d116eec63c9e2ddd91c550def6e95e

See more details on using hashes here.

File details

Details for the file metriport-8.0.2b0-py3-none-any.whl.

File metadata

  • Download URL: metriport-8.0.2b0-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1054-azure

File hashes

Hashes for metriport-8.0.2b0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e46180d302c68bfab37c30752b3c7dac287b97f74cef774cfa0352363223b27
MD5 da2ae8987b20201a20945fe7d66a0ad1
BLAKE2b-256 a4750445b76b8f5166e6717616e809399ecb8055e8608c517098fc036ad40999

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page