upload ให้แล้ว file จะอยู่ด้านล่างของกระทู้นี้ครับ YindeeAndTan Tool For HOSxP 3.55.12.26
code ที่แก้ไขกรณีเป็น IPD Case
procedure TIPDAdmitEditForm.cxButton2Click(Sender: TObject);
var i,i1:integer;
begin
if cxTextEdit1.Text='' then
begin
ShowMessage('ไม่ได้กำหนด HN ที่ส่งตรวจผิด');
cxTextEdit1.SetFocus;
Exit;
end;
if cxTextEdit2.Text='' then
begin
ShowMessage('ไม่ได้กำหนด AN');
cxTextEdit2.SetFocus;
Exit;
end;
if Length(cxTextEdit2.Text)<>9 then
begin
ShowMessage('AN ต้องเท่ากับ 9 หลัก');
cxTextEdit2.SetFocus;
Exit;
end;
if cxTextEdit3.Text<>'' then
begin
TC.Close;
tc.data:=hosxp_getdataset('select * from hosxp_ddl_field where field_name ="an"');
ClientDataSet1.Close;
ClientDataSet1.data:=HOSxP_GetDataSet('select sys_value from '+
'sys_var where sys_name="hn_digit"');
i1:=StrToInt(ClientDataSet1.FieldByName('sys_value').AsString);
{PatientCDS.Close;
PatientCDS.Data:=HOSxP_GetDataSet('select concat(pname,fname," ",lname) as ptname '+
'from patient where hn="'+addzero(cxtextedit3.text,i1)+'" limit 1') ;}
ProgressBar1.position:=0;
ProgressBar1.max:=tc.recordcount;
i:=0;
while not tc.eof do
begin
i:=i+1;
label1.caption:='ตารางที่:'+inttostr(i)+': ชื่อ: '+tc.fields[0].asstring;
if tc.fields[1].asstring ='an' then
begin
Memo1.lines.add('Table...'+tc.fields[0].asstring);
try
hosxp_getdataset('update '+tc.fields[0].asstring+' set hn="'+
addzero(cxtextedit3.text,i1)+'" where an="'+
cxTextEdit2.text+'" and hn="'+AddZero(cxtextedit1.text,i1)+'" ');
HOSxP_GetDataSet('update lab_head set '+
'hn="'+addzero(cxtextedit3.text,i1)+'" '+
'where vn="'+ cxTextEdit2.text+'" ') ;
HOSxP_GetDataSet('update patient set '+
'admit="Y" '+
'where hn="'+ addzero(cxtextedit3.text,i1)+'" limit 1') ;
HOSxP_GetDataSet('update patient set '+
'admit="N" '+
'where hn="'+ addzero(cxtextedit1.text,i1)+'" limit 1') ;
except end;
end;
memo1.lines.add('Change...'+'update '+tc.fields[0].asstring+' set hn="'
+addzero(cxtextedit3.text,i1)+'" where an="'+cxtextedit2.text+'" and hn="'+
AddZero(cxtextedit1.text,i1)+'" ---> OK');
ProgressBar1.position:=ProgressBar1.position+1;
application.processmessages;
tc.next;
end;
Memo1.Lines.Add('--------------------------------------------------------------------------------------------------------------------');
Memo1.Lines.Add('Data Update Successfull...');
tc.close;
ClientDataSet1.Close;
PatientCDS.Close;
showmessage('Done.');
end else
begin
ShowMessage('ไม่ได้กำนด HN ที่ถูกต้อง') ;
cxTextEdit3.SetFocus;
Exit;
end;
end;
//////////////////////////////////////////////////////////////////
code กรณีเป็น OPD CASE
procedure TOPDvisitEditForm.cxButton2Click(Sender: TObject);
var i,i1:integer;
begin
if cxTextEdit1.Text='' then
begin
ShowMessage('ไม่ได้กำหนด HN ที่ส่งตรวจผิด');
cxTextEdit1.SetFocus;
Exit;
end;
if cxTextEdit2.Text='' then
begin
ShowMessage('ไม่ได้กำหนด VN');
cxTextEdit2.SetFocus;
Exit;
end;
if Length(cxTextEdit2.Text)<>12 then
begin
ShowMessage('VN ต้องเท่ากับ 12 หลัก');
cxTextEdit2.SetFocus;
Exit;
end;
if cxTextEdit3.Text<>'' then
begin
TC.Close;
tc.data:=hosxp_getdataset('select * from hosxp_ddl_field where field_name ="vn"');
ClientDataSet1.Close;
ClientDataSet1.data:=HOSxP_GetDataSet('select sys_value from '+
'sys_var where sys_name="hn_digit"');
i1:=StrToInt(ClientDataSet1.FieldByName('sys_value').AsString);
PatientCDS.Close;
PatientCDS.Data:=HOSxP_GetDataSet('select concat(pname,fname," ",lname) as ptname '+
'from patient where hn="'+addzero(cxtextedit3.text,i1)+'" limit 1') ;
ProgressBar1.position:=0;
ProgressBar1.max:=tc.recordcount;
i:=0;
while not tc.eof do
begin
i:=i+1;
label1.caption:='ตารางที่:'+inttostr(i)+' ชื่อ '+tc.fields[0].asstring+' Done...';
if tc.fields[1].asstring ='vn' then
begin
Memo1.lines.add('Table...'+tc.fields[0].asstring);
try
hosxp_getdataset('update '+tc.fields[0].asstring+' set hn="'+
addzero(cxtextedit3.text,i1)+'" where vn="'+
cxTextEdit2.text+'" and hn="'+AddZero(cxtextedit1.text,i1)+'" ');
HOSxP_GetDataSet('update visit_name set '+
'patient_name="'+patientcds.FieldByName('ptname').AsString+'" '+
'where vn="'+ cxTextEdit2.text+'" ') ;
except end;
end;
memo1.lines.add('Change...'+'update '+tc.fields[0].asstring+' set hn="'
+addzero(cxtextedit3.text,i1)+'" where vn="'+cxtextedit2.text+'" and hn="'+
AddZero(cxtextedit1.text,i1)+'" ---> OK');
ProgressBar1.position:=ProgressBar1.position+1;
application.processmessages;
tc.next;
end;
Memo1.Lines.Add('--------------------------------------------------------------------------------------------------------------------');
Memo1.Lines.Add('Data Update Successfull...');
tc.close;
ClientDataSet1.Close;
PatientCDS.Close;
showmessage('Done.');
end else
begin
ShowMessage('ไม่ได้กำหนด HN ที่ถูกต้อง') ;
cxTextEdit3.SetFocus;
Exit;
end;
end;