Spaces:
Sleeping
Sleeping
| \ | |
| from typing import Dict, List | |
| def capacity_projection(clients_per_day: int = 18, clinic_days_per_team: int = 48, teams: int = 6) -> int: | |
| return clients_per_day * clinic_days_per_team * teams | |
| def cost_estimate(n_clients: int, variable_per_client: float = 74.0, fixed_total: float = 75000.0) -> Dict: | |
| total_variable = variable_per_client * n_clients | |
| total = total_variable + fixed_total | |
| return { | |
| "n_clients": n_clients, | |
| "variable_per_client": variable_per_client, | |
| "fixed_total": fixed_total, | |
| "total_variable": total_variable, | |
| "total_cost": total, | |
| "cost_per_client": total / max(1, n_clients) | |
| } | |
| def prioritize_settlements(records: List[Dict]) -> List[Dict]: | |
| # records: [{name, population, risk_index, access_burden, repeat_opportunity}] | |
| if not records: | |
| return [] | |
| def scale(vals): | |
| mn, mx = min(vals), max(vals) | |
| return [0.0 if mx==mn else (v-mn)/(mx-mn) for v in vals] | |
| pop_s = scale([r.get("population", 0) for r in records]) | |
| risk_s = scale([r.get("risk_index", 0) for r in records]) | |
| acc_s = scale([r.get("access_burden", 0) for r in records]) | |
| rep_s = scale([r.get("repeat_opportunity", 0) for r in records]) | |
| out = [] | |
| for i, r in enumerate(records): | |
| score = 0.35*pop_s[i] + 0.35*risk_s[i] + 0.15*acc_s[i] + 0.15*rep_s[i] | |
| rr = dict(r); rr["priority_score"] = round(score, 3) | |
| out.append(rr) | |
| out.sort(key=lambda x: x["priority_score"], reverse=True) | |
| return out | |
| def outcomes_summary(delta_a1c=-0.4, delta_sbp=-5, delta_bmi=-0.8, delta_ldl=-12): | |
| return { | |
| "median_delta_a1c_pct": delta_a1c, | |
| "median_delta_systolic_bp_mmHg": delta_sbp, | |
| "median_delta_bmi_kg_m2": delta_bmi, | |
| "median_delta_ldl_mg_dl": delta_ldl | |
| } | |