Revert "Fix Bug #550: AI修复"

This reverts commit 16c42ca108.
This commit is contained in:
2026-05-27 08:59:07 +08:00
parent bd14563691
commit 9db5ced4e3
5432 changed files with 778638 additions and 171 deletions

View File

@@ -0,0 +1,64 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.appservice;
import com.core.common.core.domain.R;
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
import com.openhis.web.chargemanage.dto.EncounterPatientPrescriptionDto;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 门诊收费 service
*
* @author zwh
* @date 2025-03-12
*/
public interface IInpatientChargeAppService {
/**
* 门诊收费页面初始化
*
* @return 初始化信息
*/
R<?> inpatientChargeInit();
/**
* 查询住院患者分页列表
*
* @param encounterPatientPageParam 查询条件
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @param request 请求
* @return 住院患者分页列表
*/
R<?> getEncounterPatientPage(EncounterPatientPageParam encounterPatientPageParam, String searchKey, Integer pageNo,
Integer pageSize, HttpServletRequest request);
/**
* 根据就诊id查询患者待结算信息
*
* @param encounterId 就诊id
* @return 患者待结算信息
*/
List<EncounterPatientPrescriptionDto> getEncounterPatientPrescription(Long encounterId);
/**
* 医保转自费
*
* @param encounterId 就诊id
* @return 操作结果
*/
R<?> changeToSelfPay(Long encounterId);
/**
* 自费转医保
*
* @param encounterId 就诊id
* @return 操作结果
*/
R<?> changeToMedicalInsurance(Long encounterId);
}

View File

@@ -0,0 +1,88 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.appservice;
import com.core.common.core.domain.R;
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
import com.openhis.web.chargemanage.dto.EncounterPatientPrescriptionDto;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 门诊收费 service
*
* @author zwh
* @date 2025-03-12
*/
public interface IOutpatientChargeAppService {
/**
* 查询就诊患者分页列表
*
* @param encounterPatientPageParam 查询条件
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @param request 请求
* @return 就诊患者分页列表
*/
R<?> getEncounterPatientPage(EncounterPatientPageParam encounterPatientPageParam, String searchKey, Integer pageNo,
Integer pageSize, HttpServletRequest request);
/**
* 根据就诊id查询患者处方列表
*
* @param encounterId 就诊id
* @return 患者处方列表
*/
List<EncounterPatientPrescriptionDto> getEncounterPatientPrescription(Long encounterId);
/**
* 根据就诊id查询患者处方列表并新增字段实收金额、应收金额、优惠金额、折扣率
*
* @param encounterId 就诊id
* @return 患者处方列表
*/
List<EncounterPatientPrescriptionDto> getEncounterPatientPrescriptionWithPrice(Long encounterId);
/**
* 医保转自费
*
* @param encounterId 就诊id
* @return 操作结果
*/
R<?> changeToSelfPay(Long encounterId);
/**
* 自费转医保
*
* @param encounterId 就诊id
* @return 操作结果
*/
R<?> changeToMedicalInsurance(Long encounterId);
/**
* 门诊收费页面初始化
*
* @return 初始化信息
*/
R<?> outpatientChargeInit();
/**
* 学生医保转自费
*
* @param encounterId 就诊id
* @return 结果
*/
R<?> changeToStudentSelfPay(Long encounterId);
/**
* 学生自费转学生医保
*
* @param encounterId 就诊id
* @return 结果
*/
R<?> changeToStudentYbPay(Long encounterId);
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.appservice;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.openhis.web.doctorstation.dto.AdviceBaseDto;
import com.openhis.web.doctorstation.dto.PatientInfoDto;
import javax.servlet.http.HttpServletRequest;
/**
* 门诊划价 service
*
* @author yangmo
* @date 2025-04-14
*/
public interface IOutpatientPricingAppService {
/**
* 查询就诊患者信息
*
* @param patientInfoDto 查询条件 (前端可传 statusEnum 区分就诊状态tab)
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 就诊患者信息
*/
IPage<PatientInfoDto> getPatientInfo(PatientInfoDto patientInfoDto, String searchKey, Integer pageNo,
Integer pageSize, HttpServletRequest request);
/**
* 查询医嘱信息
*
* @param adviceBaseDto 查询条件
* @param searchKey 模糊查询关键字
* @param locationId 药房id
* @param organizationId 患者挂号对应的科室id
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 医嘱信息
*/
IPage<AdviceBaseDto> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto, String searchKey, Long locationId,
Long organizationId, Integer pageNo, Integer pageSize);
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.appservice;
import com.core.common.core.domain.R;
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
import com.openhis.web.chargemanage.dto.RefundItemParam;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 门诊退费 service
*
* @author zwh
* @date 2025-03-15
*/
public interface IOutpatientRefundAppService {
/**
* 根据就诊id查询患者的账单
*
* @param encounterId 就诊id
* @return 患者账单列表
*/
R<?> getEncounterPatientPayment(Long encounterId);
/**
* 根据账单退费
*
* @param refundItemList 退费项目id列表
* @return 操作结果
*/
R<?> refundPayment(List<RefundItemParam> refundItemList);
/**
* 查询结算过的就诊患者分页列表
*
* @param encounterPatientPageParam 查询条件
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @param request 请求
* @return 就诊患者分页列表
*/
R<?> getBilledEncounterPatientPage(EncounterPatientPageParam encounterPatientPageParam, String searchKey,
Integer pageNo, Integer pageSize, HttpServletRequest request);
/**
* 门诊退费页面初始化
*
* @return 初始化信息
*/
R<?> outpatientRefundInit();
/**
* 根据就诊id查询患者的退费账单
*
* @param encounterId 就诊id
* @param billDateSTime 收费时间开始
* @param billDateETime 收费时间结束
* @return 退费账单列表
*/
R<?> getEncounterPatientRefund(Long encounterId, String billDateSTime, String billDateETime);
/**
* 根据就诊id查询患者因退费重新生成的账单
*
* @param encounterId 就诊id
* @return 重新生成的账单列表
*/
R<?> getRegenerateCharge(Long encounterId);
/**
* 校验是否可以退费(耗材/药品是否已退,诊疗是否取消执行)
*
* @param chargeItemIdList 收费项目id列表
* @return 是否可退
*/
R<?> verifyRefundable(List<Long> chargeItemIdList);
}

View File

@@ -0,0 +1,97 @@
package com.openhis.web.chargemanage.appservice;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R;
import com.openhis.web.basicservice.dto.HealthcareServiceDto;
import com.openhis.web.chargemanage.dto.CurrentDayEncounterDto;
import com.openhis.web.chargemanage.dto.OrgMetadata;
import com.openhis.web.chargemanage.dto.PatientMetadata;
import com.openhis.web.chargemanage.dto.PractitionerMetadata;
import com.openhis.web.chargemanage.dto.ReprintRegistrationDto;
import com.openhis.web.paymentmanage.dto.CancelRegPaymentDto;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 门诊挂号 应用Service
*/
public interface IOutpatientRegistrationAppService {
/**
* 查询患者信息
*
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 患者信息
*/
Page<PatientMetadata> getPatientMetadataBySearchKey(String searchKey, Integer pageNo, Integer pageSize);
/**
* 查询门诊科室数据
*
* @return 门诊科室
*/
List<OrgMetadata> getOrgMetadata();
/**
* 根据科室id筛选医生
*
* @param orgId 科室ID
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 筛选医生
*/
IPage<PractitionerMetadata> getPractitionerMetadataByLocationId(Long orgId, String searchKey, Integer pageNo,
Integer pageSize);
/**
* 根据机构id筛选服务项目
*
* @param organizationId 机构id
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 服务项目
*/
IPage<HealthcareServiceDto> getHealthcareMetadataByOrganizationId(Long organizationId, String searchKey,
Integer pageNo, Integer pageSize);
/**
* 退号
*
* @param cancelRegPaymentDto 就诊id
* @return 结果
*/
R<?> returnRegister(CancelRegPaymentDto cancelRegPaymentDto);
/**
* 查询当日就诊数据
*
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 当日就诊数据
*/
IPage<CurrentDayEncounterDto> getCurrentDayEncounter(String searchKey, Integer pageNo, Integer pageSize, HttpServletRequest request);
/**
* 取消挂号
*
* @param encounterId 就诊id
* @return 结果
*/
R<?> cancelRegister(Long encounterId);
/**
* 补打挂号
*
* @param reprintRegistrationDto 补打挂号信息
* @return 结果
*/
R<?> reprintRegistration(ReprintRegistrationDto reprintRegistrationDto);
}

View File

@@ -0,0 +1,168 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.appservice.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R;
import com.core.common.utils.AgeCalculatorUtil;
import com.core.common.utils.MessageUtils;
import com.openhis.administration.service.IAccountService;
import com.openhis.administration.service.IChargeItemService;
import com.openhis.common.constant.CommonConstants;
import com.openhis.common.constant.PromptMsgConstant;
import com.openhis.common.enums.*;
import com.openhis.common.utils.EnumUtils;
import com.openhis.common.utils.HisQueryUtils;
import com.openhis.web.chargemanage.appservice.IInpatientChargeAppService;
import com.openhis.web.chargemanage.dto.EncounterPatientPageDto;
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
import com.openhis.web.chargemanage.dto.EncounterPatientPrescriptionDto;
import com.openhis.web.chargemanage.dto.OutpatientInitDto;
import com.openhis.web.chargemanage.mapper.InpatientChargeAppMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
/**
* 门诊收费 impl
*
* @author zwh
* @date 2025-03-12
*/
@Service
public class InpatientChargeAppServiceImpl implements IInpatientChargeAppService {
@Autowired
private InpatientChargeAppMapper inpatientChargeAppMapper;
@Autowired
private IChargeItemService chargeItemService;
@Autowired
private IAccountService accountService;
/**
* 住院结算页面初始化
*
* @return 初始化信息
*/
@Override
public R<?> inpatientChargeInit() {
OutpatientInitDto initDto = new OutpatientInitDto();
List<OutpatientInitDto.encounterStatusOption> encounterStatusOptions = new ArrayList<>();
encounterStatusOptions
.add(new OutpatientInitDto.encounterStatusOption(EncounterZyStatus.DISCHARGED_FROM_HOSPITAL.getValue(),
EncounterZyStatus.DISCHARGED_FROM_HOSPITAL.getInfo()));
encounterStatusOptions.add(new OutpatientInitDto.encounterStatusOption(
EncounterZyStatus.ALREADY_SETTLED.getValue(), EncounterZyStatus.ALREADY_SETTLED.getInfo()));
initDto.setEncounterStatusOptions(encounterStatusOptions);
return R.ok(initDto);
}
/**
* 查询住院患者分页列表
*
* @param encounterPatientPageParam 查询条件
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @param request 请求
* @return 住院患者分页列表
*/
@Override
public R<?> getEncounterPatientPage(EncounterPatientPageParam encounterPatientPageParam, String searchKey,
Integer pageNo, Integer pageSize, HttpServletRequest request) {
// 构建查询条件
QueryWrapper<EncounterPatientPageParam> queryWrapper = HisQueryUtils.buildQueryWrapper(
encounterPatientPageParam, searchKey,
new HashSet<>(Arrays.asList(CommonConstants.FieldName.PatientWbStr, CommonConstants.FieldName.PatientPyStr,
CommonConstants.FieldName.PatientName, CommonConstants.FieldName.PatientBusNo,
CommonConstants.FieldName.EncounterBusNo, CommonConstants.FieldName.IdCard)),
request);
// 就诊患者分页列表
Page<EncounterPatientPageDto> encounterPatientPage = inpatientChargeAppMapper.selectEncounterPatientPage(
EncounterClass.IMP.getValue(), EncounterZyStatus.DISCHARGED_FROM_HOSPITAL.getValue(),
EncounterZyStatus.ALREADY_SETTLED.getValue(), ChargeItemStatus.BILLABLE.getValue(),
ChargeItemStatus.BILLED.getValue(), ChargeItemStatus.REFUNDED.getValue(),
AccountType.PERSONAL_CASH_ACCOUNT.getCode(), new Page<>(pageNo, pageSize), queryWrapper);
encounterPatientPage.getRecords().forEach(e -> {
// 性别枚举
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
// 住院状态
e.setEncounterStatus_enumText(EnumUtils.getInfoByValue(EncounterZyStatus.class, e.getEncounterStatus()));
// 计算年龄
e.setAge(e.getBirthDate() != null ? AgeCalculatorUtil.getAge(e.getBirthDate()) : "");
});
return R.ok(encounterPatientPage);
}
/**
* 根据就诊id查询患者待结算信息
*
* @param encounterId 就诊id
* @return 患者待结算信息
*/
@Override
public List<EncounterPatientPrescriptionDto> getEncounterPatientPrescription(Long encounterId) {
List<EncounterPatientPrescriptionDto> prescriptionDtoList =
inpatientChargeAppMapper.selectEncounterPatientPrescription(encounterId,
ChargeItemContext.ACTIVITY.getValue(), ChargeItemContext.MEDICATION.getValue(),
ChargeItemContext.DEVICE.getValue(), ChargeItemContext.REGISTER.getValue(),
ChargeItemStatus.PLANNED.getValue(), ChargeItemStatus.BILLABLE.getValue(),
ChargeItemStatus.BILLED.getValue(), ChargeItemStatus.REFUNDING.getValue(),
ChargeItemStatus.REFUNDED.getValue(), ChargeItemStatus.PART_REFUND.getValue());
prescriptionDtoList.forEach(e -> {
// 收费状态枚举
e.setStatusEnum_enumText(EnumUtils.getInfoByValue(ChargeItemStatus.class, e.getStatusEnum()));
});
return prescriptionDtoList;
}
/**
* 医保转自费
*
* @param encounterId 就诊id
* @return 操作结果
*/
@Override
public R<?> changeToSelfPay(Long encounterId) {
// 获取就诊患者的自费账户id
Long accountId = accountService.getSelfPayAccount(encounterId);
if (accountId == null) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00008, new Object[] {"自费账户"}));
}
// 医保转自费
boolean result = chargeItemService.updateAccountType(encounterId, accountId);
if (!result) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00009, null));
}
return R.ok(MessageUtils.createMessage(PromptMsgConstant.Common.M00004, null));
}
/**
* 自费转医保
*
* @param encounterId 就诊id
* @return 操作结果
*/
@Override
public R<?> changeToMedicalInsurance(Long encounterId) {
// 获取就诊患者的医保账户id
Long accountId = accountService.getMedicalInsuranceAccount(encounterId);
if (accountId == null) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00008, new Object[] {"医保账户"}));
}
// 自费转医保
boolean result = chargeItemService.updateAccountType(encounterId, accountId);
if (!result) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00009, null));
}
return R.ok(MessageUtils.createMessage(PromptMsgConstant.Common.M00004, null));
}
}

View File

