我的编程空间,编程开发者的网络收藏夹
学习永远不晚

黑马程序员B站JAVA网课,医院管理系统代码(自写)

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

黑马程序员B站JAVA网课,医院管理系统代码(自写)

//        1、科室管理:新增科室,删除科室(如果有医生在,则不能删除该科室),修改科室。//        2、医生管理:录入医生信息,以及科室信息。修改医生信息(主要是修改个人信息和科室)//        3、坐诊信息设置:可以设置医生当天和未来6天的坐诊情况,包括上午和下午的坐诊时间段和可预约数量,系统将自动保存到该医生的坐诊信息列表中。//        4、全部信息展示:按照科室,展示每个医生七天的坐诊情况,需要按照科室归类展示//        5、预约功能:用户可以选择要预约的科室,医生、日期和时间段,并输入患者的个人信息,系统将自动判断该时间段是否还有预约名额,并保存预约信息。//        6、搜索功能:用户可以输入搜索日期和时间段,系统将自动搜索未来七天内在该时间段坐诊的医生信息,并按照科室分类展示。//        7、可以查询某个医生未来七天,病人对它的预约情况。
// 测试类package TotalDemo_hospital;public class text {    public static void main(String[] args) {        hospitalOperator hospitalOperator = new hospitalOperator();        hospitalOperator.allStart();    }}

医生对象类

// 医生类package TotalDemo_hospital;import java.time.LocalDate;import java.util.ArrayList;public class Doctor extends Department{ // 医生属于每个科室    private String doctorId; // 医生编号    private String name; // 医生名字    private String gender; // 性别    private String DepartmentName; // 医生所属科室名    private int age; // 年龄    private String skill; // 擅长治疗方向    private LocalDate joinTime; // 入职时间    private ArrayList<Schedule> schedule = new ArrayList<>(); // 创造时刻表,表示未来七天的日程    private ArrayList<String> appointPeople = new ArrayList<>(); // 创建预约表,以便叫号    public Doctor() {    }    public ArrayList<String> getAppointPeople() {        return appointPeople;    }    public void setAppointPeople(ArrayList<String> appointPeople) {        this.appointPeople = appointPeople;    }    public ArrayList<String> getStrings() {        return appointPeople;    }    public void setStrings(ArrayList<String> strings) {        this.appointPeople = strings;    }    public ArrayList<Schedule> getSchedule() {        return schedule;    }    public void setSchedule(ArrayList<Schedule> schedule) {        this.schedule = schedule;    }    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 getGender() {        return gender;    }    public void setGender(String gender) {        this.gender = gender;    }    public String getDepartmentName() {        return DepartmentName;    }    public void setDepartmentName(String departmentName) {        DepartmentName = departmentName;    }    public int getAge() {        return age;    }    public void setAge(int age) {        this.age = age;    }    public String getSkill() {        return skill;    }    public void setSkill(String skill) {        this.skill = skill;    }    public LocalDate getJoinTime() {        return joinTime;    }    public void setJoinTime(LocalDate joinTime) {        this.joinTime = joinTime;    }}

患者预约类

// 预约类package TotalDemo_hospital;import java.time.LocalDateTime;// 患者预约类public class Appointment {    private String name; // 患者的名字    private String gender; // 患者的性别    private int age; // 患者的年龄    private String diseaseDesc; // 患者的病情描述    private String appointDeportmentName; // 预约的科室名    private String doctorId; // 预约的医生编号    private LocalDateTime appointTime; // 预约的时间    public Appointment() {    }    public Appointment(String name, String gender, int age, String diseaseDesc, String appointDeportmentName, String doctorId, LocalDateTime appointTime) {        this.name = name;        this.gender = gender;        this.age = age;        this.diseaseDesc = diseaseDesc;        this.appointDeportmentName = appointDeportmentName;        this.doctorId = doctorId;        this.appointTime = appointTime;    }    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }    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 getDiseaseDesc() {        return diseaseDesc;    }    public void setDiseaseDesc(String diseaseDesc) {        this.diseaseDesc = diseaseDesc;    }    public String getAppointDeportmentName() {        return appointDeportmentName;    }    public void setAppointDeportmentName(String appointDeportmentName) {        this.appointDeportmentName = appointDeportmentName;    }    public String getDoctorId() {        return doctorId;    }    public void setDoctorId(String doctorId) {        this.doctorId = doctorId;    }    public LocalDateTime getAppointTime() {        return appointTime;    }    public void setAppointTime(LocalDateTime appointTime) {        this.appointTime = appointTime;    }}

医院科室类

