diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ScreeningServiceImpl.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ScreeningServiceImpl.java index 32a44833..be3ed618 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ScreeningServiceImpl.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ScreeningServiceImpl.java @@ -16,14 +16,12 @@ import com.acupuncture.common.core.redis.RedisCache; import com.acupuncture.common.exception.base.BaseException; import com.acupuncture.common.utils.SecurityUtils; import com.acupuncture.system.domain.dto.ScreeningDto; -import com.acupuncture.system.domain.po.ScrScreening; -import com.acupuncture.system.domain.po.ScrScreeningDetail; -import com.acupuncture.system.domain.po.ScrScreeningExample; -import com.acupuncture.system.domain.po.ScrScreeningRecord; +import com.acupuncture.system.domain.po.*; import com.acupuncture.system.domain.vo.QuestionnaireVo; import com.acupuncture.system.domain.vo.ScrScreenVo; import com.acupuncture.system.persist.dao.ScreeningDao; import com.acupuncture.system.persist.dao.ScreeningDetailDao; +import com.acupuncture.system.persist.mapper.PmsPatientMapper; import com.acupuncture.system.persist.mapper.ScrScreeningRecordMapper; import com.acupuncture.system.service.IScreeningService; import com.github.pagehelper.PageInfo; @@ -56,6 +54,8 @@ public class ScreeningServiceImpl implements IScreeningService { private ScrScreeningRecordMapper scrScreeningRecordMapper; @Resource private RedisCache redisCache; + @Resource + private PmsPatientMapper pmsPatientMapper; /** * 提交高危筛查问卷的时间 @@ -416,6 +416,40 @@ public class ScreeningServiceImpl implements IScreeningService { screeningDetail.setId(param.getDetailId()); screeningDetail.setSubmitStatus((byte) 1); scrScreeningRecordMapper.updateByPrimaryKeySelective(screeningDetail); + + //获取CODE查询是否已经新增患者档案 + ScrScreeningDetailExample scrScreeningDetailExample = new ScrScreeningDetailExample(); + scrScreeningDetailExample.createCriteria().andDelFlagEqualTo((byte) 0).andRecordIdEqualTo(param.getDetailId()) + .andQuestionCodeIn(CollectionUtil.newArrayList("SCWJ-NAME", "SCWJ-SEX", "SCWJ-BIRTH", + "SCWJ-AGE", "SCWJ-PHONE")); + List scrScreeningDetails = screeningDetailDao.selectByExample(scrScreeningDetailExample); + if (CollectionUtil.isNotEmpty(scrScreeningDetails)) { + Map map = scrScreeningDetails.stream().collect(Collectors.toMap(ScrScreeningDetail::getQuestionCode, Function.identity())); + ScrScreeningDetail scrScreeningDetail = map.get("SCWJ-NAME"); + ScrScreeningDetail scrScreeningDetail1 = map.get("SCWJ-PHONE"); + if (scrScreeningDetail == null || scrScreeningDetail1 == null) { + return; + } + PmsPatientExample pmsPatientExample = new PmsPatientExample(); + pmsPatientExample.createCriteria().andNameEqualTo(scrScreeningDetail.getAnswer()).andPhoneEqualTo(scrScreeningDetail1.getAnswer()); + List pmsPatients = pmsPatientMapper.selectByExample(pmsPatientExample); + if (CollectionUtil.isEmpty(pmsPatients)) { + PmsPatient pmsPatient = new PmsPatient(); + pmsPatient.setId(IdUtil.getSnowflakeNextId()); + pmsPatient.setPhone(scrScreeningDetail1.getAnswer()); + pmsPatient.setName(scrScreeningDetail.getAnswer()); + if (ObjectUtil.isNotNull(map.get("SCWJ-BIRTH"))) { + pmsPatient.setBirthDate(DateUtil.parse(map.get("SCWJ-BIRTH").getAnswer())); + } + if (ObjectUtil.isNotNull(map.get("SCWJ-SEX"))) { + pmsPatient.setGender(Byte.parseByte(map.get("SCWJ-SEX").getAnswer())); + } + pmsPatient.setSource((byte) 0); + pmsPatient.setDelFlag((byte) 0); + pmsPatient.setCreateTime(new Date()); + pmsPatientMapper.insertSelective(pmsPatient); + } + } } @Override diff --git a/acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml b/acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml index bd5d0f80..0ec75735 100644 --- a/acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml +++ b/acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml @@ -56,6 +56,8 @@ p.name LIKE CONCAT('%', #{query.keywords}, '%') OR p.pinyin_full LIKE CONCAT('%', #{query.keywords}, '%') OR p.pinyin_simple LIKE CONCAT('%', #{query.keywords}, '%') + or p.id_card LIKE CONCAT('%', #{query.keywords}, '%') + or p.phone LIKE CONCAT('%', #{query.keywords}, '%') )