#include <stdio.h> int main() { int iData[10]={12, 5, 7, 16, 13, 19, 6, 18, 4, 11}; int i,j, tt; for (i=0; i<10; i++) printf("%2d ", iData[i]); printf("\n"); for (i=9; i>0; i--) { for (j=1; j <=i; j++) { if (iData[j-1] > iData[j]) { tt = iData[j-1]; iData[j-1] = iData[j]; iData[j] = tt; } } for (j=0; j<10; j++) printf("%2d ", iData[j]); printf("\n"); } return 0; }
6
十二月
NHIRD_CD
class NHIRD_CD { public string FEE_YM; public string APPL_TYPE; public string HOSP_ID; public string APPL_DATE; public string CASE_TYPE; public string SEQ_NO; public string CURE_ITEM_NO1; public string CURE_ITEM_NO2; public string CURE_ITEM_NO3; public string CURE_ITEM_NO4; public string FUNC_TYPE; public string FUNC_DATE; public string TREAT_END_DATE; public string ID_BIRTHDAY; public string ID; public string CARD_SEQ_NO; public string GAVE_KIND; public string PART_NO; public string ACODE_ICD9_1; public string ACODE_ICD9_2; public string ACODE_ICD9_3; public string ICD_OP_CODE; public string DRUG_DAY; public string MED_TYPE; public string PRSN_ID; public string PHAR_ID; public string DRUG_AMT; public string TREAT_AMT; public string TREAT_CODE; public string DIAG_AMT; public string DSVC_NO; public string DSVC_AMT; public string BY_PASS_CODE; public string T_AMT; public string PART_AMT; public string T_APPL_AMT; public string ID_SEX; public NHIRD_CD(string line) { if (line.Length == 299) { FEE_YM = line.Substring(0, 6); APPL_TYPE = line.Substring(6, 1); HOSP_ID = line.Substring(7, 34); APPL_DATE = line.Substring(41, 8); CASE_TYPE = line.Substring(49, 2); SEQ_NO = line.Substring(51, 6); CURE_ITEM_NO1 = line.Substring(57, 2); CURE_ITEM_NO2 = line.Substring(59, 2); CURE_ITEM_NO3 = line.Substring(61, 2); CURE_ITEM_NO4 = line.Substring(63, 2); FUNC_TYPE = line.Substring(65, 2); FUNC_DATE = line.Substring(67, 8); TREAT_END_DATE = line.Substring(75, 8); ID_BIRTHDAY = line.Substring(83, 8); ID = line.Substring(91, 32); CARD_SEQ_NO = line.Substring(123, 2); GAVE_KIND = line.Substring(126, 1); PART_NO = line.Substring(127, 3); ACODE_ICD9_1 = line.Substring(130, 5).Trim(); ACODE_ICD9_2 = line.Substring(135, 5).Trim(); ACODE_ICD9_3 = line.Substring(140, 5).Trim(); ICD_OP_CODE = line.Substring(145, 4); DRUG_DAY = line.Substring(149, 2); MED_TYPE = line.Substring(151, 1); PRSN_ID = line.Substring(152, 32); PHAR_ID = line.Substring(184, 32); DRUG_AMT = line.Substring(216, 8); TREAT_AMT = line.Substring(224, 8); TREAT_CODE = line.Substring(232, 12); DIAG_AMT = line.Substring(244, 8); DSVC_NO = line.Substring(252, 12).Trim(); DSVC_AMT = line.Substring(264, 8).Trim(); BY_PASS_CODE = line.Substring(272, 2).Trim(); T_AMT = line.Substring(274, 8).Trim(); PART_AMT = line.Substring(282, 8).Trim(); T_APPL_AMT = line.Substring(290, 8).Trim(); ID_SEX = line.Substring(298, 1); } else if (line.Length == 300) { int x = 1; FEE_YM = line.Substring(0, 6); APPL_TYPE = line.Substring(6, 1); HOSP_ID = line.Substring(7, 34); APPL_DATE = line.Substring(41, 8); CASE_TYPE = line.Substring(49, 2); SEQ_NO = line.Substring(51, 6); CURE_ITEM_NO1 = line.Substring(57, 2); CURE_ITEM_NO2 = line.Substring(59, 2); CURE_ITEM_NO3 = line.Substring(61, 2); CURE_ITEM_NO4 = line.Substring(63, 2); FUNC_TYPE = line.Substring(65, 2); FUNC_DATE = line.Substring(67, 8); TREAT_END_DATE = line.Substring(75, 8); ID_BIRTHDAY = line.Substring(83, 8); ID = line.Substring(91, 32); CARD_SEQ_NO = line.Substring(123, 4);//2->4 GAVE_KIND = line.Substring(126 + x, 1); PART_NO = line.Substring(127 + x, 3); ACODE_ICD9_1 = line.Substring(130 + x, 5).Trim(); ACODE_ICD9_2 = line.Substring(135 + x, 5).Trim(); ACODE_ICD9_3 = line.Substring(140 + x, 5).Trim(); ICD_OP_CODE = line.Substring(145 + x, 4); DRUG_DAY = line.Substring(149 + x, 2); MED_TYPE = line.Substring(151 + x, 1); PRSN_ID = line.Substring(152 + x, 32); PHAR_ID = line.Substring(184 + x, 32); DRUG_AMT = line.Substring(216 + x, 8); TREAT_AMT = line.Substring(224 + x, 8); TREAT_CODE = line.Substring(232 + x, 12); DIAG_AMT = line.Substring(244 + x, 8); DSVC_NO = line.Substring(252 + x, 12).Trim(); DSVC_AMT = line.Substring(264 + x, 8).Trim(); BY_PASS_CODE = line.Substring(272 + x, 2).Trim(); T_AMT = line.Substring(274 + x, 8).Trim(); PART_AMT = line.Substring(282 + x, 8).Trim(); T_APPL_AMT = line.Substring(290 + x, 8).Trim(); ID_SEX = line.Substring(298 + x, 1); } } }
<?php if (empty($_GET["sid"]) || empty($_GET["rid"])) { $redir = "/"; header("Location: $redir"); exit; } $sid = $_GET["sid"]; $rid = $_GET["rid"]; $pdo = new PDO('mysql:host=localhost;dbname=hospital;charset=utf8', 'admin01', 'admin01'); $pdo->query("set names utf8"); //取得預約的醫師及日期時段 $sql = "SELECT depID, dname, vsection, vday FROM schedule WHERE id ='".$sid."'"; $pdoStatement = $pdo->prepare($sql); $ret = $pdoStatement->execute(); $schedule = $pdoStatement->fetch(); $depID = $schedule["depID"]; $dname = $schedule["dname"]; $vsection = $schedule["vsection"]; $vday = $schedule["vday"]; //把預約人數先加一 $sql = "UPDATE reservation SET count=count+1 WHERE id ='".$rid."'"; $pdoStatement = $pdo->prepare($sql); $ret = $pdoStatement->execute(); //取得預約日期 $sql = "SELECT visit_date FROM `reservation` WHERE id ='".$sid."'"; $pdoStatement = $pdo->prepare($sql); $ret = $pdoStatement->execute(); $reserve = $pdoStatement->fetch(); $vdate = $reserve["visit_date"]; //取得預約科別 $sql = "SELECT departName FROM opd WHERE departID ='".$depID."'"; $pdoStatement = $pdo->prepare($sql); $ret = $pdoStatement->execute(); $row = $pdoStatement->fetch(); $departName="小小科"; if (!empty($row["departName"]))//$row["departName"]=$row[0] $departName=$row["departName"]; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>無標題文件</title> </head> <body> <h2>亞大(模擬)醫院預約門診</h2> <hr /> <form name="reg_form" id="reg_form" action="opd-serve-query.php" method="POST"> <table border="2" cellpadding="1" align="center" width="600"> <tr> <td>科別:<?php echo $departName?> /醫生:<?php echo $dname?></td><td>日期:<?php echo $vdate?>(<?php echo $vday?>)/時段:<?php echo $vsection?></td> </tr> <tr> <td>病人身份證號碼:<input type="text" name="PatientID" id="PatientID" /></td> <td>病人姓名:<input type="text" name="PatientName" id="PatientName"/></td> </tr> <tr> <td colspan="2" align="right"><input type="button" name="SubmitNew" id="SubmitNew" value="預約" /></td> </tr> </table> </form> </body> </html>
<?php $pdo = new PDO('mysql:host=localhost;dbname=hospital;charset=utf8', 'admin01', 'admin01'); $pdo->query("set names utf8"); $title="一般內科"; $depID = "31800"; if (isset($_GET["depID"])) $depID = $_GET["depID"]; $sql = "SELECT departName FROM `opd` WHERE departID='".$depID."'"; $pdoStatement = $pdo->prepare($sql); $ret = $pdoStatement->execute(); $row = $pdoStatement->fetch(); $title=$row["departName"]; $sql = "SELECT id, dname, vsection, vday FROM schedule WHERE depID='".$depID."'"; $pdoStatement = $pdo->prepare($sql); $ret = $pdoStatement->execute(); $rowsSchedule = $pdoStatement->fetchAll(); $array_dname = array();//醫生的名字 foreach ($rowsSchedule as $rowS) { $array_dname[$rowS["id"]] = $rowS["dname"]; } $sql = "SELECT id, scheduleID, depID, count, max, visit_date, comment FROM reservation WHERE depID ='".$depID."'"; $pdoStatement = $pdo->prepare($sql); $ret = $pdoStatement->execute(); $rowsReservation = $pdoStatement->fetchAll(); $array_count = array(); $array_max = array(); $array_reserveID = array(); foreach ($rowsReservation as $rowR) { $array_count[$rowR["scheduleID"]][$rowR["visit_date"]] = $rowR["count"]; $array_max[$rowR["scheduleID"]][$rowR["visit_date"]] = $rowR["max"]; $array_reserveID[$rowR["scheduleID"]][$rowR["visit_date"]] = $rowR["id"]; } //時間處理 $w = array(); $dtVisit = new DateTime(); $dtBegin = new DateTime(); $dtVisit->modify('monday this week'); function markup($enable, $sid, $date, $array_dname, $array_count, $array_max, $array_reserveID) { $dname= $array_dname["$sid"]; if ($enable) { $count = $array_count["$sid"]["$date"]; $max = $array_max["$sid"]["$date"]; $rid = $array_reserveID["$sid"]["$date"]; $a='<a href="opd-reserve-form.php?sid='.$sid.'&rid='.$rid.'">'.$dname.'</a>(預約:'.$count.'/'.$max.')<br>'; } else $a=$dname.'()<br>'; return $a; } ?> <!-- saved from url=(0089)http://www.cmuh.cmu.edu.tw/html/portlet/cmuh/schedule/DymSchedule.jsp?catId=1&depId=31800 --> <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="./DymSchedule_files/schedule.css"> </head> <body> <div id="schtab"> <?php for ($j = 1; $j <= 4; $j++) { $doctors = array ( "w1" => array("morning" => "", "afternoon" => "", "night" => ""), "w2" => array("morning" => "", "afternoon" => "", "night" => ""), "w3" => array("morning" => "", "afternoon" => "", "night" => ""), "w4" => array("morning" => "", "afternoon" => "", "night" => ""), "w5" => array("morning" => "", "afternoon" => "", "night" => ""), "w6" => array("morning" => "", "afternoon" => "", "night" => ""), "w7" => array("morning" => "", "afternoon" => "", "night" => "") ); for ($i = 1; $i <= 7; $i++) { $enable = true; if ($dtVisit < $dtBegin) $enable = false; $theday = $dtVisit->format('Y-m-d'); $w[$i]=$theday ; foreach ($rowsSchedule as $rowD) { $sid = $rowD["id"]; if ($i==1 && $rowD["vday"] == "星期一") { if ($rowD["vsection"] == "上午") $doctors["w1"]["morning"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "下午") $doctors["w1"]["afternoon"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "晚上") $doctors["w1"]["night"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); } else if ($i==2 && $rowD["vday"] == "星期二") { if ($rowD["vsection"] == "上午") $doctors["w2"]["morning"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "下午") $doctors["w2"]["afternoon"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "晚上") $doctors["w2"]["night"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); } else if ($i==3 && $rowD["vday"] == "星期三") { if ($rowD["vsection"] == "上午") $doctors["w3"]["morning"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "下午") $doctors["w3"]["afternoon"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "晚上") $doctors["w3"]["night"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); } else if ($i==4 && $rowD["vday"] == "星期四") { if ($rowD["vsection"] == "上午") $doctors["w4"]["morning"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "下午") $doctors["w4"]["afternoon"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "晚上") $doctors["w4"]["night"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); } else if ($i==5 && $rowD["vday"] == "星期五") { if ($rowD["vsection"] == "上午") $doctors["w5"]["morning"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "下午") $doctors["w5"]["afternoon"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "晚上") $doctors["w5"]["night"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); } else if ($i==6 && $rowD["vday"] == "星期六") { if ($rowD["vsection"] == "上午") $doctors["w6"]["morning"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "下午") $doctors["w6"]["afternoon"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "晚上") $doctors["w6"]["night"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); } else if ($i==7 && $rowD["vday"] == "星期日") { if ($rowD["vsection"] == "上午") $doctors["w7"]["morning"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "下午") $doctors["w7"]["afternoon"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); else if ($rowD["vsection"] == "晚上") $doctors["w7"]["night"] .=markup($enable, $sid, $theday, $array_dname, $array_count, $array_max, $array_reserveID); } } $dtVisit->modify('+1 day'); } print ' <table class="sch"> <!-- 抓Tittle --> <caption>'.$title .'</caption> <tbody><tr> <td class="firstth"></td> <th class="outertop"><center>星期一('.$w[1].')</center></th><th class="outertop"><center>星期二('.$w[2].')</center></th><th class="outertop"><center>星期三('.$w[3].')</center></th><th class="outertop"><center>星期四('.$w[4].')</center></th><th class="outertop"><center>星期五('.$w[5].')</center></th><th class="outertop"><center>星期六('.$w[6].')</center></th><th class="outertop"><center>星期日('.$w[7].')</center></th> </tr> <tr> <th class="outerleft"><center>上午 <br>08:30<br><div class="outerleft_pic"></div><br>12:00</center></th> <td class="inner1"> '.$doctors["w1"]["morning"].' </td> <td class="inner2"> '.$doctors["w2"]["morning"].' </td> <td class="inner1"> '.$doctors["w3"]["morning"].' </td> <td class="inner2"> '.$doctors["w4"]["morning"].' </td> <td class="inner1"> '.$doctors["w5"]["morning"].' </td> <td class="inner2"> '.$doctors["w6"]["morning"].' </td> <td class="inner1"> '.$doctors["w7"]["morning"].' </td> </tr> <tr> <th class="outerleft"><center>下午<br>13:30<br><div class="outerleft_pic"></div><br>17:00</center></th> <td class="inner1"> '.$doctors["w1"]["afternoon"].' </td> <td class="inner2"> '.$doctors["w2"]["afternoon"].' </td> <td class="inner1"> '.$doctors["w3"]["afternoon"].' </td> <td class="inner2"> '.$doctors["w4"]["afternoon"].' </td> <td class="inner1"> '.$doctors["w5"]["afternoon"].' </td> <td class="inner2"> '.$doctors["w6"]["afternoon"].' </td> <td class="inner1"> '.$doctors["w7"]["afternoon"].' </td> </tr> <tr> <th class="outerleft"><center>晚上<br>18:30<br><div class="outerleft_pic"></div><br>21:00</center></th> <td class="inner1"> '.$doctors["w1"]["night"].' </td> <td class="inner2"> '.$doctors["w2"]["night"].' </td> <td class="inner1"> '.$doctors["w3"]["night"].' </td> <td class="inner2"> '.$doctors["w4"]["night"].' </td> <td class="inner1"> '.$doctors["w5"]["night"].' </td> <td class="inner2"> '.$doctors["w6"]["night"].' </td> <td class="inner1"> '.$doctors["w7"]["night"].' </td> </tr> </tbody></table> '; } ?> <p class="schedule_p"> </p> <div class="clear"></div> </div> </body></html>