BMS-HOSxP Community

HOSxP => Report Exchange => ข้อความที่เริ่มโดย: apatnon86 ที่ ตุลาคม 26, 2010, 10:51:01 AM

หัวข้อ: ช่วยดูคำสั่งให้หน่อยครับ
เริ่มหัวข้อโดย: apatnon86 ที่ ตุลาคม 26, 2010, 10:51:01 AM
อยากได้ ชื่อ Cid อายุ เพศ ส่วนสูง น้ำหนัก รอบเอว ความดันโลหิต และ ผลน้ำตาลในเลือด (FBS)
ของผู้มารับบริการในันที่กำหนด และมีอายุ 35 ปีขึ้นไป แยกตามรายบุคคล  ตรง FBS จะเอาเฉพาะ
รายการนี้มาแสดงได้ยังไงครับ และตรงจุดอื่นผิดถูกยังไงช่วยชี้แนะด้วย   ขอบคุณครับ


select    p.hn,concat (p.pname,p.fname,"  ",p.lname) as ptname,p.cid,
            concat (year(curdate())-year(p.birthday)) as year,
            s.name,op.height,op.bw,op.waist,op.bps,op.bpd,op.vstdate
from opdscreen op
            left outer join patient p on p.hn=op.hn
            left outer join sex s on s.code=p.sex

where  concat (year(curdate())-year(p.birthday)) between 35 and 150  and
           op.vstdate between "2010-02-01" and "2010-10-26"

           group by p.hn
           order by op.vstdate ASC
หัวข้อ: Re: ช่วยดูคำสั่งให้หน่อยครับ
เริ่มหัวข้อโดย: nahos ที่ ตุลาคม 26, 2010, 10:56:47 AM
select    p.hn,concat (p.pname,p.fname,"  ",p.lname) as ptname,p.cid,
            concat (year(curdate())-year(p.birthday)) as year,
            s.name,op.height,op.bw,op.waist,op.bps,op.bpd,op.vstdate ,
            op.fbs
from opdscreen op
            left outer join patient p on p.hn=op.hn
            left outer join sex s on s.code=p.sex

where  concat (year(curdate())-year(p.birthday)) between 35 and 150  and
           op.vstdate between "2010-07-01" and "2010-07-26"

           group by p.hn
           order by op.vstdate ASC


แต่ถ้าจะเอาผล fbs จากห้อง lab ต้องไป join กับ lab_order อีกทีครับ
หรือเขียน varaible ดึงค่ามาใส่รายงานเพิ่ม
หัวข้อ: Re: ช่วยดูคำสั่งให้หน่อยครับ
เริ่มหัวข้อโดย: apatnon86 ที่ ตุลาคม 26, 2010, 11:21:38 AM
ใช่ครับ เอาผล fbs จากห้อง lab   แต่ผมไม่รู้ว่า มันจะเอา VN ไหนจาก opdscreen ไป join กับ lab
เพราะ group by p.hn ไปแล้ว  เพราะคนนึงมีได้หลาย VN    งงมั้ยครับ
หัวข้อ: Re: ช่วยดูคำสั่งให้หน่อยครับ
เริ่มหัวข้อโดย: nahos ที่ ตุลาคม 26, 2010, 12:04:48 PM

FBS เอาแค่ผลเดียวหรือครับ

หัวข้อ: Re: ช่วยดูคำสั่งให้หน่อยครับ
เริ่มหัวข้อโดย: apatnon86 ที่ ตุลาคม 26, 2010, 13:22:06 PM

FBS เอาแค่ผลเดียวหรือครับ



ใช่ครับ
หัวข้อ: Re: ช่วยดูคำสั่งให้หน่อยครับ
เริ่มหัวข้อโดย: nahos ที่ ตุลาคม 26, 2010, 14:15:14 PM
งั้นก็ใช้ HN ก็ได้ครับ 

join lab_head  on op.hn=lab_head.hn
join lab_order on lab_order.lab_order_number=lab_head.lab_order_number

แต่ยังงงเรื่องการนำไปใช้ ถ้าคนหนึ่งมาตรวจ หลายครั้งละครับ รายงานจะโอเคไหม

จุดประสงค์ของรายงานนี้คืออะไรครับ

หัวข้อ: Re: ช่วยดูคำสั่งให้หน่อยครับ
เริ่มหัวข้อโดย: apatnon86 ที่ ตุลาคม 26, 2010, 15:40:12 PM
      เรื่องของเรื่องคือ ทาง สสจ. ให้เลิกใช้งานโปรแกรม NCD ให้รอโปรแกรมเขาพัฒนาสมบูรณ์ก่อน
แล้วค่อยกลับมาใช้  ช่วนี้เขาเลยให้ดึงข้อมูลออกมาเป็นรายงาน โดยแยกเป็นรายบุคคล  ถ้าแยกเป็นรายครั้ง
มันก็ไม่เท่าไหร่หรอกครับ  ที่เค้าต้องการมี

HN  ชื่อ-สกุล  CID  อายุ>35  เพศ  ส่วนสูง  น้ำหนัก  รอบเอว  ความดันโลหิต  FBS
หัวข้อ: Re: ช่วยดูคำสั่งให้หน่อยครับ
เริ่มหัวข้อโดย: pop_hosxp ที่ ตุลาคม 26, 2010, 15:43:08 PM
ลองเอาเฉพาะ hn ไปใช้ แล้วหาค่า fbs ครั้งล่าสุด โดยทำเป็น variable

value:=getsqlstringdata('select fbs from opdscreen where hn="'+dbpipeline['hn']+'" order by vn desc limit 1 ');
หัวข้อ: Re: ช่วยดูคำสั่งให้หน่อยครับ
เริ่มหัวข้อโดย: nahos ที่ ตุลาคม 26, 2010, 16:01:44 PM
ลองเอาเฉพาะ hn ไปใช้ แล้วหาค่า fbs ครั้งล่าสุด โดยทำเป็น variable

value:=getsqlstringdata('select fbs from opdscreen where hn="'+dbpipeline['hn']+'" order by vn desc limit 1 ');

ขอบคุณครับ
อีกแบบ เอาผลจาก lab_order

 Value :=   getsqlstringdata('select  o.lab_order_result  as hn_c '+
  ' from  lab_order o     '+
  ' left join   lab_head h on o.lab_order_number=h.lab_order_number    '+
 ' where o.lab_items_name_ref like "%fbs%"   '+
 ' and h.hn=  "'+ DBPipeline['hn']+'"  order by h.vn desc limit 1  ')