พฤษภาคม 2024
จ. อ. พ. พฤ. ศ. ส. อา.
« มี.ค.    
 12345
6789101112
13141516171819
20212223242526
2728293031  
พฤษภาคม 2024
จ. อ. พ. พฤ. ศ. ส. อา.
« มี.ค.    
 12345
6789101112
13141516171819
20212223242526
2728293031  

อื่นๆ

นอกกลุ่ม

Visit ผู้มารับบริการ แยก วันหยุด+เสาร์+อาทิตย์ และแยกนอกในเวลาราชการ

select o.vstdate as DT,
sum(if(weekday(o.vstdate)in(“0″,”1″,”2″,”3″,”4”) and h.holiday_date is null and o.vsttime BETWEEN ’08:00:00′ and ’16:00:00′,’1′,null))as visitIntime,

sum(if((weekday(o.vstdate)in(“5″,”6”)or h.holiday_date is not null)
or (weekday(o.vstdate) in(“0″,”1″,”2″,”3″,”4”) or h.holiday_date is null) and (o.vsttime not BETWEEN ’08:00:00′ and ’16:00:00′)
,’1′,null))as visitOuttime,

count(DISTINCT if(weekday(o.vstdate)in(“0″,”1″,”2″,”3″,”4”)and h.holiday_date is null and o.vsttime BETWEEN ’08:00:00′ and ’16:00:00′,o.hn,null))as HNIntime,

count(distinct if((weekday(o.vstdate)in(“5″,”6”) or h.holiday_date is not null)
or (weekday(o.vstdate) in(“0″,”1″,”2″,”3″,”4”) or h.holiday_date is null) and (o.vsttime not BETWEEN ’08:00:00′ and ’16:00:00′)
,o.hn,null))as HNOuttime,

case
when WEEKDAY(o.vstdate)=0 then “จันทร์”
when WEEKDAY(o.vstdate)=1 then “อังคาร”
when WEEKDAY(o.vstdate)=2 then “พุธ”
when WEEKDAY(o.vstdate)=3 then “พฤหัส”
when WEEKDAY(o.vstdate)=4 then “ศุกร์”
when WEEKDAY(o.vstdate)=5 then “เสาร์”
when WEEKDAY(o.vstdate)=6 then “อาทิตย์”
end as KDATE,h.day_name as Holiday
from ovst o
left outer join (select vn from opd_regist_sendlist group by vn)as r on r.vn=o.vn
left outer join holiday h on h.holiday_date=o.vstdate
where o.vstdate between ‘2019-01-01’ and ‘2019-04-31’ and r.vn is not null
group by o.vstdate

ผูกผล LAB ปรับปรุง LABFU ในการส่งออก 43 แฟ้ม กรณีผล LABRESULT ไม่ออก

/*
update
lab_items_exp_map_list
set export_value=report_result
where report_result between ‘1’ and ‘9999999’
*/

/*
select * from lab_items_exp_map_list where report_result between ‘1’ and ‘9999999’
*/

