วันพฤหัสบดีที่ 21 เมษายน พ.ศ. 2559

วันจันทร์ที่ 1 กุมภาพันธ์ พ.ศ. 2559

เพิ่มให้ Server สามารถอ่านภาษาไทยได้


เพิ่มให้ Server สามารถอ่านภาษาไทยได้

อันดับแรกตรวจสอบดูว่า MariaDB เซ็ตภาษาไว้ไหม คำสั่ง show variables like'%char%'



วันอาทิตย์ที่ 31 มกราคม พ.ศ. 2559

วิธีฝัง Embed ใน Yii2


วิธีฝัง Embed ใน Yii2


<div class="embed-responsive embed-responsive-16by9">
        <iframe class="embed-responsive-item"
                         src="//www.youtube.com/embed/8RqcjnPle_Q"></iframe>
</div>

วันเสาร์ที่ 30 มกราคม พ.ศ. 2559

TeamView 11 Premium



เข้า C;// ค้นหาคำว่า temview แล้วลบออกให้หมอ
ไฟล์   =  team viewer 11+crack.rar

วันพุธที่ 27 มกราคม พ.ศ. 2559

Maximum upload size แก้ไขค่าที่ต้องการ upload ไฟล์ขนาดใหญ่


Maximum upload size แก้ไขค่าที่ต้องการ upload ไฟล์ขนาดใหญ่

upload_max_filesize หรือ post_max_filesize
ปกติระบบจะรับข้อมูลฟอร์มเป็นแบบ POST ซึ่งข้อมูลอาจจะการ UPLOAD ไฟล์มาด้วย ดังนั้น post_max_filesize จึงควรมีขนาดมากกว่า upload_max_filesize
memory_limit
เมื่อข้อมูลส่งเข้ามาแบบ POST ระบบจะเก็บข้อมูลบางส่วนไว้ในหน่วยความจำ การตั้งค่าสูงเกินไปอาจทำให้บางโปรแกรมที่มี bug ถือโอกาสนี้กินหน่วยความจำมากเกินไปจนส่งผลกระทบกับระบบทั้งหมด
max_execute_time หรือ max_input_time
หากข้อมูลมีปริมาณเยอะมาก ก็จะต้องใช้เวลาในการ upload นาน เช่น ไฟล์ขนาด 1 MB ใช้ upload 32 kbps จะใช้เวลา 256 วินาที (4 นาที 16 วินาที) ซึ่งก็ต้องเผื่อเวลาให้ PHP จัดการกับไฟล์ขนาดใหญ่ด้วย

วันพฤหัสบดีที่ 7 มกราคม พ.ศ. 2559

เป้าหมายประชากร Type 1,3 ปีงบประมาณ 2559


เป้าหมายประชากร Type 1,3 ปีงบประมาณ 2559

