|
|
@ -6,19 +6,26 @@ import cn.hutool.core.lang.Snowflake; |
|
|
import cn.hutool.core.util.IdcardUtil; |
|
|
import cn.hutool.core.util.IdcardUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
|
import com.ccsens.carbasics.bean.dto.FirstAidDto; |
|
|
import com.ccsens.carbasics.bean.dto.PatientDto; |
|
|
import com.ccsens.carbasics.bean.dto.PatientDto; |
|
|
import com.ccsens.carbasics.bean.po.*; |
|
|
import com.ccsens.carbasics.bean.po.*; |
|
|
import com.ccsens.carbasics.bean.vo.FirstAidLogVo; |
|
|
import com.ccsens.carbasics.bean.vo.FirstAidLogVo; |
|
|
|
|
|
import com.ccsens.carbasics.bean.vo.FirstAidVo; |
|
|
import com.ccsens.carbasics.bean.vo.OrganizationVo; |
|
|
import com.ccsens.carbasics.bean.vo.OrganizationVo; |
|
|
import com.ccsens.carbasics.bean.vo.PatientVo; |
|
|
import com.ccsens.carbasics.bean.vo.PatientVo; |
|
|
import com.ccsens.carbasics.persist.dao.FirstAidDao; |
|
|
import com.ccsens.carbasics.persist.dao.FirstAidDao; |
|
|
import com.ccsens.carbasics.persist.dao.FirstAidLogDao; |
|
|
import com.ccsens.carbasics.persist.dao.FirstAidLogDao; |
|
|
|
|
|
|
|
|
|
|
|
import com.ccsens.carbasics.persist.dao.FirstAidMemberDao; |
|
|
import com.ccsens.carbasics.persist.dao.OrganizationDao; |
|
|
import com.ccsens.carbasics.persist.dao.OrganizationDao; |
|
|
import com.ccsens.carbasics.persist.dao.OrganizationMemberDao; |
|
|
import com.ccsens.carbasics.persist.dao.OrganizationMemberDao; |
|
|
import com.ccsens.carbasics.persist.mapper.*; |
|
|
import com.ccsens.carbasics.persist.mapper.*; |
|
|
import com.ccsens.carbasics.util.Constant; |
|
|
import com.ccsens.carbasics.util.Constant; |
|
|
import com.ccsens.carbasics.util.DefaultCodeError; |
|
|
import com.ccsens.carbasics.util.DefaultCodeError; |
|
|
|
|
|
import com.ccsens.common.bean.dto.CProjectDto; |
|
|
|
|
|
import com.ccsens.common.bean.vo.CProjectVo; |
|
|
|
|
|
import com.ccsens.common.service.IProjectService; |
|
|
|
|
|
import com.ccsens.util.RedisUtil; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
@ -49,16 +56,20 @@ public class FirstAidService implements IFirstAidService{ |
|
|
@Resource |
|
|
@Resource |
|
|
private Snowflake snowflake; |
|
|
private Snowflake snowflake; |
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private FirstAidMemberMapper firstAidMemberMapper; |
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
private FirstAidLogMapper firstAidLogMapper; |
|
|
private FirstAidLogMapper firstAidLogMapper; |
|
|
@Resource |
|
|
@Resource |
|
|
|
|
|
private FirstAidMemberDao firstAidMemberDao; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private IProjectService projectService; |
|
|
|
|
|
@Resource |
|
|
private OrganizationTemplateMapper templateMapper; |
|
|
private OrganizationTemplateMapper templateMapper; |
|
|
@Resource |
|
|
@Resource |
|
|
private FirstAidRecordMapper firstAidRecordMapper; |
|
|
private FirstAidRecordMapper firstAidRecordMapper; |
|
|
@Resource |
|
|
@Resource |
|
|
private FirstAidRecordLogMapper firstAidRecordLogMapper; |
|
|
private FirstAidRecordLogMapper firstAidRecordLogMapper; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@ -93,6 +104,11 @@ public class FirstAidService implements IFirstAidService{ |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void savePatient(PatientDto.SavePatient param, Long userId) { |
|
|
public void savePatient(PatientDto.SavePatient param, Long userId) { |
|
|
|
|
|
// 判断有无权限添加
|
|
|
|
|
|
OrganizationVo.Basic basic = organizationDao.getOrganization(param.getProjectId(), userId); |
|
|
|
|
|
if (basic == null) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.NO_DATA_MODIFY_PRIVILEGE); |
|
|
|
|
|
} |
|
|
//查找当前用户的职位和科室
|
|
|
//查找当前用户的职位和科室
|
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
log.info("当前用户的科室职位信息:{}",memberPosition); |
|
|
log.info("当前用户的科室职位信息:{}",memberPosition); |
|
|
@ -120,8 +136,11 @@ public class FirstAidService implements IFirstAidService{ |
|
|
firstAid.setName(param.getName()); |
|
|
firstAid.setName(param.getName()); |
|
|
firstAid.setGender(param.getGender()); |
|
|
firstAid.setGender(param.getGender()); |
|
|
firstAid.setNation(param.getNation()); |
|
|
firstAid.setNation(param.getNation()); |
|
|
|
|
|
firstAid.setHospitalId(basic.getOrganizationId()); |
|
|
|
|
|
firstAid.setValueType(param.getValueType()); |
|
|
|
|
|
firstAid.setOperator(userId); |
|
|
if(StrUtil.isNotEmpty(param.getIdcard())){ |
|
|
if(StrUtil.isNotEmpty(param.getIdcard())){ |
|
|
if(IdcardUtil.isValidCard(param.getIdcard())){ |
|
|
if(!IdcardUtil.isValidCard(param.getIdcard())){ |
|
|
throw new BaseException(DefaultCodeError.IDCARD_ERROR); |
|
|
throw new BaseException(DefaultCodeError.IDCARD_ERROR); |
|
|
} |
|
|
} |
|
|
firstAid.setIdcard(param.getIdcard()); |
|
|
firstAid.setIdcard(param.getIdcard()); |
|
|
@ -131,11 +150,12 @@ public class FirstAidService implements IFirstAidService{ |
|
|
//添加急救成员
|
|
|
//添加急救成员
|
|
|
FirstAidMember firstAidMember = new FirstAidMember(); |
|
|
FirstAidMember firstAidMember = new FirstAidMember(); |
|
|
firstAidMember.setId(snowflake.nextId()); |
|
|
firstAidMember.setId(snowflake.nextId()); |
|
|
|
|
|
firstAidMember.setFirstAidId(firstAid.getId()); |
|
|
firstAidMember.setCreateUserId(userId); |
|
|
firstAidMember.setCreateUserId(userId); |
|
|
if(position == 1){ |
|
|
if(position == 1){ |
|
|
firstAidMember.setRecordUserId(userId); |
|
|
firstAidMember.setRecordUserId(userId); |
|
|
} |
|
|
} |
|
|
firstAidMemberMapper.insertSelective(firstAidMember); |
|
|
firstAidMemberDao.insertSelective(firstAidMember); |
|
|
//添加急救日志表(创建信息)
|
|
|
//添加急救日志表(创建信息)
|
|
|
FirstAidLog firstAidLog = new FirstAidLog(); |
|
|
FirstAidLog firstAidLog = new FirstAidLog(); |
|
|
firstAidLog.setId(snowflake.nextId()); |
|
|
firstAidLog.setId(snowflake.nextId()); |
|
|
@ -154,16 +174,17 @@ public class FirstAidService implements IFirstAidService{ |
|
|
firstAidLogJoin.setOperationUserId(userId); |
|
|
firstAidLogJoin.setOperationUserId(userId); |
|
|
firstAidLogJoin.setOperationType((byte) 7); |
|
|
firstAidLogJoin.setOperationType((byte) 7); |
|
|
firstAidLogJoin.setOperationRole(position); |
|
|
firstAidLogJoin.setOperationRole(position); |
|
|
firstAidLogMapper.insertSelective(firstAidLog); |
|
|
firstAidLogMapper.insertSelective(firstAidLogJoin); |
|
|
} |
|
|
} |
|
|
//添加疑似诊断信息
|
|
|
//添加疑似诊断信息
|
|
|
FirstAidRecord firstAidRecord = new FirstAidRecord(); |
|
|
FirstAidRecord firstAidRecord = new FirstAidRecord(); |
|
|
firstAidRecord.setId(snowflake.nextId()); |
|
|
firstAidRecord.setId(snowflake.nextId()); |
|
|
firstAidRecord.setFirstAidId(firstAid.getId()); |
|
|
firstAidRecord.setFirstAidId(firstAid.getId()); |
|
|
firstAidRecord.setQuestionCode("CJBL-YSBL"); |
|
|
firstAidRecord.setQuestionCode(Constant.QuestionCode.CJBL_YSBL); |
|
|
firstAidRecord.setAnswer(param.getSuspected()); |
|
|
firstAidRecord.setAnswer(param.getSuspected()); |
|
|
firstAidRecord.setSubmitUserId(userId); |
|
|
firstAidRecord.setSubmitUserId(userId); |
|
|
firstAidRecord.setSubmitUserType((byte) 1); |
|
|
firstAidRecord.setSubmitUserType((byte) 1); |
|
|
|
|
|
firstAidRecord.setOperator(userId); |
|
|
firstAidRecordMapper.insertSelective(firstAidRecord); |
|
|
firstAidRecordMapper.insertSelective(firstAidRecord); |
|
|
//加日志
|
|
|
//加日志
|
|
|
FirstAidRecordLog firstAidRecordLog = new FirstAidRecordLog(); |
|
|
FirstAidRecordLog firstAidRecordLog = new FirstAidRecordLog(); |
|
|
@ -197,13 +218,13 @@ public class FirstAidService implements IFirstAidService{ |
|
|
throw new BaseException(DefaultCodeError.NOT_FIRST_AID_ID); |
|
|
throw new BaseException(DefaultCodeError.NOT_FIRST_AID_ID); |
|
|
} |
|
|
} |
|
|
//判断急救状态
|
|
|
//判断急救状态
|
|
|
if(firstAid.getDataStatus() == 1 || firstAid.getDataStatus() == 3){ |
|
|
if(firstAid.getDataStatus() == Constant.DataStatus.FirstAidPass.status || firstAid.getDataStatus() == Constant.DataStatus.DischargePass.status){ |
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
} |
|
|
} |
|
|
//判断操作人的权限
|
|
|
//判断操作人的权限
|
|
|
FirstAidMemberExample firstAidMemberExample = new FirstAidMemberExample(); |
|
|
FirstAidMemberExample firstAidMemberExample = new FirstAidMemberExample(); |
|
|
firstAidMemberExample.createCriteria().andFirstAidIdEqualTo(param.getFirstAidId()); |
|
|
firstAidMemberExample.createCriteria().andFirstAidIdEqualTo(param.getFirstAidId()); |
|
|
List<FirstAidMember> firstAidMembers = firstAidMemberMapper.selectByExample(firstAidMemberExample); |
|
|
List<FirstAidMember> firstAidMembers = firstAidMemberDao.selectByExample(firstAidMemberExample); |
|
|
if(CollectionUtil.isEmpty(firstAidMembers)){ |
|
|
if(CollectionUtil.isEmpty(firstAidMembers)){ |
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
} |
|
|
} |
|
|
@ -215,7 +236,7 @@ public class FirstAidService implements IFirstAidService{ |
|
|
firstAid.setNation(param.getNation()); |
|
|
firstAid.setNation(param.getNation()); |
|
|
firstAid.setGender(param.getGender()); |
|
|
firstAid.setGender(param.getGender()); |
|
|
if(StrUtil.isNotEmpty(param.getIdcard())){ |
|
|
if(StrUtil.isNotEmpty(param.getIdcard())){ |
|
|
if(IdcardUtil.isValidCard(param.getIdcard())){ |
|
|
if(!IdcardUtil.isValidCard(param.getIdcard())){ |
|
|
throw new BaseException(DefaultCodeError.IDCARD_ERROR); |
|
|
throw new BaseException(DefaultCodeError.IDCARD_ERROR); |
|
|
} |
|
|
} |
|
|
firstAid.setIdcard(param.getIdcard()); |
|
|
firstAid.setIdcard(param.getIdcard()); |
|
|
@ -227,7 +248,7 @@ public class FirstAidService implements IFirstAidService{ |
|
|
//修改急救记录信息
|
|
|
//修改急救记录信息
|
|
|
FirstAidRecord firstAidRecord = new FirstAidRecord(); |
|
|
FirstAidRecord firstAidRecord = new FirstAidRecord(); |
|
|
FirstAidRecordExample recordExample = new FirstAidRecordExample(); |
|
|
FirstAidRecordExample recordExample = new FirstAidRecordExample(); |
|
|
recordExample.createCriteria().andFirstAidIdEqualTo(param.getFirstAidId()).andQuestionCodeEqualTo("CJBL-YSBL"); |
|
|
recordExample.createCriteria().andFirstAidIdEqualTo(param.getFirstAidId()).andQuestionCodeEqualTo(Constant.QuestionCode.CJBL_YSBL); |
|
|
List<FirstAidRecord> firstAidRecords = firstAidRecordMapper.selectByExample(recordExample); |
|
|
List<FirstAidRecord> firstAidRecords = firstAidRecordMapper.selectByExample(recordExample); |
|
|
if(CollectionUtil.isNotEmpty(firstAidRecords)){ |
|
|
if(CollectionUtil.isNotEmpty(firstAidRecords)){ |
|
|
firstAidRecord = firstAidRecords.get(0); |
|
|
firstAidRecord = firstAidRecords.get(0); |
|
|
@ -235,7 +256,7 @@ public class FirstAidService implements IFirstAidService{ |
|
|
firstAidRecordMapper.updateByPrimaryKeySelective(firstAidRecord); |
|
|
firstAidRecordMapper.updateByPrimaryKeySelective(firstAidRecord); |
|
|
}else { |
|
|
}else { |
|
|
firstAidRecord.setId(snowflake.nextId()); |
|
|
firstAidRecord.setId(snowflake.nextId()); |
|
|
firstAidRecord.setQuestionCode("CJBL-YSBL"); |
|
|
firstAidRecord.setQuestionCode(Constant.QuestionCode.CJBL_YSBL); |
|
|
firstAidRecord.setFirstAidId(firstAid.getId()); |
|
|
firstAidRecord.setFirstAidId(firstAid.getId()); |
|
|
firstAidRecord.setAnswer(param.getSuspected()); |
|
|
firstAidRecord.setAnswer(param.getSuspected()); |
|
|
firstAidRecord.setSubmitUserId(userId); |
|
|
firstAidRecord.setSubmitUserId(userId); |
|
|
@ -261,7 +282,7 @@ public class FirstAidService implements IFirstAidService{ |
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
//用户的科室必须是医院的科室
|
|
|
//用户的科室必须是医院的科室
|
|
|
Organization organization = organizationDao.selectByPrimaryKey(memberPosition.getOrganizationId()); |
|
|
Organization organization = organizationDao.selectByPrimaryKey(memberPosition.getOrganizationId()); |
|
|
if(organization.getOrganizationType() != 3){ |
|
|
if(organization.getOrganizationType() != Constant.OrganizationType.HOSPITAL.status){ |
|
|
throw new BaseException(DefaultCodeError.NO_HOSPITAL); |
|
|
throw new BaseException(DefaultCodeError.NO_HOSPITAL); |
|
|
} |
|
|
} |
|
|
//根据科室查找模板
|
|
|
//根据科室查找模板
|
|
|
@ -294,4 +315,265 @@ public class FirstAidService implements IFirstAidService{ |
|
|
List<PatientVo.PatientListByQuality> patientList = firstAidDao.queryPatientListBySecretary(hospitalList,param); |
|
|
List<PatientVo.PatientListByQuality> patientList = firstAidDao.queryPatientListBySecretary(hospitalList,param); |
|
|
return new PageInfo<>(patientList); |
|
|
return new PageInfo<>(patientList); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void updateStatusBySecretary(PatientDto.StatusBySecretary param, Long userId) { |
|
|
|
|
|
//判断当前用户的职位是否是秘书
|
|
|
|
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
|
|
|
if(!memberPosition.getPositionCode().equalsIgnoreCase(Constant.Position.MI_SHU)){ |
|
|
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
|
|
} |
|
|
|
|
|
//查找急救记录
|
|
|
|
|
|
FirstAid firstAid = firstAidDao.selectByPrimaryKey(param.getFirstAidId()); |
|
|
|
|
|
if(ObjectUtil.isNull(firstAid)){ |
|
|
|
|
|
throw new BaseException(DefaultCodeError.NOT_FIRST_AID_ID); |
|
|
|
|
|
} |
|
|
|
|
|
//判断当前病例的状态和要修改的是否一致
|
|
|
|
|
|
if(firstAid.getDataStatus() == param.getDataStatus()){ |
|
|
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_SAME); |
|
|
|
|
|
} |
|
|
|
|
|
//判断病例状态是否是申请
|
|
|
|
|
|
if(firstAid.getDataStatus() != Constant.DataStatus.ApplyFor.status){ |
|
|
|
|
|
throw new BaseException(DefaultCodeError.NOT_APPLY_FOR); |
|
|
|
|
|
} |
|
|
|
|
|
//修改状态
|
|
|
|
|
|
firstAid.setDataStatus(param.getDataStatus()); |
|
|
|
|
|
firstAidDao.updateByPrimaryKeySelective(firstAid); |
|
|
|
|
|
//添加日志
|
|
|
|
|
|
FirstAidLog firstAidLog = new FirstAidLog(); |
|
|
|
|
|
firstAidLog.setId(snowflake.nextId()); |
|
|
|
|
|
firstAidLog.setFirstAidId(firstAid.getId()); |
|
|
|
|
|
firstAidLog.setOperationTime(System.currentTimeMillis()); |
|
|
|
|
|
firstAidLog.setOperationUserId(userId); |
|
|
|
|
|
firstAidLog.setOperationUserId(userId); |
|
|
|
|
|
firstAidLog.setOperationRole((byte) 4); |
|
|
|
|
|
if(param.getDataStatus() == 0){ |
|
|
|
|
|
firstAidLog.setOperationType((byte) 1); |
|
|
|
|
|
} |
|
|
|
|
|
if (param.getDataStatus() == 6){ |
|
|
|
|
|
firstAidLog.setOperationType((byte) 2); |
|
|
|
|
|
} |
|
|
|
|
|
firstAidLogDao.insertSelective(firstAidLog); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public FirstAidVo.ProjectInfo joinFirstAid(FirstAidDto.JoinFirstAid 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.SHEN_NEI.equals(memberPosition.getDepartmentCode()) || Constant.Department.SHEN_WAI.equals(memberPosition.getDepartmentCode())) { |
|
|
|
|
|
if (Constant.Position.YI_SHENG.equals(memberPosition.getPositionCode())) { |
|
|
|
|
|
position = 1; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNull(position)) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//判断病例是否已有医生加入
|
|
|
|
|
|
FirstAidMember firstAidMember = firstAidMemberDao.findByAidId(param.getFirstAidId()); |
|
|
|
|
|
if (ObjectUtil.isNotNull(firstAidMember)) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.DOCTOR_HAS_JOINED); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据模板类型创建项目
|
|
|
|
|
|
|
|
|
|
|
|
FirstAid firstAidInfo = firstAidDao.selectByPrimaryKey(param.getFirstAidId()); |
|
|
|
|
|
CProjectVo.CopyProjectInfo copyProjectInfo = new CProjectVo.CopyProjectInfo(); |
|
|
|
|
|
//如果已有项目则不创建,使用旧项目
|
|
|
|
|
|
if (firstAidInfo.getType().equals(param.getType()) && ObjectUtil.isNotNull(firstAidInfo.getProjectId())) { |
|
|
|
|
|
copyProjectInfo.setId(firstAidInfo.getProjectId()); |
|
|
|
|
|
}else { |
|
|
|
|
|
CProjectDto.CopyProject copyProject = new CProjectDto.CopyProject(); |
|
|
|
|
|
String newProjectName = ""; |
|
|
|
|
|
long incr = redisUtil.incr("hospital_" + firstAidInfo.getHospitalId().toString(), 1L); |
|
|
|
|
|
if (0 == param.getType()){ |
|
|
|
|
|
//TODO 设置项目id为神内模板 和 项目名字
|
|
|
|
|
|
newProjectName = incr+"-"+"急救(神内)-"+firstAidInfo.getName(); |
|
|
|
|
|
copyProject.setProjectName(newProjectName); |
|
|
|
|
|
copyProject.setProjectId((Long) redisUtil.get(Constant.TEMPLATE_PROJECT_KEY_SHENNEI)); |
|
|
|
|
|
}else{ |
|
|
|
|
|
//TODO 设置项目id为神外模板 和 项目名字
|
|
|
|
|
|
newProjectName = incr+"-"+"急救(神外)-"+firstAidInfo.getName(); |
|
|
|
|
|
copyProject.setProjectName(newProjectName); |
|
|
|
|
|
copyProject.setProjectId((Long) redisUtil.get(Constant.TEMPLATE_PROJECT_KEY_SHENWAI)); |
|
|
|
|
|
} |
|
|
|
|
|
log.info("加入急救-开始创建项目{}",copyProject); |
|
|
|
|
|
copyProjectInfo = projectService.copyProject(copyProject, userId); |
|
|
|
|
|
log.info("加入急救-创建项目结束{}",copyProjectInfo); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将医生添加为项目成员
|
|
|
|
|
|
CProjectDto.MemberForProject memberForProject = new CProjectDto.MemberForProject(); |
|
|
|
|
|
List<CProjectDto.MemberInfo> memberInfoList = new ArrayList<>(); |
|
|
|
|
|
CProjectDto.MemberInfo memberInfo = new CProjectDto.MemberInfo(); |
|
|
|
|
|
memberInfo.setUserId(userId); |
|
|
|
|
|
memberInfo.setMemberName(memberPosition.getName()); |
|
|
|
|
|
memberInfo.setPhone(memberPosition.getContact()); |
|
|
|
|
|
if (0 == param.getType()){ |
|
|
|
|
|
memberInfo.setRoleName(Constant.RoleName.SHEN_NEI); |
|
|
|
|
|
}else{ |
|
|
|
|
|
memberInfo.setRoleName(Constant.RoleName.SHEN_WAI); |
|
|
|
|
|
} |
|
|
|
|
|
memberInfoList.add(memberInfo); |
|
|
|
|
|
memberForProject.setProjectId(copyProjectInfo.getId()); |
|
|
|
|
|
memberForProject.setMemberInfoList(memberInfoList); |
|
|
|
|
|
log.info("加入急救-开始添加成员{}",memberForProject); |
|
|
|
|
|
projectService.addMemberForCopy(memberForProject,userId); |
|
|
|
|
|
log.info("加入急救-添加成员结束"); |
|
|
|
|
|
|
|
|
|
|
|
//添加医生为病例的录入者 t_qcp_first_aid_member
|
|
|
|
|
|
FirstAidMember newFirstAidMember = new FirstAidMember(); |
|
|
|
|
|
newFirstAidMember.setId(snowflake.nextId()); |
|
|
|
|
|
newFirstAidMember.setFirstAidId(param.getFirstAidId()); |
|
|
|
|
|
newFirstAidMember.setCreateUserId(userId); |
|
|
|
|
|
newFirstAidMember.setRecordUserId(userId); |
|
|
|
|
|
firstAidMemberDao.insertSelective(newFirstAidMember); |
|
|
|
|
|
|
|
|
|
|
|
//急救信息和项目关联
|
|
|
|
|
|
FirstAid firstAid = new FirstAid(); |
|
|
|
|
|
firstAid.setId(param.getFirstAidId()); |
|
|
|
|
|
firstAid.setProjectId(copyProjectInfo.getId()); |
|
|
|
|
|
firstAidDao.updateByPrimaryKeySelective(firstAid); |
|
|
|
|
|
|
|
|
|
|
|
//添加急救日志(类型:加入)
|
|
|
|
|
|
FirstAidLog firstAidLog = new FirstAidLog(); |
|
|
|
|
|
firstAidLog.setId(snowflake.nextId()); |
|
|
|
|
|
firstAidLog.setFirstAidId(param.getFirstAidId()); |
|
|
|
|
|
firstAidLog.setOperationTime(System.currentTimeMillis()); |
|
|
|
|
|
firstAidLog.setOperationUserId(userId); |
|
|
|
|
|
firstAidLog.setOperationType((byte)7); |
|
|
|
|
|
if (0 == param.getType()){ |
|
|
|
|
|
firstAidLog.setOperationRole((byte)1); |
|
|
|
|
|
}else{ |
|
|
|
|
|
firstAidLog.setOperationRole((byte)2); |
|
|
|
|
|
} |
|
|
|
|
|
firstAidLogDao.insertSelective(firstAidLog); |
|
|
|
|
|
//返回项目id
|
|
|
|
|
|
FirstAidVo.ProjectInfo projectInfo = new FirstAidVo.ProjectInfo(); |
|
|
|
|
|
projectInfo.setProjectId(copyProjectInfo.getId()); |
|
|
|
|
|
return projectInfo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void quitFirstAid(FirstAidDto.QuitFirstAid param, Long userId) { |
|
|
|
|
|
FirstAidMember byAidId = firstAidMemberDao.findByAidId(param.getFirstAidId()); |
|
|
|
|
|
if (ObjectUtil.isNull(byAidId)) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.NOT_FIRST_AID_ID); |
|
|
|
|
|
} |
|
|
|
|
|
if (!userId.equals(byAidId.getRecordUserId())) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.REPEAT_QUIT); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//添加急救日志(退出)
|
|
|
|
|
|
FirstAidLog firstAidLog = new FirstAidLog(); |
|
|
|
|
|
firstAidLog.setId(snowflake.nextId()); |
|
|
|
|
|
firstAidLog.setFirstAidId(param.getFirstAidId()); |
|
|
|
|
|
firstAidLog.setOperationTime(System.currentTimeMillis()); |
|
|
|
|
|
firstAidLog.setOperationUserId(userId); |
|
|
|
|
|
firstAidLog.setOperationType((byte)8); |
|
|
|
|
|
//判断角色是否神内/神外医生
|
|
|
|
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
|
|
|
log.info("当前用户的科室职位信息:{}",memberPosition); |
|
|
|
|
|
if (Constant.Department.SHEN_NEI.equals(memberPosition.getDepartmentCode())) { |
|
|
|
|
|
if (Constant.Position.YI_SHENG.equals(memberPosition.getPositionCode())) { |
|
|
|
|
|
firstAidLog.setOperationRole((byte)1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (Constant.Department.SHEN_WAI.equals(memberPosition.getDepartmentCode())) { |
|
|
|
|
|
if (Constant.Position.YI_SHENG.equals(memberPosition.getPositionCode())) { |
|
|
|
|
|
firstAidLog.setOperationRole((byte)2); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
firstAidLogDao.insertSelective(firstAidLog); |
|
|
|
|
|
//修改录入者userId为0
|
|
|
|
|
|
byAidId.setRecordUserId(0L); |
|
|
|
|
|
firstAidMemberDao.updateByPrimaryKeySelective(byAidId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void updateStatus(FirstAidDto.UpdateStatus param, Long userId) { |
|
|
|
|
|
//修改病例状态
|
|
|
|
|
|
FirstAid firstAid = firstAidDao.selectByPrimaryKey(param.getFirstAidId()); |
|
|
|
|
|
if (ObjectUtil.isNull(firstAid)) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.NOT_FIRST_AID_ID); |
|
|
|
|
|
} |
|
|
|
|
|
//判断权限
|
|
|
|
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
|
|
|
log.info("当前用户的科室职位信息:{}",memberPosition); |
|
|
|
|
|
if (!Constant.Position.ZHI_KONG.equals(memberPosition.getPositionCode())) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
|
|
} |
|
|
|
|
|
if (0 == firstAid.getType()) { |
|
|
|
|
|
if (!Constant.Department.SHEN_NEI.equals(memberPosition.getDepartmentCode())) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (1 == firstAid.getType()) { |
|
|
|
|
|
if (!Constant.Department.SHEN_WAI.equals(memberPosition.getDepartmentCode())) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (param.getDataStatus()) { |
|
|
|
|
|
case 1: |
|
|
|
|
|
if (Constant.DataStatus.Create.status != firstAid.getDataStatus() && Constant.DataStatus.FirstAidRefuse.status != firstAid.getDataStatus() && Constant.DataStatus.DischargeRefuse.status != firstAid.getDataStatus()) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 2: |
|
|
|
|
|
if (Constant.DataStatus.Create.status != firstAid.getDataStatus()) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 3: |
|
|
|
|
|
if (Constant.DataStatus.Create.status != firstAid.getDataStatus() && Constant.DataStatus.FirstAidPass.status != firstAid.getDataStatus() && Constant.DataStatus.FirstAidRefuse.status != firstAid.getDataStatus() && Constant.DataStatus.DischargeRefuse.status != firstAid.getDataStatus()) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 4: |
|
|
|
|
|
if (Constant.DataStatus.Create.status != firstAid.getDataStatus() && Constant.DataStatus.FirstAidPass.status != firstAid.getDataStatus() && Constant.DataStatus.FirstAidRefuse.status != firstAid.getDataStatus()) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 5: |
|
|
|
|
|
if (Constant.DataStatus.FirstAidPass.status != firstAid.getDataStatus() && Constant.DataStatus.DischargePass.status != firstAid.getDataStatus() && Constant.DataStatus.ApplyForRefuse.status != firstAid.getDataStatus()) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
|
|
} |
|
|
|
|
|
Integer updateNumber = firstAidLogDao.countUpdateNumber(param.getFirstAidId()); |
|
|
|
|
|
if (updateNumber >= Constant.MAX_UPDATE_NUMBER) { |
|
|
|
|
|
throw new BaseException(DefaultCodeError.SURPASS_MAX_NUMBER); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
|
|
} |
|
|
|
|
|
firstAid.setDataStatus(param.getDataStatus()); |
|
|
|
|
|
firstAidDao.updateByPrimaryKeySelective(firstAid); |
|
|
|
|
|
//添加日志
|
|
|
|
|
|
FirstAidLog firstAidLog = new FirstAidLog(); |
|
|
|
|
|
firstAidLog.setId(snowflake.nextId()); |
|
|
|
|
|
firstAidLog.setFirstAidId(param.getFirstAidId()); |
|
|
|
|
|
firstAidLog.setOperationTime(System.currentTimeMillis()); |
|
|
|
|
|
firstAidLog.setOperationUserId(userId); |
|
|
|
|
|
if (1 == param.getDataStatus() || 3 == param.getDataStatus()){ |
|
|
|
|
|
firstAidLog.setOperationType((byte)1); |
|
|
|
|
|
} |
|
|
|
|
|
if (2 == param.getDataStatus() || 4 == param.getDataStatus()){ |
|
|
|
|
|
firstAidLog.setOperationType((byte)2); |
|
|
|
|
|
} |
|
|
|
|
|
if (5 == param.getDataStatus()){ |
|
|
|
|
|
firstAidLog.setOperationType((byte)3); |
|
|
|
|
|
} |
|
|
|
|
|
firstAidLog.setOperationRole((byte)3); |
|
|
|
|
|
firstAidLogDao.insertSelective(firstAidLog); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|