|
|
@ -1,13 +1,26 @@ |
|
|
|
package com.ccsens.carbasics.service; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.IdcardUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ccsens.carbasics.bean.dto.PatientDto; |
|
|
|
import com.ccsens.carbasics.bean.po.FirstAid; |
|
|
|
import com.ccsens.carbasics.bean.po.FirstAidExample; |
|
|
|
import com.ccsens.carbasics.bean.po.FirstAidLog; |
|
|
|
import com.ccsens.carbasics.bean.po.FirstAidMember; |
|
|
|
import com.ccsens.carbasics.bean.vo.FirstAidLogVo; |
|
|
|
import com.ccsens.carbasics.bean.vo.OrganizationVo; |
|
|
|
import com.ccsens.carbasics.bean.vo.PatientVo; |
|
|
|
import com.ccsens.carbasics.persist.dao.FirstAidDao; |
|
|
|
import com.ccsens.carbasics.persist.dao.FirstAidLogDao; |
|
|
|
|
|
|
|
import com.ccsens.carbasics.persist.dao.OrganizationDao; |
|
|
|
import com.ccsens.carbasics.persist.dao.OrganizationMemberDao; |
|
|
|
import com.ccsens.carbasics.persist.mapper.FirstAidLogMapper; |
|
|
|
import com.ccsens.carbasics.persist.mapper.FirstAidMemberMapper; |
|
|
|
import com.ccsens.carbasics.util.Constant; |
|
|
|
import com.ccsens.carbasics.util.DefaultCodeError; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
@ -34,6 +47,16 @@ public class FirstAidService implements IFirstAidService{ |
|
|
|
private FirstAidDao firstAidDao; |
|
|
|
@Resource |
|
|
|
private FirstAidLogDao firstAidLogDao; |
|
|
|
@Resource |
|
|
|
private OrganizationMemberDao organizationMemberDao; |
|
|
|
@Resource |
|
|
|
private Snowflake snowflake; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private FirstAidMemberMapper firstAidMemberMapper; |
|
|
|
@Resource |
|
|
|
private FirstAidLogMapper firstAidLogMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<PatientVo.QueryPatientList> querySelf(PatientDto.QueryPatient param, Long userId) { |
|
|
@ -50,7 +73,7 @@ public class FirstAidService implements IFirstAidService{ |
|
|
|
} |
|
|
|
log.info("查询日志"); |
|
|
|
List<Long> firstAidIds = new ArrayList<>(); |
|
|
|
Map<Long, PatientVo.QueryPatientList> map = new HashMap<>(); |
|
|
|
Map<Long, PatientVo.QueryPatientList> map = new HashMap<>(list.size()); |
|
|
|
list.forEach(aid -> { |
|
|
|
firstAidIds.add(aid.getFirstAidId()); |
|
|
|
map.put(aid.getFirstAidId(), aid); |
|
|
@ -60,10 +83,89 @@ public class FirstAidService implements IFirstAidService{ |
|
|
|
if (CollectionUtil.isEmpty(members)) { |
|
|
|
return new PageInfo<>(list); |
|
|
|
} |
|
|
|
members.forEach(member -> { |
|
|
|
map.get(member.getFirstAidId()).setDoctors(member.getDoctors()); |
|
|
|
}); |
|
|
|
members.forEach(member -> map.get(member.getFirstAidId()).setDoctors(member.getDoctors())); |
|
|
|
log.info("设置成员"); |
|
|
|
return new PageInfo<>(list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void savePatient(PatientDto.SavePatient param, Long userId) { |
|
|
|
//查找当前用户的职位和科室
|
|
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
|
log.info("当前用户的科室职位信息:{}",memberPosition); |
|
|
|
if(ObjectUtil.isNull(memberPosition)){ |
|
|
|
//为空则提示没有权限
|
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
} |
|
|
|
//职位
|
|
|
|
Byte position = null; |
|
|
|
//是否是急诊的护士
|
|
|
|
if(Constant.Department.JI_ZHEN.equalsIgnoreCase(memberPosition.getDepartmentCode()) && Constant.Position.HU_SHI.equalsIgnoreCase(memberPosition.getPositionCode())){ |
|
|
|
position = 0; |
|
|
|
} |
|
|
|
//是否是神内的医生
|
|
|
|
if(Constant.Department.SHEN_NEI.equalsIgnoreCase(memberPosition.getDepartmentCode()) && Constant.Position.YI_SHENG.equalsIgnoreCase(memberPosition.getPositionCode())){ |
|
|
|
position = 1; |
|
|
|
} |
|
|
|
if(ObjectUtil.isNull(position)){ |
|
|
|
//不是急诊护士或者不是神内的医生,提示没有权限
|
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
} |
|
|
|
//创建病例
|
|
|
|
FirstAid firstAid = new FirstAid(); |
|
|
|
firstAid.setId(snowflake.nextId()); |
|
|
|
firstAid.setName(param.getName()); |
|
|
|
firstAid.setGender(param.getGender()); |
|
|
|
firstAid.setNation(param.getNation()); |
|
|
|
firstAid.setIdcard(param.getIdcard()); |
|
|
|
if(StrUtil.isNotEmpty(param.getIdcard())){ |
|
|
|
firstAid.setAge(IdcardUtil.getAgeByIdCard(param.getIdcard())); |
|
|
|
} |
|
|
|
firstAidDao.insertSelective(firstAid); |
|
|
|
//添加急救成员
|
|
|
|
FirstAidMember firstAidMember = new FirstAidMember(); |
|
|
|
firstAidMember.setId(snowflake.nextId()); |
|
|
|
firstAidMember.setCreateUserId(userId); |
|
|
|
if(position == 1){ |
|
|
|
firstAidMember.setRecordUserId(userId); |
|
|
|
} |
|
|
|
firstAidMemberMapper.insertSelective(firstAidMember); |
|
|
|
//添加急救日志表(创建信息)
|
|
|
|
FirstAidLog firstAidLog = new FirstAidLog(); |
|
|
|
firstAidLog.setId(snowflake.nextId()); |
|
|
|
firstAidLog.setFirstAidId(firstAid.getId()); |
|
|
|
firstAidLog.setOperationTime(System.currentTimeMillis()); |
|
|
|
firstAidLog.setOperationUserId(userId); |
|
|
|
firstAidLog.setOperationType((byte) 0); |
|
|
|
firstAidLog.setOperationRole(position); |
|
|
|
firstAidLogMapper.insertSelective(firstAidLog); |
|
|
|
//如果是医生,再添加一条加入的日志
|
|
|
|
if(position == 1){ |
|
|
|
FirstAidLog firstAidLogJoin = new FirstAidLog(); |
|
|
|
firstAidLogJoin.setId(snowflake.nextId()); |
|
|
|
firstAidLogJoin.setFirstAidId(firstAid.getId()); |
|
|
|
firstAidLogJoin.setOperationTime(System.currentTimeMillis()); |
|
|
|
firstAidLogJoin.setOperationUserId(userId); |
|
|
|
firstAidLogJoin.setOperationType((byte) 7); |
|
|
|
firstAidLogJoin.setOperationRole(position); |
|
|
|
firstAidLogMapper.insertSelective(firstAidLog); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PatientVo.GetPatient getPatient(PatientDto.ProjectId param, Long userId) { |
|
|
|
PatientVo.GetPatient getPatient = new PatientVo.GetPatient(); |
|
|
|
//通过项目id查找急救信息
|
|
|
|
FirstAidExample firstAidExample = new FirstAidExample(); |
|
|
|
firstAidExample.createCriteria().andProjectIdEqualTo(param.getProjectId()); |
|
|
|
List<FirstAid> firstAids = firstAidDao.selectByExample(firstAidExample); |
|
|
|
if(CollectionUtil.isNotEmpty(firstAids)){ |
|
|
|
getPatient.setFirstAidId(firstAids.get(0).getId()); |
|
|
|
getPatient.setName(firstAids.get(0).getName()); |
|
|
|
getPatient.setGender(firstAids.get(0).getGender()); |
|
|
|
getPatient.setNation(firstAids.get(0).getNation()); |
|
|
|
getPatient.setIdcard(firstAids.get(0).getIdcard()); |
|
|
|
} |
|
|
|
return getPatient; |
|
|
|
} |
|
|
|
} |
|
|
|