'economic', 'name' => 'Economic Stability'], ['id' => 'education', 'name' => 'Education Access & Quality'], ['id' => 'healthcare', 'name' => 'Health Care Access & Quality'], ['id' => 'neighborhood', 'name' => 'Neighborhood & Built Environment'], ['id' => 'social', 'name' => 'Social & Community Context'], ]; // -- Get active domain -- $active_domain_id = $_GET['domain'] ?? 'economic'; $active_domain_name = ''; foreach ($domains as $domain) { if ($domain['id'] === $active_domain_id) { $active_domain_name = $domain['name']; break; } } // --- DATA FETCHING FOR THE ACTIVE DOMAIN --- // KPI: Total Residents in this domain (placeholder) $kpi_total_residents = $pdo->query("SELECT COUNT(DISTINCT resident_id) FROM risk_scores WHERE domain = '{$active_domain_id}'")->fetchColumn(); // KPI: Average Risk Score $kpi_avg_risk = $pdo->prepare("SELECT AVG(score_int) FROM risk_scores WHERE domain = ?"); $kpi_avg_risk->execute([$active_domain_id]); $kpi_avg_risk = round($kpi_avg_risk->fetchColumn() ?? 0); // KPI: High-Risk Residents $kpi_high_risk_count = $pdo->prepare("SELECT COUNT(*) FROM risk_scores WHERE domain = ? AND level = 'high'"); $kpi_high_risk_count->execute([$active_domain_id]); $kpi_high_risk_count = $kpi_high_risk_count->fetchColumn(); // Risk & Drivers: Top Drivers (Placeholder - requires JSON processing) $top_drivers = [ ['label' => 'Inconsistent employment', 'weight' => 0.8], ['label' => 'High rent burden', 'weight' => 0.7], ['label' => 'Lack of emergency funds', 'weight' => 0.6], ]; // Summary Table: Survey Responses $survey_responses_stmt = $pdo->prepare("SELECT r.first_name, r.last_name, sr.question_label, sr.answer_value, sr.answered_at FROM survey_responses sr JOIN residents r ON sr.resident_id = r.id WHERE sr.domain = ? ORDER BY sr.answered_at DESC LIMIT 10"); $survey_responses_stmt->execute([$active_domain_id]); $survey_responses = $survey_responses_stmt->fetchAll(PDO::FETCH_ASSOC); ?>
%
[Placeholder for chronological stream of events: survey responses, notes, referrals, etc.]
| Resident | Question | Answer | Date |
|---|---|---|---|
| No survey responses for this domain yet. | |||