// 科室类package TotalDemo_hospital;import java.util.ArrayList;// 科室类public class Department {    private String departmentName; // 科室名    private ArrayList<Doctor> doctor = new ArrayList<>();    public Department() {    }    public Department(String departmentName, ArrayList<Doctor> doctor) {        this.departmentName = departmentName;        this.doctor = doctor;    }    public ArrayList<Doctor> getDoctor() {        return doctor;    }    public void setDoctor(ArrayList<Doctor> doctor) {        this.doctor = doctor;    }    public String getDepartmentName() {        return departmentName;    }    public void setDepartmentName(String departmentName) {        this.departmentName = departmentName;    }}

医生时刻表

// 时刻表类package TotalDemo_hospital;import java.time.LocalDate;import java.time.LocalTime;import java.util.ArrayList;// 时刻类// 时刻表是基于每一个医生独有的public class Schedule extends Doctor{    // 记录当前时间    private LocalDate day;    // 记录是否排班    private Boolean update = false;    // 今日预约信息    //早上预约情况    private Boolean morning = false; // 判断是否在早上排班    private LocalTime morDoctorBeginTime; // 早上开始看诊的时间    private LocalTime morDoctorEndTime; // 早上结束看诊的时间    private int morTotalVisitorNumber; // 早上医生总共可以接受看诊的人数 int类型在医生可以多看几个的时候可以随意增添    private int morTotalAppointmentNumber; // 早上已经预约的人数    //下午预约情况    private Boolean afternoon = false; // 判断是否在晚上排班    private LocalTime aftDoctorBeginTime; // 晚上开始看诊的时间    private LocalTime aftDoctorEndTime; // 晚上结束看诊的时间    private int aftTotalVisitorNumber; // 晚上医生总共可以接受看诊的人数 int类型在医生可以多看几个的时候可以随意增添    private int aftTotalAppointmentNumber; // 晚上已经预约的人数    public Schedule() {    }    public Schedule(LocalDate day, Boolean update, Boolean morning, LocalTime morDoctorBeginTime, LocalTime morDoctorEndTime, int morTotalVisitorNumber, int morTotalAppointmentNumber, Boolean afternoon, LocalTime aftDoctorBeginTime, LocalTime aftDoctorEndTime, int aftTotalVisitorNumber, int aftTotalAppointmentNumber) {        this.day = day;        this.update = update;        this.morning = morning;        this.morDoctorBeginTime = morDoctorBeginTime;        this.morDoctorEndTime = morDoctorEndTime;        this.morTotalVisitorNumber = morTotalVisitorNumber;        this.morTotalAppointmentNumber = morTotalAppointmentNumber;        this.afternoon = afternoon;        this.aftDoctorBeginTime = aftDoctorBeginTime;        this.aftDoctorEndTime = aftDoctorEndTime;        this.aftTotalVisitorNumber = aftTotalVisitorNumber;        this.aftTotalAppointmentNumber = aftTotalAppointmentNumber;    }    public Boolean getUpdate() {        return update;    }    public void setUpdate(Boolean update) {        this.update = update;    }    public LocalDate getDay() {        return day;    }    public void setDay(LocalDate day) {        this.day = day;    }    public Boolean getMorning() {        return morning;    }    public void setMorning(Boolean morning) {        this.morning = morning;    }    public LocalTime getMorDoctorBeginTime() {        return morDoctorBeginTime;    }    public void setMorDoctorBeginTime(LocalTime morDoctorBeginTime) {        this.morDoctorBeginTime = morDoctorBeginTime;    }    public LocalTime getMorDoctorEndTime() {        return morDoctorEndTime;    }    public void setMorDoctorEndTime(LocalTime morDoctorEndTime) {        this.morDoctorEndTime = morDoctorEndTime;    }    public int getMorTotalVisitorNumber() {        return morTotalVisitorNumber;    }    public void setMorTotalVisitorNumber(int morTotalVisitorNumber) {        this.morTotalVisitorNumber = morTotalVisitorNumber;    }    public int getMorTotalAppointmentNumber() {        return morTotalAppointmentNumber;    }    public void setMorTotalAppointmentNumber(int morTotalAppointmentNumber) {        this.morTotalAppointmentNumber = morTotalAppointmentNumber;    }    public Boolean getAfternoon() {        return afternoon;    }    public void setAfternoon(Boolean afternoon) {        this.afternoon = afternoon;    }    public LocalTime getAftDoctorBeginTime() {        return aftDoctorBeginTime;    }    public void setAftDoctorBeginTime(LocalTime aftDoctorBeginTime) {        this.aftDoctorBeginTime = aftDoctorBeginTime;    }    public LocalTime getAftDoctorEndTime() {        return aftDoctorEndTime;    }    public void setAftDoctorEndTime(LocalTime aftDoctorEndTime) {        this.aftDoctorEndTime = aftDoctorEndTime;    }    public int getAftTotalVisitorNumber() {        return aftTotalVisitorNumber;    }    public void setAftTotalVisitorNumber(int aftTotalVisitorNumber) {        this.aftTotalVisitorNumber = aftTotalVisitorNumber;    }    public int getAftTotalAppointmentNumber() {        return aftTotalAppointmentNumber;    }    public void setAftTotalAppointmentNumber(int aftTotalAppointmentNumber) {        this.aftTotalAppointmentNumber = aftTotalAppointmentNumber;    }}

