发布时间 : 星期六 文章[]基于JAVA的医院门诊信息管理系统设计与实现更新完毕开始阅读
1:操作成功。 2:抛出一般异常。 -1:抛出数据库异常。
Patient.getDoctorInfo实现代码如下:
public int getDoctorInfo(String orderBy){
}
if(orderBy == null || orderBy.equals(\
orderBy=Patient.NAME; int res=0;
conn=DBConnection.getConnection();
strSQL=\DID,Name,Age,Sex,Level,Section,Specialism,Phone FROM doctor ORDER BY \try{ }
catch(SQLException sqle){ }
catch(Exception e){ } finally{ }
return res; res=0;
Debug.log(Debug.getExceptionMsg(sqle)); res= -1;
stmt=conn.createStatement(); rs=stmt.executeQuery(strSQL); result=rs; res=1;
(3) 获取主治医生信息:getCurrentDoctorInfo()
本方法返回当前患者的主治医生的信息。其中“主治医生”指已创建该患者病历且治疗过程未结束的医生。 返回值如下: ? 1:操作成功。 ? 0:抛出一般异常。 ? -1:抛出数据库异常。 (4) 查询病历:getHistory() 本方法返回当前患者的所有病历。
返回值如下: ? 1:操作结果。 ? 0:抛出一般异常。 ? -1:抛出数据库异常。
(5) 预约:makeAppointment(String did, int day, int ap)
本方法用于患者预约,即向数据库中插入一条预约记录,其流程如下: 向pinqueue表插入预约记录 将curappointment表中相应的可预约数量减1。 ? 参数
? did:医生编号。
? day:预约日(0为周日,1为周一??)。 ? ap:上下午(0为上午,1为下午)。 ? 返回值
? 1:操作成功。 ? 0:抛出一般异常。 ? -1:抛出数据库异常。
? -2:已在相同的时间预约相同的医生。 ? -3:day或ap格式错误。
Patient.makeAppointment的实现代码如下:
public synchronized int makeAppointment(String did,int day,int ap){
int res=0;
conn=DBConnection.getConnection();
SimpleDateFormat dateFormat=new SimpleDateFormat(\ String[]
days={\FriA\
int index=0,curpc=0; try{
if(day < 0 || day > 6 || ap < 0 || ap > 1) //day必须是0~6之间的整数,ap必须是0或1
throw new NumberFormatException(); index=day * 2 + ap; stmt=conn.createStatement(); strSQL=
\did + \
rs=stmt.executeQuery(strSQL);
if(!rs.next() || (curpc=rs.getInt(days[index])) == 0)
throw new NumberFormatException();
strSQL=\
\
Patient=\this.PID + \
rs=stmt.executeQuery(strSQL); if(rs.next())
throw new IllegalArgumentException(); conn.setAutoCommit(false); //事务处理开始 stmt=conn.createStatement();
strSQL=\
ap + \new java.util.Date()) + \
//向pinqueue表插入预约记录
stmt.addBatch(strSQL);
}
}
catch(NumberFormatException nfe){ }
catch(SQLException sqle){ }
catch(IllegalArgumentException iae){ }
catch(Exception e){ } finally{ }
return res;
Debug.log(Debug.getExceptionMsg(e)); res=0; res= -2; conn.rollback(); res= -1;
Debug.log(Debug.getExceptionMsg(sqle)); res= -3;
strSQL=\WHERE DID='\ //将curappointment表中相应可预约数量减1 stmt.addBatch(strSQL); stmt.executeBatch(); conn.commit(); res=1;
this.PID + \
(6) 取消预约:cancleAppointment(int qid)
本方法用于患者取消预约信息,即从数据库中删除相应的预约记录,其流程
如下。
删除pinqueue表中记录 将curappointment表中相应可预约数量加1。 ? 参数
qid:预约编号。 ? 返回值
? 1:操作结果。 ? 0:抛出一般异常。 ? -1:抛出数据库异常。 Patient.cancleAppointment实现代码:
public synchronized int cancleAppointment(int qid){
int res=0;
conn=DBConnection.getConnection(); String[]
days={\\
int index,curpc,day,ap; String did=\try{
strSQL=\stmt=conn.createStatement(); rs=stmt.executeQuery(strSQL); if(!rs.next())
throw new SQLException(\day=rs.getInt(\ap=rs.getInt(\did=rs.getString(\index=day * 2 + ap;
strSQL=\rs=stmt.executeQuery(strSQL); rs.next();
curpc=rs.getInt(days[index]); conn.setAutoCommit(false); stmt=conn.createStatement();
strSQL=\stmt.addBatch(strSQL);
strSQL=\WHERE DID='\stmt.addBatch(strSQL); stmt.executeBatch(); conn.commit();