+-
Java项目:医院住院管理系统(java+SSM+jsp+mysql+maven)

一、项目简述

功能包括: 住院病人管理,住院病房管理,医生管理,药品管理,仪 器管理等等。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。

 

后台角色操作servi 202ef ce服务:

/**
* 后台角色操作service
*/

@Service
public class RoleService {

@Autowired
private RoleDao roleDao;

/**
* 角色添加/编辑
* @param role
* @return
*/
public Role save(Role role){
return roleDao.save(role);
}

/**
* 获取所有的角色列表
* @return
*/
public List<Role> findAll(){
return roleDao.findAll();
}

/**
* 获取不是医生或病人的其他角色
*/
public List<Role> findSome(){
return roleDao.findSome();
}

/**
* 分页按角色名称搜索角色列表
* @param role
* @param pageBean
* @return
*/
public PageBean<Role> findByName(Role role,PageBean<Role> pageBean){
ExampleMatcher withMatcher = ExampleMatcher.matching().withMatcher("name", GenericPropertyMatchers.contains());
withMatcher = withMatcher.withIgnorePaths("status");
Example<Role> example = Example.of(role, withMatcher);
Pageable pageable = PageRequest.of(pageBean.getCurrentPage()-1, pageBean.getPageSize());
Page<Role> findAll = roleDao.findAll(example, pageable);
pageBean.setContent(findAll.getContent());
pageBean.setTotal(findAll.getTotalElements());
pageBean.setTotalPage(findAll.getTotalPages());
return pageBean;
}

/**
* 根据id查询角色
* @param id
* @return
*/
public Role find(Long id){
return roleDao.find(id);
}

/**
* 根据id删除一条记录
* @param id
*/
public void delete(Long id){
roleDao.deleteById(id);
}
}

 

医生层Service服务:

/**
* 医生Service层
*/
@Service
public class DoctorService {

@Autowired
private DoctorDao doctorDao;

@Autowired
private OrderReceivingDao orderReceivingDao;

public Doctor find(Long id) { //通过病人id查病人信息
return doctorDao.find(id);
}

public Doctor save(Doctor patient) { //保存
return doctorDao.save(patient);
}

/**
* 分页查询医生信息
* @param doctor
* @param pageBean
* @return
*/
public PageBean<Doctor> findList(Doctor doctor, PageBean<Doctor> pageBean){
ExampleMatcher withMatcher = ExampleMatcher.matching().withMatcher("user.name", ExampleMatcher.GenericPropertyMatchers.contains());
withMatcher = withMatcher.withIgnorePaths("status","experience","user.status","user.sex","user.age");
Example<Doctor> example = Example.of(doctor, withMatcher);
Pageable pageable = PageRequest.of(pageBean.getCurrentPage()-1, pageBean.getPageSize());
Page<Doctor> findAll = doctorDao.findAll(example, pageable);
pageBean.setContent(findAll.getContent());
pageBean.setTotal(findAll.getTotalElements());
pageBean.setTotalPage(findAll.getTotalPages());
return pageBean;
}

/**
* 医生登录的信息
* @return
*/
public Doctor findByLoginDoctorUser(){//拿到医生登录的信息
Long userId = SessionUtil.getLoginedUser().getId();
return doctorDao.findByUser_Id(userId);
}

/**
* 根据医生编号拿到医生
* @param doctorDno
* @return
*/
public List<Doctor> findByDoctorDno(String doctorDno) {
return doctorDao.findByDoctorDno(doctorDno);
}

/**
* 根据ID删除
* @param id
*/
public void deleteById(Long id) {
doctorDao.deleteById(id);
}

/**
* 根据科室ID查找医生
* @param departmentId
* @return
*/
public List<Doctor> findFreeDoctorByDepartmentId(Long departmentId) {
return doctorDao.findByDepartmentIdAndStatus(departmentId, DOCTOR_STATUS_ENABLE);
}

/**
* 查看科室所有医生的信息
*
*/
public PageBean<Doctor>findAllByDepartment(PageBean<Doctor>pageBean, Long id){
Specification<Doctor> specification = new Specification<Doctor>() {
private static final long serialVersionUID = 1L;
@Override
public Predicate toPredicate(Root<Doctor> root,
CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
Predicate predicate = null;
Predicate equal1 = criteriaBuilder.equal(root.get("department"),id);
predicate = criteriaBuilder.and(equal1);
return predicate;
}
};
Sort sort = Sort.by(Sort.Direction.DESC,"createTime");
PageRequest pageable = PageRequest.of(pageBean.getCurrentPage()-1, pageBean.getPageSize(), sort);
Page<Doctor> findAll = doctorDao.findAll(specification, pageable);
pageBean.setContent(findAll.getContent());
pageBean.setTotal(findAll.getTotalElements());
pageBean.setTotalPage(findAll.getTotalPages());
return pageBean;
}

/**
* 根据医生ID修改出诊状态
*/
public boolean modifyVisitStatus(Long id){
Doctor doctor = findByLoginDoctorUser();
OrderReceiving receiving = orderReceivingDao.findAllOrderReceivingByDoctorId(id);
if (doctor.getId()==null&&doctor.getId().equals("")){
return false;
}
if (receiving.getOrderRegistration().getStatus()==REGISTRATION_STATUS_COMPLETED){
return false;
}
//订单状态设置为已完成
receiving.setStatus(RECEIVING_STATUS_COMPLETE);
//挂号状态设置为已完成
receiving.getOrderRegistration().setStatus(REGISTRATION_STATUS_COMPLETED);
orderReceivingDao.save(receiving);
return true;
}

/**
*
* 查询医生出诊信息数量
* @return
*/
public Integer selectCountByOrderReceiving(){
return doctorDao.selectCountByOrderReceiving();
}

/**
* 查询每个医生出诊的次数
* @return
*/
public DoctorOrderCount OrderCountByDoctor(){
DoctorOrderCount orderCount = new DoctorOrderCount();
List<Object> Orders = doctorDao.OrderCountByDoctor();
List<String>doctorName=new ArrayList<>();
List<Integer>countNum=new ArrayList<>();
for (Object o : Orders) {
Object[] obj = (Object[]) o;
doctorName.add(obj[0].toString());
orderCount.setDoctorName(doctorName);
countNum.add(Integer.valueOf(obj[1].toString()));
orderCount.setCountNum(countNum);
}
return orderCount;
}

}

