LIJU há 2 meses atrás
pai
commit
9023d0770e

+ 109 - 0
src/main/java/cn/hnthyy/thmz/controller/yb/YbParamController.java

@@ -0,0 +1,109 @@
+package cn.hnthyy.thmz.controller.yb;
+
+import cn.hnthyy.thmz.comment.UserLoginToken;
+import cn.hnthyy.thmz.entity.jy.ResultVo;
+import cn.hnthyy.thmz.service.yb.YbParamService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * 医保参数补全控制器
+ */
+@Slf4j
+@RestController
+@RequestMapping("/YbParam")
+public class YbParamController {
+
+    @Autowired
+    private YbParamService ybParamService;
+
+    /**
+     * 根据医保人员编号获取完整的医保接口参数
+     * @param params 包含psnNo的请求参数
+     * @return 医保接口参数
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/getYbParamsByPsnNo", method = {RequestMethod.POST})
+    public ResultVo getYbParamsByPsnNo(@RequestBody Map<String, String> params) {
+        try {
+            String psnNo = params.get("psnNo");
+            
+            if (StringUtils.isBlank(psnNo)) {
+                return new ResultVo(-1, "医保人员编号不能为空");
+            }
+
+            log.info("获取医保参数请求,psnNo: {}", psnNo);
+            
+            ResultVo result = ybParamService.getYbParamsByPsnNo(psnNo);
+            
+            log.info("获取医保参数响应,psnNo: {}, 结果: {}", psnNo, result);
+            
+            return result;
+            
+        } catch (Exception e) {
+            log.error("获取医保参数异常", e);
+            return new ResultVo(-1, "获取医保参数失败: " + e.getMessage());
+        }
+    }
+
+    /**
+     * 根据医保人员编号获取完整的医保接口参数(GET方式)
+     * @param psnNo 医保人员编号
+     * @return 医保接口参数
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/getYbParamsByPsnNo", method = {RequestMethod.GET})
+    public ResultVo getYbParamsByPsnNoGet(@RequestParam("psnNo") String psnNo) {
+        try {
+            if (StringUtils.isBlank(psnNo)) {
+                return new ResultVo(-1, "医保人员编号不能为空");
+            }
+
+            log.info("获取医保参数请求(GET),psnNo: {}", psnNo);
+            
+            ResultVo result = ybParamService.getYbParamsByPsnNo(psnNo);
+            
+            log.info("获取医保参数响应(GET),psnNo: {}, 结果: {}", psnNo, result);
+            
+            return result;
+            
+        } catch (Exception e) {
+            log.error("获取医保参数异常(GET)", e);
+            return new ResultVo(-1, "获取医保参数失败: " + e.getMessage());
+        }
+    }
+
+    /**
+     * 测试接口 - 验证医保参数补全功能
+     * @param psnNo 医保人员编号
+     * @return 测试结果
+     */
+    @RequestMapping(value = "/testYbParams", method = {RequestMethod.GET})
+    public ResultVo testYbParams(@RequestParam("psnNo") String psnNo) {
+        try {
+            if (StringUtils.isBlank(psnNo)) {
+                return new ResultVo(-1, "医保人员编号不能为空");
+            }
+
+            log.info("测试医保参数补全功能,psnNo: {}", psnNo);
+            
+            ResultVo result = ybParamService.getYbParamsByPsnNo(psnNo);
+            
+            log.info("测试医保参数补全功能结果,psnNo: {}, 结果: {}", psnNo, result);
+            
+            return result;
+            
+        } catch (Exception e) {
+            log.error("测试医保参数补全功能异常", e);
+            return new ResultVo(-1, "测试失败: " + e.getMessage());
+        }
+    }
+} 

+ 83 - 0
src/main/java/cn/hnthyy/thmz/entity/his/yb/SiPatInfo.java