SELECT v.village_moo,v.village_name ,
(SELECT COUNT(DISTINCT concat(p.house_id))from person p
where v.village_id = p.village_id and v.village_moo <> 0) AS c_house,
(SELECT COUNT(DISTINCT concat( p.family_id))from person p
where v.village_id = p.village_id and v.village_moo <> 0) AS c_family ,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and p.house_regist_type_id IN (1,3) and
p.person_discharge_id = 9 AND p.death ='N'
and p.nationality = 99) AS p_total_t13,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and p.house_regist_type_id IN (1,3) and
p.person_discharge_id = 9 AND p.death ='N' and sex =1
and p.nationality = 99) AS man_t13,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and p.house_regist_type_id IN (1,3) and
p.person_discharge_id = 9 AND p.death ='N' and sex =2
and p.nationality = 99) AS woman_t13,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and
p.person_discharge_id = 9 AND p.death ='N'
and p.nationality = 99) AS p_total,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and
p.person_discharge_id = 9 AND p.death ='N' and sex =1
and p.nationality = 99) AS man,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and
p.person_discharge_id = 9 AND p.death ='N' and sex =2
and p.nationality = 99) AS woman,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
inner JOIN person_anc pa on pa.person_id = p.person_id
where v.village_id = p.village_id and v.village_moo <> 0 and pa.lmp BETWEEN '2014-10-01' and '2015-09-30' and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p_anc',
(SELECT COUNT(DISTINCT concat(p.cid))from person p
inner JOIN person_deformed pd on pd.person_id = p.person_id
where v.village_id = p.village_id and v.village_moo <> 0 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p_dedormed',
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN person_death pd on pd.person_id = p.person_id
where v.village_id = p.village_id and pd.death_date BETWEEN '2014-10-01' and '2015-09-30'
) AS p_death,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and TIMESTAMPDIFF(month,p.birthdate,now())between 0 and 12 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS p0_1y,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and TIMESTAMPDIFF(month,p.birthdate,now())between 0 and 72 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS p0_5y,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and TIMESTAMPDIFF(month,p.birthdate,now())between 73 and 216 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS p6_18y,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and TIMESTAMPDIFF(year,p.birthdate,now())between 35 and 300 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p35y<',
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and TIMESTAMPDIFF(year,p.birthdate,now())between 60 and 300 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p60y<',
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and TIMESTAMPDIFF(year,p.birthdate,now())between 30 and 60 and sex=2 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p30-60y',
(SELECT COUNT(DISTINCT concat(p.cid))from person p
where v.village_id = p.village_id and v.village_moo <> 0 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p30-70y',DATE_FORMAT(NOW(),'%d-%m-%Y %H:%i:%s') AS com_lastupdate
FROM person p
LEFT JOIN village v on p.village_id = v.village_id
LEFT OUTER JOIN person_death pd on pd.person_id = p.person_id
where v.village_moo <> 0
GROUP BY v.village_id union
SELECT ' ','total' ,
(SELECT COUNT(DISTINCT concat(p.house_id))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0) AS c_house,
(SELECT COUNT(DISTINCT concat( p.family_id))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0) AS c_family ,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and p.house_regist_type_id IN (1,3) and
p.person_discharge_id = 9 AND p.death ='N'
and p.nationality = 99) AS p_total_t13,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and p.house_regist_type_id IN (1,3) and
p.person_discharge_id = 9 AND p.death ='N' and sex =1
and p.nationality = 99) AS man_t13,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and p.house_regist_type_id IN (1,3) and
p.person_discharge_id = 9 AND p.death ='N' and sex =2
and p.nationality = 99) AS woman_t13,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and
p.person_discharge_id = 9 AND p.death ='N'
and p.nationality = 99) AS p_total,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and
p.person_discharge_id = 9 AND p.death ='N' and sex =1
and p.nationality = 99) AS man,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and
p.person_discharge_id = 9 AND p.death ='N' and sex =2
and p.nationality = 99) AS woman,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
inner JOIN person_anc pa on pa.person_id = p.person_id
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and pa.lmp BETWEEN '2014-10-01' and '2015-09-30' and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p_anc',
(SELECT COUNT(DISTINCT concat(p.cid))from person p
INNER JOIN person_deformed pd on pd.person_id = p.person_id
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p_dedormed',
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
LEFT JOIN person_death pd on pd.person_id = p.person_id
where pd.death_date BETWEEN '2014-10-01' and '2015-09-30' ) AS p_death,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and TIMESTAMPDIFF(month,p.birthdate,now())between 0 and 12 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS p0_1y,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and TIMESTAMPDIFF(month,p.birthdate,now())between 0 and 72 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS p0_5y,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and TIMESTAMPDIFF(month,p.birthdate,now())between 73 and 216 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS p6_18y,
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and TIMESTAMPDIFF(year,p.birthdate,now())between 35 and 300 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p35y<',
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and TIMESTAMPDIFF(year,p.birthdate,now())between 60 and 300 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p60y<',
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and TIMESTAMPDIFF(year,p.birthdate,now())between 30 and 60 and sex=2 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p30-60y',
(SELECT COUNT(DISTINCT concat(p.cid))from person p
LEFT JOIN village v on p.village_id = v.village_id
where v.village_moo <> 0 and TIMESTAMPDIFF(year,p.birthdate,now())between 30 and 70 and sex=2 and
p.person_discharge_id = 9 AND p.death ='N' and p.nationality = 99) AS 'p30-70y',
DATE_FORMAT(NOW(),'%d-%m-%Y %H:%i:%s') AS com_lastupdate
FROM person p
LEFT JOIN village v on p.village_id = v.village_id
LEFT OUTER JOIN person_death pd on pd.person_id = p.person_id
where v.village_moo <> 0
GROUP BY v.village_id

