Diagnosis documentation timing and APACHE benchmarking
Completed 24 October 2026

Purpose
Post hoc supplementary evaluations of the existing h24/h72_all expanded cohorts and eight saved prediction series (four expanded-cohort models and four matching frozen diagnosis-cohort references). No predictive model was trained, selected, updated or recalibrated. The external database had already been examined. Logistic calibration fits are evaluation statistics only.

Reproduction from the project root
  .venv/Scripts/python.exe ph_transportability/mentor_revision_20261024/timing_benchmark/extract_inputs.py
  .venv/Scripts/python.exe ph_transportability/mentor_revision_20261024/timing_benchmark/evaluate.py
  .venv/Scripts/python.exe ph_transportability/mentor_revision_20261024/timing_benchmark/verify_results.py

The existing credentialed BigQuery environment and original source/model files are required. Extraction verifies the two protocol hashes, uses parameterised stay IDs, checks a dry run against the original 100-GB per-query cap, and uses only read-only SELECT queries. Its verified cache avoids another billed extraction. The two queries were estimated at 258,056,110 and 8,466,324 bytes, respectively. The common scope contained 5,198 unique expanded-cohort stays across the two landmarks.

Privacy and files
private/ contains raw diagnosis/score rows, joined fixed predictions, timing flags and hospital-bootstrap multiplicities; do not share this directory. public/results contains aggregate CSV/JSON only. Patient-level source artifacts remain in their original directories. No original result file or protocol was overwritten.

Public table names
  timing_cohort_counts.csv: all planned external population counts, including empty strata.
  timing_transitions.csv: retained, removed and negative-offset additions.
  timing_performance.csv: fixed-model results for timely unions and diagnosis-only timing strata.
  timing_paired_comparisons.csv: corresponding refit-minus-frozen differences within the same patients.
  diagnosis_offset_audit.json: row/patient negative-offset and missing-offset audit.
  diagnosis_documentation_counts.csv: all-diagnosis timely-documentation numerators/denominators.
  mimic_prior_PH_descriptive_counts.csv: prior-admission ascertainment descriptions, not development validation.
  apache_coverage.csv: score availability and outcomes in included/excluded patients by version/window.
  apache_matched_performance.csv: APACHE and all eight fixed prediction series on each matched set.
  apache_paired_comparisons.csv: each prediction series minus the matching APACHE version.
  apache_encoding_and_duplicates_audit.json: full unique-stay extraction audit by version.
  apache_window_encoding_audit.json: corresponding audit separately at 24 and 72 hours.
  extraction_manifest.json, evaluation_manifest.json, metric_engine_validation.json,
  verification_summary.json: provenance and validation evidence.

Columns and interpretation
window = h24 or h72_all. origin = refit_union_model, frozen_diagnosis_model, or benchmark. Model labels are expanded_lasso, pap_lasso, dynamic_xgb, pap_xgb, APACHE_IVa and APACHE_IV. Performance tables use n, events, hospitals, prevalence, auroc, auprc (average precision), brier, calibration_intercept, calibration_slope and citl. Intervals use metric_low/high. Paired tables use delta_metric and metric_low/high; differences are first prediction minus second prediction. Positive AUROC/AP and negative Brier differences favour the first prediction. Calibration differences are descriptive, not improvement scales.

All intervals use 1,000 whole-hospital percentile bootstrap replicates with seed 20260924, conditional on fixed models. Within a population all predictions share identical hospital draws. Timing calibration is reported as point estimates, consistent with the original primary analysis. Benchmark calibration has bootstrap intervals; all 1,000 calibration fits succeeded for every APACHE-matched model. The two-patient, zero-death negative-only subgroup has no estimable discrimination/calibration; its descriptive Brier point is retained without an interval.

Timing results
The primary rule requires at least one matching diagnosis record with 0 <= offset < landmark minutes; it is a documentation rule, not disease onset. The pressure eligibility branch is unchanged. Matching raw diagnosis coverage reproduces the original diagnostic flags exactly, and the 24-hour timely flag reproduces ph_early exactly.

