ผู้เขียน หัวข้อ: บัญชี 1 ในรุ่น 52.2.14 ขอ script ดึงชื่อ พ่อ แม่ คู่สมรส พร้อม cid  (อ่าน 5738 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ anukul

  • Hero Member
  • *****
  • กระทู้: 1,363
  • Respect: +1
    • ดูรายละเอียด
ในรุ่นเก่า  จนท.สอ.ได้ลงข้อมูล บิดา มารดา คู่สมรส เรียบร้อย  (ในตาราง person จะเก็บข้อมูลในฟิลด์ father_person_id, mother_person_id, sps_person_id

แต่รุ่นใหม่ มีการจัดเก็บ father_name,father_cid ,mother_name, mother_cid ,sps_name, sps_cid

ขอ script ที่นำ ชื่อ นามสกุล cid ของบิดา มารดา คู่สมรส  มาใส่ให้ด้วยครับ
 :D
รพ.มะการักษ์ 260 เตียง
เริ่มระบบ 1 ธค 48 (ทีม MN)
Database structure :HOSxP 3.55.9.21b
Client : 3.55.6.8-3.55.9.21b
Server : Double QuadCore XEON 3.2 G. ECC 18 G. SAS 146 G x4(Raid 5) -- CentOS 5.3 (64 bit) , MySQL 5.1.30 percana
Client : Win2000 ~ 200 clients
Module :
OPD -Register,Screening,Doctor,Dispense,Billing,Dentist,PMMR
IPD - Admit center,Ward,Nutrition,Dispense,LR,OR
LAB , X-ray
การเชื่อมต่อ : LIS             --> RAX
                    X-ray PACS --> Infinitt (ThaiGL)

ออฟไลน์ anukul

  • Hero Member
  • *****
  • กระทู้: 1,363
  • Respect: +1
    • ดูรายละเอียด
ตาราง person

จนท.สอ ไม่อยากต้องมา ค้นหา และบันทึกใหม่ ซ้ำทีละคนครับ   :'(
รพ.มะการักษ์ 260 เตียง
เริ่มระบบ 1 ธค 48 (ทีม MN)
Database structure :HOSxP 3.55.9.21b
Client : 3.55.6.8-3.55.9.21b
Server : Double QuadCore XEON 3.2 G. ECC 18 G. SAS 146 G x4(Raid 5) -- CentOS 5.3 (64 bit) , MySQL 5.1.30 percana
Client : Win2000 ~ 200 clients
Module :
OPD -Register,Screening,Doctor,Dispense,Billing,Dentist,PMMR
IPD - Admit center,Ward,Nutrition,Dispense,LR,OR
LAB , X-ray
การเชื่อมต่อ : LIS             --> RAX
                    X-ray PACS --> Infinitt (ThaiGL)

ออฟไลน์ armds

  • Hero Member
  • *****
  • กระทู้: 1,084
  • armds
  • Respect: +10
    • ดูรายละเอียด
ตาราง person

จนท.สอ ไม่อยากต้องมา ค้นหา และบันทึกใหม่ ซ้ำทีละคนครับ   :'(
ลองเอาไป  แก้ไข ปรับปรุงดูนะครับ 
ตัวนี้เป็นตัวเป็นตัวตรวจสอบและปรับปรุง  18 แฟ้ม  ของตัว person  ที่ส่งออกมาเป็น  dbf   แล้วเอาไปแก้ไขให้ดึง  CID ของพ่อ  แม่  และ ภรรยา  มาให้แล้วค่อยส่งออกเป็น txt  อีกทีครับ 
ลองดูนะครับ

ว่าง ๆ จะแก้ไขให้นะครับ 

โค๊ด: Delphi
  1. procedure TForm1.Button8Click(Sender: TObject);
  2. var tc,hos:tclientdataset;
  3. address : string;
  4. shn:string;
  5. addrcode:string;
  6. reli : Integer;
  7. begin
  8.   dbf1.close;
  9.   dbf1.tablename:=ConnectStringEdit.text+'\person.dbf';     //+'\opd\opd.dbf'
  10.   dbf1.open;
  11.  
  12.   zquery.sql.text:='delete from person_for18pcu ';
  13.    zquery.execsql;
  14.  
  15.  
  16.   pg.position:=0;
  17.   pg.max:=dbf1.RecordCount;
  18.   fabort:=false;
  19.  
  20.   tc:=tclientdataset.create(nil);
  21.   hos:=tclientdataset.create(nil);
  22.  
  23.   while (not dbf1.eof) and (not fabort) do
  24.   begin
  25.  
  26.     pg.position := pg.position + 1;
  27.     //shn := TransformHN(dbf1.fieldbyname('HN').asstring);
  28.     shn := dbf1.fieldbyname('CID').asstring;
  29.     statuslabel.caption := shn ;
  30.     application.processmessages;
  31.     tc.data:=hosxp_getdataset('select p2.cid as p2cid,p3.cid as p3cid,p4.cid as p4cid,p.* from person   p  '+
  32.                            'left outer join person  p2 on p2.person_id=p.father_person_id  '+
  33.                            'left outer join person  p3 on p3.person_id=p.mother_person_id  '+
  34.                            'left outer join person  p4 on p4.person_id=p.couple_person_id  '+
  35.                            'where p.person_id='''+ dbf1.fieldbyname('PID').asstring+'''');
  36.     hos.data:=hosxp_getdataset( 'select * from person_for18pcu  where CID = ''' + shn + '''');
  37.  
  38.     //if hos.recordcount = 0 then
  39.     //  hos.insert else hos.edit;
  40.     hos.insert;
  41.  
  42.  
  43.     statuslabel.caption := shn;
  44.  
  45.     //if trim(vartostr(hos['hos_guid'])) = '' then
  46.     //  hos['hos_guid'] := get_new_guid;
  47.  
  48.     hos['PCUCODE'] := shn;
  49.     hos['CID'] := dbf1['CID'];
  50.     hos['PID'] := dbf1['PID'];
  51.     hos['HID'] := dbf1['HID'];
  52.     try
  53.     hos['PRENAME'] := dbf1['PRENAME'];
  54.     hos['NAME']    := dbf1['NAME'];
  55.     hos['LNAME']   := dbf1['LNAME'];
  56.     hos['HN']      := dbf1['HN'];
  57.     hos['SEX']     := dbf1['SEX'];
  58.     hos['BIRTH']   := dbf1['BIRTH'];
  59.     hos['HOUSE']   := dbf1['HOUSE'];
  60.     hos['VILLAGE'] := dbf1['VILLAGE'];
  61.     hos['TAMBON']  := dbf1['TAMBON'];
  62.     hos['AMPUR']   := dbf1['AMPUR'];
  63.     hos['CHANGWAT']:= dbf1['CHANGWAT'];
  64.     hos['MSTATUS'] := dbf1['MSTATUS'];
  65.     hos['OCCUPA']  := dbf1['OCCUPA'];
  66.     hos['RACE']    := '0'+dbf1['RACE'];
  67.     hos['NATION']  := '0'+dbf1['RACE'];// no NATION
  68.  
  69.     hos['RELIGION']:= IntTostr(tc['religion']);
  70.     hos['EDUCATE'] := dbf1['EDUCATE'];
  71.     hos['FSTATUS'] := dbf1['FSTATUS'];
  72.     hos['FATHER']  := tc['p2cid'];
  73.     hos['MOTHER']  := tc['p3cid'];
  74.     hos['COUPLE']  := tc['p4cid'];
  75.     hos['MOVEIN']  := dbf1['MOVEIN'];
  76.     hos['DISCHAR'] := dbf1['DISCHAR'];
  77.     hos['DDISCH']  := dbf1['DDISCH'];
  78.     hos['BGROUP']  := dbf1['BGROUP'];
  79.     hos['LABOR']   := dbf1['LABOR'];
  80.     hos['VHID']    := dbf1['VHID'];
  81.     hos['TYPEAREA']:= dbf1['TYPEAREA'];
  82.     hos['D_UPDATE']:= dbf1['D_UPDATE'];
  83.  
  84.     except
  85.     end;
  86.  
  87.     try
  88.       //tc.post;
  89.       hos.post;
  90.     except
  91.       on e: exception do
  92.       begin
  93.         memo1.lines.add(
  94.           formatdatetime('hh:nn:ss', now) + ' ' +
  95.           e.message);
  96.         hos.cancel;
  97.       end;
  98.     end;
  99.  
  100.  
  101.     if hos.changecount>0 then hosxp_updatedelta(hos.delta,
  102.               'select * from person_for18pcu  where CID = ''' + shn + '''');
  103.  
  104.     tc.close;
  105.     hos.close;
  106.  
  107.     application.processmessages;
  108.  
  109.     dbf1.next;
  110.   end;
  111.   showmessage('Import table home_for18pcu àÊÃç¨áÅéÇ !');
  112.   tc.free;
  113.   hos.free;
  114.  
  115.   dbf1.close;
  116.   // fcds.data := cds.data;
  117.   // CreateDatasetReport('HOSxP Report');
  118.   //fcds.data := cds.data;
  119.   //ExportDatasetToExcel('test.xls');
  120.    // showmessage('done.');
  121.  
  122. end;
  123.  

« แก้ไขครั้งสุดท้าย: มีนาคม 03, 2009, 11:22:28 AM โดย armds »
โรงพยาบาลสมเด็จพระยุพราชด่านซ้าย จ.เลย
ขนาด 60 เตียง นวก. คอมพิวเตอร์ ขึ้นระบบ ปี 2548
ขอบคุณ อ.ชัยพร อ.สุชัย อ.เดชา อ.doreamon อ.naj อ.ขวด และอ.ในเว็บ hosxp.net ทุกท่าน

doramon

  • บุคคลทั่วไป
ในรุ่นเก่า  จนท.สอ.ได้ลงข้อมูล บิดา มารดา คู่สมรส เรียบร้อย  (ในตาราง person จะเก็บข้อมูลในฟิลด์ father_person_id, mother_person_id, sps_person_id

แต่รุ่นใหม่ มีการจัดเก็บ father_name,father_cid ,mother_name, mother_cid ,sps_name, sps_cid

ขอ script ที่นำ ชื่อ นามสกุล cid ของบิดา มารดา คู่สมรส  มาใส่ให้ด้วยครับ
 :D


เย็นๆๆ


ออฟไลน์ anukul

  • Hero Member
  • *****
  • กระทู้: 1,363
  • Respect: +1
    • ดูรายละเอียด
ทำยังไงดี  ร้อนมาก  รอแล้วรออีกก็ยังไม่  เย็น  สักที

 :D
รพ.มะการักษ์ 260 เตียง
เริ่มระบบ 1 ธค 48 (ทีม MN)
Database structure :HOSxP 3.55.9.21b
Client : 3.55.6.8-3.55.9.21b
Server : Double QuadCore XEON 3.2 G. ECC 18 G. SAS 146 G x4(Raid 5) -- CentOS 5.3 (64 bit) , MySQL 5.1.30 percana
Client : Win2000 ~ 200 clients
Module :
OPD -Register,Screening,Doctor,Dispense,Billing,Dentist,PMMR
IPD - Admit center,Ward,Nutrition,Dispense,LR,OR
LAB , X-ray
การเชื่อมต่อ : LIS             --> RAX
                    X-ray PACS --> Infinitt (ThaiGL)

doramon

  • บุคคลทั่วไป
ทำยังไงดี  ร้อนมาก  รอแล้วรออีกก็ยังไม่  เย็น  สักที

 :D

ขอโทษ ครับ ผมยัง อยู่ รพ ประชุม อยู่เลยครับยังไม่ได้กลับบ้าน


สรุปงาน สอ อยู่ครับ


ออฟไลน์ jdadmin1

  • Hero Member
  • *****
  • กระทู้: 6,468
  • "เครื่องชำรุด...งดใช้งานชั่วคราว"
  • Respect: +33
    • ดูรายละเอียด
อ้างถึง
ทำยังไงดี  ร้อนมาก  รอแล้วรออีกก็ยังไม่  เย็น  สักที
;D ;D ;D ดอกนี้ร้อน ๆ หนาว ๆ ครับ ;D ;D ;D
โรงพยาบาลพระสมุทรเจดีย์สวาทยานนท์ จังหวัดสมุทรปราการ
Master   : HOSxP 3.67.6.5
Slave1   : HOSxP 3.67.6.5
Upgrade 8/06/2567
Facebook : Suntad Mamak

doramon

  • บุคคลทั่วไป
กลับมาบ้านแล้ว  สงสัยคงต้องพรุ่งนี้ครับ

0:27 น

 ;D

ออฟไลน์ anukul

  • Hero Member
  • *****
  • กระทู้: 1,363
  • Respect: +1
    • ดูรายละเอียด
ลองใช้คำสั่ง update ใน SQL query  ยังไงก็ไม่ได้สักที (ความรู้น้อย ความพยายามไม่มาก ;))   เขียนไปงงไปเอง   :-\

 update person p left outer join person p1 on p1.person_id=p.father_person_id set p.father_cid = (select p1.cid from person p1 left outer join person p on p.father_person_id=p1person_id) where p.father_person_id=p1.person_id

งง ครับ มั่วไปหมด   ;D
รพ.มะการักษ์ 260 เตียง
เริ่มระบบ 1 ธค 48 (ทีม MN)
Database structure :HOSxP 3.55.9.21b
Client : 3.55.6.8-3.55.9.21b
Server : Double QuadCore XEON 3.2 G. ECC 18 G. SAS 146 G x4(Raid 5) -- CentOS 5.3 (64 bit) , MySQL 5.1.30 percana
Client : Win2000 ~ 200 clients
Module :
OPD -Register,Screening,Doctor,Dispense,Billing,Dentist,PMMR
IPD - Admit center,Ward,Nutrition,Dispense,LR,OR
LAB , X-ray
การเชื่อมต่อ : LIS             --> RAX
                    X-ray PACS --> Infinitt (ThaiGL)

ออฟไลน์ manoi

  • Hero Member
  • *****
  • กระทู้: 8,669
  • Respect: +170
    • ดูรายละเอียด
    • HOSxP Community Center
น่าจะเป็นแบบนี้นะครับ


create table tmp_person like person;

insert ignore into tmp_person select * from person;

update person set father_cid = (select cid from tmp_person where tmp_person.person_id = person.father_person_id) where length(person.father_cid)<13 or person.father_cid is null ;

drop table tmp_person;
HOSxP Project Manager / Cheif Developer / BMS MD

ออฟไลน์ anukul

  • Hero Member
  • *****
  • กระทู้: 1,363
  • Respect: +1
    • ดูรายละเอียด
ได้แล้วครับ งงอยู่ตั้งนาน สุดท้ายต้องสร้าง tmp table ช่วย  :D

update person set father_name = (select concat(pname,fname," ",lname) from tmp_person where tmp_person.person_id = person.father_person_id)

อีกคำสั่ง สำหรับนำชื่อ นามสกุลของบิดามาเติมให้ครบ

แล้วต่อด้วย mother , sps

หมายเหตุ : บันทึกไว้กันลืมครับ
รพ.มะการักษ์ 260 เตียง
เริ่มระบบ 1 ธค 48 (ทีม MN)
Database structure :HOSxP 3.55.9.21b
Client : 3.55.6.8-3.55.9.21b
Server : Double QuadCore XEON 3.2 G. ECC 18 G. SAS 146 G x4(Raid 5) -- CentOS 5.3 (64 bit) , MySQL 5.1.30 percana
Client : Win2000 ~ 200 clients
Module :
OPD -Register,Screening,Doctor,Dispense,Billing,Dentist,PMMR
IPD - Admit center,Ward,Nutrition,Dispense,LR,OR
LAB , X-ray
การเชื่อมต่อ : LIS             --> RAX
                    X-ray PACS --> Infinitt (ThaiGL)