แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - woravet

หน้า: 1 ... 5 6 [7] 8 9
301
คุณ Neo แฟ้ม er_emergency_type มีอะไรบ้างคับ

 

302
select v.pcode,
sum(if(d.count_in_year =0,1,0l)) as newpt ,
sum(if(d.count_in_year >0,1,0l)) as oldpt ,
count(d.vn) as cc
from dt_list d
inner join vn_stat v on v.vn=d.vn
left join  pttype p on v.pttype=p.pttype
where v.vstdate between "2008-12-01" and "2008-12-30"
and v.aid like "4304%"
group by  p.pcode

303
ใส่ Caption ให้กับ GetPickupList() ได้ป่าวคับ?
เพราะตอนแสดงจะไม่ทราบว่าเป็นอะไร ต้อง dragdrop ก่อน
หรือให้แสดงอัตโนมัติเลยได้มั๊ยคับ

304
กำหนด parameter ผิด ต้องกำหนดใหม่คับ

305
select a.dx_doctor,dr.name,o.icode,concat(d.name,' ',d.strength) as drug
,d.units,d.unitprice,d.unitcost
,sum(if(month(o.vstdate)=1,o.qty,0)) as 'mo1'
,sum(if(month(o.vstdate)=2,o.qty,0)) as 'mo2'
,sum(if(month(o.vstdate)=3,o.qty,0)) as 'mo3'
,sum(if(month(o.vstdate)=4,o.qty,0)) as 'mo4'
,sum(if(month(o.vstdate)=5,o.qty,0)) as 'mo5'
,sum(if(month(o.vstdate)=6,o.qty,0)) as 'mo6'
,sum(if(month(o.vstdate)=7,o.qty,0)) as 'mo7'
,sum(if(month(o.vstdate)=8,o.qty,0)) as 'mo8'
,sum(if(month(o.vstdate)=9,o.qty,0)) as 'mo9'
,sum(if(month(o.vstdate)=10,o.qty,0)) as 'mo10'
,sum(if(month(o.vstdate)=11,o.qty,0)) as 'mo11'
,sum(if(month(o.vstdate)=12,o.qty,0)) as 'mo12'
,sum(o.qty) as qty
,sum(o.sum_price) as sum_price
from opitemrece o
left join drugitems d on o.icode=d.icode
left join an_stat a on o.an=a.an
left join doctor dr on a.dx_doctor=dr.code
where o.vstdate between '2008-1-1' and '2008-12-31'
and d.antibiotic='Y'
and left(a.pdx,1)='J'
group by a.dx_doctor,o.icode
order by a.dx_doctor,o.icode

ขอโทษทีคับ sum ผิดที่ เห็นได้ค่าเลยไม่ได้ตรวจสอบ
ลองดูคับผม
*****
ราคารวมผมว่าน่าจะเป็น unitprice มากกว่า unitcost นะคับ

306
ติ๊ก ลงข้อมูลซักประวัติออก

307
select a.dx_doctor,dr.name,concat(d.name,' ',d.strength) as drug
,d.units,d.unitcost
,if(month(o.vstdate)=1,sum(o.qty),0) as 'mo1'
,if(month(o.vstdate)=2,sum(o.qty),0) as 'mo2'
,if(month(o.vstdate)=3,sum(o.qty),0) as 'mo3'
,if(month(o.vstdate)=4,sum(o.qty),0) as 'mo4'
,if(month(o.vstdate)=5,sum(o.qty),0) as 'mo5'
,if(month(o.vstdate)=6,sum(o.qty),0) as 'mo6'
,if(month(o.vstdate)=7,sum(o.qty),0) as 'mo7'
,if(month(o.vstdate)=8,sum(o.qty),0) as 'mo8'
,if(month(o.vstdate)=9,sum(o.qty),0) as 'mo9'
,if(month(o.vstdate)=10,sum(o.qty),0) as 'mo10'
,if(month(o.vstdate)=11,sum(o.qty),0) as 'mo11'
,if(month(o.vstdate)=12,sum(o.qty),0) as 'mo12'
,sum(o.qty) as qty
,sum(o.sum_price) as sum_price
from opitemrece o
left join drugitems d on o.icode=d.icode
left join an_stat a on o.an=a.an
left join doctor dr on a.dx_doctor=dr.code
where o.vstdate between '2008-1-1' and '2008-12-31'
and d.antibiotic='Y'
and left(a.pdx,1)='J'
group by a.dx_doctor,o.icode
order by a.dx_doctor,o.icode

