-
diff --git a/resident_dashboard.php b/resident_dashboard.php
index 11562ac..1ff8768 100644
--- a/resident_dashboard.php
+++ b/resident_dashboard.php
@@ -2,44 +2,48 @@
session_start();
require_once 'db/config.php';
-if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'resident') {
+// Check if user is logged in and has the 'resident' role
+if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'resident') {
header("Location: index.php");
- exit();
+ exit;
}
$resident_id = $_SESSION['user_id'];
+$pdo = db();
-// Fetch resident's name
-$stmt = $pdo->prepare("SELECT name FROM residents WHERE id = ?");
+// Fetch resident's first name
+$stmt = $pdo->prepare("SELECT first_name FROM residents WHERE id = ?");
$stmt->execute([$resident_id]);
-$resident = $stmt->fetch();
+$resident_name = $stmt->fetchColumn();
-// Fetch resident's domain scores
-$stmt = $pdo->prepare("
- SELECT d.name, rds.score
- FROM resident_domain_scores rds
- JOIN domains d ON rds.domain_id = d.id
- WHERE rds.resident_id = ?
- ORDER BY d.id
+// Fetch resident's domain risk scores, levels, and drivers
+$risk_scores_stmt = $pdo->prepare("
+ SELECT domain, score_int, level, drivers
+ FROM risk_scores
+ WHERE resident_id = ?
+ ORDER BY domain
");
-$stmt->execute([$resident_id]);
-$domain_scores = $stmt->fetchAll();
+$risk_scores_stmt->execute([$resident_id]);
+$risk_scores = $risk_scores_stmt->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_GROUP);
// Fetch resident's action plans
-$stmt = $pdo->prepare("
- SELECT ap.id, ap.title, ap.description, ap.status, d.name as domain_name
+$action_plans_stmt = $pdo->prepare("
+ SELECT ap.id, ap.title, ap.status, ap.domain
FROM action_plans ap
- JOIN domains d ON ap.domain_id = d.id
WHERE ap.resident_id = ?
ORDER BY ap.created_at DESC
");
-$stmt->execute([$resident_id]);
-$action_plans = $stmt->fetchAll();
+$action_plans_stmt->execute([$resident_id]);
+$action_plans = $action_plans_stmt->fetchAll(PDO::FETCH_ASSOC);
-// Fetch resident's case manager for messaging
-$stmt = $pdo->prepare("SELECT u.id, u.name, u.email FROM users u JOIN residents r ON u.id = r.case_manager_id WHERE r.id = ?");
-$stmt->execute([$resident_id]);
-$case_manager = $stmt->fetch();
+// Domain names mapping
+$domains = [
+ 'economic' => 'Economic Stability',
+ 'education' => 'Education Access & Quality',
+ 'healthcare' => 'Health Care Access & Quality',
+ 'neighborhood' => 'Neighborhood & Built Environment',
+ 'social' => 'Social & Community Context',
+];
?>
@@ -47,87 +51,91 @@ $case_manager = $stmt->fetch();
-
Resident Dashboard - Continuum Nexus
-
-
+
Resident Dashboard | Continuum Nexus
+
+
-
-
Welcome, !
+
Welcome, !
+
Your Domain Overview
-
-
Your Progress Across the 5 Domains
-
-
-
-
+ $domain_name): ?>
+
+
+
+
-
+
+
+
+
Key Factors:
+
+
+
No specific risk factors identified.
+
+
+
-
+
-
+
Title
Domain
Status
- Action
+
- You have no active action plans.
+ You have no active action plans.
-
-
-
- View Details
+
+
+
+ View
@@ -138,36 +146,8 @@ $case_manager = $stmt->fetch();
-
-
-
-
-
-
-
Your appointment calendar will be displayed here.
-
View Calendar
-
-
-
-
-
-
-
-
-
+