项目介绍
医院管理系统,分为管理员、医生、病人三种角色;
管理员主要功能包括:
首页、系统管理:医生管理、患者管理、药品管理;预约管理;病史管理;住院信息管理;管理员用户管理;
医生主要功能包括:首页、就医/查看病史;
病人主要功能包括:首页、病史、住院信息、挂号;
环境需要
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 登录
效果图展示
核心代码
用户管理控制层
@RestController
@RequestMapping(value = "/user")
@Api(tags = "用户管理API")
public class UserController {
@Autowired
private IUserService iUserService;
@RequestMapping(value = "/dologin", method = RequestMethod.POST)
public BaseResponse<String> doLogin(@RequestBody @Validated UserLoginReqVO reqVO, Model model) {
return iUserService.doLogin(reqVO);
}
@RequestMapping(value = "/doregister", method = RequestMethod.POST)
public BaseResponse<String> registered(@RequestBody @Validated UserRegisterReqVO reqVO, Model model) {
return iUserService.saveUserAndSendEmail(reqVO);
}
@RequestMapping(value = "/getLoginfor",method = RequestMethod.GET)
public PageRspVO<LoginInforRspVO> getLoginfor(BasePageReqVO reqVO) {
return iUserService.getLoginfor(reqVO);
}
@PostMapping(value = "/changePassword")
public BaseResponse<String> changePassword(@RequestBody @Validated ChangePasswordReqVO reqVO) {
return iUserService.changePassword(reqVO);
}
@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);
}
@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";
}
@RequestMapping("/findDeptById")
public String findDeptById(Integer deptId, HttpSession session) {
Dept de2= deptService.findDeptById(deptId);
session.setAttribute("de2",de2);
return "Dept_edit";
}
@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";
}
}
医生管理控制层
@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;
@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";
}
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add(Model model) {
model.addAttribute("departments", departmentService.findAllDepartment());
return "admin/doctor/add";
}
@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);
}
@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";
}
@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);
}
@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);
}
@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";
}
@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);
}
@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";
}
@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";
}
@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);
}
@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";
}
}
病房管理控制层
@Controller
@RequestMapping("/room")
public class RoomController {
@Autowired
private RoomService roomService;
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private BedService bedService;
@Autowired
private RoomTypeService roomTypeService;
@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";
}
@RequestMapping(value="/add")
public String add(Model model){
model.addAttribute("roomType",roomTypeService.findList());
return "admin/room/add";
}
@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);
}
//循环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);
}
@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医院管理系统的资料请关注编程网其它相关文章!