日期:2014-05-17 浏览次数:21036 次
CREATE OR REPLACE Procedure p_b_insertmz(scardno Varchar2,scheckno Varchar2,scheckname varchar2,shiscardno Varchar2,spatientname Varchar2,spatientsex Varchar2,spatientage Varchar2,
spatientid varchar2, sVoucherNo Varchar2,sfreetype Varchar2,sregistope Varchar2,drgistdate Date, ipatientautoid Out Number )
--将门诊病人加入排队
Is
maxorderi Number;
maxno Number;
icout Number;
chkflag varchar2(2);
Begin
Select nvl(max(patientorder)+5,5 ) Into maxorderi From t_b_patient Where to_char(patienttime,'yyyymmdd')=to_char(Sysdate,'yyyymmdd');
Select nvl(Max(patientno)+1,1) Into maxno From t_b_patient Where to_char(patienttime,'yyyymmdd')=to_char(Sysdate,'yyyymmdd') And checkno=scheckno ;
Select Count(*) Into icout from t_b_checkkind Where checkno=scheckno;
chkflag:='A';
If icout>0 Then
Select nvl(checkflg,'A') Into chkflag from t_b_checkkind Where checkno=scheckno;
End If;
Select s_b_patient.nextval Into ipatientautoid From dual;
Insert Into t_b_patient(autoid,cardno,hiscardno,patientid,patientno,patientname,patientsex,patientage,registtime,feetype,voucherno,rigistdate,
registope, ispre,isinvalid,checkname,patientstatus,patienttime,patientprior,patientorder,checkno,checkflag)
Values(ipatientautoid,scardno,shiscardno,spatientid,maxno,spatientname,spatientsex,spatientage,sysdate,sfreetype,svoucherno,drgistdate,
sregistope,0,0,scheckname,1,sysdate,'D-普通',maxorderi,scheckno,chkflag);
Commit;
End p_b_insertmz;