Healthcare Data Integration

Generating Synthetic Data for NHS COSD, COSD Pathology

The script parses the original sample XMLs (downloaded from NHS TRUD) — preserving the full schema structure, all coded fields (which come from real NHS value sets so they stay untouched), and all nesting — then replaces only the free-text and identifier fields with realistic values:

  • NHS numbers — genuine Modulus 11 check-digit algorithm, not random 10 digits
  • Names — drawn from a weighted UK name pool (English/Welsh, South Asian, African, Irish) matched to gender code
  • Postcodes — real UK postcodes by region
  • Addressesfaker UK street addresses
  • ODS codes — real NHS trust and site codes from the ODS registry
  • GP practice codes — real format (letter + 5 digits)
  • GMC numbers — correct 7-digit format
  • Dates — plausible ranges (DOB 1930–2005, clinical events 2018–2024)
  • Pathology/imaging report text — pool of realistic clinical prose
  • TNM staging — proper T/N/M category values