版本更新
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.openhis.financial.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.financial.domain.ClaimResponse;
|
||||
|
||||
/**
|
||||
* 索赔响应管理Service接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
public interface IClaimResponseService extends IService<ClaimResponse> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.openhis.financial.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.financial.domain.Claim;
|
||||
|
||||
/**
|
||||
* 索赔管理Service接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
public interface IClaimService extends IService<Claim> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.openhis.financial.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.financial.domain.Contract;
|
||||
|
||||
/**
|
||||
* 合同管理Service接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
public interface IContractService extends IService<Contract> {
|
||||
|
||||
/**
|
||||
* 根据医保码找合同信息
|
||||
*
|
||||
* @param contractNo 医保码
|
||||
* @return 合同实体
|
||||
*/
|
||||
Contract getByContractNo(String contractNo);
|
||||
|
||||
/**
|
||||
* 查询租户合同信息分页
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param pageNum 当前页
|
||||
* @param pageSize 每页多少条
|
||||
* @return 租户合同信息分页
|
||||
*/
|
||||
IPage<Contract> getTenantContractPage(Integer tenantId, Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 查询租户合同信息详情
|
||||
*
|
||||
* @param id ID
|
||||
* @return 租户合同信息详情
|
||||
*/
|
||||
Contract getTenantContractDetail(Long id);
|
||||
|
||||
/**
|
||||
* 新增租户合同信息
|
||||
*
|
||||
* @param contract 合同管理实体
|
||||
*/
|
||||
void addTenantContract(Contract contract);
|
||||
|
||||
/**
|
||||
* 编辑租户合同信息
|
||||
*
|
||||
* @param contract 合同管理实体
|
||||
*/
|
||||
void editTenantContract(Contract contract);
|
||||
|
||||
/**
|
||||
* 删除租户合同信息
|
||||
*
|
||||
* @param id ID
|
||||
*/
|
||||
void delTenantContract(Long id);
|
||||
|
||||
/**
|
||||
* 查詢合同的集合
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Contract> getContractList();
|
||||
|
||||
/**
|
||||
* 查詢合同的集合
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Contract> getRedisContractList();
|
||||
|
||||
/**
|
||||
* 通過合同編碼查詢合同
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Contract getContract(String contractNo);
|
||||
|
||||
/**
|
||||
* 根据参保地信息找到对应的合同
|
||||
*
|
||||
* @param insuplcAdmdvs
|
||||
* @return
|
||||
*/
|
||||
Contract getContractByInsuplcAdmdvs(String insuplcAdmdvs);
|
||||
|
||||
/**
|
||||
* 查詢合同的集合
|
||||
*
|
||||
* @return 合同集合
|
||||
*/
|
||||
List<Contract> getContractListByYb();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.openhis.financial.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.financial.domain.PaymentNotice;
|
||||
|
||||
/**
|
||||
* 合同管理Service接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
public interface IPaymentNoticeService extends IService<PaymentNotice> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.openhis.financial.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.common.enums.PaymentResult;
|
||||
import com.openhis.financial.domain.PaymentRecDetail;
|
||||
import com.openhis.financial.model.PaymentRecDetailAccountResult;
|
||||
|
||||
/**
|
||||
* 付款管理Service接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
public interface IPaymentRecDetailService extends IService<PaymentRecDetail> {
|
||||
|
||||
/**
|
||||
* 根据paymentId更改结算结果
|
||||
*
|
||||
* @param id id
|
||||
* @param paid PaymentResult
|
||||
*/
|
||||
void updateResultByPaymentId(Long id, PaymentResult paid);
|
||||
|
||||
/**
|
||||
* 根据paymentId集合查询详情信息
|
||||
*
|
||||
* @param paymentIdList 集合
|
||||
* @return 集合
|
||||
*/
|
||||
List<PaymentRecDetailAccountResult> getListByReconciliationIds(List<Long> paymentIdList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.financial.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.administration.dto.ChargeItemDefInfo;
|
||||
import com.openhis.common.enums.PaymentStatisticalMethod;
|
||||
import com.openhis.common.enums.PaymentType;
|
||||
import com.openhis.financial.domain.PaymentRecStatic;
|
||||
|
||||
/**
|
||||
* 付款管理Service接口
|
||||
*
|
||||
* @author SunJQ
|
||||
* @date 2025-08-08
|
||||
*/
|
||||
public interface IPaymentRecStaticService extends IService<PaymentRecStatic> {
|
||||
/**
|
||||
* 批量保存付款快照信息
|
||||
*
|
||||
* @param paymentId 付款id
|
||||
* @param paymentType 付款/退款
|
||||
* @param paymentStatisticalMethod 统计方式:字典/医保分类
|
||||
* @param chargeItemDefInfoList chargeItem基础信息
|
||||
*/
|
||||
void savePaymentRecStatics(Long paymentId, PaymentType paymentType,
|
||||
PaymentStatisticalMethod paymentStatisticalMethod, List<ChargeItemDefInfo> chargeItemDefInfoList);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.openhis.financial.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.common.enums.PaymentKind;
|
||||
import com.openhis.common.enums.PaymentStatus;
|
||||
import com.openhis.common.enums.ybenums.YbMdtrtCertType;
|
||||
import com.openhis.financial.domain.Contract;
|
||||
import com.openhis.financial.domain.PaymentReconciliation;
|
||||
import com.openhis.financial.model.PaymentResult;
|
||||
import com.openhis.financial.model.PaymentedItemModel;
|
||||
import com.openhis.financial.model.PrePaymentResult;
|
||||
import com.openhis.yb.dto.PaymentInpatientDto;
|
||||
|
||||
/**
|
||||
* 付款管理Service接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
public interface IPaymentReconciliationService extends IService<PaymentReconciliation> {
|
||||
|
||||
/**
|
||||
* 根据支付id获取对应收费项目的id列表
|
||||
*
|
||||
* @param paymentIdList 支付id列表
|
||||
* @return 收费项目的id列表
|
||||
*/
|
||||
List<Long> getChargeItemIdListByPayment(List<Long> paymentIdList);
|
||||
|
||||
/**
|
||||
* 更新付款状态:退款中
|
||||
*
|
||||
* @param paymentIdList 支付id列表
|
||||
*/
|
||||
void updateRefundingStatus(List<Long> paymentIdList);
|
||||
|
||||
/**
|
||||
* 【门诊预结算】
|
||||
*
|
||||
* @param ybMdtrtCertType 医保凭证类型
|
||||
* @param busiCardInfo 读卡获取的密钥
|
||||
* @param contractBusNo 合同编号
|
||||
* @param paymentedItemList 收费项
|
||||
* @return 结果
|
||||
*/
|
||||
PrePaymentResult preSettle(YbMdtrtCertType ybMdtrtCertType, String busiCardInfo, String contractBusNo,
|
||||
List<PaymentedItemModel> paymentedItemList);
|
||||
|
||||
/**
|
||||
* 【门诊结算】
|
||||
*
|
||||
* @param contract 合同
|
||||
* @param payTransNo 收费批次号
|
||||
* @param byValue 医保凭证类型
|
||||
* @param busiCardInfo 读卡获取的密钥
|
||||
* @param minpacuntDrugTracCnt 追溯码相关
|
||||
* @param mcsTracCnt 追溯码相关
|
||||
* @return 结算结果
|
||||
*/
|
||||
PaymentResult settle(Contract contract, String payTransNo, YbMdtrtCertType byValue, String busiCardInfo,
|
||||
Integer minpacuntDrugTracCnt, Integer mcsTracCnt);
|
||||
|
||||
/**
|
||||
* 更改付款状态
|
||||
*
|
||||
* @param id paymentId
|
||||
* @param success 付款状态
|
||||
*/
|
||||
void updatePaymentStatusById(Long id, PaymentStatus success);
|
||||
|
||||
/**
|
||||
* 更改状态
|
||||
*
|
||||
* @param id 主键id
|
||||
* @param success 付款状态
|
||||
* @param settleId 医保结算id
|
||||
*/
|
||||
void updatePaymentStatusAndSettleIdsById(Long id, PaymentStatus success, List<String> settleId);
|
||||
|
||||
/**
|
||||
* 【住院结算】
|
||||
*
|
||||
* @param contract 合同
|
||||
* @param paymentDto 收费参数
|
||||
* @return 结算结果
|
||||
*/
|
||||
PaymentResult inpatientSettle(Contract contract, PaymentInpatientDto paymentDto);
|
||||
|
||||
/**
|
||||
* 查询付款实体
|
||||
*
|
||||
* @param encounterId 就诊id
|
||||
* @return 付款实体
|
||||
*/
|
||||
PaymentReconciliation getByEncounterId(Long encounterId, PaymentKind kindEnum);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.openhis.financial.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.financial.domain.ClaimResponse;
|
||||
import com.openhis.financial.mapper.ClaimResponseMapper;
|
||||
import com.openhis.financial.service.IClaimResponseService;
|
||||
|
||||
/**
|
||||
* 索赔响应管理Service业务层处理
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Service
|
||||
public class ClaimResponseServiceImpl extends ServiceImpl<ClaimResponseMapper, ClaimResponse> implements IClaimResponseService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.openhis.financial.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.financial.domain.Claim;
|
||||
import com.openhis.financial.mapper.ClaimMapper;
|
||||
import com.openhis.financial.service.IClaimService;
|
||||
|
||||
/**
|
||||
* 索赔管理Service业务层处理
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Service
|
||||
public class ClaimServiceImpl extends ServiceImpl<ClaimMapper, Claim> implements IClaimService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.openhis.financial.service.impl;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
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.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.core.common.core.redis.RedisCache;
|
||||
import com.core.common.enums.DeleteFlag;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.common.constant.YbCommonConstants;
|
||||
import com.openhis.common.enums.Whether;
|
||||
import com.openhis.financial.domain.Contract;
|
||||
import com.openhis.financial.mapper.ContractMapper;
|
||||
import com.openhis.financial.service.IContractService;
|
||||
|
||||
/**
|
||||
* 合同管理Service业务层处理
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Service
|
||||
public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> implements IContractService {
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param contractNo 医保码
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Contract getByContractNo(String contractNo) {
|
||||
return baseMapper.selectOne(new LambdaUpdateWrapper<Contract>().eq(Contract::getBusNo, contractNo)
|
||||
.last(YbCommonConstants.sqlConst.LIMIT1));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户合同信息分页
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param pageNum 当前页
|
||||
* @param pageSize 每页多少条
|
||||
* @return 租户合同信息分页
|
||||
*/
|
||||
@Override
|
||||
public IPage<Contract> getTenantContractPage(Integer tenantId, Integer pageNum, Integer pageSize) {
|
||||
return baseMapper.selectPage(new Page<>(pageNum, pageSize), new LambdaQueryWrapper<Contract>()
|
||||
.eq(Contract::getTenantId, tenantId).eq(Contract::getDeleteFlag, DeleteFlag.NOT_DELETED.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户合同信息详情
|
||||
*
|
||||
* @param id ID
|
||||
* @return 租户合同信息详情
|
||||
*/
|
||||
@Override
|
||||
public Contract getTenantContractDetail(Long id) {
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增租户合同信息
|
||||
*
|
||||
* @param contract 合同管理实体
|
||||
*/
|
||||
@Override
|
||||
public void addTenantContract(Contract contract) {
|
||||
baseMapper.insert(contract);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑租户合同信息
|
||||
*
|
||||
* @param contract 合同管理实体
|
||||
*/
|
||||
@Override
|
||||
public void editTenantContract(Contract contract) {
|
||||
baseMapper.updateById(contract);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除租户合同信息
|
||||
*
|
||||
* @param id ID
|
||||
*/
|
||||
@Override
|
||||
public void delTenantContract(Long id) {
|
||||
baseMapper.update(new Contract(), new LambdaUpdateWrapper<Contract>().eq(Contract::getId, id)
|
||||
.set(Contract::getDeleteFlag, DeleteFlag.DELETED.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查詢合同的集合
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Contract> getContractList() {
|
||||
return baseMapper.selectList(
|
||||
new LambdaQueryWrapper<Contract>().eq(Contract::getTenantId, SecurityUtils.getLoginUser().getTenantId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查詢合同的集合
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = "contractListCache", key = "'contractList'")
|
||||
public List<Contract> getRedisContractList() {
|
||||
return getContractList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查詢合同的集合
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Contract getContract(String contractNo) {
|
||||
List<Contract> contractList = getRedisContractList();
|
||||
for (Contract contract : contractList) {
|
||||
if (contractNo.equals(contract.getBusNo())) {
|
||||
return contract;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参保地信息找到对应的合同
|
||||
*
|
||||
* @param insuplcAdmdvs
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Contract getContractByInsuplcAdmdvs(String insuplcAdmdvs) {
|
||||
List<Contract> contractList = getRedisContractList();
|
||||
for (Contract contract : contractList) {
|
||||
if (insuplcAdmdvs.equals(contract.getBusNo())) {
|
||||
return contract;
|
||||
}
|
||||
}
|
||||
if (!contractList.isEmpty()) {
|
||||
Optional<Contract> max = contractList.stream().max(Comparator.comparingInt(Contract::getSort));
|
||||
if (max.isPresent()) {
|
||||
return max.get();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查詢合同的集合
|
||||
*
|
||||
* @return 合同集合
|
||||
*/
|
||||
@Override
|
||||
public List<Contract> getContractListByYb() {
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<Contract>().eq(Contract::getYbFlag, Whether.YES.getValue())
|
||||
.eq(Contract::getTenantId, SecurityUtils.getLoginUser().getTenantId()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.openhis.financial.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.financial.domain.PaymentNotice;
|
||||
import com.openhis.financial.mapper.PaymentNoticeMapper;
|
||||
import com.openhis.financial.service.IPaymentNoticeService;
|
||||
|
||||
/**
|
||||
* 合同管理Service业务层处理
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Service
|
||||
public class PaymentNoticeServiceImpl extends ServiceImpl<PaymentNoticeMapper, PaymentNotice> implements IPaymentNoticeService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.openhis.financial.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.common.enums.PaymentResult;
|
||||
import com.openhis.financial.domain.PaymentRecDetail;
|
||||
import com.openhis.financial.mapper.PaymentRecDetailMapper;
|
||||
import com.openhis.financial.model.PaymentRecDetailAccountResult;
|
||||
import com.openhis.financial.service.IPaymentRecDetailService;
|
||||
|
||||
/**
|
||||
* 付款管理Service业务层处理
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Service
|
||||
public class PaymentRecDetailServiceImpl extends ServiceImpl<PaymentRecDetailMapper, PaymentRecDetail>
|
||||
implements IPaymentRecDetailService {
|
||||
|
||||
/**
|
||||
* 根据paymentId更改结算结果
|
||||
*
|
||||
* @param id id
|
||||
* @param paid PaymentResult
|
||||
*/
|
||||
@Override
|
||||
public void updateResultByPaymentId(Long id, PaymentResult paid) {
|
||||
baseMapper.update(new PaymentRecDetail().setResultEnum(PaymentResult.PAID.getValue()),
|
||||
new LambdaQueryWrapper<PaymentRecDetail>().eq(PaymentRecDetail::getReconciliationId, id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据paymentId集合查询详情信息
|
||||
*
|
||||
* @param paymentIdList 集合
|
||||
* @return 集合
|
||||
*/
|
||||
@Override
|
||||
public List<PaymentRecDetailAccountResult> getListByReconciliationIds(List<Long> paymentIdList) {
|
||||
return baseMapper.getListByReconciliationIds(paymentIdList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.financial.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.administration.dto.ChargeItemDefInfo;
|
||||
import com.openhis.common.enums.PaymentStatisticalMethod;
|
||||
import com.openhis.common.enums.PaymentType;
|
||||
import com.openhis.financial.domain.PaymentRecStatic;
|
||||
import com.openhis.financial.mapper.PaymentRecStaticMapper;
|
||||
import com.openhis.financial.service.IPaymentRecStaticService;
|
||||
|
||||
/**
|
||||
* 付款管理Service业务层处理
|
||||
*
|
||||
* @author SunJQ
|
||||
* @date 2025-08-08
|
||||
*/
|
||||
@Service
|
||||
public class PaymentRecStaticServiceImpl extends ServiceImpl<PaymentRecStaticMapper, PaymentRecStatic>
|
||||
implements IPaymentRecStaticService {
|
||||
|
||||
/**
|
||||
* 批量保存付款快照信息
|
||||
*
|
||||
* @param paymentId 付款id
|
||||
* @param paymentType 付款/退款
|
||||
* @param paymentStatisticalMethod 统计方式:字典/医保分类
|
||||
* @param chargeItemDefInfoList chargeItem基础信息
|
||||
*/
|
||||
@Override
|
||||
public void savePaymentRecStatics(Long paymentId, PaymentType paymentType,
|
||||
PaymentStatisticalMethod paymentStatisticalMethod, List<ChargeItemDefInfo> chargeItemDefInfoList) {
|
||||
if (chargeItemDefInfoList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, List<ChargeItemDefInfo>> collect;
|
||||
List<PaymentRecStatic> paymentRecStatics = new ArrayList<>();
|
||||
if (paymentStatisticalMethod == PaymentStatisticalMethod.FIN_TYPE_CODE) {
|
||||
collect = chargeItemDefInfoList.stream().collect(Collectors.groupingBy(ChargeItemDefInfo::getTypeCode));
|
||||
getPaymentRecStaticList(paymentId, paymentType, paymentStatisticalMethod, collect, paymentRecStatics);
|
||||
} else if (paymentStatisticalMethod == PaymentStatisticalMethod.MED_CHRGITM_TYPE) {
|
||||
collect = chargeItemDefInfoList.stream().collect(Collectors.groupingBy(ChargeItemDefInfo::getYbType));
|
||||
getPaymentRecStaticList(paymentId, paymentType, paymentStatisticalMethod, collect, paymentRecStatics);
|
||||
} else {
|
||||
collect = chargeItemDefInfoList.stream().collect(Collectors.groupingBy(ChargeItemDefInfo::getTypeCode));
|
||||
getPaymentRecStaticList(paymentId, paymentType, PaymentStatisticalMethod.FIN_TYPE_CODE, collect,
|
||||
paymentRecStatics);
|
||||
collect = chargeItemDefInfoList.stream().collect(Collectors.groupingBy(ChargeItemDefInfo::getYbType));
|
||||
getPaymentRecStaticList(paymentId, paymentType, PaymentStatisticalMethod.MED_CHRGITM_TYPE, collect,
|
||||
paymentRecStatics);
|
||||
}
|
||||
saveBatch(paymentRecStatics);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paymentId 付款id
|
||||
* @param paymentType 付款/退款
|
||||
* @param paymentStatisticalMethod 统计方式:字典/医保分类
|
||||
* @param collect map
|
||||
* @param paymentRecStatics 集合
|
||||
*/
|
||||
public void getPaymentRecStaticList(Long paymentId, PaymentType paymentType,
|
||||
PaymentStatisticalMethod paymentStatisticalMethod, Map<String, List<ChargeItemDefInfo>> collect,
|
||||
List<PaymentRecStatic> paymentRecStatics) {
|
||||
PaymentRecStatic paymentRecStatic;
|
||||
BigDecimal bigDecimal;
|
||||
for (Map.Entry<String, List<ChargeItemDefInfo>> stringListEntry : collect.entrySet()) {
|
||||
paymentRecStatic = new PaymentRecStatic();
|
||||
bigDecimal = BigDecimal.ZERO;
|
||||
for (ChargeItemDefInfo chargeItemDefInfo : stringListEntry.getValue()) {
|
||||
bigDecimal = bigDecimal.add(chargeItemDefInfo.getTotalPrice().multiply(paymentType.getMultiplier()));
|
||||
}
|
||||
paymentRecStatic.setAmount(bigDecimal).setReconciliationId(paymentId).setTypeCode(stringListEntry.getKey())
|
||||
.setChargeItemIds(JSON.toJSONString(
|
||||
stringListEntry.getValue().stream().map(ChargeItemDefInfo::getId).collect(Collectors.toList())))
|
||||
.setCountBy(paymentStatisticalMethod.getValue());
|
||||
paymentRecStatics.add(paymentRecStatic);
|
||||
}
|
||||
// return paymentRecStatics;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
package com.openhis.financial.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.utils.AssignSeqUtil;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.core.common.utils.StringUtils;
|
||||
import com.openhis.common.constant.CommonConstants;
|
||||
import com.openhis.common.constant.YbCommonConstants;
|
||||
import com.openhis.common.enums.DelFlag;
|
||||
import com.openhis.common.enums.PaymentKind;
|
||||
import com.openhis.common.enums.PaymentStatus;
|
||||
import com.openhis.common.enums.ybenums.YbMdtrtCertType;
|
||||
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.PaymentResult;
|
||||
import com.openhis.financial.model.PaymentedItemModel;
|
||||
import com.openhis.financial.model.PrePaymentResult;
|
||||
import com.openhis.financial.service.IContractService;
|
||||
import com.openhis.financial.service.IPaymentReconciliationService;
|
||||
import com.openhis.yb.dto.Clinic2206OrderOutput;
|
||||
import com.openhis.yb.dto.ClinicReg2201Output;
|
||||
import com.openhis.yb.dto.PaymentInpatientDto;
|
||||
import com.openhis.yb.dto.Yb2304OutputSetlInfo;
|
||||
import com.openhis.yb.model.Clinic2207OrderModel;
|
||||
import com.openhis.yb.service.YbManager;
|
||||
|
||||
/**
|
||||
* 付款管理Service业务层处理
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Service
|
||||
public class PaymentReconciliationServiceImpl extends ServiceImpl<PaymentReconciliationMapper, PaymentReconciliation>
|
||||
implements IPaymentReconciliationService {
|
||||
@Resource
|
||||
private AssignSeqUtil assignSeqUtil;
|
||||
@Autowired
|
||||
private IContractService iContractService;
|
||||
@Autowired
|
||||
private YbManager ybManager;
|
||||
|
||||
/**
|
||||
* 根据支付id获取对应收费项目的id列表
|
||||
*
|
||||
* @param paymentIdList 支付id列表
|
||||
* @return 收费项目的id列表
|
||||
*/
|
||||
@Override
|
||||
public List<Long> getChargeItemIdListByPayment(List<Long> paymentIdList) {
|
||||
|
||||
// 根据支付id获取支付信息
|
||||
List<PaymentReconciliation> paymentReconciliationList =
|
||||
baseMapper.selectList(new LambdaQueryWrapper<PaymentReconciliation>()
|
||||
.select(PaymentReconciliation::getChargeItemIds).in(PaymentReconciliation::getId, paymentIdList));
|
||||
if (paymentReconciliationList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
// 拆解所有的chargeItemId,拼装成一个集合
|
||||
List<String> chargeItemIdList = paymentReconciliationList.stream().map(PaymentReconciliation::getChargeItemIds)
|
||||
.collect(Collectors.toList());
|
||||
List<Long> chargeItemIds = new ArrayList<>();
|
||||
for (String chargeItemId : chargeItemIdList) {
|
||||
if (StringUtils.isNotEmpty(chargeItemId)) {
|
||||
chargeItemIds.addAll(Arrays
|
||||
.stream(
|
||||
chargeItemId.replaceAll("\\[", "").replaceAll("\\]", "").split(CommonConstants.Common.COMMA))
|
||||
.map(Long::parseLong).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
// 将收费项目集合转换成列表
|
||||
return chargeItemIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新付款状态:退款中
|
||||
*
|
||||
* @param paymentIdList 支付id列表
|
||||
*/
|
||||
@Override
|
||||
public void updateRefundingStatus(List<Long> paymentIdList) {
|
||||
baseMapper.update(new PaymentReconciliation().setStatusEnum(PaymentStatus.REFUNDING.getValue()),
|
||||
new LambdaUpdateWrapper<PaymentReconciliation>().in(PaymentReconciliation::getId, paymentIdList));
|
||||
}
|
||||
|
||||
/**
|
||||
* PS:对chargeItem分付款方式 2025/05/23 ChargeItem分完付款方式之后,医保支付的ChargeItem还要分特慢病和普通门诊,特慢病等支付与常规门诊支付传参不一样
|
||||
*/
|
||||
/**
|
||||
* 【预结算】
|
||||
*
|
||||
* @param ybMdtrtCertType 医保凭证类型
|
||||
* @param busiCardInfo 读卡获取的密钥
|
||||
* @param contractBusNo 合同编号
|
||||
* @param paymentedItemList 收费项
|
||||
* @return 预结算结果
|
||||
*/
|
||||
@Override
|
||||
public PrePaymentResult preSettle(YbMdtrtCertType ybMdtrtCertType, String busiCardInfo, String contractBusNo,
|
||||
List<PaymentedItemModel> paymentedItemList) {
|
||||
|
||||
PrePaymentResult prePaymentResult = null;
|
||||
String ybSwitchFlag = SecurityUtils.getLoginUser().getOptionJson().getString(CommonConstants.Option.YB_SWITCH);
|
||||
if (ybSwitchFlag.equals("0")) {
|
||||
contractBusNo = CommonConstants.BusinessName.DEFAULT_CONTRACT_NO;
|
||||
}
|
||||
|
||||
Contract contract = iContractService.getContract(contractBusNo);
|
||||
|
||||
switch (contractBusNo) {
|
||||
case CommonConstants.BusinessName.DEFAULT_CONTRACT_NO:
|
||||
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(sumAmount);
|
||||
prePaymentResult.setChrgBchno(CommonConstants.BusinessName.DEFAULT_CONTRACT_NO);
|
||||
break;
|
||||
case "229900":// 吉林省医保
|
||||
case "220199":// 长春市医保(农大)
|
||||
case "220100":// 长春市医保(长大)
|
||||
Map<String, List<PaymentedItemModel>> collect =
|
||||
paymentedItemList.stream().collect(Collectors.groupingBy(PaymentedItemModel::getMedType));
|
||||
PrePaymentResult result;
|
||||
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());
|
||||
}
|
||||
// 调用预结算
|
||||
clinic2206OrderOutput = ybManager.preSettle(contract, medTypeKV.getValue().get(0).getEncounterId(),
|
||||
ybMdtrtCertType, busiCardInfo, reg2201Output, "01", medTypeKV.getValue().stream()
|
||||
.map(PaymentedItemModel::getChargeItemId).collect(Collectors.toList()),
|
||||
YbMedType.getByValue(medTypeKV.getKey()));
|
||||
prePaymentResult = new PrePaymentResult();
|
||||
BeanUtils.copyProperties(clinic2206OrderOutput, prePaymentResult);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return prePaymentResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 【门诊结算】
|
||||
*
|
||||
* @param contract 合同
|
||||
* @param payTransNo 支付批次号
|
||||
* @param ybMdtrtCertType 凭证类型
|
||||
* @param busiCardInfo 读卡获取到的凭证
|
||||
* @param minpacuntDrugTracCnt 追溯码相关信息
|
||||
* @param mcsTracCnt 追溯码相关信息
|
||||
* @return 结算结果
|
||||
*/
|
||||
@Override
|
||||
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)) {
|
||||
// 医保支付 todo:支付的详细信息在于结算中已经存好了,但是还没有存储卡余额
|
||||
Clinic2207OrderModel clinic2207OrderModel =
|
||||
ybManager.settle(contract, payTransNo, busiCardInfo, ybMdtrtCertType, minpacuntDrugTracCnt, mcsTracCnt);
|
||||
paymentResult = new PaymentResult();
|
||||
BeanUtils.copyProperties(clinic2207OrderModel, paymentResult);
|
||||
} else {
|
||||
// 自费返回new实体
|
||||
paymentResult = new PaymentResult();
|
||||
}
|
||||
return paymentResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 【住院结算】
|
||||
*
|
||||
* @param contract 合同
|
||||
* @param paymentDto 收费参数
|
||||
* @return 结算结果
|
||||
*/
|
||||
@Override
|
||||
public PaymentResult inpatientSettle(Contract contract, PaymentInpatientDto paymentDto) {
|
||||
PaymentResult paymentResult = null;
|
||||
if (!CommonConstants.BusinessName.DEFAULT_CONTRACT_NO.equals(contract.getBusNo())) {
|
||||
// 医保支付 todo:支付的详细信息在于结算中已经存好了,但是还没有存储卡余额
|
||||
Yb2304OutputSetlInfo yb2304OutputSetlInfo = ybManager.inpatientSettle(contract, paymentDto);
|
||||
paymentResult = new PaymentResult();
|
||||
BeanUtils.copyProperties(yb2304OutputSetlInfo, paymentResult);
|
||||
} else {
|
||||
// 自费返回new实体
|
||||
paymentResult = new PaymentResult();
|
||||
}
|
||||
return paymentResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改付款状态
|
||||
*
|
||||
* @param id paymentId
|
||||
* @param success 付款状态
|
||||
*/
|
||||
@Override
|
||||
public void updatePaymentStatusById(Long id, PaymentStatus success) {
|
||||
baseMapper.update(new PaymentReconciliation().setStatusEnum(success.getValue()),
|
||||
new LambdaQueryWrapper<PaymentReconciliation>().eq(PaymentReconciliation::getId, id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改payment状态以及医保支付结算id
|
||||
*
|
||||
* @param id 主键id
|
||||
* @param success 状态
|
||||
* @param settleId 医保结算id
|
||||
*/
|
||||
@Override
|
||||
public void updatePaymentStatusAndSettleIdsById(Long id, PaymentStatus success, List<String> settleId) {
|
||||
if (settleId.isEmpty()) {
|
||||
baseMapper.update(new PaymentReconciliation().setStatusEnum(success.getValue()),
|
||||
new LambdaQueryWrapper<PaymentReconciliation>().eq(PaymentReconciliation::getId, id));
|
||||
} else {
|
||||
baseMapper.update(
|
||||
new PaymentReconciliation().setStatusEnum(success.getValue())
|
||||
.setYbSettleIds(String.join(",", settleId)),
|
||||
new LambdaQueryWrapper<PaymentReconciliation>().eq(PaymentReconciliation::getId, id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询付款实体
|
||||
*
|
||||
* @param encounterId 就诊id
|
||||
* @return 付款实体
|
||||
*/
|
||||
@Override
|
||||
public PaymentReconciliation getByEncounterId(Long encounterId, PaymentKind paymentKind) {
|
||||
return baseMapper.selectOne(new LambdaQueryWrapper<PaymentReconciliation>()
|
||||
.eq(PaymentReconciliation::getEncounterId, encounterId)
|
||||
.eq(PaymentReconciliation::getKindEnum, PaymentKind.HOSPITAL_DEPOSIT.getValue())
|
||||
.eq(PaymentReconciliation::getDeleteFlag, DelFlag.NO.getCode()).last(YbCommonConstants.sqlConst.LIMIT1));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user