小工具知识网

当前位置: 首页 > 行业知识 > Java基础 - 模拟医院挂号系统

行业知识

Java基础 - 模拟医院挂号系统

2026-11-07 03:59:26 来源:互联网转载

���拟医院挂号系统功能

()

1. 科室管理:新增科室,删除科室(如果有医生在,则不能删除该科室),修改科室

2. 医生管理:录入医生信息以及科室信息,修改医生信息(主要是修改个人信息和科室)

()

3. 坐诊信息设置:可以设置医生当天和未来6天的坐诊情况,包括上午和下午的坐诊时间段和可预约数量,系统将自动保存到该医生的坐诊信息列表中

4. 全部信息展示:按照科室,展示每个医生七天的坐诊情况,需要按照科室归类展示

5. 预约功能:用户可以选择要预约的科室,医生、日期和时间段,并输入患者的个人信息,系统将激动判断该时间段是否还有预约名额,并保存预约信息

6. 搜索功能:用户可以输入搜索日期和时间段,系统将自动搜索未来七天内在该时间段坐诊的医生信息,并按照科室分类展示

7. 可以查询某个医生未来7天,病人对他的预约情况

//Apppublic class App {    public static void main(String[] args) {        //创建一个医院管理对象        HospitalManager h = new HospitalManager();        h.start();    }}
//Doctor//医生类public class Doctor {    private String doctorId;  //编号(唯一)    private String name;  //姓名    private String departmentName;  //科室名称    private String gender;  //性别    private int age;  //年龄    private String specialty;  //主治方向    private LocalDate joinDate;  //入职时间    private ArrayList schedules = new ArrayList();  //7天坐诊情况    public Doctor() {    }    public Doctor(String doctorId, String name, String departmentName, String gender, int age, String specialty, LocalDate joinDate, ArrayList schedules) {        this.doctorId = doctorId;        this.name = name;        this.departmentName = departmentName;        this.gender = gender;        this.age = age;        this.specialty = specialty;        this.joinDate = joinDate;        this.schedules = schedules;    }    public String getDoctorId() {        return doctorId;    }    public void setDoctorId(String doctorId) {        this.doctorId = doctorId;    }    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }    public String getDepartmentName() {        return departmentName;    }    public void setDepartmentName(String departmentName) {        this.departmentName = departmentName;    }    public String getGender() {        return gender;    }    public void setGender(String gender) {        this.gender = gender;    }    public int getAge() {        return age;    }    public void setAge(int age) {        this.age = age;    }    public String getSpecialty() {        return specialty;    }    public void setSpecialty(String specialty) {        this.specialty = specialty;    }    public LocalDate getJoinDate() {        return joinDate;    }    public void setJoinDate(LocalDate joinDate) {        this.joinDate = joinDate;    }    public ArrayList getSchedules() {        return schedules;    }    public void setSchedules(ArrayList schedules) {        this.schedules = schedules;    }}
//Department//科室类public class Department {    private String name;    private ArrayList doctors = new ArrayList();    public Department() {    }    public Department(String name, ArrayList doctors) {        this.name = name;        this.doctors = doctors;    }    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }    public ArrayList getDoctors() {        return doctors;    }    public void setDoctors(ArrayList doctors) {        this.doctors = doctors;    }}
//Schedule//医生坐诊情况类public class Schedule {    private LocalDate today;  //当天日期    private boolean update = false;  //是否排班(默认未排班false)    //上午    private boolean morning;  //是否看诊    private LocalTime mStart;  //上午开始时间    private LocalTime mEnd;  //上午结束时间    private int mTotalNum;  //上午可预约人数    private int mAppointNum;  //上午已预约人数    //下午    private boolean afternoon;  //是否看诊    private LocalTime aStart;  //下午开始时间    private LocalTime aEnd;  //下午结束时间    private int aTotalNum;  //下午可预约人数    private int aAppointNum;  //下午已预约人数    public Schedule() {    }    public Schedule(LocalDate today, boolean update, boolean morning, LocalTime mStart, LocalTime mEnd, int mTotalNum, int mAppointNum, boolean afternoon, LocalTime aStart, LocalTime aEnd, int aTotalNum, int aAppointNum) {        this.today = today;        this.update = update;        this.morning = morning;        this.mStart = mStart;        this.mEnd = mEnd;        this.mTotalNum = mTotalNum;        this.mAppointNum = mAppointNum;        this.afternoon = afternoon;        this.aStart = aStart;        this.aEnd = aEnd;        this.aTotalNum = aTotalNum;        this.aAppointNum = aAppointNum;    }    public boolean isUpdate() {        return update;    }    public void setUpdate(boolean update) {        this.update = update;    }    public LocalDate getToday() {        return today;    }    public void setToday(LocalDate today) {        this.today = today;    }    public boolean isMorning() {        return morning;    }    public void setMorning(boolean morning) {        this.morning = morning;    }    public LocalTime getmStart() {        return mStart;    }    public void setmStart(LocalTime mStart) {        this.mStart = mStart;    }    public LocalTime getmEnd() {        return mEnd;    }    public void setmEnd(LocalTime mEnd) {        this.mEnd = mEnd;    }    public int getmTotalNum() {        return mTotalNum;    }    public void setmTotalNum(int mTotalNum) {        this.mTotalNum = mTotalNum;    }    public int getmAppointNum() {        return mAppointNum;    }    public void setmAppointNum(int mAppointNum) {        this.mAppointNum = mAppointNum;    }    public boolean isAfternoon() {        return afternoon;    }    public void setAfternoon(boolean afternoon) {        this.afternoon = afternoon;    }    public LocalTime getaStart() {        return aStart;    }    public void setaStart(LocalTime aStart) {        this.aStart = aStart;    }    public LocalTime getaEnd() {        return aEnd;    }    public void setaEnd(LocalTime aEnd) {        this.aEnd = aEnd;    }    public int getaTotalNum() {        return aTotalNum;    }    public void setaTotalNum(int aTotalNum) {        this.aTotalNum = aTotalNum;    }    public int getaAppointNum() {        return aAppointNum;    }    public void setaAppointNum(int aAppointNum) {        this.aAppointNum = aAppointNum;    }}
//Appointment//患者预约信息类public class Appointment {    private String userName;  //患者姓名    private String sex;  //患者性别    private int age;  //患者年龄    private String tel;  //患者电话    private String desc;  //病情描述    private String departmentName;  //挂号科室    private String doctorId;  //看诊医生id    private LocalDateTime appointDateTime;  //预约时间    public Appointment() {    }    public String getUserName() {        return userName;    }    public void setUserName(String userName) {        this.userName = userName;    }    public String getSex() {        return sex;    }    public void setSex(String sex) {        this.sex = sex;    }    public int getAge() {        return age;    }    public void setAge(int age) {        this.age = age;    }    public String getTel() {        return tel;    }    public void setTel(String tel) {        this.tel = tel;    }    public String getDesc() {        return desc;    }    public void setDesc(String desc) {        this.desc = desc;    }    public String getDepartmentName() {        return departmentName;    }    public void setDepartmentName(String departmentName) {        this.departmentName = departmentName;    }    public String getDoctorId() {        return doctorId;    }    public void setDoctorId(String doctorId) {        this.doctorId = doctorId;    }    public LocalDateTime getAppointDateTime() {        return appointDateTime;    }    public void setAppointDateTime(LocalDateTime appointDateTime) {        this.appointDateTime = appointDateTime;    }}
/*    模拟医院挂号系统功能        1. 科室管理:新增科室,删除科室(如果有医生在,则不能删除该科室),修改科室名称        2. 医生管理:录入医生信息以及科室信息,修改医生信息(主要是修改个人信息和科室)        3. 坐诊信息设置:可以设置医生当天和未来6天的坐诊情况,包括上午和下午的坐诊时间段和可预约数量,系统将自动保存到该医生的坐诊信息列表中        4. 全部信息展示:按照科室,展示每个医生七天的坐诊情况,需要按照科室归类展示        5. 预约功能:用户可以选择要预约的科室,医生、日期和时间段,并输入患者的个人信息,系统将激动判断该时间段是否还有预约名额,并保存预约信息        6. 搜索功能:用户可以输入搜索日期和时间段,系统将自动搜索未来七天内在该时间段坐诊的医生信息,并按照科室分类展示        7. 可以查询某个医生未来7天,病人对他的预约情况*///HospitalManagerpublic class HospitalManager {    //系统需要存储全部科室信息    private ArrayList departments = new ArrayList();    //系统需要记录全部预约信息    private ArrayList appointments = new ArrayList();    Scanner sc = new Scanner(System.in);    public void start() {        while(true){            System.out.println("====欢迎进入莴笋医院信息管理系统====");            System.out.println("====1.科室管理--添加科室====");            System.out.println("====2.科室管理--删除科室====");            System.out.println("====3.科室管理--修改科室名称====");            System.out.println("====4.医生管理--录入医生====");            System.out.println("====5.医生管理--医生坐诊设置(可设置当天和未来6天的坐诊情况)====");            System.out.println("====6.搜索--查看全部医生坐诊情况(当天和未来6天的坐诊详情)====");            System.out.println("====7.搜索--查看某医生坐诊情况(当天和未来6天的坐诊详情)====");            System.out.println("====8.挂号--挂号预约====");            System.out.println("====9.退出====");            System.out.println("请输入您的操作指令(1-9):");            switch (sc.next()){                case "1":                    addDepartment();                    break;                case "2":                    deleteDepartment();                    break;                case "3":                    modifyDepartment();                    break;                case "4":                    addDoctor();                    break;                case "5":                    setDoctorJob();                    break;                case "6":                    searchAllJob();                    break;                case "7":                    searchOneJob();                    break;                case "8":                    Appoint();                    break;                case "9":                    return;                default:                    System.out.println("您选择的操作不存在,请重新选择");                    break;            }        }    }    private void Appoint() {        System.out.println("====挂号预约====");        //判断有没有科室(医院没有科室就一定没有医生)        if(isDepartment()==false) {            System.out.println("没有科室就没有医生");            return;        }        //有科室        while(true) {            showAllDepartment();  //展示已有科室            //先选择科室            System.out.println("请选择挂号科室(最大选择" + departments.size() + "):");            int command1 = sc.nextInt();            if (existDepartment(command1) == false) {                //不存在该科室                continue;            }            //存在该科室            Department department = departments.get(command1 - 1);            //判断该科室是否存在医生            if (department.getDoctors().size() == 0) {                //没有医生                System.out.println("该科室无医生");                return;            }            //有医生            while (true) {                //显示该科室的全部医生                showAllDoctor(department);                Appointment a = new Appointment();                a.setDepartmentName(department.getName());  //保存挂号科室名称                //选择看诊的医生                ArrayList doctors = department.getDoctors();                System.out.println("请选择看诊医生的序号(最大选择"+doctors.size()+"):");                int command2 = sc.nextInt();                if(existDoctor(doctors,command2)==false){                    //不存在该医生                    continue;                }                //存在该医生                Doctor d = doctors.get(command2-1);  //保存选择的医生对象                //展示该医生的排班信息                print(d);                ArrayList arr = d.getSchedules();  //arr保存该医生的排班信息                //如果该医生一次都没排过(arr数组都是空的)                if(arr.size() == 0){                    System.out.println("该医生未排班,请重新选择");                    continue;                }                OUT:                while (true) {                    //该医生排过班(arr数组不是空的)                    System.out.println("请选择看诊日期:");                    String dayStr = sc.next();                    LocalDate ld = LocalDate.parse(dayStr);                    for (int i = 0; i = 0; i--) {  //遍历已保存的7天            LocalDate ld = schedules.get(i).getToday();   //已经保存的第i个日期            if(ld.isBefore(now)){  //保存的第i个日期早于今天的日期                schedules.remove(i);                count++;            }        }        //如果有删除过期的时间,那么需要补全7天        //count == 0说明没有删除日期        if(count == 0){            return;        }        //count不等于0说明有删除(那么应该从count-1开始补全日期,比如删除了5天,剩下2天,那么就应该从第3个位置(索引2)开始补5天)        for (int i=7-count; i  departments.size()){            //没有该科室            System.out.println("不存在该科室,请重新选择");            return false;        }        //有该科室        return true;    }    //判断选择的序号是否有医生存在    private boolean existDoctor(ArrayList doctors,int command){        if(command  doctors.size()){            //没有该医生            System.out.println("不存在该医生,请重新选择");            return false;        }        //有该医生        return true;    }}

上一篇:晋江下载应用必备指南,简易步骤,快速安装使用!

下一篇:苹果服务器无法接通怎么办?