@@ -0,0 +1,281 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.appservice.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R;
import com.core.common.utils.AgeCalculatorUtil;
import com.core.common.utils.MessageUtils;
import com.openhis.administration.service.IAccountService;
import com.openhis.administration.service.IChargeItemService;
import com.openhis.common.constant.CommonConstants;
import com.openhis.common.constant.PromptMsgConstant;
import com.openhis.common.enums.AdministrativeGender;
import com.openhis.common.enums.ChargeItemContext;
import com.openhis.common.enums.ChargeItemStatus;
import com.openhis.common.enums.EncounterClass;
import com.openhis.common.enums.ybenums.YbPayment;
import com.openhis.common.utils.EnumUtils;
import com.openhis.common.utils.HisQueryUtils;
import com.openhis.web.chargemanage.appservice.IOutpatientChargeAppService;
import com.openhis.web.chargemanage.dto.EncounterPatientPageDto;
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
import com.openhis.web.chargemanage.dto.EncounterPatientPrescriptionDto;
import com.openhis.web.chargemanage.dto.OutpatientInitDto;
import com.openhis.web.chargemanage.mapper.OutpatientChargeAppMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
/**
* 门诊收费 impl
*
* @author zwh
* @date 2025-03-12
*/
@Service
public class OutpatientChargeAppServiceImpl implements IOutpatientChargeAppService {
@Autowired
private OutpatientChargeAppMapper outpatientChargeAppMapper;
@Autowired
private IChargeItemService chargeItemService;
@Autowired
private IAccountService accountService;
/**
* 门诊收费页面初始化
*
* @return 初始化信息
*/
@Override
public R<?> outpatientChargeInit() {
OutpatientInitDto initDto = new OutpatientInitDto();
List<OutpatientInitDto.chargeItemStatusOption> chargeItemStatusOptions = new ArrayList<>();
chargeItemStatusOptions.add(new OutpatientInitDto.chargeItemStatusOption(ChargeItemStatus.PLANNED.getValue(),
ChargeItemStatus.PLANNED.getInfo()));
chargeItemStatusOptions.add(new OutpatientInitDto.chargeItemStatusOption(ChargeItemStatus.BILLABLE.getValue(),
ChargeItemStatus.BILLABLE.getInfo()));
chargeItemStatusOptions.add(new OutpatientInitDto.chargeItemStatusOption(ChargeItemStatus.BILLED.getValue(),
ChargeItemStatus.BILLED.getInfo()));
initDto.setChargeItemStatusOptions(chargeItemStatusOptions);
return R.ok(initDto);
}
/**
* 查询就诊患者分页列表
*
* @param encounterPatientPageParam 查询条件
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @param request 请求
* @return 就诊患者分页列表
*/
@Override
public R<?> getEncounterPatientPage(EncounterPatientPageParam encounterPatientPageParam, String searchKey,
Integer pageNo, Integer pageSize, HttpServletRequest request) {
// 构建查询条件
QueryWrapper<EncounterPatientPageParam> queryWrapper = HisQueryUtils.buildQueryWrapper(
encounterPatientPageParam, searchKey,
new HashSet<>(Arrays.asList(CommonConstants.FieldName.PatientWbStr, CommonConstants.FieldName.PatientPyStr,
CommonConstants.FieldName.PatientName, CommonConstants.FieldName.PatientBusNo,
CommonConstants.FieldName.EncounterBusNo, CommonConstants.FieldName.IdCard)),
request);
// 就诊患者分页列表
Page<EncounterPatientPageDto> encounterPatientPage = outpatientChargeAppMapper
.selectEncounterPatientPage(new Page<>(pageNo, pageSize), queryWrapper, EncounterClass.AMB.getValue());
encounterPatientPage.getRecords().forEach(e -> {
// 性别枚举
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
// 收费状态枚举
e.setStatusEnum_enumText(EnumUtils.getInfoByValue(ChargeItemStatus.class, e.getStatusEnum()));
// 计算年龄
e.setAge(e.getBirthDate() != null ? AgeCalculatorUtil.getAge(e.getBirthDate()) : "");
});
return R.ok(encounterPatientPage);
}
/**
* 根据就诊id查询患者处方列表
*
* @param encounterId 就诊id
* @return 患者处方列表
*/
@Override
public List<EncounterPatientPrescriptionDto> getEncounterPatientPrescription(Long encounterId) {
List<EncounterPatientPrescriptionDto> prescriptionDtoList
= outpatientChargeAppMapper.selectEncounterPatientPrescription(encounterId,
ChargeItemContext.ACTIVITY.getValue(), ChargeItemContext.MEDICATION.getValue(),
ChargeItemContext.DEVICE.getValue(), ChargeItemContext.REGISTER.getValue(),
ChargeItemContext.WESTERN_MEDICINE.getValue(), ChargeItemContext.CHINESE_PATENT_MEDICINE.getValue(),
ChargeItemStatus.PLANNED.getValue(), ChargeItemStatus.BILLABLE.getValue(),
ChargeItemStatus.BILLED.getValue(), ChargeItemStatus.REFUNDING.getValue(),
ChargeItemStatus.REFUNDED.getValue(), ChargeItemStatus.PART_REFUND.getValue(),
CommonConstants.TableName.WOR_DEVICE_REQUEST);
prescriptionDtoList.forEach(e -> {
// 收费状态枚举
e.setStatusEnum_enumText(EnumUtils.getInfoByValue(ChargeItemStatus.class, e.getStatusEnum()));
});
return prescriptionDtoList;
}
/**
* 医保转自费
*
* @param encounterId 就诊id
* @return 操作结果
*/
@Override
public R<?> changeToSelfPay(Long encounterId) {
// 获取就诊患者的自费账户id
Long accountId = accountService.getSelfPayAccount(encounterId);
if (accountId == null) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00008, new Object[]{"自费账户"}));
}
// 医保转自费
boolean result = chargeItemService.updateAccountType(encounterId, accountId);
if (!result) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00009, null));
}
return R.ok(MessageUtils.createMessage(PromptMsgConstant.Common.M00004, null));
}
/**
* 自费转医保
*
* @param encounterId 就诊id
* @return 操作结果
*/
@Override
public R<?> changeToMedicalInsurance(Long encounterId) {
// 获取就诊患者的医保账户id
Long accountId = accountService.getMedicalInsuranceAccount(encounterId);
if (accountId == null) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00008, new Object[]{"医保账户"}));
}
// 自费转医保
boolean result = chargeItemService.updateAccountType(encounterId, accountId);
if (!result) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00009, null));
}
return R.ok(MessageUtils.createMessage(PromptMsgConstant.Common.M00004, null));
}
/**
* 学生医保转学生自费
*
* @param encounterId 就诊id
* @return 结果
*/
@Override
public R<?> changeToStudentSelfPay(Long encounterId) {
// 获取就诊患者的学生自费账户id
Long accountId = accountService.getStudentSelfAccount(encounterId);
if (accountId == null) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00008, new Object[]{"医保账户"}));
}
// 自费转医保
boolean result = chargeItemService.updateAccountType(encounterId, accountId);
if (!result) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00009, null));
}
return R.ok(MessageUtils.createMessage(PromptMsgConstant.Common.M00004, null));
}
/**
* 学生自费转学生医保
*
* @param encounterId 就诊id
* @return 结果
*/
@Override
public R<?> changeToStudentYbPay(Long encounterId) {
// 获取就诊患者的学生医保账户id
Long accountId = accountService.getStudentYbAccount(encounterId);
if (accountId == null) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00008, new Object[]{"医保账户"}));
}
// 自费转医保
boolean result = chargeItemService.updateAccountType(encounterId, accountId);
if (!result) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Payment.M00009, null));
}
return R.ok(MessageUtils.createMessage(PromptMsgConstant.Common.M00004, null));
}
/**
* 根据就诊id查询患者处方列表并新增字段应收金额实收金额优惠金额折扣率
*
* @param encounterId 就诊id
* @return 患者处方列表
*/
@Override
public List<EncounterPatientPrescriptionDto> getEncounterPatientPrescriptionWithPrice(Long encounterId) {
List<EncounterPatientPrescriptionDto> prescriptionDtoList = outpatientChargeAppMapper
.selectEncounterPatientPrescriptionWithPrice(encounterId, ChargeItemContext.ACTIVITY.getValue(),
ChargeItemContext.MEDICATION.getValue(), ChargeItemContext.DEVICE.getValue(),
ChargeItemContext.REGISTER.getValue(), ChargeItemStatus.PLANNED.getValue(),
ChargeItemStatus.BILLABLE.getValue(), ChargeItemStatus.BILLED.getValue(),
ChargeItemStatus.REFUNDING.getValue(), ChargeItemStatus.REFUNDED.getValue(),
ChargeItemStatus.PART_REFUND.getValue(), YbPayment.DISCOUNT_PAY.getValue(),
YbPayment.SELF_CASH_VALUE.getValue(), YbPayment.SELF_CASH_VX_VALUE.getValue(),
YbPayment.SELF_CASH_ALI_VALUE.getValue(), YbPayment.SELF_CASH_UNION_VALUE.getValue(),
CommonConstants.TableName.WOR_DEVICE_REQUEST);
prescriptionDtoList.forEach(e -> {
// 应收金额
BigDecimal receivableAmount = e.getReceivableAmount();
// 实收金额
BigDecimal receivedAmount = e.getReceivedAmount();
// 计算折扣率
BigDecimal discountRate = BigDecimal.ONE;
if (receivableAmount.compareTo(BigDecimal.ZERO) > 0 && receivedAmount.compareTo(BigDecimal.ZERO) > 0
&& receivableAmount.compareTo(receivedAmount) > 0) {
discountRate = receivedAmount.divide(receivableAmount, 2, RoundingMode.HALF_UP);
}
e.setDiscountRate(this.returnDiscountRate(discountRate));
// 收费状态枚举
e.setStatusEnum_enumText(EnumUtils.getInfoByValue(ChargeItemStatus.class, e.getStatusEnum()));
});
return prescriptionDtoList;
}
/**
* 调整折扣率
*
* @param discountRate 折扣率
* @return 调整后的折扣率0.05的倍数)
*
*/
private String returnDiscountRate(BigDecimal discountRate) {
BigDecimal compareValue = BigDecimal.valueOf(0.05);
BigDecimal remainder = discountRate.remainder(compareValue);
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
// 比较余数若为0则数据为0.05倍数,否则需要再次四舍五入
if (remainder.compareTo(BigDecimal.ZERO) == 0) {
return df.format(discountRate);
} else {
// 再次四舍五入
BigDecimal reActuarial = BigDecimal.ZERO;
if (remainder.compareTo(BigDecimal.valueOf(CommonConstants.UtilMethodConstant.THRESHOLD_VALUE)) > 0) {
reActuarial = discountRate.add(compareValue.subtract(remainder));
} else {
reActuarial = discountRate.subtract(remainder);
}
return df.format(reActuarial);
}
}
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.appservice.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.openhis.common.enums.Whether;
import com.openhis.web.chargemanage.appservice.IOutpatientPricingAppService;
import com.openhis.web.chargemanage.mapper.OutpatientPricingAppMapper;
import com.openhis.web.doctorstation.appservice.IDoctorStationAdviceAppService;
import com.openhis.web.doctorstation.appservice.IDoctorStationMainAppService;
import com.openhis.web.doctorstation.dto.AdviceBaseDto;
import com.openhis.web.doctorstation.dto.PatientInfoDto;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 门诊划价 impl
*
* @author yangmo
* @date 2025-04-14
*/
@Service
public class OutpatientPricingAppServiceImpl implements IOutpatientPricingAppService {
@Resource
OutpatientPricingAppMapper outpatientPricingAppMapper;
@Resource
IDoctorStationMainAppService iDoctorStationMainAppService;
@Resource
IDoctorStationAdviceAppService iDoctorStationAdviceAppService;
/**
* 查询就诊患者信息
*
* @param patientInfoDto 查询条件 (前端传 statusEnum 区分就诊状态tab)
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 就诊患者信息
*/
@Override
public IPage<PatientInfoDto> getPatientInfo(PatientInfoDto patientInfoDto, String searchKey, Integer pageNo,
Integer pageSize, HttpServletRequest request) {
return iDoctorStationMainAppService.getPatientInfo(patientInfoDto, searchKey, pageNo, pageSize, request,
Whether.YES.getValue());
}
/**
* 查询医嘱信息
*
* @param adviceBaseDto 查询条件
* @param searchKey 模糊查询关键字
* @param locationId 药房id
* @param organizationId 患者挂号对应的科室id
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 医嘱信息
*/
@Override
public IPage<AdviceBaseDto> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto, String searchKey, Long locationId,
Long organizationId, Integer pageNo, Integer pageSize) {
// 根据前端传入的adviceType动态构建查询类型列表
// 如果adviceType不为空只查询该类型如果为空查询所有类型1:药品, 2:耗材, 3:诊疗)
List<Integer> adviceTypes;
if (adviceBaseDto != null && adviceBaseDto.getAdviceType() != null) {
adviceTypes = List.of(adviceBaseDto.getAdviceType());
} else {
adviceTypes = List.of(1, 2, 3);
}
String categoryCode = adviceBaseDto != null ? adviceBaseDto.getCategoryCode() : null;
// 门诊划价:仅返回划价标记为“是”的项目
return iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, searchKey, locationId, null,
organizationId, pageNo, pageSize, Whether.YES.getValue(), adviceTypes, null, categoryCode);
}
}

View File