@@ -0,0 +1,83 @@
+package cn.hnthyy.thmz.entity.his.yb;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 医保患者信息表 t_si_pat_info
+ */
+@Data
+public class SiPatInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    // 主键字段
+    private String patNo;        // 住院号/门诊号
+    private Integer times;       // 住院次数/门诊次数
+    private Integer ledgerSn;    // 账页号(门诊固定为0)
+
+    // 医保人员信息
+    private String psnNo;        // 人员编号(医保人员唯一标识)
+    private String psnName;      // 人员姓名
+    private String psnCertType;  // 人员证件类型
+    private String certno;       // 证件号码
+    private String gend;         // 性别
+    private String naty;         // 民族
+    private Date brdy;           // 出生日期
+    private Float age;           // 年龄
+
+    // 医保相关信息
+    private String insutype;     // 险种类型
+    private String medType;      // 医疗类别
+    private String insuplcAdmdvs; // 参保地医保区划
+    private String psnType;      // 人员类别
+    private String psnInsuStas;  // 人员参保状态
+    private Date psnInsuDate;    // 个人参保日期
+    private Integer pausInsuDate; // 暂停参保日期
+    private String cvlservFlag;  // 公务员标志
+    private String empName;      // 单位名称
+    private String psnIdetType;  // 人员身份类别
+    private String psnTypeLv;    // 人员类别等级
+
+    // 就诊结算信息
+    private String mdtrtId;      // 就诊ID
+    private String setlId;       // 结算ID
+    private String medinsSetlId; // 医药机构结算ID
+    private BigDecimal balc;     // 个人账户余额
+
+    // 费用信息
+    private BigDecimal fulamtOwnpayAmt; // 全自费金额
+    private BigDecimal overlmtAmt;      // 超限价金额
+    private BigDecimal preselfpayAmt;   // 先行自付金额
+    private BigDecimal inscpScpAmt;     // 符合政策范围金额
+
+    // 时间信息
+    private Date createDatetime; // 创建时间
+    private Date visitDatetime;  // 就诊时间
+
+    // 消息ID
+    private String admRegMsgid;  // 入院登记消息ID
+    private String setlMsgid;    // 结算消息ID
+    private String rvkSetlMsgid; // 撤销结算消息ID
+
+    // 诊断信息
+    private String diseCode;     // 疾病代码
+    private String diseName;     // 疾病名称
+
+    // 其他信息
+    private String insuplcAdmdvsName; // 参保地医保区划名称
+    private Integer canceAdmissCount; // 取消入院登记次数
+
+    // 追溯码相关字段(从mz_drug_trac_codg表关联查询得到)
+    private String drugTracCodg;    // 药品追溯码
+    private String drugName;         // 药品名称
+    private String specification;    // 规格
+    private String chargeItemCode;   // 收费项目编码
+    private Integer orderNo;         // 处方号
+    private Integer receiptNo;       // 发票分票号
+    private Integer realNo;          // 流水号
+    private Date confirmTime;        // 确认时间
+} 

+ 51 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/yb/SiPatInfoMapper.java

