Get the source code: Download it from "Resources" on the homepage of the blog!
Project Introduction
The hospital management system is divided into three roles: administrator, doctor, and patient;
The main functions of the administrator include:
home page, system management: doctor management, patient management, drug management; appointment management; medical history management; hospitalization information management
;
The main functions of the patient include: home page, medical history, hospitalization information, registration;
environmental needs
1. Operating environment: preferably java jdk 1.8, we are running on this platform. Other versions are also theoretically possible.
2. IDE environment: IDEA, Eclipse, Myeclipse can be used. IDEA is recommended;
3. Tomcat environment: Tomcat 7.x, 8.x, 9.x versions are available
4. Hardware environment: Windows 7/8/10 with more than 1G memory; or Mac OS;
5. Maven project: Yes; Check whether pom.xml is included in the source code directory; if so, it is a maven project, otherwise it is a non-maven project
6. Database: MySql version 5.7;
technology stack
1. Backend: SpringBoot
2. Front end: Layui+Freemaker
Instructions for use
1. Use Navicat or other tools to create a database with the corresponding name in mysql, and import the sql file of the project;
2. Use IDEA/Eclipse/MyEclipse to import the project. When importing from Eclipse/MyEclipse, if it is a maven project, please select maven;
If it is a maven project, please execute the maven clean;maven install command after the import is successful
3. Change the database configuration in the application.yml configuration file in the project to your own configuration, configure tomcat, and then run;
4. Run the project, enter http://localhost:8088 to log in
User management control layer:
@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();
}
}
@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";
}
}
Doctor management control layer:
/**
* 医生管理控制层
*/
@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";
}
}
Ward management control layer:
/***
* 病房管理控制层
*/
@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);
}
}
Get the source code: Download it from "Resources" on the homepage of the blog!