陈昶聿
5 天以前 284df1b9b053dc036004ed9dc5a941a238164efc
smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -18,6 +18,7 @@
import com.smartor.service.IServiceExternalService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -815,10 +816,16 @@
            patMedInhosp1.setDiagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC());
        }
        patMedInhosp1.setInhospstate("1");
        String orgid = ObjectUtils.isNotEmpty(BingRenXX) && ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null;
        if(StringUtils.isNotEmpty(orgid) && orgid.equals("47246103233112211A1001")){
            //缙云二院 住院记录不更新状态
        }else {
            patMedInhosp1.setInhospstate("1");
        }
        if (CollectionUtils.isNotEmpty(patMedInhospList)) {
            patMedInhosp1.setUpdateTime(new Date());
            patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX) && ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null);
            patMedInhosp1.setOrgid(orgid);
            if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) {
                //不需要长期任务随访
                patMedInhosp1.setFuflag("0");
@@ -831,7 +838,7 @@
                patMedInhosp1.setHospitalcode(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null);
                patMedInhosp1.setLeavehospitaldistrictname(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianBQMC")) ? BingRenXX.get("DangQianBQMC").toString() : null);
                patMedInhosp1.setLeavehospitaldistrictcode(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianBQID")) ? BingRenXX.get("DangQianBQID").toString() : null);
                patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null);
                patMedInhosp1.setOrgid(orgid);
                //丽水无院区,默认值是 1
                patMedInhosp1.setCampusid("1");
                patMedInhosp1.setPatno(ObjectUtils.isNotEmpty(BingRenXX.get("BingRenID")) ? BingRenXX.get("BingRenID").toString() : null);
@@ -1164,7 +1171,7 @@
        List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.callSpQueryOuthosp(patMedOuthospreq);
        for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
            PatArchive pa = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid());
            if (patArchive.getBirthdate() != null) {
            if (ObjectUtils.isNotEmpty(patArchive) && patArchive.getBirthdate() != null) {
                Map<String, String> map = calculateAge(pa.getBirthdate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now());
                pa.setAge(ObjectUtils.isNotEmpty(map.get("age")) ? Long.valueOf(map.get("age")) : null);
                pa.setAgeUnit(map.get("ageUnit"));
@@ -1242,10 +1249,22 @@
            i = patMedOuthospService.insertPatMedOuthosp(patMedOuthosp);
        }
        Date adminDate = externalJZInfo.getJiuZhenRQ();
        Date adminDate = patMedOuthosp.getAdmitdate();
        //完成接诊 已经完成任务再次随访
        if(ObjectUtils.isNotEmpty(visitTimeNum) && ObjectUtils.isNotEmpty(adminDate)){
            patMedOuthospService.followUpAgainByPatMedOuthosp(patMedOuthosp, adminDate, visitTimeNum);
        if(ObjectUtils.isNotEmpty(visitTimeNum)
                && ObjectUtils.isNotEmpty(adminDate)
                && StringUtils.isNotEmpty(patMedOuthosp.getFuflag())
                && patMedOuthosp.getFuflag().equals("1")){
            if(visitTimeUnit.equals("天")){
                visitTimeNum = visitTimeNum;
            }else if(visitTimeUnit.equals("周")){
                visitTimeNum = visitTimeNum * 7;
            }else if(visitTimeUnit.equals("月")){
                visitTimeNum = visitTimeNum * 30;
            }else if(visitTimeUnit.equals("年")){
                visitTimeNum = visitTimeNum * 365;
            }
            patMedOuthospService.dealPatMedOuthosp(patMedOuthosp, visitTimeNum);
        }
        if (i > 0) {
@@ -1337,7 +1356,6 @@
        ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true);
        PatArchive patArchive = addPatArchive(externalInHospPatientInfo, null, null);
        //手术信息新增
        Map<String, Object> ssxx = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("ShouShuSQ") : null;
        //手术更新
@@ -1353,12 +1371,6 @@
            externalOperationInfo = BeanUtil.mapToBean(sscx, ExternalOperationInfo.class, true);
        PatMedOperation patMedOperation = new PatMedOperation();
        patMedOperation.setPatid(patArchive.getId());
        patMedOperation.setPatcode(externalInHospPatientInfo.getBingRenID());
        patMedOperation.setPaname(externalInHospPatientInfo.getXingMing());
        patMedOperation.setLeaveldeptcode(externalInHospPatientInfo.getDangQianKSID());
        patMedOperation.setLeaveldeptname(externalInHospPatientInfo.getDangQianKSMC());
        patMedOperation.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID());
        patMedOperation.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC());
        patMedOperation.setOpreqcode(externalOperationInfo.getShenQingDID());
        //查询一下,该患者是否已经有这些数据
        List<PatMedOperation> patMedOperations = patMedOperationMapper.selectPatMedOperationList(patMedOperation);
@@ -1413,6 +1425,13 @@
            patMedOperation.setInhospno(externalInHospPatientInfo.getBingAnHao());
            patMedOperation.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC());
            patMedOperation.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID());
            patMedOperation.setPatcode(externalInHospPatientInfo.getBingRenID());
            patMedOperation.setPaname(externalInHospPatientInfo.getXingMing());
            patMedOperation.setLeaveldeptcode(externalInHospPatientInfo.getDangQianKSID());
            patMedOperation.setLeaveldeptname(externalInHospPatientInfo.getDangQianKSMC());
            patMedOperation.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID());
            patMedOperation.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC());
        }
        patMedOperation.setHospitaldistrictcode(null);
        patMedOperation.setHospitaldistrictname(null);
@@ -1457,6 +1476,10 @@
                return info;
            }).collect(Collectors.toList()) : null;
            if(ObjectUtils.isNotEmpty(patMedOperation.getId())){
                patMedOperationItemMapper.deleteHardPatMedOperationItemByOpId(patMedOperation.getId().toString());
            }
            //addMianTableFalg是否需要将主手术的信息放到PatMedOperation表中(只有第一个主手术信息需要放,后面的都不需要放了,也就是说,第一个放完后,就要把这个flag改成false)
            Boolean addMianTableFalg = true;
            for (ExternalOperationDetail externalOperationDetail : externalOperationDetails) {
@@ -1490,6 +1513,7 @@
                    addMianTableFalg = false;
                }
                patMedOperationItem.setCreateTime(new Date());
                patMedOperationItem.setUpdateTime(new Date());
                patMedOperationItemMapper.insertPatMedOperationItem(patMedOperationItem);
            }
        }
@@ -1984,6 +2008,12 @@
                log.info("手术申请入参类型为:{}", type);
                addOperationInfo(dataMap);
                return true;
            case "SM_SQ_ShouShuAP":
                log.info("手术安排入参类型为:{}", type);
                return true;
            case "SM_SQ_CheXiao":
                log.info("手术撤销入参类型为:{}", type);
                return true;
            case "TJ_YW_BaoGaoXX":
                log.info("体检报告入参类型为:{}", type);
                return true;