项目介绍
医院管理系统,分为管理员、医生、病人三种角色;
管理员主要功能包括:
首页、系统管理:医生管理、患者管理、药品管理;预约管理;病史管理;住院信息管理;管理员用户管理;
医生主要功能包括:首页、就医/查看病史;
病人主要功能包括:首页、病史、住院信息、挂号;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本;
技术栈
1. 后端:SpringBoot
2. 前端:Layui+Freemaker
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置,配置tomcat,然后运行;
4. 运行项目,输入http://localhost:8088 登录
效果图展示
核心代码
用户管理控制层
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
@RestController @RequestMapping (value = "/user" ) @Api (tags = "用户管理API" ) public class UserController {
@Autowired private IUserService iUserService;
/** * 登录验证 * * @param reqVO * @param model * @return */ @RequestMapping (value = "/dologin" , method = RequestMethod.POST) public BaseResponse<String> doLogin( @RequestBody @Validated UserLoginReqVO reqVO, Model model) {
return iUserService.doLogin(reqVO); }
/** * 保存用户注册信息,向用户发送激活链接 * * @param reqVO * @return */ @RequestMapping (value = "/doregister" , method = RequestMethod.POST) public BaseResponse<String> registered( @RequestBody @Validated UserRegisterReqVO reqVO, Model model) {
return iUserService.saveUserAndSendEmail(reqVO); }
/** * 获取登录日志 * * @param reqVO * @return */ @RequestMapping (value = "/getLoginfor" ,method = RequestMethod.GET) public PageRspVO<LoginInforRspVO> getLoginfor(BasePageReqVO reqVO) {
return iUserService.getLoginfor(reqVO); }
/** * 修改密码 * * @param reqVO * @return */ @PostMapping (value = "/changePassword" ) public BaseResponse<String> changePassword( @RequestBody @Validated ChangePasswordReqVO reqVO) {
return iUserService.changePassword(reqVO); }
/** * 个人资料设置 * * @return */ @PostMapping (value = "/getUserInfo" ) public List<UserInfoVO> getUserInfo() {
return iUserService.getUserInfo(); }
@PostMapping (value = "/changeUserInfo" ) public BaseResponse<String> changeUserInfo( @RequestBody @Validated UserInfoVO reqVO) {
return iUserService.changeUserInfo(reqVO); }
@PostMapping (value = "/getAnnContent" ) public AnnRspVO getAnnContent( @RequestParam String id) {
return iUserService.getAnnContent(id); }
@PostMapping (value = "/addAnotherRole" ) public BaseResponse<String> addAnotherRole( @RequestBody @Validated AccountRoleVO reqVO) {
return iUserService.addAnotherRole(reqVO); }
/** * 获取所有角色 * @param * @return */ @PostMapping (value = "/getAllRole" ) public List<GetAllRoleRspVO> getAllRole() { return iUserService.getAllRole(); }
} |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
@Controller public class DeptController { @Autowired private DeptService deptService;
/** * 分页查询 */ @RequestMapping ( "/findDept" ) public String findDept(String deptNo, String deptName,Integer pageIndex , Integer pageSize, Model model,HttpSession session){ PageInfo<Dept> de = deptService.findPageInfo(deptNo,deptName, pageIndex,pageSize); model.addAttribute( "de" ,de); session.setAttribute( "u" ,deptNo); session.setAttribute( "t" ,deptName); return "Dept_list" ; }
/** * 添加管理员信息 */ @RequestMapping (value = "/addDept" ,method = RequestMethod.POST) @ResponseBody public String addDept( @RequestBody Dept dept) { int a = deptService.addDept(dept); return "Dept_list" ; }
/** * 修改信息 */ @RequestMapping ( value = "/updateDept" , method = RequestMethod.POST) public String updateDept(Dept dept) { int a = deptService.updateDept(dept); return "redirect:/findDept" ; }
/** * 根据Id搜索; */ @RequestMapping ( "/findDeptById" ) public String findDeptById(Integer deptId, HttpSession session) { Dept de2= deptService.findDeptById(deptId); session.setAttribute( "de2" ,de2); return "Dept_edit" ; }
/** * 导出Excel */ @RequestMapping (value = "/exportDeptlist" , method = RequestMethod.POST) @ResponseBody public List<Dept> exportDept(){ List<Dept> depts = deptService.getAll(); return depts; }
/** * 部门人员信息查询 */ @RequestMapping (value = "/findDeptPersonnel" ) public String findClassStudent(Dept dept,Model model, HttpSession session) { List<Dept> dep = deptService.findDeptPersonnel(dept); model.addAttribute( "dep" ,dep); return "dept_Personnellist" ; }
} |
医生管理控制层
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
/** * 医生管理控制层 */
@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 ) { model.addAttribute( "name" , doctor.getUser().getName()); } model.addAttribute( "pageBean" , doctorService.findList(doctor, pageBean)); return "admin/doctor/list" ; }
/** * 医生添加页面 * @param model * @return */ @RequestMapping (value = "/add" , method = RequestMethod.GET) public String add(Model model) {
model.addAttribute( "departments" , departmentService.findAllDepartment()); return "admin/doctor/add" ; }
/** * 医生添加提交 * @param doctor * @return */ @RequestMapping (value = "/add" , method = RequestMethod.POST) @ResponseBody public Result<Boolean> add(Doctor doctor) {
CodeMsg validate = ValidateEntityUtil.validate(doctor);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) { return Result.error(validate); } 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.emailFormat(doctor.getUser().getEmail())) { return Result.error(CodeMsg.ADMIN_PUBLIC_EMAIL); } if (!StringUtil.isMobile(doctor.getUser().getMobile())) { return Result.error(CodeMsg.ADMIN_PUBLIC_MOBILE); }
Role role = roleService.find(Doctor.DOCTOR_ROLE_ID); String dNo = StringUtil.generateSn(Doctor.PATIENT_ROLE_DNO);
int age = DateUtil.getAge(doctor.getUser().getBirthDay()); if (age < 0 ) { return Result.error(CodeMsg.ADMIN_PUBLIC_AGE); }
doctor.setDoctorDno(dNo); doctor.getUser().setPassword(dNo); doctor.getUser().setUsername(dNo); doctor.getUser().setRole(role);
User user = doctor.getUser(); user.setAge(age);
User save = userService.save(user); if (userService.save(user) == null ) { return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR); } operaterLogService.add( "添加用户,用户名:" + user.getUsername()); doctor.setUser(save);
if (doctorService.save(doctor) == null ) { return Result.error(CodeMsg.ADMIN_DOCTOR_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( "doctor" , doctorService.find(id)); model.addAttribute( "departments" , departmentService.findAllDepartment()); return "admin/doctor/edit" ; }
/** * 医生修改提交 * @param doctor * @return */ @RequestMapping (value = "/edit" , method = RequestMethod.POST) @ResponseBody public Result<Boolean> edit(Doctor doctor) { Doctor findDoctor = doctorService.find(doctor.getId());
List<Doctor> doctors = doctorService.findByDoctorDno(findDoctor.getDoctorDno());
if (doctors.size() > 1 || doctors.size() <= 0 ) { return Result.error(CodeMsg.ADMIN_PATIENT_PNO_ERROR); }
if (doctors.get( 0 ).getId() != doctor.getId()) { return Result.error(CodeMsg.ADMIN_PATIENT_PNO_ERROR); } 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.emailFormat(doctor.getUser().getEmail())) { return Result.error(CodeMsg.ADMIN_PUBLIC_EMAIL); } if (!StringUtil.isMobile(doctor.getUser().getMobile())) { return Result.error(CodeMsg.ADMIN_PUBLIC_MOBILE); }
int age = DateUtil.getAge(doctor.getUser().getBirthDay()); if (age < 0 ) { return Result.error(CodeMsg.ADMIN_PUBLIC_AGE); }
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" ; }
/** * 提交修改个人出诊状态 * @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" ); doctorService.save(doc); return Result.success( true ); }
/** * 医生查询接单记录 * @param model * @param pageBean * @return */ @RequestMapping (value = "/orderRecord" ,method = RequestMethod.GET) public String doctorOrderRecords(Model model, PageBean<OrderReceiving> pageBean) { //获取医生登录的信息 Doctor loginDoctorUser = doctorService.findByLoginDoctorUser(); model.addAttribute( "title" , "出诊信息" ); model.addAttribute( "pageBean" , orderReceivingService.findByDoctorId(pageBean,loginDoctorUser.getId())); return "admin/doctor/orderRecord" ; }
/** * 查看自己科室所有医生信息 * @param model * @param pageBean * @return */ @RequestMapping (value = "/findByDepartment" , method = RequestMethod.GET) public String AllDoctorByDepartment(Model model,PageBean<Doctor> pageBean) { Doctor loginDoctorUser = doctorService.findByLoginDoctorUser(); model.addAttribute( "title" , "本科室所有医生列表" ); model.addAttribute( "pageBean" , doctorService.findAllByDepartment(pageBean, loginDoctorUser.getDepartment().getId())); return "admin/doctor/doctorInformation" ; }
/** * 医生完成出诊订单 * @param id * @return */ @RequestMapping (value = "/orderRecord" ,method = RequestMethod.POST) @ResponseBody public Result<Boolean>modifyVisitStatus(Long id){ boolean flag = doctorService.modifyVisitStatus(id); if (flag){ return Result.success( true ); } return Result.error(CodeMsg.ADMIN_DOCTOR_CANNOT_REPEATED); }
/** * 管理员查看所有订单信息 * @param model * @param orderReceiving * @param pageBean * @return */ @RequestMapping (value= "/allOrderInformation" ,method = RequestMethod.GET) public String findAll(Model model,OrderReceiving orderReceiving, PageBean<OrderReceiving> pageBean){ model.addAttribute( "title" , "出诊信息" ); model.addAttribute( "pageBean" ,orderReceivingService.findList(orderReceiving,pageBean)); return "admin/doctor/allOrderInformation" ; }
/** * 医生查询负责的住院信息 */ @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" ; }
} |
病房管理控制层
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
/*** * 病房管理控制层 */ @Controller @RequestMapping ( "/room" ) public class RoomController { @Autowired private RoomService roomService; @Autowired private OperaterLogService operaterLogService; @Autowired private BedService bedService; @Autowired private RoomTypeService roomTypeService;
/*** * 病房分页查询 * @param model * @param pageBean * @param room * @return */ @RequestMapping ( "/list" ) String list(Model model, PageBean<Room> pageBean, Room room){ model.addAttribute( "title" , "病房列表" ); model.addAttribute( "roomNo" , room.getRoomNo()); model.addAttribute( "pageBean" ,roomService.findAll(room,pageBean)); return "admin/room/list" ; } /** * 新增病房页面 * @param model * @return */ @RequestMapping (value= "/add" ) public String add(Model model){ model.addAttribute( "roomType" ,roomTypeService.findList()); return "admin/room/add" ; }
/** * 病房添加表单提交处理 * @param room * @return */ @RequestMapping (value= "/add" ,method= RequestMethod.POST) @ResponseBody public Result<Boolean> add(Room room){ //用统一验证实体方法验证是否合法 CodeMsg validate = ValidateEntityUtil.validate(room); if (validate.getCode() != CodeMsg.SUCCESS.getCode()){ return Result.error(validate); } //设置可用床数 int total = room.getTotal(); room.setUsable(total); if (Objects.isNull(room.getRoomNo())){ return Result.error(CodeMsg.ADMIN_ROOM_NO_ISEXIST); } if (roomService.isExistRoomNo(room.getRoomNo(),0L)){ return Result.error(CodeMsg.ADMIN_ROOM_EXIST); } //到这说明一切符合条件,进行数据库新增 if (roomService.save(room) == null ){ return Result.error(CodeMsg.ADMIN_ROOM_ADD_ERROR); }
/* //判断是否床位存在 if(bedService.find(room.getId())!=null){ return Result.error(CodeMsg.ADMIN_BED_EXIST); }*/ //循环total向床位表添加相应床位 for ( int i = 0 ;i<total ; i++ ){ Bed bed = new Bed(); bed.setBedNo(i+ 1 ); // 1 2 3 4 bed.setRoom(room); //进行数据库新增 bedService.save(bed); } operaterLogService.add( "添加病房,病房号:" + room.getRoomNo()); return Result.success( true ); }
/* */ /** * 病房编辑页面 * @param model * @return */ /* @RequestMapping(value="/edit",method=RequestMethod.GET) public String edit(Model model,@RequestParam(name="id",required=true)Long id){ model.addAttribute("roomType",roomTypeService.findList()); model.addAttribute("room",roomService.find(id)); return "admin/room/edit"; } */ /** * 编辑病房类型信息表单提交处理 * @param room * @return */ /* @RequestMapping(value="/edit",method=RequestMethod.POST) @ResponseBody public Result<Boolean> edit(Room room){ //用统一验证实体方法验证是否合法 CodeMsg validate = ValidateEntityUtil.validate(room); if(validate.getCode() != CodeMsg.SUCCESS.getCode()){ return Result.error(validate); } if(room.getId() == null || room.getId().longValue() <= 0){ return Result.error(CodeMsg.ADMIN_ROOM_NO_EXIST); } if(roomService.isExistRoomNo(room.getRoomNo(),room.getId())){ return Result.error(CodeMsg.ADMIN_ROOM_EXIST); } //到这说明一切符合条件,进行数据库保存 Room findById = roomService.find(room.getId()); //将提交的科室信息指定字段复制到已存在的RoomType对象中,该方法会覆盖新字段内容 BeanUtils.copyProperties(room, findById, "id","createTime","updateTime","total","usable"); 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 ); } } |
以上就是Java实战之医院管理系统的实现的详细内容,更多关于Java医院管理系统的资料请关注其它相关文章!
原文链接:https://blog.csdn.net/m0_66863468/article/details/124336655
查看更多关于Java实战之医院管理系统的实现的详细内容...