BMS-HOSxP Community

HOSxP => Report Exchange => ข้อความที่เริ่มโดย: gu_prajag ที่ มีนาคม 19, 2014, 15:03:34 PM

หัวข้อ: รายงานการทำหัตการผู้ป่วยใน เฉพาะ icode ที่ต้องการ
เริ่มหัวข้อโดย: gu_prajag ที่ มีนาคม 19, 2014, 15:03:34 PM
ผมลองเขียน code ดังนี้
select i.hn,i.an,concat(p.fname,' ',p.lname) as fullname,concat(p.addrpart,' ',p.moopart,' ',t.full_name) as fulladdr,io.ipt_oper_code,o.qty,o.icode,io.name,i.regdate,o.rxdate
from ipt i
left outer join patient p on p.hn=i.hn
left outer join an_stat a on a.an=i.an
left outer join opitemrece o on o.an=i.an
left outer join ipt_oper_code io on io.icode=o.icode
left outer join thaiaddress t on t.addressid=a.aid
where io.ipt_oper_code in('1','23') and o.rxdate between "2013-10-01" and "2013-10-17" and o.an is not null
order by i.an
limit 100

จาก ipt_oper_code
ipt_oper_code | icode | name
1|3000853|IV ให้สารน้ำทางหลอดเลือดดำ [เด็ก]
23|3000853|IV ให้สารน้ำทางหลอดเลือดดำ [ผู้ใหญ่]

ทำให้ข้อมูลที่ออกมา
1.0039693|560003901|สมมุติ ทดสอบ|14/1 ม.1 ต..........|31/12/2013|04/01/2014|23|1|3000853|IV ให้สารน้ำทางหลอดเลือดดำ [เด็ก]
2.0039693|560003901|สมมุติ ทดสอบ|14/1 ม.1 ต..........|31/12/2013|04/01/2014|1|1|3000853|IV ให้สารน้ำทางหลอดเลือดดำ [ผู้ใหญ่]

ทำให้ไม่สามารถทราบได้จริงว่าตกลงได้ IV ผู้ใหญ่หรือเด็ก
วิธีที่จำทำได้คือต้องอ้าง ipt_oper_code เพราะแยกกันชัดเจน แต่ผมหาไม่เจอว่ามันเชื่อมกับตารางไหนที่เกี่ยวข้อง
รบกวนเพื่อนด้วยครับ

หัวข้อ: Re: รายงานการทำหัตการผู้ป่วยใน เฉพาะ icode ที่ต้องการ
เริ่มหัวข้อโดย: gu_prajag ที่ มีนาคม 20, 2014, 09:43:28 AM
 :)
หัวข้อ: Re: รายงานการทำหัตการผู้ป่วยใน เฉพาะ icode ที่ต้องการ
เริ่มหัวข้อโดย: chitvichai ที่ มีนาคม 20, 2014, 10:35:33 AM
ผมลองเขียน code ดังนี้
select i.hn,i.an,concat(p.fname,' ',p.lname) as fullname,concat(p.addrpart,' ',p.moopart,' ',t.full_name) as fulladdr,io.ipt_oper_code,o.qty,o.icode,io.name,i.regdate,o.rxdate
from ipt i
left outer join patient p on p.hn=i.hn
left outer join an_stat a on a.an=i.an
left outer join opitemrece o on o.an=i.an
left outer join ipt_nurse_oper ipo on ipo.an=i.an
left outer join ipt_oper_code io on io.icode=o.icode and ipo.ipt_oper_code=io.ipt_oper_code
left outer join thaiaddress t on t.addressid=a.aid
where io.ipt_oper_code in('1','23') and o.rxdate between "2013-10-01" and "2013-10-17" and o.an is not null
order by i.an
limit 100

จาก ipt_oper_code
ipt_oper_code | icode | name
1|3000853|IV ให้สารน้ำทางหลอดเลือดดำ [เด็ก]
23|3000853|IV ให้สารน้ำทางหลอดเลือดดำ [ผู้ใหญ่]

ทำให้ข้อมูลที่ออกมา
1.0039693|560003901|สมมุติ ทดสอบ|14/1 ม.1 ต..........|31/12/2013|04/01/2014|23|1|3000853|IV ให้สารน้ำทางหลอดเลือดดำ [เด็ก]
2.0039693|560003901|สมมุติ ทดสอบ|14/1 ม.1 ต..........|31/12/2013|04/01/2014|1|1|3000853|IV ให้สารน้ำทางหลอดเลือดดำ [ผู้ใหญ่]

ทำให้ไม่สามารถทราบได้จริงว่าตกลงได้ IV ผู้ใหญ่หรือเด็ก
วิธีที่จำทำได้คือต้องอ้าง ipt_oper_code เพราะแยกกันชัดเจน แต่ผมหาไม่เจอว่ามันเชื่อมกับตารางไหนที่เกี่ยวข้อง
รบกวนเพื่อนด้วยครับ



ลองเติมคำสั่งตัวสีแดงเพิ่มอึกทีครับว่าได้ไหม
หัวข้อ: Re: รายงานการทำหัตการผู้ป่วยใน เฉพาะ icode ที่ต้องการ
เริ่มหัวข้อโดย: gu_prajag ที่ มีนาคม 20, 2014, 11:08:59 AM
น่าจะโอเคแล้ว
ขอบคุณครับ...

แต่สงสัยว่า qty ในตาราง opitemrece
และ oper_qty ในตาราง ipt_nurse_oper
มันต่างกันยังไง เพราะว่า บางตัวเท่ากัน แต่บางตัวไม่เท่ากัน
หัวข้อ: Re: รายงานการทำหัตการผู้ป่วยใน เฉพาะ icode ที่ต้องการ
เริ่มหัวข้อโดย: gu_prajag ที่ มีนาคม 31, 2014, 09:55:10 AM
น่าจะโอเคแล้ว
ขอบคุณครับ...

แต่สงสัยว่า qty ในตาราง opitemrece
และ oper_qty ในตาราง ipt_nurse_oper
มันต่างกันยังไง เพราะว่า บางตัวเท่ากัน แต่บางตัวไม่เท่ากัน

 ::)