Skip to content

Conversation

@Rifa-111
Copy link

Overview

This PR adds a new tutorial demonstrating how to compute healthcare KPIs (length of stay, readmission rate, and bed occupancy) using synthetic inpatient admissions data.

The tutorial supports users working with EHR-like tabular data alongside medical imaging workflows. Synthetic data avoids any patient-identifiable information and enables reproducible experimentation for benchmarking and educational use cases.

Notebook contents

  • synthetic data generation
  • age, diagnosis, and hospital site cohort filtering
  • KPI computation
  • KPI visualisation
  • discussion and reproducibility notes

Implementation details

  • New notebook: tutorials/health_kpi_analysis.ipynb
  • Dependencies: pandas, matplotlib, seaborn, health-analytics-toolkit >= 0.1.0

Notes

  • No PHI or real patient data is used.
  • Notebook runs on CPU-only environments.
  • Happy to adjust folder placement, naming conventions, or formatting to align with MONAI contributor guidelines.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

Adds a new Jupyter Notebook tutorial demonstrating healthcare KPI computation from synthetic patient data. The notebook covers data generation via a health analytics toolkit, KPI calculations (average length of stay, 30-day readmission rate, bed occupancy), visualization of results, and includes reproducibility and extension notes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description covers implementation details, notebook contents, and dependencies. However, it doesn't follow the template structure with 'Fixes #' issue reference or 'Types of changes' checkboxes as required. Add 'Fixes #' section referencing the related issue and include the template's 'Types of changes' checkboxes to match repository standards.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a healthcare KPI analysis tutorial with synthetic inpatient data. It's concise, specific, and directly reflects the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@monai/tutorials/health_kpi_analysis/health_kpi_analysis.ipynb`:
- Around line 4-8: The first cell is currently defined as a code cell
("cell_type": "code") but contains markdown content, so change its "cell_type"
value to "markdown" for that cell (the one with "execution_count": null and
empty "outputs") and ensure the notebook cell's "source" remains the same so
headings render correctly; you can also remove "execution_count" and "outputs"
entries if present for cleanliness.
🧹 Nitpick comments (2)
monai/tutorials/health_kpi_analysis/health_kpi_analysis.ipynb (2)

47-55: Add a deterministic seed for reproducibility.
Line 81-82 generates synthetic data but the tutorial claims reproducibility. Add a seed (verify the toolkit’s preferred API).

💡 Suggested fix (adjust per toolkit docs)
 import pandas as pd
 import seaborn as sns
 import matplotlib.pyplot as plt
 import health_analytics_toolkit as hat
+import numpy as np

 sns.set(style="whitegrid")
-df = hat.generate_synthetic_patients(n=2000)
+np.random.seed(42)
+df = hat.generate_synthetic_patients(n=2000)

Also applies to: 81-82


147-149: Verify the 30‑day readmission window.
Line 148 computes readmission_rate without an explicit window, but the text says “30‑day.” Confirm the default or pass the window explicitly.

Comment on lines +4 to +8
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Make the intro cell markdown.
Line 4-8 defines a code cell but the content is markdown, so headings render as comments.

💡 Suggested fix
-        {
-            "cell_type": "code",
-            "execution_count": null,
-            "metadata": {},
-            "outputs": [],
+        {
+            "cell_type": "markdown",
+            "metadata": {},
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
🤖 Prompt for AI Agents
In `@monai/tutorials/health_kpi_analysis/health_kpi_analysis.ipynb` around lines 4
- 8, The first cell is currently defined as a code cell ("cell_type": "code")
but contains markdown content, so change its "cell_type" value to "markdown" for
that cell (the one with "execution_count": null and empty "outputs") and ensure
the notebook cell's "source" remains the same so headings render correctly; you
can also remove "execution_count" and "outputs" entries if present for
cleanliness.

@ericspod
Copy link
Member

Hi @Rifa-111 thanks for this contribution. We keep tutorials in a separate repo here, please propose your notebook there as a PR and then we can review. Any details about placement and conventions we can discuss there and sort out any details.

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.

2 participants