发布时间 : 星期三 文章[]基于JAVA的医院门诊信息管理系统设计与实现更新完毕开始阅读efb0cb2eed630b1c59eeb55a
本方法供医生修改病历。 ? 参数
? hid:病历编号。 ? diagnose:诊断。 ? rx:处方。 ? description:症状。 ? 返回值
? 1:操作成功。 ? 0:抛出一般异常。 ? -1:抛出数据异常。 ? -2:非法hid值。
(6) 结束治疗:finishedHistory(int hid)
本方法将结束患者的治疗过程(即将数据库中的“Finished”字段设置为“1”)。 ? 参数
hid:病历编号 ? 返回值
1:操作成功。 0:抛出一般异常。 -1:抛出数据库异常。 -2:非法hid值。
(7) 更改密码:updatePassword(String password) 本方法用于修改医生的密码。 ? 参数
password:新密码。 ? 返回值
? 1:操作成功。 ? 0:抛出一般异常。 ? -1:抛出数据库异常。 5.2.2.2 患者模型Patient类
本类位于hospital.db.operation包中,Patient类封装了患者角色可执行的所有操作,部分代码如下:
public class Patient
extends DBOperation{
public static final String NAME=\ //封装“Name”字段名 public static final String SECTION=\ //封装“Section”字段名 public static final String ANONYMOUS=\ //封装匿名用户 private int PID; //存储患者表的“PID”字段 public Patient(String id) }
public int login(String password){ ?? }
public synchronized int addPatient(String username, String name, String password, int age, int sex,String address,String phone){ ??
}
public int getDoctorInfo(String orderBy){ ?? }
public int getCurrentDoctorInfo(){ ?? }
public int getHistory(){ ?? }
public synchronized int makeAppointment(String did,int day,int ap){ ?? }
public synchronized int cancleAppointment(int qid){ ?? }
public int getAppointmentInfo(){ ?? }
public int getDoctorAppointmentInfo(String did){ ?? }
protected void checkUser(String id)
throws InvalidUserException{ conn=DBConnection.getConnection();
throws InvalidUserException{ super(id); //调用父类构造器
}
strSQL=\if(id.equals(Patient.ANONYMOUS)) try{ }
catch(SQLException sqle){
Debug.log(Debug.getExceptionMsg(sqle)); }
stmt=conn.createStatement(); rs=stmt.executeQuery(strSQL); if(!rs.next())
throw new InvalidUserException(); return;
}
下面对Patient类中的一些关键方法的功能和原理加以说明。 (1) 患者注册:addPatient
本方法用于患者注册,即向数据库中插入患者信息记录。 ? 参数
? username:用户名。 ? name:姓名。 ? password:密码。 ? age:年龄。 ? sex:性别。 ? address:联系地址。 ? phone:联系电话。 ? 返回值
? 1:操作成功。 ? 0:抛出一般异常。 ? -1:抛出数据库异常。 ? -2:账户已存在。 Patient.addPatient实现代码如下:
public synchronized int addPatient(String username, String name, String password, int age, int sex, String address, String phone){
System.out.println(\+\int res=0;
conn=DBConnection.getConnection(); if(conn!=null){ } try{
String insertSQL = \
(Name,Username,Password,Age,Sex,Address,Phone)VALUES(?, ? , ? , ? , ? , ? , ?)\System.out.println(\System.out.println(\}else{
}
}
PreparedStatement ps = conn.prepareStatement(insertSQL); ps.setString(1 , name); ps.setString(2 , username); ps.setString(3 , password); ps.setInt(4 , age); ps.setInt(5 ,sex); ps.setString(6 , address); ps.setString(7 , phone); ps.execute(); res=1;
catch(SQLException sqle){ }
catch(IllegalArgumentException iae){ }
catch(Exception e){ } finally{ }
return res;
res=0;
Debug.log(Debug.getExceptionMsg(iae)); res= -2;
Debug.log(Debug.getExceptionMsg(sqle)); res= -1;
(2) 查询医生信息:getDoctorInfo(String orderBy) 本方法查询所有医生的全部信息。 ? 参数
orderBy:结果集排序方式。 ? 返回值