@@ -0,0 +1,599 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.appservice.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R;
import com.core.common.exception.ServiceException;
import com.core.common.utils.AgeCalculatorUtil;
import com.core.common.utils.AssignSeqUtil;
import com.core.common.utils.MessageUtils;
import com.core.common.utils.SecurityUtils;
import com.core.common.utils.bean.BeanUtils;
import com.openhis.administration.domain.ChargeItem;
import com.openhis.administration.service.IChargeItemService;
import com.openhis.common.constant.CommonConstants;
import com.openhis.common.constant.PromptMsgConstant;
import com.openhis.common.enums.*;
import com.openhis.common.utils.EnumUtils;
import com.openhis.common.utils.HisQueryUtils;
import com.openhis.financial.service.IPaymentReconciliationService;
import com.openhis.medication.domain.MedicationDispense;
import com.openhis.medication.domain.MedicationRequest;
import com.openhis.medication.service.IMedicationDispenseService;
import com.openhis.medication.service.IMedicationRequestService;
import com.openhis.web.chargemanage.appservice.IOutpatientRefundAppService;
import com.openhis.web.chargemanage.dto.*;
import com.openhis.web.chargemanage.mapper.OutpatientRefundAppMapper;
import com.openhis.workflow.domain.DeviceDispense;
import com.openhis.workflow.domain.DeviceRequest;
import com.openhis.workflow.domain.ServiceRequest;
import com.openhis.workflow.service.IDeviceDispenseService;
import com.openhis.workflow.service.IDeviceRequestService;
import com.openhis.workflow.service.IServiceRequestService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* 门诊退费 impl
*
* @author zwh
* @date 2025-03-15
*/
@Service
public class OutpatientRefundAppServiceImpl implements IOutpatientRefundAppService {
@Resource
private OutpatientRefundAppMapper outpatientRefundAppMapper;
@Resource
private IPaymentReconciliationService paymentReconciliationService;
@Resource
private IChargeItemService chargeItemService;
@Resource
private IMedicationDispenseService medicationDispenseService;
@Resource
private IDeviceDispenseService deviceDispenseService;
@Resource
private IServiceRequestService serviceRequestService;
@Resource
private IMedicationRequestService medicationRequestService;
@Resource
private IDeviceRequestService deviceRequestService;
@Resource
private AssignSeqUtil assignSeqUtil;
/**
* 门诊退费页面初始化
*
* @return 初始化信息
*/
@Override
public R<?> outpatientRefundInit() {
OutpatientInitDto initDto = new OutpatientInitDto();
List<OutpatientInitDto.chargeItemStatusOption> chargeItemStatusOptions = new ArrayList<>();
// 门诊退费页面去掉已收费状态筛选
// chargeItemStatusOptions.add(new OutpatientInitDto.chargeItemStatusOption(ChargeItemStatus.BILLED.getValue(),
// ChargeItemStatus.BILLED.getInfo()));
chargeItemStatusOptions.add(new OutpatientInitDto.chargeItemStatusOption(ChargeItemStatus.REFUNDING.getValue(),
ChargeItemStatus.REFUNDING.getInfo()));
chargeItemStatusOptions.add(new OutpatientInitDto.chargeItemStatusOption(ChargeItemStatus.REFUNDED.getValue(),
ChargeItemStatus.REFUNDED.getInfo()));
chargeItemStatusOptions.add(new OutpatientInitDto.chargeItemStatusOption(
ChargeItemStatus.PART_REFUND.getValue(), ChargeItemStatus.PART_REFUND.getInfo()));
initDto.setChargeItemStatusOptions(chargeItemStatusOptions);
return R.ok(initDto);
}
/**
* 根据就诊id查询患者的账单
*
* @param encounterId 就诊id
* @return 患者账单列表
*/
@Override
public R<?> getEncounterPatientPayment(Long encounterId) {
// 患者账单信息列表
List<EncounterPatientPaymentDto> encounterPatientPaymentList =
outpatientRefundAppMapper.selectEncounterPatientPayment(encounterId, PaymentStatus.SUCCESS.getValue(),
PaymentStatus.REFUND_PART.getValue(), PaymentStatus.REFUND_ALL.getValue());
// 获取付款id集合
List<Long> paymentIdList = encounterPatientPaymentList.stream().map(EncounterPatientPaymentDto::getPaymentId)
.collect(Collectors.toList());
if (paymentIdList.isEmpty()) {
return R.ok(null);
}
// 根据付款id获取对应收费项目的id列表(费用项id)
List<Long> chargeItemIdList = paymentReconciliationService.getChargeItemIdListByPayment(paymentIdList);
// 根据收费项目id列表查询费用项
List<RefundItemDto> refundItemList = outpatientRefundAppMapper.selectRefundItem(chargeItemIdList,
CommonConstants.TableName.MED_MEDICATION_REQUEST, CommonConstants.TableName.WOR_SERVICE_REQUEST,
CommonConstants.TableName.WOR_DEVICE_REQUEST, CommonConstants.Common.THREE);
refundItemList.forEach(e -> {
// 退费状态
e.setRefundStatus_enumText(EnumUtils.getInfoByValue(ChargeItemStatus.class, e.getRefundStatus()));
});
refundItemList.sort(Comparator.comparing(RefundItemDto::getPaymentId));
return R.ok(refundItemList);
}
/**
* 根据账单退费
*
* @param refundItemList 退费项目id列表
* @return 操作结果
*/
@Override
public R<?> refundPayment(List<RefundItemParam> refundItemList) {
// 未退费用项,生成新的请求发放费用项
List<RefundItemParam> creatList = new ArrayList<>();
for (RefundItemParam param : refundItemList) {
if (!param.getRefundFlg()) {
// 未退费费用项list
creatList.add(param);
}
}
// todo 半退逻辑需修改
if (!creatList.isEmpty()) {
// 未退费费用项id集合
List<Long> creatChargeItemIdList =
creatList.stream().map(RefundItemParam::getChargeItemId).collect(Collectors.toList());
// 根据费用项id查询费用项请求发放信息
List<RefundItemDto> creatChargeItemList = outpatientRefundAppMapper.selectRefundItem(creatChargeItemIdList,
CommonConstants.TableName.MED_MEDICATION_REQUEST, CommonConstants.TableName.WOR_SERVICE_REQUEST,
CommonConstants.TableName.WOR_DEVICE_REQUEST, CommonConstants.Common.THREE);
for (RefundItemDto createDto : creatChargeItemList) {
// 未退费用项,生成新的请求,发放,费用项
if (CommonConstants.TableName.MED_MEDICATION_REQUEST.equals(createDto.getServiceTable())) {
// 药品请求查询
MedicationRequest medicationRequest = medicationRequestService.getById(createDto.getRequestId());
// 生成新的药品请求
medicationRequest.setId(null); // 药品请求id
medicationRequest
.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.MEDICATION_RES_NO.getPrefix(), 4)); // 药品请求编码
medicationRequest.setPrescriptionNo(String.valueOf("C" + createDto.getPrescriptionNo())); // 处方号
medicationRequestService.save(medicationRequest);
// 药品发放查询
MedicationDispense medicationDispense =
medicationDispenseService.getById(createDto.getDispenseId());
// 生成新的药品发放
medicationDispense.setId(null); // 药品发放id
medicationDispense
.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.MEDICATION_DIS_NO.getPrefix(), 4)); // 药品发放编码
medicationDispense.setMedReqId(medicationRequest.getId()); // 药品请求id
medicationDispenseService.save(medicationDispense);
// 费用项查询
ChargeItem chargeItem = chargeItemService.getById(createDto.getChargeItemId());
// 生成新的费用项
chargeItem.setRefundId(chargeItem.getId());// 退费id
chargeItem.setId(null); // 费用项id
chargeItem.setBusNo(AssignSeqEnum.CHARGE_ITEM_NO.getPrefix().concat(medicationRequest.getBusNo())); // 编码
chargeItem.setPrescriptionNo(String.valueOf("C" + createDto.getPrescriptionNo())); // 处方号
chargeItem.setServiceId(medicationRequest.getId()); // 医疗服务ID
chargeItem.setStatusEnum(ChargeItemStatus.PLANNED.getValue());// 收费单状态:待收费
chargeItemService.save(chargeItem);
} else if (CommonConstants.TableName.WOR_SERVICE_REQUEST.equals(createDto.getServiceTable())) {
// 服务请求查询
ServiceRequest serviceRequest = serviceRequestService.getById(createDto.getRequestId());
// 生成新的服务请求
serviceRequest.setId(null); // 服务请求id
serviceRequest.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.SERVICE_RES_NO.getPrefix(), 4)); // 服务请求编码
serviceRequestService.save(serviceRequest);
// 费用项查询
ChargeItem chargeItem = chargeItemService.getById(createDto.getChargeItemId());
// 生成新的费用项
chargeItem.setRefundId(chargeItem.getId());// 退费id
chargeItem.setId(null); // 费用项id
chargeItem.setBusNo(AssignSeqEnum.CHARGE_ITEM_NO.getPrefix().concat(serviceRequest.getBusNo())); // 编码
chargeItem.setServiceId(serviceRequest.getId()); // 医疗服务ID
chargeItem.setStatusEnum(ChargeItemStatus.PLANNED.getValue());// 收费单状态:待收费
chargeItemService.save(chargeItem);
} else if (CommonConstants.TableName.WOR_DEVICE_REQUEST.equals(createDto.getServiceTable())) {
// 耗材请求查询
DeviceRequest deviceRequest = deviceRequestService.getById(createDto.getRequestId());
// 生成新的耗材请求
deviceRequest.setId(null); // 耗材请求id
deviceRequest.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.DEVICE_RES_NO.getPrefix(), 4)); // 耗材请求编码
deviceRequestService.save(deviceRequest);
// 耗材发放查询
DeviceDispense deviceDispense = deviceDispenseService.getById(createDto.getDispenseId());
// 生成新的耗材发放
deviceDispense.setId(null); // 耗材id
deviceDispense.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.DEVICE_DIS_NO.getPrefix(), 4)); // 器材发放id
deviceDispense.setDeviceReqId(deviceRequest.getId()); // 器材请求id
deviceDispenseService.save(deviceDispense);
// 费用项查询
ChargeItem chargeItem = chargeItemService.getById(createDto.getChargeItemId());
// 生成新的费用项
chargeItem.setRefundId(chargeItem.getId());// 退费id
chargeItem.setId(null); // 费用项id
chargeItem.setBusNo(AssignSeqEnum.CHARGE_ITEM_NO.getPrefix().concat(deviceRequest.getBusNo())); // 编码
chargeItem.setServiceId(deviceRequest.getId()); // 医疗服务ID
chargeItem.setStatusEnum(ChargeItemStatus.PLANNED.getValue());// 收费单状态:待收费
chargeItemService.save(chargeItem);
}
}
}
// 全部退费
// 退费费用项id集合
List<Long> chargeItemIdList =
refundItemList.stream().map(RefundItemParam::getChargeItemId).collect(Collectors.toList());
// 服务请求id集合
List<Long> medReqIdList = new ArrayList<>();
List<Long> devReqIdList = new ArrayList<>();
List<Long> serReqIdList = new ArrayList<>();
// 查询退费项目信息
List<ChargeItem> chargeItemList = chargeItemService.listByIds(chargeItemIdList);
if (chargeItemList != null && !chargeItemList.isEmpty()) {
chargeItemList.forEach(item -> {
switch (item.getServiceTable()) {
case CommonConstants.TableName.MED_MEDICATION_REQUEST -> medReqIdList.add(item.getServiceId());
case CommonConstants.TableName.WOR_DEVICE_REQUEST -> devReqIdList.add(item.getServiceId());
case CommonConstants.TableName.WOR_SERVICE_REQUEST -> serReqIdList.add(item.getServiceId());
}
});
}
// 处理退药申请
if (!medReqIdList.isEmpty()) {
// 药品请求查询
List<MedicationRequest> medicationRequests = medicationRequestService.listByIds(medReqIdList);
// 药品发放查询
List<MedicationDispense> medicationDispenses =
medicationDispenseService.selectByRequestIdList(medReqIdList);
// 根据请求id做map
Map<Long, List<MedicationDispense>> medicationDispenseMap =
medicationDispenses.stream().collect(Collectors.groupingBy(MedicationDispense::getMedReqId));
for (MedicationRequest medicationRequest : medicationRequests) {
// 根据请求匹配发放
List<MedicationDispense> medicationDispenseList = medicationDispenseMap.get(medicationRequest.getId());
// 判断是否是退药流程
boolean isRefundFlow = false;
if (medicationDispenseList != null) {
for (MedicationDispense dispense : medicationDispenseList) {
// 先判断是否包含“已完成/部分完成”的药品,这决定了是走“退药流程”还是“取消流程”
if (DispenseStatus.COMPLETED.getValue().equals(dispense.getStatusEnum())
|| DispenseStatus.PART_COMPLETED.getValue().equals(dispense.getStatusEnum())) {
isRefundFlow = true;
break; // 只要有一条是完成状态,整个单子即视为走退药流程
}
}
}
if (isRefundFlow) {
// ==================== 走退药流程 (生成新单据) ====================
// 校验是否重复申请
if (medicationRequest.getRefundMedicineId() != null) {
throw new ServiceException("已申请退药,请勿重复申请");
}
MedicationRequest newRefundRequest = new MedicationRequest();
BeanUtils.copyProperties(medicationRequest, newRefundRequest);
newRefundRequest.setId(null); // 清空ID以新增
newRefundRequest
.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.MEDICATION_RES_NO.getPrefix(), 4));
newRefundRequest.setQuantity(medicationRequest.getQuantity().multiply(new BigDecimal("-1"))); // 数量取反
newRefundRequest.setStatusEnum(RequestStatus.CANCELLED.getValue());
newRefundRequest.setRefundMedicineId(medicationRequest.getId()); // 关联原ID
newRefundRequest.setPrescriptionNo("T" + medicationRequest.getPrescriptionNo());
medicationRequestService.save(newRefundRequest);
Long newRequestId = newRefundRequest.getId();
// 再生成对应的负向发药记录,并关联退药请求
List<MedicationDispense> newDispensesToSave = new ArrayList<>();
for (MedicationDispense originDispense : medicationDispenseList) {
// 只处理已完成或部分完成的记录
if (DispenseStatus.COMPLETED.getValue().equals(originDispense.getStatusEnum())
|| DispenseStatus.PART_COMPLETED.getValue().equals(originDispense.getStatusEnum())) {
MedicationDispense refundDispense = new MedicationDispense();
BeanUtils.copyProperties(originDispense, refundDispense);
refundDispense.setId(null); // ID置空
refundDispense.setDispenseQuantity(BigDecimal.ZERO); // 已退数量
refundDispense.setMedReqId(newRequestId); // 关联退药请求id
refundDispense
.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.MEDICATION_DIS_NO.getPrefix(), 4));
// 退药状态
refundDispense.setStatusEnum(DispenseStatus.PENDING_REFUND.getValue());
newDispensesToSave.add(refundDispense);
}
}
// 批量保存新的发药记录
if (!newDispensesToSave.isEmpty()) {
medicationDispenseService.saveBatch(newDispensesToSave);
}
} else {
// ==================== 走直接取消流程 (修改原单据状态) ====================
if (medicationDispenseList != null) {
List<MedicationDispense> dispensesToUpdate = new ArrayList<>();
for (MedicationDispense medicationDispense : medicationDispenseList) {
// 检查是否已经是退药状态
if (DispenseStatus.STOPPED.getValue().equals(medicationDispense.getStatusEnum())
&& NotPerformedReason.REFUND.getValue().equals(medicationDispense.getStatusEnum())) {
throw new ServiceException("已申请退药,请勿重复申请");
}
// 修改状态
medicationDispense.setStatusEnum(DispenseStatus.STOPPED.getValue())
.setNotPerformedReasonEnum(NotPerformedReason.REFUND.getValue());
dispensesToUpdate.add(medicationDispense);
}
// 批量更新
if (!dispensesToUpdate.isEmpty()) {
medicationDispenseService.updateBatchById(dispensesToUpdate);
}
}
}
}
}
// 处理退耗材申请
if (!devReqIdList.isEmpty()) {
// 耗材请求查询
List<DeviceRequest> deviceRequests = deviceRequestService.listByIds(devReqIdList);
// 耗材发放查询
List<DeviceDispense> deviceDispenses = deviceDispenseService.selectByRequestIdList(devReqIdList);
// 根据请求id做map
Map<Long, List<DeviceDispense>> deviceDispenseMap =
deviceDispenses.stream().collect(Collectors.groupingBy(DeviceDispense::getDeviceReqId));
for (DeviceRequest deviceRequest : deviceRequests) {
// 根据请求匹配发放
List<DeviceDispense> deviceDispenseList = deviceDispenseMap.get(deviceRequest.getId());
// 判断是否是退耗材流程
boolean isRefundFlow = false;
if (deviceDispenseList != null) {
for (DeviceDispense dispense : deviceDispenseList) {
// 先判断是否包含“已完成/部分完成”的耗材,这决定了是走“退耗材流程”还是“取消流程”
if (DispenseStatus.COMPLETED.getValue().equals(dispense.getStatusEnum())
|| DispenseStatus.PART_COMPLETED.getValue().equals(dispense.getStatusEnum())) {
isRefundFlow = true;
break; // 只要有一条是完成状态,整个单子即视为走退耗材流程
}
}
}
if (isRefundFlow) {
// ==================== 走退耗材流程 (生成新单据) ====================
// 校验是否重复申请
if (deviceRequest.getRefundDeviceId() != null) {
throw new ServiceException("已申请退耗材,请勿重复申请");
}
DeviceRequest newRefundRequest = new DeviceRequest();
BeanUtils.copyProperties(deviceRequest, newRefundRequest);
newRefundRequest.setId(null); // 清空ID以新增
newRefundRequest.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.DEVICE_RES_NO.getPrefix(), 4));
newRefundRequest.setQuantity(deviceRequest.getQuantity().multiply(new BigDecimal("-1"))); // 数量取反
newRefundRequest.setStatusEnum(RequestStatus.CANCELLED.getValue());
newRefundRequest.setRefundDeviceId(deviceRequest.getId()); // 关联原ID
newRefundRequest.setPrescriptionNo("T" + deviceRequest.getPrescriptionNo());
newRefundRequest.setTenantId(deviceRequest.getTenantId()); // 显式设置租户ID
deviceRequestService.save(newRefundRequest);
Long newRequestId = newRefundRequest.getId();
// 再生成对应的负向发耗材记录,并关联退耗材请求
List<DeviceDispense> newDispensesToSave = new ArrayList<>();
for (DeviceDispense originDispense : deviceDispenseList) {
// 只处理已完成或部分完成的记录
if (DispenseStatus.COMPLETED.getValue().equals(originDispense.getStatusEnum())
|| DispenseStatus.PART_COMPLETED.getValue().equals(originDispense.getStatusEnum())) {
DeviceDispense refundDispense = new DeviceDispense();
BeanUtils.copyProperties(originDispense, refundDispense);
refundDispense.setId(null); // ID置空
refundDispense.setDispenseQuantity(BigDecimal.ZERO); // 已退数量
refundDispense.setDeviceReqId(newRequestId); // 关联退耗材请求id
refundDispense
.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.DEVICE_DIS_NO.getPrefix(), 4));
// 退耗材状态
refundDispense.setStatusEnum(DispenseStatus.PENDING_REFUND.getValue());
newDispensesToSave.add(refundDispense);
}
}
// 批量保存新的发耗材记录
if (!newDispensesToSave.isEmpty()) {
deviceDispenseService.saveBatch(newDispensesToSave);
}
} else {
// ==================== 走直接取消流程 (修改原单据状态) ====================
if (deviceDispenseList != null) {
List<DeviceDispense> dispensesToUpdate = new ArrayList<>();
for (DeviceDispense deviceDispense : deviceDispenseList) {
// 检查是否已经是退耗材状态
if (DispenseStatus.STOPPED.getValue().equals(deviceDispense.getStatusEnum())
&& NotPerformedReason.REFUND.getValue().equals(deviceDispense.getStatusEnum())) {
throw new ServiceException("已申请退耗材,请勿重复申请");
}
// 修改状态
deviceDispense.setStatusEnum(DispenseStatus.STOPPED.getValue())
.setNotPerformedReasonEnum(NotPerformedReason.REFUND.getValue());
dispensesToUpdate.add(deviceDispense);
}
// 批量更新
if (!dispensesToUpdate.isEmpty()) {
deviceDispenseService.updateBatchById(dispensesToUpdate);
}
}
}
}
}
// 处理退诊疗项目申请
// 诊疗申请待更新id列表
List<Long> serReqUpdateList = new ArrayList<>();
if (!serReqIdList.isEmpty()) {
// 查询诊疗申请
List<ServiceRequest> serviceRequestList = serviceRequestService.listByIds(serReqIdList);
for (ServiceRequest serviceRequest : serviceRequestList) {
// 诊疗项目需医技科室同意退费
if (RequestStatus.COMPLETED.getValue().equals(serviceRequest.getStatusEnum())) {
if (serviceRequest.getRefundServiceId() != null) {
throw new ServiceException("已申请退费,请勿重复申请");
}
// 生成服务请求(取消服务)
serviceRequest.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.SERVICE_RES_NO.getPrefix(), 4)); // 服务请求编码
serviceRequest.setQuantity(serviceRequest.getQuantity().multiply(new BigDecimal("-1"))); // 请求数量
serviceRequest.setStatusEnum(RequestStatus.CANCELLED.getValue()); // 请求状态
serviceRequest.setRefundServiceId(serviceRequest.getId());// 退id
serviceRequest.setId(null); // 服务请求id
serviceRequestService.save(serviceRequest);
} else {
if (RequestStatus.STOPPED.getValue().equals(serviceRequest.getStatusEnum())) {
throw new ServiceException("已申请退费,请勿重复申请");
}
serReqUpdateList.add(serviceRequest.getId());
}
}
}
// 更新收费状态:退费中
chargeItemService.updateRefundChargeStatus(chargeItemIdList);
// 更新未执行诊疗状态:停止
if (!serReqUpdateList.isEmpty()) {
serviceRequestService.updateStopRequestStatus(serReqUpdateList);
}
// 返回退费成功信息
return R.ok(MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"门诊退费"}));
}
/**
* 查询结算过的就诊患者分页列表
*
* @param encounterPatientPageParam 查询条件
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @param request 请求
* @return 就诊患者分页列表
*/
@Override
public R<?> getBilledEncounterPatientPage(EncounterPatientPageParam encounterPatientPageParam, String searchKey,
Integer pageNo, Integer pageSize, HttpServletRequest request) {
// 构建查询条件
QueryWrapper<EncounterPatientPageParam> queryWrapper = HisQueryUtils.buildQueryWrapper(
encounterPatientPageParam, searchKey,
new HashSet<>(Arrays.asList(CommonConstants.FieldName.PatientWbStr, CommonConstants.FieldName.PatientPyStr,
CommonConstants.FieldName.PatientName, CommonConstants.FieldName.PatientBusNo,
CommonConstants.FieldName.EncounterBusNo, CommonConstants.FieldName.IdCard)),
request);
// 就诊患者分页列表
Page<EncounterPatientPageDto> encounterPatientPage = outpatientRefundAppMapper.selectBilledEncounterPatientPage(
new Page<>(pageNo, pageSize), queryWrapper, ChargeItemStatus.BILLED.getValue(),
ChargeItemStatus.REFUNDING.getValue(), ChargeItemStatus.REFUNDED.getValue(),
ChargeItemStatus.PART_REFUND.getValue(), AccountType.MEDICAL_ELECTRONIC_CERTIFICATE.getCode(),
EncounterClass.AMB.getValue(), ChargeItemContext.REGISTER.getValue());
encounterPatientPage.getRecords().forEach(e -> {
// 性别枚举
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
// 收费状态枚举
e.setStatusEnum_enumText(EnumUtils.getInfoByValue(ChargeItemStatus.class, e.getStatusEnum()));
// 计算年龄
if (e.getBirthDate() != null) {
e.setAge(AgeCalculatorUtil.getAge(e.getBirthDate()));
}
});
return R.ok(encounterPatientPage);
}
/**
* 根据就诊id查询患者的退费账单
*
* @param encounterId 就诊id
* @param billDateSTime 收费时间开始
* @param billDateETime 收费时间结束
* @return 退费账单列表
*/
@Override
public R<?> getEncounterPatientRefund(Long encounterId, String billDateSTime, String billDateETime) {
List<EncounterPatientRefundDto> refundDtoList =
outpatientRefundAppMapper.selectEncounterPatientRefund(encounterId, ChargeItemStatus.REFUNDING.getValue(),
ChargeItemStatus.REFUNDED.getValue(), ChargeItemStatus.PART_REFUND.getValue(),
CommonConstants.TableName.WOR_SERVICE_REQUEST, CommonConstants.TableName.WOR_DEVICE_REQUEST,
CommonConstants.TableName.MED_MEDICATION_REQUEST, billDateSTime, billDateETime);
refundDtoList.forEach(e -> {
// 收费状态枚举
e.setChargeStatus_enumText(EnumUtils.getInfoByValue(ChargeItemStatus.class, e.getChargeStatus()));
// 支付状态枚举
e.setPaymentStatus_enumText(EnumUtils.getInfoByValue(PaymentStatus.class, e.getPaymentStatus()));
// 发药状态
e.setDispenseStatus_enumText(EnumUtils.getInfoByValue(DispenseStatus.class, e.getDispenseStatus()));
// 诊疗执行枚举
e.setServiceStatus_enumText(EnumUtils.getInfoByValue(RequestStatus.class, e.getServiceStatus()));
});
return R.ok(refundDtoList);
}
/**
* 根据就诊id查询患者因退费重新生成的账单
*
* @param encounterId 就诊id
* @return 重新生成的账单列表
*/
@Override
public R<?> getRegenerateCharge(Long encounterId) {
return R.ok(chargeItemService.getRegenerateCharge(encounterId));
}
/**
* 校验是否可以退费(耗材/药品是否已退,诊疗是否取消执行)
*
* @param chargeItemIdList 收费项目id列表
* @return 是否可退
*/
@Override
public R<?> verifyRefundable(List<Long> chargeItemIdList) {
// 查询收费项目信息
List<ChargeItem> chargeItemList = chargeItemService.listByIds(chargeItemIdList);
// 分别获取各个请求id列表
List<Long> medReqIdList = new ArrayList<>();
List<Long> devReqIdList = new ArrayList<>();
chargeItemList.forEach(item -> {
switch (item.getServiceTable()) {
case CommonConstants.TableName.MED_MEDICATION_REQUEST -> medReqIdList.add(item.getServiceId());
case CommonConstants.TableName.WOR_DEVICE_REQUEST -> devReqIdList.add(item.getServiceId());
}
});
if (!medReqIdList.isEmpty()) {
List<MedicationRequest> medicationRequestList = medicationRequestService.list(
new LambdaQueryWrapper<MedicationRequest>().in(MedicationRequest::getRefundMedicineId, medReqIdList));
if (!medicationRequestList.isEmpty()) {
if (medicationRequestList.stream().map(MedicationRequest::getStatusEnum)
.anyMatch(x -> x.equals(RequestStatus.CANCELLED.getValue()))) {
throw new ServiceException("请先退药后再退费");
}
}
}
String fixmedinsCode =
SecurityUtils.getLoginUser().getOptionJson().getString(CommonConstants.Option.FIXMEDINS_CODE);
if (!HospitalCodeEnum.CCU.getCode().equals(fixmedinsCode)) {
if (!devReqIdList.isEmpty()) {
List<DeviceRequest> deviceRequestList = deviceRequestService
.list(new LambdaQueryWrapper<DeviceRequest>().in(DeviceRequest::getRefundDeviceId, devReqIdList));
if (!deviceRequestList.isEmpty()) {
if (deviceRequestList.stream().map(DeviceRequest::getStatusEnum)
.anyMatch(x -> x.equals(RequestStatus.CANCELLED.getValue()))) {
throw new ServiceException("请先退耗材后再退费");
}
}
}
}
return R.ok();
}
}

