基于javaweb+mysql的springboot医院分诊挂号住院管理系统(java+springboot+freemarker+mysql+maven)

基于javaweb+mysql的springboot医院分诊挂号住院管理系统(java+springboot+freemarker+mysql+maven)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb的SpringBoot医院分诊挂号住院管理系统(java+springboot+freemarker+mysql+maven)

主要实现了从挂号预约到分诊住院出诊等一些列医院基本操作流程的全部功能,系统分医生、患者、管理员三个角色,除基础脚手架外,实现的功能有:

管理员:医生管理、病人管理、科室管理、病房类型管理、病房管理、床位自动生成、统计管理(病人统计、医生出诊统计、总收入统计)等。

患者/病人:登录、修改个人信息、挂号、查看就医信息(挂号、支付记录、住院记录)等。

医生:登录、修改个人信息、出诊叫号、开具药方、安排住院、查看自己出诊记录、查看自己科室医生、设置自己是否可出诊。

运行环境:windows/Linux均可、jdk1.8、mysql5.7、idea/eclipse均可。


/**
 * 医生管理控制层
 */

@Controller
@RequestMapping("/doctor")
public class DoctorController {

    @Autowired
    private DoctorService doctorService;

    @Autowired
    private UserService userService;

    @Autowired
    private RoleService roleService;

    @Autowired
    private OperaterLogService operaterLogService;

    @Autowired
    private DepartmentService departmentService;

    @Autowired
    private OrderReceivingService orderReceivingService;

    @Autowired
    private BedAllotService bedAllotService;

    /**
     * 跳转医生列表页面
     * @param model
     * @param doctor
     * @param pageBean
     * @return
     */
    @RequestMapping(value = "/list")
    public String list(Model model, Doctor doctor, PageBean<Doctor> pageBean) {
        model.addAttribute("title", "医生列表");
        if (doctor.getUser() != null) {
            Doctor doctor = doctorService.find(id);
            doctorService.deleteById(id);
            userService.delete(doctor.getUser().getId());
        } catch (Exception e) {
            return Result.error(CodeMsg.ADMIN_DOCTOR_DELETE_ERROR);
        }
        operaterLogService.add("添加用户,用户ID:" + id);
        return Result.success(true);
    }

    /**
     * 修改个人出诊状态页面
     * @param model
     * @return
     */
    @RequestMapping(value = "/updateStatus", method = RequestMethod.GET)
    public String updateDoctorStatus(Model model) {
        Doctor doctor = doctorService.findByLoginDoctorUser();
        model.addAttribute("title","个人出诊信息修改");
        model.addAttribute("doctor", doctor);
        return "admin/doctor/visitingStatus";
    }

