BMS-HOSxP Community
HOSxP => การเขียน SQL Script => ข้อความที่เริ่มโดย: aottoxxx ที่ พฤษภาคม 08, 2013, 14:41:09 PM
-
---เนื่องจาก สอ.ผม มีผู้ป่วยอยุ่ในทะเบียนโรคเรื้อรังจำนวนมาก (โอนข้อมูลมาจาก HCIS เดิม) ทำให้การกำหนดเป้าหมายผิดพลาด
---ผมต้องการตัดผู้ที่ไม่ได้มารับบริการ 1 ปี ออกจากทะเบียนผุ้ป่วยโรคเรื้อรัง และเปลี่ยนสถานะผู้ป่วยในทะเบียนคลินิกพิเศษ เป็น "ขาดการรักษาไม่มาติดต่อ"
---เบื้องต้นผมได้ลองทำคำสั่งเปลี่ยนสถานะผุ้ป่วยในคลินิคพิเศษ แต่มันเปลี่ยนผุ้ที่เพิ่งจะมาตรวจรักษาไปด้วย (ตรวจสอบจากวันรับบริการล่าสุด) ตามนี้ครับ
Update clinicmember c
left outer join ovst o
on c.hn = o.hn
set c.clinic_member_status_id = '6'
where c.clinic_member_status_id = '3' and o.vstdate < '2012-10-01'
ขอความอนุเคราะห์จากอาจารย์ทุกท่านช่วยตรวจสอบคำสั่งให้ผมด้วยครับ
ขอขอบคุณอาจารย์ทุกท่านล่วงหน้าครับ ^_^
-
ลองแบบนี้ครับ
update clinicmember c
set c.clinic_member_status_id = '6'
where c.clinic_member_status_id = '3'
and c.hn in (select hn from ovst o where max(o.vstdate) < '2012-10-01' group by hn)
-
ยังไม่ได้ครับ ผมเองได้ลองแก้ไขจากคำสั่งของพี่แล้วก็ยังไม่ผ่าน
ช่วยดูให้อีกทีน่ะครับ ขอบคุณพี่ pop มาก ๆ ครับ :)
-
ลองใช้
update clinicmember set clinic_member_status_id = '6'
where clinic_member_status_id = '3'
and hn not in (select distinct(hn) from ovst where vstdate > '2012-01-01' )
ครับ
-
ลองใช้
update clinicmember set clinic_member_status_id = '6'
where clinic_member_status_id = '3'
and hn not in (select distinct(hn) from ovst where vstdate > '2012-01-01' )
ครับ
ใช้ได้ครับ ขอบคุณ อ.เกื้อ อ.ป๊อป มาก ๆๆๆๆ ครับ :D :D :D