# cogstack/dbt_mimic_omop architecture

> Architecture diagram of the GitHub repository cogstack/dbt_mimic_omop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cogstack/dbt_mimic_omop
- Repository: https://github.com/cogstack/dbt_mimic_omop

## Overview

This repository converts MIMIC-IV into OMOP CDM tables with dbt, with optional note NLP and MIMIC-CXR imaging extensions. Users load clinical CSVs, vocabularies, and optionally imaging metadata into DuckDB, then run dbt to produce cleaned/mapped intermediate data and gold tables. The graph preserves the documented clinical, vocabulary, note, imaging, and metrics branches. SQL model relationships are not asserted individually because their contents were not sampled; edges reflect only loader code and README statements.

Main entry points: [`models/gold`](https://github.com/cogstack/dbt_mimic_omop/tree/main/models/gold) (OMOP CDM models), [`load_mimic_to_duckdb.py`](https://github.com/cogstack/dbt_mimic_omop/blob/main/load_mimic_to_duckdb.py) (MIMIC loader), [`load_vocabularies_to_duckdb.py`](https://github.com/cogstack/dbt_mimic_omop/blob/main/load_vocabularies_to_duckdb.py) (Vocabulary loader), [`load_mimic_cxr_to_duckdb.py`](https://github.com/cogstack/dbt_mimic_omop/blob/main/load_mimic_cxr_to_duckdb.py) (CXR loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Data loading"]
  node_mimic_data["MIMIC-IV files"]
  node_vocabulary_files["Vocabulary files"]
  node_cxr_files["CXR metadata"]
  node_mimic_loader["MIMIC loader"]
  node_vocab_loader["Vocabulary loader"]
  node_cxr_loader["CXR loader"]
  node_duckdb[("DuckDB database")]
end

subgraph group_transform["dbt transformation"]
  node_silver["Staging and mapping"]
end

subgraph group_clinical["Clinical outputs"]
  node_gold["OMOP CDM models"]
  node_vocabulary["Vocabulary tables"]
end

subgraph group_extensions["Extensions and metrics"]
  node_notes["Notes and NLP"]
  node_cxr_models["Imaging extension"]
  node_image_outputs["Image tables"]
  node_metrics["Summary metrics"]
end

node_user(("Pipeline user"))

node_user -->|"loads data"| node_mimic_loader
node_user -->|"loads data"| node_vocab_loader
node_user -.->|"optionally loads"| node_cxr_loader
node_mimic_data -->|"reads CSVs"| node_mimic_loader
node_vocabulary_files -->|"reads CSVs"| node_vocab_loader
node_cxr_files -->|"reads CSVs"| node_cxr_loader
node_mimic_loader -->|"writes tables"| node_duckdb
node_vocab_loader -->|"writes tables"| node_duckdb
node_cxr_loader -->|"writes tables"| node_duckdb
node_user -->|"runs dbt"| node_silver
node_silver -->|"builds CDM"| node_gold
node_gold -->|"includes vocabularies"| node_vocabulary
node_gold -->|"includes notes"| node_notes
node_user -.->|"optionally selects"| node_cxr_models
node_cxr_models -->|"produces imaging tables"| node_image_outputs
node_user -->|"optionally runs"| node_metrics

click node_mimic_data "https://github.com/cogstack/dbt_mimic_omop/tree/main/data/mimic"
click node_vocabulary_files "https://github.com/cogstack/dbt_mimic_omop/tree/main/data/custom_mappings"
click node_cxr_files "https://github.com/cogstack/dbt_mimic_omop/tree/main/data/mimic_cxr"
click node_mimic_loader "https://github.com/cogstack/dbt_mimic_omop/blob/main/load_mimic_to_duckdb.py"
click node_vocab_loader "https://github.com/cogstack/dbt_mimic_omop/blob/main/load_vocabularies_to_duckdb.py"
click node_cxr_loader "https://github.com/cogstack/dbt_mimic_omop/blob/main/load_mimic_cxr_to_duckdb.py"
click node_silver "https://github.com/cogstack/dbt_mimic_omop/tree/main/models/silver"
click node_gold "https://github.com/cogstack/dbt_mimic_omop/tree/main/models/gold"
click node_vocabulary "https://github.com/cogstack/dbt_mimic_omop/tree/main/models/gold/vocabulary"
click node_notes "https://github.com/cogstack/dbt_mimic_omop/tree/main/models/gold/note"
click node_cxr_models "https://github.com/cogstack/dbt_mimic_omop/tree/main/models/silver/mimic_cxr"
click node_image_outputs "https://github.com/cogstack/dbt_mimic_omop/tree/main/models/gold/image_occurrence"
click node_metrics "https://github.com/cogstack/dbt_mimic_omop/tree/main/models/gold/metrics"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mimic_data,node_vocabulary_files,node_cxr_files,node_mimic_loader,node_vocab_loader,node_cxr_loader,node_duckdb,node_user toneBlue
class node_silver toneAmber
class node_gold,node_vocabulary toneMint
class node_notes,node_cxr_models,node_image_outputs,node_metrics toneRose
```

## Components

### Data loading

- [MIMIC-IV files](https://github.com/cogstack/dbt_mimic_omop/tree/main/data/mimic): `data/mimic`
- [Vocabulary files](https://github.com/cogstack/dbt_mimic_omop/tree/main/data/custom_mappings): `data/custom_mappings`
- [CXR metadata](https://github.com/cogstack/dbt_mimic_omop/tree/main/data/mimic_cxr): `data/mimic_cxr`
- [MIMIC loader](https://github.com/cogstack/dbt_mimic_omop/blob/main/load_mimic_to_duckdb.py): `load_mimic_to_duckdb.py`
- [Vocabulary loader](https://github.com/cogstack/dbt_mimic_omop/blob/main/load_vocabularies_to_duckdb.py): `load_vocabularies_to_duckdb.py`
- [CXR loader](https://github.com/cogstack/dbt_mimic_omop/blob/main/load_mimic_cxr_to_duckdb.py): `load_mimic_cxr_to_duckdb.py`
- **DuckDB database**

### dbt transformation

- [Staging and mapping](https://github.com/cogstack/dbt_mimic_omop/tree/main/models/silver): `models/silver`

### Clinical outputs

- [OMOP CDM models](https://github.com/cogstack/dbt_mimic_omop/tree/main/models/gold): `models/gold`
- [Vocabulary tables](https://github.com/cogstack/dbt_mimic_omop/tree/main/models/gold/vocabulary): `models/gold/vocabulary`

### Extensions and metrics

- [Notes and NLP](https://github.com/cogstack/dbt_mimic_omop/tree/main/models/gold/note): `models/gold/note`
- [Imaging extension](https://github.com/cogstack/dbt_mimic_omop/tree/main/models/silver/mimic_cxr): `models/silver/mimic_cxr`
- [Image tables](https://github.com/cogstack/dbt_mimic_omop/tree/main/models/gold/image_occurrence): `models/gold/image_occurrence`
- [Summary metrics](https://github.com/cogstack/dbt_mimic_omop/tree/main/models/gold/metrics): `models/gold/metrics`

### Other components

- **Pipeline user**

## Connections

- Pipeline user → MIMIC loader: loads data (evidence: `README.md`)
- Pipeline user → Vocabulary loader: loads data (evidence: `README.md`)
- Pipeline user → CXR loader: optionally loads (evidence: `README.md`)
- MIMIC-IV files → MIMIC loader: reads CSVs (evidence: `load_mimic_to_duckdb.py`)
- Vocabulary files → Vocabulary loader: reads CSVs (evidence: `load_vocabularies_to_duckdb.py`)
- CXR metadata → CXR loader: reads CSVs (evidence: `load_mimic_cxr_to_duckdb.py`)
- MIMIC loader → DuckDB database: writes tables (evidence: `load_mimic_to_duckdb.py`)
- Vocabulary loader → DuckDB database: writes tables (evidence: `load_vocabularies_to_duckdb.py`)
- CXR loader → DuckDB database: writes tables (evidence: `load_mimic_cxr_to_duckdb.py`)
- Pipeline user → Staging and mapping: runs dbt (evidence: `README.md`)
- Staging and mapping → OMOP CDM models: builds CDM (evidence: `README.md`)
- OMOP CDM models → Vocabulary tables: includes vocabularies (evidence: `README.md`)
- OMOP CDM models → Notes and NLP: includes notes (evidence: `README.md`)
- Pipeline user → Imaging extension: optionally selects (evidence: `README.md`)
- Imaging extension → Image tables: produces imaging tables (evidence: `README.md`)
- Pipeline user → Summary metrics: optionally runs (evidence: `README.md`)
