|
|
@ -1,25 +1,23 @@ |
|
|
|
package com.ccsens.carbasics.service; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
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.po.*; |
|
|
|
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.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.persist.mapper.*; |
|
|
|
import com.ccsens.carbasics.util.Constant; |
|
|
|
import com.ccsens.carbasics.util.DefaultCodeError; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -46,6 +44,12 @@ public class FirstAidService implements IFirstAidService{ |
|
|
|
private FirstAidMemberMapper firstAidMemberMapper; |
|
|
|
@Resource |
|
|
|
private FirstAidLogMapper firstAidLogMapper; |
|
|
|
@Resource |
|
|
|
private OrganizationTemplateMapper templateMapper; |
|
|
|
@Resource |
|
|
|
private FirstAidRecordMapper firstAidRecordMapper; |
|
|
|
@Resource |
|
|
|
private FirstAidRecordLogMapper firstAidRecordLogMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<PatientVo.QueryPatientList> querySelf(PatientDto.QueryPatient param, Long userId) { |
|
|
@ -86,8 +90,11 @@ public class FirstAidService implements IFirstAidService{ |
|
|
|
firstAid.setName(param.getName()); |
|
|
|
firstAid.setGender(param.getGender()); |
|
|
|
firstAid.setNation(param.getNation()); |
|
|
|
firstAid.setIdcard(param.getIdcard()); |
|
|
|
if(StrUtil.isNotEmpty(param.getIdcard())){ |
|
|
|
if(IdcardUtil.isValidCard(param.getIdcard())){ |
|
|
|
throw new BaseException(DefaultCodeError.IDCARD_ERROR); |
|
|
|
} |
|
|
|
firstAid.setIdcard(param.getIdcard()); |
|
|
|
firstAid.setAge(IdcardUtil.getAgeByIdCard(param.getIdcard())); |
|
|
|
} |
|
|
|
firstAidDao.insertSelective(firstAid); |
|
|
@ -119,6 +126,20 @@ public class FirstAidService implements IFirstAidService{ |
|
|
|
firstAidLogJoin.setOperationRole(position); |
|
|
|
firstAidLogMapper.insertSelective(firstAidLog); |
|
|
|
} |
|
|
|
//添加疑似诊断信息
|
|
|
|
FirstAidRecord firstAidRecord = new FirstAidRecord(); |
|
|
|
firstAidRecord.setId(snowflake.nextId()); |
|
|
|
firstAidRecord.setFirstAidId(firstAid.getId()); |
|
|
|
firstAidRecord.setQuestionCode("CJBL-YSBL"); |
|
|
|
firstAidRecord.setAnswer(param.getSuspected()); |
|
|
|
firstAidRecord.setSubmitUserId(userId); |
|
|
|
firstAidRecord.setSubmitUserType((byte) 1); |
|
|
|
firstAidRecordMapper.insertSelective(firstAidRecord); |
|
|
|
//加日志
|
|
|
|
FirstAidRecordLog firstAidRecordLog = new FirstAidRecordLog(); |
|
|
|
BeanUtil.copyProperties(firstAidRecord,firstAidRecordLog); |
|
|
|
firstAidRecordLog.setId(snowflake.nextId()); |
|
|
|
firstAidRecordLogMapper.insertSelective(firstAidRecordLog); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -137,4 +158,110 @@ public class FirstAidService implements IFirstAidService{ |
|
|
|
} |
|
|
|
return getPatient; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updatePatient(PatientDto.UpdatePatient param, Long userId) { |
|
|
|
//查找急救信息
|
|
|
|
FirstAid firstAid = firstAidDao.selectByPrimaryKey(param.getFirstAidId()); |
|
|
|
if(ObjectUtil.isNull(firstAid)){ |
|
|
|
throw new BaseException(DefaultCodeError.NOT_FIRST_AID_ID); |
|
|
|
} |
|
|
|
//判断急救状态
|
|
|
|
if(firstAid.getDataStatus() == 1 || firstAid.getDataStatus() == 3){ |
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
} |
|
|
|
//判断操作人的权限
|
|
|
|
FirstAidMemberExample firstAidMemberExample = new FirstAidMemberExample(); |
|
|
|
firstAidMemberExample.createCriteria().andFirstAidIdEqualTo(param.getFirstAidId()); |
|
|
|
List<FirstAidMember> firstAidMembers = firstAidMemberMapper.selectByExample(firstAidMemberExample); |
|
|
|
if(CollectionUtil.isEmpty(firstAidMembers)){ |
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
} |
|
|
|
if(!userId.equals(firstAidMembers.get(0).getCreateUserId()) && !userId.equals(firstAidMembers.get(0).getRecordUserId())){ |
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
} |
|
|
|
//修改信息
|
|
|
|
firstAid.setName(param.getName()); |
|
|
|
firstAid.setNation(param.getNation()); |
|
|
|
firstAid.setGender(param.getGender()); |
|
|
|
if(StrUtil.isNotEmpty(param.getIdcard())){ |
|
|
|
if(IdcardUtil.isValidCard(param.getIdcard())){ |
|
|
|
throw new BaseException(DefaultCodeError.IDCARD_ERROR); |
|
|
|
} |
|
|
|
firstAid.setIdcard(param.getIdcard()); |
|
|
|
firstAid.setAge(IdcardUtil.getAgeByIdCard(param.getIdcard())); |
|
|
|
} |
|
|
|
firstAidDao.updateByPrimaryKeySelective(firstAid); |
|
|
|
//修改疑似诊断信息
|
|
|
|
if(StrUtil.isNotEmpty(param.getSuspected())){ |
|
|
|
//修改急救记录信息
|
|
|
|
FirstAidRecord firstAidRecord = new FirstAidRecord(); |
|
|
|
FirstAidRecordExample recordExample = new FirstAidRecordExample(); |
|
|
|
recordExample.createCriteria().andFirstAidIdEqualTo(param.getFirstAidId()).andQuestionCodeEqualTo("CJBL-YSBL"); |
|
|
|
List<FirstAidRecord> firstAidRecords = firstAidRecordMapper.selectByExample(recordExample); |
|
|
|
if(CollectionUtil.isNotEmpty(firstAidRecords)){ |
|
|
|
firstAidRecord = firstAidRecords.get(0); |
|
|
|
firstAidRecord.setAnswer(param.getSuspected()); |
|
|
|
firstAidRecordMapper.updateByPrimaryKeySelective(firstAidRecord); |
|
|
|
}else { |
|
|
|
firstAidRecord.setId(snowflake.nextId()); |
|
|
|
firstAidRecord.setQuestionCode("CJBL-YSBL"); |
|
|
|
firstAidRecord.setFirstAidId(firstAid.getId()); |
|
|
|
firstAidRecord.setAnswer(param.getSuspected()); |
|
|
|
firstAidRecord.setSubmitUserId(userId); |
|
|
|
firstAidRecord.setSubmitUserType((byte) 1); |
|
|
|
firstAidRecordMapper.insertSelective(firstAidRecord); |
|
|
|
} |
|
|
|
//添加日志信息
|
|
|
|
FirstAidRecordLog firstAidRecordLog = new FirstAidRecordLog(); |
|
|
|
BeanUtil.copyProperties(firstAidRecord,firstAidRecordLog); |
|
|
|
firstAidRecordLog.setId(snowflake.nextId()); |
|
|
|
firstAidRecordLogMapper.insertSelective(firstAidRecordLog); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<PatientVo.PatientListByQuality> queryPatientListByQuality(PatientDto.QueryListByQuality param, Long userId) { |
|
|
|
//根据项目id查找医院id
|
|
|
|
FirstAid firstAid = firstAidDao.getIdByProjectId(param.getProjectId()); |
|
|
|
if(ObjectUtil.isNull(firstAid) || ObjectUtil.isNull(firstAid.getHospitalId())){ |
|
|
|
throw new BaseException(DefaultCodeError.NOT_HOSPITAL_ID); |
|
|
|
} |
|
|
|
//查找当前用户的职位和科室
|
|
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
|
//用户的科室必须是医院的科室
|
|
|
|
Organization organization = organizationDao.selectByPrimaryKey(memberPosition.getOrganizationId()); |
|
|
|
if(organization.getOrganizationType() != 3){ |
|
|
|
throw new BaseException(DefaultCodeError.NO_HOSPITAL); |
|
|
|
} |
|
|
|
//根据科室查找模板
|
|
|
|
OrganizationTemplateExample templateExample = new OrganizationTemplateExample(); |
|
|
|
templateExample.createCriteria().andCodeEqualTo(memberPosition.getDepartmentCode()).andCodeTypeEqualTo((byte) 0); |
|
|
|
List<OrganizationTemplate> templateList = templateMapper.selectByExample(templateExample); |
|
|
|
if(CollectionUtil.isEmpty(templateList)){ |
|
|
|
throw new BaseException(DefaultCodeError.NOT_TEMPLATE); |
|
|
|
} |
|
|
|
//查找病例信息
|
|
|
|
PageHelper.startPage(param.getPageNum(),param.getPageSize()); |
|
|
|
List<PatientVo.PatientListByQuality> patientList = firstAidDao.queryPatientListByQuality(templateList.get(0).getTemplate(),firstAid.getHospitalId(),param); |
|
|
|
return new PageInfo<>(patientList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<PatientVo.PatientListByQuality> queryPatientListBySecretary(PatientDto.QueryListByQuality param, Long userId) { |
|
|
|
//根据项目id查询机构信息
|
|
|
|
Organization organization = organizationDao.getByProjectId(param.getProjectId()); |
|
|
|
if(ObjectUtil.isNull(organization)){ |
|
|
|
throw new BaseException(DefaultCodeError.NOT_ORGANIZATION); |
|
|
|
} |
|
|
|
//查询医院所属的下级医院
|
|
|
|
List<Organization> hospitalList = organizationDao.getHospitalByParentId(organization.getId()); |
|
|
|
if(CollectionUtil.isEmpty(hospitalList)){ |
|
|
|
throw new BaseException(DefaultCodeError.NOT_HOSPITAL_ID); |
|
|
|
} |
|
|
|
//查找病例信息
|
|
|
|
PageHelper.startPage(param.getPageNum(),param.getPageSize()); |
|
|
|
List<PatientVo.PatientListByQuality> patientList = firstAidDao.queryPatientListBySecretary(hospitalList,param); |
|
|
|
return new PageInfo<>(patientList); |
|
|
|
} |
|
|
|
} |
|
|
|