Charité Demo Source
===================

``charite_demo`` reads the public, fully synthetic CHARITÉ mock dataset: a set of
Parquet tables shaped like the Charité Health Data Platform, queried with an
in-process DuckDB. Its variable definitions are served by the public demo Concepts
API, so it runs without data access or an account. It is the source behind the
:doc:`../tutorials/charite_demo` tutorial and ``corr init --demo`` (:doc:`../cli`).

Installation
------------

.. code-block:: bash

   uv add "corr-vars[charite-demo]"     # or: pip install "corr-vars[charite-demo]"

The extra adds the comorbidity-score package some served definitions use.

Usage
-----

.. code-block:: python

   from corr_vars import Cohort

   cohort = Cohort(
       obs_level="icu_stay",
       sources={"charite_demo": {}},
       project="demo",
       api_key="cak_demo_0d2b53ac",   # public, read-only demo key
   )

By default the dataset is read straight from its URL; a query transfers only the
parts of the files it touches. For repeated work, download it once and pass the
folder as ``path``:

.. code-block:: python

   from corr_vars.sources.charite_demo import download

   path = download("~/data/charite_mockdata")
   cohort = Cohort(
       obs_level="icu_stay",
       sources={"charite_demo": {"path": path}},
       project="demo",
       api_key="cak_demo_0d2b53ac",
   )

Configuration
-------------

.. code-block:: python

   sources = {
       "charite_demo": {
           "path": "https://demo-data.corr.icu/v1",   # default; or a local folder
           "filter": {
               "extraction_start_date": "2020-01-01",
               "extraction_end_date": None,
               "include_adults_only": True,           # default
               "exclude_brain_death": True,           # default
           },
           "icu_stay": {
               "merge_consecutive": True,             # or "any" / "same_icu_only" / False
               "extra_columns": [],                   # e.g. ["room_number", "bed_number"]
           },
       }
   }

API Reference
-------------

.. currentmodule:: corr_vars.sources.charite_demo

.. autofunction:: download

.. currentmodule:: corr_vars.sources.charite_demo.cohort

.. autofunction:: load_data