@@ -0,0 +1,51 @@
+package cn.hnthyy.thmz.mapper.his.yb;
+
+import cn.hnthyy.thmz.entity.his.yb.SiPatInfo;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * 医保患者信息表 Mapper
+ */
+public interface SiPatInfoMapper {
+
+    /**
+     * 根据医保人员编号查询患者信息
+     * @param psnNo 医保人员编号
+     * @return 患者信息列表
+     */
+    @Select("SELECT pat_no, times, ledger_sn, psn_no, psn_name, psn_cert_type, certno, " +
+            "gend, naty, brdy, age, insutype, med_type, insuplc_admdvs, psn_type, " +
+            "psn_insu_stas, psn_insu_date, paus_insu_date, cvlserv_flag, emp_name, " +
+            "psn_idet_type, psn_type_lv, mdtrt_id, setl_id, medins_setl_id, balc, " +
+            "fulamt_ownpay_amt, overlmt_amt, preselfpay_amt, inscp_scp_amt, " +
+            "create_datetime, visit_datetime, adm_reg_msgid, setl_msgid, rvk_setl_msgid, " +
+            "dise_code, dise_name, insuplc_admdvs_name, cance_admiss_count " +
+            "FROM t_si_pat_info WHERE psn_no = #{psnNo}")
+    List<SiPatInfo> selectByPsnNo(@Param("psnNo") String psnNo);
+
+    /**
+     * 根据医保人员编号和追溯码关联查询患者信息和追溯码信息
+     * @param psnNo 医保人员编号
+     * @return 患者信息和追溯码信息
+     */
+    @Select("SELECT t.pat_no, t.times, t.ledger_sn, t.psn_no, t.psn_name, t.psn_cert_type, " +
+            "t.certno, t.gend, t.naty, t.brdy, t.age, t.insutype, t.med_type, " +
+            "t.insuplc_admdvs, t.psn_type, t.psn_insu_stas, t.psn_insu_date, " +
+            "t.paus_insu_date, t.cvlserv_flag, t.emp_name, t.psn_idet_type, " +
+            "t.psn_type_lv, t.mdtrt_id, t.setl_id, t.medins_setl_id, t.balc, " +
+            "t.fulamt_ownpay_amt, t.overlmt_amt, t.preselfpay_amt, t.inscp_scp_amt, " +
+            "t.create_datetime, t.visit_datetime, t.adm_reg_msgid, t.setl_msgid, " +
+            "t.rvk_setl_msgid, t.dise_code, t.dise_name, t.insuplc_admdvs_name, " +
+            "t.cance_admiss_count, m.drug_trac_codg, m.drug_name, m.specification, " +
+            "m.charge_item_code, m.order_no, m.receipt_no, m.real_no, m.confirm_time " +
+            "FROM t_si_pat_info t " +
+            "INNER JOIN mz_drug_trac_codg m ON t.pat_no = m.patient_id AND t.times = m.times " +
+            "WHERE t.psn_no = #{psnNo} " +
+            "AND m.drug_trac_codg IS NOT NULL " +
+            "AND m.drug_trac_codg != '' " +
+            "ORDER BY m.confirm_time DESC")
+    List<SiPatInfo> selectByPsnNoWithTracCodg(@Param("psnNo") String psnNo);
+} 

+ 25 - 0
src/main/java/cn/hnthyy/thmz/service/his/yb/SiPatInfoService.java

@@ -0,0 +1,25 @@
+package cn.hnthyy.thmz.service.his.yb;
+
+import cn.hnthyy.thmz.entity.his.yb.SiPatInfo;
+
+import java.util.List;
+
+/**
+ * 医保患者信息表 Service接口
+ */
+public interface SiPatInfoService {
+
+    /**
+     * 根据医保人员编号查询患者信息
+     * @param psnNo 医保人员编号
+     * @return 患者信息列表
+     */
+    List<SiPatInfo> selectByPsnNo(String psnNo);
+
+    /**
+     * 根据医保人员编号和追溯码关联查询患者信息和追溯码信息
+     * @param psnNo 医保人员编号
+     * @return 患者信息和追溯码信息
+     */
+    List<SiPatInfo> selectByPsnNoWithTracCodg(String psnNo);
+} 

+ 29 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/yb/SiPatInfoServiceImpl.java

@@ -0,0 +1,29 @@
+package cn.hnthyy.thmz.service.impl.his.yb;
+
+import cn.hnthyy.thmz.entity.his.yb.SiPatInfo;
+import cn.hnthyy.thmz.mapper.his.yb.SiPatInfoMapper;
+import cn.hnthyy.thmz.service.his.yb.SiPatInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 医保患者信息表 Service实现类
+ */
+@Service
+public class SiPatInfoServiceImpl implements SiPatInfoService {
+
+    @Autowired
+    private SiPatInfoMapper siPatInfoMapper;
+
+    @Override
+    public List<SiPatInfo> selectByPsnNo(String psnNo) {
+        return siPatInfoMapper.selectByPsnNo(psnNo);
+    }
+
+    @Override
+    public List<SiPatInfo> selectByPsnNoWithTracCodg(String psnNo) {
+        return siPatInfoMapper.selectByPsnNoWithTracCodg(psnNo);
+    }
+} 

