<?php$config=require'config.php';$servername=$config['servername'];$username=$config['username'];$password=$config['password'];$dbname=$config['dbname'];// 创建连接$conn=newMysqli($servename,$username,$password,$dbname);if($conn->connect_error){die('connect error:'.$conn->connect_errno);}$button=$_POST['button'];if ($button="lxs") {$authCode=$_POST['authCode'];if ($authCode!="lxsyj") {exit ("验证码不对。"); }$center=$_POST['center'];if ($center=="茂名市人民医院") {$center="center_A"; }if ($center=="广州医科大学附属二院") {$center="center_B"; }if ($center=="湛江中心人民医院") {$center="center_C"; }if ($center=="广东省人民医院") {$center="center_D"; }if ($center=="广东医科大学附属医院") {$center="center_E"; }$patID=$_POST['patID'];$patGender=$_POST['patGender'];$patName=$_POST['patName'];$patAge=$_POST['patAge'];// 先看是否已存在随机号,防止重复产生随机号$sqlQuery="SELECT treatment, 随机日期 from `硫辛酸研究随机表` WHERE stratum=\"$center\" AND patID=\"$patID\"";$result=$conn->query($sqlQuery);$row=$result->fetch_all(MYSQLI_BOTH);//参数MYSQL_ASSOC、MYSQLI_NUM、MYSQLI_BOTH规定产生数组类型if (count($row)>=1) {$treatment=$row[0]['treatment'];$randomizationDate=$row[0]['随机日期'];// 计算已入组病人数$sqlCount="SELECT COUNT(*) AS count FROM `硫辛酸研究随机表` WHERE used=1";$resultCount=$conn->query($sqlCount);$rowCount=$resultCount->fetch_assoc();$patientCount=$rowCount['count'];exit("患者:".$patName.",".$patGender.",".$patAge."岁,住院号:".$patID.",已于".$randomizationDate."被随机分组至:<br><font color=\"#FF0000\">".$treatment."</font><br>建议<font color=\"#0000FF\">截图保存</font>,如果忘记分组,可重新输入住院号等信息获取分组信息。<br>目前已入组病人数:".$patientCount); }// 获取随机号$sqlQuery="SELECT treatment from `硫辛酸研究随机表` WHERE stratum=\"$center\" AND used=0 ORDER BY id ASC LIMIT 1";$result=$conn->query($sqlQuery);$row=$result->fetch_all(MYSQLI_BOTH);//参数MYSQL_ASSOC、MYSQLI_NUM、MYSQLI_BOTH规定产生数组类型$treatment=$row[0]['treatment'];echo"患者:".$patName.",".$patGender.",".$patAge."岁,住院号:".$patID.",随机分组至:<br><font color=\"#FF0000\">".$treatment;echo"</font><br>建议<font color=\"#0000FF\">截图保存</font>,如果忘记分组,可重新输入住院号等信息获取分组信息。";// 更新使用状态$sqlUpdate="UPDATE `硫辛酸研究随机表` SET used=1, patID=\"$patID\", 随机日期=now(), patName=\"$patName\", patGender=\"$patGender\", patAge=$patAge, used=1 WHERE stratum=\"$center\" AND used=0 ORDER BY id ASC LIMIT 1";$conn->query($sqlUpdate);// 计算已入组病人数$sqlCount="SELECT COUNT(*) AS count FROM `硫辛酸研究随机表` WHERE used=1";$resultCount=$conn->query($sqlCount);$rowCount=$resultCount->fetch_assoc();$patientCount=$rowCount['count'];echo"<br>目前已入组病人数:".$patientCount;}?>