Impfworkflow + Patientensuche repariert

This commit is contained in:
2026-03-24 14:57:21 +01:00
parent 211ce11e06
commit 6dd0ac86b2
3 changed files with 97 additions and 19 deletions
+79 -1
View File
@@ -92,6 +92,23 @@ function workflowDeleteWaitlistEntry(PDO $pdo, int $warteid): void
$stDelete->execute(['wid' => $warteid]);
}
function workflowLoadWaitlistEntry(PDO $pdo, int $warteid): ?array
{
if ($warteid <= 0) {
return null;
}
$stWait = $pdo->prepare("SELECT w.warteid, w.userid, w.checked, p.vorname, p.nachname
FROM warteliste w
LEFT JOIN persons p ON p.person_id = w.userid
WHERE w.warteid = :wid
LIMIT 1");
$stWait->execute(['wid' => $warteid]);
$row = $stWait->fetch(PDO::FETCH_ASSOC);
return $row ?: null;
}
function workflowCountWaitersForPlan(PDO $pdo, int $impfstoffId, int $planId): int
{
return impfWorkflowNotificationCountWaitersForPlan($pdo, $impfstoffId, $planId);
@@ -583,6 +600,55 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$error = "Wartelisten-Eintrag nicht gefunden.";
}
}
} elseif ($aktion === 'confirm_waitlist') {
$warteid = (int)($_POST['warteid'] ?? 0);
if ($warteid <= 0) {
$error = "Ungültiger Wartelisten-Eintrag.";
} else {
$waitRow = workflowLoadWaitlistEntry($pdo, $warteid);
if (!$waitRow) {
$error = "Wartelisten-Eintrag nicht gefunden.";
} elseif ((int)$waitRow['checked'] >= 1) {
$error = "Der Wartelisten-Eintrag ist bereits bestätigt.";
} else {
$stUpdate = $pdo->prepare("UPDATE warteliste
SET checked = 1
WHERE warteid = :wid
AND checked < 1");
$stUpdate->execute(['wid' => $warteid]);
if ($stUpdate->rowCount() < 1) {
$error = "Wartelisten-Eintrag konnte nicht bestätigt werden.";
} else {
SendMailMessageVorlage($pdo, '2', $warteid, '9');
$notificationEvents = impfWorkflowNotificationProcess($pdo);
$personName = trim((string)($waitRow['vorname'] ?? '') . ' ' . (string)($waitRow['nachname'] ?? ''));
$message = "Wartelisten-Eintrag für " . trim($personName) . " wurde bestätigt.";
if (!empty($notificationEvents)) {
$message .= ' ' . count($notificationEvents) . " Impfworkflow-Benachrichtigung(en) wurden versendet.";
}
}
}
}
} elseif ($aktion === 'cancel_waitlist') {
$warteid = (int)($_POST['warteid'] ?? 0);
if ($warteid <= 0) {
$error = "Ungültiger Wartelisten-Eintrag.";
} else {
$waitRow = workflowLoadWaitlistEntry($pdo, $warteid);
if (!$waitRow) {
$error = "Wartelisten-Eintrag nicht gefunden.";
} else {
SendMailMessageVorlage($pdo, '2', $warteid, '10');
workflowDeleteWaitlistEntry($pdo, $warteid);
$notificationEvents = impfWorkflowNotificationProcess($pdo);
$personName = trim((string)($waitRow['vorname'] ?? '') . ' ' . (string)($waitRow['nachname'] ?? ''));
$message = "Wartelisten-Eintrag für " . trim($personName) . " wurde abgesagt.";
if (!empty($notificationEvents)) {
$message .= ' ' . count($notificationEvents) . " Impfworkflow-Benachrichtigung(en) wurden versendet.";
}
}
}
}
}
@@ -809,7 +875,19 @@ try {
<td><?php echo esc(workflowWarteStatus((int)$w['checked'])); ?></td>
<td><?php echo esc((string)$w['date_created']); ?></td>
<td>
<form method="post" onsubmit="return confirm('Eintrag wirklich löschen?');">
<?php if ((int)$w['checked'] === 0): ?>
<form method="post" style="display:inline-block; margin-right:6px;" onsubmit="return confirm('Eintrag wirklich als bestätigt markieren?');">
<input type="hidden" name="aktion" value="confirm_waitlist">
<input type="hidden" name="warteid" value="<?php echo (int)$w['warteid']; ?>">
<button class="btn btn-success btn-xs" type="submit">Bestätigen</button>
</form>
<?php endif; ?>
<form method="post" style="display:inline-block; margin-right:6px;" onsubmit="return confirm('Wartelisten-Eintrag wirklich absagen?');">
<input type="hidden" name="aktion" value="cancel_waitlist">
<input type="hidden" name="warteid" value="<?php echo (int)$w['warteid']; ?>">
<button class="btn btn-warning btn-xs" type="submit">Absagen</button>
</form>
<form method="post" style="display:inline-block;" onsubmit="return confirm('Eintrag wirklich löschen?');">
<input type="hidden" name="aktion" value="delete_waitlist">
<input type="hidden" name="warteid" value="<?php echo (int)$w['warteid']; ?>">
<button class="btn btn-danger btn-xs" type="submit">Löschen</button>
+9 -9
View File
@@ -1,12 +1,12 @@
$(function() {
$("#user_input").autocomplete({
source: "inc/suchepatient.php",
minLength: 3,
select: function( event, ui ) {
event.preventDefault();
$("#userid_input").val(ui.item.id);
$("#user_input").val(ui.item.value);
$(function() {
$("#user_input").autocomplete({
source: "../inc/suchepatient.php",
minLength: 3,
select: function( event, ui ) {
event.preventDefault();
$("#userid_input").val(ui.item.id);
$("#user_input").val(ui.item.value);
$("#formbenutzersuche").submit();
}
});
@@ -43,4 +43,4 @@ function submitForm(sub) {
}).responseText;
//window.location.reload(false);
document.body.innerHTML = result;
}
}
+9 -9
View File
@@ -1,12 +1,12 @@
$(function() {
$("#user_input").autocomplete({
source: "inc/suchepatient.php",
minLength: 3,
select: function( event, ui ) {
event.preventDefault();
$("#userid_input").val(ui.item.id);
$("#user_input").val(ui.item.value);
$(function() {
$("#user_input").autocomplete({
source: "../inc/suchepatient.php",
minLength: 3,
select: function( event, ui ) {
event.preventDefault();
$("#userid_input").val(ui.item.id);
$("#user_input").val(ui.item.value);
$("#formbenutzersuche").submit();
}
});
@@ -43,4 +43,4 @@ function submitForm(sub) {
}).responseText;
//window.location.reload(false);
document.body.innerHTML = result;
}
}