CVD Risk Report



***แนะนำให้ไปใช้โปรแกรม THAI CVRisk จะสะดวกกว่าและสามารถออกรายงานสรุปผลได้ด้วย นะจ๊ะ***

Link คลิกดาวน์โหลดThaiCvRiskและวิธีติดตั้ง


.............................................................

ส่วนข้อมูลเดิมที่ยังโพสต์ไว้...เพื่อ
1.ทดสอบการออกรายงานแบบใช้ scpt รัน 
2.เพื่อปรับแก้คนที่ลืมคีย์สูบบุหรี่

ทดลองออกรายงาน CVD Risk จาก JHCIS

(ด้วยการ รัน CVD Risk SCRIPT )

 ข้อห้าม (ถือปฏิบัติ โดยเคร่งครัด)
1.การดำเนินการ ต่อไปนี้เป็นการทดลองออกรายงาน CVD Risk เพื่อ ให้ได้ข้อมูลที่สมบูรณ์และครบทุกเรคคอร์ด ..(ไม่ได้นำไปใช้งานจริง แต่อย่างใด)
2.ให้Back up ในเครื่องserver และ Copy หรือ Restore มาทดลองในเครื่อง note book (รอง) เท่านั้น ห้าม รันข้อมูลใดๆ ในเครื่องServer (หลัก) ของหน่วยงานโดยเด็ดขาด  >>>ฝ่าฝืนถือเป็นความรับผิดชอบของตัวท่านเอง
3.ขณะดำเนินการ กรูณา ตัดระบบ อินเตอร์เน็ต ออกจากเครื่อง note book โดยเด็ดขาด
4.Script ทุก ตัวทุกชุด ถือเป็นส่วนประกอบเพื่อการทดลองเท่านั้น ไม่ใช่เพื่อการ ดัดแปลง ตกแต่ง หรือทำให้ข้อมูลเสียหายแต่อย่างใด

แจ้งเพื่อทราบ ในการออกรายงาน CVD Risk นั้น
ประกอบด้วย
1.CVD Risk ในกลุ่มผู้ป่วยโรคเรื้อรัง แยกเป็น
   1.1 แบบไม่มีผลตรวจ Cholesterol
   1.2 แบบมีผลตรวจ Cholesterol
2.CVD Risk ในกลุ่มคัดกรอง NCDScreen 35 ปี ขึ้นไป
ตามคู่มือ Color Chart  ดังนี้
................................................................................

...............................................................................

เริ่มทดลอง ออกรายงาน

  **********  CVD Risk ในกลุ่มคัดกรอง NCDScreen ************

ขั้นเตรียมการ