แบบนี้พอไหวมั๊ยคับ  อาจจะเพี้ยนถ้าไม่ใช่ปีเดียวกัน
ตอนทำรายงานก้อ summary group จาก dx_doctor เอาคับ

308
Report Exchange / Re: ช่วยทีครับER
« เมื่อ: พฤษภาคม 26, 2009, 15:01:51 PM »
select x.code,x.type,x.period,ifnull(y.amount,0) as 'amount'
from (select concat(e1.er_emergency_type,e2.er_period) as 'code'
,e1.name as 'Type',e2.name as 'Period'
from er_emergency_type e1,er_period e2
order by code) x
left join (select concat(e.er_emergency_type,e.er_period) as 'code'
,count(e.vn) as 'amount'
from er_regist e
where e.vstdate between '2009-1-1' and '2009-1-1'
group by e.er_emergency_type,e.er_period) y on x.code=y.code


แบบนี้พอได้ม่ะ

309
select a.an, a.hn,p.pname,p.fname,p.lname
,current_date as 'now',a.regdate,a.dchdate,current_date-a.regdate as 'stay'
from an_stat a
left join patient p on a.hn = p.hn
where a.dchdate is null
and current_date-a.regdate>90
แบบนี้รึป่าว?

310
Report Exchange / Re: รบกวนผู้รู้ช่วยทีครับ
« เมื่อ: พฤษภาคม 14, 2009, 15:12:15 PM »
select d.icode,d.name as drug,d.units,d.strength
,sum(if(o2.icd10 between 'w00' and 'w9999',o1.qty,0)) as 'Code_W'
,sum(if(o2.icd10='a09',o1.qty,0)) as 'A09'
,sum(if(o2.icd10='j039',o1.qty,0)) as 'J039'
,sum(if(o2.icd10='j069',o1.qty,0)) as 'J069'
,sum(if(o2.icd10='j00',o1.qty,0)) as 'J00'
,sum(if(o2.icd10='j029',o1.qty,0)) as 'j029'
from drugitems d
left join opitemrece o1 on o1.icode=d.icode
left join ovstdiag o2 on o1.vn=o2.vn
where o1.vstdate between '2009-1-1' and '2009-1-31'
group by d.icode
order by d.name

ตก ) ไปตัวหนึ่ง

