Skip to content

MedConB Client

Build Status Documentation Checked with mypy Code style: black Linting: Ruff

This library provides a Python interface to the MedConB API. With this you can easily retrieve whole codelists from MedConB.

Installation

You can install (and update) it into your python environment by running:

pip install --force-reinstall -U medconb-client

Usage

To use it, you need to create a client:

from medconb_client import Client

endpoint = "https://api.medconb.example.com/graphql/"
token = get_token()

client = Client(endpoint, token)

with that client you can now interact with the API.

Get a codelist by name

codelist = client.get_codelist_by_name(
    codelist_name="Coronary Artery Disease",
    codelist_collection_name="Pacific AF [Sample]",
)
codelist = client.get_codelist_by_name(
    codelist_name="Coronary Artery Disease",
    phenotype_collection_name="[Sample] PACIFIC AF ECA",
    phenotype_name="Coronary Artery Disease",
)

Get a codelist by id

codelist = client.get_codelist(
    codelist_id="9c4ad312-3008-4d95-9b16-6f9b21ec1ad9"
)

Retrieve collections in your workspace

workspace_info = client.get_workspace()

collection_info = next(
    collection
    for collection in workspace_info.collections
    if collection.itemType == "Codelist"
)

codelist = client.get_codelist(collection_info.items[0].id)

For more information, also see our Examples Page.