BMS-HOSxP Community

HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: nksawan2011 ที่ ตุลาคม 31, 2012, 14:02:36 PM

หัวข้อ: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: nksawan2011 ที่ ตุลาคม 31, 2012, 14:02:36 PM
ผมลองทำแล้วมันขึ้นทุกตัวครับ

select o.vn,o.hn,concat(p.pname,p.fname," ",p.lname) as pt_name,p.cid,o.vstdate,v.age_y,v.pttypeno
,if(op.icode like "1%",concat(d.name,d.strength," ",d.units),nd.name)  as drugname

,op.icode,op.qty,op.unitprice,op.sum_price,op.income,op.paidst
,if(op.paidst="01" or op.paidst="02",sum_price,null) as reim_amount
,if(op.paidst="03",sum_price,null) as not_reim_amount
,if(op.icode like "1%",if(op.paidst=03,"àºÔ¡äÁèä´é","àºÔ¡ä´é"),concat("ÃËÑÊ ",nd.billcode)) as reim_status
,if(op.income="03",if(d.drugaccount ='','¤èÒÂҹ͡ºÑ­ªÕÂÒËÅÑ¡áË觪ҵÔ','¤èÒÂÒ㹺ѭªÕÂÒËÅÑ¡áË觪ҵÔ'),i.name)as check_drugtype
,concat("***",i.name,"***") as income_name,o.vsttime,p1.name,concat(v.hospmain,"  ",h.hosptype,h.name) as hospname
,concat(p.addrpart,"ËÁÙè ",p.moopart," ",p.road," ",t.full_name) as fulladdressname
,concat(pc.name," , ",pa.name) as pcname,shortlist,d1.name as doctor_name,pdx,v.pttype,v.pttype,p.chwpart,p1.pcode,v.item_money,v.hospmain
,pn.presc_reason
from ovst o
join patient p on p.hn=o.hn
join vn_stat v on v.vn=o.vn
LEFT OUter Join thaiaddress t ON t.addressid=v.aid
join opitemrece op  on op.vn=o.vn
join income i on i.income=op.income
join income_report2 i2 on i2.group_id=i.group2
left outer join drugitems d on d.icode=op.icode
left outer join nondrugitems nd on nd.icode=op.icode
left outer join pttype p1 on p1.pttype=v.pttype
left outer join hospcode h on h.hospcode=v.hospmain
left outer join paidst pa on pa.paidst=p1.paidst
left outer join pcode pc on pc.code =p1.pcode
left outer join drugusage du on du.drugusage =op.drugusage
left outer join doctor d1 on d1.code =o.doctor
join ovst_presc_ned pn on pn.vn =o.vn
where o.vn="551025140054"

order by income_name,i2.group_id,check_drugtype, op.item_no
หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: patoona49 ที่ ตุลาคม 31, 2012, 14:55:13 PM
เอาใหม่ ที่วา "ผมลองทำแล้วมันขึ้นทุกตัวครับ"

