liusheng
2025-03-03 88c5064877fa22316d794c225fff3ceced4371f3
smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -1,7 +1,5 @@
package com.smartor.service.impl;
import java.lang.reflect.Field;
import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
@@ -9,21 +7,22 @@
import com.smartor.domain.*;
import com.smartor.mapper.*;
import com.smartor.service.IServiceExternalService;
import com.smartor.service.IServiceSubtaskRecordService;
import com.smartor.service.IServiceSubtaskService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Value;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.security.auth.login.CredentialNotFoundException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@@ -46,11 +45,14 @@
    @Autowired
    private PatMedInhospMapper patMedInhospMapper;
    @Autowired
    private Icd10AssociationMapper icd10AssociationMapper;
    private PatMedOperationMapper patMedOperationMapper;
    @Autowired
    private IServiceSubtaskService iServiceSubtaskService;
    private PatMedOperationItemMapper patMedOperationItemMapper;
    @Autowired
    private Icd10Mapper icd10Mapper;
    @Value("${defaultPwd}")
    private String defaultPwd;
    public Boolean generalInterface(Map dataMap) {
        Map XiaoXiTou = (Map) dataMap.get("XiaoXiTou");
@@ -111,11 +113,15 @@
        ExternalUserInfo externalUserInfo = BeanUtil.mapToBean(yongHuXX, ExternalUserInfo.class, true);
        SysUser sysUser = new SysUser();
        sysUser.setGuid(externalUserInfo.getZuZhiJGID());
        sysUser.setUserName(externalUserInfo.getYongHuID());
        sysUser.setUserName(externalUserInfo.getYongHuDLM());
        sysUser.setNickName(externalUserInfo.getYongHuXM());
        sysUser.setUserType("");
        sysUser.setDeptId(null);
        sysUser.setTitle(null);
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        sysUser.setPassword(passwordEncoder.encode(defaultPwd));
        sysUser.setHisUserId(externalUserInfo.getYongHuID());
        sysUser.setPhonenumber(externalUserInfo.getLianXiDH());
        sysUser.setJobPhone(externalUserInfo.getGongZuoDH());
@@ -320,7 +326,20 @@
    @Override
    public Boolean addFinshJZInfo(Map dataMap) {
        //这个先等等
        log.error("ServiceExternalServiceImpl---addFinshJZInfo的新增的值为:{}", dataMap);
//        Map yeWuXX = (Map) dataMap.get("YeWuXX");
//        Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX");
//        Map<String, Object> JiuZhenXX = (Map<String, Object>) yeWuXX.get("JiuZhenXX");
//        ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true);
//        PatMedOuthosp patMedOuthosp = new PatMedOuthosp();
//        patMedOuthosp.setOuthospno(externalInHospPatientInfo.getBingAnHao());
//        patMedOuthosp.setSerialnum(externalInHospPatientInfo.getBingAnHao());
//        patMedOuthosp.setPatid(Long.valueOf(externalInHospPatientInfo.getBingRenID()));
//        patMedOuthosp.setPatname(externalInHospPatientInfo.getXingMing());
//        patMedOuthosp.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC());
//        patMedOuthosp.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID());
//        patMedOuthosp.setIcd10code();
        return null;
    }
@@ -331,20 +350,20 @@
        Map yeWuXX = (Map) dataMap.get("YeWuXX");
        Map<String, Object> JiBing = (Map<String, Object>) yeWuXX.get("JiBing");
        ExternalDiseaseInfo externalDiseaseInfo = BeanUtil.mapToBean(JiBing, ExternalDiseaseInfo.class, true);
        Icd10Association icd10Association = new Icd10Association();
        icd10Association.setIcd10code(externalDiseaseInfo.getJiBingID());
        icd10Association.setIcd10name(externalDiseaseInfo.getJiBingMC());
        icd10Association.setGuid(externalDiseaseInfo.getZuZhiJGID());
        icd10Association.setOrgid(externalDiseaseInfo.getZuZhiJGID());
        icd10Association.setPid(externalDiseaseInfo.getFUJIBID());
        icd10Association.setIcd10AssortCode(externalDiseaseInfo.getJiBingFLDM());
        icd10Association.setIcd10AssortName(externalDiseaseInfo.getJiBingFLMC());
        icd10Association.setChineseMedicineDiagnoseSign(externalDiseaseInfo.getZhongYiZDBZ());
        icd10Association.setChineseMedicineDiagnoseAssortCode(externalDiseaseInfo.getZhongYiZDFLDM());
        icd10Association.setChineseMedicineDiagnoseAssortName(externalDiseaseInfo.getZhongYiZDFLMC());
        icd10Association.setOutpatientUseAssort(externalDiseaseInfo.getMenZhenSYBZ());
        icd10Association.setInpatientUseAssort(externalDiseaseInfo.getZhuYuanSYBZ());
        icd10AssociationMapper.insertIcd10Association(icd10Association);
        Icd10 icd10 = new Icd10();
        icd10.setIcdcode(externalDiseaseInfo.getJiBingID());
        icd10.setIcdname(externalDiseaseInfo.getJiBingMC());
        icd10.setGuid(externalDiseaseInfo.getZuZhiJGID());
        icd10.setOrgid(externalDiseaseInfo.getZuZhiJGID());
        icd10.setLastflag(externalDiseaseInfo.getMOJIBZ());
        icd10.setChimedflag("" + externalDiseaseInfo.getZhongYiZDBZ());
//        icd10Association.setIcd10AssortName(externalDiseaseInfo.getJiBingFLMC());
//        icd10Association.setChineseMedicineDiagnoseSign(externalDiseaseInfo.getZhongYiZDBZ());
//        icd10Association.setChineseMedicineDiagnoseAssortCode(externalDiseaseInfo.getZhongYiZDFLDM());
//        icd10Association.setChineseMedicineDiagnoseAssortName(externalDiseaseInfo.getZhongYiZDFLMC());
//        icd10Association.setOutpatientUseAssort(externalDiseaseInfo.getMenZhenSYBZ());
//        icd10Association.setInpatientUseAssort(externalDiseaseInfo.getZhuYuanSYBZ());
        icd10Mapper.insertIcd10(icd10);
        return true;
    }
