解决合并冲突

This commit is contained in:
2025-12-10 14:20:24 +08:00
parent e1385cb3e6
commit 18f6a845e6
804 changed files with 61881 additions and 13577 deletions

View File

@@ -81,7 +81,7 @@ public class PaymentReconciliation extends HisBaseEntity {
private Integer printCount;
/** 合同编码 */
private String contractNo;//2025/05/08李自付和医保同时付费时只生成一条payment故此该字段在insert时先为null
private String contractNo;// 2025/05/08李自付和医保同时付费时只生成一条payment故此该字段在insert时先为null
/** 处方号集合 */
private String chargeItemIds;
@@ -96,15 +96,19 @@ public class PaymentReconciliation extends HisBaseEntity {
private Long invoiceId;
/** 关联账户Id */
private Long accountId;//2025/05/08李自付和医保同时付费时只生成一条payment故此该字段在insert时先为null
private Long accountId;// 2025/05/08李自付和医保同时付费时只生成一条payment故此该字段在insert时先为null
/** 医保结算id */
private String ybSettleIds;//记录医保结算id
private String ybSettleIds;// 记录医保结算id
/** 医保清算标志 */
<<<<<<< HEAD
private Integer ybClearFlag;//默认值0 未清算
/** 退号/退费原因 */
@TableField("refund_reason")
private String refundReason;
=======
private Integer ybClearFlag;// 默认值0 未清算
>>>>>>> upstream/develop
}

View File

@@ -0,0 +1,144 @@
package com.openhis.financial.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
/**
* 第三方支付回调实体(下方备注信息以中银支付为模板)
*/
@Data
@TableName("fin_three_part_pay_call_back")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class ThreePartPayCallBack {
@TableId(type = IdType.ASSIGN_ID)
private BigDecimal id;
/**
* 响应码枚举RespCode00 表示成功,其它表示失败
*/
private String respCode;
/**
* 响应码解释信息需要Base64解密
*/
private String respMsg;
/**
* 交易类型枚举TranType
*/
private String tranType;
/**
* 交易金额
*/
private String txnAmt;
/**
* 支付方式:
*/
private String payType;
/**
* 终端流水号终端号系统跟踪号同请求报文原值返回客户端收到应答报文需要验证traceNo字段值需与请求报文值一致如果不一致则丢包交易失败
*/
private String traceNo;
/**
* 交易时间yyyyMMddHHmmss
*/
private String txnTime;
/**
* 支付订单号:银行返回系统订单号,需要保存该支付交易订单号
*/
private String tradeNo;
/**
* 第三方支付订单号
*/
private String transNo;
/**
* 商户号
*/
private String mid;
/**
* 商户名称
*/
private String merName;
/**
* 终端号
*/
private String tid;
/**
* 商户系统订单号:同请求一致
*/
private String merTradeNo;
/**
* 商户系统退款授权单号:同请求一致
*/
private String vfTradeNo;
/**
* 优惠金额
*/
private String discountAmt;
/**
* 有效时间:二维码本身的有效时间,是相对时间,单位为秒,以接收方收到报文时间为起始点计时。不同类型的订单以及不同的订单状况会对应不同的默认有效时间和最大有效时间(可以为空)
*/
private String qrValidTime;
/**
* 二维码信息主扫支付二维码以二维码形式显示手机APP扫二维码码消费
*/
private String scanCode;
/**
* 原交易类型1、订单查询类交易填写原交易类型被扫交易必填2、非订单查询填写交易类型与tranType一致可以为空
*/
private String orgTranType;
/**
* 原交易名称:订单查询类交易填写原交易名称,非订单查询填写交易名称(被扫交易必填)
*/
private String orgTxnName;
/**
* 订单数据当tranType为F时payType 值为ZFBA或WEIX时支付宝返回的tradeNo 或者微信返回的prepayId
*/
private String payData;
/**
* POS机号
*/
private String posNo;
/**
* 付款主键ID
*/
private Long paymentId;
/**
* 前台UI序号
*/
private Long index;
/**
* 时间戳(中银建议)
*/
private Long time;
}

View File

@@ -0,0 +1,10 @@
package com.openhis.financial.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.openhis.financial.domain.ClaimResponse;
import com.openhis.financial.domain.ThreePartPayCallBack;
import org.springframework.stereotype.Repository;
@Repository
public interface ThreePartPayCallBackMapper extends BaseMapper<ThreePartPayCallBack> {
}

View File

@@ -1,8 +1,9 @@
package com.openhis.financial.model;
import com.openhis.administration.domain.ChargeItem;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
@Data
public class PaymentedItemModel {
@@ -21,4 +22,37 @@ public class PaymentedItemModel {
/** 总价 */
private Long chargeItemId;
/** 医疗服务所在表 */
private String serviceTable;
/** 医疗服务ID */
private Long serviceId;
/** 产品所在表 */
private String productTable;
/** 产品ID */
private Long productId;
/** 开立人ID */
private Long entererId;
/** 开立科室 */
private Long requestingOrgId;
/** 开立时间 */
private Date enteredDate;
/** 数量 */
private BigDecimal quantityValue;
/** 单位 */
private String quantityUnit;
/** 单价 */
private BigDecimal unitPrice;
/** chargeItem定义id */
private Long definitionId;
}

View File

@@ -1,12 +1,13 @@
package com.openhis.financial.model;
import com.alibaba.fastjson2.annotation.JSONField;
import com.openhis.yb.dto.Clinic2206FundPaymentResult;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
import com.alibaba.fastjson2.annotation.JSONField;
import com.openhis.yb.dto.Clinic2206FundPaymentResult;
import lombok.Data;
@Data
public class PrePaymentResult {
@@ -82,4 +83,6 @@ public class PrePaymentResult {
private String busNo; // 挂号采访码
private Long accountId; // 账号ID码
private BigDecimal gfRatio;// 学校垫付金额
}

View File

@@ -0,0 +1,49 @@
package com.openhis.financial.model;
import java.math.BigDecimal;
import lombok.Data;
@Data
public class StudentPaymentItemModel extends PaymentedItemModel {
/**
* 医保等级
*/
private Integer chrgitmLv;
/**
* 医保分类
*/
private String ybType;
/**
* 自付比例
*/
private BigDecimal selfRatio;
/**
* 公费一次报销金额
*/
private BigDecimal oncePrice;
/**
* 医保折扣部分金额
*/
private BigDecimal ybRatio;
/**
* 学校垫付部分金额
*/
private BigDecimal studentRatio;
/**
* 自付比例
*/
private BigDecimal twiceRatio;
/**
* 公费二次报销金额
*/
private BigDecimal twicePrice;
}

View File

@@ -98,6 +98,14 @@ public interface IPaymentReconciliationService extends IService<PaymentReconcili
*/
PaymentReconciliation getByEncounterId(Long encounterId, PaymentKind kindEnum);
/**
* 查询付款实体
*
* @param encounterId 就诊id
* @return 付款实体
*/
List<PaymentReconciliation> getListByEncounterId(Long encounterId, PaymentKind paymentKind);
/**
* 判断是否已退费
*

View File

@@ -0,0 +1,7 @@
package com.openhis.financial.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.openhis.financial.domain.ThreePartPayCallBack;
public interface ThreePartPayCallBackService extends IService<ThreePartPayCallBack> {
}

View File

@@ -1,6 +1,7 @@
package com.openhis.financial.service.impl;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -16,25 +17,41 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.core.common.exception.ServiceException;
import com.core.common.utils.AssignSeqUtil;
import com.core.common.utils.SecurityUtils;
import com.core.common.utils.StringUtils;
import com.openhis.administration.domain.ChargeItemDefinition;
import com.openhis.administration.domain.DeviceDefinition;
import com.openhis.administration.domain.HealthcareService;
import com.openhis.administration.service.IChargeItemDefinitionService;
import com.openhis.administration.service.IChargeItemService;
import com.openhis.administration.service.IDeviceDefinitionService;
import com.openhis.administration.service.IHealthcareServiceService;
import com.openhis.administration.service.impl.PatientServiceImpl;
import com.openhis.administration.service.impl.PatientStudentServiceImpl;
import com.openhis.common.constant.CommonConstants;
import com.openhis.common.constant.YbCommonConstants;
import com.openhis.common.enums.DelFlag;
import com.openhis.common.enums.ItemType;
import com.openhis.common.enums.PaymentKind;
import com.openhis.common.enums.PaymentStatus;
import com.openhis.common.enums.ybenums.YbChrgitmLv;
import com.openhis.common.enums.ybenums.YbMdtrtCertType;
import com.openhis.common.enums.ybenums.YbMedChrgItmType;
import com.openhis.common.enums.ybenums.YbMedType;
import com.openhis.financial.domain.Contract;
import com.openhis.financial.domain.PaymentReconciliation;
import com.openhis.financial.mapper.PaymentReconciliationMapper;
import com.openhis.financial.model.PaymentReconciliationAccountDel;
import com.openhis.financial.model.PaymentResult;
import com.openhis.financial.model.PaymentedItemModel;
import com.openhis.financial.model.PrePaymentResult;
import com.openhis.financial.model.*;
import com.openhis.financial.service.IContractService;
import com.openhis.financial.service.IPaymentReconciliationService;
import com.openhis.medication.domain.MedicationDefinition;
import com.openhis.medication.service.IMedicationDefinitionService;
import com.openhis.nenu.dto.GfTypeRatioDto;
import com.openhis.nenu.service.impl.GfRatioServiceImpl;
import com.openhis.workflow.domain.ActivityDefinition;
import com.openhis.workflow.service.IActivityDefinitionService;
import com.openhis.yb.dto.Clinic2206OrderOutput;
import com.openhis.yb.dto.ClinicReg2201Output;
import com.openhis.yb.dto.PaymentInpatientDto;
@@ -57,6 +74,24 @@ public class PaymentReconciliationServiceImpl extends ServiceImpl<PaymentReconci
private IContractService iContractService;
@Autowired
private YbManager ybManager;
@Autowired
private GfRatioServiceImpl gfRatioService;
@Autowired
private PatientServiceImpl patientService;
@Autowired
private PatientStudentServiceImpl patientStudentService;
@Autowired
private IChargeItemService chargeItemService;
@Autowired
private IChargeItemDefinitionService chargeItemDefinitionService;
@Autowired
private IDeviceDefinitionService deviceDefinitionService;
@Autowired
private IActivityDefinitionService activityDefinitionService;
@Autowired
private IMedicationDefinitionService medicationDefinitionService;
@Autowired
private IHealthcareServiceService healthcareServiceService;
/**
* 根据支付id获取对应收费项目的id列表
@@ -143,6 +178,9 @@ public class PaymentReconciliationServiceImpl extends ServiceImpl<PaymentReconci
case "220100":// 长春市医保(长大)
Map<String, List<PaymentedItemModel>> collect =
paymentedItemList.stream().collect(Collectors.groupingBy(PaymentedItemModel::getMedType));
if (collect.entrySet().size() > 1) {
throw new ServiceException("医保只接受同种医疗类型结算(普通门诊与慢病等不可以同时结算)!");
}
PrePaymentResult result;
for (Map.Entry<String, List<PaymentedItemModel>> medTypeKV : collect.entrySet()) {
Clinic2206OrderOutput clinic2206OrderOutput = null;
@@ -161,19 +199,108 @@ public class PaymentReconciliationServiceImpl extends ServiceImpl<PaymentReconci
}
// 调用预结算
clinic2206OrderOutput = ybManager.preSettle(contract, medTypeKV.getValue().get(0).getEncounterId(),
ybMdtrtCertType, busiCardInfo, reg2201Output, "01", medTypeKV.getValue().stream()
.map(PaymentedItemModel::getChargeItemId).collect(Collectors.toList()),
ybMdtrtCertType, busiCardInfo, reg2201Output, "01", medTypeKV.getValue(),
YbMedType.getByValue(medTypeKV.getKey()));
prePaymentResult = new PrePaymentResult();
BeanUtils.copyProperties(clinic2206OrderOutput, prePaymentResult);
}
break;
case "STUDENT0000":
prePaymentResult = this.studentSelfPay(paymentedItemList);
break;
case "STUDENT220100":
case "STUDENT229900":
case "STUDENT220199":
prePaymentResult = this.studentYbPay(contract, ybMdtrtCertType, busiCardInfo, "01", paymentedItemList);
break;
default:
break;
}
return prePaymentResult;
}
/**
* 学生二次报销
*
* @param contract 合同
* @param ybMdtrtCertType 医疗类别
* @param busiCardInfo 电子码
* @param s 按项目收费还是按病种收费该字段目前在系统里面没用上默认都是01
* @param paymentedItemList 收费项
* @return 预结算结果
*/
private PrePaymentResult studentYbPay(Contract contract, YbMdtrtCertType ybMdtrtCertType, String busiCardInfo,
String s, List<PaymentedItemModel> paymentedItemList) {
// 查比例及分类信息(PaymentedItemModel在chargeItem表中不是一定存在的所以此处改用单独查询)
List<StudentPaymentItemModel> allPaymentItemList = getStudentPaymentItemModelList(paymentedItemList);
// 拟定使用公费医疗的情况下实收金额
BigDecimal onceReceivedAmount = BigDecimal.ZERO;
for (StudentPaymentItemModel studentPaymentItemModel : allPaymentItemList) {
// 获取折扣比例
BigDecimal ratio = studentPaymentItemModel.getTwiceRatio() == null ? studentPaymentItemModel.getSelfRatio()
: studentPaymentItemModel.getTwiceRatio();
// 计算金额
onceReceivedAmount = onceReceivedAmount.add(studentPaymentItemModel.getTotalPrice()
.multiply(ratio.divide(new BigDecimal("100"), 6, RoundingMode.HALF_UP)));
}
// 医保结算
PrePaymentResult prePaymentResult =
this.studentPreSettleYb(contract, ybMdtrtCertType, busiCardInfo, paymentedItemList);
if (prePaymentResult == null) {
throw new ServiceException("医生开具的收费项未分配对应的医疗类型!");
}
BigDecimal psnPartAmt = prePaymentResult.getPsnPartAmt();
if (psnPartAmt.compareTo(onceReceivedAmount) > 0) {
prePaymentResult.setGfRatio(psnPartAmt.subtract(onceReceivedAmount));
prePaymentResult.setPsnCashPay(onceReceivedAmount);
} else {
prePaymentResult.setGfRatio(BigDecimal.ZERO);
}
return prePaymentResult;
}
/**
* 学生一次报销
*
* @param paymentedItemList 收费项
* @return 预结算结果
*/
private PrePaymentResult studentSelfPay(List<PaymentedItemModel> paymentedItemList) {
List<StudentPaymentItemModel> allPaymentItemList = getStudentPaymentItemModelList(paymentedItemList);
// 拟定使用公费医疗的情况下实收金额
BigDecimal onceReceivedAmount = BigDecimal.ZERO;
for (StudentPaymentItemModel studentPaymentItemModel : allPaymentItemList) {
// 获取折扣比例
BigDecimal ratio = studentPaymentItemModel.getTwiceRatio() == null ? studentPaymentItemModel.getSelfRatio()
: studentPaymentItemModel.getTwiceRatio();
// 计算金额
onceReceivedAmount = onceReceivedAmount.add(studentPaymentItemModel.getTotalPrice().multiply(ratio));
}
PrePaymentResult prePaymentResult = new PrePaymentResult();
BigDecimal sumAmount = BigDecimal.ZERO;
for (PaymentedItemModel item : paymentedItemList) {
sumAmount = sumAmount.add(item.getTotalPrice());
}
prePaymentResult.setMedfeeSumamt(sumAmount);
prePaymentResult.setFulamtOwnpayAmt(sumAmount);
prePaymentResult.setPsnPartAmt(sumAmount);
prePaymentResult.setPsnCashPay(onceReceivedAmount.divide(new BigDecimal("100"), 6, RoundingMode.HALF_UP));
prePaymentResult.setGfRatio(sumAmount.subtract(prePaymentResult.getPsnCashPay()));
prePaymentResult.setChrgBchno(CommonConstants.BusinessName.DEFAULT_STUDENT_CONTRACT_NO);
return prePaymentResult;
}
/**
* 【门诊结算】
*
@@ -189,7 +316,8 @@ public class PaymentReconciliationServiceImpl extends ServiceImpl<PaymentReconci
public PaymentResult settle(Contract contract, String payTransNo, YbMdtrtCertType ybMdtrtCertType,
String busiCardInfo, Integer minpacuntDrugTracCnt, Integer mcsTracCnt) {
PaymentResult paymentResult = null;
if (!CommonConstants.BusinessName.DEFAULT_CONTRACT_NO.equals(payTransNo)) {
if (!(CommonConstants.BusinessName.DEFAULT_CONTRACT_NO.equals(payTransNo)
|| CommonConstants.BusinessName.DEFAULT_STUDENT_CONTRACT_NO.equals(payTransNo))) {
// 医保支付 todo支付的详细信息在于结算中已经存好了但是还没有存储卡余额
Clinic2207OrderModel clinic2207OrderModel =
ybManager.settle(contract, payTransNo, busiCardInfo, ybMdtrtCertType, minpacuntDrugTracCnt, mcsTracCnt);
@@ -272,6 +400,21 @@ public class PaymentReconciliationServiceImpl extends ServiceImpl<PaymentReconci
.eq(PaymentReconciliation::getDeleteFlag, DelFlag.NO.getCode()).last(YbCommonConstants.sqlConst.LIMIT1));
}
/**
* 查询已收费付款实体
*
* @param encounterId 就诊id
* @return 付款实体
*/
@Override
public List<PaymentReconciliation> getListByEncounterId(Long encounterId, PaymentKind paymentKind) {
return baseMapper.selectList(new LambdaQueryWrapper<PaymentReconciliation>()
.eq(PaymentReconciliation::getEncounterId, encounterId)
.in(PaymentReconciliation::getStatusEnum, PaymentStatus.SUCCESS.getValue(),PaymentStatus.REFUNDING.getValue())
.eq(PaymentReconciliation::getKindEnum, PaymentKind.HOSPITAL_DEPOSIT.getValue())
.eq(PaymentReconciliation::getDeleteFlag, DelFlag.NO.getCode()));
}
/**
* 判断是否已退费
*
@@ -309,4 +452,181 @@ public class PaymentReconciliationServiceImpl extends ServiceImpl<PaymentReconci
return baseMapper.getPaymentAccountContract(startTime, endTime, entererId, contractNo, success, returnAll,
clinic);
}
/**
* 查询自付比例等
*
* @param paymentedItemList 收款明细
* @return 学生付款实体
*/
private List<StudentPaymentItemModel> getStudentPaymentItemModelList(List<PaymentedItemModel> paymentedItemList) {
// 大项比例
List<GfTypeRatioDto> typeRatioList = gfRatioService.getTypeRatioList();
Map<String, Map<String, List<GfTypeRatioDto>>> result = typeRatioList.stream().collect(
// 第一次分组:按 ybClass 分组(外层 key 为 ybClass
Collectors.groupingBy(GfTypeRatioDto::getYbClass,
// 第二次分组:对每个分组的 List 再按 subType 分组(内层 key 为 subType
Collectors.groupingBy(GfTypeRatioDto::getYbLv)));
List<StudentPaymentItemModel> allPaymentItemList = new ArrayList<>();
Map<String, List<PaymentedItemModel>> paymentedItemListByServiceTableMap =
paymentedItemList.stream().collect(Collectors.groupingBy(PaymentedItemModel::getServiceTable));
for (Map.Entry<String, List<PaymentedItemModel>> stringListEntry : paymentedItemListByServiceTableMap
.entrySet()) {
String key = stringListEntry.getKey();
ItemType itemType;
if (CommonConstants.TableName.MED_MEDICATION_REQUEST.equals(key)) {
itemType = ItemType.MEDICINE;
} else if (CommonConstants.TableName.WOR_SERVICE_REQUEST.equals(key)) {
itemType = ItemType.ACTIVITY;
} else {
throw new ServiceException("除药品和诊疗项目外不存在其他公费项目,请确认!");
}
List<PaymentedItemModel> value = stringListEntry.getValue();
List<StudentPaymentItemModel> paymentItemList = gfRatioService.getGfRatioList(itemType, value);
for (StudentPaymentItemModel studentPaymentItemModel : paymentItemList) {
// 如果自付比例有值就continue掉
if (studentPaymentItemModel.getSelfRatio() != null && studentPaymentItemModel.getTwiceRatio() != null) {
continue;
}
// 查定价分类
ChargeItemDefinition chargeItemDefinition =
chargeItemDefinitionService.getById(studentPaymentItemModel.getDefinitionId());
// 查医保等级
if (CommonConstants.TableName.ADM_DEVICE_DEFINITION.equals(studentPaymentItemModel.getProductTable())) {
DeviceDefinition deviceDefinition =
deviceDefinitionService.getById(studentPaymentItemModel.getProductId());
if (deviceDefinition != null && chargeItemDefinition != null) {
// 约定大项目的自付比例获取条件
YbMedChrgItmType medChrgItmType = YbMedChrgItmType.getByValue(chargeItemDefinition.getYbType());
if (medChrgItmType == null) {
throw new ServiceException(chargeItemDefinition.getChargeName() + "未配置正确的医保分类!请检查!!!");
}
YbChrgitmLv chrgitmLv = YbChrgitmLv.getByValue(deviceDefinition.getChrgitmLv());
if (chrgitmLv == null) {
throw new ServiceException(chargeItemDefinition.getChargeName() + "未配置正确的医保等级!请检查!!!");
}
List<GfTypeRatioDto> gfTypeRatioDtos =
result.get(chargeItemDefinition.getYbType()).get(chrgitmLv.getCode());
if (gfTypeRatioDtos == null || gfTypeRatioDtos.isEmpty()) {
throw new ServiceException(
"医保分类:" + medChrgItmType.getInfo() + "医保等级:" + chrgitmLv.getInfo() + "未配置自付比例!请检查!!!");
}
studentPaymentItemModel.setSelfRatio(gfTypeRatioDtos.get(0).getSelfRatio());
studentPaymentItemModel.setTwiceRatio(gfTypeRatioDtos.get(0).getSelfRatio());
}
} else if (CommonConstants.TableName.WOR_ACTIVITY_DEFINITION
.equals(studentPaymentItemModel.getProductTable())) {
ActivityDefinition activityDefinition =
activityDefinitionService.getById(studentPaymentItemModel.getProductId());
if (activityDefinition != null && chargeItemDefinition != null) {
// 约定大项目的自付比例获取条件
YbMedChrgItmType medChrgItmType = YbMedChrgItmType.getByValue(chargeItemDefinition.getYbType());
if (medChrgItmType == null) {
throw new ServiceException(chargeItemDefinition.getChargeName() + "未配置正确的医保分类!请检查!!!");
}
YbChrgitmLv chrgitmLv = YbChrgitmLv.getByValue(activityDefinition.getChrgitmLv());
if (chrgitmLv == null) {
throw new ServiceException(chargeItemDefinition.getChargeName() + "未配置正确的医保等级!请检查!!!");
}
List<GfTypeRatioDto> gfTypeRatioDtos =
result.get(chargeItemDefinition.getYbType()).get(chrgitmLv.getCode());
if (gfTypeRatioDtos == null || gfTypeRatioDtos.isEmpty()) {
throw new ServiceException(
"医保分类:" + medChrgItmType.getInfo() + "医保等级:" + chrgitmLv.getInfo() + "未配置自付比例!请检查!!!");
}
studentPaymentItemModel.setSelfRatio(gfTypeRatioDtos.get(0).getSelfRatio());
studentPaymentItemModel.setTwiceRatio(gfTypeRatioDtos.get(0).getSelfRatio());
}
} else if (CommonConstants.TableName.MED_MEDICATION_DEFINITION
.equals(studentPaymentItemModel.getProductTable())) {
MedicationDefinition medicationDefinition =
medicationDefinitionService.getById(studentPaymentItemModel.getProductId());
if (medicationDefinition != null && chargeItemDefinition != null) {
// 约定大项目的自付比例获取条件
YbMedChrgItmType medChrgItmType = YbMedChrgItmType.getByValue(chargeItemDefinition.getYbType());
if (medChrgItmType == null) {
throw new ServiceException(chargeItemDefinition.getChargeName() + "未配置正确的医保分类!请检查!!!");
}
YbChrgitmLv chrgitmLv = YbChrgitmLv.getByValue(medicationDefinition.getChrgitmLv());
if (chrgitmLv == null) {
throw new ServiceException(chargeItemDefinition.getChargeName() + "未配置正确的医保等级!请检查!!!");
}
List<GfTypeRatioDto> gfTypeRatioDtos =
result.get(chargeItemDefinition.getYbType()).get(chrgitmLv.getCode());
if (gfTypeRatioDtos == null || gfTypeRatioDtos.isEmpty()) {
throw new ServiceException(
"医保分类:" + medChrgItmType.getInfo() + "医保等级:" + chrgitmLv.getInfo() + "未配置自付比例!请检查!!!");
}
studentPaymentItemModel.setSelfRatio(gfTypeRatioDtos.get(0).getSelfRatio());
studentPaymentItemModel.setTwiceRatio(gfTypeRatioDtos.get(0).getSelfRatio());
}
} else {
HealthcareService healthcareService =
healthcareServiceService.getById(studentPaymentItemModel.getServiceId());
if (healthcareService != null && chargeItemDefinition != null) {
// 约定大项目的自付比例获取条件 医疗服务没有定义医保等级,默认百分百还是直接抛异常?
studentPaymentItemModel.setSelfRatio(new BigDecimal("100"));
studentPaymentItemModel.setTwiceRatio(new BigDecimal("100"));
}
}
allPaymentItemList.addAll(paymentItemList);
}
}
return allPaymentItemList;
}
/**
* 医保预结算
*
* @param contract 合同b
* @param ybMdtrtCertType 证件类型
* @param busiCardInfo 电子密钥
* @param paymentedItemList 收款明细
* @return 预结算参数
*/
private PrePaymentResult studentPreSettleYb(Contract contract, YbMdtrtCertType ybMdtrtCertType, String busiCardInfo,
List<PaymentedItemModel> paymentedItemList) {
Map<String, List<PaymentedItemModel>> collect =
paymentedItemList.stream().collect(Collectors.groupingBy(PaymentedItemModel::getMedType));
// 一次医保结算只能支持一种医疗类型的结算
for (Map.Entry<String, List<PaymentedItemModel>> medTypeKV : collect.entrySet()) {
Clinic2206OrderOutput clinic2206OrderOutput = null;
ClinicReg2201Output reg2201Output = null;
if (!medTypeKV.getKey().equals(YbMedType.GENERAL_OUTPATIENT.getValue()) && "1"
.equals(SecurityUtils.getLoginUser().getOptionJson().getString(CommonConstants.Option.YB_SWITCH))) {
// 不是普通门诊就诊类型,补充挂号信息
reg2201Output = ybManager.createRegWithMedType(contract, ybMdtrtCertType, busiCardInfo,
medTypeKV.getValue().get(0).getEncounterId(),
YbMedType.getByValue(medTypeKV.getValue().get(0).getMedType()));
reg2201Output.setMedType(medTypeKV.getKey());// 2025/06/05慢病挂号后上传2206信息报错2201返回值没有medType此处更正赋值
} else {
// 从数据库里取reg2201
reg2201Output = ybManager.getClinicRegByEncounterId(medTypeKV.getValue().get(0).getEncounterId());
}
if (reg2201Output == null) {
throw new ServiceException("未查询到医保挂号信息");
}
// 调用预结算
clinic2206OrderOutput =
ybManager.preSettle(contract, medTypeKV.getValue().get(0).getEncounterId(), ybMdtrtCertType,
busiCardInfo, reg2201Output, "01", medTypeKV.getValue(), YbMedType.getByValue(medTypeKV.getKey()));
PrePaymentResult prePaymentResult = new PrePaymentResult();
BeanUtils.copyProperties(clinic2206OrderOutput, prePaymentResult);
return prePaymentResult;
}
return null;
}
}

View File

@@ -0,0 +1,11 @@
package com.openhis.financial.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.openhis.financial.domain.ThreePartPayCallBack;
import com.openhis.financial.mapper.ThreePartPayCallBackMapper;
import com.openhis.financial.service.ThreePartPayCallBackService;
import org.springframework.stereotype.Service;
@Service
public class ThreePartPayCallBackServiceImpl extends ServiceImpl<ThreePartPayCallBackMapper, ThreePartPayCallBack> implements ThreePartPayCallBackService {
}