View File

@@ -0,0 +1,894 @@
package com.openhis.web.chargemanage.appservice.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.core.common.core.domain.R;
import com.core.common.utils.AgeCalculatorUtil;
import com.core.common.utils.MessageUtils;
import com.core.common.utils.SecurityUtils;
import com.core.common.utils.StringUtils;
import com.core.common.utils.bean.BeanUtils;
import com.core.common.core.domain.entity.SysRole;
import com.core.common.core.domain.model.LoginUser;
import com.openhis.administration.domain.*;
import com.openhis.administration.mapper.PatientMapper;
import com.openhis.administration.service.*;
import com.openhis.common.constant.CommonConstants;
import com.openhis.common.constant.PromptMsgConstant;
import com.openhis.common.enums.SlotStatus;
import com.openhis.common.enums.*;
import com.openhis.common.enums.ybenums.YbPayment;
import com.openhis.common.utils.EnumUtils;
import com.openhis.common.utils.HisPageUtils;
import com.openhis.common.utils.HisQueryUtils;
import com.openhis.appointmentmanage.domain.SchedulePool;
import com.openhis.appointmentmanage.domain.ScheduleSlot;
import com.openhis.appointmentmanage.mapper.SchedulePoolMapper;
import com.openhis.appointmentmanage.mapper.ScheduleSlotMapper;
import com.openhis.clinical.domain.Order;
import com.openhis.clinical.service.IOrderService;
import com.openhis.financial.domain.PaymentReconciliation;
import com.openhis.financial.domain.RefundLog;
import com.openhis.financial.service.IRefundLogService;
import com.openhis.web.basicservice.dto.HealthcareServiceDto;
import com.openhis.web.basicservice.mapper.HealthcareServiceBizMapper;
import com.openhis.web.chargemanage.appservice.IOutpatientRegistrationAppService;
import com.openhis.web.chargemanage.dto.CurrentDayEncounterDto;
import com.openhis.web.chargemanage.dto.OrgMetadata;
import com.openhis.web.chargemanage.dto.PatientMetadata;
import com.openhis.web.chargemanage.dto.PractitionerMetadata;
import com.openhis.web.chargemanage.dto.ReprintRegistrationDto;
import com.openhis.web.chargemanage.mapper.OutpatientRegistrationAppMapper;
import com.openhis.triageandqueuemanage.domain.DivLog;
import com.openhis.triageandqueuemanage.domain.TriageCandidateExclusion;
import com.openhis.triageandqueuemanage.service.DivLogService;
import com.openhis.triageandqueuemanage.service.TriageCandidateExclusionService;
import com.openhis.web.paymentmanage.appservice.IPaymentRecService;
import com.openhis.web.paymentmanage.dto.CancelPaymentDto;
import com.openhis.web.paymentmanage.dto.CancelRegPaymentDto;
import com.openhis.yb.model.CancelRegPaymentModel;
import com.openhis.yb.service.YbManager;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* 门诊挂号 应用实现类
*/
@Slf4j
@Service
public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistrationAppService {
@Resource
PatientMapper patientMapper;
@Resource
OutpatientRegistrationAppMapper outpatientRegistrationAppMapper;
@Resource
HealthcareServiceBizMapper healthcareServiceBizMapper;
@Resource
IEncounterService iEncounterService;
@Resource
IAccountService iAccountService;
@Resource
IChargeItemService iChargeItemService;
@Resource
IOrganizationService iOrganizationService;
@Resource
YbManager ybManager;
@Resource
IPaymentRecService iPaymentRecService;
@Resource
IPatientIdentifierService patientIdentifierService;
@Resource
TriageCandidateExclusionService triageCandidateExclusionService;
@Resource
IRefundLogService iRefundLogService;
@Resource
IOrderService orderService;
@Resource
com.openhis.triageandqueuemanage.service.TriageQueueItemService triageQueueItemService;
@Resource
DivLogService divLogService;
@Resource
ScheduleSlotMapper scheduleSlotMapper;
@Resource
SchedulePoolMapper schedulePoolMapper;
@Resource
com.openhis.document.service.IEmrService iEmrService;
/**
* 门诊挂号 - 查询患者信息
*
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 患者信息
*/
@Override
public Page<PatientMetadata> getPatientMetadataBySearchKey(String searchKey, Integer pageNo, Integer pageSize) {
// 构建查询条件添加phone字段支持手机号搜索
QueryWrapper<Patient> queryWrapper = HisQueryUtils.buildQueryWrapper(null, searchKey,
new HashSet<>(Arrays.asList("id_card", "name", "py_str", "wb_str", "phone")), null);
// 设置排序
queryWrapper.orderByDesc("update_time");
// 通过证件号匹配 patient
if (StringUtils.isNotEmpty(searchKey)) {
List<PatientIdentifier> patientIdentifiers = patientIdentifierService
.list(new LambdaQueryWrapper<PatientIdentifier>().eq(PatientIdentifier::getIdentifierNo, searchKey));
if (patientIdentifiers != null && !patientIdentifiers.isEmpty()) {
// 如果有多个匹配结果,将它们全部添加到查询条件中
if (patientIdentifiers.size() == 1) {
// 单个结果时直接添加条件
queryWrapper.or(q -> q.eq("id", patientIdentifiers.get(0).getPatientId()));
} else {
// 多个结果时使用in条件
List<Long> patientIds = patientIdentifiers.stream()
.map(PatientIdentifier::getPatientId)
.collect(Collectors.toList());
queryWrapper.or(q -> q.in("id", patientIds));
}
}
}
// 患者信息
Page<PatientMetadata> patientMetadataPage =
HisPageUtils.selectPage(patientMapper, queryWrapper, pageNo, pageSize, PatientMetadata.class);
// 现有就诊过的患者id集合
List<Long> patientIdList =
iEncounterService.list().stream().map(e -> e.getPatientId()).collect(Collectors.toList());
// 一次性获取所有患者标识
List<Long> patientIds = patientMetadataPage.getRecords().stream()
.map(PatientMetadata::getId)
.collect(Collectors.toList());
final Map<Long, List<PatientIdentifier>> patientIdentifierMap;
if (!patientIds.isEmpty()) {
patientIdentifierMap = patientIdentifierService.list(
new LambdaQueryWrapper<PatientIdentifier>().in(PatientIdentifier::getPatientId, patientIds)
).stream().collect(Collectors.groupingBy(PatientIdentifier::getPatientId));
} else {
patientIdentifierMap = new HashMap<>();
}
patientMetadataPage.getRecords().forEach(e -> {
// 性别枚举
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
// 计算年龄
e.setAge(e.getBirthDate() != null ? AgeCalculatorUtil.getAge(e.getBirthDate()) : "");
// 初复诊
e.setFirstEnum_enumText(patientIdList.contains(e.getId()) ? EncounterType.FOLLOW_UP.getInfo()
: EncounterType.INITIAL.getInfo());
// 患者标识 - 从Map中获取避免N+1查询
List<PatientIdentifier> patientIdentifiers = patientIdentifierMap.get(e.getId());
if (patientIdentifiers != null && !patientIdentifiers.isEmpty()) {
// 取第一个标识号,如果需要可以根据业务需求选择其他逻辑
e.setIdentifierNo(patientIdentifiers.get(0).getIdentifierNo());
}
});
return patientMetadataPage;
}
/**
* 查询门诊科室数据
*
* @return 门诊科室
*/
@Override
public List<OrgMetadata> getOrgMetadata() {
List<Organization> list =
iOrganizationService.getList(OrganizationType.DEPARTMENT.getValue(), String.valueOf(OrganizationClass.CLINIC.getValue()));
List<OrgMetadata> orgMetadataList = new ArrayList<>();
OrgMetadata orgMetadata;
for (Organization organization : list) {
orgMetadata = new OrgMetadata();
BeanUtils.copyProperties(organization, orgMetadata);
orgMetadataList.add(orgMetadata);
}
return orgMetadataList;
}
/**
* 根据科室id筛选医生
*
* @param orgId 科室ID
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 筛选医生
*/
@Override
public IPage<PractitionerMetadata> getPractitionerMetadataByLocationId(Long orgId, String searchKey, Integer pageNo,
Integer pageSize) {
// 构建查询条件
QueryWrapper<PractitionerMetadata> queryWrapper = HisQueryUtils.buildQueryWrapper(null, searchKey,
new HashSet<>(Arrays.asList("name", "py_str", "wb_str")), null);
IPage<PractitionerMetadata> practitionerMetadataPage =
outpatientRegistrationAppMapper.getPractitionerMetadataPage(new Page<>(pageNo, pageSize), orgId,
PractitionerRoles.DOCTOR.getCode(), queryWrapper);
practitionerMetadataPage.getRecords().forEach(e -> {
// 性别
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
});
return practitionerMetadataPage;
}
/**
* 根据机构id筛选服务项目
*
* @param organizationId 机构id
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 服务项目
*/
@Override
public IPage<HealthcareServiceDto> getHealthcareMetadataByOrganizationId(Long organizationId, String searchKey,
Integer pageNo, Integer pageSize) {
// 构建查询条件
HealthcareServiceDto healthcareServiceDto = new HealthcareServiceDto();
healthcareServiceDto.setOfferedOrgId(organizationId);
QueryWrapper<HealthcareServiceDto> queryWrapper = HisQueryUtils.buildQueryWrapper(healthcareServiceDto,
searchKey, new HashSet<>(Arrays.asList("name", "charge_name")), null);
return healthcareServiceBizMapper.getHealthcareServicePage(new Page<>(pageNo, pageSize),
CommonConstants.TableName.ADM_HEALTHCARE_SERVICE, CommonConstants.TableName.WOR_ACTIVITY_DEFINITION,
queryWrapper);
}
/**
* 退号
*
* @param cancelRegPaymentDto 就诊id
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public R<?> returnRegister(CancelRegPaymentDto cancelRegPaymentDto) {
Encounter byId = iEncounterService.getById(cancelRegPaymentDto.getEncounterId());
if (byId == null) {
return R.fail(null, "就诊记录不存在");
}
if (EncounterStatus.CANCELLED.getValue().equals(byId.getStatusEnum())) {
return R.fail(null, "该患者已经退号,请勿重复退号");
}
// 只有待诊状态才能退号
if (!EncounterStatus.PLANNED.getValue().equals(byId.getStatusEnum())) {
return R.fail(null, "该患者已开始就诊,不能退号!");
}
// 诊前退号检查:病历、费用明细、班段时间
R<?> checkResult = checkPreConsultationRefund(byId);
if (checkResult != null) {
return checkResult;
}
iEncounterService.returnRegister(cancelRegPaymentDto.getEncounterId());
// 查询账户信息
Account account = iAccountService
.getOne(new LambdaQueryWrapper<Account>().eq(Account::getEncounterId, cancelRegPaymentDto.getEncounterId())
.ne(Account::getTypeCode, AccountType.PERSONAL_CASH_ACCOUNT.getCode())
.eq(Account::getEncounterFlag, Whether.YES.getValue()));
CancelPaymentDto cancelPaymentDto = new CancelPaymentDto();
BeanUtils.copyProperties(cancelRegPaymentDto, cancelPaymentDto);
//LoginUser loginUser = SecurityUtils.getLoginUser();
//String string1 = SecurityUtils.getLoginUser().getOptionJson().getString(CommonConstants.Option.YB_SWITCH);
// 开通医保的处理
if ("1".equals(SecurityUtils.getLoginUser().getOptionJson().getString(CommonConstants.Option.YB_SWITCH))
&& account != null && !CommonConstants.BusinessName.DEFAULT_CONTRACT_NO.equals(account.getContractNo())) {
CancelRegPaymentModel model = new CancelRegPaymentModel();
BeanUtils.copyProperties(cancelRegPaymentDto, model);
model.setContractNo(account.getContractNo());
ybManager.cancelReg(model);
cancelPaymentDto.setSetlId(model.getSetlId());
// return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"医保退号"}));
}
R<?> result = iPaymentRecService.cancelRegPayment(cancelPaymentDto);
PaymentReconciliation paymentRecon = null;
if (result.getData() != null && PaymentReconciliation.class.isAssignableFrom(result.getData().getClass())) {
paymentRecon = (PaymentReconciliation)result.getData();
}
if (paymentRecon != null) {
String[] strings = paymentRecon.getChargeItemIds().split(",");
List<Long> chargeItemIds = new ArrayList<>();
for (String string : strings) {
chargeItemIds.add(Long.parseLong(string));
}
// 更新收费状态:已退费
if (!chargeItemIds.isEmpty()) {
iChargeItemService.updatePaymentStatus(chargeItemIds, ChargeItemStatus.REFUNDED.getValue());
}
}
// 退费成功后,同步回滚预约订单状态及号源;同时移除分诊队列
Long refundOrderMainId = null;
if (result != null && result.getCode() == 200) {
refundOrderMainId = syncAppointmentReturnStatus(byId, cancelRegPaymentDto.getReason());
removeTriageQueueItem(byId.getId());
}
// 退号日志独立事务写入,无论退费成功与否均记录
recordRefundLog(cancelRegPaymentDto, byId, result, paymentRecon, refundOrderMainId);
// 2025/05/05 该处保存费用项后,会通过统一收费处理进行收费
return R.ok(paymentRecon, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"退号"}));
}
/**
* 诊前退号检查
* 检查项:病历记录、费用明细、当日就诊、班段结束时间
*
* @param encounter 就诊记录
* @return null 表示通过检查,否则返回失败原因
*/
private R<?> checkPreConsultationRefund(Encounter encounter) {
Long encounterId = encounter.getId();
// 当日时间范围:今天 00:00:00 到 明天 00:00:00
LocalDate today = LocalDate.now();
LocalDateTime todayStart = today.atStartOfDay();
LocalDateTime tomorrowStart = today.plusDays(1).atStartOfDay();
Date todayStartDate = Date.from(todayStart.atZone(ZoneId.systemDefault()).toInstant());
Date tomorrowStartDate = Date.from(tomorrowStart.atZone(ZoneId.systemDefault()).toInstant());
// 1. 检查是否有当日病历记录(医生已写病历则不能退号)
// 只检查当天的病历,避免误判历史数据
// 条件:(recordTime在当天范围内) OR (recordTime为空 AND createTime在当天范围内)
long emrCount = iEmrService.count(new LambdaQueryWrapper<com.openhis.document.domain.Emr>()
.eq(com.openhis.document.domain.Emr::getEncounterId, encounterId)
.and(wrapper -> wrapper
.and(w -> w
.ge(com.openhis.document.domain.Emr::getRecordTime, todayStartDate)
.lt(com.openhis.document.domain.Emr::getRecordTime, tomorrowStartDate)
)
.or()
.and(w -> w
.isNull(com.openhis.document.domain.Emr::getRecordTime)
.ge(com.openhis.document.domain.Emr::getCreateTime, todayStartDate)
.lt(com.openhis.document.domain.Emr::getCreateTime, tomorrowStartDate)
)
));
if (emrCount > 0) {
return R.fail(null, "该患者已有病历记录,不能退号!");
}
// 2. 检查是否有当日费用明细(除挂号费外的其他费用)
// 只检查当天的费用明细,避免误判历史数据
// 条件:(occurrenceTime在当天范围内) OR (occurrenceTime为空 AND createTime在当天范围内)
long chargeItemCount = iChargeItemService.count(new LambdaQueryWrapper<ChargeItem>()
.eq(ChargeItem::getEncounterId, encounterId)
.ne(ChargeItem::getContextEnum, ChargeItemContext.REGISTER.getValue())
.ne(ChargeItem::getStatusEnum, ChargeItemStatus.REFUNDED.getValue())
.and(wrapper -> wrapper
.and(w -> w
.ge(ChargeItem::getOccurrenceTime, todayStartDate)
.lt(ChargeItem::getOccurrenceTime, tomorrowStartDate)
)
.or()
.and(w -> w
.isNull(ChargeItem::getOccurrenceTime)
.ge(ChargeItem::getCreateTime, todayStartDate)
.lt(ChargeItem::getCreateTime, tomorrowStartDate)
)
));
if (chargeItemCount > 0) {
return R.fail(null, "该患者已产生诊疗费用,不能退号!");
}
// 3. 检查是否当日就诊(防止隔日财务封账)
if (encounter.getCreateTime() != null) {
LocalDate encounterDate = encounter.getCreateTime().toInstant()
.atZone(ZoneId.systemDefault()).toLocalDate();
if (encounterDate.isBefore(today)) {
return R.fail(null, "非当日就诊记录,不能退号!");
}
}
// 4. 检查班段是否已结束(通过预约订单获取班段信息)
R<?> shiftCheckResult = checkShiftEnded(encounter);
if (shiftCheckResult != null) {
return shiftCheckResult;
}
return null; // 检查通过
}
/**
* 检查班段是否已结束
* 截止时间 = 班段结束时间
*
* @param encounter 就诊记录
* @return null 表示通过检查,否则返回失败原因
*/
private R<?> checkShiftEnded(Encounter encounter) {
try {
// 通过患者、科室、日期查找关联的预约订单
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<Order>()
.eq(Order::getPatientId, encounter.getPatientId())
.orderByDesc(Order::getUpdateTime)
.orderByDesc(Order::getCreateTime)
.last("LIMIT 1");
if (encounter.getOrganizationId() != null) {
queryWrapper.eq(Order::getDepartmentId, encounter.getOrganizationId());
}
if (encounter.getTenantId() != null) {
queryWrapper.eq(Order::getTenantId, encounter.getTenantId());
}
if (encounter.getCreateTime() != null) {
LocalDate encounterDate = encounter.getCreateTime().toInstant()
.atZone(ZoneId.systemDefault()).toLocalDate();
Date startOfDay = Date.from(encounterDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
Date nextDayStart = Date.from(encounterDate.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant());
queryWrapper.ge(Order::getAppointmentDate, startOfDay)
.lt(Order::getAppointmentDate, nextDayStart);
}
Order appointmentOrder = orderService.getOne(queryWrapper, false);
if (appointmentOrder == null || appointmentOrder.getSlotId() == null) {
// 没有关联的预约订单,跳过班段检查(非预约挂号的场景)
return null;
}
// 获取号源槽位
ScheduleSlot slot = scheduleSlotMapper.selectById(appointmentOrder.getSlotId());
if (slot == null || slot.getPoolId() == null) {
return null;
}
// 获取号源池(班段信息)
SchedulePool pool = schedulePoolMapper.selectById(slot.getPoolId());
if (pool == null || pool.getEndTime() == null) {
return null;
}
// 检查当前时间是否已过班段结束时间
LocalTime now = LocalTime.now();
if (now.isAfter(pool.getEndTime())) {
return R.fail(null, "当前班段已结束,不能退号!");
}
return null;
} catch (Exception e) {
log.warn("检查班段结束时间失败, encounterId={}", encounter.getId(), e);
// 异常情况下允许退号,避免阻断正常业务
return null;
}
}
/**
* 查询当日就诊数据
*
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 当日就诊数据
*/
@Override
public IPage<CurrentDayEncounterDto> getCurrentDayEncounter(String searchKey, Integer pageNo, Integer pageSize,
HttpServletRequest request) {
// 构建查询条件
QueryWrapper<CurrentDayEncounterDto> queryWrapper = HisQueryUtils.buildQueryWrapper(null, searchKey,
new HashSet<>(Arrays.asList("patient_name", "organization_name", "practitioner_name", "healthcare_name", "identifier_no")),
request);
// 手动处理 statusEnum 参数(用于过滤退号记录)
String statusEnumParam = request.getParameter("statusEnum");
if (statusEnumParam != null && !statusEnumParam.isEmpty()) {
try {
Integer statusEnum = Integer.parseInt(statusEnumParam);
if (statusEnum == -1) {
// -1 表示排除退号记录(正常挂号)
queryWrapper.ne("status_enum", 6);
} else {
// 其他值表示精确匹配
queryWrapper.eq("status_enum", statusEnum);
}
} catch (NumberFormatException e) {
// 忽略无效的参数值
}
}
IPage<CurrentDayEncounterDto> currentDayEncounter = outpatientRegistrationAppMapper.getCurrentDayEncounter(
new Page<>(pageNo, pageSize), EncounterClass.AMB.getValue(), EncounterStatus.IN_PROGRESS.getValue(),
ParticipantType.ADMITTER.getCode(), ParticipantType.REGISTRATION_DOCTOR.getCode(), queryWrapper,
ChargeItemContext.REGISTER.getValue(), PaymentStatus.SUCCESS.getValue());
// 过滤候选池排除列表
// 仅当调用方显式传 excludeFromCandidatePool=true 时才过滤,避免非分诊场景(挂号/收费)
// 因未传参导致默认过滤,使已入队患者不可见
String excludeParam = request.getParameter("excludeFromCandidatePool");
boolean shouldExclude = "true".equalsIgnoreCase(excludeParam);
if (shouldExclude && currentDayEncounter != null && !currentDayEncounter.getRecords().isEmpty()) {
try {
// 获取当前租户和日期
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
LocalDate today = LocalDate.now();
// 查询排除列表
List<TriageCandidateExclusion> exclusions = triageCandidateExclusionService.list(
new LambdaQueryWrapper<TriageCandidateExclusion>()
.eq(TriageCandidateExclusion::getTenantId, tenantId)
.eq(TriageCandidateExclusion::getExclusionDate, today)
.eq(TriageCandidateExclusion::getDeleteFlag, "0")
);
if (exclusions != null && !exclusions.isEmpty()) {
// 构建排除的 encounterId 集合
Set<Long> excludedEncounterIds = exclusions.stream()
.map(TriageCandidateExclusion::getEncounterId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 过滤结果
List<CurrentDayEncounterDto> filteredRecords = currentDayEncounter.getRecords().stream()
.filter(e -> e.getEncounterId() == null || !excludedEncounterIds.contains(e.getEncounterId()))
.collect(Collectors.toList());
// 更新分页结果
currentDayEncounter.setRecords(filteredRecords);
currentDayEncounter.setTotal(filteredRecords.size());
}
} catch (Exception e) {
// 如果过滤失败,记录日志但不影响正常查询
log.warn("过滤候选池排除列表失败", e);
}
}
currentDayEncounter.getRecords().forEach(e -> {
// 性别
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
// 就诊状态
e.setStatusEnum_enumText(EnumUtils.getInfoByValue(EncounterStatus.class, e.getStatusEnum()));
// 计算年龄
e.setAge(e.getBirthDate() != null ? AgeCalculatorUtil.getAge(e.getBirthDate()) : "");
});
return currentDayEncounter;
}
/**
* 取消挂号
*
* @param encounterId 就诊id
* @return 结果
*/
@Override
public R<?> cancelRegister(Long encounterId) {
iEncounterService.removeById(encounterId);
return R.ok("已取消挂号");
}
/**
* 诊前退号:回滚预约订单、号源槽位、号源池统计。
*
* <p>处理四件事:
* <ol>
* <li>order_main → status=0(患者取消), pay_status=3(已退费), 写入取消时间和原因</li>
* <li>adm_schedule_slot → status=0(待约), order_id=NULL(释放号源)</li>
* <li>adm_schedule_pool → 重算统计值 + version+1</li>
* <li>返回 order_main.id 供 refund_log 关联</li>
* </ol>
*
* <p>异常仅记录日志不向上抛,不影响主流程返回成功。
*/
private Long syncAppointmentReturnStatus(Encounter encounter, String reason) {
if (encounter == null || encounter.getPatientId() == null) {
return null;
}
try {
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<Order>()
.eq(Order::getPatientId, encounter.getPatientId())
.orderByDesc(Order::getUpdateTime)
.orderByDesc(Order::getCreateTime)
.last("LIMIT 1");
if (encounter.getOrganizationId() != null) {
queryWrapper.eq(Order::getDepartmentId, encounter.getOrganizationId());
}
if (encounter.getTenantId() != null) {
queryWrapper.eq(Order::getTenantId, encounter.getTenantId());
}
if (encounter.getCreateTime() != null) {
LocalDate encounterDate = encounter.getCreateTime().toInstant()
.atZone(ZoneId.systemDefault()).toLocalDate();
Date startOfDay = Date.from(encounterDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
Date nextDayStart = Date.from(encounterDate.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant());
queryWrapper.ge(Order::getAppointmentDate, startOfDay)
.lt(Order::getAppointmentDate, nextDayStart);
}
Order appointmentOrder = orderService.getOne(queryWrapper, false);
if (appointmentOrder == null) {
return null;
}
// 只有有效订单(1)才能退号
if (!OrderStatus.ACTIVE.getValue().equals(appointmentOrder.getStatus())) {
log.warn("退号跳过:订单状态非有效, orderId={}, status={}",
appointmentOrder.getId(), appointmentOrder.getStatus());
return null;
}
// 乐观锁更新WHERE version = 旧值,防并发重复退号
boolean updated = orderService.update(
new LambdaUpdateWrapper<Order>()
.set(Order::getStatus, OrderStatus.PATIENT_CANCELLED.getValue())
.set(Order::getPayStatus, PaymentStatus.REFUND_ALL.getValue())
.set(Order::getCancelTime, new Date())
.set(Order::getCancelReason, "诊前退号")
.set(Order::getUpdateTime, new Date())
.setSql("version = version + 1")
.eq(Order::getId, appointmentOrder.getId())
.eq(Order::getVersion, appointmentOrder.getVersion())
);
if (!updated) {
log.warn("退号乐观锁冲突,订单已被其他操作修改, orderId={}", appointmentOrder.getId());
return null;
}
Long slotId = appointmentOrder.getSlotId();
if (slotId == null) {
return appointmentOrder.getId();
}
// 只有已预约(1)的号源才能退号,对应签到后的 BOOKED 状态
ScheduleSlot slot = scheduleSlotMapper.selectById(slotId);
if (slot == null || !SlotStatus.BOOKED.getValue().equals(slot.getStatus())) {
log.warn("退号跳过:槽位非已预约状态, slotId={}, status={}", slotId,
slot != null ? slot.getStatus() : null);
return appointmentOrder.getId();
}
int slotRows = scheduleSlotMapper.updateSlotStatus(slotId, SlotStatus.AVAILABLE.getValue());
if (slotRows == 0) {
log.warn("退号时更新槽位状态未影响任何行, slotId={}", slotId);
return appointmentOrder.getId();
}
Long poolId = scheduleSlotMapper.selectPoolIdBySlotId(slotId);
if (poolId != null) {
schedulePoolMapper.update(null,
new LambdaUpdateWrapper<SchedulePool>()
.setSql("booked_num = booked_num - 1, version = version + 1")
.set(SchedulePool::getUpdateTime, new Date())
.eq(SchedulePool::getId, poolId));
}
return appointmentOrder.getId();
} catch (Exception e) {
log.warn("同步预约号源已退号状态失败, encounterId={}", encounter.getId(), e);
return null;
}
}
/**
* 补打挂号
* 补打挂号不需要修改数据库,只需要返回成功即可,前端已有所有需要的数据用于打印
*
* @param reprintRegistrationDto 补打挂号信息
* @return 结果
*/
@Override
public R<?> reprintRegistration(ReprintRegistrationDto reprintRegistrationDto) {
// 补打挂号只是重新打印,不需要修改数据库
// 可以在这里添加日志记录补打操作
return R.ok(null, "补打挂号成功");
}
/**
* 记录退号日志(独立事务)。
*
* <p>REQUIRES_NEW 确保即使主事务回滚,退号审计日志也不丢失。
* orderMainId 优先使用 order_main.id若退费失败则 fallback 到 encounterId。
*
* @param cancelRegPaymentDto 退号请求对象
* @param encounter 就诊信息
* @param result 退号结果
* @param paymentRecon 支付对账信息
* @param orderMainId 预约订单主键order_main.id用于关联业务数据
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void recordRefundLog(CancelRegPaymentDto cancelRegPaymentDto,
Encounter encounter,
R<?> result,
PaymentReconciliation paymentRecon,
Long orderMainId) {
RefundLog refundLog = new RefundLog();
try {
// 1. 订单ID关联 order_main.id
String orderId = orderMainId != null
? String.valueOf(orderMainId)
: String.valueOf(cancelRegPaymentDto.getEncounterId());
refundLog.setOrderId(orderId);
// 已存在则不重复插入(防止唯一约束异常)
long exist = iRefundLogService.lambdaQuery()
.eq(RefundLog::getOrderId, orderId)
.count();
if (exist > 0) {
log.warn("退号日志已存在orderId={}", orderId);
return;
}
// 2. 患者信息
if (encounter != null) {
refundLog.setPatientId(String.valueOf(encounter.getPatientId()));
Patient patient = patientMapper.selectById(encounter.getPatientId());
refundLog.setPatientName(patient != null ? patient.getName() : "未知");
} else {
refundLog.setPatientId("0");
refundLog.setPatientName("未知");
}
// 3. 金额
// 优先使用paymentRecon中的displayAmount如果没有则尝试使用cancelRegPaymentDto中的displayAmount
BigDecimal refundAmount = BigDecimal.ZERO;
if (paymentRecon != null) {
// 使用退号后生成的paymentRecon的实际金额这个金额应该是负数
refundAmount = paymentRecon.getDisplayAmount() != null
? paymentRecon.getDisplayAmount().abs() // 取绝对值,因为退费金额通常显示为正数
: BigDecimal.ZERO;
} else if (cancelRegPaymentDto.getDisplayAmount() != null) {
refundAmount = cancelRegPaymentDto.getDisplayAmount();
}
refundLog.setRefundAmount(refundAmount);
// 4. 原因 & 类型
refundLog.setRefundReason(
StringUtils.isNotEmpty(cancelRegPaymentDto.getReason())
? cancelRegPaymentDto.getReason()
: "诊前退号-已缴费签到未就诊"
);
refundLog.setRefundType("FULL");
// 5. 退款方式
String refundMethod = "UNKNOWN";
if (cancelRegPaymentDto.getPaymentDetails() != null
&& !cancelRegPaymentDto.getPaymentDetails().isEmpty()) {
Integer payEnum = cancelRegPaymentDto.getPaymentDetails().get(0).getPayEnum();
if (payEnum != null) {
YbPayment ybPayment = YbPayment.getByValue(payEnum);
refundMethod = (ybPayment != null ? ybPayment.getInfo() : payEnum.toString());
}
}
refundLog.setRefundMethod(refundMethod);
// 6. 原交易号
refundLog.setOriginalTradeNo(
paymentRecon != null ? paymentRecon.getPaymentNo() : null
);
// 7. 时间
refundLog.setRefundTime(LocalDateTime.now());
// 8. 操作人
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
refundLog.setOpUserId(String.valueOf(loginUser.getUserId()));
refundLog.setOpUserName(loginUser.getUsername());
List<SysRole> roles = loginUser.getRoleList();
refundLog.setOpRole(
roles != null && !roles.isEmpty() ? roles.get(0).getRoleName() : "SYSTEM"
);
} else {
refundLog.setOpUserId("0");
refundLog.setOpUserName("SYSTEM");
refundLog.setOpRole("SYSTEM");
}
// 9. 状态
if (result != null && result.getCode() == 200) {
refundLog.setState(1);
} else {
refundLog.setState(0);
refundLog.setFailReason(result != null ? result.getMsg() : "未知错误");
}
// 10. 创建时间
refundLog.setCreatedAt(LocalDateTime.now());
refundLog.setUpdatedAt(LocalDateTime.now());
// 11. 保存
boolean saved = iRefundLogService.save(refundLog);
if (!saved) {
throw new RuntimeException("退号日志保存失败");
}
log.info("退号日志入库成功, orderId={}", orderId);
} catch (Exception e) {
log.error("退号日志入库失败,数据={}", refundLog, e);
throw e; // 让事务感知(你也可以只记录不抛)
}
}
/**
* 移除分诊队列中的记录
* 退号时同步移除患者队列记录,避免已退号患者仍在排队
*
* @param encounterId 就诊ID
*/
private void removeTriageQueueItem(Long encounterId) {
if (encounterId == null) {
return;
}
// 1. 移除分诊队列中的记录(必须成功,否则回滚事务)
com.openhis.triageandqueuemanage.domain.TriageQueueItem queueItem = triageQueueItemService.getOne(
new LambdaQueryWrapper<com.openhis.triageandqueuemanage.domain.TriageQueueItem>()
.eq(com.openhis.triageandqueuemanage.domain.TriageQueueItem::getEncounterId, encounterId)
.eq(com.openhis.triageandqueuemanage.domain.TriageQueueItem::getDeleteFlag, "0")
);
if (queueItem != null) {
// 逻辑删除队列项
queueItem.setDeleteFlag("1");
queueItem.setUpdateTime(LocalDateTime.now());
triageQueueItemService.updateById(queueItem);
// 写入分诊操作日志:诊前退号
try {
LoginUser loginUser = SecurityUtils.getLoginUser();
DivLog divLog = new DivLog()
.setPoolId(queueItem.getPoolId())
.setSlotId(queueItem.getSlotId())
.setOpUserId(loginUser != null ? loginUser.getUserId() : null)
.setAction("REFUND")
.setCreateTime(LocalDateTime.now())
.setUpdateAt(LocalDateTime.now())
.setCreatedAt(LocalDateTime.now());
divLogService.save(divLog);
} catch (Exception e) {
log.error("写入分诊退号日志失败encounterId={}", encounterId, e);
}
log.info("退号成功已移除分诊队列记录encounterId={}, queueItemId={}", encounterId, queueItem.getId());
}
// 2. 移除候选池排除记录(非必须,即使失败也不影响主流程)
try {
TriageCandidateExclusion exclusion = triageCandidateExclusionService.getOne(
new LambdaQueryWrapper<TriageCandidateExclusion>()
.eq(TriageCandidateExclusion::getEncounterId, encounterId)
.eq(TriageCandidateExclusion::getDeleteFlag, "0")
);
if (exclusion != null) {
exclusion.setDeleteFlag("1");
exclusion.setUpdateTime(LocalDateTime.now());
triageCandidateExclusionService.updateById(exclusion);
log.info("已移除候选池排除记录encounterId={}", encounterId);
}
} catch (Exception e) {
// 候选池排除记录移除失败不影响主流程,仅记录日志
log.warn("移除候选池排除记录失败encounterId={}", encounterId, e);
}
}
}

View File

@@ -0,0 +1,92 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.controller;
import com.core.common.core.domain.R;
import com.openhis.web.chargemanage.appservice.IInpatientChargeAppService;
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* 住院收费 controller
*
* @author zwh
* @date 2025-03-12
*/
@RestController
@RequestMapping("/charge-manage/inpatient-charge")
@Slf4j
@AllArgsConstructor
public class InpatientChargeController {
@Resource
private IInpatientChargeAppService inpatientChargeAppService;
/**
* 收费页面初始化
*
* @return 初始化信息
*/
@GetMapping(value = "/init")
public R<?> inpatientChargeInit() {
return inpatientChargeAppService.inpatientChargeInit();
}
/**
* 查询住院患者分页列表
*
* @param encounterPatientPageParam 查询条件
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @param request 请求
* @return 住院患者分页列表
*/
@GetMapping(value = "/encounter-patient-page")
public R<?> getEncounterPatientPage(EncounterPatientPageParam encounterPatientPageParam,
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
return inpatientChargeAppService.getEncounterPatientPage(encounterPatientPageParam, searchKey, pageNo, pageSize,
request);
}
/**
* 根据就诊id查询患者待结算信息
*
* @param encounterId 就诊id
* @return 患者待结算信息
*/
@GetMapping(value = "/patient-prescription")
public R<?> getEncounterPatientPrescription(Long encounterId) {
return R.ok(inpatientChargeAppService.getEncounterPatientPrescription(encounterId));
}
/**
* 医保转自费
*
* @param encounterId 就诊id
* @return 操作结果
*/
@PutMapping("/self-pay")
public R<?> changeToSelfPay(@RequestParam Long encounterId) {
return inpatientChargeAppService.changeToSelfPay(encounterId);
}
/**
* 自费转医保
*
* @param encounterId 就诊id
* @return 操作结果
*/
@PutMapping("/medical-insurance")
public R<?> changeToMedicalInsurance(@RequestParam Long encounterId) {
return inpatientChargeAppService.changeToMedicalInsurance(encounterId);
}
}

View File

@@ -0,0 +1,125 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.controller;
import com.core.common.core.domain.R;
import com.openhis.web.chargemanage.appservice.IOutpatientChargeAppService;
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* 门诊收费 controller
*
* @author zwh
* @date 2025-03-12
*/
@RestController
@RequestMapping("/charge-manage/charge")
@Slf4j
@AllArgsConstructor
public class OutpatientChargeController {
@Resource
private IOutpatientChargeAppService outpatientChargeAppService;
/**
* 门诊收费页面初始化
*
* @return 初始化信息
*/
@GetMapping(value = "/init")
public R<?> outpatientChargeInit() {
return outpatientChargeAppService.outpatientChargeInit();
}
/**
* 查询就诊患者分页列表
*
* @param encounterPatientPageParam 查询条件
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @param request 请求
* @return 就诊患者分页列表
*/
@GetMapping(value = "/encounter-patient-page")
public R<?> getEncounterPatientPage(EncounterPatientPageParam encounterPatientPageParam,
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
return R.ok(outpatientChargeAppService.getEncounterPatientPage(encounterPatientPageParam, searchKey, pageNo,
pageSize, request));
}
/**
* 根据就诊id查询患者处方列表
*
* @param encounterId 就诊id
* @return 患者处方列表
*/
@GetMapping(value = "/patient-prescription")
public R<?> getEncounterPatientPrescription(@RequestParam Long encounterId) {
return R.ok(outpatientChargeAppService.getEncounterPatientPrescription(encounterId));
}
/**
* 根据就诊id查询患者处方列表并新增字段实收金额、应收金额、优惠金额、折扣率
*
* @param encounterId 就诊id
* @return 患者处方列表
*/
@GetMapping(value = "/patient-prescription-with-price")
public R<?> getEncounterPatientPrescriptionWithPrice(@RequestParam Long encounterId) {
return R.ok(outpatientChargeAppService.getEncounterPatientPrescriptionWithPrice(encounterId));
}
/**
* 医保转自费
*
* @param encounterId 就诊id
* @return 操作结果
*/
@PutMapping("/self-pay")
public R<?> changeToSelfPay(@RequestParam Long encounterId) {
return outpatientChargeAppService.changeToSelfPay(encounterId);
}
/**
* 自费转医保
*
* @param encounterId 就诊id
* @return 操作结果
*/
@PutMapping("/medical-insurance")
public R<?> changeToMedicalInsurance(@RequestParam Long encounterId) {
return outpatientChargeAppService.changeToMedicalInsurance(encounterId);
}
/**
* 医保转自费
*
* @param encounterId 就诊id
* @return 操作结果
*/
@PutMapping("/student-self-pay")
public R<?> changeToStudentSelfPay(@RequestParam Long encounterId) {
return outpatientChargeAppService.changeToStudentSelfPay(encounterId);
}
/**
* 自费转医保
*
* @param encounterId 就诊id
* @return 操作结果
*/
@PutMapping("/student-yb-pay")
public R<?> changeToStudentYbPay(@RequestParam Long encounterId) {
return outpatientChargeAppService.changeToStudentYbPay(encounterId);
}
}

View File

@@ -0,0 +1,79 @@
package com.openhis.web.chargemanage.controller;
import com.core.common.core.domain.R;
import com.openhis.web.chargemanage.appservice.IOutpatientPricingAppService;
import com.openhis.web.doctorstation.dto.AdviceBaseDto;
import com.openhis.web.doctorstation.dto.PatientInfoDto;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* 门诊划价 controller
*
* @author yangmo
* @date 2025-04-14
*/
@RestController
@RequestMapping("/charge-manage/pricing")
@Slf4j
@AllArgsConstructor
public class OutpatientPricingController {
private final IOutpatientPricingAppService iOutpatientPricingAppService;
/**
* 查询就诊患者信息
*
* @param patientInfoDto 查询条件 (前端可传 statusEnum 区分就诊状态tab)
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 就诊患者信息
*/
@GetMapping(value = "/patient-info")
public R<?> getPatientInfo(PatientInfoDto patientInfoDto,
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
return R.ok(iOutpatientPricingAppService.getPatientInfo(patientInfoDto, searchKey, pageNo, pageSize, request));
}
/**
* 查询医嘱信息
*
* @param adviceBaseDto 查询条件
* @param searchKey 模糊查询关键字
* @param locationId 药房id
* @param organizationId 患者挂号对应的科室id
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 医嘱信息
*/
@GetMapping(value = "/advice-base-info")
public R<?> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto,
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@RequestParam(value = "locationId", required = false) Long locationId,
@RequestParam(value = "organizationId") Long organizationId,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(value = "categoryCode", required = false) String categoryCode,
@RequestParam(value = "adviceType", required = false) Integer adviceType) {
// 将 categoryCode 设置到 adviceBaseDto 中
// Bug #438 修复:接收并处理 adviceType 参数
if (adviceType != null) {
adviceBaseDto.setAdviceType(adviceType);
}
if (categoryCode != null && !categoryCode.isEmpty()) {
adviceBaseDto.setCategoryCode(categoryCode);
}
return R.ok(iOutpatientPricingAppService.getAdviceBaseInfo(adviceBaseDto, searchKey, locationId, organizationId,
pageNo, pageSize));
}
}

View File

@@ -0,0 +1,122 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.controller;
import com.core.common.core.domain.R;
import com.openhis.web.chargemanage.appservice.IOutpatientRefundAppService;
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
import com.openhis.web.chargemanage.dto.RefundItemParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 门诊退费 controller
*
* @author zwh
* @date 2025-03-15
*/
@RestController
@RequestMapping("/charge-manage/refund")
@Slf4j
@AllArgsConstructor
public class OutpatientRefundController {
@Resource
private IOutpatientRefundAppService outpatientRefundAppService;
/**
* 门诊退费页面初始化
*
* @return 初始化信息
*/
@GetMapping(value = "/init")
public R<?> outpatientRefundInit() {
return outpatientRefundAppService.outpatientRefundInit();
}
/**
* 查询结算过的就诊患者分页列表
*
* @param encounterPatientPageParam 查询条件
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @param request 请求
* @return 就诊患者分页列表
*/
@GetMapping(value = "/encounter-patient-page")
public R<?> getBilledEncounterPatientPage(EncounterPatientPageParam encounterPatientPageParam,
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
return outpatientRefundAppService.getBilledEncounterPatientPage(encounterPatientPageParam, searchKey, pageNo,
pageSize, request);
}
/**
* 根据就诊id查询患者的账单申请退费列表
*
* @param encounterId 就诊id
* @return 患者账单列表
*/
@GetMapping(value = "/patient-payment")
public R<?> getEncounterPatientPayment(@RequestParam(required = false) Long encounterId) {
if (encounterId == null) {
return R.fail(null, "请先选择患者后再进行退费操作");
}
return outpatientRefundAppService.getEncounterPatientPayment(encounterId);
}
/**
* 根据账单申请退费
*
* @param refundItemList 退费项目id列表
* @return 操作结果
*/
@PostMapping(value = "/refund-payment")
public R<?> refundPayment(@RequestBody List<RefundItemParam> refundItemList) {
return outpatientRefundAppService.refundPayment(refundItemList);
}
/**
* 根据就诊id查询患者的退费账单
*
* @param encounterId 就诊id
* @param billDateSTime 收费时间开始
* @param billDateETime 收费时间结束
* @return 退费账单列表
*/
@GetMapping(value = "/patient-refund")
public R<?> getEncounterPatientRefund(@RequestParam Long encounterId, @RequestParam String billDateSTime,
@RequestParam String billDateETime) {
return outpatientRefundAppService.getEncounterPatientRefund(encounterId, billDateSTime, billDateETime);
}
/**
* 根据就诊id查询患者因退费重新生成的账单
*
* @param encounterId 就诊id
* @return 重新生成的账单列表
*/
@GetMapping(value = "/regenerate_charge")
public R<?> getRegenerateCharge(@RequestParam Long encounterId) {
return outpatientRefundAppService.getRegenerateCharge(encounterId);
}
/**
* 校验是否可以退费(耗材/药品是否已退,诊疗是否取消执行)
*
* @param chargeItemIdList 收费项目id列表
* @return 是否可退
*/
@GetMapping(value = "/verify_refund")
public R<?> verifyRefundable(@RequestParam List<Long> chargeItemIdList) {
return outpatientRefundAppService.verifyRefundable(chargeItemIdList);
}
}

View File

@@ -0,0 +1,166 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.controller;
import com.core.common.core.domain.R;
import com.openhis.common.enums.PriorityLevel;
import com.openhis.financial.domain.PaymentReconciliation;
import com.openhis.web.chargemanage.appservice.IOutpatientRegistrationAppService;
import com.openhis.web.chargemanage.dto.OutpatientRegistrationInitDto;
import com.openhis.web.chargemanage.dto.ReprintRegistrationDto;
import com.openhis.web.paymentmanage.appservice.IEleInvoiceService;
import com.openhis.web.paymentmanage.dto.CancelRegPaymentDto;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 门诊挂号 controller
*/
@RestController
@RequestMapping("/charge-manage/register")
@Slf4j
@AllArgsConstructor
public class OutpatientRegistrationController {
private final IOutpatientRegistrationAppService iOutpatientRegistrationAppService;
@Autowired
private IEleInvoiceService eleInvoiceService;
/**
* 基础数据初始化
*/
@GetMapping(value = "/init")
public R<?> init() {
OutpatientRegistrationInitDto outpatientRegistrationInitDto = new OutpatientRegistrationInitDto();
// 优先级
List<OutpatientRegistrationInitDto.priorityLevelOption> priorityLevelOptionOptions =
Stream.of(PriorityLevel.values())
.map(e -> new OutpatientRegistrationInitDto.priorityLevelOption(e.getValue(), e.getInfo()))
.collect(Collectors.toList());
outpatientRegistrationInitDto.setPriorityLevelOptionOptions(priorityLevelOptionOptions);
return R.ok(outpatientRegistrationInitDto);
}
/**
* 查询患者信息
*
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 患者信息
*/
@GetMapping(value = "/patient-metadata")
public R<?> getPatientMetadata(@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
return R.ok(iOutpatientRegistrationAppService.getPatientMetadataBySearchKey(searchKey, pageNo, pageSize));
}
/**
* 查询就诊科室
*
* @return 就诊科室集合
*/
@GetMapping(value = "/org-list")
public R<?> getLocationTree() {
return R.ok(iOutpatientRegistrationAppService.getOrgMetadata());
}
/**
* 根据科室id筛选医生
*/
@GetMapping(value = "/practitioner-metadata")
public R<?> getPractitionerMetadata(@RequestParam(value = "orgId") Long orgId,
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
return R.ok(
iOutpatientRegistrationAppService.getPractitionerMetadataByLocationId(orgId, searchKey, pageNo, pageSize));
}
/**
* 根据机构id筛选服务项目
*/
@GetMapping(value = "/healthcare-metadata")
public R<?> getHealthcareMetadata(@RequestParam(value = "organizationId") Long organizationId,
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
return R.ok(iOutpatientRegistrationAppService.getHealthcareMetadataByOrganizationId(organizationId, searchKey,
pageNo, pageSize));
}
/**
* 退号
*
* @param cancelRegPaymentDto 就诊id
* @return 结果
*/
@PutMapping(value = "return")
public R<?> returnRegister(@RequestBody CancelRegPaymentDto cancelRegPaymentDto) {
R<?> result = iOutpatientRegistrationAppService.returnRegister(cancelRegPaymentDto);
// 取消付款成功后,开具发票
if (result.getCode() == 200) {
PaymentReconciliation paymentRecon = null;
if (PaymentReconciliation.class.isAssignableFrom(result.getData().getClass())) {
paymentRecon = (PaymentReconciliation)result.getData();
}
R<?> eleResult =
eleInvoiceService.invoiceWriteoff(paymentRecon.getRelationId(), cancelRegPaymentDto.getReason());
if (eleResult.getCode() != 200) {
// 因取消付款成功前端需要关闭弹窗此处信息仅用于提示所以返回ok
return R.ok(null, " 取消付款成功,电子发票开具失败 :" + eleResult.getMsg());
}
}
return result;
}
/**
* 取消挂号
*
* @param encounterId 就诊id
* @return 结果
*/
@PutMapping(value = "cancel")
public R<?> cancelRegister(@RequestParam(value = "encounterId") Long encounterId) {
return iOutpatientRegistrationAppService.cancelRegister(encounterId);
}
/**
* 查询当日就诊数据
*
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 当日就诊数据
*/
@GetMapping(value = "/current-day-encounter")
public R<?> getCurrentDayEncounter(@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
return R.ok(iOutpatientRegistrationAppService.getCurrentDayEncounter(searchKey, pageNo, pageSize, request));
}
/**
* 补打挂号
*
* @param reprintRegistrationDto 补打挂号信息
* @return 结果
*/
@PostMapping(value = "/reprint")
public R<?> reprintRegistration(@RequestBody ReprintRegistrationDto reprintRegistrationDto) {
return iOutpatientRegistrationAppService.reprintRegistration(reprintRegistrationDto);
}
}

View File

@@ -0,0 +1,65 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.constant.CommonConstants;
import com.openhis.common.enums.AccountBillingStatus;
import com.openhis.common.enums.AccountStatus;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
* 就诊账号 表单数据
*/
@Data
@Accessors(chain = true)
public class AccountFormData {
/**
* 就诊ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/** 患者id */
@NotNull(message = "患者id不能为空")
@JsonSerialize(using = ToStringSerializer.class)
private Long patientId;
/** 状态枚举 */
private Integer statusEnum;
/** 结账状态枚举 */
private Integer billingStatusEnum;
/** 账户类型编码 */
private String typeCode; // 【01医保电子凭证 | 02 居民身份证 | 03 社会保障卡 | 04 个人现金账户】
/** 名称 */
private String name; // 刷医保卡时应该会带出该信息
/** 账户余额 */
private BigDecimal balanceAmount; // 刷医保卡时应该会带出该信息
/** 医保区域编码 */
private String ybAreaNo; // 刷医保卡时应该会带出该信息
/** 合同编码 */
private String contractNo; // 从选择的费用性质里选择合同编码
/** 欠费限制额度 */
private BigDecimal limitAccount; // 刷医保卡时应该会带出该信息
/**
* 设置默认值
*/
public AccountFormData() {
this.contractNo = CommonConstants.BusinessName.DEFAULT_CONTRACT_NO;
this.statusEnum = AccountStatus.ACTIVE.getValue();
this.billingStatusEnum = AccountBillingStatus.OPEN.getValue();
}
}

View File

@@ -0,0 +1,91 @@
package com.openhis.web.chargemanage.dto;
import com.core.common.utils.SecurityUtils;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.constant.CommonConstants;
import com.openhis.common.enums.ChargeItemContext;
import com.openhis.common.enums.ChargeItemStatus;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
/**
* 费用项管理 表单数据
*/
@Data
@Accessors(chain = true)
public class ChargeItemFormData {
/**
* 就诊ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/** 患者id */
@NotNull(message = "患者id不能为空")
@JsonSerialize(using = ToStringSerializer.class)
private Long patientId;
/** 层级 */
private String busNo;
/** 状态 */
private Integer statusEnum;
/** 类别 */
private Integer contextEnum;
/** 发生时间 */
private Date occurrenceTime;
/** 执行人Id */
@JsonSerialize(using = ToStringSerializer.class)
private Long performerId;
/** 费用定价ID */
@NotNull(message = "费用定价ID不能为空")
@JsonSerialize(using = ToStringSerializer.class)
private Long definitionId;
/** 开立人ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long entererId;
/** 开立时间 */
private Date enteredDate;
/** 医疗服务类型 */
private String serviceTable;
/** 医疗服务ID */
@NotNull(message = "医疗服务ID不能为空")
@JsonSerialize(using = ToStringSerializer.class)
private Long serviceId;
/** 总价 */
@NotNull(message = "总价不能为空")
private BigDecimal totalPrice;
/** 关联账户ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long accountId;
/**
* 设置默认值
*/
public ChargeItemFormData() {
this.statusEnum = ChargeItemStatus.PLANNED.getValue();
this.contextEnum = ChargeItemContext.REGISTER.getValue();
this.occurrenceTime = new Date();
this.performerId = SecurityUtils.getLoginUser().getPractitionerId();
this.entererId = SecurityUtils.getLoginUser().getPractitionerId();
this.enteredDate = new Date();
this.serviceTable = CommonConstants.TableName.ADM_HEALTHCARE_SERVICE;
}
}

View File

@@ -0,0 +1,16 @@
package com.openhis.web.chargemanage.dto;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 费用性质 元数据
*/
@Data
@Accessors(chain = true)
public class ContractMetadata {
/** 合同名称 */
private String contractName;
/** 合同编码 */
private String busNo;
}

View File

@@ -0,0 +1,178 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
/**
* 当天就诊信息
*/
@Data
@Accessors(chain = true)
public class CurrentDayEncounterDto {
/**
* 租户ID
*/
private Integer tenantId;
/**
* 就诊ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/**
* 科室ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long organizationId;
/**
* 科室名称
*/
private String organizationName;
/**
* 挂号类型
*/
private String healthcareName;
/**
* 专家账号id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long practitionerUserId;
/**
* 专家
*/
private String practitionerName;
/**
* 费用性质
*/
private String contractName;
/**
* 患者id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long patientId;
/**
* 患者姓名
*/
private String patientName;
/**
* 患者性别
*/
private Integer genderEnum;
private String genderEnum_enumText;
/**
* 证件号
*/
private String idCard;
/**
* 就诊状态
*/
private Integer statusEnum;
private String statusEnum_enumText;
/**
* 挂号日期/时间
*/
private Date registerTime;
/**
* 价格
*/
private BigDecimal totalPrice;
/**
* 账户名称
*/
private String accountName;
/**
* 挂号人
*/
private String entererName;
/**
* 收费项目ids
*/
private String chargeItemIds;
/**
* 付款id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long paymentId;
/**
* 发票url地址
*/
private String pictureUrl;
/**
* 年龄
*/
private String age;
/**
* 生日
*/
private Date birthDate;
/**
* 电话
*/
private String phone;
/**
* 就诊卡号
*/
private String identifierNo;
/**
* 流水号(就诊当日序号)
*/
private Integer displayOrder;
/**
* 是否来自预约签到
* true: 预约签到
* false: 正常挂号
*/
private Boolean isFromAppointment;
/**
* 号源槽位ID关联 adm_schedule_slot.id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long slotId;
/**
* 号源池ID关联 adm_schedule_pool.id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long poolId;
/**
* 诊室名称Bug #410分诊队列需显示诊室而非科室
*/
private String clinicRoom;
/**
* 预约序号(来自 adm_schedule_slot.seq_no
*/
private Integer seqNo;
}

View File

@@ -0,0 +1,30 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
/**
* 就诊诊断 表单数据
*/
@Data
@Accessors(chain = true)
public class EncounterDiagnosisFormData {
/**
* 就诊ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/**
* 诊断ID
*/
@NotBlank(message = "诊断ID不能为空")
@JsonSerialize(using = ToStringSerializer.class)
private Long conditionId;
}

View File

@@ -0,0 +1,92 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.enums.*;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* 就诊 表单数据
*/
@Data
@Accessors(chain = true)
public class EncounterFormData {
/**
* 患者ID
*/
@NotNull(message = "患者ID不能为空")
@JsonSerialize(using = ToStringSerializer.class)
private Long patientId;
/**
* 状态编码
*/
private Integer statusEnum;
/**
* 类别编码
*/
private Integer classEnum;
/**
* 类别医保编码
*/
private Integer ybClassEnum;
/**
* 类别医保文本
*/
private String ybClassText; // 医保接口获取
/**
* 优先级编码
*/
@NotNull(message = "优先级编码不能为空")
private Integer priorityEnum;
/**
* 分类编码
*/
private Integer typeEnum;
/**
* 服务ID
*/
@NotNull(message = "服务ID不能为空")
@JsonSerialize(using = ToStringSerializer.class)
private Long serviceTypeId;
/**
* 就诊对象状态
*/
private Integer subjectStatusEnum;
/**
* 机构ID
*/
@NotNull(message = "机构ID不能为空")
@JsonSerialize(using = ToStringSerializer.class)
private Long organizationId;
/**
* 预约订单ID用于预约签到时关联预约订单
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long orderId;
/**
* 设置默认值
*/
public EncounterFormData() {
this.statusEnum = EncounterStatus.PLANNED.getValue();
this.classEnum = EncounterClass.AMB.getValue();
this.ybClassEnum = EncounterYbClass.ORDINARY_OUTPATIENT.getValue();
this.typeEnum = OutpatientClass.GENERAL_OUTPATIENT_SERVICE.getValue();
this.subjectStatusEnum = EncounterSubjectStatus.TRIAGED.getValue();
}
}

View File

@@ -0,0 +1,42 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.enums.EncounterActivityStatus;
import com.openhis.common.enums.LocationForm;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 就诊位置 表单数据
*/
@Data
@Accessors(chain = true)
public class EncounterLocationFormData {
/**
* 就诊ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/**
* 位置ID
*/
private Long locationId;
/** 状态枚举 */
private Integer statusEnum;
/** 物理形式枚举 */
private Integer formEnum;
/**
* 设置默认值
*/
public EncounterLocationFormData() {
this.statusEnum = EncounterActivityStatus.PLANNED.getValue();
this.formEnum = LocationForm.ROOM.getValue();
}
}

View File

@@ -0,0 +1,36 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.enums.ParticipantType;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 就诊参数者 表单数据
*/
@Data
@Accessors(chain = true)
public class EncounterParticipantFormData {
/**
* 就诊ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/** 参与者类型 */
private String typeCode;
/** 参与者ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long practitionerId;
/**
* 设置默认值
*/
public EncounterParticipantFormData() {
this.typeCode = ParticipantType.REGISTRATION_DOCTOR.getCode();// 挂号医生
}
}

View File

@@ -0,0 +1,133 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 就诊患者分页dto
*
* @author zwh
* @date 2025-03-12
*/
@Data
@Accessors(chain = true)
public class EncounterPatientPageDto {
/**
* 就诊ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/** 住院状态 */
private Integer encounterStatus;
private String encounterStatus_enumText;
/**
* 患者
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long patientId;
/**
* 患者姓名
*/
private String patientName;
/**
* 患者院内编码/病历号
*/
private String patientBusNo;
/**
* 身份证号
*/
private String idCard;
/**
* 拼音码
*/
private String patientPyStr;
/**
* 五笔码
*/
private String patientWbStr;
/**
* 就诊编码
*/
private String encounterBusNo;
/**
* 性别编码
*/
private Integer genderEnum;
private String genderEnum_enumText;
/**
* 生日
*/
private Date birthDate;
/**
* 账户余额
*/
private BigDecimal balanceAmount;
/**
* 接诊时间
*/
private Date receptionTime;
/**
* 年龄
*/
private String age;
/** 收费状态 */
private Integer statusEnum;
private String statusEnum_enumText;
/**
* 医保总额
*/
private BigDecimal insuranceAmount;
/**
* 自费总额
*/
private BigDecimal selfAmount;
/**
* 付款总额
*/
private BigDecimal totalAmount;
/**
* 结算时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date maxBillDate;
/**
* 开始时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/**
* 科室名称
*/
private String organizationName;
}

View File

@@ -0,0 +1,75 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 就诊患者分页查询条件
*
* @author zwh
* @date 2025-03-12
*/
@Data
@Accessors(chain = true)
public class EncounterPatientPageParam {
/**
* 患者姓名
*/
private String patientName;
/**
* 患者院内编码/病历号
*/
private String patientBusNo;
/**
* 身份证号
*/
private String idCard;
/**
* 拼音码
*/
private String patientPyStr;
/**
* 五笔码
*/
private String patientWbStr;
/**
* 就诊编码
*/
private String encounterBusNo;
/**
* 接诊时间
*/
private Date receptionTime;
/**
* 住院开始时间
*/
private Date startTime;
/**
* 收费时间
*/
private Date billTime;
/**
* 收费状态
*/
private Integer statusEnum;
/**
* 患者状态
*/
private Integer encounterStatus;
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.annotation.Dict;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
/**
* 就诊患者账单 dto
*
* @author zwh
* @date 2025-03-17
*/
@Data
@Accessors(chain = true)
public class EncounterPatientPaymentDto {
/** ID */
@TableId(type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
private Long paymentId;
/** 就诊ID */
private Long encounterId;
/** 处方号 */
private String prescriptionNo;
/** 关联账户ID */
private Long accountId;
/** 支付状态 */
private Integer statusEnum;
/** 关联ID */
private Long relationId;
/** 支付的业务标识符 */
private String paymentNo;
/** 付款类别 */
private Integer paymentEnum;
/** 支付位置 */
@Dict(dictTable = "adm_location", dictText = "name", dictCode = "id")
private Long locationId;
private String locationId_dictText;
/** 到期时间 */
private Date expirationDate;
/** 应收金额 */
private BigDecimal tenderedAmount;
/** 找零金额 */
private BigDecimal returnedAmount;
/** 付款总额 */
private BigDecimal displayAmount;
/** 合同编码 */
private String contractNo;
}

View File

@@ -0,0 +1,222 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.annotation.Dict;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
/**
* 就诊患者处方 dto
*
* @author zwh
* @date 2025-03-14
*/
@Data
@Accessors(chain = true)
public class EncounterPatientPrescriptionDto {
/**
* 收费项目类型
*/
private Integer contextEnum;
private String contextEnum_enumText;
/**
* 收费状态
*/
private Integer statusEnum;
private String statusEnum_enumText;
/**
* 就诊ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/**
* 患者id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long patientId;
/**
* ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
* 开立科室
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long requestingOrgId;
/**
* 数量
*/
private Long quantityValue;
/**
* 单位
*/
@Dict(dictCode = "unit_code")
private String quantityUnit;
private String quantityUnit_dictText;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 总价
*/
private BigDecimal totalPrice;
/**
* 处方号
*/
private String prescriptionNo;
/**
* 业务编码
*/
private String busNo;
/**
* 收款人ID
*/
@JsonSerialize(using = ToStringSerializer.class)
@Dict(dictCode = "id", dictTable = "adm_practitioner", dictText = "name")
private Long entererId;
private String entererId_dictText;
/**
* 开立时间
*/
private Date enteredDate;
/**
* 收费时间
*/
private Date billDate;
/**
* 关联账户ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long accountId;
/**
* 物品编码
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long itemId;
/**
* 物品名称
*/
private String itemName;
/**
* 特病标识
*/
@Dict(dictCode = "med_type")
private String medTypeCode;
private String medTypeCode_dictText;
/**
* 用法
*/
@Dict(dictCode = "method_code")
private String methodCode;
private String methodCode_dictText;
/**
* 剂量
*/
private String dose;
/**
* 剂量单位
*/
@Dict(dictCode = "unit_code")
private String doseUnitCode;
private String doseUnitCode_dictText;
/**
* 频次
*/
private String rateCode;
/**
* 合同编码
*/
private String contractNo;
/**
* 医保编码
*/
private String ybNo;
/**
* 合同名称
*/
private String contractName;
/**
* 服务所在表
*/
private String serviceTable;
/**
* 服务所在表对应的id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long serviceId;
/**
* 付款id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long paymentId;
/**
* 实收金额
*/
private BigDecimal receivedAmount = BigDecimal.ZERO;
/**
* 优惠金额
*/
private BigDecimal discountAmount = BigDecimal.ZERO;
/**
* 应收金额
*/
private BigDecimal receivableAmount = BigDecimal.ZERO;
/**
* 折扣率
*/
@Dict(dictCode = "charge_discount")
private String discountRate = "0";
private String discountRate_dictText;
/**
* 账单生成来源
*/
private Integer generateSourceEnum;
/**
* 来源单据号(手术单号等)
*/
private String sourceBillNo;
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.annotation.Dict;
import com.openhis.yb.dto.PaymentDetailDto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 患者退款信息列表
*
* @author zwh
* @date 2025-05-05
*/
@Data
@Accessors(chain = true)
public class EncounterPatientRefundDto {
/** 支付ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long paymentId;
/** 收款人ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long entererId;
/** 就诊ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/** 支付的患者ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long patientId;
/** 请求ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long requestId;
/** 发放ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long dispenseId;
/** 处方号 */
private String prescriptionNo;
/** 收费项目编号 */
private String busNo;
/** 合同编号 */
private String contractNo;
/** 项目名 */
private String itemName;
/** 项目名 */
private String orgName;
/** 收费项目ids */
private String chargeItemIds;
/** 收款人 */
private String entererName;
/** 服务表名 */
private String serviceTable;
/** 收费状态 */
private Integer chargeStatus;
private String chargeStatus_enumText;
/** 支付状态 */
private Integer paymentStatus;
private String paymentStatus_enumText;
/** 发放状态 */
private Integer dispenseStatus;
private String dispenseStatus_enumText;
/** 执行状态 */
private Integer serviceStatus;
private String serviceStatus_enumText;
/** 数量 */
private Integer quantityValue;
/** 已发药数量 */
private Integer dispenseQuantity;
/** 单位 */
@Dict(dictCode = "unit_code")
private String quantityUnit;
private String quantityUnit_dictText;
/** 单价 */
private BigDecimal unitPrice;
/** 总价 */
private BigDecimal totalPrice;
/** 结算时间 */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date billDate;
/**
* 支付明细列表
*/
private List<PaymentDetailDto> paymentDetailList;
}

View File

@@ -0,0 +1,27 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 门诊科室信息 元数据
*/
@Data
@Accessors(chain = true)
public class OrgMetadata {
/**
* ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
* 科室名称
*/
private String name;
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 门诊费用相关初始化
*
* @author zwh
* @date 2025-03-30
*/
@Data
@Accessors(chain = true)
public class OutpatientInitDto {
private List<OutpatientInitDto.chargeItemStatusOption> chargeItemStatusOptions;
private List<OutpatientInitDto.encounterStatusOption> encounterStatusOptions;
/**
* 收费状态
*/
@Data
public static class chargeItemStatusOption {
private Integer value;
private String label;
public chargeItemStatusOption(Integer value, String label) {
this.value = value;
this.label = label;
}
}
/**
* 住院状态
*/
@Data
public static class encounterStatusOption {
private Integer value;
private String label;
public encounterStatusOption(Integer value, String label) {
this.value = value;
this.label = label;
}
}
}

View File

@@ -0,0 +1,52 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.annotation.Dict;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
/**
* 门诊划价库存 dto
*/
@Data
@Accessors(chain = true)
public class OutpatientPricingInventoryDto {
/** 物理表名 */
private String itemTable;
/** 实例id */
@JsonSerialize(using = ToStringSerializer.class)
private Long itemId;
/** 当前库存数量 ,对应小单位*/
private BigDecimal quantity;
/** 单位 , 对应小单位*/
@Dict(dictCode = "unit_code")
private String unitCode;
private String unitCode_dictText;
/** 产品批号 */
private String lotNumber;
/** 库位 */
@JsonSerialize(using = ToStringSerializer.class)
private Long locationStoreId;
/** 库房id */
@JsonSerialize(using = ToStringSerializer.class)
private Long locationId;
/**
* 库房名称
*/
private String locationName;
/** 采购单价(进价) */
private BigDecimal price;
}

View File

@@ -0,0 +1,45 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.annotation.Dict;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
/**
* 门诊划价价格 dto
*/
@Data
@Accessors(chain = true)
public class OutpatientPricingPriceDto {
/**
* 费用定价名称
*/
private String chargeName;
/** 费用定价主表ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long definitionId;
/** 费用定价子表ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long definitionDetailId;
/** 命中条件 */
private String conditionCode;
/** 命中值 */
private String conditionValue;
/** 价格 */
private BigDecimal price;
/** 单位 */
@Dict(dictCode = "unit_code")
private String unitCode;
private String unitCode_dictText;
}

View File

@@ -0,0 +1,73 @@
package com.openhis.web.chargemanage.dto;
import com.openhis.yb.dto.Info5301SpecialConditionResult;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.Valid;
import java.util.List;
/**
* 门诊挂号 新增参数
*/
@Data
@Accessors(chain = true)
public class OutpatientRegistrationAddParam {
/**
* 就诊管理-表单数据
*/
@Valid
private EncounterFormData encounterFormData;
// /**
// * 就诊诊断管理-表单数据
// */
// private EncounterDiagnosisFormData encounterDiagnosisFormData;
/**
* 就诊位置管理-表单数据
*/
@Valid
private EncounterLocationFormData encounterLocationFormData;
/**
* 就诊参数者管理-表单数据
*/
@Valid
private EncounterParticipantFormData encounterParticipantFormData;
/**
* 就诊账户管理-表单数据
*/
@Valid
private AccountFormData accountFormData;
/**
* 费用项管理-表单数据 //todo:挂号费会绑定诊查费该字段会变成List挂号前先把这个收费项开个前台后台没有保存
*/
@Valid
private ChargeItemFormData chargeItemFormData;
/**
* 密钥 医保挂号时使用
*/
private String busiCardInfo;// 2025/05/16 前后端一致,前端大写,后端保持大写
/**
* 类型 医保挂号时使用
*/
private String ybMdtrtCertType;
/**
* 医保个人结算方式 参照枚举 按项目结算 01 按定额结算 02
*/
private String YbPsnSetlWay;
/**
* 特慢病列表
*/
private List<Info5301SpecialConditionResult> feedetail;
public OutpatientRegistrationAddParam() {
this.YbPsnSetlWay = "01";
}
}

View File

@@ -0,0 +1,32 @@
package com.openhis.web.chargemanage.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 门诊挂号 init基础数据
*/
@Data
@Accessors(chain = true)
public class OutpatientRegistrationInitDto {
private List<priorityLevelOption> priorityLevelOptionOptions;
/**
* 优先级
*/
@Data
public static class priorityLevelOption {
private Integer value;
private String label;
public priorityLevelOption(Integer value, String label) {
this.value = value;
this.label = label;
}
}
}

View File

@@ -0,0 +1,21 @@
package com.openhis.web.chargemanage.dto;
import com.openhis.yb.dto.PaymentDetailDto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
public class OutpatientRegistrationSettleParam {
OutpatientRegistrationAddParam outpatientRegistrationAddParam;
String chrgBchno;// 收费批次号 付款时必传
String busNo;// 挂号no
List<PaymentDetailDto> paymentDetails;// 支付渠道 付款时必传
}

View File

@@ -0,0 +1,63 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 患者信息 元数据
*/
@Data
@Accessors(chain = true)
public class PatientMetadata {
/**
* ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
* 患者姓名
*/
private String name;
/**
* 性别编码
*/
private Integer genderEnum;
private String genderEnum_enumText;
/**
* 身份证号
*/
private String idCard;
/**
* 电话
*/
private String phone;
/**
* 生日
*/
private Date birthDate;
/**
* 年龄
*/
private String age;
/**
* 初复诊
*/
private String firstEnum_enumText;
/**
* 就诊卡号
*/
private String identifierNo;
}

View File

@@ -0,0 +1,38 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 参与者 元数据
*/
@Data
@Accessors(chain = true)
public class PractitionerMetadata {
/**
* ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/** 姓名 */
private String name;
/**
* 性别编码
*/
private Integer genderEnum;
private String genderEnum_enumText;
/** 拼音码 */
private String pyStr;
/** 五笔码 */
private String wbStr;
/** 医生职称 */
private String drProfttlCode;
}

View File

@@ -0,0 +1,150 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.dto;
import com.core.common.utils.SecurityUtils;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.enums.EncounterClass;
import com.openhis.common.enums.RequestStatus;
import com.openhis.common.enums.TherapyTimeType;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
/**
* 划价项目 dto
*
* @author zwh
* @date 2025-04-10
*/
@Data
@Accessors(chain = true)
public class PricingProjectDto {
/** 医嘱类型 */
private Integer adviceType; // 1:药品 , 2: 耗材 , 3:项目
/**
* 医嘱详细分类
*/
private String categoryCode;
/** 拆零比 */
private BigDecimal partPercent;
/** 执行次数 */
private Integer executeNum; // 当医嘱类型为药品时,选填
/** 请求数量 */
private Integer quantity;
/** 请求单位编码 */
private String unitCode;
/** 单价 */
private BigDecimal unitPrice;
/** 总价 */
private BigDecimal totalPrice;
/** 费用定价主表ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long definitionId;
/** 费用定价子表ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long definitionDetailId;
/** 产品批号 */
private String lotNumber;
/**
* 请求状态
*/
private Integer statusEnum;
/** 请求类型 */
private Integer categoryEnum;
/** 耗材ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long deviceId;
/**
* 医嘱对应表名
*/
private String adviceTableName;
/** 患者 */
@JsonSerialize(using = ToStringSerializer.class)
private Long patientId;
/** 开方医生 */
@JsonSerialize(using = ToStringSerializer.class)
private Long practitionerId;
/** 请求发起的位置 */
@JsonSerialize(using = ToStringSerializer.class)
private Long locationId;
/** 发放位置 */
@JsonSerialize(using = ToStringSerializer.class)
private Long performLocation;
/** 所属科室 */
@JsonSerialize(using = ToStringSerializer.class)
private Long orgId;
/** 就诊id */
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/**
* 账户id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long accountId;
/**
* 诊断ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long conditionId;
/** 治疗类型 */
private Integer therapyEnum;
/** 用法 */
private String methodCode;
/** 用药频次 */
private String rateCode;
/** 单次剂量 */
private BigDecimal dose;
/** 剂量单位 */
private String doseUnitCode;
/** 组套id */
@JsonSerialize(using = ToStringSerializer.class)
private Long packageId;
/** 活动(项目)定义id */
@JsonSerialize(using = ToStringSerializer.class)
private Long activityId;
/**
* 设置默认值
*/
public PricingProjectDto() {
this.statusEnum = RequestStatus.ACTIVE.getValue();
this.categoryEnum = EncounterClass.AMB.getValue();
this.therapyEnum = TherapyTimeType.TEMPORARY.getValue();
this.practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
this.orgId = SecurityUtils.getLoginUser().getOrgId(); // 开方人科室
}
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.annotation.Dict;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
/**
* 退款项目 dto
*
* @author zwh
* @date 2025-03-18
*/
@Data
@Accessors(chain = true)
public class RefundItemDto {
/** 收费ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long chargeItemId;
/** 收费ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long paymentId;
/** 医疗服务所在表 */
private String serviceTable;
/** 医疗服务ID */
private Long serviceId;
/** 请求编码 */
private String busNo;
/** 处方号 */
private String prescriptionNo;
/** 请求数量 */
private BigDecimal quantity;
/** 请求单位编码 */
@Dict(dictCode = "unit_code")
private String unitCode;
private String unitCode_dictText;
/** 单价 */
private BigDecimal unitPrice;
/** 总价 */
private BigDecimal totalPrice;
/** 退款状态 */
private Integer refundStatus;
private String refundStatus_enumText;
/** 发放状态 */
private Integer dispenseStatus;
private String dispenseStatus_enumText;
/** 执行状态 */
private Integer serviceStatus;
private String serviceStatus_enumText;
/** 未发药原因 */
private Integer notPerformedReason;
/** 项目id */
private Long itemId;
/** 发放id */
private Long dispenseId;
/** 请求id */
private Long requestId;
/** 项目名 */
private String itemName;
/** 费用支付方式编码 */
private String medfeePaymtdCode;
/** 费用类型 */
private String feeType;
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.dto;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 退费项目id列表 dto
*
* @author yangmo
* @date 2025-04-15
*/
@Data
@Accessors(chain = true)
public class RefundItemParam {
/** 付款ID */
private Long paymentId;
/** 收费项ID */
private Long chargeItemId;
/** 退费标志 */
private Boolean refundFlg;
}

View File

@@ -0,0 +1,71 @@
package com.openhis.web.chargemanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
/**
* 补打挂号 DTO
*/
@Data
@Accessors(chain = true)
public class ReprintRegistrationDto {
/**
* 就诊ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/**
* 就诊卡号
*/
private String cardNo;
/**
* 患者姓名
*/
private String name;
/**
* 挂号科室
*/
private String organizationName;
/**
* 医生姓名
*/
private String practitionerName;
/**
* 挂号费
*/
private BigDecimal price;
/**
* 诊疗费
*/
private BigDecimal activityPrice;
/**
* 病历费
*/
private BigDecimal medicalRecordFee;
/**
* 合计
*/
private BigDecimal totalPrice;
/**
* 预约/挂号时间
*/
private String visitTime;
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.openhis.web.chargemanage.dto.EncounterPatientPageDto;
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
import com.openhis.web.chargemanage.dto.EncounterPatientPrescriptionDto;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 门诊收费 appMapper
*
* @author zwh
* @date 2025-03-13
*/
@Repository
public interface InpatientChargeAppMapper {
/**
* 查询就诊患者分页列表
*
* @param classEnum 住院患者类型:住院
* @param dischargedFromHospital 住院状态:已出院
* @param alreadySettled 住院状态:已结算出院
* @param page 分页
* @param queryWrapper 查询条件
* @return 就诊患者分页列表
*/
Page<EncounterPatientPageDto> selectEncounterPatientPage(@Param("classEnum") Integer classEnum,
@Param("dischargedFromHospital") Integer dischargedFromHospital,
@Param("alreadySettled") Integer alreadySettled, @Param("billable") Integer billable,
@Param("billed") Integer billed, @Param("refunded") Integer refunded,
@Param("personalCashAccount") String personalCashAccount, @Param("page") Page<EncounterPatientPageDto> page,
@Param(Constants.WRAPPER) QueryWrapper<EncounterPatientPageParam> queryWrapper);
/**
* 根据就诊id查询患者处方列表
*
* @param encounterId 就诊id
* @param activity 项目
* @param medication 药品
* @param device 耗材
* @param register 挂号费
* @param planned 收费状态:待收费
* @param billable 收费状态:待结算
* @param billed 收费状态:已结算
* @param refunding 收费状态:退费中
* @param refunded 收费状态:全部退费
* @param partRefund 收费状态:部分退费
* @return 患者处方列表
*/
List<EncounterPatientPrescriptionDto> selectEncounterPatientPrescription(@Param("encounterId") Long encounterId,
@Param("activity") Integer activity, @Param("medication") Integer medication, @Param("device") Integer device,
@Param("register") Integer register, @Param("planned") Integer planned, @Param("billable") Integer billable,
@Param("billed") Integer billed, @Param("refunding") Integer refunding, @Param("refunded") Integer refunded,
@Param("partRefund") Integer partRefund);
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.openhis.web.chargemanage.dto.EncounterPatientPageDto;
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
import com.openhis.web.chargemanage.dto.EncounterPatientPrescriptionDto;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 门诊收费 appMapper
*
* @author zwh
* @date 2025-03-13
*/
@Repository
public interface OutpatientChargeAppMapper {
/**
* 查询就诊患者分页列表
*
* @param page 分页
* @param queryWrapper 查询条件
* @param amb 就诊类型:门诊
* @return 就诊患者分页列表
*/
Page<EncounterPatientPageDto> selectEncounterPatientPage(@Param("page") Page<EncounterPatientPageDto> page,
@Param(Constants.WRAPPER) QueryWrapper<EncounterPatientPageParam> queryWrapper, @Param("amb") Integer amb);
/**
* 根据就诊id查询患者处方列表
*
* @param encounterId 就诊id
* @param activity 项目
* @param medication 药品
* @param device 耗材
* @param register 挂号费
* @param westernMedicine 西药
* @param chinesePatentMedicine 中成药
* @param planned 收费状态:待收费
* @param billable 收费状态:待结算
* @param billed 收费状态:已结算
* @param refunding 收费状态:退费中
* @param refunded 收费状态:全部退费
* @param partRefund 收费状态:部分退费
* @param worDeviceRequest 耗材请求表名常量
* @return 患者处方列表
*/
List<EncounterPatientPrescriptionDto> selectEncounterPatientPrescription(@Param("encounterId") Long encounterId,
@Param("activity") Integer activity, @Param("medication") Integer medication, @Param("device") Integer device,
@Param("register") Integer register, @Param("westernMedicine") Integer westernMedicine,
@Param("chinesePatentMedicine") Integer chinesePatentMedicine,
@Param("planned") Integer planned, @Param("billable") Integer billable,
@Param("billed") Integer billed, @Param("refunding") Integer refunding, @Param("refunded") Integer refunded,
@Param("partRefund") Integer partRefund, @Param("worDeviceRequest") String worDeviceRequest);
/**
* 根据就诊id查询患者处方列表并新增字段应收金额实收金额优惠金额折扣率
*
* @param encounterId 就诊id
* @param activity 项目
* @param medication 药品
* @param device 耗材
* @param register 挂号费
* @param planned 收费状态:待收费
* @param billable 收费状态:待结算
* @param billed 收费状态:已结算
* @param refunding 收费状态:退费中
* @param refunded 收费状态:全部退费
* @param partRefund 收费状态:部分退费
* @param discountCode 优惠枚举码
* @param selfCode 现金枚举码
* @param selfVxCode 微信枚举码
* @param selfAliCode 支付宝枚举码
* @param selfUnionCode 银联枚举码
* @param worDeviceRequest 耗材请求表名常量
* @return 患者处方列表
*/
List<EncounterPatientPrescriptionDto> selectEncounterPatientPrescriptionWithPrice(
@Param("encounterId") Long encounterId, @Param("activity") Integer activity,
@Param("medication") Integer medication, @Param("device") Integer device, @Param("register") Integer register,
@Param("planned") Integer planned, @Param("billable") Integer billable, @Param("billed") Integer billed,
@Param("refunding") Integer refunding, @Param("refunded") Integer refunded,
@Param("partRefund") Integer partRefund, @Param("discountCode") Integer discountCode,
@Param("self") Integer selfCode, @Param("selfVx") Integer selfVxCode, @Param("selfAli") Integer selfAliCode,
@Param("selfUnion") Integer selfUnionCode, @Param("worDeviceRequest") String worDeviceRequest);
}

View File

@@ -0,0 +1,17 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.mapper;
import org.springframework.stereotype.Repository;
/**
* 门诊划价 appMapper
*
* @author yangmo
* @date 2025-04-14
*/
@Repository
public interface OutpatientPricingAppMapper {
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.chargemanage.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.openhis.web.chargemanage.dto.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 门诊退费 appMapper
*
* @author zwh
* @date 2025-03-15
*/
@Repository
public interface OutpatientRefundAppMapper {
/**
* 获取就诊患者账单列表
*
* @param encounterId 就诊id
* @param success 支付状态:成功
* @param refundPart 支付状态:部分退款
* @param refundAll 支付状态:全部退款
* @return 就诊患者账单列表
*/
List<EncounterPatientPaymentDto> selectEncounterPatientPayment(@Param("encounterId") Long encounterId,
@Param("success") Integer success, @Param("refundPart") Integer refundPart,
@Param("refundAll") Integer refundAll);
/**
* 查询退费项目
*
* @param chargeItemIdList 收费项列表
* @param medMedicationRequest 药品请求表
* @param worServiceRequest 服务请求表
* @param worDeviceRequest 耗材请求表
* @param three 用于字符截位
* @return 退费项目列表
*/
List<RefundItemDto> selectRefundItem(@Param("chargeItemIdList") List<Long> chargeItemIdList,
@Param("medMedicationRequest") String medMedicationRequest,
@Param("worServiceRequest") String worServiceRequest, @Param("worDeviceRequest") String worDeviceRequest,
@Param("three") Integer three);
/**
* 查询已结算就诊患者分页列表
*
* @param page 分页
* @param queryWrapper 查询条件
* @param billed 收费状态:已结算
* @param refunding 收费状态:退费中
* @param refunded 收费状态:已退费
* @param partRefund 收费状态:部分退费
* @param insurance 账户类型:医保
* @param amb 就诊类型:门诊
* @param register 账单类型:挂号费
* @return 已结算就诊患者分页列表
*/
Page<EncounterPatientPageDto> selectBilledEncounterPatientPage(@Param("page") Page<EncounterPatientPageDto> page,
@Param(Constants.WRAPPER) QueryWrapper<EncounterPatientPageParam> queryWrapper, @Param("billed") Integer billed,
@Param("refunding") Integer refunding, @Param("refunded") Integer refunded,
@Param("partRefund") Integer partRefund, @Param("insurance") String insurance, @Param("amb") Integer amb,
@Param("register") Integer register);
/**
* 查询患者退费项目
*
* @param encounterId 就诊id
* @param refunding 收费状态:退费中
* @param refunded 收费状态:已退款
* @param partRefund 收费状态:部分退款
* @param worServiceRequest 服务请求表
* @param worDeviceRequest 设备请求表
* @param medMedicationRequest 药品请求表
* @param billDateSTime 收费时间开始
* @param billDateETime 收费时间结束
* @return 查询患者退费项目
*/
List<EncounterPatientRefundDto> selectEncounterPatientRefund(@Param("encounterId") Long encounterId,
@Param("refunding") Integer refunding, @Param("refunded") Integer refunded,
@Param("partRefund") Integer partRefund, @Param("worServiceRequest") String worServiceRequest,
@Param("worDeviceRequest") String worDeviceRequest, @Param("medMedicationRequest") String medMedicationRequest,
@Param("billDateSTime") String billDateSTime, @Param("billDateETime") String billDateETime);
}

View File

@@ -0,0 +1,72 @@
package com.openhis.web.chargemanage.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.openhis.web.chargemanage.dto.CurrentDayEncounterDto;
import com.openhis.web.chargemanage.dto.PractitionerMetadata;
import com.openhis.web.personalization.dto.ActivityDeviceDto;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 门诊挂号 应用Mapper
*/
@Repository
public interface OutpatientRegistrationAppMapper {
/**
* 查询医生
*/
IPage<PractitionerMetadata> getPractitionerMetadataPage(@Param("page") Page<PractitionerMetadata> page,
@Param("orgId") Long orgId, @Param("RoleCode") String RoleCode,
@Param(Constants.WRAPPER) QueryWrapper<PractitionerMetadata> queryWrapper);
/**
* 根据病人id和科室id查询当日挂号次数
*/
Integer getNumByPatientIdAndOrganizationId(@Param("patientId") Long patientId,
@Param("serviceTypeId") Long serviceTypeId, @Param("cancelled") Integer cancelled);
/**
* 查询当日就诊数据
*
* @param page 分页参数
* @param classEnum 就诊类型
* @param statusEnum 门诊就诊状态 | 在诊
* @param participantType1 参与者类型 | 接诊医生
* @param participantType2 参与者类型 | 挂号医生
* @param queryWrapper 查询条件
* @param register 收费项目类型:挂号
* @param paymentStatus 支付状态:成功
* @return 当日就诊数据
*/
IPage<CurrentDayEncounterDto> getCurrentDayEncounter(@Param("page") Page<CurrentDayEncounterDto> page,
@Param("classEnum") Integer classEnum, @Param("statusEnum") Integer statusEnum,
@Param("participantType1") String participantType1, @Param("participantType2") String participantType2,
@Param(Constants.WRAPPER) QueryWrapper<CurrentDayEncounterDto> queryWrapper,
@Param("register") Integer register, @Param("paymentStatus") Integer paymentStatus);
/**
* 查询item绑定的信息(耗材或诊疗)
*
* @param itemId itemId
* @param devActable 绑定的表名(耗材或诊疗)
* @return item绑定的信息
*/
List<ActivityDeviceDto> getTmpActivityList(@Param("itemId") String itemId, @Param("devActable") String devActable);
/**
* 根据用法代码查询绑定的耗材
*
* @param methodCode 用法代码
* @param devActTable 绑定的表名(耗材)
* @param typeCode 类型代码(1-用法绑定)
* @return 绑定的耗材列表
*/
List<ActivityDeviceDto> getBoundDevicesByUsage(@Param("methodCode") String methodCode,
@Param("devActTable") String devActTable, @Param("typeCode") String typeCode);
}