浏览代码

调佣分组质控接口保存日志,分组信息功能

lihong 2 年之前
父节点
当前提交
efb513c143

+ 7 - 1
src/main/java/thyyxxk/webserver/constants/sidicts/SiFunction.java

@@ -591,7 +591,13 @@ public enum SiFunction {
     /**
      * 通过此交易下载【1301-1319】目录信息下载、【5204】费用明细查询、【3202】医药机构费用结算对明细账交易生成的文件(文件下载)
      */
-    DOWNLOAD_FILE("9102", "");
+    DOWNLOAD_FILE("9102", ""),
+    /* =========================================== 创智接口 ========================================== */
+    DRG_GROUP_INFO("100001","分组接口"),
+
+    QUALITY_INFO("100002","质控接口")
+
+    ;
 
     private final String code;
     

+ 18 - 0
src/main/java/thyyxxk/webserver/controller/medicalinsurance/SetlListUpldController.java

@@ -24,6 +24,7 @@ import thyyxxk.webserver.entity.querydata.AutoUploadBill;
 import thyyxxk.webserver.entity.querydata.JieSuanDanChaXun;
 import thyyxxk.webserver.entity.querydata.SiSetlinfoTemp;
 import thyyxxk.webserver.entity.querydata.TSetlDeptConf;
+import thyyxxk.webserver.entity.querydata.TUploadDrgGroup;
 import thyyxxk.webserver.entity.vo.quality.QualityInfoVO;
 import thyyxxk.webserver.service.medicalinsurance.SetlListUpldService;
 import thyyxxk.webserver.utils.ResultVoUtil;
@@ -322,6 +323,17 @@ public class SetlListUpldController {
     public ResultVo<String> removeBloodTransfusion(@RequestParam("id") Integer id) {
         return service.removeBloodTransfusion(id);
     }
+    /**
+     * @description:导出分组信息
+     * @author: lihong
+     * @date: 2023/1/4 14:35
+     * @param: response
+     * @param: param
+     **/
+    @PostMapping("/exportDrgGroupInfo")
+    public void exportDrgGroupInfo(HttpServletResponse response,@RequestBody TUploadDrgGroup query) {
+        service.exportDrgGroupInfo(response,query);
+    }
     /**
      * @description:导出上传日志
      * @author: lihong
@@ -374,4 +386,10 @@ public class SetlListUpldController {
     public ResultVo<Integer> getUploadMaxDay() {
         return service.getUploadMaxDay();
     }
+
+
+    @PostMapping("/queryDrgGroupPage")
+    public ResultVo<IPage<TUploadDrgGroup>> queryDrgGroupPage(@RequestBody TUploadDrgGroup query) {
+        return ResultVoUtil.success(service.queryDrgGroupPage(query));
+    }
 }

+ 18 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/TUploadDrgGroupDao.java

@@ -0,0 +1,18 @@
+package thyyxxk.webserver.dao.his.medicalinsurance;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import thyyxxk.webserver.entity.querydata.TUploadDrgGroup;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author lihong
+ * @since 2023-01-29
+ */
+@Mapper
+public interface TUploadDrgGroupDao extends BaseMapper<TUploadDrgGroup> {
+
+}

+ 3 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/UpIdCollectionDao.java

@@ -21,6 +21,7 @@ import thyyxxk.webserver.entity.medicalinsurance.setllistupld.*;
 import thyyxxk.webserver.entity.querydata.SiSetlinfoTemp;
 import thyyxxk.webserver.entity.querydata.TAutoUploadBill;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -995,4 +996,6 @@ public interface UpIdCollectionDao extends BaseMapper<SetlinfoUpld> {
 
     @Select(" select  count(1) from    t_case_frontsheet_main where bah=#{inpatientNo} and admiss_times = #{admissTimes}")
     Integer queryCountTCaseFrontsheetMain(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
+    @Select(" select medfee_sumamt from t_si_setlinfo  where   pat_no = #{patNo} and  times =#{times} and ledger_sn = #{ledgerSn}")
+    BigDecimal getsetlTotalFee(@Param("patNo") String patNo, @Param("times") Integer times,@Param("ledgerSn")Integer ledgerSn);
 }

+ 17 - 3
src/main/java/thyyxxk/webserver/entity/medicalinsurance/log/SiLog.java

@@ -1,8 +1,5 @@
 package thyyxxk.webserver.entity.medicalinsurance.log;
 
-import java.io.Serializable;
-import java.util.Date;
-
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
@@ -10,6 +7,9 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
+import java.io.Serializable;
+import java.util.Date;
+
 @Data
 @TableName("t_si_log")
 public class SiLog implements Serializable {
@@ -113,4 +113,18 @@ public class SiLog implements Serializable {
 		setInfcode(infcode);
 		setPsnNo(psnNo);
 	}
+
+	public SiLog(String msgid, String infno, String insuplcAdmdvs, String opter, String body,String result, String patNo, Integer times, Integer ledgerSn, Integer logType, String psnNo) {
+		this.msgid = msgid;
+		this.infno = infno;
+		this.insuplcAdmdvs = insuplcAdmdvs;
+		this.opter = opter;
+		this.body = body;
+		this.result = result;
+		this.patNo = patNo;
+		this.times = times;
+		this.ledgerSn = ledgerSn;
+		this.logType = logType;
+		this.psnNo = psnNo;
+	}
 }

+ 114 - 0
src/main/java/thyyxxk/webserver/entity/querydata/TUploadDrgGroup.java

@@ -0,0 +1,114 @@
+package thyyxxk.webserver.entity.querydata;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * <p>
+ * 分组结果表
+ * </p>
+ *
+ * @author lihong
+ * @since 2023-01-29
+ */
+@Data
+@TableName("t_upload_drg_group")
+public class TUploadDrgGroup implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 分组编码
+     */
+    private String code;
+
+    /**
+     * 分组名称
+     */
+    private String name;
+
+    /**
+     * 权重
+     */
+    private BigDecimal weight;
+
+    /**
+     * 倍率
+     */
+    private String bl;
+
+    /**
+     * 盈亏额
+     */
+    private BigDecimal profit;
+
+    /**
+     * 标杆费用
+     */
+    @TableField(value = "fee_stand")
+    private BigDecimal feeStand;
+
+    /**
+     * 住院号
+     */
+    @TableField(value = "pat_no")
+    private String patNo;
+
+    /**
+     * 住院次数
+     */
+    private Integer times;
+    /**
+     * 账页号
+     */
+    @TableField(value = "ledger_sn")
+    private Integer ledgerSn;
+
+    /**
+     * 分组提示
+     */
+    @TableField(value = "group_messages")
+    private String groupMessages;
+    /**
+     * 总费用
+     */
+    @TableField(value = "total_fee")
+    private BigDecimal totalFee;
+
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time")
+    private Date createTime;
+
+    /**
+     * 结算时间
+     */
+    @TableField(value = "setl_time")
+    private Date setlTime;
+
+    @TableField(exist = false)
+    private long currentPage;
+    /**
+     * 分页
+     */
+    @TableField(exist = false)
+    private long pageSize;
+
+    @TableField(exist = false)
+    private String setlStartTime;
+
+    @TableField(exist = false)
+    private String setlEndTime;
+
+}

+ 53 - 0
src/main/java/thyyxxk/webserver/entity/vo/quality/GroupInfoVO.java

@@ -0,0 +1,53 @@
+package thyyxxk.webserver.entity.vo.quality;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author:lihong
+ * @Date: 2023/1/29
+ */
+@Data
+public class GroupInfoVO implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 分组编码
+     */
+    private String code;
+
+    /**
+     * 分组名称
+     */
+    private String name;
+
+    /**
+     * 权重
+     */
+    private BigDecimal weight;
+
+    /**
+     * 倍率
+     */
+    private String bl;
+
+    /**
+     * 盈亏额
+     */
+    private BigDecimal profit;
+
+    /**
+     * 标杆费用
+     */
+    private BigDecimal fee_stand;
+
+    /**
+     * 分组提示
+     */
+    private List<String> group_messages;
+
+
+}

+ 129 - 50
src/main/java/thyyxxk/webserver/service/medicalinsurance/SetlListUpldService.java

@@ -1,6 +1,8 @@
 package thyyxxk.webserver.service.medicalinsurance;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.bean.copier.CopyOptions;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.ReflectUtil;
@@ -56,8 +58,10 @@ import thyyxxk.webserver.entity.querydata.AutoUploadBill;
 import thyyxxk.webserver.entity.querydata.JieSuanDanChaXun;
 import thyyxxk.webserver.entity.querydata.SiSetlinfoTemp;
 import thyyxxk.webserver.entity.querydata.TSetlDeptConf;
+import thyyxxk.webserver.entity.querydata.TUploadDrgGroup;
 import thyyxxk.webserver.entity.vo.DrgGroupTestVO;
 import thyyxxk.webserver.entity.vo.quality.DiseInfoListVO;
+import thyyxxk.webserver.entity.vo.quality.GroupInfoVO;
 import thyyxxk.webserver.entity.vo.quality.OprtInfoListVO;
 import thyyxxk.webserver.entity.vo.quality.QualityInfoVO;
 import thyyxxk.webserver.entity.vo.quality.SetlBaseInfoVO;
@@ -105,13 +109,16 @@ public class SetlListUpldService {
     private DrgWebServices drgWebServices;
     private AutoUploadBillService autoUploadBillService;
     private TSetlDeptConfService tSetlDeptConfService;
+    private final TUploadDrgGroupService tUploadDrgGroupService;
+    private final SiLogService siLogService;
 
     public SetlListUpldService(ExecService exec, SiQueryDao queryDao, UpIdCollectionDao upIdCollectionDao,
                                DismissDao dismissDao, PublicServer publicServer, SendWxInfoService sendWxInfoService,
                                SiLogDao logDao, CaseFrontSheetMainService caseFrontSheetMainService,
                                RedisLikeService redisLikeService, DrgWebServices drgWebServices,
                                AutoUploadBillService autoUploadBillService,
-                               TSetlDeptConfService tSetlDeptConfService
+                               TSetlDeptConfService tSetlDeptConfService,TUploadDrgGroupService tUploadDrgGroupService,
+                               SiLogService siLogService
     ) {
         this.exec = exec;
         this.queryDao = queryDao;
@@ -125,6 +132,8 @@ public class SetlListUpldService {
         this.drgWebServices = drgWebServices;
         this.autoUploadBillService = autoUploadBillService;
         this.tSetlDeptConfService = tSetlDeptConfService;
+        this.tUploadDrgGroupService = tUploadDrgGroupService;
+        this.siLogService = siLogService;
     }
 
 
@@ -145,6 +154,7 @@ public class SetlListUpldService {
         param.setAdmissTimes(times);
         sheetVerification(param);
         ResultVo<UpldCollection> upldCollection = getUploadInfo(patNo, times, ledgerSn);
+        dealDrgGroup(patNo,times,ledgerSn,upldCollection.getData().getSetlinfo());
         if(checkFlag){
             checkUploadCondition(patNo, upldCollection,times);
         }
@@ -187,6 +197,53 @@ public class SetlListUpldService {
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("医保中心报错的:【%s】 ", errMsg));
     }
 
+
+    public void dealDrgGroup(String patNo, Integer times,Integer ledgerSn, SetlinfoUpld setlinfo) {
+        SiLog siLog = null;
+        try {
+            Integer flag = dao.setlModifyReqAuditFlag(patNo, times);
+            flag = flag == null ? 0 : flag;
+            List<YbZyDisDiag> ybZyDisDiags = dao.zhenDuanXinXi(patNo, times, flag == 1 ? "zy_dis_diag_yb_modify" : "zy_dis_diag_yb");
+            List<BatjBa4> batjBa4s = dao.shouShuXinXi(patNo, times, flag == 1 ? "batj_ba4_modify" : "batj_ba4");
+            ZyInactpatient param = new ZyInactpatient();
+            param.setInpatientNo(patNo);
+            param.setAdmissTimes(times);
+            param.setNewYbZyDisDiag(ybZyDisDiags);
+            param.setNewBatjBa4(batjBa4s);
+            param.setMedfeeSumamt(dao.getsetlTotalFee(patNo,times,ledgerSn));
+            Map<String, Object> temp = getDrgQualityResult(param, setlinfo);
+            JSONObject resultInfo = (JSONObject)temp.get("result");
+            Object drgParam = temp.get("param");
+            siLog = new SiLog(SiUtil.makeMsgId(),SiFunction.DRG_GROUP_INFO.getCode(),setlinfo.getInsuplc(),redisLikeService.getUserInfoByToken().getCode(),JSON.toJSONString(drgParam),JSON.toJSONString(resultInfo),patNo,times,ledgerSn,1,setlinfo.getPsnNo());
+            if (resultInfo.getBooleanValue("isSuccess")) {
+                JSONObject groupInfo = resultInfo.getJSONObject("result").getJSONObject("group_info");
+                GroupInfoVO groupInfoVO = JSON.parseObject(JSON.toJSONString(groupInfo), GroupInfoVO.class);
+                log.info("分组结果[groupInfoVO]:{}",JSON.toJSONString(groupInfoVO));
+                siLog.setInfcode(0);
+                if(groupInfoVO != null){
+                    Map<String, Object> groupInfoVOMap = BeanUtil.beanToMap(groupInfoVO, false, true);
+                    TUploadDrgGroup uploadDrgGroup = new TUploadDrgGroup();
+                    CopyOptions options = new CopyOptions();
+                    options.setIgnoreProperties("group_messages");
+                    BeanUtil.fillBeanWithMap(groupInfoVOMap, uploadDrgGroup, true, options);
+                    uploadDrgGroup.setPatNo(patNo);
+                    uploadDrgGroup.setTimes(times);
+                    uploadDrgGroup.setLedgerSn(ledgerSn);
+                    uploadDrgGroup.setSetlTime(setlinfo.getSetlEndDate());
+                    uploadDrgGroup.setTotalFee(param.getMedfeeSumamt());
+                    if(ListUtil.notBlank(groupInfoVO.getGroup_messages())){
+                        uploadDrgGroup.setGroupMessages(CollUtil.join(groupInfoVO.getGroup_messages(),";"));
+                    }
+                    tUploadDrgGroupService.delAndSaveData(uploadDrgGroup);
+                }
+            }
+        }catch (Exception e){
+            siLog.setInfcode(-1);
+            log.error("处理分组结果报错",e);
+        }
+        siLogService.delAndSave(siLog);
+    }
+
     private void checkUploadCondition(String patNo, ResultVo<UpldCollection> upldCollection,Integer times) {
         if (upldCollection.getCode() != 200) {
             throw new BizException(ExceptionEnum.INTERNAL_SERVER_ERROR, upldCollection.getMessage());
@@ -1834,56 +1891,19 @@ public class SetlListUpldService {
      **/
     public ResultVo<List<QualityInfoVO>> drgQualityTest(ZyInactpatient param) {
         List<QualityInfoVO> qualityInfoVOS;
+        SiLog siLog = null;
         try {
-            String visitId = param.getInpatientNo() + "_" + param.getAdmissTimes();
             SetlinfoUpld setlinfoUpldInfo = getSetlinfoUpldInfo(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn());
             AssertUtil.isnotBlank(setlinfoUpldInfo, "结算清单基本信息为空");
-            Map<String, Object> tempMap = BeanUtil.beanToMap(setlinfoUpldInfo, true, true);
-            SetlBaseInfoVO setlBaseInfoVO = new SetlBaseInfoVO();
-            Map<String, Object> drgQualityParam = new HashMap<>();
-            BeanUtil.fillBeanWithMap(tempMap, setlBaseInfoVO, true);
-            setlBaseInfoVO.setVisit_id(visitId);
-            setlBaseInfoVO.setFixmedins_code("H43010500370");
-            setlBaseInfoVO.setFixmedins_name("长沙泰和医院");
-            setlBaseInfoVO.setTotal_fee(param.getMedfeeSumamt() == null ? null : param.getMedfeeSumamt().toString());
-            //格式化一些时间的问题
-            formatSetlBaseInfoVO(setlBaseInfoVO, setlinfoUpldInfo);
-
-            log.info("setlBaseInfoVO 基本信息传参:{}", JSON.toJSONString(setlBaseInfoVO));
-            drgQualityParam.put("base_info", setlBaseInfoVO);
-            //诊断
-            //先诊断转码 国临 转医保
-            if (ListUtil.notBlank(param.getNewYbZyDisDiag())) {
-                List<String> disCode = param.getNewYbZyDisDiag().stream().map(YbZyDisDiag::getDisDiag).collect(Collectors.toList());
-                List<Map<String, String>> ybDisCodes = dao.listYbDiseOrOprt(disCode, "zd_icd_code_new");
-                List<DiseInfoListVO> diseInfoListVOS = ConvertUtil.ybZyDisDiag2DiseInfoListVO(param.getNewYbZyDisDiag(), visitId, ybDisCodes);
-                drgQualityParam.put("dise_info_list", diseInfoListVOS);
-            } else {
-                drgQualityParam.put("dise_info_list", new ArrayList<>(1));
-            }
-            //手术
-            if (ListUtil.notBlank(param.getNewBatjBa4())) {
-                List<String> oprtCodes = param.getNewBatjBa4().stream().map(BatjBa4::getSsbm).collect(Collectors.toList());
-                List<Map<String, String>> ybOprtCodes = dao.listYbDiseOrOprt(oprtCodes, "zd_icd9_cm3");
-                List<String> mzfsCodes = param.getNewBatjBa4().stream().map(BatjBa4::getMzff).collect(Collectors.toList());
-                List<Map<String, String>> ybMzfs = dao.listZdAnaesthesia(mzfsCodes);
-                List<String> ssysCodes = param.getNewBatjBa4().stream().map(BatjBa4::getSsys).collect(Collectors.toList());
-                List<String> mzysCodes = param.getNewBatjBa4().stream().map(BatjBa4::getMzys).collect(Collectors.toList());
-                if (ListUtil.notBlank(mzysCodes)) {
-                    ssysCodes.addAll(mzysCodes);
-                }
-                //医生转码
-                List<Map<String, String>> ysCodeDict = dao.listYbSsys(ssysCodes);
-                List<OprtInfoListVO> oprtInfoListVOS = ConvertUtil.batjBa4ToOprtInfoListVO(param.getNewBatjBa4(), visitId, ybOprtCodes, ybMzfs, ysCodeDict);
-                drgQualityParam.put("oprt_info_list", oprtInfoListVOS);
-            } else {
-                drgQualityParam.put("oprt_info_list", new ArrayList<>(1));
-            }
-            log.info("质控测算传参:{}", JSON.toJSONString(drgQualityParam));
-            JSONObject resultInfo = drgWebServices.drgQuality(JSON.parseObject(JSON.toJSONString(drgQualityParam)));
+            Map<String,Object> tempResult = getDrgQualityResult(param, setlinfoUpldInfo);
+            JSONObject resultInfo = (JSONObject)tempResult.get("result");
+            Object qualityParam = tempResult.get("param");
             log.info("质控测算返回:{}", JSON.toJSONString(resultInfo));
+            siLog = new SiLog(SiUtil.makeMsgId(),SiFunction.QUALITY_INFO.getCode(),setlinfoUpldInfo.getInsuplc(),redisLikeService.getUserInfoByToken().getCode(),JSON.toJSONString(qualityParam),JSON.toJSONString(resultInfo),param.getInpatientNo(),param.getAdmissTimes(),param.getLedgerSn(),1,setlinfoUpldInfo.getPsnNo());
             if (resultInfo.getBooleanValue("isSuccess")) {
+                siLog.setInfcode(0);
                 JSONArray jsonArray = resultInfo.getJSONObject("result").getJSONArray("quality_info");
+                siLogService.delAndSave(siLog);
                 if (jsonArray.isEmpty()) {
                     return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "没有质控问题数据");
                 }
@@ -1893,10 +1913,14 @@ public class SetlListUpldService {
                     return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "没有质控问题数据");
                 }
             } else {
+                siLog.setInfcode(-1);
+                siLogService.delAndSave(siLog);
                 throw new BizException(ExceptionEnum.LOGICAL_ERROR, "创智质控测算接口调用失败");
             }
 
         } catch (Exception e) {
+            siLog.setInfcode(-1);
+            siLogService.delAndSave(siLog);
             if (e instanceof BizException) {
                 throw new BizException(ExceptionEnum.LOGICAL_ERROR, e.getMessage());
             } else {
@@ -1907,6 +1931,57 @@ public class SetlListUpldService {
         return ResultVoUtil.success(qualityInfoVOS);
     }
 
+    public Map<String,Object> getDrgQualityResult(ZyInactpatient param, SetlinfoUpld setlinfoUpldInfo) {
+        Map<String, Object> resultMap = new HashMap<>();
+        String visitId = param.getInpatientNo() + "_" + param.getAdmissTimes();
+        Map<String, Object> tempMap = BeanUtil.beanToMap(setlinfoUpldInfo, true, true);
+        SetlBaseInfoVO setlBaseInfoVO = new SetlBaseInfoVO();
+        Map<String, Object> drgQualityParam = new HashMap<>();
+        BeanUtil.fillBeanWithMap(tempMap, setlBaseInfoVO, true);
+        setlBaseInfoVO.setVisit_id(visitId);
+        setlBaseInfoVO.setFixmedins_code("H43010500370");
+        setlBaseInfoVO.setFixmedins_name("长沙泰和医院");
+        setlBaseInfoVO.setTotal_fee(param.getMedfeeSumamt() == null ? null : param.getMedfeeSumamt().toString());
+        //格式化一些时间的问题
+        formatSetlBaseInfoVO(setlBaseInfoVO, setlinfoUpldInfo);
+
+        log.info("setlBaseInfoVO 基本信息传参:{}", JSON.toJSONString(setlBaseInfoVO));
+        drgQualityParam.put("base_info", setlBaseInfoVO);
+        //诊断
+        //先诊断转码 国临 转医保
+        if (ListUtil.notBlank(param.getNewYbZyDisDiag())) {
+            List<String> disCode = param.getNewYbZyDisDiag().stream().map(YbZyDisDiag::getDisDiag).collect(Collectors.toList());
+            List<Map<String, String>> ybDisCodes = dao.listYbDiseOrOprt(disCode, "zd_icd_code_new");
+            List<DiseInfoListVO> diseInfoListVOS = ConvertUtil.ybZyDisDiag2DiseInfoListVO(param.getNewYbZyDisDiag(), visitId, ybDisCodes);
+            drgQualityParam.put("dise_info_list", diseInfoListVOS);
+        } else {
+            drgQualityParam.put("dise_info_list", new ArrayList<>(1));
+        }
+        //手术
+        if (ListUtil.notBlank(param.getNewBatjBa4())) {
+            List<String> oprtCodes = param.getNewBatjBa4().stream().map(BatjBa4::getSsbm).collect(Collectors.toList());
+            List<Map<String, String>> ybOprtCodes = dao.listYbDiseOrOprt(oprtCodes, "zd_icd9_cm3");
+            List<String> mzfsCodes = param.getNewBatjBa4().stream().map(BatjBa4::getMzff).collect(Collectors.toList());
+            List<Map<String, String>> ybMzfs = dao.listZdAnaesthesia(mzfsCodes);
+            List<String> ssysCodes = param.getNewBatjBa4().stream().map(BatjBa4::getSsys).collect(Collectors.toList());
+            List<String> mzysCodes = param.getNewBatjBa4().stream().map(BatjBa4::getMzys).collect(Collectors.toList());
+            if (ListUtil.notBlank(mzysCodes)) {
+                ssysCodes.addAll(mzysCodes);
+            }
+            //医生转码
+            List<Map<String, String>> ysCodeDict = dao.listYbSsys(ssysCodes);
+            List<OprtInfoListVO> oprtInfoListVOS = ConvertUtil.batjBa4ToOprtInfoListVO(param.getNewBatjBa4(), visitId, ybOprtCodes, ybMzfs, ysCodeDict);
+            drgQualityParam.put("oprt_info_list", oprtInfoListVOS);
+        } else {
+            drgQualityParam.put("oprt_info_list", new ArrayList<>(1));
+        }
+        log.info("质控测算传参:{}", JSON.toJSONString(drgQualityParam));
+        JSONObject result =  drgWebServices.drgQuality(JSON.parseObject(JSON.toJSONString(drgQualityParam)));
+        resultMap.put("result",result);
+        resultMap.put("param",drgQualityParam);
+        return resultMap;
+    }
+
     private void formatSetlBaseInfoVO(SetlBaseInfoVO setlBaseInfoVO, SetlinfoUpld setlinfoUpldInfo) {
         String timepatten = "yyyy-MM-dd HH:mm:ss";
         setlBaseInfoVO.setAge(StringUtil.notBlank(setlinfoUpldInfo.getAge()) ? String.valueOf(new BigDecimal(setlinfoUpldInfo.getAge()).intValue()) : null);
@@ -1976,11 +2051,7 @@ public class SetlListUpldService {
                 isFertilitySign = true;
             }
         }
-        // 如果是生育住院的那么 医保支付方式 为 1 按项目
-        if (isFertilitySign) {
-            setlinfoUpld.setHiPaymtd("1");
-        }
-        setlinfoUpld.setHiPaymtd(getDrgHaiPay(setlinfoUpld.getInsuplc(),setlinfoUpld.getHiPaymtd(),setlinfoUpld.getSetlEndDate()));
+        setlinfoUpld.setHiPaymtd(CommonUtil.calcHiPaymtd(setlinfoUpld.getInsuplc(),medType,setlinfoUpld.getHiType(),setlinfoUpld.getSetlEndDate()).toString());
         //  如果是 职工基本医疗保险的话 没有单位名称和地址 那么就 写死成 普通职工 和 现住址
         if ("310".equals(setlinfoUpld.getHiType())) {
             if (StringUtil.isBlank(setlinfoUpld.getEmpAddr())) {
@@ -2179,4 +2250,12 @@ public class SetlListUpldService {
         Integer day =  NumberUtil.isInteger(temp) ? Integer.parseInt(temp) : 7;
         return ResultVoUtil.success(day);
     }
+
+    public IPage<TUploadDrgGroup> queryDrgGroupPage(TUploadDrgGroup query) {
+       return tUploadDrgGroupService.queryUploadDrgGroupPage(query);
+    }
+
+    public void exportDrgGroupInfo(HttpServletResponse response, TUploadDrgGroup query) {
+         tUploadDrgGroupService.exportDrgGroupInfo(response,query);
+    }
 }

+ 13 - 0
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiLogService.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.service.medicalinsurance;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,7 @@ import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.medicalinsurance.log.FetchLog;
 import thyyxxk.webserver.entity.medicalinsurance.log.SiLog;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.AssertUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
 
 import java.text.NumberFormat;
@@ -60,4 +62,15 @@ public class SiLogService {
         return ResultVoUtil.success(dao.selectById(msgid));
     }
 
+    public void delAndSave(SiLog siLog) {
+        AssertUtil.isnotBlank(siLog.getPatNo(),"病案号不能为空");
+        AssertUtil.isnotBlank(siLog.getTimes(),"住院次数不能为空");
+        AssertUtil.isnotBlank(siLog.getLedgerSn(),"账页号不能为空");
+        QueryWrapper queryWrapper = new QueryWrapper();
+        queryWrapper.eq("pat_no",siLog.getPatNo());
+        queryWrapper.eq("times",siLog.getTimes());
+        queryWrapper.eq("ledger_sn",siLog.getLedgerSn());
+        dao.delete(queryWrapper);
+        dao.insert(siLog);
+    }
 }

+ 74 - 0
src/main/java/thyyxxk/webserver/service/medicalinsurance/TUploadDrgGroupService.java

@@ -0,0 +1,74 @@
+package thyyxxk.webserver.service.medicalinsurance;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.dao.his.medicalinsurance.TUploadDrgGroupDao;
+import thyyxxk.webserver.entity.HeadInfo;
+import thyyxxk.webserver.entity.querydata.TUploadDrgGroup;
+import thyyxxk.webserver.utils.ExcelUtil;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author lihong
+ * @since 2023-01-29
+ */
+@Service
+public class TUploadDrgGroupService extends ServiceImpl<TUploadDrgGroupDao, TUploadDrgGroup> {
+
+
+    public IPage<TUploadDrgGroup> queryUploadDrgGroupPage(TUploadDrgGroup uploadDrgGroup){
+        IPage<TUploadDrgGroup> page = new Page(uploadDrgGroup.getCurrentPage(),uploadDrgGroup.getPageSize());
+        QueryWrapper<TUploadDrgGroup> query = gettUploadDrgGroupQueryWrapper(uploadDrgGroup);
+        baseMapper.selectPage(page,query);
+        return page;
+    }
+
+    @NotNull
+    private QueryWrapper<TUploadDrgGroup> gettUploadDrgGroupQueryWrapper(TUploadDrgGroup uploadDrgGroup) {
+        QueryWrapper<TUploadDrgGroup> query = new QueryWrapper<>();
+        query.eq(StringUtils.isNotBlank(uploadDrgGroup.getPatNo()),"pat_no", uploadDrgGroup.getPatNo());
+        query.eq(uploadDrgGroup.getTimes() !=null,"times", uploadDrgGroup.getTimes());
+        query.eq(uploadDrgGroup.getLedgerSn() !=null,"ledger_sn", uploadDrgGroup.getLedgerSn());
+        query.ge(StringUtils.isNotBlank(uploadDrgGroup.getSetlStartTime()), "setl_time", uploadDrgGroup.getSetlStartTime());
+        query.le(StringUtils.isNotBlank(uploadDrgGroup.getSetlEndTime()), "setl_time", uploadDrgGroup.getSetlEndTime());
+        return query;
+    }
+
+
+    public void delAndSaveData(TUploadDrgGroup uploadDrgGroup) {
+        QueryWrapper<TUploadDrgGroup> query = new QueryWrapper<>();
+        query.eq("pat_no",uploadDrgGroup.getPatNo());
+        query.eq("times", uploadDrgGroup.getTimes());
+        query.eq("ledger_sn",uploadDrgGroup.getLedgerSn());
+        baseMapper.delete(query);
+        baseMapper.insert(uploadDrgGroup);
+    }
+    /**
+     * @description:导出
+     * @author: lihong
+     * @date: 2023/1/30 9:23
+     * @param: response
+     * @param: query
+     **/
+    public void exportDrgGroupInfo(HttpServletResponse response, TUploadDrgGroup query) {
+        List<TUploadDrgGroup> list = baseMapper.selectList(gettUploadDrgGroupQueryWrapper(query));
+        List<Map<String, Object>> result = ExcelUtil.beanToMap(list,TUploadDrgGroup.class);
+        String[] display = {"住院号","住院次数","账页号","分组编码","分组名称","权重","病历类型","盈亏额","标杆费用","总费用","结算时间","分组提示"};
+        String[] names = {"patNo","times","ledgerSn","code","name","weight","bl","profit","feeStand","totalFee","setlTime","groupMessages"};
+        List<HeadInfo> headList = ExcelUtil.createHeadInfos(display,names);
+        ExcelUtil.exportExcelReport(response,result,headList,"drg分组信息");
+    }
+}

+ 46 - 1
src/main/java/thyyxxk/webserver/utils/ExcelUtil.java

@@ -1,5 +1,7 @@
 package thyyxxk.webserver.utils;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ReflectUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFCell;
@@ -21,17 +23,19 @@ import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.RegionUtil;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jetbrains.annotations.NotNull;
-import thyyxxk.webserver.entity.nationalmatch.SiCentralSuppliesMini;
 import thyyxxk.webserver.entity.HeadInfo;
+import thyyxxk.webserver.entity.nationalmatch.SiCentralSuppliesMini;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -381,4 +385,45 @@ public class ExcelUtil {
         return value;
     }
 
+    /**
+     * @description:封装导出的表头 displays 和 names 按顺序一一对应,长度必须一样
+     * @author: lihong
+     * @date: 2023/1/30 10:35
+     * @param: displays  字段中文
+     * @param: names  字段
+     * @return: java.util.List<thyyxxk.webserver.entity.HeadInfo>
+     **/
+    public static  List<HeadInfo>  createHeadInfos(String[] displays,String[] names){
+        List<HeadInfo> headList = new ArrayList<>(displays.length);
+        for (int i = 0; i < displays.length; i++) {
+            HeadInfo headInfo = new HeadInfo();
+            headInfo.setDisplay(displays[i]);
+            headInfo.setName(names[i]);
+            headList.add(headInfo);
+        }
+        return headList;
+    }
+    /**
+     * @description:集合bean转为map 格式化时间类型
+     * @author: lihong
+     * @date: 2023/1/30 10:47
+     * @param: list
+     * @param: beanClass
+     * @return: java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
+     **/
+    public static<T> List<Map<String,Object>>  beanToMap(List<T> list,Class<?> beanClass){
+        List<Map<String, Object>> result = new ArrayList<>();
+        list.forEach(bean -> {
+            Map<String, Object> temp = BeanUtil.beanToMap(bean);
+            Field[] fields = ReflectUtil.getFields(beanClass);
+            for (Field field : fields) {
+                Object fieldValue = ReflectUtil.getFieldValue(bean, field);
+                if(fieldValue instanceof Date){
+                    temp.put(ReflectUtil.getFieldName(field),cn.hutool.core.date.DateUtil.formatDateTime((Date)fieldValue));
+                }
+            }
+            result.add(temp);
+        });
+        return result;
+    }
 }