+ 151 - 0
src/main/java/cn/hnthyy/thmz/service/impl/yb/YbParamServiceImpl.java

@@ -0,0 +1,151 @@
+package cn.hnthyy.thmz.service.impl.yb;
+
+import cn.hnthyy.thmz.entity.his.mz.Employee;
+import cn.hnthyy.thmz.entity.his.yb.SiPatInfo;
+import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
+import cn.hnthyy.thmz.entity.jy.ResultVo;
+import cn.hnthyy.thmz.entity.yb.DrugTracCodg;
+import cn.hnthyy.thmz.entity.yb.SelinfoSold;
+import cn.hnthyy.thmz.entity.yb.SelinfoSoldTotal;
+import cn.hnthyy.thmz.service.his.mz.EmployeeService;
+import cn.hnthyy.thmz.service.his.yp.YpZdDictService;
+import cn.hnthyy.thmz.service.his.yb.SiPatInfoService;
+import cn.hnthyy.thmz.service.yb.YbParamService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 医保参数补全服务实现类
+ */
+@Slf4j
+@Service
+public class YbParamServiceImpl implements YbParamService {
+
+    @Autowired
+    private SiPatInfoService siPatInfoService;
+
+    @Autowired
+    private YpZdDictService ypZdDictService;
+
+    @Autowired
+    private EmployeeService employeeService;
+
+    @Override
+    public ResultVo getYbParamsByPsnNo(String psnNo) {
+        try {
+            // 验证参数
+            if (StringUtils.isBlank(psnNo)) {
+                return new ResultVo(-1, "医保人员编号不能为空");
+            }
+
+            // 查询患者信息和追溯码
+            List<SiPatInfo> siPatInfoList = siPatInfoService.selectByPsnNoWithTracCodg(psnNo);
+            
+            if (siPatInfoList == null || siPatInfoList.isEmpty()) {
+                return new ResultVo(-1, "缺少医保追溯码");
+            }
+
+            // 补全医保接口参数
+            SelinfoSoldTotal selinfoSoldTotal = buildYbParams(psnNo);
+            
+            if (selinfoSoldTotal == null) {
+                return new ResultVo(-1, "参数补全失败");
+            }
+
+            return new ResultVo(0, "获取医保参数成功", selinfoSoldTotal);
+
+        } catch (Exception e) {
+            log.error("获取医保参数失败,psnNo: {}, 错误信息: {}", psnNo, e.getMessage(), e);
+            return new ResultVo(-1, "获取医保参数失败: " + e.getMessage());
+        }
+    }
+
+    @Override
+    public SelinfoSoldTotal buildYbParams(String psnNo) {
+        try {
+            // 查询患者信息和追溯码
+            List<SiPatInfo> siPatInfoList = siPatInfoService.selectByPsnNoWithTracCodg(psnNo);
+            
+            if (siPatInfoList == null || siPatInfoList.isEmpty()) {
+                log.warn("未找到医保追溯码记录,psnNo: {}", psnNo);
+                return null;
+            }
+
+            // 获取第一条记录作为基础信息
+            SiPatInfo baseInfo = siPatInfoList.get(0);
+            
+            // 构建医保接口参数
+            SelinfoSold selinfoSold = new SelinfoSold();
+            
+            // 1. 关联字段(从追溯码记录中获取)
+            selinfoSold.setPatientId(baseInfo.getPatNo());
+            selinfoSold.setTimes(baseInfo.getTimes());
+            selinfoSold.setReceiptNo(baseInfo.getReceiptNo() != null ? baseInfo.getReceiptNo() : 1);
+            selinfoSold.setOrderNo(baseInfo.getOrderNo() != null ? baseInfo.getOrderNo() : 0);
+            selinfoSold.setChargeItemCode(baseInfo.getChargeItemCode() != null ? baseInfo.getChargeItemCode() : "");
+            selinfoSold.setRealNo(baseInfo.getRealNo() != null ? baseInfo.getRealNo() : 0);
+            
+            // 2. 患者信息(从t_si_pat_info表获取)
+            selinfoSold.setPsnName(baseInfo.getPsnName());
+            selinfoSold.setPsnCertType(baseInfo.getPsnCertType());
+            selinfoSold.setCertno(baseInfo.getCertno());
+            
+            // 3. 固定参数(写死)
+            selinfoSold.setPharName("宋荣芝");
+            selinfoSold.setSelRetnOpterName("宋荣芝");
+            selinfoSold.setPharPracCertNo("HY321322000735");
+            
+            // 4. 默认参数
+            selinfoSold.setMdtrtSetlType("2"); // 默认自费结算
+            selinfoSold.setRxFlag("0"); // 默认非处方药
+            selinfoSold.setTrdnFlag("0"); // 默认非拆零
+            
+            // 5. 追溯码信息
+            List<DrugTracCodg> drugTracCodgList = new ArrayList<>();
+            for (SiPatInfo info : siPatInfoList) {
+                if (StringUtils.isNotBlank(info.getDrugTracCodg())) {
+                    DrugTracCodg drugTracCodg = new DrugTracCodg();
+                    drugTracCodg.setDrugTracCodg(info.getDrugTracCodg());
+                    drugTracCodgList.add(drugTracCodg);
+                }
+            }
+            
+            // 6. 补全药品相关信息
+            if (!drugTracCodgList.isEmpty()) {
+                // 获取第一个追溯码对应的药品信息
+                String chargeItemCode = baseInfo.getChargeItemCode();
+                if (StringUtils.isNotBlank(chargeItemCode)) {
+                    // 查询药品字典获取医保编码等信息
+                    YpZdDict ypZdDict = ypZdDictService.queryYpZdDictByCodeAndSerial(chargeItemCode, "01");
+                    if (ypZdDict != null) {
+                        selinfoSold.setMedListCodg(ypZdDict.getNationalCode());
+                        selinfoSold.setRxFlag(ypZdDict.getRxFlag() != null ? ypZdDict.getRxFlag() : "0");
+                        selinfoSold.setTrdnFlag(ypZdDict.getClFlag() != null ? ypZdDict.getClFlag() : "0");
+                    }
+                }
+            }
+            
+            // 7. 补全医师信息(需要从其他表查询)
+            // 这里暂时使用默认值,实际应该从处方信息中获取
+            selinfoSold.setPrscDrName("未知医师");
+            
+            // 构建返回对象
+            SelinfoSoldTotal selinfoSoldTotal = new SelinfoSoldTotal();
+            selinfoSoldTotal.setSelinfoSold(selinfoSold);
+            selinfoSoldTotal.setDrugtracinfo(drugTracCodgList);
+            
+            log.info("医保参数补全成功,psnNo: {}, 追溯码数量: {}", psnNo, drugTracCodgList.size());
+            
+            return selinfoSoldTotal;
+            
+        } catch (Exception e) {
+            log.error("医保参数补全失败,psnNo: {}, 错误信息: {}", psnNo, e.getMessage(), e);
+            return null;
+        }
+    }
+} 

+ 24 - 0
src/main/java/cn/hnthyy/thmz/service/yb/YbParamService.java

@@ -0,0 +1,24 @@
+package cn.hnthyy.thmz.service.yb;
+
+import cn.hnthyy.thmz.entity.jy.ResultVo;
+import cn.hnthyy.thmz.entity.yb.SelinfoSoldTotal;
+
+/**
+ * 医保参数补全服务接口
+ */
+public interface YbParamService {
+
+    /**
+     * 根据医保人员编号获取完整的医保接口参数
+     * @param psnNo 医保人员编号
+     * @return 医保接口参数
+     */
+    ResultVo getYbParamsByPsnNo(String psnNo);
+
+    /**
+     * 补全医保接口参数
+     * @param psnNo 医保人员编号
+     * @return 补全后的医保接口参数
+     */
+    SelinfoSoldTotal buildYbParams(String psnNo);
+}