อะไรขึ้น ยังไงครับ
หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: golf_win ที่ ตุลาคม 31, 2012, 15:48:09 PM
แปลกที่เป็นใบสั่งยาแต่ไม่ใช้ตาราง doctor_order_print   ??? ???
หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: nongtan ที่ ตุลาคม 31, 2012, 16:00:46 PM
ของผมเป็นแบบนี้ครับ แต่ก็ยังไม่แน่ใจ ตรง having ว่ามันจะทำให้ยาในบัญชีหายหมดหรือเปล่า
**********************************************************************
select d1.patient_name,v1.hn,DATE_FORMAT(v1.vstdate,'%d/%m/ %Y') as vstdate,d1.rx_queue,d1.patient_pttype_name,k.department,concat(d1.qty_name,' ',dr.units) as qty_name,
right(d1.doctor_order_print_date_time,8) as doctor_rx_time,d1.icode,d1.drug_name,
if(left(d1.ward_name,5)='ยานอก','NED','') as status1,
if(left(d1.ward_name,4)='ยาใน',(if((dr.icode in("1300028","1300160","1300140","1300145","1300297",
     "1300214","1300310","1300190","1300363","1300289","1300362","1300380",
     "1530002","1530003","1300319","1300127","1530005","1300379","1550012"))
and(d1.patient_pttype_name in(select name from pttype where pttype in("02","03","04","05","07","09","10","11","15"))),'ED**','ED')),'') as status2,
if(dr.icode in(1300193,1300194,1300195,1300014,1300015,1300377,1300281,1300218,1300024
,1300026,1300027,1300028,1300034,1300365,1300038,1300267,1300333,1300049,1300050,1300051,1300052,1300081,1300058
,1300061,1300060,1300042,1300041,1300040,1300043,1300072,1300073,1300074,1300075,1300206,1300359,1300266,1300087
,1300088,1300356,1300095,1300331,1300097,1300257,1300222,1300103,1530008,1300104,1300106,1300105,1300107,1300108
,1300113,1300114,1300118,1300205,1300337,1540029,1300120,1300124,1300125,1300127,1300126,1300129,1300130,1300133
,1300280,1300134,1300135,1300209,1300141,1300146,1300147,1300369,1300156,1300157,1300158,1300164,1300223,1300169
,1300170,1300171,1300173,1300336,1300325,1520014,1300180,1300181,1300182,1300183,1300301,1300241),'@','') as status3,
opn.presc_reason,opn.icode
from doctor_order_print d1
left outer join vn_stat v1 on v1.vn=d1.vn
left outer join ovst o1 on o1.vn=d1.vn
left outer join drugitems dr on dr.icode=d1.icode
left outer join kskdepartment k on k.depcode=o1.main_dep
left outer join ovst_presc_ned opn on opn.vn=d1.vn
where d1.vn="551031141115"
and d1.print_mode=1 and d1.icode not like "3%"
group by d1.icode,opn.icode
having d1.icode=opn.icode
หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: nongtan ที่ ตุลาคม 31, 2012, 16:03:38 PM
แปลกที่เป็นใบสั่งยาแต่ไม่ใช้ตาราง doctor_order_print   ??? ???

อาจเป็นเพราะต้องการ Print ย้อนหลังมั๊งครับ  ของผมถ้าจะ print ย้อนหลัง ผมใช้ opitemrece

ว่าแต่  คุณ nksawan2011  ใช่พี่จิราเดช รึเปล่า แสดงตัวตนด้านล่างด้วยนะครับ ผมนนท์ครับ
หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: nksawan2011 ที่ ตุลาคม 31, 2012, 16:14:25 PM
เอาใหม่ ที่วา "ผมลองทำแล้วมันขึ้นทุกตัวครับ"

อะไรขึ้น ยังไงครับ

เหตุผลของ presc_reason ครับ
หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: nksawan2011 ที่ ตุลาคม 31, 2012, 16:16:34 PM
แปลกที่เป็นใบสั่งยาแต่ไม่ใช้ตาราง doctor_order_print   ??? ???

รพ.จิตเวช หมอปรับยาในวันเดียวกัน พอปริ้นยามีปัญหาการพิมพ์ยาซ้ำบ่อยมาก
หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: nksawan2011 ที่ ตุลาคม 31, 2012, 16:17:48 PM
อขบคุณมากครับ พรุ่งนี้ลองดู

ของผมเป็นแบบนี้ครับ แต่ก็ยังไม่แน่ใจ ตรง having ว่ามันจะทำให้ยาในบัญชีหายหมดหรือเปล่า
**********************************************************************
select d1.patient_name,v1.hn,DATE_FORMAT(v1.vstdate,'%d/%m/ %Y') as vstdate,d1.rx_queue,d1.patient_pttype_name,k.department,concat(d1.qty_name,' ',dr.units) as qty_name,
right(d1.doctor_order_print_date_time,8) as doctor_rx_time,d1.icode,d1.drug_name,
if(left(d1.ward_name,5)='ยานอก','NED','') as status1,
if(left(d1.ward_name,4)='ยาใน',(if((dr.icode in("1300028","1300160","1300140","1300145","1300297",
     "1300214","1300310","1300190","1300363","1300289","1300362","1300380",
     "1530002","1530003","1300319","1300127","1530005","1300379","1550012"))
and(d1.patient_pttype_name in(select name from pttype where pttype in("02","03","04","05","07","09","10","11","15"))),'ED**','ED')),'') as status2,
if(dr.icode in(1300193,1300194,1300195,1300014,1300015,1300377,1300281,1300218,1300024
,1300026,1300027,1300028,1300034,1300365,1300038,1300267,1300333,1300049,1300050,1300051,1300052,1300081,1300058
,1300061,1300060,1300042,1300041,1300040,1300043,1300072,1300073,1300074,1300075,1300206,1300359,1300266,1300087
,1300088,1300356,1300095,1300331,1300097,1300257,1300222,1300103,1530008,1300104,1300106,1300105,1300107,1300108
,1300113,1300114,1300118,1300205,1300337,1540029,1300120,1300124,1300125,1300127,1300126,1300129,1300130,1300133
,1300280,1300134,1300135,1300209,1300141,1300146,1300147,1300369,1300156,1300157,1300158,1300164,1300223,1300169
,1300170,1300171,1300173,1300336,1300325,1520014,1300180,1300181,1300182,1300183,1300301,1300241),'@','') as status3,
opn.presc_reason,opn.icode
from doctor_order_print d1
left outer join vn_stat v1 on v1.vn=d1.vn
left outer join ovst o1 on o1.vn=d1.vn
left outer join drugitems dr on dr.icode=d1.icode
left outer join kskdepartment k on k.depcode=o1.main_dep
left outer join ovst_presc_ned opn on opn.vn=d1.vn
where d1.vn="551031141115"
and d1.print_mode=1 and d1.icode not like "3%"
group by d1.icode,opn.icode
having d1.icode=opn.icode

หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: nksawan2011 ที่ พฤศจิกายน 01, 2012, 11:17:10 AM
ทำได้แล้วครับ ขอบคุณทุกท่านมากครับ
แบบนี้ครับ
left outer join ovst_presc_ned pn on pn.vn= o.vn and pn.icode=d.icode
หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: nongtan ที่ พฤศจิกายน 01, 2012, 11:36:56 AM
ทำได้แล้วครับ ขอบคุณทุกท่านมากครับ
แบบนี้ครับ
left outer join ovst_presc_ned pn on pn.vn= o.vn and pn.icode=d.icode

เยี่ยมครับ  ผมเข้าใจที่ คุณ nksawan2011 สงสัยในตอนแรก  ผมไปหาวิธี join กับ group by  (หลงทาง) อยู่พักนึงแล้วเหมือนกันครับ     ตอนนี้ของผมก็ปรับตามคุณ nksawan2011  จึงได้ concept สั้นๆ ว่า
select d1.vn,d1.icode as icode_doctor_order_print,opn.icode as icode_ovst_presc_ned,
opn.presc_reason
from doctor_order_print d1
join ovst_presc_ned opn on opn.vn=d1.vn and d1.icode=opn.icode
where d1.icode not like "3%" and d1.vn="551031141115"

**ตอนนี้ใบสั่งยาผม ถ้าจะเอาเหตุผลยานอกด้วย คงต้องปรับใหม่อีกนิดหน่อยครับ****
หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: nksawan2011 ที่ พฤศจิกายน 02, 2012, 09:04:23 AM
เพิ่มครงนี้อีกนิดก็ได้
,left(pn.presc_reason,1) as ned   (แสดง "A-F")
,if(pn.presc_reason like"F%","ต้องชำระเงินเอง",null) as ned1 (เหตุผลที่ต้องชำระเงินเอง "F")


ทำได้แล้วครับ ขอบคุณทุกท่านมากครับ
แบบนี้ครับ
left outer join ovst_presc_ned pn on pn.vn= o.vn and pn.icode=d.icode

เยี่ยมครับ  ผมเข้าใจที่ คุณ nksawan2011 สงสัยในตอนแรก  ผมไปหาวิธี join กับ group by  (หลงทาง) อยู่พักนึงแล้วเหมือนกันครับ     ตอนนี้ของผมก็ปรับตามคุณ nksawan2011  จึงได้ concept สั้นๆ ว่า
select d1.vn,d1.icode as icode_doctor_order_print,opn.icode as icode_ovst_presc_ned,
opn.presc_reason
from doctor_order_print d1
join ovst_presc_ned opn on opn.vn=d1.vn and d1.icode=opn.icode
where d1.icode not like "3%" and d1.vn="551031141115"

**ตอนนี้ใบสั่งยาผม ถ้าจะเอาเหตุผลยานอกด้วย คงต้องปรับใหม่อีกนิดหน่อยครับ****
หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: nongtan ที่ พฤศจิกายน 02, 2012, 10:08:01 AM
นอกเรื่องหน่อย  ที่ นครสวรรค์ เค้าให้ส่งออก 21 แฟ้มรึยังครับ
หัวข้อ: Re: ต้องการเพิ่มเหตุผล ned ในใบสั่งยา ครับ
เริ่มหัวข้อโดย: nksawan2011 ที่ พฤศจิกายน 02, 2012, 10:11:15 AM
ยังไม่เห็นหนังสือเลยครับ

นอกเรื่องหน่อย  ที่ นครสวรรค์ เค้าให้ส่งออก 21 แฟ้มรึยังครับ