function pregtest() { //function นัด pregtest $sql = "SELECT\n concat('สถานบริการ(สถานีอนามัย/PCU): ',chospital.`hosname`,' หมู่ที่:',ifnull(chospital.`mu`,'...'),' ต.',\n\tifnull(csubdistrict.`subdistname`,' ...'),' อ.',ifnull(cdistrict.`distname`,' ...'),' จ.',\n\tifnull(cprovince.`provname`,'...')) AS chospital_hosname\nFROM\n `chospital` chospital \n INNER JOIN `office` office ON chospital.`hoscode` = office.`offid`\n left outer join `csubdistrict` csubdistrict ON chospital.`provcode` = csubdistrict.`provcode`\n AND chospital.`distcode` = csubdistrict.`distcode`\n AND chospital.`subdistcode` = csubdistrict.`subdistcode`\n left outer JOIN `cdistrict` cdistrict ON chospital.`provcode` = cdistrict.`provcode`\n AND chospital.`distcode` = cdistrict.`distcode`\n INNER JOIN `cprovince` cprovince ON chospital.`provcode` = cprovince.`provcode`"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $hosp = $row[chospital_hosname]; $village = $_GET[village]; if ($village == "00000000") { $wvill = ""; } else { $wvill = " AND house.villcode='{$village}' "; } if ($village == "00000000") { $mu = "ทุกหมู่บ้าน"; } else { $mu = getvillagename($village); } $str = retdaterangstr($_GET[str]); $sto = retdaterangsto($_GET[str]); $strx = retDatets($str); $stox = retDatets($sto); $sql = "SELECT\nperson.pcucodeperson,\nperson.pid,\nperson.idcard,\nperson.fname,\nconcat(ctitle.titlename, person.fname , ' ' , person.lname) AS pname,\nperson.birth,\nROUND(DATEDIFF(now(),person.birth)/365.25) AS age,\nhouse.villcode,\nhouse.hno,\nhouse.hcode,\nhouse.xgis,\nhouse.ygis,\nvisit.visitdate,\nvisitfp.pregtest,\nvisitfp.pregtestresult,\nvisit.username\nFROM\nhouse\nINNER JOIN person ON house.pcucode = person.pcucodeperson AND house.hcode = person.hcode\nLEFT JOIN ctitle on ctitle.titlecode = person.prename\nINNER JOIN visit ON person.pcucodeperson = visit.pcucodeperson AND person.pid = visit.pid\nINNER JOIN visitfp ON visit.pcucodeperson = visitfp.pcucodeperson AND visit.pid = visitfp.pid AND visit.visitdate = visitfp.datefp\nwhere visitfp.pregtest = '17' and visit.visitdate between '{$str}' and '{$sto}' {$wvill}\norder by visit.visitdate,person.fname"; $result = mysql_query($sql); $txt = '<p align=\'center\'><b>รายงานการตรวจทดสอบการตั้งครรภ์<br>'; $txt .= "ข้อมูลวันที่ {$strx} ถึง {$stox} {$mu}</b></p><b>{$hosp}</b><table width='99%' border='0' cellspacing='1' cellpadding='1' class='table table-striped table-hover table-bordered'>\n <tr>\n <th width='4%' scope='col'><div align='center'>ลำดับ</th>\n\t<th width='5%' scope='col'><div align='center'>HN</th>\n <th width='10%' scope='col'><div align='center'>ชื่อ - สกุล</th>\n\t<th width='5%' scope='col'><div align='center'>อายุ</th>\n <th width='6%' scope='col'><div align='center'>บ้านเลขที่</th>\n\t<th width='4%' scope='col'><div align='center'>หมู่ที่</th>\n <th width='4%' scope='col'><div align='center'>วันที่ตรวจ</th>\n\t<th width='9%' scope='col'><div align='center'>ผลการตรวจ</th>\n\t<th width='9%' scope='col'><div align='center'>ผู้ตรวจ</th>\n </tr>"; while ($row = mysql_fetch_array($result)) { $moo = substr($row[villcode], 6, 2); $vill = getMooVillage($row[villcode]); $userv = getusername($row[username]); if ($row[pregtestresult] == "0") { $pregtestname = "ไม่ตั้งครรภ์"; } elseif ($row[pregtestresult] == "1") { $pregtestname = "ตั้งครรภ์"; } elseif ($row[pregtestresult] == "3") { $pregtestname = "แปลผลไม่ได้"; } else { $pregtestname = ""; } if ($row[visitdate] == "") { $appsick = ""; } else { $appsick = retDatets($row[visitdate]); } ++$i; if ($i % 2 == 1) { $cr = " class='altrow'"; } else { $cr = ""; } $txt .= " <tr {$cr}>\n <td><div align='center'>{$i}</div></td>\n\t<td><div align='center'>{$row['pid']}</div></td>\n <td>{$row['pname']}</td>\n\t<td><div align='center'>{$row['age']}</div></td>\n <td><div align='center'>{$row['hno']}</div></td>\n <td><div align='center'>{$moo}</div></td>\n\t<td><div align='center'>{$appsick}</div></td>\n\t<td><div align='center'>{$pregtestname}</div></td>\n\t<td><div align='left'>{$userv}</div></td>\n </tr>"; } $txt .= "</table><br>"; echo $txt; }
function pregtest() { //function นัด pregtest $village = $_GET[village]; if ($village == "00000000") { $wvill = ""; } else { $wvill = " AND house.villcode='{$village}' "; } if ($village == "00000000") { $mu = "ทุกหมู่บ้าน"; } else { $mu = getvillagename($village); } $str = retdaterangstr($_GET[str]); $sto = retdaterangsto($_GET[str]); $strx = retDatets($str); $stox = retDatets($sto); $sql = "SELECT\nperson.pcucodeperson,\nperson.pid,\nperson.idcard,\nperson.fname,\nconcat(ctitle.titlename, person.fname , ' ' , person.lname) AS pname,\nperson.birth,\nROUND(DATEDIFF(now(),person.birth)/365.25) AS age,\nhouse.villcode,\nhouse.hno,\nhouse.hcode,\nhouse.xgis,\nhouse.ygis,\nvisit.visitdate,\nvisitfp.pregtest,\nvisitfp.pregtestresult,\nvisit.username\nFROM\nhouse\nINNER JOIN person ON house.pcucode = person.pcucodeperson AND house.hcode = person.hcode\nLEFT JOIN ctitle on ctitle.titlecode = person.prename\nINNER JOIN visit ON person.pcucodeperson = visit.pcucodeperson AND person.pid = visit.pid\nINNER JOIN visitfp ON visit.pcucodeperson = visitfp.pcucodeperson AND visit.pid = visitfp.pid AND visit.visitdate = visitfp.datefp\nwhere visitfp.pregtest = '17' and visit.visitdate between '{$str}' and '{$sto}' {$wvill}\norder by visit.visitdate,person.fname"; $result = mysql_query($sql); $xml = '<markers>'; while ($row = mysql_fetch_array($result)) { $moo = substr($row[villcode], 6, 2); $vill = getMooVillage($row[villcode]); $userv = getusername($row[username]); if ($row[pregtestresult] == "0") { $pregtestname = "ไม่ตั้งครรภ์"; } elseif ($row[pregtestresult] == "1") { $pregtestname = "ตั้งครรภ์"; } elseif ($row[pregtestresult] == "3") { $pregtestname = "แปลผลไม่ได้"; } else { $pregtestname = ""; } if ($row[visitdate] == "") { $appsick = ""; } else { $appsick = retDatets($row[visitdate]); } $xml .= '<marker '; $xml .= 'pid="' . $row[pid] . '" '; $xml .= 'pname="' . $row[pname] . '" '; $xml .= 'age="' . $row[age] . '" '; $xml .= 'hno="' . $row[hno] . '" '; $xml .= 'moo="' . $moo . '" '; $xml .= 'sick="' . $appsick . '" '; $xml .= 'labresult="' . $pregtestname . '" '; $xml .= 'userv="' . $userv . '" '; $xml .= 'lat="' . $row[ygis] . '" '; $xml .= 'lng="' . $row[xgis] . '" '; $xml .= '/>'; } $xml .= '</markers>'; echo $xml; }
function fp() { //function นัด fp $village = $_GET[village]; if ($village == "00000000") { $wvill = ""; } else { $wvill = " AND perapp.villcode='{$village}' "; } if ($village == "00000000") { $mu = "ทุกหมู่บ้าน"; } else { $mu = getvillagename($village); } $chk_ncd = $_GET[chk_ncd]; if ($chk_ncd == "2") { $chkncd = " AND vper.visitdate is not null"; } else { if ($chk_ncd == "3") { $chkncd = " AND vper.visitdate is null"; } else { $chkncd = ""; } } $str = $_GET[str]; $strx = retDatets($str); $sql = "SELECT\nperapp.*,\nvper.visitdate as datechk\nFROM\n(\nSELECT\nperson.pcucodeperson,\nperson.pid,\nperson.idcard,\nperson.fname,\nconcat(ctitle.titlename, person.fname , ' ' , person.lname) AS pname,\nperson.birth,\nROUND(DATEDIFF(now(),person.birth)/365.25) AS age,\nhouse.villcode,\nhouse.hno,\nhouse.hcode,\nhouse.xgis,\nhouse.ygis,\nvisitfp.datedue,\ncdrug.drugname,\ncdrug.drugtypesub,\nvisitfp.datefp\nFROM\nhouse\nINNER JOIN person ON house.pcucode = person.pcucodeperson AND house.hcode = person.hcode\nINNER JOIN visitfp ON person.pcucodeperson = visitfp.pcucodeperson AND person.pid = visitfp.pid\ninner JOIN cdrug on visitfp.fpcode = cdrug.drugcode\nLEFT JOIN ctitle ON person.prename = ctitle.titlecode\nwhere visitfp.datedue = '{$str}') as perapp\nleft JOIN (SELECT visit.* FROM visit WHERE visit.visitdate = '{$str}') as vper \non perapp.pcucodeperson = vper.pcucodeperson and perapp.pid = vper.pid\nwhere perapp.pcucodeperson is not null {$chkncd} {$wvill}\norder by perapp.villcode,perapp.fname"; $result = mysql_query($sql); $txt = '<p align=\'center\'><b>รายงานการนัดวางแผนครอบครัว'; $txt .= "<br>ข้อมูลการนัดวันที่ {$_GET['str']} {$mu}</b></p><br><b>{$hosp}</b><table width='99%' border='0' cellspacing='1' cellpadding='1' class='table table-striped table-hover table-bordered'>\n <tr>\n <th width='4%' scope='col'><div align='center'>ลำดับ</div></th>\n\t<th width='10%' scope='col'><div align='center'>เลขบัตรประชาชน</div></th>\n <th width='10%' scope='col'><div align='center'>ชื่อ - สกุล</div></th>\n\t<th width='5%' scope='col'><div align='center'>อายุ</div></th>\n <th width='6%' scope='col'><div align='center'>บ้านเลขที่</div></th>\n\t<th width='4%' scope='col'><div align='center'>หมู่ที่</div></th>\n <th width='4%' scope='col'><div align='center'>วันที่นัด</div></th>\n\t<th width='4%' scope='col'><div align='center'>ประเภทการนัด</div></th>\n\t<th width='9%' scope='col'><div align='center'>##</div></th>\n\t<th width='9%' scope='col'><div align='center'>วันที่มารับบริการ</div></th>\n\t\n </tr>"; while ($row = mysql_fetch_array($result)) { $moo = substr($row[villcode], 6, 2); $vill = getMooVillage($row[villcode]); $title = getTitle($row[prename]); if ($row[drugtypesub] == "0") { $apptypename = "วชย.ทดสอบตั้งครรภ์"; } elseif ($row[drugtypesub] == "1") { $apptypename = "ยาเม็ด"; } elseif ($row[drugtypesub] == "2") { $apptypename = "ยาฉีด"; } elseif ($row[drugtypesub] == "3") { $apptypename = "ยาฝัง"; } elseif ($row[drugtypesub] == "4") { $apptypename = "ห่วง"; } elseif ($row[drugtypesub] == "5") { $apptypename = "ถุงยางอนามัย"; } elseif ($row[drugtypesub] == "6") { $apptypename = "หมันชาย"; } else { $apptypename = "หมันหญิง"; } if ($row[datedue] == "") { $appsick = ""; } else { $appsick = retDatets($row[datedue]); } if ($row[datechk] == "") { $sick = ""; } else { $sick = retDatets($row[datechk]); } if ($row[datechk] == "") { $sicksign = "ขาดนัด"; } else { $sicksign = "มาตามนัด"; } ++$i; if ($i % 2 == 1) { $cr = " class='altrow'"; } else { $cr = ""; } $txt .= " <tr {$cr}>\n <td><div align='center'>{$i}</div></td>\n\t<td><div align='center'>{$row['idcard']}</div></td>\n <td>{$row['pname']}</td>\n\t<td><div align='center'>{$row['age']}</div></td>\n <td><div align='center'>{$row['hno']}</div></td>\n <td><div align='center'>{$moo}</div></td>\n\t<td><div align='center'>{$appsick}</div></td>\n\t<td><div align='center'>{$apptypename}</div></td>\n\t<td><div align='center'>{$sicksign}</div></td>\n\t<td><div align='center'>{$sick}</div></td>\n </tr>"; } $txt .= "</table><br>"; echo $txt; }
$ect1 = ""; } else { $ect1 = " visitepi.vaccinecode = '{$vaccine}' "; } $village = $_GET[village]; if ($village == '00000000') { $ect2 = ""; } else { $ect2 = " villcode = '{$village}' AND "; } $sql = "select\npcu,\npid,\npname,\nbirth,\nage,\nhno,\nvillcode,\nvillname,\nvaccinecode,\ndrugname,\ndateepi,\nxgis,\nygis\nFROM\n(SELECT\nperson.pcucodeperson as pcu,\nperson.pid as pid,\nconcat(ctitle.titlename,person.fname,' ',person.lname) AS pname,\nperson.fname,\nperson.birth as birth,\nround(DATEDIFF(now(),person.birth) /30) AS age,\nhouse.hno as hno,\nhouse.villcode as villcode,\nCONVERT(village.villname using utf8) AS villname,\nhouse.xgis,\nhouse.ygis\nFROM\nhouse\nInner Join person ON house.pcucode = person.pcucodeperson AND house.hcode = person.hcode\nInner Join village ON village.pcucode = house.pcucode AND village.villcode = house.villcode\nInner Join ctitle ON person.prename = ctitle.titlecode\nwhere right(house.villcode,2) <> '00' and ((person.dischargetype is null) or (person.dischargetype = '9')) and round(DATEDIFF(now(),person.birth) /30) IN({$ect0})\norder by age) as per_epi\nleft Join (SELECT\nperson.pcucodeperson as pcu1,\nperson.pid as pid1,\nvisitepi.vaccinecode,\ncdrug.drugname,\nvisitepi.dateepi\nFROM\nhouse\nInner Join person ON house.pcucode = person.pcucodeperson AND house.hcode = person.hcode\nInner Join village ON village.pcucode = house.pcucode AND village.villcode = house.villcode\nInner Join visitepi ON person.pcucodeperson = visitepi.pcucodeperson AND person.pid = visitepi.pid\nInner Join ctitle ON person.prename = ctitle.titlecode\nInner Join cdrug ON visitepi.vaccinecode = cdrug.drugcode\nwhere right(house.villcode,2) <> '00' and ((person.dischargetype is null) or (person.dischargetype = '9')) and round(DATEDIFF(now(),person.birth) /30) IN({$ect0}) and {$ect1}\n) as visit_epi ON per_epi.pcu = visit_epi.pcu1 AND per_epi.pid = visit_epi.pid1\nwhere {$ect2} pid1 is null\norder by right(villcode,2),fname"; $result = mysql_query($sql); $xml = '<markers>'; while ($row = mysql_fetch_array($result)) { $moo = substr($row[villcode], 6, 2); $vill = getMooVillage($row[villcode]); $bod = retDatets($row[birth]); $title = getTitle($row[prename]); $dateepix = retDatets($row[dateepi]); $xml .= '<marker '; $xml .= 'hono="' . $row[hno] . '" '; $xml .= 'moo="' . $moo . '" '; $xml .= 'vill="' . $vill . '" '; $xml .= 'pname="' . $title . $row[pname] . '" '; $xml .= 'bod="' . $bod . '" '; $xml .= 'ag="' . $row[age] . '" '; $xml .= 'drugname="' . $row[drugname] . '" '; $xml .= 'vaccinecode="' . $row[vaccinecode] . '" '; $xml .= 'lat="' . $row[ygis] . '" '; $xml .= 'lng="' . $row[xgis] . '" '; $xml .= '/>';
<?php header("Content-type: text/xml"); include "../includes/conndb.php"; include "../includes/config.inc.php"; $xml = '<markers>'; $txtfile = fopen("oth.csv", "r"); while ($h = fgets($txtfile, 1024)) { $h = iconv('TIS-620', 'UTF-8', $h); ++$i; if ($i == 1) { } else { list($villcode, $hono, $title, $pname, $info1, $info2) = split(',', $h); $moo = substr($villcode, 6, 2); $vill = getMooVillage($villcode); $lat = getLatHouse($villcode, $hono); $lng = getLngHouse($villcode, $hono); $xml .= '<marker '; $xml .= 'hono="' . $hono . '" '; $xml .= 'moo="' . $moo . '" '; $xml .= 'vill="' . $vill . '" '; $xml .= 'pname="' . $pname . '" '; $xml .= 'info1="' . $info1 . '" '; $xml .= 'info2="' . $info2 . '" '; $xml .= 'lat="' . $lat . '" '; $xml .= 'lng="' . $lng . '" '; $xml .= '/>'; } } fclose($txtfile); $xml .= '</markers>';
function fp() { //function นัด fp $village = $_GET[village]; if ($village == "00000000") { $wvill = ""; } else { $wvill = " AND perapp.villcode='{$village}' "; } if ($village == "00000000") { $mu = "ทุกหมู่บ้าน"; } else { $mu = getvillagename($village); } $chk_ncd = $_GET[chk_ncd]; if ($chk_ncd == "2") { $chkncd = " AND vper.visitdate is not null"; } else { if ($chk_ncd == "3") { $chkncd = " AND vper.visitdate is null"; } else { $chkncd = ""; } } $str = $_GET[str]; $strx = retDatets($str); $sql = "SELECT\nperapp.*,\nvper.visitdate as datechk\nFROM\n(\nSELECT\nperson.pcucodeperson,\nperson.pid,\nperson.idcard,\nperson.fname,\nconcat(ctitle.titlename, person.fname , ' ' , person.lname) AS pname,\nperson.birth,\nROUND(DATEDIFF(now(),person.birth)/365.25) AS age,\nhouse.villcode,\nhouse.hno,\nhouse.hcode,\nhouse.xgis,\nhouse.ygis,\nvisitfp.datedue,\ncdrug.drugname,\ncdrug.drugtypesub,\nvisitfp.datefp\nFROM\nhouse\nINNER JOIN person ON house.pcucode = person.pcucodeperson AND house.hcode = person.hcode\nINNER JOIN visitfp ON person.pcucodeperson = visitfp.pcucodeperson AND person.pid = visitfp.pid\ninner JOIN cdrug on visitfp.fpcode = cdrug.drugcode\nLEFT JOIN ctitle ON person.prename = ctitle.titlecode\nwhere visitfp.datedue = '{$str}') as perapp\nleft JOIN (SELECT visit.* FROM visit WHERE visit.visitdate = '{$str}') as vper \non perapp.pcucodeperson = vper.pcucodeperson and perapp.pid = vper.pid\nwhere perapp.pcucodeperson is not null {$chkncd} {$wvill}\norder by perapp.villcode,perapp.fname"; $result = mysql_query($sql); $xml = '<markers>'; while ($row = mysql_fetch_array($result)) { $moo = substr($row[villcode], 6, 2); $vill = getMooVillage($row[villcode]); $title = getTitle($row[prename]); if ($row[drugtypesub] == "0") { $apptypename = "วชย.ทดสอบตั้งครรภ์"; } elseif ($row[drugtypesub] == "1") { $apptypename = "ยาเม็ด"; } elseif ($row[drugtypesub] == "2") { $apptypename = "ยาฉีด"; } elseif ($row[drugtypesub] == "3") { $apptypename = "ยาฝัง"; } elseif ($row[drugtypesub] == "4") { $apptypename = "ห่วง"; } elseif ($row[drugtypesub] == "5") { $apptypename = "ถุงยางอนามัย"; } elseif ($row[drugtypesub] == "6") { $apptypename = "หมันชาย"; } else { $apptypename = "หมันหญิง"; } if ($row[datedue] == "") { $appsick = ""; } else { $appsick = retDatets($row[datedue]); } if ($row[datechk] == "") { $sick = ""; } else { $sick = retDatets($row[datechk]); } if ($row[datechk] == "") { $sicksign = "ขาดนัด"; } else { $sicksign = "มาตามนัด"; } $xml .= '<marker '; $xml .= 'pid="' . $row[pid] . '" '; $xml .= 'pname="' . $row[pname] . '" '; $xml .= 'age="' . $row[age] . '" '; $xml .= 'hno="' . $row[hno] . '" '; $xml .= 'moo="' . $moo . '" '; $xml .= 'appsick="' . $appsick . '" '; $xml .= 'apptypename="' . $apptypename . '" '; $xml .= 'sicksign="' . $sicksign . '" '; $xml .= 'lat="' . $row[ygis] . '" '; $xml .= 'lng="' . $row[xgis] . '" '; $xml .= '/>'; } $xml .= '</markers>'; echo $xml; }