BMS-HOSxP Community

HOSxP => Report Exchange => ข้อความที่เริ่มโดย: panus_t ที่ มิถุนายน 30, 2011, 14:14:45 PM

หัวข้อ: ดึงข้อมูล เด็ก อายุ 0-6 ปีบริบูรณ์ได้อย่างไรครับ
เริ่มหัวข้อโดย: panus_t ที่ มิถุนายน 30, 2011, 14:14:45 PM
ดึงข้อมูล เด็ก อายุ 0-6 ปีบริบูรณ์ได้อย่างไรครับ
ผมใช้เงื่อนไขนี้ไม่ได้
vn.age_y between "0" and "6" and vn.age_m = "0" and vn.age_d = "0"
จากตาราง vn_stat   ;D
หัวข้อ: Re: ดึงข้อมูล เด็ก อายุ 0-6 ปีบริบูรณ์ได้อย่างไรครับ
เริ่มหัวข้อโดย: golf_win ที่ มิถุนายน 30, 2011, 14:18:14 PM
ไปดึงจากวันเกิด ที่ตาราง Patient น่าจะง่ายกว่านะครับ
หัวข้อ: Re: ดึงข้อมูล เด็ก อายุ 0-6 ปีบริบูรณ์ได้อย่างไรครับ
เริ่มหัวข้อโดย: เกื้อกูล ครับ.. ที่ มิถุนายน 30, 2011, 20:17:12 PM
งั้นก็ดึงภายใต้เงือนไข...ผู้เกิดระหว่างวันที่"xxxx-xx-xx" ถึง "xxxx-yy-yy"  ได้ไหมครับ..(คงไม่ได้ทำรายงาน หรือถ้าดึงผ่าน  custom serch  opd ได้ไหมครับ...
หัวข้อ: Re: ดึงข้อมูล เด็ก อายุ 0-6 ปีบริบูรณ์ได้อย่างไรครับ
เริ่มหัวข้อโดย: redfireball ที่ มิถุนายน 30, 2011, 23:45:58 PM
ดึงจาก patient ประมาณนี้ได้ไมครับ  :) :) :)
select hn,cid,pname,fname,lname,timestampdiff(year,birthday,now()) as age_y
,timestampdiff(month,birthday,now())-(timestampdiff(year,birthday,now())*12) as age_m
from patient
where timestampdiff(year,birthday,now()) between 0 and 6
order by age_y,age_m

ลองดูครับ

หัวข้อ: Re: ดึงข้อมูล เด็ก อายุ 0-6 ปีบริบูรณ์ได้อย่างไรครับ
เริ่มหัวข้อโดย: panus_t ที่ กรกฎาคม 01, 2011, 10:03:16 AM
ขอบคุณครับ สำหรับทุกคำตอบ
สงสัยผมถามสั้นไป คืออายุที่ต้องการเป็นอายุ ณ วันที่มารับบริการ

select ov.vn,ov.hn,concat(pt.pname," ",pt.fname,"  ",pt.lname) as pt_name,
ov.vstdate,ov.main_dep,vn.age_y,os.temperature,os.hpi
from ovst ov
left outer join vn_stat vn on vn.vn=ov.vn
left outer join patient pt on pt.hn=vn.hn
left outer join opdscreen os on os.vn=ov.vn
where ov.vstdate between "2011-05-01" and "2001-05-31" and ov.main_dep="010"
and os.temperature between "38.0" and "38.4" and vn.age_y between "0" and "6"
order by ov.hn asc

จาก Code ด้านบน ทำยังไงจะได้ผู้ป่วย อายุถึง 6 ปีบริบูรณ์ครับ  (6 ปี 1 วัน ขึ้นไปก็ไม่เอาครับ)
 ;D :D
หัวข้อ: Re: ดึงข้อมูล เด็ก อายุ 0-6 ปีบริบูรณ์ได้อย่างไรครับ
เริ่มหัวข้อโดย: มนตรี บอยรักยุ้ยคนเดียว ที่ กรกฎาคม 01, 2011, 10:20:58 AM
ขอบคุณครับ สำหรับทุกคำตอบ
สงสัยผมถามสั้นไป คืออายุที่ต้องการเป็นอายุ ณ วันที่มารับบริการ