1.ส่วนประกอบที่สำคัญ เพื่อการออกรายงาน

  1. บุคคลอายุ 40 ปี ขึ้นไป แยกเพศชาย - หญิง (ค่าความเสี่ยงต่างกัน จ้า)
  2. ข้อมูลการสูบบุหรี่ รวมถึงเลิกสูบมาน้อยกว่า 1 ปี (ถือว่ายังสูบอยู่นะค่ะ)
  3. ค่าความดันโลหิต ค่าบน (systolicใน jhcis เอาค่าจากการวัดความดันฯ ครั้งแรก)

 2.ปัญหา คือ  JHCIS version ก่อนวันที่ 3 ธันวาคม 2558 นี้ลงไป ไม่มีข้อมูลการสูบบุหรี่ (ไม่มีที่ให้เติมผลสำรวจการสูบบุหรี่ และถ้าจะยึดข้อมูลจากแฟ้ม Behavior (แฟ้มพฤติกรรมสุขภาพ) ก็ยังถือว่าเป็นข้อมูลเก่าเพราะรายชื่อบางคน บันทึกไว้ตั้งแต่ปีเริ่มต้นใช้ Jhcis จนถึงปัจจุบัน ไม่เคยมีการอัพเดด ข้อมูลส่วนนี้เลย


3.การแก้ปัญหา เบื้องต้น ให้สามารถออกรายงานได้ครบทุกเรคคอร์ด ให้ดำเนินการ ดังนี้นะค่ะ
3.1 ให้ใช้ Scpt ชุดที่ 1 รันดู ข้อมูลตั้งแต่ 01-10-2558 จนถึงปัจจุบันว่า มีคนที่ คัดกรอง NCDScreen  ที่ยังไม่ได้เติมข้อมูลการสูบบุหรี่ อยู่กี่คน  ตามนี้จ้า
.....................................................................................................................
SELECT *
FROM ncd_person_ncd_screen
WHERE (ncd_person_ncd_screen.smoke IS NULL
OR ncd_person_ncd_screen.alcohol IS null)
AND ncd_person_ncd_screen.screen_date BETWEEN '2015-10-01'AND'2016-09-30';

.....................................................................................................................
***หากรันดูแล้วมีรายชื่อโผล่มา  เท่าไหร่ บันทึกไว้นะ ..
3.2 รันอัพเดด ข้อมูล ส่วนที่ว่าง..ด้วย Scpt ชุดที่ 2 ตามนี้
...................................................................................................................
 set @start = '2014-10-01'; #เวันเริ่มต้น
set @end = '2015-09-30'; # วันสิ้นสุด

DROP TABLE IF EXISTS ncd_smok59;
CREATE TABLE ncd_smok59 AS
   (SELECT pcucode,pid,ncd_person_ncd_screen.screen_date,ncd_person_ncd_screen.alcohol AS 'alcohol2'
,ncd_person_ncd_screen.smoke AS 'smoke2',ncd_person_ncd_screen.bsl
    FROM ncd_person_ncd_screen
    WHERE ncd_person_ncd_screen.screen_date BETWEEN @start AND @end
GROUP BY ncd_person_ncd_screen.pid);
UPDATE ncd_person_ncd_screen
INNER JOIN ncd_smok59 ON ncd_person_ncd_screen.pid = ncd_smok59.pid
SET ncd_person_ncd_screen.smoke = ncd_smok59.smoke2
WHERE (ncd_person_ncd_screen.smoke IS NULL OR ncd_person_ncd_screen.smoke = 0);

UPDATE ncd_person_ncd_screen
INNER JOIN ncd_smok59 ON ncd_person_ncd_screen.pid = ncd_smok59.pid
SET ncd_person_ncd_screen.alcohol = ncd_smok59.alcohol2
WHERE (ncd_person_ncd_screen.alcohol IS NULL OR ncd_person_ncd_screen.alcohol = 0);

# ลบตามราง ncd_smok59 (อีกรอบเพื่อความขัวร์
DROP TABLE ncd_smok59;

..................................................................................................................
**** หมายเหตุ Scpt ชุดที่ 2 นี้ จะเป็นการรันเอาข้อมูล การสูบบุหรี่ของปีที่มีล่าสุด มาอัพเดดในปีปัจจุบัน ทั้งนี้หาก แห่งใดมีข้อมูลจากการสำรวจจริงอยู่แล้ว.....ก็ขอแนะนำให้กลับไปกรอกข้อมูลให้เป็นปัจจุบัน(ตามจริง) จะดีกว่านะ่ค่ะ  ซึ่งในส่วนบุหรี่และอัลกอฮอล์ ของJhcis V ล่าสุด (เขาเปิดให้เติมได้แล้วจ้า)
ดังตัวอย่าง
 *สามารถเติมผลการสูบบุหรี่ ได้ 5 อย่าง คือ 1 =ไม่สูบ, 2 =สูขนานๆครั้ง, 3 =สูบเป็นครั้งคราว, 4 =สูบเป็นประจำ, 9 =ไม่ทราบ
3.3 รันดูข้อมูลส่วนที่เหลืออีกรอบ ด้วย (Scpt ชุดที่ 1) ว่าเหลือเท่าไหร่ จากนั้น สมมติว่าส่วนที่เหลือให้ถือว่าเป็นคนที่ไม่สูบบุหรี่ โดยใช้ Scpt ชุดที่ 3 รันอัพเดด อีกรอบ ตามนี้จ้า
scpt ชุดที่ 3
.......................................................................................................................
UPDATE ncd_person_ncd_screen
set ncd_person_ncd_screen.smoke = '1'
WHERE ncd_person_ncd_screen.screen_date BETWEEN '2015-10-01' AND '2016-09-30'
AND (ncd_person_ncd_screen.smoke is NULL or ncd_person_ncd_screen.smoke = 0);
.......................................................................................................................
 ขั้นการออกรายงาน
ในการออกรายงาน CVD Risk NCDScreen นั้น จะได้รายงาน ประกอบด้วย
1.เสี่ยงต่ำ, 2.เสี่ยงปานกลาง, 3.เสี่ยงสูง, 4.เสี่ยงสูงมาก, 5.เสี่ยงสูงอันตราย
และ จะออกรายงานได้เฉพาะกลุ่มที่อายุ 40 ปี ขึ้นไป (อายุต่ำกว่านั้น ไม่ต้องประเมิน)
โดยใช้ Scpt ชุดที 4  ตามนี้
.......................................................................................................................
select
person.pid
,ctitle.titlename AS 'คำนำหน้า'
,person.fname AS 'ชื่อ'
,person.lname AS 'ชื่อ-สกุล'
,GetAgeYearNum(person.birth,CURRENT_DATE)AS 'อายุ'
,house.hno AS 'เลขที่'
,village.villno AS 'หมู่ที่'
,case when ncd_person_ncd_screen.smoke = 1 then 'ไม่สูบ' when ncd_person_ncd_screen.smoke in ('2','3','4','5')then 'สูบ' ELSE '' END AS 'บุหรี่'
,ncd_person_ncd_screen.hbp_s1
,MAX(case when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 40 and 49 AND ncd_person_ncd_screen.hbp_s1 <=169 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 40 and 49 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 40 and 49 AND ncd_person_ncd_screen.hbp_s1 <= 159 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับต่ำ'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 40 and 49 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับปานกลาง'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 40 and 49 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูงอันตราย'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 40 and 49 AND ncd_person_ncd_screen.hbp_s1 <= 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 40 and 49 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงมาก'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 40 and 49 AND ncd_person_ncd_screen.hbp_s1 <= 159 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับต่ำ'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 40 and 49 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับปานกลาง'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 40 and 49 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูง'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 <=159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 <=159 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับต่ำ'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูง'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูงอันตราย'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 <=159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 <=159 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับต่ำ'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูง'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 50 and 59 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูงอันตราย'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 <=139 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 between 140 and 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 <=139 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับต่ำ'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 between 140 and 159 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับปานกลาง'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูงมาก'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูงอันตราย'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 <=139 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 between 140 and 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 <=139 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับต่ำ'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 between 140 and 159 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับปานกลาง'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูงมาก'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) between 60 and 69 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูงอันตราย'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 <=139 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 between 140 and 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 <=139 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับต่ำ'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 between 140 and 159 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูง'
when person.sex = '1' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 >= 160 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูงอันตราย'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 <=139 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 between 140 and 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 <=139 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับต่ำ'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 between 140 and 159 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูง'
when person.sex = '2' AND getAgeYearNum(person.birth,CURDATE()) >= 70 AND ncd_person_ncd_screen.hbp_s1 >= 160 and ncd_person_ncd_screen.smoke in ('2','3','4','5') then 'ระดับสูงอันตราย'
ELSE '' END) AS 'CVD Risk'
,ncd_person_ncd_screen.screen_date
FROM
ncd_person_ncd_screen
INNER JOIN person ON ncd_person_ncd_screen.pid = person.pid
INNER JOIN house ON person.hcode = house.hcode AND person.pcucodeperson = house.pcucode
LEFT JOIN personbehavior ON ncd_person_ncd_screen.pid = personbehavior.pid
INNER JOIN village ON village.villcode = house.villcode
INNER JOIN ctitle ON person.prename = ctitle.titlecode
WHERE ncd_person_ncd_screen.screen_date between '2015-10-01' and '2016-09-30'
AND SUBSTRING(house.villcode,7,2)<> '00'
GROUP BY person.pid
ORDER BY person.birth desc;
  
