fix: resolve 500 error in actions.php and re-implement token system checkbox
This commit is contained in:
parent
adc8aae5d0
commit
e4e7b4a246
@ -303,6 +303,28 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$stmt = $db->prepare("INSERT INTO visits (patient_id, doctor_id, appointment_id, weight, blood_pressure, heart_rate, temperature, symptoms, diagnosis, treatment_plan) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
$stmt = $db->prepare("INSERT INTO visits (patient_id, doctor_id, appointment_id, weight, blood_pressure, heart_rate, temperature, symptoms, diagnosis, treatment_plan) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
$stmt->execute([$patient_id, $doctor_id, $appointment_id, $weight, $bp, $hr, $temp, $symptoms, $diagnosis, $treatment]);
|
$stmt->execute([$patient_id, $doctor_id, $appointment_id, $weight, $bp, $hr, $temp, $symptoms, $diagnosis, $treatment]);
|
||||||
$visit_id = $db->lastInsertId();
|
$visit_id = $db->lastInsertId();
|
||||||
|
$token_message = '';
|
||||||
|
|
||||||
|
// Token Generation
|
||||||
|
if (isset($_POST['generate_token']) && $_POST['generate_token'] == '1') {
|
||||||
|
$stmtDoc = $db->prepare("SELECT department_id FROM doctors WHERE id = ?");
|
||||||
|
$stmtDoc->execute([$doctor_id]);
|
||||||
|
$docData = $stmtDoc->fetch();
|
||||||
|
$dept_id = $docData ? $docData['department_id'] : null;
|
||||||
|
|
||||||
|
if ($dept_id) {
|
||||||
|
$today = date('Y-m-d');
|
||||||
|
$stmtTok = $db->prepare("SELECT MAX(token_number) FROM patient_queue WHERE department_id = ? AND DATE(created_at) = ?");
|
||||||
|
$stmtTok->execute([$dept_id, $today]);
|
||||||
|
$max_token = $stmtTok->fetchColumn();
|
||||||
|
$next_token = ($max_token) ? $max_token + 1 : 1;
|
||||||
|
|
||||||
|
$stmtQueue = $db->prepare("INSERT INTO patient_queue (patient_id, department_id, doctor_id, visit_id, token_number, status, created_at) VALUES (?, ?, ?, ?, ?, 'waiting', NOW())");
|
||||||
|
$stmtQueue->execute([$patient_id, $dept_id, $doctor_id, $visit_id, $next_token]);
|
||||||
|
|
||||||
|
$token_message = " (" . __('token') . ": #" . $next_token . ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
if (isset($_POST['prescriptions']) && is_array($_POST['prescriptions'])) {
|
if (isset($_POST['prescriptions']) && is_array($_POST['prescriptions'])) {
|
||||||
$drug_names = $_POST['prescriptions']['drug_name'] ?? [];
|
$drug_names = $_POST['prescriptions']['drug_name'] ?? [];
|
||||||
$dosages = $_POST['prescriptions']['dosage'] ?? [];
|
$dosages = $_POST['prescriptions']['dosage'] ?? [];
|
||||||
@ -320,7 +342,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$stmt->execute([$appointment_id]);
|
$stmt->execute([$appointment_id]);
|
||||||
}
|
}
|
||||||
$db->commit();
|
$db->commit();
|
||||||
$_SESSION['flash_message'] = __('add_visit') . ' ' . __('successfully');
|
$_SESSION['flash_message'] = __('add_visit') . ' ' . __('successfully') . $token_message;
|
||||||
$redirect = true;
|
$redirect = true;
|
||||||
}
|
}
|
||||||
} elseif ($_POST['action'] === 'edit_visit') {
|
} elseif ($_POST['action'] === 'edit_visit') {
|
||||||
|
|||||||
@ -972,6 +972,12 @@
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-12 mb-3">
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input class="form-check-input" type="checkbox" id="generate_token" name="generate_token" value="1">
|
||||||
|
<label class="form-check-label" for="generate_token"><?php echo __('issue_token'); ?></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user