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 Tutorial: a first study on the Charité demo dataset tutorial and corr init --demo (The corr command line).

Installation#

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#

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:

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#

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#

corr_vars.sources.charite_demo.download(dest, base_url=None, tables=None)[source]#

Download the charite_demo dataset into a local folder.

Files already present are skipped: when the manifest records a sha256 for a file (manifest["files"][path]["sha256"]) the local copy must match it, otherwise its size must match the size the server reports. A partially downloaded file is resumed with a range request, so an interrupted download can simply be restarted, and every downloaded file is checked against its sha256 when the manifest has one.

The published file names carry a content hash, so a new release adds new files. Parquet files under the dataset’s own subfolder (<dest>/<dataset>/, e.g. charite_mockdata/) that the new manifest does not list are removed after the download; nothing outside that subfolder is touched. The folder gets its own manifest.json listing exactly the tables on disk.

The release also carries a validation set (manifest key validation, folder validation/: the generator’s parameters per ICU stay and case, fully synthetic) for checking concept implementations. Cohorts do not need it, so it is not downloaded; read it from the release URL if needed.

With tables, the download refreshes only those tables: the other tables of an existing local copy stay listed (as long as their files are present and match their recorded size and sha256), and only stale files of the requested tables are removed.

Every file path in the manifest must be a .parquet file under <dataset>/; a manifest listing any other path (absolute, with .., a backslash or a scheme) is rejected before anything is written.

from corr_vars.sources import charite_demo

path = charite_demo.download("~/data/charite_mockdata")
cohort = Cohort(obs_level="icu_stay", sources={"charite_demo": {"path": path}})
Parameters:
  • dest (str | Path) – Target folder (~ is expanded); created if needed.

  • base_url (str | None) – Dataset URL. Defaults to the published dataset.

  • tables (Iterable[str] | None) – Tables to download. Defaults to all.

Returns:

The absolute path of dest, usable as the source’s path.

Return type:

str

Raises:
  • ValueError – If base_url is not a URL, tables names a table the manifest does not list, or the manifest lists an unsafe file path.

  • ConnectionError – If the manifest cannot be fetched.

  • httpx.HTTPError – If a file cannot be downloaded or fails its checksum.

corr_vars.sources.charite_demo.cohort.load_data(obs_level, source_kwargs)[source]#

Build the cohort’s observation frame from the charite_demo dataset.

Parameters:
  • obs_level (ObsLevel) – Level of observation the frame is keyed at.

  • source_kwargs (SourceDict) – This source’s resolved configuration.

Returns:

One row per observation.

Return type:

pl.DataFrame

Raises:
  • NotImplementedError – For ObsLevel.PROCEDURE.

  • ValueError – For any other unsupported observation level.