.......................................................................................................................
เมื่อ รันแล้ว จะได้ รายงาน ประมาณ นี้นะค่ะ
(ตัวอย่างรายงาน)

........................................................................................................................
ในส่วนการหารายงาน CVD RISK ใน Chronic (แบบไม่มีผลตรวจ Cholesterol)
ก็นำ SCPTชุดที่ 5  รันดูได้เลยจ้า
.........................................................................................................................
select
 concat(ctitle.titlename,person.fname,' ',person.lname)as 'ชื่อ-สกุล',
GetAgeYearNum(person.birth,CURRENT_DATE)as 'อายุ',
concat(person.hnomoi,' ','หมู่',person.mumoi) as 'ที่อยู่',
case when (pcht.chroniccode is not null and pcdm.chroniccode is null )then '1' else '' end as ht,
 case when (pcdm.chroniccode is not null and pcht.chroniccode is null ) then '1' else '' end as dm,
 case when pcdm.chroniccode is not null and pcht.chroniccode is not null then '1' else '' end as htdm,
 case when ncd_person_ncd_screen.smoke = 1 then 'ไม่สูบ' when ncd_person_ncd_screen.smoke in ('2','3','4') then 'สูบ' else '' end as 'บุหรี่',
left(pressure,locate("/",pressure)-1) as SBP,
 case when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <=169 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <= 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับปานกลาง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <= 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงมาก'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <= 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับปานกลาง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <=159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <=159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <=159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <=159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <=139 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 140 and 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <=139 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 140 and 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับปานกลาง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงมาก'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <=139 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 140 and 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <=139 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 140 and 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับปานกลาง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงมาก'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <=139 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 140 and 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <=139 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 140 and 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 160 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <=139 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 140 and 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูงอันตราย'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <=139 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 140 and 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูง'