/*
update
lab_items_exp_map_list
set export_value=report_result
where report_result not between ‘1’ and ‘9999999’

การดึงผล LAB ออกมาแสดงในรายงาน DHDC2 ในส่วนของ Electronic Health Record (EHR)




 

ขอขอบคุณเจ้าของผลงาน HDHC2  ครับ
District Health Data Checker, Web:20170101.27.1 , Db:2017.01.27
พัฒนาโดย :UTEHN PHNU

SELECT l.labtest,if(l.labtest =’0531002′ or l.labtest =’01’ ,’01 ตรวจน้ำตาลในเลือด จากเส้นเลือดดำ หลังอดอาหาร’,
if(l.labtest=’0531004′ or l.labtest =’02’,’02 ตรวจน้ำตาลในเลือด จากเส้นเลือดดำ โดยไม่อดอาหาร’,
if(l.labtest=’0531101′ or l.labtest =’03’,’03 ตรวจน้ำตาลในเลือด จากเส้นเลือดฝอย หลังอดอาหาร’,
if(l.labtest=’0531102′ or l.labtest =’04’,’04 ตรวจน้ำตาลในเลือด จากเส้นเลือดฝอย โดยไม่อดอาหาร’,
if(l.labtest=’0531601′ or l.labtest =’05’,’05 ตรวจ HbA1C’,
if(l.labtest=’0546602′ or l.labtest =’06’,’06 ตรวจ Trglyceride’,
if(l.labtest=’0541601′ or l.labtest =’07’,’07 ตรวจ Total Cholesterol’,
if(l.labtest=’0541202′ or l.labtest =’08’,’08 ตรวจ HDL Cholesterol’,
if(l.labtest=’0541402′ or l.labtest =’09’,’09 ตรวจ LDL Cholesterol’,
if(l.labtest=’0583001′ or l.labtest =’10’,’10 ตรวจ BUN ในเลือด’,
if(l.labtest=’0581902′ or l.labtest =’11’,’11 ตรวจ Creatinine ในเลือด’,
if(l.labtest=’0581902′ or l.labtest =’12’,’12 ตรวจโปรตีน Microalbumin ในปัสสาวะ’,
if(l.labtest=’0581903′ or l.labtest =’13’,’13 ตรวจ CREATININE ในปัสสาวะ’,
if(l.labtest=’0446203′ or l.labtest =’14’,’14 ตรวจโปรตีน Macroalbumin ในปัสสาวะ’,
if(l.labtest=’0581904′ or l.labtest =’15’,’15 ตรวจ eGFR สูตร CKD-EPI’,
if(l.labtest=’0621401′ or l.labtest =’16’,’16 ตรวจ Hb’,
if(l.labtest=’0440205′ or l.labtest =’17’,’17 ตรวจ UPCR’,
if(l.labtest=’0511402′ or l.labtest =’18’,’18 ตรวจ K ckd stage 3 หรือยา ACEI//ARBs’,
if(l.labtest=’0510402′ or l.labtest =’19’,’19 ตรวจ Bicarb ckd stage 3′,
if(l.labtest=’0511202′ or l.labtest =’20’,’20 ตรวจ phosphate ckd stage 3′,
if(l.labtest=’0614402′ or l.labtest =’21’,’21 ตรวจ PTH ckd stage 3′,
Null))))))))))))))))))))) AS tlname,labresult
FROM tmp_labfu l
LEFT JOIN clabtest t ON t.id_labtest = l.labtest
WHERE cid =’$cid’
AND seq=’$seq’ AND hospcode = ‘$hospcode’

คนไข้ความดัน ควบคุมระดับ ได้ดี 2 ครั้งหลังสุด คัดกรองจากคลิคนิค

set @d1 = ‘2015-05-31’;
set @d2 = ‘2016-10-01’;

SELECT * FROM

(select p.patient_hn as hn, p.cid, concat(p.pname, p.fname ,” “, p.lname) as pt_name
, TIMESTAMPDIFF(year,p.birthdate,now()) as age,
p.nationality,p.person_discharge_id,p.death,p.death_date,p.house_regist_type_id,m.clinic_member_status_id

,if(p.sex =1,”ชาย”,”หญิง”) as sex ,h.address, v1.village_moo, v1.village_name
, “NOT PASS” as group1,p.patient_hn,ps2.icd10

,(select if(bps between ‘1’ and ‘140’ and bpd between ‘1’ and ’90’,1,0) as poin
from opdscreen o1 WHERE o1.hn = v.hn and vstdate between @d1 and @d2
ORDER BY vstdate DESC limit 0,1) as dtx1

,(select vstdate
from opdscreen o1d WHERE o1d.hn = v.hn and vstdate between @d1 and @d2
ORDER BY vstdate DESC limit 0,1) as dtx1d
,(select bps
from opdscreen o1a WHERE o1a.hn = v.hn and vstdate between @d1 and @d2
ORDER BY vstdate DESC limit 0,1) as dtx1a
,(select bpd
from opdscreen o1b WHERE o1b.hn = v.hn and vstdate between @d1 and @d2
ORDER BY vstdate DESC limit 0,1) as dtx1b
,(select if(bps between ‘1’ and ‘140’ and bpd between ‘1’ and ’90’,1,0) as poin
from opdscreen o2 WHERE o2.hn = v.hn and vstdate between @d1 and @d2
ORDER BY vstdate DESC limit 1,1) as dtx2

,(select vstdate
from opdscreen o2d WHERE o2d.hn = v.hn and vstdate between @d1 and @d2
ORDER BY vstdate DESC limit 1,1) as dtx2d
,(select bps
from opdscreen o2a WHERE o2a.hn = v.hn and vstdate between @d1 and @d2
ORDER BY vstdate DESC limit 1,1) as dtx2a
,(select bpd
from opdscreen o2b WHERE o2b.hn = v.hn and vstdate between @d1 and @d2
ORDER BY vstdate DESC limit 1,1) as dtx2b

from vn_stat v
left join person p on p.patient_hn = v.hn
LEFT JOIN house h on h.house_id = p.house_id
LEFT JOIN village v1 on v1.village_id = p.village_id
left join clinic_persist_icd ps on ps.hn=v.hn
left join clinic_persist_icd ps2 on ps2.hn=ps.hn and ps2.icd10 between ‘e10′ and’e149’
left join clinicmember m on m.hn=ps.hn

where (v.vstdate between @d1 and @d2)
and /* v.hn in (select hn from clinicmember where clinic=”002″) */
((ps.icd10 between ‘i10’ and ‘i159′ or ps.icd10=’i674′ or ps.icd10=’H350′)
and (p.death=’N’) and (p.house_regist_type_id in (‘1′,’3′))and (m.clinic_member_status_id =’3’))
and (ps2.icd10 is null)
ORDER BY v.hn ) t1

