Skip to content

notebooks/Synthea.ipynb: rewrite as a real synthlab tutorial - #5

Merged
bschilder merged 2 commits into
mainfrom
migration/notebook-tutorial
May 16, 2026
Merged

notebooks/Synthea.ipynb: rewrite as a real synthlab tutorial#5
bschilder merged 2 commits into
mainfrom
migration/notebook-tutorial

Conversation

@bschilder

Copy link
Copy Markdown
Owner

Summary

The Synthea notebook on `main` was byte-identical to `bschilder/AoU/notebooks/Synthea.ipynb` — it still imported `AoU.phenome.synthea.*` and never exercised any synthlab code. This PR replaces it with an end-to-end tutorial against synthlab's public API.

Walks through:

  1. `SyntheaRunner()` auto-downloads the Synthea JAR
  2. `SyntheaConfig(population_size=10, exporter_flags={"exporter.csv.export": "true", "exporter.fhir.export": "false"})` enables CSV output (Synthea defaults to FHIR JSON; the OMOP converter needs CSV)
  3. `runner.run()` → 18 CSV files
  4. `convert_synthea_to_omop(cdm_version="5.4", output_format="parquet")` → 10 OMOP tables (person, condition_occurrence, drug_exposure, measurement, visit_occurrence, …)
  5. `pandas` previews of the resulting OMOP frames

Render status

  • 6 code cells, 6 with outputs, 0 errors
  • person table preview shows 14 real synthetic patients (10 living + 4 historical from the 10-pop seed)

Notes for reviewer

  • The notebook `%load_ext autoreload` cell appends openjdk@21 to `PATH` if the homebrew install is present; this is the only platform-specific bit and only kicks in on macOS. Linux/CI: pre-install Java.

Test plan

  • Open on github.com and confirm outputs render
  • `jupyter nbconvert --to notebook --execute --inplace notebooks/Synthea.ipynb` reproduces locally (requires Java)

🤖 Generated with Claude Code

bschilder and others added 2 commits May 16, 2026 19:46
The notebook on main was byte-identical to bschilder/AoU's original
copy — it still imported AoU.phenome.synthea.* and never exercised any
synthlab code. Replaced with an end-to-end tutorial against the
synthlab public API:

  1. SyntheaRunner() auto-downloads the Synthea JAR
  2. SyntheaConfig(population_size=10, exporter_flags={"exporter.csv.export": "true",
     "exporter.fhir.export": "false"}) to enable CSV output
  3. runner.run() → 18 CSV files
  4. convert_synthea_to_omop(cdm_version="5.4", output_format="parquet")
     → 10 OMOP tables (person, condition_occurrence, drug_exposure, …)
  5. pandas previews of the resulting OMOP frames

Rendered end-to-end (6 of 6 code cells, 0 errors); the person table
preview shows 14 real synthetic patients. Closes the migration
described in the AoU notebook deprecation pointer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`convert_synthea_to_omop` returns a `dict[str, str]` keyed by OMOP table
name; the cell was iterating the dict directly (which yields keys), then
calling `Path(path).stat()` on the table name, which always returns 0.
Switched to `omop_files.items()` and now print both the table name and
the actual file size.

Cosmetic only — the conversion itself was already correct. Caught by
PR review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bschilder
bschilder merged commit cefc5cc into main May 16, 2026
1 check passed
@bschilder
bschilder deleted the migration/notebook-tutorial branch May 16, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant