mypy-boto3-healthlake

1.42.3 · active · verified Sat Apr 11

mypy-boto3-healthlake provides type annotations for the boto3 HealthLake service. It enhances development with static type checking for AWS SDK for Python (boto3) code, catching potential errors early. The current version is 1.42.3, and new versions are released frequently, typically in lockstep with botocore/boto3 updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a type-hinted HealthLake client, create a FHIR datastore, and list existing datastores. It leverages `mypy-boto3-healthlake` for precise type checking of client methods and request/response TypeDefs.

import boto3
import os
from mypy_boto3_healthlake.client import HealthLakeClient
from mypy_boto3_healthlake.type_defs import CreateFHIRDatastoreRequestRequestTypeDef

# Use os.environ.get for quickstart to satisfy auth check
aws_region = os.environ.get("AWS_REGION", "us-east-1")
datastore_name = "my-healthlake-datastore-example"
datastore_type = "R4"  # or "STU3"

client: HealthLakeClient = boto3.client("healthlake", region_name=aws_region)

request_params: CreateFHIRDatastoreRequestRequestTypeDef = {
    "DatastoreName": datastore_name,
    "DatastoreType": datastore_type
}

try:
    # In a real application, you might add tags or other configurations
    response = client.create_fhir_datastore(**request_params)
    print(f"Datastore creation initiated: {response['DatastoreId']} with status {response['DatastoreStatus']}")
    # Wait for the datastore to be active if needed
    # client.get_waiter('datastore_created').wait(DatastoreId=response['DatastoreId'])
except client.exceptions.ConflictException:
    print(f"Datastore '{datastore_name}' already exists.")
except Exception as e:
    print(f"An error occurred: {e}")

# Example of listing datastores
print("\nListing HealthLake Datastores:")
response = client.list_fhir_datastores()
for ds in response.get("Datastores", []):
    print(f"- {ds['DatastoreName']} ({ds['DatastoreStatus']})")

view raw JSON →