|
|
@@ -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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|