医院管理系统

package TotalDemo_hospital;//        1、科室管理:新增科室,删除科室(如果有医生在,则不能删除该科室),修改科室。//        2、医生管理:录入医生信息,以及科室信息。修改医生信息(主要是修改个人信息和科室)//        3、坐诊信息设置:可以设置医生当天和未来6天的坐诊情况,包括上午和下午的坐诊时间段和可预约数量,系统将自动保存到该医生的坐诊信息列表中。//        4、全部坐诊信息展示:按照科室,展示每个医生七天的坐诊情况,需要按照科室归类展示//        5、预约功能:用户可以选择要预约的科室,医生、日期和时间段,并输入患者的个人信息,系统将自动判断该时间段是否还有预约名额,并保存预约信息。//        6、搜索功能:用户可以输入搜索日期和时间段,系统将自动搜索未来七天内在该时间段坐诊的医生信息,并按照科室分类展示。//        7、可以查询某个医生未来七天,病人对它的预约情况。import java.time.LocalDate;import java.time.LocalTime;import java.util.ArrayList;import java.util.Scanner;import java.util.UUID;public class hospitalOperator {    ArrayList<Department> department = new ArrayList<>(); // 创建一个科室类,保存所有的科室    ArrayList<Doctor> doctors = new ArrayList<>(); // 创建一个医生数组对象    Scanner sc = new Scanner(System.in); // 输入信息    public void allStart(){        while (true) {            System.out.println("欢迎进入仁爱医院,请选择您的身份");            System.out.println("1、用户");            System.out.println("2、管理");            int cmd  = sc.nextInt();            switch (cmd){                case 1:                    peopleStart();                    break;                case 2:                    start();                    break;            }        }    }    // 用户操作系统    private void peopleStart() {        while (true) {            System.out.println("请选择您要进行的操作");            System.out.println("1、预约");            System.out.println("2、搜索");            System.out.println("3、查看预约情况");            System.out.println("4、退出");            int cmd = sc.nextInt();            switch (cmd){                case 1:                    appointmentOperator(department);                    break;                case 2:                    searchOperator(department);                    break;                case 3:                    dorSearch(department);                    break;                case 4:                    return;                default:                    System.out.println("系统繁忙,请重试");                    break;            }        }    }    public void start(){        while (true) {            System.out.println("欢迎进入医院管理系统");            System.out.println("请选择您要使用的功能");            System.out.println("1、科室管理");            System.out.println("2、医生管理");            System.out.println("3、坐诊信息设置");            System.out.println("4、全部坐诊信息展示");            System.out.println("5、退出");            int com = sc.nextInt();            switch (com){                case 1:                    deportmentOperator();                    break;                case 2:                    doctorOperator();                    break;                case 3:                    scheduleOperator();                    break;                case 4:                    printAllInformation(department);                    break;                case 5:                    return;                default:                    System.out.println("指令错误,请重试");                    break;            }        }    }    // 查询功能    public void dorSearch(ArrayList<Department> department){        System.out.println("请输入您要查询的科室");        Department department1 = getDepartByUser();        System.out.println("请输入您要查询的医生");        Doctor doctor = getDoctorByUser(department1);        System.out.println( doctor.getName() + "的坐诊信息如下");        getTime(doctor);    }    private void getTime(Doctor doctor) {        ArrayList<Schedule> schedules = doctor.getSchedule();        for (int i = 0; i < schedules.size(); i++) {            Schedule schedule = schedules.get(i);            LocalDate lod = schedule.getDay();            System.out.println(lod);            if(!schedule.getUpdate()){                System.out.println("未排班");            }else {                System.out.println("早上排班情况如下:");                if(!schedule.getMorning()){                    System.out.println("早上的看诊时间为" + schedule.getMorDoctorBeginTime() + "-" + schedule.getMorDoctorEndTime());                    System.out.println("当前预约人数/看诊人数为:" + schedule.getMorTotalAppointmentNumber() + "/" + schedule.getMorTotalVisitorNumber());                }else {                    System.out.println("休息");                }                System.out.println("晚上排班情况如下:");                if(!schedule.getAfternoon()){                    System.out.println("晚上的看诊时间为" + schedule.getAftDoctorBeginTime() + "-" + schedule.getAftDoctorEndTime());                    System.out.println("当前预约人数/看诊人数为:" + schedule.getAftTotalAppointmentNumber() + "/" + schedule.getAftTotalVisitorNumber());                }else {                    System.out.println("休息");                }            }        }    }    // 搜索功能    public void searchOperator(ArrayList<Department> department){//        6、搜索功能:用户可以输入搜索日期和时间段,系统将自动搜索未来七天内在该时间段坐诊的医生信息,并按照科室分类展示。        // 获取当前时间,遍历之后七天        LocalDate lod = LocalDate.now();        for (int i = 0; i < 7; i++) {            System.out.println( (i+1) + "、" + lod.plusDays(i));        }        System.out.println("请选择您要搜索的日期");        // 得到用户选择的日期        int cmd = sc.nextInt()-1;        System.out.println("请选择上午还是下午");        System.out.println("1、上午");        System.out.println("2、下午");        int cmdd = sc.nextInt();        for (int i = 0; i < department.size(); i++) {            // 得到每一个科室对象            Department department1 = department.get(i);            ArrayList<Doctor> doctors = department1.getDoctor();            System.out.println(department1.getDepartmentName());            for (int i1 = 0; i1 < doctors.size(); i1++) {                // 得到每一个医生对象                Doctor doctor = doctors.get(i);                ArrayList<Schedule> schedules = doctor.getSchedule();                // 得到用户选择的那一天的时刻表                Schedule schedule = schedules.get(cmd);                if (!schedule.getUpdate()){                    continue;                }                switch (cmdd){                    case 1:                        if(!schedule.getMorning()){System.out.println(doctor.getName());                        }                        break;                    case 2:                        if(!schedule.getAfternoon()){System.out.println(doctor.getName());                        }                        break;                }            }            System.out.println("  ---------------------   ");        }    }    // 用户预约功能    public void appointmentOperator(ArrayList<Department> department){        System.out.println("请选择您要预约的科室");        Department department1 = getDepartByUser();        System.out.println("请选择您要预约的医生");        Doctor doctor = getDoctorByUser(department1);        System.out.println("请选择您要预约的日期和时间");        getTimeByUser(doctor);    }    private void getTimeByUser(Doctor doctor) {        ArrayList<Schedule> schedules = doctor.getSchedule();        for (int i = 0; i < schedules.size(); i++) {            Schedule schedule = schedules.get(i);            LocalDate lod = schedule.getDay();            System.out.println((i+1) + "、" + lod);            if(!schedule.getUpdate()){                System.out.println("未排班");            }else {                System.out.println("早上排班情况如下:");                if(!schedule.getMorning()){                    System.out.println("早上的看诊时间为" + schedule.getMorDoctorBeginTime() + "-" + schedule.getMorDoctorEndTime());                    System.out.println("当前预约人数/看诊人数为:" + schedule.getMorTotalAppointmentNumber() + "/" + schedule.getMorTotalVisitorNumber());                }else {                    System.out.println("休息");                }                System.out.println("晚上排班情况如下:");                if(!schedule.getAfternoon()){                    System.out.println("晚上的看诊时间为" + schedule.getAftDoctorBeginTime() + "-" + schedule.getAftDoctorEndTime());                    System.out.println("当前预约人数/看诊人数为:" + schedule.getAftTotalAppointmentNumber() + "/" + schedule.getAftTotalVisitorNumber());                }else {                    System.out.println("休息");                }            }        }        System.out.println("请输入您要选择的时间");        int cmd = sc.nextInt()-1;        Schedule schedule = schedules.get(cmd);        if(!schedule.getUpdate()){            System.out.println("该时刻医生未排班,请更换时间");            return;        }        if(!schedule.getMorning() & !schedule.getAfternoon()){            System.out.println("请选择早上还是下午");            System.out.println("1、早上   2、下午");            int cmd1 = sc.nextInt();            switch (cmd1){                case 1:                    int number = schedule.getMorTotalAppointmentNumber();                    number++;                    schedule.setMorTotalAppointmentNumber(number);                    System.out.println("请输入您的名字");                    String name = sc.next();                    doctor.getAppointPeople().add(name);                    System.out.println("预约成功");                    return;                case 2:                    int number1 = schedule.getAftTotalAppointmentNumber();                    number1++;                    schedule.setAftTotalAppointmentNumber(number1);                    System.out.println("请输入您的名字");                    String name1 = sc.next();                    doctor.getAppointPeople().add(name1);                    System.out.println("预约成功");            }        }else if (!schedule.getAfternoon()){            int number1 = schedule.getAftTotalAppointmentNumber();            number1++;            schedule.setAftTotalAppointmentNumber(number1);            System.out.println("请输入您的名字");            String name = sc.next();            doctor.getAppointPeople().add(name);            System.out.println("预约成功");        }else if (!schedule.getMorning()) {            int number = schedule.getMorTotalAppointmentNumber();            number++;            schedule.setMorTotalAppointmentNumber(number);            System.out.println("请输入您的名字");            String name = sc.next();            doctor.getAppointPeople().add(name);            System.out.println("预约成功");        }else {            System.out.println("当前时间医生休息,请更换医生");        }    }    // 全部坐诊信息展示    public void printAllInformation(ArrayList<Department> department){        for (int i = 0; i < department.size(); i++) {            // 打印科室名            System.out.println( (i + 1) + "、"  + department.get(i).getDepartmentName());            // 拿到医生数组信息            ArrayList<Doctor> doctors = department.get(i).getDoctor();            // 打印医生坐诊情况            for (int i1 = 0; i1 < doctors.size(); i1++) {                // 拿到医生信息                Doctor doctor = doctors.get(i1);                // 输出医生名字                System.out.println( (i1+1) + "、" + doctor.getName());                // 更新一下医生的排班时刻表                updateSchedule(doctor.getSchedule());                // 得到医生时刻表数组对象                ArrayList<Schedule> schedules = doctor.getSchedule();                for (int i2 = 0; i2 < schedules.size(); i2++) {                    // 得到医生时刻表                    Schedule schedule1 = schedules.get(i2);                    LocalDate lod = schedule1.getDay();                    System.out.println(lod + "的排班情况如下");                    if(!schedule1.getUpdate()){                        System.out.println("未排班");                    }else {                        System.out.println("早上排班情况如下:");                        if(!schedule1.getMorning()){System.out.println("早上的看诊时间为" + schedule1.getMorDoctorBeginTime() + "-" + schedule1.getMorDoctorEndTime());System.out.println("当前预约人数/看诊人数为:" + schedule1.getMorTotalAppointmentNumber() + "/" + schedule1.getMorTotalVisitorNumber());                        }else {System.out.println("休息");                        }                        System.out.println("晚上排班情况如下:");                        if(!schedule1.getAfternoon()){System.out.println("晚上的看诊时间为" + schedule1.getAftDoctorBeginTime() + "-" + schedule1.getAftDoctorEndTime());System.out.println("当前预约人数/看诊人数为:" + schedule1.getAftTotalAppointmentNumber() + "/" + schedule1.getAftTotalVisitorNumber());                        }else {System.out.println("休息");                        }                    }                }            }        }    }     // 坐诊信息管理    public void scheduleOperator(){        if(department.size() == 0){            System.out.println("系统暂无科室信息,请录入科室信息后重试");            return;        }         // 选择科室        Department department1 = getDepartByUser();        // 选择医生        ArrayList<Doctor> doctors = department1.getDoctor();        if(doctors.size() == 0) {            System.out.println("当前科室下无医生");            return;        }        Doctor doctor1 = getDoctorByUser(department1);        // 更改时刻表        // 得到医生对象的时间表        ArrayList<Schedule> schedule1 = doctor1.getSchedule();        // 更新医生的坐诊时间        updateSchedule(schedule1);                // 修改医生的坐诊情况        for (int i = 0; i < schedule1.size(); i++) {            Schedule schedule = schedule1.get(i);            updateDoctorSchedule(schedule);        }    }    private void updateDoctorSchedule(Schedule schedule) {        LocalDate lod = schedule.getDay();        System.out.println(lod + "的排班情况如下");        if(!schedule.getUpdate()){            System.out.println("未排班");        }else {            System.out.println("早上排班情况如下:");            if(!schedule.getMorning()){                System.out.println("早上的看诊时间为" + schedule.getMorDoctorBeginTime() + "-" + schedule.getMorDoctorEndTime());                System.out.println("当前预约人数/看诊人数为:" + schedule.getMorTotalAppointmentNumber() + "/" + schedule.getMorTotalVisitorNumber());            }else {                System.out.println("休息");            }            System.out.println("晚上排班情况如下:");            if(!schedule.getAfternoon()){                System.out.println("晚上的看诊时间为" + schedule.getAftDoctorBeginTime() + "-" + schedule.getAftDoctorEndTime());                System.out.println("当前预约人数/看诊人数为:" + schedule.getAftTotalAppointmentNumber() + "/" + schedule.getAftTotalVisitorNumber());            }else {                System.out.println("休息");            }        }        System.out.println("是否修改信息(y/n)");        String cmd = sc.next();        switch (cmd){            case "y":                schedule.setUpdate(true);                System.out.println("请问是否在早上排班(y/n)");                String cmdd= sc.next();                switch (cmdd){                    case "y":                        schedule.setMorning(false);                         // 早上开始看诊的时间                        System.out.println("请设置开始看诊的时间");                        String MorBeaginTime = sc.next();                        schedule.setMorDoctorBeginTime(LocalTime.parse(MorBeaginTime));                        // 结束看诊的时间                        System.out.println("请设置结束的时间");                        String MorEndTime = sc.next();                        schedule.setMorDoctorEndTime(LocalTime.parse(MorEndTime));                        // 总的可预约人数                        System.out.println("请设置总预约人数");                        int visitor = sc.nextInt();                        schedule.setMorTotalVisitorNumber(visitor);                        break;                    case "n":                        schedule.setMorning(true);                        break;                }                System.out.println("请问下午是否排班(y/n)");                String cmddd = sc.next();                switch (cmddd){                    case "y":                        schedule.setAfternoon(false);                        // 早上开始看诊的时间                        System.out.println("请设置开始看诊的时间");                        String AftBeaginTime = sc.next();                        schedule.setAftDoctorBeginTime(LocalTime.parse(AftBeaginTime));                        // 结束看诊的时间                        System.out.println("请设置结束的时间");                        String AftEndTime = sc.next();                        schedule.setAftDoctorEndTime(LocalTime.parse(AftEndTime));                        // 总的可预约人数                        System.out.println("请设置总预约人数");                        int visitor = sc.nextInt();                        schedule.setAftTotalVisitorNumber(visitor);                        break;                    case "n":                        schedule.setAfternoon(true);                        break;                }        }    }    // 更新坐诊时间表(更新到自今天起后六天)    private void updateSchedule(ArrayList<Schedule> schedule1) {        // 当前医生没有坐诊信息,对坐诊信息初始化        if(schedule1.size() == 0){            for (int i = 0; i < 7; i++) {                Schedule schedule = new Schedule();                LocalDate lod = LocalDate.now();                schedule.setDay(lod.plusDays(i));                schedule1.add(schedule);            }            return;        }        // 更新当前医生的坐诊时间        //1、去除过期的时间        // !!注意:去除过去时间之后数组内部的元素个数会同步减少        for (int i = 0; i < schedule1.size(); i++) {            Schedule schedule = schedule1.get(i);            LocalDate lod = LocalDate.now();            LocalDate current = schedule.getDay();            if(current.equals(lod)){                break;            }            if(current.isBefore(lod)){                // !!注意:remove会删除数组内元素,并且使之后的元素序号全部向前移动一位                schedule1.remove(i);                i--;            }        }        // 更新之后七天的时间,只需要更新新的时间就可以了        // 得到最后一天的时间        LocalDate endTime = schedule1.get(schedule1.size()-1).getDay();        int number = schedule1.size();        for (int i = 0; i < 7 - number; i++) {            Schedule schedule = new Schedule();            schedule.setDay(endTime.plusDays(i + 1));            schedule1.add(schedule);        }    }    // 医生管理    public void doctorOperator(){        // 判断当前有没有科室,没有科室需要先创建科室        if (department.size() == 0){            System.out.println("系统无科室信息,请录入科室后再尝试操作");            return;        }        while (true) {            System.out.println("欢迎进入医生管理系统");            System.out.println("请选择您要进行的功能");            System.out.println("1:录入医生信息");            System.out.println("2:删除医生信息");            System.out.println("3:修改医生信息");            System.out.println("4:退出");            int com = sc.nextInt();            switch (com){                case 1:                    addDoctor();                    break;                case 2:                    deleteDoctor();                    break;                case 3:                    changeDoctor();                    break;                case 4:                    return;                default:                    System.out.println("您输入的指令有误,请重试");                    break;            }        }    }    private void changeDoctor() {        if(doctors.size() == 0){            System.out.println("请您录入医生信息后重试");            return;        }        System.out.println("请输入医生所属的科室名");        String nowDepartName = sc.next();        for (int i = 0; i < department.size(); i++) {            String departName = department.get(i).getDepartmentName();            if(nowDepartName.equals(departName)){                ArrayList<Doctor> doctors = department.get(i).getDoctor();                System.out.println("请选择需要修改信息的医生");                // 遍历科室所属医生                for (int i1 = 0; i1 < doctors.size(); i1++) {                    System.out.println("1、" + doctors.get(i).getName());                }                // 得到需要修改的医生对象                int docCom = sc.nextInt() -1;                if(docCom < 1|| docCom > doctors.size()){                    System.out.println("指令输入错误,请重新输入");                    return;                }                Doctor doctor = doctors.get(docCom);                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、医生擅长治疗方向");                    System.out.println("6、退出");                    int com = sc.nextInt();                    switch (com){                        case 1:System.out.println("请输入修改后的名字");doctor.setName(sc.next());System.out.println("修改成功");break;                        case 2:System.out.println("请输入修改后的性别");doctor.setGender(sc.next());System.out.println("修改成功");break;                        case 3:// 遍历所有科室名for (int i1 = 0; i1 < department.size(); i1++) {    System.out.println((i + 1) + "、" + department.get(i).getDepartmentName());}System.out.println("请选择要更改的科室");ArrayList<Doctor> doctors1 = department.get(sc.nextInt() - 1).getDoctor();doctors1.add(doctor);doctors.remove(doctor);System.out.println("科室更改完成");break;                        case 4:System.out.println("请输入修改后年龄");doctor.setAge(sc.nextInt());System.out.println("修改成功");break;                        case 5:System.out.println("请输入修改后治疗方向");doctor.setSkill(sc.next());System.out.println("修改成功");break;                        case 6:return;                        default:System.out.println("指令输入错误,请重试");break;                    }                }            }        }    }    private void deleteDoctor() {        if(doctors.size() == 0){            System.out.println("请您先录入医生后重试");            return;        }        System.out.println("请输入您要删除的医生编号");        String ID = sc.next();        for (int i = 0; i < doctors.size(); i++) {            String Id = doctors.get(i).getDoctorId();            if(ID.equals(Id)){                // 把医生从科室里面删除                Doctor doc = doctors.get(i);                for (int i1 = 0; i1 < department.size(); i1++) {                    if(department.get(i1).getDepartmentName().equals(doc.getDepartmentName())){                        for (int i2 = 0; i2 < department.get(i1).getDoctor().size(); i2++) {Doctor doctor = department.get(i1).getDoctor().get(i2);if (doctor.getDoctorId().equals(ID)){    department.get(i1).getDoctor().remove(i2);}                        }                    }                }                // 在医生数组中把医生删除                doctors.remove(i);                System.out.println("医生信息删除成功");                return;            }        }        System.out.println("ID错误,请重试");    }    // 添加医生    private void addDoctor() {        // 1、找见科室        System.out.println("新增医生");        Doctor doctor = new Doctor();        OUT:        while (true) {            System.out.println("请选择该医生要加入的科室");            for (int i = 0; i < department.size(); i++) {                Department de = department.get(i);                System.out.println((i + 1) + "、" + de.getDepartmentName());            }            int com = sc.nextInt();            if(com < 1 || com > department.size()){                System.out.println("您输入的指令错误,请重试");                continue OUT;            }            Department de1 = department.get(com-1);            // 将该医生所在的科室名加入            doctor.setDepartmentName(de1.getDepartmentName());            // 使用UUID工具类随机一个ID            doctor.setDoctorId(UUID.randomUUID().toString());            System.out.println("请输入医生的名字");            doctor.setName(sc.next());            System.out.println("请输入医生的性别");            doctor.setGender(sc.next());            System.out.println("请输入医生的年龄");            doctor.setAge(sc.nextInt());            System.out.println("请输入医生的擅长方向");            doctor.setSkill(sc.next());            // 入职时间            System.out.println("请输入医生的入职时间(格式: yyyy-MM-dd)");            LocalDate jointimeee = LocalDate.parse(sc.next());            doctor.setJoinTime(jointimeee);            // 把医生信息加入全部医生中            doctors.add(doctor);            // 把医生对象加入到所属的科室类中            de1.getDoctor().add(doctor);            break ;        }    }    // 科室管理    public void deportmentOperator(){        while (true) {            System.out.println("欢迎进入科室管理系统");            System.out.println("请选择您要进行的功能");            System.out.println("1:新增科室");            System.out.println("2:删除科室");            System.out.println("3:修改科室信息");            System.out.println("4:退出");            int command = sc.nextInt();            switch (command){                case 1:                    newDeportment(); // 新增科室                    break;                case 2:                    deleteDeportment(); // 删除科室                    break;                case 3:                    changeDeportment(); // 修改科室信息                    break;                case 4:                    return;                default:                    System.out.println("您输入的指令有误,请重新输入");            }        }    }    // 修改科室信息    private void changeDeportment() {        int number = department.size();        System.out.println("欢迎进入科室修改系统");        if (number == 0){            System.out.println("系统无科室信息,请录入科室后再尝试操作");            return;        }        while (true){            System.out.println("请输入您要修改的科室名");            String departName = sc.next();            for (int i = 0; i < number; i++) {                Department de = department.get(i);                String departName1 = de.getDepartmentName();                if(departName.equals(departName1)){                    ArrayList<Doctor> doctors = de.getDoctor(); // 获取Doctor对象,便于之后直接更改                    // 修改科室信息                    Boolean flag = true;                    while (true) {                        System.out.println("修改科室名请按1,退出请按2");                        int com = sc.nextInt();                        switch (com){case 1:    System.out.println("请输入修改后的科室名");    String newDepartName = sc.next();    de.setDepartmentName(newDepartName);    System.out.println("修改成功");    break;case 2:    return;default:    System.out.println("输入指令错误,请重试");    break;                        }                    }                }else { // 匹配不成功                    if(i == number -1 ){                        System.out.println("您输入的科室名错误,请重试");                    }                }            }        }    }    // 删除科室    private void deleteDeportment() {        int number = department.size();        if(number == 0){            System.out.println("系统无科室信息,请录入科室后再尝试操作");            return;        }        while (true) {            System.out.println("请输入需要删除的科室名");            String departName = sc.next();            for (int i = 0; i < number; i++) {                Department de = new Department();                de = department.get(i);                String departName1 = de.getDepartmentName();                if(departName.equals(departName1)){                    // 删除科室,如果没有医生了就删除,有就提示并保留                    ArrayList<Doctor> doctors = new ArrayList<>();                    doctors = de.getDoctor();                    if(doctors.size() == 0){                        department.remove(i);                        System.out.println("科室删除成功");                        return;                    }else {                        System.out.println("当前科室内仍然有医生在岗,请修改后重试");                        return;                    }                }else{                    if(i == number -1){                        System.out.println("科室信息不存在,请重试");                    }                }            }        }    }    // 新增科室    private void newDeportment() {        Department de = new Department();        OUT:        while (true) {        System.out.println("---新建科室---");        System.out.println("请输入科室名");        String departName = sc.next();        // 做判断,保证科室名不重复        for (int i = 0; i < department.size(); i++) {            String departName1 = department.get(i).getDepartmentName();            if(departName.equals(departName1)){                System.out.println("您输入的科室名重复,请重试");                continue OUT;            }        }        de.setDepartmentName(departName);        department.add(de); // 把新创建的科室对象加入数组中        break;        }    }    public Department getDepartByUser() {        Department department1;        while (true) {            for (int i = 0; i < department.size(); i++) {                System.out.println(i+1 + "、" + department.get(i).getDepartmentName());            }            int com = sc.nextInt()-1;            if(com < 0 || com > department.size()){                System.out.println("指令输入错误,请重新输入");                continue;            }            department1 = department.get(com);            return department1;        }    }    public Doctor getDoctorByUser(Department department) {        Doctor doctor;        while (true) {            for (int i = 0; i < department.getDoctor().size(); i++) {                System.out.println(i+1 + "、" + department.getDoctor().get(i).getName());            }            int com = sc.nextInt()-1;            if(com < 0 || com > department.getDoctor().size()){                System.out.println("指令输入错误,请重新输入");                continue;            }            doctor = department.getDoctor().get(com);            return doctor;        }    }}

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