@@ -381,6 +400,134 @@
        return true;
    }
    @Override
    public Boolean addOperationInfo(Map dataMap) {
        log.error("ServiceExternalServiceImpl---addOperationInfo的新增的值为:{}", dataMap);
        Map yeWuXX = (Map) dataMap.get("YeWuXX");
        Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX");
        ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true);
        PatArchive patArchive = addPatArchive(externalInHospPatientInfo, null, null);
        //手术信息新增
        Map<String, Object> ssxx = (Map<String, Object>) yeWuXX.get("ShouShuSQ");
        //手术更新
        Map<String, Object> ssgx = (Map<String, Object>) yeWuXX.get("ShouShuGX");
        //手术撤销
        Map<String, Object> sscx = (Map<String, Object>) yeWuXX.get("ShouShuCX");
        ExternalOperationInfo externalOperationInfo = null;
        if (ObjectUtils.isNotEmpty(ssxx))
            externalOperationInfo = BeanUtil.mapToBean(ssxx, ExternalOperationInfo.class, true);
        else if (ObjectUtils.isNotEmpty(ssgx))
            externalOperationInfo = BeanUtil.mapToBean(ssgx, ExternalOperationInfo.class, true);
        else if (ObjectUtils.isNotEmpty(sscx))
            externalOperationInfo = BeanUtil.mapToBean(sscx, ExternalOperationInfo.class, true);
        PatMedOperation patMedOperation = new PatMedOperation();
        patMedOperation.setPatid(patArchive.getId());
        patMedOperation.setPatcode(externalInHospPatientInfo.getBingRenID());
        patMedOperation.setPaname(externalInHospPatientInfo.getXingMing());
