| """Generate synthetic rehabilitation workforce & training dataset for SSA. |
| |
| Research-based parameterization: |
| - WHO Rehabilitation 2030: SSA has 0.5-2 rehab professionals per |
| 100K vs 60+ in high-income; massive shortage across all cadres. |
| - WCPT: <5000 physiotherapists for all of SSA; most concentrated in |
| urban areas; rural coverage near zero. |
| - ISPO: ~0.5 prosthetists/orthotists per million in SSA. |
| - SSA context: Few training institutions; brain drain; task-shifting |
| to CHWs/nurses; limited CPD opportunities. |
| """ |
|
|
| from __future__ import annotations |
|
|
| from pathlib import Path |
|
|
| import numpy as np |
| import pandas as pd |
|
|
| SEED = 42 |
| N_PER_SCENARIO = 10_000 |
|
|
| YEAR_RANGE = np.arange(2010, 2025) |
| YEAR_WEIGHTS = np.linspace(0.85, 1.3, len(YEAR_RANGE)) |
| YEAR_WEIGHTS = YEAR_WEIGHTS / YEAR_WEIGHTS.sum() |
|
|
| SCENARIOS = { |
| "urban_training_institution": { |
| "setting_probs": {"university": 0.30, "teaching_hospital": 0.25, |
| "rehab_training_school": 0.20, "private_institution": 0.25}, |
| "cadre_probs": {"physiotherapist": 0.25, "occupational_therapist": 0.12, |
| "speech_therapist": 0.08, "prosthetist_orthotist": 0.10, |
| "rehab_nurse": 0.15, "psychologist": 0.08, |
| "social_worker": 0.08, "rehab_physician": 0.05, |
| "audiologist": 0.04, "other": 0.05}, |
| "staff_density_per_100k": 2.0, |
| "training_places": 50, |
| "retention_rate": 0.60, |
| "cpd_access_pct": 0.30, |
| "task_shifting_pct": 0.15, |
| }, |
| "district_service_delivery": { |
| "setting_probs": {"district_hospital": 0.35, "health_centre": 0.25, |
| "community_programme": 0.20, "outreach": 0.20}, |
| "cadre_probs": {"physiotherapist": 0.20, "rehab_nurse": 0.20, |
| "rehab_assistant": 0.15, "cbr_worker": 0.15, |
| "occupational_therapist": 0.08, "prosthetist_orthotist": 0.05, |
| "social_worker": 0.07, "other": 0.10}, |
| "staff_density_per_100k": 0.5, |
| "training_places": 15, |
| "retention_rate": 0.40, |
| "cpd_access_pct": 0.10, |
| "task_shifting_pct": 0.35, |
| }, |
| "rural_task_shifted": { |
| "setting_probs": {"health_post": 0.30, "community_home": 0.25, |
| "cbr_programme": 0.25, "mobile_clinic": 0.20}, |
| "cadre_probs": {"cbr_worker": 0.30, "chw_rehab_trained": 0.25, |
| "rehab_assistant": 0.15, "nurse_task_shifted": 0.15, |
| "physiotherapist": 0.05, "other": 0.10}, |
| "staff_density_per_100k": 0.1, |
| "training_places": 5, |
| "retention_rate": 0.25, |
| "cpd_access_pct": 0.03, |
| "task_shifting_pct": 0.70, |
| }, |
| } |
|
|
| SCENARIO_FILES = { |
| "urban_training_institution": "rehab_wf_urban.csv", |
| "district_service_delivery": "rehab_wf_district.csv", |
| "rural_task_shifted": "rehab_wf_rural.csv", |
| } |
|
|
|
|
| def _choice(rng, prob_map): |
| keys = list(prob_map.keys()) |
| weights = np.array(list(prob_map.values()), dtype=float) |
| weights = weights / weights.sum() |
| return rng.choice(keys, p=weights) |
|
|
|
|
| def _simulate_scenario(name, params, seed): |
| rng = np.random.default_rng(seed) |
| records = [] |
|
|
| for idx in range(N_PER_SCENARIO): |
| year = int(rng.choice(YEAR_RANGE, p=YEAR_WEIGHTS)) |
| setting = _choice(rng, params["setting_probs"]) |
|
|
| cadre = _choice(rng, params["cadre_probs"]) |
| age = int(np.clip(rng.normal(35, 10), 22, 65)) |
| sex = rng.choice(["male", "female"], p=[0.40, 0.60]) |
| years_experience = int(np.clip(rng.exponential(6), 0, 35)) |
|
|
| |
| qualification = rng.choice(["degree", "diploma", "certificate", "on_job_training"], |
| p=[0.20, 0.30, 0.25, 0.25]) |
| training_institution = rng.choice(["local_university", "foreign_trained", |
| "regional_school", "in_service"], |
| p=[0.30, 0.10, 0.25, 0.35]) |
| cpd_received = int(rng.random() < params["cpd_access_pct"]) |
| supervision_regular = int(rng.random() < 0.20) |
| mentorship = int(rng.random() < 0.10) |
|
|
| |
| position_filled = int(rng.random() < params["retention_rate"]) |
| vacancy = int(not position_filled) |
| task_shifted = int(rng.random() < params["task_shifting_pct"]) |
| workload_patients_week = int(np.clip(rng.poisson(20), 2, 80)) |
| burnout = int(workload_patients_week > 30 and rng.random() < 0.35) |
| emigration_intent = int(rng.random() < 0.25) |
| rural_willingness = int(rng.random() < 0.15) |
|
|
| |
| equipment_available = int(rng.random() < 0.30) |
| dedicated_space = int(rng.random() < 0.25) |
| consumables_available = int(rng.random() < 0.35) |
|
|
| |
| assessment_competent = int(rng.random() < 0.50) |
| treatment_competent = int(rng.random() < 0.45) |
| assistive_device_competent = int(rng.random() < 0.25) |
| community_rehab_competent = int(rng.random() < 0.20) |
| paediatric_competent = int(rng.random() < 0.15) |
|
|
| |
| patients_seen_month = int(np.clip(rng.poisson(workload_patients_week * 4), 5, 300)) |
| patient_satisfaction = int(rng.random() < (0.55 if assessment_competent else 0.30)) |
| functional_outcomes_measured = int(rng.random() < 0.15) |
| referral_network = int(rng.random() < 0.20) |
|
|
| |
| rehab_in_health_policy = int(rng.random() < 0.25) |
| budget_for_rehab = int(rng.random() < 0.10) |
| regulation_registered = int(qualification in ("degree", "diploma") and rng.random() < 0.50) |
|
|
| record = { |
| "record_id": f"{name[:3].upper()}-{idx:05d}", |
| "scenario": name, |
| "year": year, |
| "setting": setting, |
| "cadre": cadre, |
| "age": age, |
| "sex": sex, |
| "years_experience": years_experience, |
| "qualification": qualification, |
| "training_institution": training_institution, |
| "cpd_received": cpd_received, |
| "supervision_regular": supervision_regular, |
| "position_filled": position_filled, |
| "vacancy": vacancy, |
| "task_shifted": task_shifted, |
| "workload_patients_week": workload_patients_week, |
| "burnout": burnout, |
| "emigration_intent": emigration_intent, |
| "rural_willingness": rural_willingness, |
| "equipment_available": equipment_available, |
| "dedicated_space": dedicated_space, |
| "assessment_competent": assessment_competent, |
| "treatment_competent": treatment_competent, |
| "assistive_device_competent": assistive_device_competent, |
| "patients_seen_month": patients_seen_month, |
| "patient_satisfaction": patient_satisfaction, |
| "functional_outcomes_measured": functional_outcomes_measured, |
| "rehab_in_health_policy": rehab_in_health_policy, |
| "budget_for_rehab": budget_for_rehab, |
| "regulation_registered": regulation_registered, |
| } |
| records.append(record) |
|
|
| return pd.DataFrame(records) |
|
|
|
|
| def main(): |
| output_dir = Path("data") |
| output_dir.mkdir(parents=True, exist_ok=True) |
| for idx, (name, params) in enumerate(SCENARIOS.items()): |
| df = _simulate_scenario(name, params, SEED + idx * 211) |
| df.to_csv(output_dir / SCENARIO_FILES[name], index=False) |
| print(f"Saved {name} -> {SCENARIO_FILES[name]}") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|