BMS-HOSxP Community
HOSxP => Report Exchange => ข้อความที่เริ่มโดย: Bluebird ที่ ตุลาคม 07, 2009, 09:17:48 AM
-
ปก OPDCard ไม่ปรากฏ ถนน ในช่องที่อยู่
-
... ข้อมูลอยู่ที่ field => road ในตาราง patient ครับ
ใช้การวาง variable ในฟอร์ม FORM-RB1T02
แล้ว copy คำสั่งข้างล่างไปวางใน variable ที่สร้างขึ้นมาก็ได้ครับ ... :D ....
Value := GetSQLStringData('select road from patient where hn = "'+DBPipeline['HN']+'" ');
-
... ข้อมูลอยู่ที่ field => road ในตาราง patient ครับ
ใช้การวาง variable ในฟอร์ม FORM-RB1T02
แล้ว copy คำสั่งข้างล่างไปวางใน variable ที่สร้างขึ้นมาก็ได้ครับ ... :D ....
Value := GetSQLStringData('select road from patient where hn = "'+DBPipeline['HN']+'" ');
ไม่ทัน อ.ขวด เลย เรื่องรายงานนี้
-
... ;D ;D ;D ....
... แต่เรื่องอื่นๆ( อิ อิ ;D ) ไม่ทัน อ.อ๊อด ซักเรื่องเลยผมเนี่ย เดี่ยวต้องไปขอให้ อ.นาจ(มีพาดพิง) ถ่ายทอดวิทยายุทธ์มาให้บ้าง ... ;D ;D ...
-
... ข้อมูลอยู่ที่ field => road ในตาราง patient ครับ
ใช้การวาง variable ในฟอร์ม FORM-RB1T02
แล้ว copy คำสั่งข้างล่างไปวางใน variable ที่สร้างขึ้นมาก็ได้ครับ ... :D ....
Value := GetSQLStringData('select road from patient where hn = "'+DBPipeline['HN']+'" ');
ไม่รู้จะไปวาง Variable ไปตรงไหน เพื่อให้อยู่ ระหว่าง บ้านเลขที่ กับตำบล เนื่องจากดูในคำสั่ง ในการดึงรายงานแล้ว เป็นการนำค่าจาก tempreport field => name3 ซึ่ง Field => name3 จะเก็บเฉพาะ บ้านเลขที่ ตำบล อำเภอ และ จังหวัด จะไม่มีถนน
select r1.name as HN,r1.name1 as Pt_Name,r1.name2 as Pt_Age,r1.name3 as FullAddress,r1.name4 as Sex,r1.date1 as BirthDay,
r2.name as Occupation,r2.name1 as MarryStatus,r2.name2 as Nationality,r2.name3 as Citizenship,r2.name4 as Religion,
r3.name as BloodGroup,r3.name1 as DrugAllergy,r3.name2 as HomeTel,r3.name3 as InformName,r3.name4 as InformAddr,
r4.name as InformRelation,r4.name1 as Father,r4.name2 as Mother,r4.name3 as SPSName,r4.name4 as CardName,
r5.name as CardCODE,r5.name1 as PtRight,r5.name2 as PtRightCode,r5.date1 as RightExpire,r5.date2 as RightBegin,
concat(hpmain.hosptype,hpmain.name) as hospmain,
concat(hpsub.hosptype,hpsub.name) as hospsub
from tempreport r1
left outer join tempreport r2 on r2.reportname=r1.reportname and r2.id=r1.id and r2.num=2
left outer join tempreport r3 on r3.reportname=r1.reportname and r3.id=r1.id and r3.num=3
left outer join tempreport r4 on r4.reportname=r1.reportname and r4.id=r1.id and r4.num=4
left outer join tempreport r5 on r5.reportname=r1.reportname and r5.id=r1.id and r5.num=5
left outer join vn_stat vs on vs.hn = r1.name
left outer join hospcode hpmain on hpmain.hospcode = vs.hospmain
left outer join hospcode hpsub on hpsub.hospcode = vs.hospsub
where
r1.id="ID-{7A982941-8457-46C2-B99F-839EFFDFA90D}" and
r2.id="ID-{7A982941-8457-46C2-B99F-839EFFDFA90D}" and
r3.id="ID-{7A982941-8457-46C2-B99F-839EFFDFA90D}" and
r4.id="ID-{7A982941-8457-46C2-B99F-839EFFDFA90D}" and
r5.id="ID-{7A982941-8457-46C2-B99F-839EFFDFA90D}" and
r1.reportname="RB1T02" and r1.num=1
limit 1
-
... ไม่ทราบว่าทำได้หรือยัง ...
... ถ้ายังไม่ได้ ดูตามรูปที่แนบนะครับ .... :D ....
-
ตามรูปที่แนบไป ทีแรกก็ทำคำสั่ง variable แล้ว มันจะแยก กันกับที่อยู่ (ซึ่งในคำสั่ง ข้างล่างนี้ คือ FullAddress
)
select r1.name as HN,r1.name1 as Pt_Name,r1.name2 as Pt_Age,r1.name3 as FullAddress,r1.name4 as Sex,r1.date1 as BirthDay,
r2.name as Occupation,r2.name1 as MarryStatus,r2.name2 as Nationality,r2.name3 as Citizenship,r2.name4 as Religion,
r3.name as BloodGroup,r3.name1 as DrugAllergy,r3.name2 as HomeTel,r3.name3 as InformName,r3.name4 as InformAddr,
r4.name as InformRelation,r4.name1 as Father,r4.name2 as Mother,r4.name3 as SPSName,r4.name4 as CardName,
r5.name as CardCODE,r5.name1 as PtRight,r5.name2 as PtRightCode,r5.date1 as RightExpire,r5.date2 as RightBegin,
concat(hpmain.hosptype,hpmain.name) as hospmain,
concat(hpsub.hosptype,hpsub.name) as hospsub
from tempreport r1
left outer join tempreport r2 on r2.reportname=r1.reportname and r2.id=r1.id and r2.num=2
left outer join tempreport r3 on r3.reportname=r1.reportname and r3.id=r1.id and r3.num=3
left outer join tempreport r4 on r4.reportname=r1.reportname and r4.id=r1.id and r4.num=4
left outer join tempreport r5 on r5.reportname=r1.reportname and r5.id=r1.id and r5.num=5
left outer join vn_stat vs on vs.hn = r1.name
left outer join hospcode hpmain on hpmain.hospcode = vs.hospmain
left outer join hospcode hpsub on hpsub.hospcode = vs.hospsub
where
r1.id="ID-{7A982941-8457-46C2-B99F-839EFFDFA90D}" and
r2.id="ID-{7A982941-8457-46C2-B99F-839EFFDFA90D}" and
r3.id="ID-{7A982941-8457-46C2-B99F-839EFFDFA90D}" and
r4.id="ID-{7A982941-8457-46C2-B99F-839EFFDFA90D}" and
r5.id="ID-{7A982941-8457-46C2-B99F-839EFFDFA90D}" and
r1.reportname="RB1T02" and r1.num=1
limit 1
-
ตามรูปที่แนบไป ทีแรกก็ทำคำสั่ง variable แล้ว มันจะแยก กันกับที่อยู่ (ซึ่งในคำสั่ง ข้างล่างนี้ คือ FullAddress
)
... อ๋อ เข้าใจแล้วครับ เดี๋ยวลองดูให้ครับ
เป็น บ้านเลขที่ ถนน หมู่ที่ ตำบล อำเภอ จังหวัด นะครับ ... :D ....
-
... ขออภัย นานไปหน่อย ;D ;D ...
... พอดีมีงาน แล้วก็ที่แรกว่าจะใช้การ concat กันแบบธรรมดาๆ แต่พบว่าถ้าเป็นรายไม่มีข้อมูลของถนนอยู่ด้วย ข้อมูลที่แสดงออกมา ช่องไฟมันไม่ค่อยสวยครับ เลยลองหาทาง concat แบบพิเศษ(ค่าแรงแพงขึ้น อิ อิ) แล้วลองทดสอบอีกนิดหน่อยครับ
แต่เนื่องจากช่องที่บันทึกข้อมูลถนน นั้น สามารถบันทึกได้ทั้ง ตรอก/ซอย/ถนน ผมเลยไม่ได้ใส่คำนำหน้าไว้เหมือนพวก ตำบล/อำเภอ/จังหวัด นะครับ ถ้าจะให้มีคำนำหน้าพวกตรอก/ซอย/ถนน เวลาบันทึกข้อมูลต้องใส่เข้าไปด้วยนะครับ ..
... ให้ copy คำสั่งข้างล่างไปวางใน variable ได้เลยครับ แล้วเอา variable ตัวนี้ไปแทนที่ DBText เดิมที่เป็นข้อมูลที่อยู่ได้เลยครับ
ก่อนจะ copy คำสั่งข้างล่าง ให้ดูภาษาตรง Language bar ให้เป็นภาษาไทยด้วยนะครับ ไม่งั้นเวลาเอาไปวาง ตรงที่เป็นภาษาไทยจะกลายเป็นเครื่องหมาย ? ก็จะต้องตามไปแก้ครับ ... :D ....
Value := GetSQLStringData('select addrpart from patient where hn = "'+DBPipeline['HN']+'" ')+
GetSQLStringData('select concat(" ",if((road = ""),null,road)) from patient '+
'where hn = "'+DBPipeline['HN']+'" ')+
GetSQLStringData('select concat(" ม.",if((moopart = ""),null,moopart)) from patient '+
'where hn = "'+DBPipeline['HN']+'" ')+
GetSQLStringData('select concat(" ต.",t3.name," อ.",t2.name," จ.",t1.name) from patient p '+
'left outer join thaiaddress t1 on t1.chwpart = p.chwpart and t1.codetype = "1" '+
'left outer join thaiaddress t2 on t2.chwpart = p.chwpart and t2.amppart = p.amppart '+
'and t2.codetype = "2" '+
'left outer join thaiaddress t3 on t3.chwpart = p.chwpart and t3.amppart = p.amppart '+
'and t3.tmbpart = p.tmbpart and t3.codetype = "3" '+
'where hn = "'+DBPipeline['HN']+'" ');
----------------------------------------------------------------------------------------------------------------
-
... ที่จริงการดึงข้อมูลส่วนของ ตำบล/อำเภอ/จังหวัด ใช้สั้นๆ แบบข้างล่าง(สีน้ำเงิน)ก็ได้ แต่การปรับระยะห่างของช่องไฟระหว่าง ตำบล/อำเภอ/จังหวัด ต้องไปแก้ในตาราง thaiaddress ... :D ....
Value := GetSQLStringData('select addrpart from patient where hn = "'+DBPipeline['HN']+'" ')+
GetSQLStringData('select concat(" ",if((road = ""),null,road)) as road from patient '+
'where hn = "'+DBPipeline['HN']+'" ')+
GetSQLStringData('select concat(" ม.",if((moopart = ""),null,moopart)) from patient '+
'where hn = "'+DBPipeline['HN']+'" ')+
GetSQLStringData('select concat(" ",t.full_name) from patient p '+
'left outer join thaiaddress t on t.addressid = concat(p.chwpart,p.amppart,p.tmbpart) '+
'where hn = "'+DBPipeline['HN']+'" ');
-
ขอบคุณมากครับ