WHERE t1.dtx1 =1 and t1.dtx2= 1
GROUP BY t1.hn

my.ini conifg

[mysqld]
skip-locking
skip-innodb
query_cache_limit=1M
query_cache_size=32M
query_cache_type=1
max_connections=500
interactive_timeout=100
wait_timeout=100
connect_timeout=10
thread_cache_size=128
key_buffer=16M
join_buffer=1M
max_allowed_packet=16M
table_cache=1024
record_buffer=1M
sort_buffer_size=2M
read_buffer_size=2M
max_connect_errors=10
# Try number of CPU’s*2 for thread_concurrency
thread_concurrency=2
myisam_sort_buffer_size=64M
log-bin
server-id=1

[safe_mysqld]
err-log=/var/log/mysqld.log
open_files_limit=8192

[mysqldump]
quick
max_allowed_packet=16M

[mysql]
no-auto-rehash
#safe-updates

[isamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M

[myisamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M

[mysqlhotcopy]
interactive-timeout

 

ที่มา : http://www.idatabase.in.th/2008/11/23/optimize-mysql

ทะเบียนเครื่องคอมพิวเตอร์ visio

ทะเบียน จำนวนข้อมูลคอมพิวเตอร์ และปริ๊นเตอร์

แบบฟอร์มการเก็บข้อมูล gishealth (http://gishealth.moph.go.th/)

Form INsert Gisheal on web

ตรวจสอบ บริการเยี่ยมบ้าน กิจกรรมซ้ำกันมากกว่า 1 ครั้ง และมีช่องว่าง

select count(o.vn)as JP,v.hn,v.vstdate,o.*
from ovst_community_service o
left join vn_stat v on v.vn=o.vn

group by o.vn, o.ovst_community_service_type_id
having count(o.vn)>1

 

 

select t.ovst_community_service_type_code,ovst_community_service_type_name,v.hn,v.vstdate,o.*
from ovst_community_service o
left join vn_stat v on v.vn=o.vn
left join ovst_community_service_type t on t.ovst_community_service_type_id=o.ovst_community_service_type_id
where vstdate between ‘2015-12-01’ and ‘2015-12-31’

hosxp ข้อมูลผู้ป่วยค้างชำระในเมนูห้องทะเบียนการเงิน ไม่ตรงกับ รายงาน end user report

select r.hn,concat(p.pname,p.fname,’ ‘,p.lname) as ptname, r.*,
o.vstdate,o.vsttime,t.name as pttype_name
from rcpt_arrear r
left outer join ovst o on o.vn=r.vn
left outer join patient p on p.hn=r.hn
left outer join pttype t on t.pttype = o.pttype
where r.arrear_date between ‘2015-09-01’ and ‘2015-09-30’
and r.paid in (‘Y’,’N’)
order by r.arrear_id

hosxp 10 อันดับยาใช้งานเยอะสุด

select count(*),o.icode,d.name
from opitemrece o
left join drugitems d on d.icode=o.icode
where o.vstdate between ‘2014-10-01’ and ‘2015-09-30’ and (o.icode not like ‘30%’)
group by o.icode
order by count(*) desc
limit 10