来源地址:https://blog.csdn.net/qq_74521328/article/details/132418014

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

黑马程序员B站JAVA网课,医院管理系统代码(自写)

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

黑马程序员B站JAVA网课,医院管理系统代码(自写)

// 1、科室管理:新增科室,删除科室(如果有医生在,则不能删除该科室),修改科室。// 2、医生管理:录入医生信息,以及科室信息。修改医生信息(主要是修改个人信息和科室)// 3、坐诊信息设置:可
黑马程序员B站JAVA网课,医院管理系统代码(自写)
2023-12-22

编程热搜

  • Python 学习之路 - Python
    一、安装Python34Windows在Python官网(https://www.python.org/downloads/)下载安装包并安装。Python的默认安装路径是:C:\Python34配置环境变量:【右键计算机】--》【属性】-
    Python 学习之路 - Python
  • chatgpt的中文全称是什么
    chatgpt的中文全称是生成型预训练变换模型。ChatGPT是什么ChatGPT是美国人工智能研究实验室OpenAI开发的一种全新聊天机器人模型,它能够通过学习和理解人类的语言来进行对话,还能根据聊天的上下文进行互动,并协助人类完成一系列
    chatgpt的中文全称是什么
  • C/C++中extern函数使用详解
  • C/C++可变参数的使用
    可变参数的使用方法远远不止以下几种,不过在C,C++中使用可变参数时要小心,在使用printf()等函数时传入的参数个数一定不能比前面的格式化字符串中的’%’符号个数少,否则会产生访问越界,运气不好的话还会导致程序崩溃
    C/C++可变参数的使用
  • css样式文件该放在哪里
  • php中数组下标必须是连续的吗
  • Python 3 教程
    Python 3 教程 Python 的 3.0 版本,常被称为 Python 3000,或简称 Py3k。相对于 Python 的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0 在设计的时候没有考虑向下兼容。 Python
    Python 3 教程
  • Python pip包管理
    一、前言    在Python中, 安装第三方模块是通过 setuptools 这个工具完成的。 Python有两个封装了 setuptools的包管理工具: easy_install  和  pip , 目前官方推荐使用 pip。    
    Python pip包管理
  • ubuntu如何重新编译内核
  • 改善Java代码之慎用java动态编译

目录