'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; } } // -- Get search term -- $search_term = $_GET['search'] ?? ''; // --- DATA FETCHING FOR THE ACTIVE DOMAIN --- // Base query for residents $resident_filter_sql = 'FROM residents r WHERE 1=1'; $params = []; if (!empty($search_term)) { $resident_filter_sql .= ' AND (r.first_name LIKE ? OR r.last_name LIKE ?)'; $params[] = "%$search_term%"; $params[] = "%$search_term%"; } // KPI: Total Residents in this domain $kpi_total_residents_sql = "SELECT COUNT(DISTINCT r.id) $resident_filter_sql"; $kpi_stmt = $pdo->prepare($kpi_total_residents_sql); $kpi_stmt->execute($params); $kpi_total_residents = $kpi_stmt->fetchColumn(); // KPI: Average Risk Score $kpi_avg_risk_sql = "SELECT AVG(rs.score_int) FROM risk_scores rs JOIN residents r ON rs.resident_id = r.id WHERE rs.domain = ?"; $avg_risk_params = [$active_domain_id]; if (!empty($search_term)) { $kpi_avg_risk_sql .= ' AND (r.first_name LIKE ? OR r.last_name LIKE ?)'; $avg_risk_params[] = "%$search_term%"; $avg_risk_params[] = "%$search_term%"; } $kpi_avg_risk = $pdo->prepare($kpi_avg_risk_sql); $kpi_avg_risk->execute($avg_risk_params); $kpi_avg_risk = round($kpi_avg_risk->fetchColumn() ?? 0); // KPI: High-Risk Residents $kpi_high_risk_sql = "SELECT COUNT(rs.id) FROM risk_scores rs JOIN residents r ON rs.resident_id = r.id WHERE rs.domain = ? AND rs.level = 'high'"; $high_risk_params = [$active_domain_id]; if (!empty($search_term)) { $kpi_high_risk_sql .= ' AND (r.first_name LIKE ? OR r.last_name LIKE ?)'; $high_risk_params[] = "%$search_term%"; $high_risk_params[] = "%$search_term%"; } $kpi_high_risk_count = $pdo->prepare($kpi_high_risk_sql); $kpi_high_risk_count->execute($high_risk_params); $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_sql = "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 = ?"; $survey_params = [$active_domain_id]; if (!empty($search_term)) { $survey_sql .= ' AND (r.first_name LIKE ? OR r.last_name LIKE ?)'; $survey_params[] = "%$search_term%"; $survey_params[] = "%$search_term%"; } $survey_sql .= ' ORDER BY sr.answered_at DESC LIMIT 10'; $survey_responses_stmt = $pdo->prepare($survey_sql); $survey_responses_stmt->execute($survey_params); $survey_responses = $survey_responses_stmt->fetchAll(PDO::FETCH_ASSOC); ?> Staff Dashboard | Continuum Nexus

Continuum Control Center

New Resident

Domain:

Residents in Domain

Avg. Risk Score

%

High-Risk

Domain Timeline

[Placeholder for chronological stream of events: survey responses, notes, referrals, etc.]

Summary: Survey Responses
ResidentQuestionAnswerDate
No survey responses for this domain yet.