Skip to content

MedConBCollection

Retrieve Codelists for use in Phenex from a MedConB Collection. Codelists are accessed by name, and the collection name is specified when initializing the factory.

Example:

from medconb_client import Client
endpoint = "https://api.medconb.example.com/graphql/"
token = get_token()
client = Client(endpoint, token)
medconb_factory = MedConBCollection(client, "my_collection")

phenex_codelist = medconb_factory.get_codelist(
    name="atrial_fibrillation"
)

Source code in phenex/codelists/factory.py
class MedConBCollection:
    """
    Retrieve Codelists for use in Phenex from a MedConB Collection. Codelists are accessed by name, and the collection name is specified when initializing the factory.

    Example:
    ```python
    from medconb_client import Client
    endpoint = "https://api.medconb.example.com/graphql/"
    token = get_token()
    client = Client(endpoint, token)
    medconb_factory = MedConBCollection(client, "my_collection")

    phenex_codelist = medconb_factory.get_codelist(
        name="atrial_fibrillation"
    )
    ```
    """

    def __init__(self, medconb_client: "Client", collection_name: str):
        self.medconb_client = medconb_client
        self.collection_name = collection_name

    def get_codelist(self, name: str):
        medconb_codelist = self.medconb_client.get_codelist_by_name(
            codelist_name=name,
            codelist_collection_name=self.collection_name,
        )
        return Codelist.from_medconb(medconb_codelist)