311
Report Exchange / Re: รบกวนผู้รู้ช่วยทีครับ
« เมื่อ: พฤษภาคม 14, 2009, 09:50:14 AM »
เอาใหม่
select d.icode,d.name as drug,d.units,d.strength
,sum(if(o2.icd10 between 'w00' and 'w9999',o1.qty,0) as 'Code=W'
,sum(if(o2.icd10='a09',o1.qty,0)) as 'A09'
,sum(if(o2.icd10='j039',o1.qty,0)) as 'J039'
,sum(if(o2.icd10='j069',o1.qty,0)) as 'J069'
,sum(if(o2.icd10='j00',o1.qty,0)) as 'J00'
,sum(if(o2.icd10='j029',o1.qty,0)) as 'j029'
from drugitems d
left join opitemrece o1 on o1.icode=d.icode
left join ovstdiag o2 on o1.vn=o2.vn
where o1.vstdate between '2009-1-1' and '2009-1-31'
group by d.icode
order by d.name

312
Report Exchange / Re: รบกวนผู้รู้ช่วยทีครับ
« เมื่อ: พฤษภาคม 14, 2009, 09:45:44 AM »
select d.icode,d.name as drug,d.units,d.strength
,sum(if(o2.icd10 between 'w00' and 'w9999',o1.qty,0) as 'Code=W',sum(if(o2.icd10='w9999',o1.qty,0)) as 'W9999'
,sum(if(o2.icd10='a09',o1.qty,0)) as 'A09'
,sum(if(o2.icd10='j039',o1.qty,0)) as 'J039'
,sum(if(o2.icd10='j069',o1.qty,0)) as 'J069'
,sum(if(o2.icd10='j00',o1.qty,0)) as 'J00'
,sum(if(o2.icd10='j029',o1.qty,0)) as 'j029'
from drugitems d
left join opitemrece o1 on o1.icode=d.icode
left join ovstdiag o2 on o1.vn=o2.vn
where o1.vstdate between '2009-1-1' and '2009-1-31'
group by d.icode
order by d.name

313
Report Exchange / Re: รบกวนผู้รู้ช่วยทีครับ
« เมื่อ: พฤษภาคม 07, 2009, 11:52:56 AM »
คำสั่ง SQL
select d.icode,d.name as drug,d.units,d.strength
,sum(if(o2.icd10='w0099',o1.qty,0)) as 'W0099'
,sum(if(o2.icd10='w9999',o1.qty,0)) as 'W9999'
,sum(if(o2.icd10='a09',o1.qty,0)) as 'A09'
,sum(if(o2.icd10='j039',o1.qty,0)) as 'J039'
,sum(if(o2.icd10='j069',o1.qty,0)) as 'J069'
,sum(if(o2.icd10='j00',o1.qty,0)) as 'J00'
,sum(if(o2.icd10='j029',o1.qty,0)) as 'j029'
from drugitems d
left join opitemrece o1 on o1.icode=d.icode
left join ovstdiag o2 on o1.vn=o2.vn
where o1.vstdate between '2009-1-1' and '2009-1-31'
group by d.icode
order by d.name
แบบนี้ไวมั๊ย เปลี่ยนช่วงเดือนเอาหล่ะกันคับ

314
1.แบบ dx ว่าเป็น I10 และ K30
select v.*
from vn_stat v
left join ovstdiag o1 on v.vn=o1.vn
left join ovstdiag o2 on v.vn=o2.vn
where o1.icd10='I10' and o2.icd10='K30'
and v.vstdate between '2009-1-1' and '2009-1-31'
group by v.vn

2.แบบ dx เป็น I10 หรือ K30
select v.*
from vn_stat v
left join ovstdiag o1 on v.vn=o1.vn
where o1.icd10 in ('I10','K30')
and v.vstdate between '2009-1-1' and '2009-1-31'
group by v.vn

315
เปลี่ยนชื่อแฟ้มใหม่....ให้สั้นๆ

316
การเขียน SQL Script / Re: ผู้ป่่วยโรคแทรกซ้อน
« เมื่อ: มีนาคม 30, 2009, 14:56:36 PM »
ลองตรวจสอบข้อมูลของ IPTDIAG ดู เช่น
select a.hn,a.an,a.dchdate,i.icd10
from an_stat a
left join iptdiag i on i.an=a.an
where a.an=510001325
ว่ามีข้อมูลมั๊ย?

317
การเขียน SQL Script / Re: ผู้ป่่วยโรคแทรกซ้อน
« เมื่อ: มีนาคม 30, 2009, 13:53:13 PM »
select a.hn,a.an,a.pdx,a.dx0,a.dx1,a.dx2,a.dx3,a.dx4,a.dx5,concat(p.pname,p.fname,'  ',p.lname) as ptname from an_stat a
left outer join patient p on p.hn=a.hn
left join iptdiag i on i.an=a.an
where a.dchdate between '2007-12-01' and '2008-09-30'
and ((i.icd10  >= 'L03' and i.icd10  <= 'L09') and i.icd10 in ('E119','E110','E149','E100')  )
group by a.an
order by a.an

318
การเขียน SQL Script / Re: ผู้ป่่วยโรคแทรกซ้อน
« เมื่อ: มีนาคม 30, 2009, 10:45:14 AM »
select a.hn,a.an,concat(p.pname,p.fname,'  ',p.lname) as ptname
,a.pdx,a.dx0,a.dx1,a.dx2,a.dx3,a.dx4,a.dx5
from an_stat a
left join iptdiag i on i.an=a.an
left join patient p on p.hn=a.hn
where a.dchdate between '2007-12-01' and '2008-09-30'
and i.icd10 between 'E10' and 'E1499'
and (i.icd10 between 'L01' and 'L099' or i.icd10='T793' or i.icd10='L89'
or i.icd10 in ('E105','E115','E145','E100','E110','E119','E149'))
group by a.an

319
แบบนี้ไหวมั๊ย
select p.hn,p.pname,p.fname,p.lname
,v.pdx,v.dx0,v.dx1,v.dx2,v.dx3,v.dx4,v.dx5
,p.last_visit,max(v.vstdate) as maxdate
from patient p
left join vn_stat v on p.hn=v.hn
left join ovstdiag d on v.vn=d.vn
where v.vstdate between '2009-1-1' and '2009-1-31'
and (d.icd10='E119' or d.icd10='I10')
group by p.hn
order by p.hn
อยากได้ field ไหนก้อเพิ่มเองนะคับ

320
select v.hn as HN,replace(p.cardno,'-','') as CID,o.icd10 as ICD10,pt.informname as N1,pt.informaddr as N2,
concat(pt.pname,pt.fname," ",pt.lname) as fullname,s.name as sex ,pt.birthday,
v.vstdate,na.name as nationality,pt.hometel
from vn_stat v,ovstdiag o,visit_pttype vp,ptcardno p,patient pt
left outer join sex s on s.code=pt.sex
left outer join nationality na on na.nationality=pt.nationality
where v.vn=o.vn and v.vn=vp.vn and v.hn = pt.hn and vp.pttype="52"
and o.icd10 in ("Z021","Z027") and p.hn=v.hn
and v.vstdate between "2008-02-11" and "2008-02-11" group by v.hn

321
เนื่องจากมี dx ที่ขึ้นเป็นอักษรพิมพ์เล็ก
จากการตั้ง Auto Diag ของคลีนิคพิเศษ
เลยอยากตรวจสอบ เพราะบ้างครั้ง ผป.ไม่ได้มาตรวจจากคลีนิคพิเศษ/หรือ จนท.ติ๊กผิิิิด


322
ขอทราบวิธีใช้งาน ReSync-VN หรือ AN หน่อยครับ
*****
ของ VN ใช่ไปที่เมนูผู้ป่วยนอก->บันทึกผลวินิจฉัย แล้ว คลิ๊กขวา
ส่วน AN ไปที่เมนูผู้ป่วยใน->บันทึกผลวินิจฉัย แล้ว คลิ๊กขวา
ใช่มั๊ยครับ
*****
หรือมีวิธีที่จะให้ทำงานโดยระบุทั้งปี หรือ เดือน บ้างมั๊ยครับ


323
การเขียน SQL Script / Re: คำสั่ง การแสดงผล
« เมื่อ: สิงหาคม 21, 2008, 16:30:21 PM »
select if(inregion='Y','PCU','N') as inregion
from patient

324
ใช้ VFP9 ครับ
ตัว runtime ต้องไป d/l ที่ สกส.  หรือ www.thaifox.net/vfoxpro

325
เป็น Application ที่พัฒนาเองครับ

326
แฟ้ม NUTRI ของผม มทั้ง PID และ CID ครับ

327
ช่วยดูหน่อยครับ เกี่ยวแฟ้ม NUTRI
ซึ่ง F18 ผ่านการตรวสอบ แต่ PP ไม่สามารถเปิดแฟ้มได้

328
พอดีส่งข้อมูลแล้ว สปสช.ไม่สามารถเปิดแฟ้มได้

329
Report Exchange / Re: 5 อันดับโรคที่พบบ่อยของ OPD
« เมื่อ: สิงหาคม 05, 2008, 13:33:45 PM »
select v.pdx,i.name,count(distinct v.hn) as 'คน',count(v.hn) as 'ครั้ง',v.aid
from vn_stat v
left join icd101 i on v.pdx=i.code
where v.vstdate between '2008-1-1' and '2008-1-31'
and v.aid=621001
and i.name is not null
group by v.pdx
order by 4 desc
limit 5

ขอโทษทีครับ พอดีผมเปลี่ยนชื่อ column ใหม่เป็นภาษาไทย

330
Report Exchange / Re: 5 อันดับโรคที่พบบ่อยของ OPD
« เมื่อ: สิงหาคม 04, 2008, 17:43:27 PM »
select v.pdx,i.name,count(distinct v.hn) as 'คน',count(v.hn) as 'ครั้ง',v.aid
from vn_stat v
left join icd101 i on v.pdx=i.code
where v.vstdate between '2008-1-1' and '2008-1-31'
and v.aid=621001
and i.name is not null
group by v.pdx
order by amount desc
limit 5

ที่อยู่คงได้แค่ aid เท่านั้น


331
Report Exchange / Re: 5 อันดับโรคที่พบบ่อยของ OPD
« เมื่อ: สิงหาคม 04, 2008, 15:10:02 PM »
select v.pdx,i.name,count(v.hn) as amount
from vn_stat v
left join icd101 i on v.pdx=i.code
where v.vstdate between '2008-1-1' and '2008-1-31'
and v.aid=621001
group by v.pdx
order by amount desc
limit 5
แบบนี้ได้มั๊ย ให้เปลี่ยน v.aid ตามรหัสที่อยู่เอาเอง ซึ่งจะได้จำนวนครั้ง
ถ้าต้องการจำนวนคน ให้เปลี่ยนจาก count( v.hn) เป็น count(distinct v.hn) เอา
ถ้าต้องการมากกว่า 5 รายการ เปลี่ยนจาก limit 5 เป็น limit จำนวนที่ต้องการ
คำนวนจาก principle dx.

332
แจ้งปัญหา / ขอความช่วยเหลือ / Re: แฟ้มwoman,nutri
« เมื่อ: กรกฎาคม 23, 2008, 16:32:22 PM »
น่าจะเกิดจากความกว้างของ weigth น้อยกว่าจำนวนที่คำนวณได้จาก HOSxP
*****
ใช้ VFP อยู่ ใช่มั๊ยครับ
ลอง use (ชื่อแฟ้มที่ต้องการ)
แล้ว modi stru
แก้ไขความกว้างของฟิล์ด weigth ให้ใหญ่ขึ้น

333
การเขียน SQL Script / Re: ขอคำสั่ง SQl ครับ
« เมื่อ: กรกฎาคม 23, 2008, 16:28:50 PM »
select p.hn,p.pname,p.fname,p.lname,p.pttype,p.death
,p.addrpart,p.moopart,p.tmbpart,p.amppart,p.chwpart
from patient p
left join pttype p1 on p1.pttype=p.pttype
where p1.pcode='A2' and (p.death<>'Y' or p.death is null)
and year(now())-year(p.birthday) between 30 and 50
and p.chwpart=62
and p.amppart=10
and p.tmbpart=01
and p.moopart in (1,5)
order by p.hn

พอได้มั๊ยครับ
ส่วนตรงข้อมูล จะเปลี่ยนเป็น p.* ก้อได้นะครับ
ส่วนที่อยู่แก้ไขตามต้องการนะครับ
ข้าราชการ คงเป็นสิทธิเบิกได้ ทุกอย่าง ทุกโครงการ ใช่มั๊ยครับ

334
ผมใช้คำสั่ง sql
select o.hn,v.cid,o.oqueue,v.age_y,v.age_m,s.bw,s.height,s.bmi,d.name as doctor_name
from ovst o
left join vn_stat v on v.vn=o.vn
left join opdscreen s on s.vn=o.vn
left join doctor d on d.code=v.dx_doctor
where o.vstdate between '2007-10-1' and '2007-10-31' and v.age_y<=5
แล้วมากรองเอา

335
ขอตัวอย่างแฟ้ม nutri ได้มั๊ยครับ

336
จากการตรวจสอบแฟ้ม nutri
ไม่ผ่าน ขึ้นว่า นำไม่ได้เลย(format ไม่ถูกต้อง) ไม่สามารถเปิดไฟล์ได้
ส่งเป็น dbf แก้ไขอย่างไรครับ
*****
รพ.ใด ส่งผ่านบ้างครับ ขอดูตัวอย่างบ้างครับ

337
Development / Re: VFP9+ADO+MySQL5 ตัวอย่างโปรแกรมครับ
« เมื่อ: กรกฎาคม 11, 2008, 16:21:06 PM »
หรือจะลองทำแบบ ODBC
ตัวอย่างรายงาน 504
_server='192.168.0.1'
_user='sa'
_psw='sa'
_database='hos'
_connect = ;
"Driver={MySQL ODBC 3.51 Driver};" + ;
"Server=" + _server + ";" + ;
"UID=" + _user + ";" + ;
"PASSWORD=" + _psw + ";" + ;
"Database="+_database+";" +;
"Port=3306;" + ;
"Option= 0 ;"+;
"Stmt =set names tis620;"
_handle=sqlstringconnect(_connect)
If _handle>0
_sql=[select a.*,ifnull(d.amount,0) as amount from rpt_504_name a left join ]+;
         [(select b.id,count(b.id) as amount from rpt_504_code b,ovstdiag c ]+;
         [where c.icd10 between b.code1 and b.code2 and c.icd10 is not null ]+;
         [and c.vstdate between '2008-1-1' and '2008-1-31' ]+;
         [group by b.id) d on d.id=a.id ]+;
         [order by a.id ]
if sqlexec(_handle,_sql,'TEMP')>0
brow &&แสดงข้อมูลที่คำนวณได้
else
=aeeror(test)
=messagebox('คำสั่ง SQL ผิด',0,'Error')
endif
=sqldisconnect(_handle)
else
=aerror(test)
=messagebox('ติดต่อ HOSxP ไม่ได้'+chr(13)+test(1,2),0,'Error')
endif

ควรใช้ MySQL ODBC Driver vesion 3.51.15 ขึ้นไป

338
select  p.hn,p.pname,p.fname,p.lname,v.age_y,p.moopart,p.tmbpart
from patient p
left  join vn_stat v on v.hn = p.hn
left join ovstdiag o on o.vn=v.vn
where v.vstdate  between '2008-1-1' and '2008-1-31'
and p.moopart='4'
and p.tmbpart='01'
and o.icd10 between 'i10' and 'i1599'
group by p.hn
order by p.hn

**ระวังไม่ระบุรหัสจังหวัดจะเป็นของจังหวัดอื่นได้ ถ้ามีข้อมูล
**ระวัง moopart ระบุอย่างไรบ้าง

340
ผมจะ add network printer แล้วขึ้นแบบนี้ แก้ไขอย่างไรครับ

341
Report Exchange / Re: ขอความช่วยเหลือ
« เมื่อ: เมษายน 28, 2008, 14:15:55 PM »
select i.an,i.hn,i.regdate,i.dchdate
from ipt
left join an_stat on i.an=a.an
where i.dchdate between '2008-4-1' and '2008-4-30'
and (a.pdx is null or a.pdx=' ')
order by i.regdate

342
ผมทำการ Update Structure ของ HOSxP_PCU จาก HOSxP_PCU แล้ว Error
ใช้ HOSxP 3.51.3.28 , HOSxP_PCU_Full 3.51.3.18,MySQL 4.1

343
ลองแบบนี้
Value :=GetSQLStringData('select vstdate from vn_stat where hn="'+DBPipeline['HN'] +'"and vn<"'+DBPipeline['vn']  +'" order by vn desc limit 1');
ถ้าต้องวันที่ที่มาครั้งก่อน


344
มี Source code ของ
1.Export SSN
2.Import HCIS->HOSxP
3.Import HCIS->HOSxP_PCU
ให้ศึกษาบ้างมั๊ยครับ

345
Report Exchange / Re: จะเขียนคำสั่งยังไงเนี่ยครับ
« เมื่อ: กุมภาพันธ์ 26, 2008, 17:45:18 PM »
แบบนี้พอไหวมั๊ย
select o.vn,o.hn,p.pname,p.fname,p.lname
,p.addrpart,p.moopart,a.full_name as address
,count(op.icode) as amount,s.bps,s.bpd
from ovst o
left join patient p on p.hn=o.hn
left join thaiaddress a on a.addressid=concat(p.chwpart,p.amppart,p.tmbpart)
left join opitemrece op on o.vn=op.vn
left join drugitems d on op.icode=d.icode
left join opdscreen s on s.vn=o.vn
where o.vstdate=now()
and d.name is not null
and o.hn in (select hn from clinicmember where clinic=
(select sys_value from sys_var where sys_name='ht_clinic_code'))
group by o.vn
having amount>=5
order by o.hn

346
Report Exchange / Re: รบกวนผู้รู้เรื่องรายงานครับ
« เมื่อ: กุมภาพันธ์ 22, 2008, 16:27:33 PM »
ลองเอาสั่ง sql ไปประยุกต์ดูครับ
select a.hn,concat(pname,p.fname,' ',p.lname) as namept,a.order_date
,b.lab_items_code,c.lab_items_name
,count(a.hn) as amount,d.name as doctor
from lab_head a
left join lab_order b on b.lab_order_number=a.lab_order_number
left join lab_items c on c.lab_items_code=b.lab_items_code
left join doctor d on d.code=a.doctor_code
left join patient p on p.hn=a.hn
where a.order_date between '2008-1-1' and '2008-1-31'
group by a.hn,a.order_date,b.lab_items_code,a.doctor_code
having amount>1
order by a.hn,a.order_date,b.lab_items_code,a.doctor_code
น่าจะพอใช้ได้

347
select o.hn,o.vstdate,p.pname,p.fname,p.lname,v.pdx
from ovst o
left join vn_stat v on o.vn=v.vn
left join patient p on o.hn=p.hn
where v.vstdate between '2008-1-1' and '2008-1-31'
and (v.pdx is null or v.pdx=' '
or left(v.pdx,1) in ('0','1','2','3','4','5','6','7','8','9'))
order by o.hn,o.vstdate

ลองประยุกต์ต่อนะครับ

348
Report Exchange / Re: รายงาน
« เมื่อ: กุมภาพันธ์ 01, 2008, 17:03:29 PM »
หรือจะลองแบบนี้มั๊ง
select cm.hn,cm.last_vn,concat(p.pname,p.fname,' ',p.lname) as name
,concat(p.addrpart,ifnull(p.moopart,if(p.moopart=' ','',' ม.'+p.moopart)),' ',ifnull(t.full_name,'')) as address
,o.vstdate,o.bps,o.bpd,o.fbs,o.cholesterol,o.tg,o.hdl,o.ldl
from clinicmember cm
left join patient p on cm.hn=p.hn
left join thaiaddress t on t.addressid=concat(p.chwpart,p.amppart,p.tmbpart)
left join opdscreen o on cm.last_vn=o.vn
where cm.clinic=001
order by cm.hn

ลองปรับแต่งเอานะครับ โดยเอาผลจาก opdscreen

349
Development / Re: VFP7 VS Mysql
« เมื่อ: มกราคม 28, 2008, 15:15:15 PM »
กรณีที่ 2 โดยการสร้าง User DSN ขึ้นมา && สมมุติชื่อ hos
set talk off
close data
_handle=sqlconnect('hos')
if _handle>0
  ?'สามารถ Connect HOSxp ได้'
  =sqldisconect(_handle)
else
 =aerror(merror)
 ?'ไม่สามารถติดต่อ HOSxP ได้'
 ?merror(1,2)
endif
close data

โดยปกติผมจะใช้กรณีที่ 1 เพราะที่ รพ.เปลี่ยน IP กันบ่อยมาก
โดยสร้าง func รับค่าจาก C:\WINDOWS\HOS-WIN32.INI

350
Development / Re: VFP7 VS Mysql
« เมื่อ: มกราคม 28, 2008, 15:05:26 PM »
ของ อ.อ๊อด น่าจะ Connect ไม่ได้
น่าจะเป็น
กรณี 1
set talk off
close data
_server='192.168.1.1'
_user='sa'
_psw='sa'
_database='hos'ntoc(_database,0)
_connect = ;
"Driver={MySQL ODBC 3.51 Driver};" + ;
"Server=" + _server + ";" + ;
"UID=" + _user + ";" + ;
"PASSWORD=" + _psw + ";" + ;
"Database="+_database+";" +;
"Port=3306;" + ;
"Option= 0 ;"+;
"Stmt =set names tis620;"
_handle=sqlstringconnect(_connect)
if _handle>0
  ?'สามารถ Connect HOSxp ได้'
  =sqldisconect(_handle)
else
 =aerror(merror)
 ?'ไม่สามารถติดต่อ HOSxP ได้'
 ?merror(1,2)
endif
close data

หน้า: 1 ... 5 6 [7] 8 9