feat: 药品信息管理模块

This commit is contained in:
chihaya 2025-05-28 10:17:39 +08:00
parent 7145d3975d
commit 1eeb027acc
4 changed files with 1061 additions and 0 deletions

158
modules/medications/add.php Normal file
View File

@ -0,0 +1,158 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>新增药品 - 电子病历系统</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
<link href="../../css/material.css" rel="stylesheet">
</head>
<body>
<header class="header">
<h1>
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M17,3C18.1,3 19,3.9 19,5V8H21V10H19V19C19,20.1 18.1,21 17,21H7C5.9,21 5,20.1 5,19V10H3V8H5V5C5,3.9 5.9,3 7,3H17M7,5V8H17V5H7M7,10V19H17V10H7M9,12H15V14H9V12M9,15H13V17H9V15Z"/>
</svg>
新增药品
</h1>
</header>
<nav class="nav-menu">
<ul>
<li><a href="../../index.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z"/>
</svg>
仪表板
</a></li>
<li><a href="../patients/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z"/>
</svg>
患者管理
</a></li>
<li><a href="../doctors/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M14.84,2.5C16.2,2.5 17.5,3.2 18.28,4.38L18.5,4.75L19.25,4.38C19.92,4 20.75,4.2 21.13,4.87C21.5,5.54 21.33,6.42 20.66,6.79L20.04,7.12C20.04,7.12 20.04,7.12 20.04,7.12C20.47,7.88 20.47,8.78 20.04,9.54L20.5,9.78C21.17,10.15 21.33,11.04 20.97,11.71C20.6,12.38 19.72,12.54 19.05,12.17L18.5,11.88C17.71,13.07 16.39,13.77 15.04,13.77C13.68,13.77 12.36,13.07 11.57,11.88L11,12.17C10.33,12.54 9.45,12.38 9.08,11.71C8.71,11.04 8.88,10.15 9.55,9.78L10,9.54C9.58,8.78 9.58,7.88 10,7.12L9.38,6.79C8.71,6.42 8.55,5.54 8.92,4.87C9.29,4.2 10.17,4 10.84,4.38L11.57,4.75C12.35,3.56 13.67,2.86 15.04,2.86M15.04,4.64C14.18,4.64 13.4,5.09 12.96,5.78L12.5,6.5L11.78,6.06C11.58,5.94 11.32,6 11.19,6.21C11.07,6.42 11.13,6.68 11.34,6.81L12.06,7.25L11.78,7.94C11.58,8.38 11.58,8.87 11.78,9.31L12.06,10L11.34,10.44C11.13,10.57 11.07,10.83 11.19,11.04C11.32,11.25 11.58,11.31 11.78,11.19L12.5,10.75L12.96,11.47C13.4,12.16 14.18,12.61 15.04,12.61C15.9,12.61 16.68,12.16 17.12,11.47L17.58,10.75L18.3,11.19C18.5,11.31 18.76,11.25 18.89,11.04C19.01,10.83 18.95,10.57 18.74,10.44L18.02,10L18.3,9.31C18.5,8.87 18.5,8.38 18.3,7.94L18.02,7.25L18.74,6.81C18.95,6.68 19.01,6.42 18.89,6.21C18.76,6 18.5,5.94 18.3,6.06L17.58,6.5L17.12,5.78C16.68,5.09 15.9,4.64 15.04,4.64M11,15.5V17.5H3V15.5C3,14.39 6.69,13.5 9.5,13.5C10.4,13.5 11.5,13.65 12.5,13.91C11.84,14.8 11.5,15.88 11.5,17C11.34,16.83 11.17,16.66 11,15.5M9.5,12A2.5,2.5 0 0,1 7,9.5A2.5,2.5 0 0,1 9.5,7A2.5,2.5 0 0,1 12,9.5A2.5,2.5 0 0,1 9.5,12Z"/>
</svg>
医生管理
</a></li>
<li><a href="../medical_records/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z"/>
</svg>
病历管理
</a></li>
<li><a href="../departments/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,11.5A2.5,2.5 0 0,1 9.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,11.5M12,2A7,7 0 0,0 5,9C5,14.25 12,22 12,22C12,22 19,14.25 19,9A7,7 0 0,0 12,2Z"/>
</svg>
科室管理
</a></li>
<li><a href="list.php" class="active">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M17,3C18.1,3 19,3.9 19,5V8H21V10H19V19C19,20.1 18.1,21 17,21H7C5.9,21 5,20.1 5,19V10H3V8H5V5C5,3.9 5.9,3 7,3H17M7,5V8H17V5H7M7,10V19H17V10H7M9,12H15V14H9V12M9,15H13V17H9V15Z"/>
</svg>
药品管理
</a></li>
</ul>
</nav>
<div class="container">
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
include "../../conn/conn.php";
$name = mysqli_real_escape_string($connID, $_POST['name']);
$specification = mysqli_real_escape_string($connID, $_POST['specification']);
$unit = mysqli_real_escape_string($connID, $_POST['unit']);
$manufacturer = mysqli_real_escape_string($connID, $_POST['manufacturer']);
$price = $_POST['price'] ? (float)$_POST['price'] : null;
$sql = "INSERT INTO medications (name, specification, unit, manufacturer, price)
VALUES ('$name', '$specification', '$unit', '$manufacturer', " . ($price ? "'$price'" : "NULL") . ")";
if (mysqli_query($connID, $sql)) {
echo '<div class="alert alert-success">药品信息添加成功!</div>';
echo '<script>setTimeout(function(){window.location.href="list.php";}, 2000);</script>';
} else {
echo '<div class="alert alert-error">添加失败:' . mysqli_error($connID) . '</div>';
}
}
?>
<div class="card">
<div class="card-header">
<h2 class="card-title">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z"/>
</svg>
新增药品信息
</h2>
</div>
<div class="card-content">
<form method="POST">
<div class="grid grid-2">
<div class="form-group">
<label class="form-label">药品名称 *</label>
<input type="text" name="name" class="form-control" required placeholder="请输入完整的药品通用名称">
</div>
<div class="form-group">
<label class="form-label">规格 *</label>
<input type="text" name="specification" class="form-control" required placeholder="0.25g*24粒">
</div>
<div class="form-group">
<label class="form-label">单位 *</label>
<select name="unit" class="form-control" required>
<option value="">请选择单位</option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value="毫升">毫升</option>
<option value=""></option>
<option value="千克">千克</option>
</select>
</div>
<div class="form-group">
<label class="form-label">生产厂家 *</label>
<input type="text" name="manufacturer" class="form-control" required placeholder="请输入生产厂家名称">
</div>
<div class="form-group">
<label class="form-label">价格(元)</label>
<input type="number" name="price" class="form-control" step="0.01" min="0" placeholder="单价(可选)">
</div>
</div>
<div style="margin-top: 24px; padding: 16px; background: #f5f5f5; border-radius: 4px;">
<h4 style="margin: 0 0 12px 0; color: #666;">填写说明</h4>
<ul style="margin: 0; padding-left: 20px; color: #666; font-size: 14px; line-height: 1.6;">
<li>药品名称请使用通用名称,如:阿莫西林胶囊</li>
<li>规格格式示例0.25g*24粒、100ml/瓶、50mg*10</li>
<li>生产厂家请填写完整的企业名称</li>
<li>价格为可选项,可后续在编辑时补充</li>
</ul>
</div>
<div style="display: flex; gap: 16px; margin-top: 24px;">
<button type="submit" class="btn btn-primary">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/>
</svg>
保存药品信息
</button>
<a href="list.php" class="btn" style="background: #f5f5f5; color: #666;">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"/>
</svg>
取消
</a>
</div>
</form>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,201 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>编辑药品 - 电子病历系统</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
<link href="../../css/material.css" rel="stylesheet">
</head>
<body>
<header class="header">
<h1>
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z"/>
</svg>
编辑药品信息
</h1>
</header>
<nav class="nav-menu">
<ul>
<li><a href="../../index.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z"/>
</svg>
仪表板
</a></li>
<li><a href="../patients/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z"/>
</svg>
患者管理
</a></li>
<li><a href="../doctors/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M14.84,2.5C16.2,2.5 17.5,3.2 18.28,4.38L18.5,4.75L19.25,4.38C19.92,4 20.75,4.2 21.13,4.87C21.5,5.54 21.33,6.42 20.66,6.79L20.04,7.12C20.04,7.12 20.04,7.12 20.04,7.12C20.47,7.88 20.47,8.78 20.04,9.54L20.5,9.78C21.17,10.15 21.33,11.04 20.97,11.71C20.6,12.38 19.72,12.54 19.05,12.17L18.5,11.88C17.71,13.07 16.39,13.77 15.04,13.77C13.68,13.77 12.36,13.07 11.57,11.88L11,12.17C10.33,12.54 9.45,12.38 9.08,11.71C8.71,11.04 8.88,10.15 9.55,9.78L10,9.54C9.58,8.78 9.58,7.88 10,7.12L9.38,6.79C8.71,6.42 8.55,5.54 8.92,4.87C9.29,4.2 10.17,4 10.84,4.38L11.57,4.75C12.35,3.56 13.67,2.86 15.04,2.86M15.04,4.64C14.18,4.64 13.4,5.09 12.96,5.78L12.5,6.5L11.78,6.06C11.58,5.94 11.32,6 11.19,6.21C11.07,6.42 11.13,6.68 11.34,6.81L12.06,7.25L11.78,7.94C11.58,8.38 11.58,8.87 11.78,9.31L12.06,10L11.34,10.44C11.13,10.57 11.07,10.83 11.19,11.04C11.32,11.25 11.58,11.31 11.78,11.19L12.5,10.75L12.96,11.47C13.4,12.16 14.18,12.61 15.04,12.61C15.9,12.61 16.68,12.16 17.12,11.47L17.58,10.75L18.3,11.19C18.5,11.31 18.76,11.25 18.89,11.04C19.01,10.83 18.95,10.57 18.74,10.44L18.02,10L18.3,9.31C18.5,8.87 18.5,8.38 18.3,7.94L18.02,7.25L18.74,6.81C18.95,6.68 19.01,6.42 18.89,6.21C18.76,6 18.5,5.94 18.3,6.06L17.58,6.5L17.12,5.78C16.68,5.09 15.9,4.64 15.04,4.64M11,15.5V17.5H3V15.5C3,14.39 6.69,13.5 9.5,13.5C10.4,13.5 11.5,13.65 12.5,13.91C11.84,14.8 11.5,15.88 11.5,17C11.34,16.83 11.17,16.66 11,15.5M9.5,12A2.5,2.5 0 0,1 7,9.5A2.5,2.5 0 0,1 9.5,7A2.5,2.5 0 0,1 12,9.5A2.5,2.5 0 0,1 9.5,12Z"/>
</svg>
医生管理
</a></li>
<li><a href="../medical_records/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z"/>
</svg>
病历管理
</a></li>
<li><a href="../departments/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,11.5A2.5,2.5 0 0,1 9.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,11.5M12,2A7,7 0 0,0 5,9C5,14.25 12,22 12,22C12,22 19,14.25 19,9A7,7 0 0,0 12,2Z"/>
</svg>
科室管理
</a></li>
<li><a href="list.php" class="active">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M17,3C18.1,3 19,3.9 19,5V8H21V10H19V19C19,20.1 18.1,21 17,21H7C5.9,21 5,20.1 5,19V10H3V8H5V5C5,3.9 5.9,3 7,3H17M7,5V8H17V5H7M7,10V19H17V10H7M9,12H15V14H9V12M9,15H13V17H9V15Z"/>
</svg>
药品管理
</a></li>
</ul>
</nav>
<div class="container">
<?php
include "../../conn/conn.php";
$medication_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
if ($medication_id <= 0) {
echo '<div class="alert alert-error">无效的药品ID</div>';
exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = mysqli_real_escape_string($connID, $_POST['name']);
$specification = mysqli_real_escape_string($connID, $_POST['specification']);
$unit = mysqli_real_escape_string($connID, $_POST['unit']);
$manufacturer = mysqli_real_escape_string($connID, $_POST['manufacturer']);
$price = $_POST['price'] ? (float)$_POST['price'] : null;
$sql = "UPDATE medications SET
name = '$name',
specification = '$specification',
unit = '$unit',
manufacturer = '$manufacturer',
price = " . ($price ? "'$price'" : "NULL") . "
WHERE id = $medication_id";
if (mysqli_query($connID, $sql)) {
echo '<div class="alert alert-success">药品信息更新成功!</div>';
echo '<script>setTimeout(function(){window.location.href="list.php";}, 2000);</script>';
} else {
echo '<div class="alert alert-error">更新失败:' . mysqli_error($connID) . '</div>';
}
}
$sql = "SELECT * FROM medications WHERE id = $medication_id";
$result = mysqli_query($connID, $sql);
if (mysqli_num_rows($result) == 0) {
echo '<div class="alert alert-error">药品不存在</div>';
exit;
}
$medication = mysqli_fetch_assoc($result);
?>
<div class="card">
<div class="card-header">
<h2 class="card-title">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z"/>
</svg>
编辑药品信息
</h2>
<p style="margin: 8px 0 0 0; color: #666;">
当前编辑:<?php echo htmlspecialchars($medication['name']); ?> - <?php echo htmlspecialchars($medication['specification']); ?>
</p>
</div>
<div class="card-content">
<form method="POST">
<div class="grid grid-2">
<div class="form-group">
<label class="form-label">药品名称 *</label>
<input type="text" name="name" class="form-control" required
value="<?php echo htmlspecialchars($medication['name']); ?>"
placeholder="请输入完整的药品通用名称">
</div>
<div class="form-group">
<label class="form-label">规格 *</label>
<input type="text" name="specification" class="form-control" required
value="<?php echo htmlspecialchars($medication['specification']); ?>"
placeholder="0.25g*24粒">
</div>
<div class="form-group">
<label class="form-label">单位 *</label>
<select name="unit" class="form-control" required>
<option value="">请选择单位</option>
<option value="" <?php echo $medication['unit'] == '盒' ? 'selected' : ''; ?>>盒</option>
<option value="" <?php echo $medication['unit'] == '瓶' ? 'selected' : ''; ?>>瓶</option>
<option value="" <?php echo $medication['unit'] == '支' ? 'selected' : ''; ?>>支</option>
<option value="" <?php echo $medication['unit'] == '片' ? 'selected' : ''; ?>>片</option>
<option value="" <?php echo $medication['unit'] == '粒' ? 'selected' : ''; ?>>粒</option>
<option value="" <?php echo $medication['unit'] == '袋' ? 'selected' : ''; ?>>袋</option>
<option value="毫升" <?php echo $medication['unit'] == '毫升' ? 'selected' : ''; ?>>毫升</option>
<option value="" <?php echo $medication['unit'] == '克' ? 'selected' : ''; ?>>克</option>
<option value="千克" <?php echo $medication['unit'] == '千克' ? 'selected' : ''; ?>>千克</option>
</select>
</div>
<div class="form-group">
<label class="form-label">生产厂家 *</label>
<input type="text" name="manufacturer" class="form-control" required
value="<?php echo htmlspecialchars($medication['manufacturer']); ?>"
placeholder="请输入生产厂家名称">
</div>
<div class="form-group">
<label class="form-label">价格(元)</label>
<input type="number" name="price" class="form-control" step="0.01" min="0"
value="<?php echo $medication['price']; ?>"
placeholder="单价(可选)">
</div>
</div>
<div style="margin-top: 24px; padding: 16px; background: #f5f5f5; border-radius: 4px;">
<h4 style="margin: 0 0 12px 0; color: #666;">编辑说明</h4>
<ul style="margin: 0; padding-left: 20px; color: #666; font-size: 14px; line-height: 1.6;">
<li>修改药品信息会影响新创建的处方</li>
<li>价格修改不会影响已开具的处方</li>
<li>如有库存相关业务,请谨慎修改规格和单位信息</li>
<li>生产厂家变更请确认药品批准文号等相关信息</li>
</ul>
</div>
<div style="display: flex; gap: 16px; margin-top: 24px;">
<button type="submit" class="btn btn-primary">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/>
</svg>
保存修改
</button>
<a href="list.php" class="btn btn-secondary">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M9,12L11,14L15,10M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2Z"/>
</svg>
返回列表
</a>
<a href="list.php" class="btn" style="background: #f5f5f5; color: #666;">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"/>
</svg>
取消
</a>
</div>
</form>
</div>
</div>
<div style="margin-top: 16px; text-align: center; color: #666; font-size: 14px;">
创建时间:<?php echo date('Y年m月d日 H:i', strtotime($medication['created_at'])); ?>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,278 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>药品管理 - 电子病历系统</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
<link href="../../css/material.css" rel="stylesheet">
</head>
<body>
<header class="header">
<h1>
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M17,3C18.1,3 19,3.9 19,5V8H21V10H19V19C19,20.1 18.1,21 17,21H7C5.9,21 5,20.1 5,19V10H3V8H5V5C5,3.9 5.9,3 7,3H17M7,5V8H17V5H7M7,10V19H17V10H7M9,12H15V14H9V12M9,15H13V17H9V15Z"/>
</svg>
药品管理
</h1>
</header>
<nav class="nav-menu">
<ul>
<li><a href="../../index.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z"/>
</svg>
仪表板
</a></li>
<li><a href="../patients/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z"/>
</svg>
患者管理
</a></li>
<li><a href="../doctors/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M14.84,2.5C16.2,2.5 17.5,3.2 18.28,4.38L18.5,4.75L19.25,4.38C19.92,4 20.75,4.2 21.13,4.87C21.5,5.54 21.33,6.42 20.66,6.79L20.04,7.12C20.04,7.12 20.04,7.12 20.04,7.12C20.47,7.88 20.47,8.78 20.04,9.54L20.5,9.78C21.17,10.15 21.33,11.04 20.97,11.71C20.6,12.38 19.72,12.54 19.05,12.17L18.5,11.88C17.71,13.07 16.39,13.77 15.04,13.77C13.68,13.77 12.36,13.07 11.57,11.88L11,12.17C10.33,12.54 9.45,12.38 9.08,11.71C8.71,11.04 8.88,10.15 9.55,9.78L10,9.54C9.58,8.78 9.58,7.88 10,7.12L9.38,6.79C8.71,6.42 8.55,5.54 8.92,4.87C9.29,4.2 10.17,4 10.84,4.38L11.57,4.75C12.35,3.56 13.67,2.86 15.04,2.86M15.04,4.64C14.18,4.64 13.4,5.09 12.96,5.78L12.5,6.5L11.78,6.06C11.58,5.94 11.32,6 11.19,6.21C11.07,6.42 11.13,6.68 11.34,6.81L12.06,7.25L11.78,7.94C11.58,8.38 11.58,8.87 11.78,9.31L12.06,10L11.34,10.44C11.13,10.57 11.07,10.83 11.19,11.04C11.32,11.25 11.58,11.31 11.78,11.19L12.5,10.75L12.96,11.47C13.4,12.16 14.18,12.61 15.04,12.61C15.9,12.61 16.68,12.16 17.12,11.47L17.58,10.75L18.3,11.19C18.5,11.31 18.76,11.25 18.89,11.04C19.01,10.83 18.95,10.57 18.74,10.44L18.02,10L18.3,9.31C18.5,8.87 18.5,8.38 18.3,7.94L18.02,7.25L18.74,6.81C18.95,6.68 19.01,6.42 18.89,6.21C18.76,6 18.5,5.94 18.3,6.06L17.58,6.5L17.12,5.78C16.68,5.09 15.9,4.64 15.04,4.64M11,15.5V17.5H3V15.5C3,14.39 6.69,13.5 9.5,13.5C10.4,13.5 11.5,13.65 12.5,13.91C11.84,14.8 11.5,15.88 11.5,17C11.34,16.83 11.17,16.66 11,15.5M9.5,12A2.5,2.5 0 0,1 7,9.5A2.5,2.5 0 0,1 9.5,7A2.5,2.5 0 0,1 12,9.5A2.5,2.5 0 0,1 9.5,12Z"/>
</svg>
医生管理
</a></li>
<li><a href="../medical_records/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z"/>
</svg>
病历管理
</a></li>
<li><a href="../departments/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,11.5A2.5,2.5 0 0,1 9.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,11.5M12,2A7,7 0 0,0 5,9C5,14.25 12,22 12,22C12,22 19,14.25 19,9A7,7 0 0,0 12,2Z"/>
</svg>
科室管理
</a></li>
<li><a href="list.php" class="active">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M17,3C18.1,3 19,3.9 19,5V8H21V10H19V19C19,20.1 18.1,21 17,21H7C5.9,21 5,20.1 5,19V10H3V8H5V5C5,3.9 5.9,3 7,3H17M7,5V8H17V5H7M7,10V19H17V10H7M9,12H15V14H9V12M9,15H13V17H9V15Z"/>
</svg>
药品管理
</a></li>
</ul>
</nav>
<div class="container">
<div class="card">
<div class="card-header">
<h2 class="card-title">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M17,3C18.1,3 19,3.9 19,5V8H21V10H19V19C19,20.1 18.1,21 17,21H7C5.9,21 5,20.1 5,19V10H3V8H5V5C5,3.9 5.9,3 7,3H17M7,5V8H17V5H7M7,10V19H17V10H7M9,12H15V14H9V12M9,15H13V17H9V15Z"/>
</svg>
药品列表
</h2>
<div style="margin-top: 16px;">
<a href="add.php" class="btn btn-primary">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z"/>
</svg>
新增药品
</a>
</div>
</div>
<div class="card-content">
<div style="margin-bottom: 20px;">
<form method="GET" style="display: flex; gap: 16px; align-items: center;">
<input type="text" name="search" class="form-control" placeholder="搜索药品名称或生产厂家"
value="<?php echo isset($_GET['search']) ? htmlspecialchars($_GET['search']) : ''; ?>"
style="max-width: 300px;">
<select name="sort" class="form-control" style="max-width: 150px;">
<option value="name" <?php echo (isset($_GET['sort']) && $_GET['sort'] == 'name') ? 'selected' : ''; ?>>按名称排序</option>
<option value="price_low" <?php echo (isset($_GET['sort']) && $_GET['sort'] == 'price_low') ? 'selected' : ''; ?>>价格从低到高</option>
<option value="price_high" <?php echo (isset($_GET['sort']) && $_GET['sort'] == 'price_high') ? 'selected' : ''; ?>>价格从高到低</option>
<option value="newest" <?php echo (isset($_GET['sort']) && $_GET['sort'] == 'newest') ? 'selected' : ''; ?>>最新添加</option>
</select>
<button type="submit" class="btn btn-primary btn-small">搜索</button>
<?php if(isset($_GET['search']) && $_GET['search']): ?>
<a href="list.php" class="btn btn-small" style="background: #f5f5f5; color: #666;">清除</a>
<?php endif; ?>
</form>
</div>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>药品名称</th>
<th>规格</th>
<th>单位</th>
<th>生产厂家</th>
<th>价格</th>
<th>添加时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php
include "../../conn/conn.php";
$search = isset($_GET['search']) ? trim($_GET['search']) : '';
$sort = isset($_GET['sort']) ? $_GET['sort'] : 'name';
$where_clause = '';
if ($search) {
$search = mysqli_real_escape_string($connID, $search);
$where_clause = "WHERE name LIKE '%$search%' OR manufacturer LIKE '%$search%'";
}
$order_clause = '';
switch($sort) {
case 'price_low':
$order_clause = 'ORDER BY price ASC';
break;
case 'price_high':
$order_clause = 'ORDER BY price DESC';
break;
case 'newest':
$order_clause = 'ORDER BY created_at DESC';
break;
default:
$order_clause = 'ORDER BY name ASC';
break;
}
$sql = "SELECT * FROM medications $where_clause $order_clause";
$result = mysqli_query($connID, $sql);
if(mysqli_num_rows($result) > 0):
while($medication = mysqli_fetch_assoc($result)):
?>
<tr>
<td><?php echo $medication['id']; ?></td>
<td><strong><?php echo htmlspecialchars($medication['name']); ?></strong></td>
<td><?php echo htmlspecialchars($medication['specification']); ?></td>
<td><?php echo htmlspecialchars($medication['unit']); ?></td>
<td><?php echo htmlspecialchars($medication['manufacturer']); ?></td>
<td>
<?php if($medication['price']): ?>
<strong style="color: #1976d2;">¥<?php echo number_format($medication['price'], 2); ?></strong>
<?php else: ?>
<span style="color: #999;">未设置</span>
<?php endif; ?>
</td>
<td><?php echo date('Y-m-d H:i', strtotime($medication['created_at'])); ?></td>
<td>
<a href="view.php?id=<?php echo $medication['id']; ?>" class="btn btn-small btn-primary">查看</a>
<a href="edit.php?id=<?php echo $medication['id']; ?>" class="btn btn-small btn-warning">编辑</a>
<button onclick="prescribeMedication(<?php echo $medication['id']; ?>, '<?php echo htmlspecialchars($medication['name']); ?>')" class="btn btn-small btn-success">处方</button>
</td>
</tr>
<?php
endwhile;
else:
?>
<tr>
<td colspan="8" style="text-align: center; color: #999; padding: 40px;">
<?php if($search): ?>
未找到匹配的药品信息
<?php else: ?>
暂无药品数据
<?php endif; ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="grid grid-3" style="margin-top: 24px;">
<div class="card">
<div class="card-content">
<h3 style="color: #1976d2; margin-bottom: 16px;">快速统计</h3>
<?php
$total_medications = mysqli_query($connID, "SELECT COUNT(*) as count FROM medications");
$total_count = mysqli_fetch_assoc($total_medications)['count'];
$avg_price = mysqli_query($connID, "SELECT AVG(price) as avg_price FROM medications WHERE price > 0");
$avg_price_result = mysqli_fetch_assoc($avg_price)['avg_price'];
$expensive_count = mysqli_query($connID, "SELECT COUNT(*) as count FROM medications WHERE price > 50");
$expensive_count_result = mysqli_fetch_assoc($expensive_count)['count'];
?>
<div style="display: grid; gap: 12px;">
<div style="display: flex; justify-content: space-between; align-items: center; padding: 12px; background: #e3f2fd; border-radius: 4px;">
<span>药品总数</span>
<strong style="color: #1976d2; font-size: 18px;"><?php echo $total_count; ?></strong>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; padding: 12px; background: #e8f5e8; border-radius: 4px;">
<span>平均价格</span>
<strong style="color: #388e3c; font-size: 18px;">¥<?php echo number_format($avg_price_result ?: 0, 2); ?></strong>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; padding: 12px; background: #fff3e0; border-radius: 4px;">
<span>高价药品</span>
<strong style="color: #f57c00; font-size: 18px;"><?php echo $expensive_count_result; ?></strong>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-content">
<h3 style="color: #1976d2; margin-bottom: 16px;">常用药品</h3>
<?php
$common_medications = mysqli_query($connID, "SELECT m.*, COUNT(p.id) as usage_count
FROM medications m
LEFT JOIN prescriptions p ON m.id = p.medication_id
GROUP BY m.id
ORDER BY usage_count DESC
LIMIT 5");
?>
<div style="display: grid; gap: 8px;">
<?php while($med = mysqli_fetch_assoc($common_medications)): ?>
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px; border-bottom: 1px solid #e0e0e0;">
<div>
<strong><?php echo htmlspecialchars($med['name']); ?></strong>
<div style="font-size: 12px; color: #666;"><?php echo htmlspecialchars($med['specification']); ?></div>
</div>
<span style="font-size: 12px; color: #999;">使用 <?php echo $med['usage_count']; ?> 次</span>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
<div class="card">
<div class="card-content">
<h3 style="color: #1976d2; margin-bottom: 16px;">最新药品</h3>
<?php
$recent_medications = mysqli_query($connID, "SELECT * FROM medications ORDER BY created_at DESC LIMIT 5");
?>
<div style="display: grid; gap: 8px;">
<?php while($recent = mysqli_fetch_assoc($recent_medications)): ?>
<div style="padding: 8px; border: 1px solid #e0e0e0; border-radius: 4px;">
<div style="display: flex; justify-content: space-between; margin-bottom: 4px;">
<strong><?php echo htmlspecialchars($recent['name']); ?></strong>
<?php if($recent['price']): ?>
<span style="color: #1976d2; font-weight: 500;">¥<?php echo number_format($recent['price'], 2); ?></span>
<?php endif; ?>
</div>
<div style="font-size: 12px; color: #666;">
<?php echo htmlspecialchars($recent['manufacturer']); ?><br>
<?php echo date('m-d H:i', strtotime($recent['created_at'])); ?>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
</div>
</div>
<script>
function prescribeMedication(id, name) {
if(confirm('确定要为 "' + name + '" 创建处方吗?')) {
window.location.href = '../medical_records/add.php?medication_id=' + id;
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,424 @@
<?php
include "../../conn/conn.php";
// 获取药品ID
$medication_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($medication_id <= 0) {
echo "<script>alert('无效的药品ID'); window.location.href='list.php';</script>";
exit;
}
// 查询药品信息
$sql = "SELECT * FROM medications WHERE id = $medication_id";
$result = mysqli_query($connID, $sql);
if (mysqli_num_rows($result) == 0) {
echo "<script>alert('药品不存在'); window.location.href='list.php';</script>";
exit;
}
$medication = mysqli_fetch_assoc($result);
// 获取药品使用统计信息
$stats_sql = "SELECT
COUNT(DISTINCT mr.id) as total_prescriptions,
COUNT(DISTINCT mr.patient_id) as total_patients,
COUNT(CASE WHEN DATE(mr.created_at) = CURDATE() THEN 1 END) as today_prescriptions,
COUNT(CASE WHEN mr.created_at >= DATE_SUB(NOW(), INTERVAL 30 DAY) THEN 1 END) as month_prescriptions
FROM medical_records mr
WHERE mr.prescription LIKE '%{$medication['name']}%'";
$stats_result = mysqli_query($connID, $stats_sql);
$stats = mysqli_fetch_assoc($stats_result);
// 获取最近的处方记录
$recent_prescriptions_sql = "SELECT mr.*, p.name as patient_name, p.phone as patient_phone, d.name as doctor_name
FROM medical_records mr
JOIN patients p ON mr.patient_id = p.id
JOIN doctors d ON mr.doctor_id = d.id
WHERE mr.prescription LIKE '%{$medication['name']}%'
ORDER BY mr.created_at DESC
LIMIT 5";
$recent_prescriptions_result = mysqli_query($connID, $recent_prescriptions_sql);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>药品详情 - <?php echo htmlspecialchars($medication['name']); ?> - 电子病历系统</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
<link href="../../css/material.css" rel="stylesheet">
<style>
.medication-header {
background: linear-gradient(135deg, #26a69a 0%, #00796b 100%);
color: white;
padding: 2rem;
border-radius: 12px;
margin-bottom: 2rem;
position: relative;
overflow: hidden;
}
.medication-header::before {
content: '';
position: absolute;
top: 0;
right: 0;
width: 200px;
height: 200px;
background: rgba(255, 255, 255, 0.1);
border-radius: 50%;
transform: translate(50%, -50%);
}
.medication-avatar {
width: 80px;
height: 80px;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 2rem;
margin-bottom: 1rem;
border: 3px solid rgba(255, 255, 255, 0.3);
}
.medication-name {
font-size: 2rem;
font-weight: 500;
margin-bottom: 0.5rem;
}
.medication-spec {
font-size: 1.2rem;
opacity: 0.9;
margin-bottom: 0.5rem;
}
.medication-id {
background: rgba(255, 255, 255, 0.2);
display: inline-block;
padding: 0.3rem 0.8rem;
border-radius: 20px;
font-size: 0.9rem;
}
.price-badge {
background: linear-gradient(45deg, #ffa726, #ff9800);
color: white;
padding: 0.5rem 1rem;
border-radius: 25px;
font-size: 1.2rem;
font-weight: 600;
display: inline-block;
margin-left: 1rem;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
margin-bottom: 2rem;
}
.stat-card {
background: white;
padding: 1.5rem;
border-radius: 12px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
text-align: center;
transition: transform 0.3s ease;
}
.stat-card:hover {
transform: translateY(-5px);
}
.stat-number {
font-size: 2.5rem;
font-weight: 700;
margin-bottom: 0.5rem;
}
.stat-label {
color: #666;
font-size: 0.9rem;
}
.info-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 2rem;
}
.info-item {
padding: 1rem 0;
border-bottom: 1px solid #eee;
}
.info-item:last-child {
border-bottom: none;
}
.info-label {
font-weight: 500;
color: #666;
margin-bottom: 0.3rem;
}
.info-value {
font-size: 1.1rem;
color: #333;
}
.recent-prescriptions {
margin-top: 2rem;
}
.prescription-item {
padding: 1rem;
border: 1px solid #eee;
border-radius: 8px;
margin-bottom: 1rem;
transition: box-shadow 0.3s ease;
}
.prescription-item:hover {
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.prescription-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem;
}
.patient-name {
font-weight: 500;
color: #1976d2;
}
.prescription-date {
color: #666;
font-size: 0.9rem;
}
.doctor-info {
color: #26a69a;
font-weight: 500;
}
.safety-info {
background: #fff3e0;
border-left: 4px solid #ff9800;
padding: 1rem;
border-radius: 8px;
margin-top: 1rem;
}
.safety-title {
font-weight: 600;
color: #ef6c00;
margin-bottom: 0.5rem;
}
@media (max-width: 768px) {
.info-grid {
grid-template-columns: 1fr;
gap: 1rem;
}
.medication-header {
padding: 1.5rem;
}
.medication-name {
font-size: 1.5rem;
}
.price-badge {
margin-left: 0;
margin-top: 0.5rem;
}
}
</style>
</head>
<body>
<header class="header">
<h1>
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M17,3C18.1,3 19,3.9 19,5V8H21V10H19V19C19,20.1 18.1,21 17,21H7C5.9,21 5,20.1 5,19V10H3V8H5V5C5,3.9 5.9,3 7,3H17M7,5V8H17V5H7M7,10V19H17V10H7M9,12H15V14H9V12M9,15H13V17H9V15Z"/>
</svg>
药品详情
</h1>
</header>
<nav class="nav-menu">
<ul>
<li><a href="../../index.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z"/>
</svg>
仪表板
</a></li>
<li><a href="../patients/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z"/>
</svg>
患者管理
</a></li>
<li><a href="../doctors/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M14.84,2.5C16.2,2.5 17.5,3.2 18.28,4.38L18.5,4.75L19.25,4.38C19.92,4 20.75,4.2 21.13,4.87C21.5,5.54 21.33,6.42 20.66,6.79L20.04,7.12C20.04,7.12 20.04,7.12 20.04,7.12C20.47,7.88 20.47,8.78 20.04,9.54L20.5,9.78C21.17,10.15 21.33,11.04 20.97,11.71C20.6,12.38 19.72,12.54 19.05,12.17L18.5,11.88C17.71,13.07 16.39,13.77 15.04,13.77C13.68,13.77 12.36,13.07 11.57,11.88L11,12.17C10.33,12.54 9.45,12.38 9.08,11.71C8.71,11.04 8.88,10.15 9.55,9.78L10,9.54C9.58,8.78 9.58,7.88 10,7.12L9.38,6.79C8.71,6.42 8.55,5.54 8.92,4.87C9.29,4.2 10.17,4 10.84,4.38L11.57,4.75C12.35,3.56 13.67,2.86 15.04,2.86M15.04,4.64C14.18,4.64 13.4,5.09 12.96,5.78L12.5,6.5L11.78,6.06C11.58,5.94 11.32,6 11.19,6.21C11.07,6.42 11.13,6.68 11.34,6.81L12.06,7.25L11.78,7.94C11.58,8.38 11.58,8.87 11.78,9.31L12.06,10L11.34,10.44C11.13,10.57 11.07,10.83 11.19,11.04C11.32,11.25 11.58,11.31 11.78,11.19L12.5,10.75L12.96,11.47C13.4,12.16 14.18,12.61 15.04,12.61C15.9,12.61 16.68,12.16 17.12,11.47L17.58,10.75L18.3,11.19C18.5,11.31 18.76,11.25 18.89,11.04C19.01,10.83 18.95,10.57 18.74,10.44L18.02,10L18.3,9.31C18.5,8.87 18.5,8.38 18.3,7.94L18.02,7.25L18.74,6.81C18.95,6.68 19.01,6.42 18.89,6.21C18.76,6 18.5,5.94 18.3,6.06L17.58,6.5L17.12,5.78C16.68,5.09 15.9,4.64 15.04,4.64M11,15.5V17.5H3V15.5C3,14.39 6.69,13.5 9.5,13.5C10.4,13.5 11.5,13.65 12.5,13.91C11.84,14.8 11.5,15.88 11.5,17C11.34,16.83 11.17,16.66 11,15.5M9.5,12A2.5,2.5 0 0,1 7,9.5A2.5,2.5 0 0,1 9.5,7A2.5,2.5 0 0,1 12,9.5A2.5,2.5 0 0,1 9.5,12Z"/>
</svg>
医生管理
</a></li>
<li><a href="../medical_records/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z"/>
</svg>
病历管理
</a></li>
<li><a href="../departments/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,11.5A2.5,2.5 0 0,1 9.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,11.5M12,2A7,7 0 0,0 5,9C5,14.25 12,22 12,22C12,22 19,14.25 19,9A7,7 0 0,0 12,2Z"/>
</svg>
科室管理
</a></li>
<li><a href="list.php" class="active">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M17,3C18.1,3 19,3.9 19,5V8H21V10H19V19C19,20.1 18.1,21 17,21H7C5.9,21 5,20.1 5,19V10H3V8H5V5C5,3.9 5.9,3 7,3H17M7,5V8H17V5H7M7,10V19H17V10H7M9,12H15V14H9V12M9,15H13V17H9V15Z"/>
</svg>
药品管理
</a></li>
</ul>
</nav>
<div class="container">
<!-- 药品头部信息 -->
<div class="medication-header">
<div class="medication-avatar">
💊
</div>
<div class="medication-name">
<?php echo htmlspecialchars($medication['name']); ?>
<?php if ($medication['price'] > 0): ?>
<span class="price-badge">¥<?php echo number_format($medication['price'], 2); ?></span>
<?php endif; ?>
</div>
<div class="medication-spec"><?php echo htmlspecialchars($medication['specification']); ?> • <?php echo htmlspecialchars($medication['unit']); ?></div>
<div class="medication-id">药品编号: <?php echo $medication['id']; ?></div>
</div>
<!-- 统计卡片 -->
<div class="stats-grid">
<div class="stat-card">
<div class="stat-number" style="color: #1976d2;"><?php echo $stats['total_prescriptions']; ?></div>
<div class="stat-label">总处方次数</div>
</div>
<div class="stat-card">
<div class="stat-number" style="color: #388e3c;"><?php echo $stats['total_patients']; ?></div>
<div class="stat-label">使用患者数</div>
</div>
<div class="stat-card">
<div class="stat-number" style="color: #f57c00;"><?php echo $stats['today_prescriptions']; ?></div>
<div class="stat-label">今日处方</div>
</div>
<div class="stat-card">
<div class="stat-number" style="color: #7b1fa2;"><?php echo $stats['month_prescriptions']; ?></div>
<div class="stat-label">本月处方</div>
</div>
</div>
<div class="info-grid">
<!-- 基本信息 -->
<div class="card">
<div class="card-header">
<h3 class="card-title">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M17,3C18.1,3 19,3.9 19,5V8H21V10H19V19C19,20.1 18.1,21 17,21H7C5.9,21 5,20.1 5,19V10H3V8H5V5C5,3.9 5.9,3 7,3H17M7,5V8H17V5H7M7,10V19H17V10H7M9,12H15V14H9V12M9,15H13V17H9V15Z"/>
</svg>
基本信息
</h3>
</div>
<div class="card-content">
<div class="info-item">
<div class="info-label">药品名称</div>
<div class="info-value"><?php echo htmlspecialchars($medication['name']); ?></div>
</div>
<div class="info-item">
<div class="info-label">药品规格</div>
<div class="info-value"><?php echo htmlspecialchars($medication['specification']); ?></div>
</div>
<div class="info-item">
<div class="info-label">计量单位</div>
<div class="info-value"><?php echo htmlspecialchars($medication['unit']); ?></div>
</div>
<div class="info-item">
<div class="info-label">单价</div>
<div class="info-value">
<?php if ($medication['price'] > 0): ?>
<strong style="color: #1976d2;">¥<?php echo number_format($medication['price'], 2); ?></strong>
<?php else: ?>
<span style="color: #999;">未设置</span>
<?php endif; ?>
</div>
</div>
<div class="info-item">
<div class="info-label">入库时间</div>
<div class="info-value"><?php echo date('Y年m月d日', strtotime($medication['created_at'])); ?></div>
</div>
</div>
</div>
<!-- 生产信息 -->
<div class="card">
<div class="card-header">
<h3 class="card-title">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.22,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.22,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.68 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z"/>
</svg>
生产信息
</h3>
</div>
<div class="card-content">
<div class="info-item">
<div class="info-label">生产厂家</div>
<div class="info-value"><?php echo htmlspecialchars($medication['manufacturer']); ?></div>
</div>
</div>
</div>
</div>
<!-- 最近处方记录 -->
<div class="recent-prescriptions">
<div class="card">
<div class="card-header">
<h3 class="card-title">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M9,10H7V12H9V10M13,10H11V12H13V10M17,10H15V12H17V10M19,3A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5C3.89,21 3,20.1 3,19V5A2,2 0 0,1 5,3H6V1H8V3H16V1H18V3H19M19,19V8H5V19H19M9,14H7V16H9V14M13,14H11V16H13V14M17,14H15V16H17V14Z"/>
</svg>
最近处方记录
</h3>
</div>
<div class="card-content">
<?php if (mysqli_num_rows($recent_prescriptions_result) > 0): ?>
<?php while($prescription = mysqli_fetch_assoc($recent_prescriptions_result)): ?>
<div class="prescription-item">
<div class="prescription-header">
<span class="patient-name"><?php echo htmlspecialchars($prescription['patient_name']); ?></span>
<span class="prescription-date"><?php echo date('Y-m-d H:i', strtotime($prescription['created_at'])); ?></span>
</div>
<div style="margin-bottom: 0.5rem;">
主治医生: <span class="doctor-info"><?php echo htmlspecialchars($prescription['doctor_name']); ?></span>
</div>
<div style="color: #666; margin-bottom: 0.5rem;">
联系电话: <?php echo htmlspecialchars($prescription['patient_phone']); ?>
</div>
<div style="color: #333;">
处方详情: <?php echo htmlspecialchars(mb_substr($prescription['prescription'], 0, 100, 'UTF-8')); ?>
<?php if (mb_strlen($prescription['prescription'], 'UTF-8') > 100): ?>...<?php endif; ?>
</div>
<div style="margin-top: 0.5rem;">
<a href="../medical_records/view.php?id=<?php echo $prescription['id']; ?>" class="btn btn-small btn-primary">查看详情</a>
</div>
</div>
<?php endwhile; ?>
<div style="text-align: center; margin-top: 1rem;">
<a href="../medical_records/list.php?medication=<?php echo urlencode($medication['name']); ?>" class="btn btn-primary">查看全部处方</a>
</div>
<?php else: ?>
<div style="text-align: center; color: #999; padding: 2rem;">
暂无处方记录
</div>
<?php endif; ?>
</div>
</div>
</div>
<!-- 操作按钮 -->
<div style="margin-top: 2rem; text-align: center;">
<a href="list.php" class="btn btn-primary">返回药品列表</a>
<a href="edit.php?id=<?php echo $medication_id; ?>" class="btn btn-warning">编辑信息</a>
<a href="../medical_records/add.php?medication_id=<?php echo $medication_id; ?>" class="btn btn-success">开具处方</a>
</div>
</div>
</body>
</html>