At 24 hours, 409/597 documented patients had a nonnegative PH record before the landmark. The timely union retained 4,663 patients, 264 deaths and 125 hospitals; it removed 167 patients with 46 deaths from the original 4,830/310 union. Expanded-cohort pressure XGBoost AUROC was 0.843962 (95% CI 0.815554-0.869807), average precision 0.383720 and Brier 0.043149. Diagnosis-only timely patients numbered 343/57 deaths (AUROC 0.735125), compared with 165/46 recorded at/after the landmark (AUROC 0.621849); another two diagnosis-only patients had negative records without nonnegative timely documentation and neither died.

Fifteen negative-offset rows occurred in ten 24-hour patients, ranging from -8,586 to -3 minutes (median -90). Including negative records added only those two diagnosis-only survivors: union 4,665/264, AUROC 0.843852. Negative values were therefore explicitly audited and tested, not silently treated as invalid or normal.

At 72 hours, 256/333 documented patients had a record satisfying the 0-4,320-minute rule. The timely union retained 2,390 patients and 223 deaths (114 hospitals), removing 69 patients and 18 deaths. Expanded-cohort pressure XGBoost AUROC was 0.812861 (0.790648-0.835415), average precision 0.356108 and Brier 0.071825. Including negative offsets did not change this union. The four negative rows in four patients ranged from -137 to -18 minutes. Do not interpret differences between full-union and restricted-union AUROCs as a paired model-improvement effect: the populations differ.

MIMIC-IV provides discharge coding without an appropriate diagnosis-recording offset. Prior completed-admission PH was observed in 274 patients/38 deaths at 24 hours and 141/28 at 72 hours; among patients with a current PH code the corresponding counts were 240/37 and 116/26. Replacing current codes with prior PH while preserving the pressure branch yielded 4,057/246 and 2,210/240. These populations also added 12/0 and 7/1 prior-PH patients absent from the original unions. Absence of prior coding does not establish absence of pre-existing PH. No in-sample MIMIC model performance is presented as validation.

APACHE results
IV and IVa were kept separate. Each version had 4,727 source rows, one per stay: 4,651 valid probabilities and 76 values of -1. No conflicting duplicates, nonnumeric values, missing probability values or values above one were observed in the extracted rows. These counts refer to the pooled unique-stay scope, not to either landmark separately.

Within h24, each version was available for 4,321/4,830 patients (89.46%), with 274 deaths in 120 hospitals. Unavailability comprised 443 patients without a version row and 66 with the -1 sentinel. At h72, coverage was 2,182/2,459 (88.74%), 211 deaths in 108 hospitals; 224 had no row and 53 had -1.

At h24 on the same 4,321 patients, pressure XGBoost AUROC was 0.841714 (0.813564-0.866658), IVa 0.828598 (0.800613-0.855955), and IV 0.817603 (0.786970-0.846898). Pressure XGBoost minus IVa AUROC was 0.013116 (-0.018643 to 0.042983), with Brier difference -0.003780 (-0.006597 to -0.000253). Its AUROC difference from IV was 0.024111 (-0.012887 to 0.058871). The 24-hour discrimination intervals do not establish superiority over either APACHE version.

At h72 on the same 2,182 patients, pressure XGBoost AUROC was 0.810354 (0.786497-0.834691), IVa 0.761514 (0.735114-0.790283), and IV 0.750925 (0.719580-0.781703). AUROC differences were 0.048841 (0.014550-0.082651) and 0.059429 (0.021003-0.098338). APACHE remains the stored admission/first-day prediction, whereas the h72 model uses observations through 72 hours. This comparison does not isolate algorithmic or PH-specific superiority. Stored score-generation times were not established.

Validation
All eight original full-union AUROC/AP/Brier values were reproduced at each landmark. Sixteen random prediction checks matched the saved model artifacts allowing the original XGBoost float32-to-CSV round-trip. The weighted bootstrap metric engine matched sklearn on ties, endpoint probabilities and integer/zero weights. Independent validation expanded three saved hospital draws into repeated patient rows in each APACHE population and reproduced all nine series with sklearn. All benchmark points, intervals and paired intervals, 72 timing performance rows, score joins and 42 source/code hashes passed. verification_summary.json records the checks. This code does not treat a change in cohort membership as new prediction-model validation.
