Patient Operations Data Analysis Project

Data Analytics project 12

Patient Operations Data Analysis Project

Build a complete patient data analysis portfolio project with documented metrics, reproducible Python code, validation checks, and responsible interpretation.

Explore Data Analytics training in VizagView all project ideas

Business question

How do wait-time distribution, admission rate, and operational flow differ across departments?

Dataset and grain

Two thousand five hundred synthetic encounters with department, wait time, admission flag, length of stay, and left-before-seen flag.

Requirements

Python 3.10 or later with numpy and pandas installed.

Method and validation checks

Calculate overall encounter KPIs, then aggregate counts, median and 90th-percentile wait, admission rate, and admitted-patient length of stay by department.

  • Encounter ID is the counting grain
  • Median and p90 show more than a simple mean
  • Length of stay excludes non-admitted zero values
  • No operational association is framed as clinical quality or diagnosis

Complete Python code

Save the code as da_patient_data_analysis.py. Review the stated model and field assumptions before using another dataset.

"""Analyse synthetic hospital operations data, not clinical outcomes."""

from __future__ import annotations

import numpy as np
import pandas as pd


def make_demo_encounters(n: int = 2_500, seed: int = 42) -> pd.DataFrame:
    rng = np.random.default_rng(seed)
    department = rng.choice(["Emergency", "Cardiology", "Orthopaedics", "General Medicine"], n, p=[0.38, 0.18, 0.2, 0.24])
    wait = np.select([department == "Emergency", department == "Cardiology"], [rng.gamma(2.2, 18, n), rng.gamma(2.0, 24, n)], default=rng.gamma(2.0, 15, n))
    admitted = rng.random(n) < np.select([department == "Emergency", department == "Cardiology"], [0.32, 0.38], default=0.18)
    length = np.where(admitted, np.maximum(1, rng.negative_binomial(3, 0.45, n)), 0)
    return pd.DataFrame({"encounter_id": range(1, n + 1), "department": department,
                         "wait_minutes": wait.round(1), "admitted": admitted,
                         "length_of_stay_days": length, "left_before_seen": rng.random(n) < 0.025})


def analyse_operations(data: pd.DataFrame) -> tuple[dict[str, float], pd.DataFrame]:
    encounters = data.copy()
    kpis = {"encounters": float(encounters["encounter_id"].nunique()),
            "median_wait_minutes": float(encounters["wait_minutes"].median()),
            "admission_rate": float(encounters["admitted"].mean()),
            "left_before_seen_rate": float(encounters["left_before_seen"].mean())}
    department = encounters.groupby("department", as_index=False).agg(encounters=("encounter_id", "nunique"), median_wait=("wait_minutes", "median"), p90_wait=("wait_minutes", lambda s: s.quantile(0.9)), admission_rate=("admitted", "mean"), mean_stay_admitted=("length_of_stay_days", lambda s: s[s > 0].mean()))
    return kpis, department


def main() -> None:
    kpis, table = analyse_operations(make_demo_encounters())
    print({k: round(v, 3) for k, v in kpis.items()})
    print(table.round(2).to_string(index=False))
    print("Synthetic operations data only; not diagnosis, quality grading, or medical advice.")


if __name__ == "__main__":
    main()

Build and run the project

Run python da_patient_data_analysis.py to create overall and department operations summaries.

  1. Confirm the source grain and field definitions.
  2. Reconcile record counts and additive totals.
  3. Validate rate denominators and date filters.
  4. Review outliers and missing values.
  5. Read the interpretation limits before sharing conclusions.

Expected analytical output

Overall operations KPIs and a department table with volume, wait distribution, admission rate, and mean admitted stay.

Interpretation and responsible-use limits

Synthetic operations data only. It cannot evaluate care quality, diagnose patients, compare clinicians, or guide treatment. Real health data requires privacy, governance, risk adjustment, and clinical review.

Ways to extend the project

Add arrival acuity, time-of-day, staffing, censored waits, control charts, risk adjustment, and privacy-preserving access controls.

Continue learning Data Analytics

Try the next project, return to the Softenant project library, or explore the Data Analytics course in Vizag for guided SQL, Excel, Power BI, Python, dashboard, and portfolio practice.