    /**
     * 提交修改个人出诊状态
     * @param doctor
     * @return
     */
    @RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> editStatus(Doctor doctor) {
        Doctor doc = doctorService.findByLoginDoctorUser();
        if(Objects.isNull(doctor.getUser().getEmail())){
            return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_EMAIL);
        }
        if(Objects.isNull(doctor.getUser().getMobile())){
            return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_MOBILE);
        }
        if (!StringUtil.isMobile(doctor.getUser().getMobile())) {
            return Result.error(CodeMsg.ADMIN_PUBLIC_MOBILE);
        }
        if (!StringUtil.emailFormat(doctor.getUser().getEmail())) {
            return Result.error(CodeMsg.ADMIN_PUBLIC_EMAIL);
        }
        User user = doc.getUser();
        user.setEmail(doctor.getUser().getEmail());
        user.setMobile(doctor.getUser().getMobile());
        user.setStatus(doctor.getStatus());
        doc.setStatus(doctor.getStatus());
        doc.setDescription(doctor.getDescription());
        doc.setExperience(doctor.getExperience());
        BeanUtils.copyProperties(user, doctor.getUser(), "id", "createTime", "updateTime", "password", "username", "role", "sex", "age", "birthday");
        if (age < 0) {
            return   Result.error(CodeMsg.ADMIN_PUBLIC_AGE);
        }

        User user = patient.getUser();
        user.setAge(age);

        BeanUtils.copyProperties(user,findPatient.getUser(), "id","createTime","updateTime","password","username","role");

        userService.save(findPatient.getUser());
        patientService.save(findPatient);

        return Result.success(true);
    }

    /**
     * 删除病人用户
     * @param id
     * @return
     */
    @RequestMapping(value="/delete",method=RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
        try {
            Patient patient = patientService.find(id);
            patientService.deleteById(id);
            userService.delete(patient.getUser().getId());
        } catch (Exception e) {
            return Result.error(CodeMsg.ADMIN_UPATIENT_ERROR);
        }
        operaterLogService.add("添加病人用户,病人用户ID:" + id);
        return Result.success(true);
    }

    /**
     * 病人查询个人住院信息
     */
    @RequestMapping(value="/bedAllot")
    public String bedAllotSelf(Model model,PageBean<BedAllot> pageBean){
        Patient loginPatientUser = patientService.findByLoginPatientUser();
        Long patientId = loginPatientUser.getId();
        model.addAttribute("title","住院信息");
        model.addAttribute("pageBean",bedAllotService.findByPatient(pageBean,patientId));
        return "admin/patient/bedAllot";

        findDoctor.setDepartment(doctor.getDepartment());
        findDoctor.setDescription(doctor.getDescription());
        findDoctor.setExperience(doctor.getExperience());

        User user = doctor.getUser();
        user.setAge(age);

        BeanUtils.copyProperties(user, findDoctor.getUser(), "id", "createTime", "updateTime", "password", "username", "role");

        userService.save(findDoctor.getUser());
        doctorService.save(findDoctor);

        return Result.success(true);
    }

    /**
     * 删除医生用户
     * @param id
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> delete(@RequestParam(name = "id", required = true) Long id) {
        try {
            Doctor doctor = doctorService.find(id);
            doctorService.deleteById(id);
            userService.delete(doctor.getUser().getId());
        } catch (Exception e) {
            return Result.error(CodeMsg.ADMIN_DOCTOR_DELETE_ERROR);
        }
        operaterLogService.add("添加用户,用户ID:" + id);
        return Result.success(true);
    }

    /**
     * 修改个人出诊状态页面
     * @param model
     * @return
     */
    @RequestMapping(value = "/updateStatus", method = RequestMethod.GET)
    public String updateDoctorStatus(Model model) {
        Doctor doctor = doctorService.findByLoginDoctorUser();
        model.addAttribute("title","个人出诊信息修改");
        model.addAttribute("doctor", doctor);
        return "admin/doctor/visitingStatus";
    @ResponseBody
    public List<Bed> findFreeBed(@RequestParam("id") Long id) {
        List<Bed> beds = bedService.findFreeBed(id);
        return beds;
    }

    /**
     * 查看出诊详情
     * @param model
     * @param orderReceivingId
     * @return
     */
    @RequestMapping("/detail")
    public String detail(Model model, @RequestParam("id") Long orderReceivingId) {
        ReceivingDTO dto = orderReceivingService.detailReceiving(orderReceivingId);
        model.addAttribute("dto", dto);
        model.addAttribute("size", dto.getServiceNames().size());
        return "admin/receiving/detail";
    }

    /**
     * 进行支付
     * @param
     * @return
     */
    @RequestMapping(value="/pay",method=RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> orderRegistration(@RequestParam(name = "id",required = true)Long id){
        boolean flag = orderReceivingService.updateStatus(id);
        if(flag){
            return Result.success(true);
        }else {
            return Result.error(CodeMsg.ADMIN_PAY_ERROR);
        }
    }

    /**
     * 支付服务详情
     */
    @RequestMapping(value="/details")
    public String details(Model model,OrderReceiving orderReceiving){
        model.addAttribute("total","详情");
        Long id = orderReceiving.getId();
     * 根据病房类型查询病房
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/room/type", method = RequestMethod.POST)
    @ResponseBody
    public List<Room> findFreeRoom(@RequestParam("id") Long id) {
        List<Room> rooms = roomService.findByRoomTypeId(id).stream().filter(o -> o.getUsable() > 0).collect(Collectors.toList()); //todo 改成sql查询
        return rooms;
    }

    /**
     * 根据病房查询空余病床
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/room", method = RequestMethod.POST)
    @ResponseBody
    public List<Bed> findFreeBed(@RequestParam("id") Long id) {
        List<Bed> beds = bedService.findFreeBed(id);
        return beds;
    }

    /**
     * 查看出诊详情
     * @param model
     * @param orderReceivingId
     * @return
     */
    @RequestMapping("/detail")
    public String detail(Model model, @RequestParam("id") Long orderReceivingId) {
        ReceivingDTO dto = orderReceivingService.detailReceiving(orderReceivingId);
        model.addAttribute("dto", dto);
        model.addAttribute("size", dto.getServiceNames().size());
        return "admin/receiving/detail";
    }

    /**
     * 进行支付
     * @param
     * @return
     */
    @RequestMapping(value="/pay",method=RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> orderRegistration(@RequestParam(name = "id",required = true)Long id){
        boolean flag = orderReceivingService.updateStatus(id);
        if(flag){
	public Result<Boolean> add(Menu menu){
		if(menu == null){
			Result.error(CodeMsg.DATA_ERROR);
		}
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(menu);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		if(menu.getParent() != null){
			if(menu.getParent().getId() == null){
				menu.setParent(null);
			}
		}
		//表示验证都通过,开始添加数据库
		if(menuService.save(menu) == null){
			Result.error(CodeMsg.ADMIN_MENU_ADD_ERROR);
		}
		//数据库添加操作成功,记录日志
		operaterLogService.add("添加菜单信息【" + menu + "】");
		return Result.success(true);
	}
	
	/**
	 * 菜单编辑页面
	 * @param model
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.GET)
	public String eidt(Model model,@RequestParam(name="id",required=true)Long id){
		List<Menu> findAll = menuService.findAll();
		model.addAttribute("title","菜单列表");
		model.addAttribute("topMenus",MenuUtil.getTopMenus(findAll));
		model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
		model.addAttribute("menu",menuService.find(id));
		return "admin/menu/edit";
	}
	
	/**
	 * 菜单编辑页面表单提交处理
	 * @param request
	 * @param menu

}

/**
 * 病人信息管理控制层
 */
@Controller
@RequestMapping("/patient")
public class PatientController {

    @Autowired
    private PatientService patientService;

    @Autowired
    private UserService userService;

    @Autowired
    private RoleService roleService;

    @Autowired
    private OperaterLogService operaterLogService;
    @Autowired
    private BedAllotService bedAllotService;

    /**
        patient.getUser().setAge(age);
        patient.setPatientPno(pNo);
        patient.getUser().setPassword(pNo);
        patient.getUser().setUsername(pNo);
        patient.getUser().setRole(role);
        User user = patient.getUser();

        User save = userService.save(user);
        if(userService.save(user) == null){
            return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR);
        }
        operaterLogService.add("添加用户,用户名:" + user.getUsername());
        patient.setUser(save);

        if (patientService.save(patient) == null) {
            return Result.error(CodeMsg.ADMIN_PATIENT_ADD_EXIST);
        }
        return Result.success(true);
    }

    /**
     * 跳转到修改病人页面
     * @param model
     * @param id
     * @return
     */
    @RequestMapping(value="/edit",method=RequestMethod.GET)
    public String edit(Model model,@RequestParam(name="id")Long id){
        model.addAttribute("patient", patientService.find(id));
        return "admin/patient/edit";
    }

    /**
     * 修改病人
     * @param patient
     * @return
     */
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> edit(Patient patient) {
        Patient findPatient = patientService.find(patient.getId());

        List<Patient> patients = patientService.findByPatientPno(findPatient.getPatientPno());

        if (patients.size() > 1 || patients.size() <= 0) {
            return Result.error(CodeMsg.ADMIN_PATIENT_PNO_ERROR);
        }

	/**
	 * 验证输入的邮箱格式是否符合
	 * @param email
	 * @return 是否合法
	 */
	public static boolean emailFormat(String email)
	{
		boolean tag = true;
		final String pattern1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
		final Pattern pattern = Pattern.compile(pattern1);
		final Matcher mat = pattern.matcher(email);
		if (!mat.find()) {
			tag = false;
		}
		return tag;
	}

	/**
	 * 验证是否是手机号
	 * @param
	 * @return
	 */
	public static boolean  isMobile(String str) {
		Pattern p = null;
		Matcher m = null;
		boolean b = false;
		String s2="^1[0-9]{10}$";// 验证手机号
		if(StringUtils.isNotBlank(str)){
			p = Pattern.compile(s2);
			m = p.matcher(str);
			b = m.matches();
		}
		return b;
	}

	/**
	 * 生成唯一字符串
	 * @return
	 */
	public static String generateSn(){
		return UUID.randomUUID().toString().toUpperCase().replace("-", "");
	}

	public static String getMac(){
		String mac = "";
		try {
			InetAddress localHost = InetAddress.getLocalHost();
			byte[] hardwareAddress = NetworkInterface.getByInetAddress(localHost).getHardwareAddress();
			StringBuffer sb = new StringBuffer("");

/***
 * 统计控制层
 */
@Controller
@RequestMapping("/statistical")
public class StatisticalController {
    @Autowired
    private PayServiceService payServices;
    @Autowired
    private DoctorService doctorService;

    @Autowired
    private OrderRegistrationService orderRegistrationService;

    @Autowired
    private PatientService patientService;

    @Autowired
    private StatisticalService statisticalService;

    /**
     * 总收入,医生接单,病人总数统计页面
     * @param model
     * @return
     */
    @RequestMapping(value = "/list")
    public String list(Model model) {
        List<PayService> countMoney = payServices.findAll();
        BigDecimal money = new BigDecimal(0.00);
        for (int i = 0; i < countMoney.size(); i++) {
            money = money.add(new BigDecimal(String.valueOf(countMoney.get(i).getMoney())));
        }
    public Result<Boolean> add(OrderRegistration orderRegistration){
        //用统一验证实体方法验证是否合法
        CodeMsg validate = ValidateEntityUtil.validate(orderRegistration);
        if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
            return Result.error(validate);
        }
        if(orderRegistration.getDepartment() == null || orderRegistration.getDepartment().getId() == null){
            return Result.error(CodeMsg.ADMIN_ORDER_REGISTRATION_DEPARTMENT_EMPTY);
        }

        Patient loginPatientUser = patientService.findByLoginPatientUser();
        if(loginPatientUser == null){
            return Result.error(CodeMsg.ADMIN_PATIENT_NO_EXIST);
        }

        //设置挂号的病人
        orderRegistration.setPatient(loginPatientUser);

        //判断该病人提交的挂单是否存在且状态为未完成或者未撤销
        if(orderRegistrationService.isExistOrderRegistration(loginPatientUser.getId(),orderRegistration.getDepartment().getId(),orderRegistration.getStatus(),0l)){
            return Result.error(CodeMsg.ADMIN_ORDER_REGISTRATION_EXIST);
        }

        //到这说明一切符合条件,进行数据库新增
        if(orderRegistrationService.save(orderRegistration) == null){
            return Result.error(CodeMsg.ADMIN_ORDER_REGISTRATION_ADD_ERROR);
        }
        operaterLogService.add("添加挂号信息,挂号科室:" + orderRegistration.getDepartment());
        return Result.success(true);
    }

    /**
     * 取消挂号
     * @param
     * @return
     */
    @RequestMapping(value="/recall",method=RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> orderRegistration(@RequestParam(name = "id",required = true)Long id){
        boolean flag = orderRegistrationService.updateStatus(id);
        if(flag){
            return Result.success(true);
        }else {
        if(roomService.save(findById) == null){
            return Result.error(CodeMsg.ADMIN_ROOM_EDIT_ERROR);
        }
        operaterLogService.add("编辑病房,病房号:" + room.getRoomNo());
        return Result.success(true);
    }*/

    /**
     * 删除病房
     * @param id
     * @return
     */
    @RequestMapping(value="/delete",method=RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
        try {
            roomService.delete(id);
        } catch (Exception e) {
            return Result.error(CodeMsg.ADMIN_ROOM_DELETE_ERROR);
        }
        operaterLogService.add("删除病房,病房ID:" + id);
        return Result.success(true);
    }
}

    @RequestMapping(value="/bedAllot")
    public String bedAllotSelf(Model model,PageBean<BedAllot> pageBean){
        Doctor loginDoctorUser = doctorService.findByLoginDoctorUser();
        Long doctorId = loginDoctorUser.getId();
        model.addAttribute("title","住院信息");
        model.addAttribute("pageBean",bedAllotService.findByDoctor(pageBean,doctorId));
        return "admin/doctor/bedAllot";
    }

}

}

/**
 * 系统控制器
 *
 */
        model.addAttribute("roomTypes", roomTypeService.findList());

        return "admin/receiving/edit";
    }

    /**
     * 出诊提交
     * @param dto
     * @return
     */
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> edit(@RequestBody ReceivingDTO dto) {

        OrderReceiving orderReceive = dto.getOrderReceive();

        //用统一验证实体方法验证是否合法
        CodeMsg validate = ValidateEntityUtil.validate(orderReceive);
        if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
            return Result.error(validate);
        }

        if (Objects.isNull(orderReceive.getDoctor()) || Objects.isNull(orderReceive.getDoctor().getId())) {
            return Result.error(CodeMsg.ADMIN_ORDER_RECEIVING_DOCTOR_ERROR);
        }

        if (orderReceivingService.findByOrderRegistrationId(orderReceive.getOrderRegistration().getId()) != null) {
            return Result.error(CodeMsg.ADMIN_ORDER_RECEIVING_EXIST);
        }
        List<String> serviceNames = dto.getServiceNames();
        List<BigDecimal> money = dto.getMoney();

        if (CollectionUtils.isEmpty(money) || CollectionUtils.isEmpty(serviceNames)) {
            return Result.error(CodeMsg.ADMIN_ORDER_RECEIVING_PAY_EMPTY);
        }

        OrderRegistration orderRegistration = orderRegistrationService.find(orderReceive.getOrderRegistration().getId());//挂号订单状态改为2 看病中

        if (Objects.isNull(orderReceive.getBed()) || Objects.isNull(orderReceive.getBed().getId())) {
            orderReceive.setBed(null);
        }

        if (Objects.nonNull(orderReceive.getBed()) && Objects.nonNull(orderReceive.getBed().getId())) {
            List<BedAllot> bedAllots = bedAllotService.findByPatientId(orderReceive.getPatient().getId());
            List<BedAllot> allots = bedAllots.stream().filter(o -> o.getDischarge() == null).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(allots)) {
                return Result.error(CodeMsg.ADMIN_ORDER_RECEIVING_PATIENT_BED_ALLOT_ERROR);
            }

            Bed bed = bedService.find(orderReceive.getBed().getId());//根据病床id查找信息
            Room room = bed.getRoom();
            int usable = room.getUsable() - 1;  //病房可用数量减一
            if (usable < 0) {
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/room/type", method = RequestMethod.POST)
    @ResponseBody
    public List<Room> findFreeRoom(@RequestParam("id") Long id) {
        List<Room> rooms = roomService.findByRoomTypeId(id).stream().filter(o -> o.getUsable() > 0).collect(Collectors.toList()); //todo 改成sql查询
        return rooms;
    }

    /**
     * 根据病房查询空余病床
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/room", method = RequestMethod.POST)
    @ResponseBody
    public List<Bed> findFreeBed(@RequestParam("id") Long id) {
        List<Bed> beds = bedService.findFreeBed(id);
        return beds;
    }

    /**
     * 查看出诊详情
     * @param model
     * @param orderReceivingId
     * @return
     */
    @RequestMapping("/detail")
    public String detail(Model model, @RequestParam("id") Long orderReceivingId) {
        ReceivingDTO dto = orderReceivingService.detailReceiving(orderReceivingId);
        model.addAttribute("dto", dto);
        model.addAttribute("size", dto.getServiceNames().size());
        return "admin/receiving/detail";
    }

    /**
     * 进行支付
     * @param
     * @return

/***
 * 统计控制层
 */
@Controller
@RequestMapping("/statistical")
public class StatisticalController {
    @Autowired
    private PayServiceService payServices;
    @Autowired
    private DoctorService doctorService;

    @Autowired
    private OrderRegistrationService orderRegistrationService;

    @Autowired
    private PatientService patientService;

    @Autowired
    private StatisticalService statisticalService;

    /**
     * 总收入,医生接单,病人总数统计页面
     * @param model
     * @return
     */
    @RequestMapping(value = "/list")
    public String list(Model model) {
        List<PayService> countMoney = payServices.findAll();
        BigDecimal money = new BigDecimal(0.00);
        for (int i = 0; i < countMoney.size(); i++) {
            money = money.add(new BigDecimal(String.valueOf(countMoney.get(i).getMoney())));
        }
        //总收入统计
        model.addAttribute("TotalRevenue", money);
        //医生接单统计
        model.addAttribute("OrderNumCount", doctorService.selectCountByOrderReceiving());
        //病人总数统计
        model.addAttribute("patientTotal",patientService.total());

        return "admin/statistical/statistical";
    }

    /**
     * 按月份统计住院人数
     * @return

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

java毕业

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值