Initial commit

This commit is contained in:
2025-01-07 17:55:50 +08:00
commit eab1d70061
86 changed files with 2772 additions and 0 deletions

View File

@ -0,0 +1,114 @@
<?php
include "db_config.php";
date_default_timezone_set("Asia/Shanghai");
$conn = $link;
// 生成UUID函数
function generateUUID() {
return bin2hex(random_bytes(16));
}
// 初始化变量
$patient_id = $doctor_id = $fee = "";
$register_date = date("Y-m-d");
$message = "";
// 提交表单处理
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$patient_id = $_POST["patient_id"];
$doctor_id = $_POST["doctor_id"];
$fee = empty($_POST["fee"]) ? 10 : (int)$_POST["fee"]; // 默认挂号费为10元
$current_date = strtotime($register_date);
// 检查同一患者当天是否已挂号
$sql_check = "SELECT * FROM register_90 WHERE patient_id = '$patient_id' AND register_date = $current_date";
$result_check = $conn->query($sql_check);
if ($result_check->num_rows > 0) {
// 更新挂号信息
$sql_update = "UPDATE register_90 SET doctor_id = '$doctor_id', fee = $fee, state = '1' WHERE patient_id = '$patient_id' AND register_date = $current_date";
if ($conn->query($sql_update)) {
$message = "挂号信息已更新!";
} else {
$message = "更新失败: " . $conn->error;
}
} else {
// 插入新挂号记录
$biz_id = generateUUID();
$sql_insert = "INSERT INTO register_90 (biz_id, doctor_id, patient_id, register_date, fee, state) VALUES ('$biz_id', '$doctor_id', '$patient_id', $current_date, $fee, '1')";
if ($conn->query($sql_insert)) {
$message = "挂号成功!";
} else {
$message = "挂号失败: " . $conn->error;
}
}
}
// 获取患者列表
$sql_patients = "SELECT patient_id, patient_name FROM patient_90";
$result_patients = $conn->query($sql_patients);
// 获取医生和科室列表
$sql_doctors = "
SELECT doctor_90.doctor_id, doctor_90.doctor_name, department_90.department_name
FROM doctor_90
JOIN department_90 ON doctor_90.department_id = department_90.department_id";
$result_doctors = $conn->query($sql_doctors);
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>患者挂号</title>
</head>
<body>
<h2>患者挂号</h2>
<form action="patient_register_90.php" method="post">
<!-- 患者选择 -->
<label for="patient_id">选择患者:</label>
<select id="patient_id" name="patient_id">
<?php if ($result_patients->num_rows > 0): ?>
<?php while ($row = $result_patients->fetch_assoc()) { ?>
<option value="<?php echo $row['patient_id']; ?>" <?php echo ($patient_id == $row['patient_id']) ? "selected" : ""; ?>>
<?php echo $row['patient_name']; ?>
</option>
<?php } ?>
<?php else: ?>
<option value="">暂无患者数据</option>
<?php endif; ?>
</select>
<br><br>
<!-- 医生选择 -->
<label for="doctor_id">选择医生:</label>
<select id="doctor_id" name="doctor_id">
<?php if ($result_doctors->num_rows > 0): ?>
<?php while ($row = $result_doctors->fetch_assoc()) { ?>
<option value="<?php echo $row['doctor_id']; ?>" <?php echo ($doctor_id == $row['doctor_id']) ? "selected" : ""; ?>>
<?php echo $row['doctor_name'] . "|" . $row['department_name']; ?>
</option>
<?php } ?>
<?php else: ?>
<option value="">暂无医生数据</option>
<?php endif; ?>
</select>
<br><br>
<!-- 挂号时间 -->
<label for="register_date">挂号时间:</label>
<input type="text" id="register_date" name="register_date" value="<?php echo $register_date; ?>" readonly>
<br><br>
<!-- 挂号费 -->
<label for="fee">挂号费:</label>
<input type="text" id="fee" name="fee" value="<?php echo $fee; ?>">
<br><br>
<!-- 提交按钮 -->
<input type="submit" id="ok" name="ok" value="确定">
</form>
<p><?php echo $message; ?></p>
</body>
</html>