ตรวจสอบการฝากครรถ์ 5 ครั้งคุณภาพ


ตรวจสอบการฝากครรถ์ 5 ครั้งคุณภาพ

SELECT  p.person_id,p.cid,CONCAT(p.pname,p.fname," ",p.lname)  name_mother,
h.address,v.village_moo as moo ,Year(Now())-Year(p.birthdate)  age,a.preg_no,
CONCAT (substr(a.lmp,9,2),"-",substr(a.lmp,6,2),"-",substr(a.lmp,1,4)+543) lmp,
CONCAT (substr(a.edc,9,2),"-",substr(a.edc,6,2),"-",substr(a.edc,1,4)+543) edc,
if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "1" and "12" or ao.precare_no =1
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1',null) '<12w_1',
if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "16" and "20"  or ao.precare_no =2
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1',null) '16-20w_2',
if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "24" and "28"  or ao.precare_no =3
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1',null) '24-28w_3',
if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "30" and "34"  or ao.precare_no =4
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1',null) '30-34w_4',
if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "36" and "40"  or ao.precare_no =5
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1',null) '36-40w_5',
concat(round(if(count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "1" and "12" or ao.precare_no =1
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1','0'))
+ if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "16" and "20" or ao.precare_no =2
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1','0')
+ if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "24" and "28" or ao.precare_no =3
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1','0')
+ if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "30" and "34" or ao.precare_no =4
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1','0')
+ if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "36" and "40" or ao.precare_no =5
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1','0') )total,
if( concat(round(if(count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "1" and "12" or ao.precare_no =1
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1','0'))) = 1,'Yes','No') result_anc_12w,
if( concat(round(if(count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "1" and "12" or ao.precare_no =1
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1','0'))
+ if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "16" and "20" or ao.precare_no =2
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1','0')
+ if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "24" and "28" or ao.precare_no =3
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1','0')
+ if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "30" and "34" or ao.precare_no =4
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1','0')
+ if (count(DISTINCT  case when  p.cid  and ps.pa_week BETWEEN "36" and "40" or ao.precare_no =5
then  p.house_id = h.house_id else null end)
in ('1','2','3','4'),'1','0') ) = 5,'Yes','No') result_anc_5,
CONCAT (substr(a.labor_date,9,2),"-",substr(a.labor_date,6,2),"-",substr(a.labor_date,1,4)+543) bir_baby,
DATEDIFF(( SELECT ac.care_date FROM  person_anc_preg_care  ac
LEFT JOIN person_anc aa on  ac.person_anc_id = aa.person_anc_id
 where   aa.person_id = p.person_id  and aa.person_anc_id = a.person_anc_id and
 ac.preg_care_number = 1 order by  ac.care_date desc LIMIT 0,1 ),labor_date) m_1,
( SELECT concat(substr(ac.care_date,9,2),"-",substr(ac.care_date,6,2),"-",substr(ac.care_date,1,4)+543)ac FROM  person_anc_preg_care  ac
LEFT JOIN person_anc aa on  ac.person_anc_id = aa.person_anc_id
 where   aa.person_id = p.person_id  and aa.person_anc_id = a.person_anc_id and
 ac.preg_care_number = 1 order by  ac.care_date desc LIMIT 0,1 ) mother_care_1,
DATEDIFF(( SELECT ac.care_date FROM  person_anc_preg_care  ac
LEFT JOIN person_anc aa on  ac.person_anc_id = aa.person_anc_id
 where   aa.person_id = p.person_id  and aa.person_anc_id = a.person_anc_id and
 ac.preg_care_number = 2 order by  ac.care_date desc LIMIT 0,1 ),labor_date) m_2,
(SELECT concat(substr(ac.care_date,9,2),"-",substr(ac.care_date,6,2),"-",substr(ac.care_date,1,4)+543) ac FROM  person_anc_preg_care  ac
LEFT JOIN person_anc aa on  ac.person_anc_id = aa.person_anc_id
 where   aa.person_id = p.person_id  and aa.person_anc_id = a.person_anc_id and
  ac.preg_care_number = 2 order by  ac.care_date desc LIMIT 0,1 ) mother_care_2,
DATEDIFF(( SELECT ac.care_date FROM  person_anc_preg_care  ac
LEFT JOIN person_anc aa on  ac.person_anc_id = aa.person_anc_id
 where   aa.person_id = p.person_id  and aa.person_anc_id = a.person_anc_id and
 ac.preg_care_number = 3 order by  ac.care_date desc LIMIT 0,1 ),labor_date) m_3,
(SELECT concat(substr(ac.care_date,9,2),"-",substr(ac.care_date,6,2),"-",substr(ac.care_date,1,4)+543) ac FROM  person_anc_preg_care  ac
LEFT JOIN person_anc aa on  ac.person_anc_id = aa.person_anc_id
 where   aa.person_id = p.person_id  and aa.person_anc_id = a.person_anc_id and
 ac.preg_care_number = 3 order by  ac.care_date desc LIMIT 0,1 ) mother_care_3,
concat(substr(a.force_complete_date,9,2),"-",substr(a.force_complete_date,6,2),"-",substr(a.force_complete_date,1,4)+543) mother_send_43f,
CONCAT(p2.pname,p2.fname," ",p2.lname)  name_baby,
DATEDIFF(( SELECT pc.care_date FROM  person_wbc_post_care  pc
LEFT JOIN person_wbc pw on  pc.person_wbc_id = pw.person_wbc_id
 where    pw.person_id = p2.person_id  and  pc.care_number= 1 order by  pc.care_date desc LIMIT 0,1),labor_date) b_1,
( SELECT concat(substr( pc.care_date,9,2),"-",substr(pc.care_date,6,2),"-",substr(pc.care_date,1,4)+543)pc FROM  person_wbc_post_care  pc
LEFT JOIN person_wbc pw on  pc.person_wbc_id = pw.person_wbc_id
 where    pw.person_id = p2.person_id  and  pc.care_number= 1 order by  pc.care_date desc LIMIT 0,1 ) baby_care_1,
DATEDIFF(( SELECT pc.care_date FROM  person_wbc_post_care  pc
LEFT JOIN person_wbc pw on  pc.person_wbc_id = pw.person_wbc_id
 where    pw.person_id = p2.person_id  and  pc.care_number= 2 order by  pc.care_date desc LIMIT 0,1),labor_date) b_2,
( SELECT concat(substr( pc.care_date,9,2),"-",substr(pc.care_date,6,2),"-",substr(pc.care_date,1,4)+543)pc FROM  person_wbc_post_care  pc
LEFT JOIN person_wbc pw on  pc.person_wbc_id = pw.person_wbc_id
 where    pw.person_id = p2.person_id  and  pc.care_number= 2 order by  pc.care_date desc LIMIT 0,1 ) baby_care_2,
DATEDIFF(( SELECT pc.care_date FROM  person_wbc_post_care  pc
LEFT JOIN person_wbc pw on  pc.person_wbc_id = pw.person_wbc_id
 where    pw.person_id = p2.person_id  and  pc.care_number= 3 order by  pc.care_date desc LIMIT 0,1),labor_date) b_3,
( SELECT concat(substr( pc.care_date,9,2),"-",substr(pc.care_date,6,2),"-",substr(pc.care_date,1,4)+543)pc FROM  person_wbc_post_care  pc
LEFT JOIN person_wbc pw on  pc.person_wbc_id = pw.person_wbc_id
 where    pw.person_id = p2.person_id  and  pc.care_number= 3 order by  pc.care_date desc LIMIT 0,1 ) baby_care_3,
concat(substr(pw.force_complete_date,9,2),"-",substr(pw.force_complete_date,6,2),"-",substr(pw.force_complete_date,1,4)+543) baby_send_43f
FROM person  p
left JOIN house h ON p.house_id = h.house_id
left JOIN village  v ON v.village_id = h.village_id
LEFT JOIN person_anc  a ON a.person_id = p.person_id
left JOIN person_anc_preg_care  ac ON ac.person_anc_id = a.person_anc_id
LEFT JOIN person_anc_service  ps ON ps.person_anc_id = a.person_anc_id
left JOIN person_anc_other_precare ao on ao.person_anc_id = a.person_anc_id
left OUTER JOIN person  p2 ON p2.birthdate = a.labor_date and p2.mother_person_id = p.person_id
LEFT OUTER JOIN  person_wbc  pw on pw.person_id = p2.person_id
LEFT OUTER JOIN person_wbc_post_care  pc ON pc.person_wbc_id = pw.person_wbc_id
WHERE v.village_moo <> 0 AND  p.death = "N"  and a.edc > 20140930
GROUP BY a.person_anc_id
ORDER BY a.lmp asc


HOSxP ตรวจสอบการได้รับวัคซีน


HOSxP ตรวจสอบการได้รับวัคซีน

select p.person_id,CONCAT(p.pname,p.fname," ",p.lname) as ptname,
concat( timestampdiff(year,birthdate,NOW() ) ," y ",
timestampdiff(month,birthdate,NOW() )-(timestampdiff(year,birthdate,NOW() )*12) ," m ",
timestampdiff(day,date_add(birthdate,interval (timestampdiff(month,birthdate,NOW() )) month),NOW() ) ," d ") as age,
h.address h_no,v.village_moo v_no ,p.birthdate,p.house_regist_type_id type,
(select GROUP_CONCAT( DISTINCT pv.export_vaccine_code,' - ','(',pv.vaccine_code,')') from person_vaccine pv
LEFT JOIN person_vaccine_elsewhere pve on pve.person_vaccine_id = pv.person_vaccine_id
where p.person_id = pve.person_id
GROUP BY p.cid ) as 'all_vaccine_other',
(select GROUP_CONCAT( DISTINCT wv.export_vaccine_code,' - ','(',wv.wbc_vaccine_code,')')
from wbc_vaccine wv
left JOIN person_wbc_vaccine_detail pwvs ON wv.wbc_vaccine_id = pwvs.wbc_vaccine_id
left JOIN person_wbc_service pws ON pws.person_wbc_service_id = pwvs.person_wbc_service_id
left JOIN person_wbc pw ON pw.person_wbc_id = pws.person_wbc_id
where p.person_id = pw.person_id
GROUP BY p.cid ) as 'all_vaccine_in_0-1y' ,
(select GROUP_CONCAT( DISTINCT ev.export_vaccine_code,' - ','(',ev.vaccine_code,')')
FROM epi_vaccine ev
left JOIN person_epi_vaccine_list pel ON ev.epi_vaccine_id = pel.epi_vaccine_id
left JOIN person_epi_vaccine pev ON pel.person_epi_vaccine_id = pev.person_epi_vaccine_id
left JOIN person_epi pe ON pev.person_epi_id = pe.person_epi_id
where p.person_id = pe.person_id
GROUP BY p.cid ) as 'all_vaccine_in_1-5y'
FROM person p
left JOIN house h ON p.house_id = h.house_id
left JOIN village v ON v.village_id = h.village_id
where TIMESTAMPDIFF(MONTH,p.birthdate,now())between 0 and 60 and p.death = 'N' AND p.person_discharge_id =9
and v.village_moo <> "0" AND p.nationality = 99 and p.house_regist_type_id IN (1,3)
group by p.person_id
order by p.birthdate DESC

วันอังคารที่ 5 มกราคม พ.ศ. 2559

การตั้งค่า HN AN VN REFER เมื่อขึ้นปีใหม่


คลิก Youtube

ติดตั้ง Yii2 พร้อม Update Composer


อันดับแรก Download Composer Setup ไว้ที่ Xampp\php สำหรับ ลิงค์ดาวน์โหลด


composer global require "fxp/composer-asset-plugin:~1.1.1"
BASIC ===>  composer create-project yiisoft/yii2-app-basic basic 2.0.6
Advinced ===> composer create-project yiisoft/yii2-app-advanced advanced 2.0.6
composer require yiisoft/yii2 2.0.6

init 0


อัพเดรทไลบารี่ Composer ===> composer self-update
อัพเดรท Composer ===> composer update

คำสั่ง Clear Squid ClearOS




Clearing Squid Log file on /var/log/squid

#rm -rf /var/log/squid
#mkdir -p /var/log/squid
#chmod 777 /var/log/squid
#chown squid:squid /var/log/squid
#squid -z
================================================

Clearing Squid Cache file on /var/spool/squid/

#rm -rf /var/spool/squid/
#mkdir -p /var/spool/squid
#chmod 777 /var/spool/squid/
#chown squid:squid /var/spool/squid/
#squid -z
===============================================

Clearing Frox Cache on  /var/spool/frox/cache/

#rm -rf /var/spool/frox/cache/
#mkdir -p /var/spool/frox/cache/
#chown frox:frox /var/spool/frox/cache/
#chmod 777 /var/spool/frox/cache/
#service frox start

==============================================
คำสั่งเครีย cache ftp ของ frox แบบบันทัดเดียว

rm -rf /var/cache/frox/cache/*;service frox restart

Chmod 77


คำสั่งChmod 77 เฉพาะไฟล์ที่อยู่มในโฟลเดอร์

 chown apache.apache -R /var/www/html/...

วันจันทร์ที่ 4 มกราคม พ.ศ. 2559

ขั้นตอนการตรวจเช็คทรพยากรณ์และติดตั้ง DS_EMR อย่างละเอียด


ขั้นตอนการตรวจเช็คทรัพยากรณ์และติดตั้ง DS_EMR อย่างละเอียด

คำสั่งเช็คเวอร์ชั่น CentOS              ====>    cat /etc/redhat-release

คำสั่งเข้าไปตั้ง IP DNS Gateway   ====>    setup   (CentOS ต้องลง x-windows) 

คำสั่งเปลี่ยน Graphic Mode           ====>    vi /etc/inittab
                                                                       ดูตรง  id:5:initdefault:
                                                                       3 = text mode
                                                                       5 = graphic mode  แล้วสั่ง restart เครื่อง

คำสั่งติดตั้ง Wine                            ====>    wine เอาไว้เปิดไฟล์ exe ใน linux
    1.wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    2.wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
    3.sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm    หากไม่ได้ให้ติดตั้ง
    4.sudo yum upgrade ca-certificates --disablerepo=epel
    5.sudo sed -i "s/mirrorlist=https/mirrorlist=http/" /etc/yum.repos.d/epel.repo 
    และ yum install wine   
    เปิด winecfg



คำสั่งติดตั้ง Teamviwer For CentOS ====> เข้าเว็บโหลดโปรแกรมมาติดตั้งผ่าน wine กำหนดให้เริ่มโปรแกรมอัตโนมัติเมื่อเปิด Server




ตั้ง Default User                       ====>     เพื่อหลังจากเปิด Server ขึ้นมาไม่ต้อง Login เข้าหน้าแรกเลย
     1.vi /etc/gdm/custom.conf
     2.เพิ่มเข้าไป 2 บรรทัด


ติดตั้ง Install VNC                 ====>    https://www.youtube.com/watch?v=gElZQUSxleg

ติดตั้ง x windows                   ====>    yum groupinstall "X Window System" -y
                                                              yum groupinstall "Desktop" -y
                                                              yum groupinstall "General Purpose Desktop" -y
                                                              yum groupinstall "Development Tools" -y
                                                              yum install xorg-x11-fonts-misc
                                                              yum install *font* -y
                                                              (สำหรับเครื่องที่ลงเป็น Text Mode แต่แรก)

ติดตั้ง ftp                                ====>   yum install ftp
                                                             sftp root@IP Address
                                                             sftp h11031@IP Address

สร้าง Directory รองรับโปรแกรม      ====>  mkdir /dstmp
                                                                      mkdir /dstmpall
                                                                      chmod -R 777 /dstmp
                                                                      chmod -R 777 /dstmpall
                                                                      ls /

Path ของโปรแกรม DS_EMR  ====>  /root/.wine/drive_c/users/Public/Application/Application_data

Path ของIDSServer(ตัวนำเข้า) ==>/home/ck-datacenter/.wine/drive_c/Program Files/iDSEMRServer

grant @localhost       ====>  grant all on *.* to sa@"localhost" identified by 'sa' with grant option;
                                               grant super on *.* to sa@"%" identified by 'sa' with grant option;
                                               flush privileges;

clear process             ====>  kill -9 (ตามด้วยหมายเลข process)





ขั้นตอนการติดตั้ง DS_EMR

Copy ไฟล์ Config   ====> 1. XEDSBTF-BEGIN
                                            2. XEDSBTF-WIN32
                                            ไปไว้ที่ /root/.wine/drive_c/users/Public/Application/Application_data

การติดตั้ง DS_EMR ====> 1. iDSEMRClient_FULL_Install_58.10.01 (ตัวส่งรายวัน)



                                             2. iBackupANT_FULL_Install_58.10.02 (ตัวส่งฐานตั้งต้น)













คำสั่ง Backup + Restore + Repair ฐานข้อมูล


คำสั่ง Backup + Restore + Repair ฐานข้อมูล

mysqldump --opt --default-character-set=tis620 --force --allow-keywords --single-transaction -u root -p<bank> hos > /var/backup/hosxp_backup.sql

cd /var/backup --------> gzip hos.sql

mysqldump --opt --default-character-set=tis620 --force --allow-keywords --single-transaction -u root -p<bank> ck_db > /var/backup/ck_db.sql

cd /var/backup --------> gzip ck_db.sql


repair database    -------------->   mysqlcheck -uroot -p --auto-repair --optimize --all-databases


การ Backup และ Restore ฐานข้อมูลผ่าน command lineในการสำรองข้อมูล (Backup) หรือการคืนค่าข้อมูล (Restore) หลายท่านน่าจะเคยทำผ่าน web application เช่น phpMyAdmin มาบ้างแล้ว แต่ด้วยข้อจำกัดของ HTTP นั้นจะมีปัญหาสำหรับฐานข้อมูลที่มีขนาดใหญ่ ดังนั้นการใช้คำสั่งผ่าน command line นั้นจึงมีประสิทธิภาพมากที่สุด

การสำรองข้อมูลใน MySQL นั้นทางผู้พัฒนาเองได้ให้เครื่องมือช่วยมาด้วยชื่อว่า mysqldump สามารถทำการสำรองข้อมูลตามต้องการได้ โดยการใช้งานสั่งได้โดยทำงานผ่าน command line โดยมีรูปแบบ

BASH
mysqldump -u [username] -p[password] [database] > [filename]

ตัวอย่างการใช้งานเช่น

BASH
mysqldump -u root -pMyPass test > backup.sql
เป็นลักษณะการสั่งให้สำรองฐานข้อมูลลงในไฟล์ ในระบบปฎิบัติการ Unix/Linux นั้นเราสามารถใช้คำสั่งบีบอัดร่วมได้เช่น

BASH
mysqldump -u root -pMyPass test | gzip > backup.sql.gz
หรือ
zyN8pQ==
_

BASH
mysqldump -u root -pMyPass test | bzip2 > backup.sql.bz2

และยังเรายังสามารถสำรองฐานข้อมูลทั้งหมดด้วย
BASH
mysqldump -u root -pMyPass --all-databases | gzip > backup.sql.gz
และยังมีค่าอื่นเพื่อระบุรูปแบบได้ตามต้องการ เช่น
--add-drop-table เพื่อสั่งให้ drop ตารางที่มีอยู่ก่อน
--no-data เพื่อสั่งให้สำรองเฉพาะโครงสร้างของตาราง
--add-locks เพื่อสั่งให้มีการล็อคตารางและคลายล็อคตาราง

ส่วนการคืนค่าข้อมูลก็สามารถทำได้ด้วยการใช้คำสั่ง mysql มีรูปแบบการใช้งาน
BASH
mysql -u [username] -p[password] [database] < backup.sql
ตัวอย่างการใช้งานเช่น
BASH
mysql -u root -pMyPass test < backup.sql
ส่วนถ้าเป็นไฟล์บีบอัดเช่น
BASH
gunzip < backup.sql.gz | mysql -u root -pMyPass test
หรือ
BASH
bzip2 < backup.sql.bz2 | mysql -u root -pMyPass test
หวังว่าจะมีประโยชน์สำหรับทุกท่าน

ซ่อมตาราง
mysqlcheck -u root -p --auto-repair referdb

คำสั่งติดตั้ง MySQL CentOS


คำสั่งติดตั้ง MySQL CentOS

 ใช้คำสั่งตรวจสอบว่ามี Mysql อยู่ในเครื่องเราหรือไม่
- rpm -qa | grep MariaDB

ใช้คำสั่งลบ Mysql ที่มีอยู่หรือที่ติดมากับ CentOS
- rpm -e --nodeps MariaDB-shared
- rpm -e --nodeps MariaDB-client
- rpm -e --nodeps MariaDB-server

ใช้คำสั่งเข้าไปปิดไฟล์วอล
- vi /etc/sysconfig/selinux
- vi /etc/sysconfig/iptables
- vi /etc/security/limits.conf
- service iptables restart


ใช้คำสั่งตรวจสอบ libs mysql และทำการลบ
- rpm -e --nodeps mysql-libs

ใช้คำสั่ง copy และเปลี่ยนชื่อ my.cnf ไปไว้ทใน /etc
- cp my_cnf16G.txt /etc/my.cnf

ใช้คำสั่งแก้ไข my.cnf
- vi /etc/my.cnf

ใช้คำสั่งลบ libs และ mysql
- rm -rf /var/lib/mysql/*
- rm -Rv mysql:mysql /var/lib/mysql

ใช้คำสั่งติดตั้ง Mysql
- rpm -ivh MariaDB...client.rpm --nodeps --force
- rpm -ivh MariaDB...shared.rpm --nodeps --force
- rpm -ivh MariaDB...server.rpm --nodeps --force

ใช้คำสั่งกำหนดสิทธ์ให้สามารถแก้ไข libs และ mysql อีกครั้ง
- chown -Rv mysql:mysql /var/lib/mysql/

ใช้คำสั้งติดตั้ง mysql
- sudo -u mysql mysql_install_db

ใช้คำสั่ง restart service mysql
- service mysql restart

ใช้คำสั่งกำหนด password ให้กับ mysql
- /usr/bin/mysqladmin -u root password '123456'

ใช้คำสั่งเข้า mysql
- mysql -u root -p
- QUIT
- service mysql restart


หาก connect ไม่ได้ให้เข้าไปที่ vi /etc/sysconfig/iptables
เพิ่มและกำหนดพอท -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
และ service iptables restart


create database hos;
grant all on *.* to sa@"%" identified by 'sa' with grant option;
grant super on *.* to sa@"%" identified by 'sa' with grant option;
flush privileges;


mysqlcheck -u root -p --auto-repair referdb




ติดตั้ง PHP ควรเป็นเวอร์ชั่นเดียวกันนะครับ rpm -qa | grep php ตรวจสอบ

-  yum install php
-  vi /etc/php.ini  แก้ไข short_open_tag = On
-  yum php-mysql-5.3.3-27.el6_5.x86_64
-  yum install php-devel-5.3.3-27.el6_5.x86_64
-  yum install php-gd-5.3.3-27.el6_5.x86_64  
-  yum install php-pear gcc
-  yum install ImageMagick ImageMagick-devel ImageMagick-perl
-  pecl install imagick
-  service httpd resatrt

Query รายงานการใช้ยา HosXP + PCU


เปลี่ยนรหัสสถานพยาบาลให้ตรงตามแต่ละที่ด้วยนะครับ และตาราง stock_bdg_year ตรงตามปีงบ


select s.name as drugname
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=10 and icode=s.icode )as "oct"
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=11 and icode=s.icode )as "nov"
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=12 and icode=s.icode )as "dece"
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=1 and icode=s.icode )as "jan"
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=2 and icode=s.icode )as "feb"
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=3 and icode=s.icode )as "mar"
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=4 and icode=s.icode )as "apr"
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=5 and icode=s.icode )as "may"
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=6 and icode=s.icode )as "june"
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=7 and icode=s.icode )as "july"
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=8 and icode=s.icode )as "aug"
,(select sum(qty)as cc from opitemrece  o
left outer join stock_bdg_year s on (o.vstdate >= s.begin_date and o.vstdate <= s.end_date )
where s.bdg_year="2559" and month(o.vstdate)=9 and icode=s.icode )as "sep"

from drugitems  s
where  istatus ="Y"

วิธีแปลง Format ค.ศ เป็น พ.ศ HOSXP


1.ใช้ variable เพื่อจัดการฟังชั่น

2.ใส่โค้ส

                    Value := formatdatetime ('dd' ,DBPipeline['vstdate'])+
                                  formatdatetime ('mmmm' ,DBPipeline['vstdate'])+
                                  inttostr (strtoint(formatdatetime ('yyyy' ,DBPipeline['vstdate']))+543);

3.