prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$userId]);
$user = $stmt->fetch();
// Fetch pooled requests
$stmt = $pdo->prepare("SELECT * FROM pooled_requests WHERE user_id = ? ORDER BY created_at DESC");
$stmt->execute([$userId]);
$pooled_requests = $stmt->fetchAll();
// Fetch shortage predictions
$stmt = $pdo->prepare("SELECT * FROM shortage_predictions WHERE user_id = ? ORDER BY days_to_shortage ASC");
$stmt->execute([$userId]);
$predictions = $stmt->fetchAll();
// Prepare data for the chart
$prediction_labels = [];
$prediction_data = [];
foreach ($predictions as $prediction) {
$prediction_labels[] = $prediction['medicine_name'];
$prediction_data[] = $prediction['days_to_shortage'];
}
// Calculate stats
$high_risk_alerts = 0;
foreach ($predictions as $prediction) {
if ($prediction['days_to_shortage'] < 20) {
$high_risk_alerts++;
}
}
$active_pooled_requests = count($pooled_requests);
$medicines_monitored = count($predictions);
?>
Pharmacy Dashboard - Kotkakey
Dashboard
My Pooled Requests
| Medicine |
Status |
Participants |
Created |
|
|
|
Pharmacies |
|
View |