BMS-HOSxP Community
HOSxP => Report Exchange => ข้อความที่เริ่มโดย: Sukjai ที่ พฤษภาคม 01, 2014, 15:13:46 PM
-
เครดิต ต้องขอขอบคุณ อ.วรเวทย์ เอี่ยมพร รพ.บึงสามัคคี ที่ได้จัดทำรายงานนี้ ครับ
-
แยกคลิกนิกได้ด้วยนะครัช อิอิ ของเขาดีจริง อิอิ
-
แบบของผม ครับ ได้โค้ดมาจาก อ.วรเวทย์ เอี่ยมพร เหมือนกันครับ เอามาปรับนิดหน่อยครับ
credit : อ.วรเวทย์ เอี่ยมพร , อ.ภศล สุริยะ
คำสั่งสร้างตาราง colorchart
CREATE TABLE `colorchart` (
`id` int(5) NOT NULL,
`has` varchar(1) DEFAULT NULL,
`chronic` varchar(1) DEFAULT NULL,
`sex` varchar(1) DEFAULT NULL,
`age` int(3) DEFAULT NULL,
`smoke` varchar(1) DEFAULT NULL,
`bp` int(3) DEFAULT NULL,
`cholesterol` int(3) DEFAULT NULL,
`color` int(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=tis620;
-
ต้องปรับเรื่องการสูบบุหรี่นิดนึงครับสำหรับคนที่ smoking_type_id=1 คือ ไม่เคยสูบ ครับ และถ้าใช้ function thaiage ไม่ได้ก็ใช้ timestampdiff แทนก็ได้นะครับ
-
ของผมลองทำแล้วก็ยัง Error อยู่ครับ
-
ของผมลองทำแล้วก็ยัง Error อยู่ครับ
-------------------------------------------------------------------
ส่งภาพที่ Error ขึ้นมาดูด้วยครับ
-
ภาพครับ
-
ภาพครับ
--------------------------------
ถ้าไม่แก้ไขรายงาน ให้นำคำสั่งนี้ไป Run ใน SQL Query หรือ Navicat เพื่อสร้าง function thaiage ดูครับ
CREATE FUNCTION `thaiage`(param1 date,param2 date) RETURNS char(15) CHARSET tis620
begin
declare cAge char(15);
declare nyear int;
declare nmonth int;
declare nday int;
set param2=date(param2);
set param2=if(param2='0000-00-00',now(),param2);
select timestampdiff(year,param1,param2) into nyear;
select timestampdiff(month,param1,param2)-(timestampdiff(year,param1,param2)*12) into nmonth;
select timestampdiff(day,date_add(param1,interval (timestampdiff(month,param1,param2)) month),param2) into nday;
select concat(lpad(nyear,3,'0'),lpad(nmonth,2,'0'),lpad(nday,2,'0')) into cage;
set cage=if(nyear>0,concat(lpad(nyear,2,'0'),' years'),'');
set cage=if(cage='' and nmonth>0,concat(lpad(nmonth,2,'0'),' months'),cage);
set cage=if(cage='',concat(lpad(nday,2,'0'),' days'),cage);
set cage=replace(cage,'years','ปี');
set cage=replace(cage,'months','เดือน');
set cage=replace(cage,'days','วัน');
return cage;
end
-
เหมือนมีชื่อเราถูกพาดพิงในกระทู้นี้
-
เครดิต ต้องขอขอบคุณ อ.วรเวทย์ เอี่ยมพร รพ.บึงสามัคคี ที่ได้จัดทำรายงานนี้ ครับ
-----------------------------------------
อ.วรเวทย์ รพ.บึงสามัคคี
ฝากแก้ไขตาราง colorchart เนื่องจาก ตาราง เก่า มีการคำนวณเกี่ยวกับสี่ที่ผิดพลาด
ให้ ลบข้อมูลในตาราง colorchart เดิมทิ้ง
แล้ว Download และนำเข้า ไฟล์ colorchart.cds ใหม่ครับ
-
ในตัวรายงาน ใช้ v.age_y แทนการใช้ function thaiage ได้ไหมครับ
ให้ผลต่างกันหรือไม่
-
ได้คับ