//        patMedOperation.setOpreqid(externalOperationInfo.getShenQingDID());
        patMedOperation.setOpreqcode(externalOperationInfo.getShenQingDID());
        //查询一下,该患者是否已经有这些数据
        List<PatMedOperation> patMedOperations = patMedOperationMapper.selectPatMedOperationList(patMedOperation);
        patMedOperation.setOpsstatus(null);
        patMedOperation.setOptypecode(externalOperationInfo.getShouShuLBDM());
        patMedOperation.setOptypename(externalOperationInfo.getShouShuLBMC());
        patMedOperation.setOperatortime(externalOperationInfo.getYaoQiuSJ());
        patMedOperation.setOpreqtime(externalOperationInfo.getShenQingSJ());
        patMedOperation.setReqdoccode(externalOperationInfo.getShenQingYSID());
        patMedOperation.setReqdocname(externalOperationInfo.getShenQingYSXM());
        patMedOperation.setReqdeptcode(externalOperationInfo.getShenQingKSID());
        patMedOperation.setReqdeptname(externalOperationInfo.getShenQingKSMC());
        patMedOperation.setReqloccode(externalOperationInfo.getShouShuKSID());
        patMedOperation.setReqlocname(externalOperationInfo.getShouShuKSMC());
        patMedOperation.setSurgeoncode(externalOperationInfo.getZhuDaoYSID());
        patMedOperation.setSurgeonname(externalOperationInfo.getSanZhuYSXM());
        patMedOperation.setFirasscode(externalOperationInfo.getYiZhuID());
        patMedOperation.setFirassname(externalOperationInfo.getYiZhuMC());
        patMedOperation.setSecasscode(externalOperationInfo.getErZhuYSID());
        patMedOperation.setSecassname(externalOperationInfo.getErZhuYSXM());
        patMedOperation.setThrasscode(externalOperationInfo.getSanZhuYSID());
        patMedOperation.setThrassname(externalOperationInfo.getSanZhuYSXM());
        patMedOperation.setCanceltime(null);
        patMedOperation.setCancelreason(null);
        patMedOperation.setCancelcode(null);
        patMedOperation.setCancelname(null);
        patMedOperation.setVisittype(null);
        patMedOperation.setStatus(null);
        patMedOperation.setSchemetime(null);
        patMedOperation.setSchemestatus(null);
        patMedOperation.setDelFlag("0");
        patMedOperation.setIsupload(null);
        patMedOperation.setUploadTime(null);
        patMedOperation.setOrgid(externalInHospPatientInfo.getZuZhiJGID());
        patMedOperation.setInhospstate(null);
        patMedOperation.setPatno(externalInHospPatientInfo.getBingRenID());
        patMedOperation.setPatname(externalInHospPatientInfo.getXingMing());
        patMedOperation.setVisitid(null);
        patMedOperation.setSerialnum(externalInHospPatientInfo.getZhuYuanHao());
        patMedOperation.setInhospno(externalInHospPatientInfo.getZhuYuanHao());
        patMedOperation.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC());
        patMedOperation.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID());
        patMedOperation.setDeptid(externalOperationInfo.getShouShuKSID());
        patMedOperation.setDeptcode(externalOperationInfo.getShouShuKSID());
        patMedOperation.setDeptname(externalOperationInfo.getShouShuKSMC());
        patMedOperation.setHospitaldistrictcode(null);
        patMedOperation.setHospitaldistrictname(null);
        patMedOperation.setRoomno(null);
        patMedOperation.setBedNo(null);
        patMedOperation.setDrcode(externalOperationInfo.getZhuDaoYSID());
        patMedOperation.setDrname(externalOperationInfo.getZhuDaoYSXM());
        patMedOperation.setNurseId(null);
        patMedOperation.setNurseName(null);
        if (CollectionUtils.isNotEmpty(patMedOperations)) {
            Long id = patMedOperations.get(0).getId();
            patMedOperation.setId(id);
            patMedOperation.setCheckFlag(patMedOperations.get(0).getCheckFlag());
            //如果手术撤销,直接删除该条手术信息
            if (ObjectUtils.isNotEmpty(sscx)) {
                patMedOperation.setDelFlag("1");
                //同时去查询,是否在subtask中生成任务,如果生成出得立马删除
            }
            patMedOperationMapper.updatePatMedOperation(patMedOperation);
        } else patMedOperationMapper.insertPatMedOperation(patMedOperation);
        log.error("-----patMedOperation的主键id为:{}", patMedOperation.getId());
        if (ObjectUtils.isNotEmpty(ssxx)) {
            Map<String, Object> ShouShuMXList = (Map<String, Object>) ssxx.get("ShouShuMXList");
            List<ExternalOperationDetail> externalOperationDetails = BeanUtil.mapToBean(ShouShuMXList, List.class, true);
            //addMianTableFalg是否需要将主手术的信息放到PatMedOperation表中(只有第一个主手术信息需要放,后面的都不需要放了,也就是说,第一个放完后,就要把这个flag改成false)
            Boolean addMianTableFalg = true;
            for (ExternalOperationDetail externalOperationDetail : externalOperationDetails) {
                PatMedOperationItem patMedOperationItem = new PatMedOperationItem();
                patMedOperationItem.setOpid(patMedOperation.getId());
                patMedOperationItem.setOpcode(externalOperationDetail.getShouShuMCID());
                patMedOperationItem.setOpdesc(externalOperationDetail.getShouShuMC());
                patMedOperationItem.setMainFlag(externalOperationDetail.getZhuShouSBZ());
                patMedOperationItem.setIncitypecode(externalOperationDetail.getQieKouLBDM());
                patMedOperationItem.setIncitypedesc(externalOperationDetail.getQieKouLBMC());
                patMedOperationItem.setOplevelcode(externalOperationDetail.getShouShuJBDM());
                patMedOperationItem.setOpleveldesc(externalOperationDetail.getShouShuJBMC());
                patMedOperationItem.setOpposition(externalOperationDetail.getShouShuBW());
                patMedOperationItem.setDelFlag("0");
                patMedOperationItem.setOrgid(patMedOperation.getOrgid());
                if (externalOperationDetail.getZhuShouSBZ().equals("1") && addMianTableFalg == true) {
                    patMedOperation.setOpcode(externalOperationDetail.getShouShuMCID());
                    patMedOperation.setOpdesc(externalOperationDetail.getShouShuMC());
//                    patMedOperation.setOpid(externalOperationDetail.getShouShuJBDM());
                    patMedOperationMapper.updatePatMedOperation(patMedOperation);
                    addMianTableFalg = false;
                }
                patMedOperationItemMapper.insertPatMedOperationItem(patMedOperationItem);
            }
        }
        return true;
    }
    //新增患者基本信息
    private PatArchive addPatArchive(ExternalInHospPatientInfo externalInHospPatientInfo, ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo, ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo) {
        PatArchive patArchive = new PatArchive();
@@ -396,14 +543,20 @@
        patArchive.setNation(externalInHospPatientInfo.getMinZuMC());
        patArchive.setNativePlace(externalInHospPatientInfo.getGuoJiMC());
        if (ObjectUtils.isNotEmpty(externalInHospPatientAddrInfo)) {
            patArchive.setPlaceOfResidence(externalInHospPatientAddrInfo.getShengFenMC() + externalInHospPatientAddrInfo.getShiDiQMC() + externalInHospPatientAddrInfo.getXianQuMC() + externalInHospPatientAddrInfo.getXiangZhenMC() + externalInHospPatientAddrInfo.getCunJiMC() + externalInHospPatientAddrInfo.getQiTaXX());
            patArchive.setBirthplace(externalInHospPatientAddrInfo.getShengFenMC() + externalInHospPatientAddrInfo.getShiDiQMC() + externalInHospPatientAddrInfo.getXianQuMC() + externalInHospPatientAddrInfo.getXiangZhenMC() + externalInHospPatientAddrInfo.getCunJiMC() + externalInHospPatientAddrInfo.getQiTaXX());
            String por = externalInHospPatientAddrInfo.getShengFenMC() + externalInHospPatientAddrInfo.getShiDiQMC() + externalInHospPatientAddrInfo.getXianQuMC() + externalInHospPatientAddrInfo.getXiangZhenMC() + externalInHospPatientAddrInfo.getCunJiMC() + externalInHospPatientAddrInfo.getQiTaXX();
            patArchive.setPlaceOfResidence(por.replace(null, ""));
            String bp = externalInHospPatientAddrInfo.getShengFenMC() + externalInHospPatientAddrInfo.getShiDiQMC() + externalInHospPatientAddrInfo.getXianQuMC() + externalInHospPatientAddrInfo.getXiangZhenMC() + externalInHospPatientAddrInfo.getCunJiMC() + externalInHospPatientAddrInfo.getQiTaXX();
            patArchive.setBirthplace(bp.replace(null, ""));
        }
        patArchive.setBirthdate(externalInHospPatientInfo.getChuShengRQ());
        patArchive.setAge(externalInHospPatientInfo.getNianLing());
        patArchive.setAgeUnit(externalInHospPatientInfo.getNianLingDW());
        patArchive.setTelcode(externalInHospPatientInfo.getLianXiDH());
        if (StringUtils.isEmpty(externalInHospPatientInfo.getLianXiDH()))
            patArchive.setTelcode(externalInHospPatientInfo.getLianXiRDH());
        patArchive.setRelativetelcode(externalInHospPatientInfo.getLianXiRDH());
        patArchive.setGuid(externalInHospPatientInfo.getZuZhiJGID());
        patArchive.setOrgid(externalInHospPatientInfo.getZuZhiJGID());
        if (ObjectUtils.isNotEmpty(externalInHospPatientLiaisonInfo))
            patArchive.setRelativetelcode(externalInHospPatientLiaisonInfo.getLianXiRDH());
        patArchive.setInhospno(externalInHospPatientInfo.getZhuYuanHao());
@@ -434,7 +587,9 @@
            patMedInhosp.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID());
            patMedInhosp.setStarttime(externalInHospPatientInfo.getRuYuanSJ());
            patMedInhosp.setDeptcode(externalInHospPatientInfo.getDangQianKSID());
            patMedInhosp.setLeaveldeptcode(externalInHospPatientInfo.getDangQianKSID());
            patMedInhosp.setDeptname(externalInHospPatientInfo.getDangQianKSMC());
            patMedInhosp.setLeaveldeptname(externalInHospPatientInfo.getDangQianKSMC());
            patMedInhosp.setBedNo(externalInHospPatientInfo.getDangQianCWID());
            patMedInhosp.setOrgid(externalInHospPatientInfo.getZuZhiJGID());
            patMedInhosp.setHospitaldistrictid(externalInHospPatientInfo.getDangQianBQID());