select ov.vn,ov.hn,concat(pt.pname," ",pt.fname,"  ",pt.lname) as pt_name,
ov.vstdate,ov.main_dep,vn.age_y,os.temperature,os.hpi
from ovst ov
left outer join vn_stat vn on vn.vn=ov.vn
left outer join patient pt on pt.hn=vn.hn
left outer join opdscreen os on os.vn=ov.vn
where ov.vstdate between "2011-05-01" and "2001-05-31" and ov.main_dep="010"
and os.temperature between "38.0" and "38.4" and vn.age_y between "0" and "6"
order by ov.hn asc

จาก Code ด้านบน ทำยังไงจะได้ผู้ป่วย อายุถึง 6 ปีบริบูรณ์ครับ  (6 ปี 1 วัน ขึ้นไปก็ไม่เอาครับ)
 ;D :D

and vn.age_y between "0" and "5"

แค่นี้ลองดู
หัวข้อ: Re: ดึงข้อมูล เด็ก อายุ 0-6 ปีบริบูรณ์ได้อย่างไรครับ
เริ่มหัวข้อโดย: panus_t ที่ กรกฎาคม 01, 2011, 10:36:39 AM
ขอบคุณครับ สำหรับทุกคำตอบ
สงสัยผมถามสั้นไป คืออายุที่ต้องการเป็นอายุ ณ วันที่มารับบริการ

select ov.vn,ov.hn,concat(pt.pname," ",pt.fname,"  ",pt.lname) as pt_name,
ov.vstdate,ov.main_dep,vn.age_y,os.temperature,os.hpi
from ovst ov
left outer join vn_stat vn on vn.vn=ov.vn
left outer join patient pt on pt.hn=vn.hn
left outer join opdscreen os on os.vn=ov.vn
where ov.vstdate between "2011-05-01" and "2001-05-31" and ov.main_dep="010"
and os.temperature between "38.0" and "38.4" and vn.age_y between "0" and "6"
order by ov.hn asc

จาก Code ด้านบน ทำยังไงจะได้ผู้ป่วย อายุถึง 6 ปีบริบูรณ์ครับ  (6 ปี 1 วัน ขึ้นไปก็ไม่เอาครับ)
 ;D :D

and vn.age_y between "0" and "5"

แค่นี้ลองดู

แล้วจะได้ 6.0 ปีหรือเปล่าครับ ต้องการ 6.0 ปีด้วยครับ (6 ปีบริบุรณ์)
หัวข้อ: Re: ดึงข้อมูล เด็ก อายุ 0-6 ปีบริบูรณ์ได้อย่างไรครับ
เริ่มหัวข้อโดย: woravet ที่ กรกฎาคม 01, 2011, 10:44:15 AM
select v.vn,v.hn,concat(p.pname,p.fname,' ',p.lname) as ptname
,v.vstdate,v.age_y,v.age_m,v.age_d,s.temperature,s.hpi
from vn_stat v
left join patient p on p.hn=v.hn
left join opdscreen s on s.vn=v.vn
where v.vstdate between "2011-05-01" and "2011-05-31"
and (v.age_y between 0 and 5 or (v.age_y=6 and v.age_m=0 and v.age_d=0))
and s.temperature between 38.0 and 38.4
หัวข้อ: Re: ดึงข้อมูล เด็ก อายุ 0-6 ปีบริบูรณ์ได้อย่างไรครับ
เริ่มหัวข้อโดย: redfireball ที่ กรกฎาคม 01, 2011, 10:51:42 AM
select v.vn,v.hn,concat(p.pname,p.fname,' ',p.lname) as ptname
,v.vstdate,v.age_y,v.age_m,v.age_d,s.temperature,s.hpi
from vn_stat v
left join patient p on p.hn=v.hn
left join opdscreen s on s.vn=v.vn
where v.vstdate between "2011-05-01" and "2011-05-31"
and (v.age_y between 0 and 5 or (v.age_y=6 and v.age_m=0 and v.age_d=0))
and s.temperature between 38.0 and 38.4

ชัดเจนเลยครับ อ.woravet  :) :)