when pcdm.chroniccode is not null and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 160 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <=179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <= 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงมาก'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <=179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <= 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 40 and 49 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงมาก'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <=179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <= 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <=179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <= 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 50 and 59 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <= 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <= 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <= 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <= 139 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 140 and 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') between 60 and 69 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <= 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) <= 139 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 140 and 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '1'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <= 159 and ncd_person_ncd_screen.smoke = 1 then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke = 1 then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke = 1 then 'ระดับสูง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) <= 139 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับต่ำ'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 140 and 159 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับปานกลาง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) between 160 and 179 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูง'
when (pcht.chroniccode is not null and pcdm.chroniccode is null ) and getAgeYearNum(birth,'20141001') >= 70 and person.sex = '2'and left(pressure,locate("/",pressure)-1) >= 180 and ncd_person_ncd_screen.smoke in ('2','3','4') then 'ระดับสูงอันตราย'
else '' end as 'CVD Risk'
 from person
 inner join ctitle on person.prename = ctitle.titlecode
 inner join house on person.hcode = house.hcode and person.pcucodeperson = house.pcucode
 left join visit ON person.pcucodeperson = visit.pcucodeperson and person.pid = visit.pid
 left join visitdiag on visit.visitno = visitdiag.visitno
 inner join village on house.villcode = village.villcode and house.pcucode = village.pcucode
 left join personchronic pcht on person.pid = pcht.pid and person.pcucodeperson = pcht.pcucodeperson and trim(pcht.chroniccode) = 'I10'
 left join personchronic pcdm on person.pid = pcdm.pid and person.pcucodeperson = pcdm.pcucodeperson and trim(pcdm.chroniccode) between 'E10' and 'E149'
 left join personchronic pc on person.pid = pc.pid and person.pcucodeperson = pc.pcucodeperson
 left join ncd_person_ncd_screen on person.pid = ncd_person_ncd_screen.pid
 where visit.visitdate between '2015-10-01' and '2016-09-30'
 and SUBSTRING(house.villcode,7,2)<> '00' and (visitdiag.diagcode between 'E10' and 'E159' or (visitdiag.diagcode ='I10'))
 and pc.cup = pc.pcucodeperson
 group by pc.pid
 order by village.villno;
..........................................................................................................................
***หมายเหตุ หากfields ใดว่าง แสดงว่า ขาดข้อมูลบุหรี่ หรือ อายุไม่อยู่ในช่วงจ้า****


GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG

กรณีปัญหา  
  • สั่งรันแล้ว จะช้านิสนึ่ง ..เนื่องจากข้อมูลเชื่อมโยงหลายแฟ้ม นะค่ะ (รอค่ะ) 
  • scpt ยาวไป ก็โหลด จาก link ได้นะจ๊ะ ตามนี้จ้า  SCPT st1-St5

""""""" จบ การทดลอง ออกรายงาน CVD RISK ทั้งใน NCD Screen และ Person Chronic""""








    1 ความคิดเห็น:

    kitaphon กล่าวว่า...

    หากSCpt ใดทีรันไม่ได้ รบกวน แจ้งให้ทราบด้วยนะค่ะ จะโพสต์ ให้ใหม่จ้า

    https://www.blogs

     kllgnsgkj[jtlm'oahd bfldkb'pdojgaojp mfigjdo;sjgaij misjgo;sjagijwo;