';
exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$action = $_POST['action'] ?? '';
if ($action == 'start') {
$chief_complaint = $_POST['chief_complaint'] ? mysqli_real_escape_string($connID, $_POST['chief_complaint']) : NULL;
$notes = $_POST['notes'] ? mysqli_real_escape_string($connID, $_POST['notes']) : NULL;
$sql = "UPDATE medical_records SET
status = '就诊中',
chief_complaint = " . ($chief_complaint ? "'$chief_complaint'" : "chief_complaint") . ",
notes = " . ($notes ? "'$notes'" : "notes") . "
WHERE id = $record_id AND status = '待诊'";
if (mysqli_query($connID, $sql)) {
if (mysqli_affected_rows($connID) > 0) {
echo '
已开始诊治,病历状态已更新!
';
echo '';
} else {
echo '
操作失败,病历可能已被其他医生处理
';
}
} else {
echo '
操作失败:' . mysqli_error($connID) . '
';
}
}
}
$sql = "SELECT mr.*, p.name as patient_name, p.gender as patient_gender, p.birth_date, p.phone as patient_phone,
d.name as doctor_name, d.specialty, dept.name as department_name
FROM medical_records mr
JOIN patients p ON mr.patient_id = p.id
JOIN doctors d ON mr.doctor_id = d.id
JOIN departments dept ON mr.department_id = dept.id
WHERE mr.id = $record_id";
$result = mysqli_query($connID, $sql);
if (mysqli_num_rows($result) == 0) {
echo '