@@ -443,7 +598,11 @@
            patMedInhosp.setOperator(externalInHospPatientInfo.getCaoZuoRXM());
            patMedInhosp.setOperatorId(externalInHospPatientInfo.getCaoZuoRID());
            patMedInhosp.setHospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID());
            patMedInhosp.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID());
            patMedInhosp.setHospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC());
            patMedInhosp.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC());
            patMedInhosp.setTelcode(patArchive.getTelcode());
            patMedInhosp.setDrname("");
        }
        if (ObjectUtils.isNotEmpty(externalInHospPatientDiagnoseInfo)) {
            patMedInhosp.setIcd10code(StringUtils.isNotEmpty(patMedInhosp.getIcd10code()) ? patMedInhosp.getIcd10code() + "," + externalInHospPatientDiagnoseInfo.getZhenDuanID() : externalInHospPatientDiagnoseInfo.getZhenDuanID());
@@ -454,7 +613,7 @@
            patMedInhosp.setPatid(patArchive.getId());
            patMedInhosp.setPatno(patArchive.getPatientno());
            patMedInhosp.setPatname(patArchive.getName());
            patMedInhosp.setDrname("");
            patMedInhosp.setSchemestatus(1L);
            patMedInhosp.setCreateTime(new Date());
        }
@@ -540,6 +699,7 @@
                return true;
            case "SM_SQ_ShenQing":
                log.error("手术申请入参类型为:{}", type);
                addOperationInfo(dataMap);
                return true;
            case "TJ_YW_BaoGaoXX":
                log.error("体检报告入参类型为:{}", type);