HealthPY Core — Standalone
NHS commissioning activity-reconciliation pipeline. Build the weekly report every commissioning support unit runs against trust returns. Instructor-reviewed submission, reviewer feedback within 10 working days.
Projects in this bundle
HealthPY Core — NHS Activity Reconciliation
## The scenario You have just joined **CubedNet Health**, a fictional NHS commissioning support unit, as a junior data analyst on the Activity team. CubedNet Health commissions admitted-patient care for a regional population from three NHS trusts: a major London acute trust, a smaller South East acute trust, and a North West community trust. Every month each trust sends CubedNet Health a SUS+ activity extract — a CSV containing one row per spell (a continuous period of admitted care, from admission to discharge). Each row has the patient, the admission and discharge dates, the primary diagnosis (ICD-10), the primary procedure (OPCS-4), the length of stay, and the HRG code (Healthcare Resource Group) the trust's grouper has assigned to the spell. Your manager has asked you to build a **monthly activity reconciliation report** that looks up each spell's HRG against the NHS Payment Scheme tariff, computes the expected payment per spell using the right price (elective / non-elective / day case), aggregates spend and activity by provider, and flags any spell that fails an audit rule. ## Deliverables A Python project that runs end-to-end with `python healthpy_report.py` and produces two output CSVs in `./output/`: `provider_summary.csv` (one row per provider with total spells, total bed-days, total spend) and `flagged_spells.csv` (one row per audit-failing spell with `flag_type` ∈ {`unknown_hrg`, `backward_dates`, `missing_los`, `no_applicable_price`}). **Stdlib only** — no pandas, no numpy. Use `csv.DictReader`, `pathlib`, `datetime`, `collections`. ## Payment lookup rules 1. If `length_of_stay_days = 0` AND HRG has a `day_case_price_pence`, use that. 2. Else if admission method is `Emergency` / `Maternity` / `Transfer` AND HRG has a `non_elective_price_pence`, use that. 3. Else if HRG has an `elective_price_pence`, use that. 4. Else flag the spell as `no_applicable_price`. ## Acceptance criteria (summary) Runs in one command · stdlib only · both output CSVs correct · bad rows logged not fatal · HRG codes cleaned before lookup · ≥3 named functions with docstrings · PEP 8 compliant · ≥8 conventional commits. Full brief and dataset orientation appear inside the lesson once enrolled.