用户管理service服务:

/**
* 用户管理service
*
*/
@Service
public class UserService {

@Autowired
private UserDao userDao;

/**
* 根据用户id查询
* @param id
* @return
*/
public User find(Long id){
return userDao.find(id);
}

/**
* 按照用户名查找用户
* @param username
* @return
*/
public User findByUsername(String username){
return userDao.findByUsername(username);
}

/**
* 用户添加/编辑操作
* @param user
* @return
*/
@Transactional
public User save(User user){
return userDao.save(user);
}

/**
* 分页查询用户列表
* @param user
* @param pageBean
* @return
*/
public PageBean<User> findList(User user,PageBean<User> pageBean){
ExampleMatcher withMatcher = ExampleMatcher.matching().withMatcher("username", GenericPropertyMatchers.contains());
withMatcher = withMatcher.withIgnorePaths("status","sex");
Example<User> example = Example.of(user, withMatcher);
Pageable pageable = PageRequest.of(pageBean.getCurrentPage()-1, pageBean.getPageSize());
Page<User> findAll = userDao.findAll(example, pageable);
pageBean.setContent(findAll.getContent());
pageBean.setTotal(findAll.getTotalElements());
pageBean.setTotalPage(findAll.getTotalPages());
return pageBean;
}

/**
* 判断用户名是否存在,添加和编辑均可判断
* @param username
* @param id
* @return
*/
public boolean isExistUsername(String username,Long id){
User user = userDao.findByUsername(username);
if(user != null){
//表示用户名存在,接下来判断是否是编辑用户的本身
if(user.getId().longValue() != id.longValue()){
return true;
}
}
return false;
}

/**
* 按照用户id删除
* @param id
*/
public void delete(Long id){
userDao.deleteById(id);
}

/**
* 返回用户总数
* @return
*/
public long total(){
return userDao.count();
}
}

病房类型层 Service服务:

/***
* 病房类型Service层
*/
@Service
public class RoomTypeService {
@Autowired
private RoomTypeDao roomTypeDao;

/***
* 病房类型全查询
* @return
*/
public PageBean<RoomType> findAll(RoomType roomType, PageBean<RoomType> pageBean){
ExampleMatcher withMatcher = ExampleMatcher.matching().withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains());
Example<RoomType> example = Example.of(roomType, withMatcher);
Pageable pageable = PageRequest.of(pageBean.getCurrentPage()-1, pageBean.getPageSize());
Page<RoomType> findAll = roomTypeDao.findAll(example, pageable);
pageBean.setContent(findAll.getContent());
pageBean.setTotal(findAll.getTotalElements());
pageBean.setTotalPage(findAll.getTotalPages());
return pageBean;
}

/***
* 病房类型全查询列表
* @return
*/
public List<RoomType> findList(){
return roomTypeDao.findAll();
}

/***
* 根据病房类型NAME判断是否存在
* @param name
* @return
*/
public boolean isByName(String name) {
RoomType byName = roomTypeDao.findByName(name);
if(byName != null){
if(byName.getName().equals(name)){
return true;
}
}
return false;
}
public boolean isByName(String name,Long id) {
RoomType byName = roomTypeDao.findByName(name);
if(byName != null){
if(byName.getId().longValue() != id.longValue()){
return true;
}
}
return false;
}

/***
* 病房类型添加
* @param roomType
* @return
*/
public RoomType save(RoomType roomType){
return roomTypeDao.save(roomType);
}

/***
* 根据ID查询病房类型
* @param id
* @return
*/
public RoomType find(Long id) {
return  roomTypeDao.find(id);
}
/***
* 根据ID删除病房类型
* @param id
*/
public void delete(Long id){
roomTypeDao.deleteById(id);
}

}