退费部分代码完成
This commit is contained in:
@@ -3,10 +3,13 @@
|
||||
*/
|
||||
package com.openhis.web.chargemanage.appservice;
|
||||
|
||||
import com.core.common.core.domain.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
|
||||
|
||||
/**
|
||||
* 门诊退费 service
|
||||
*
|
||||
@@ -30,4 +33,17 @@ public interface IOutpatientRefundAppService {
|
||||
* @return 操作结果
|
||||
*/
|
||||
R<?> refundPayment(List<Long> paymentIdList);
|
||||
|
||||
/**
|
||||
* 查询结算过的就诊患者分页列表
|
||||
*
|
||||
* @param encounterPatientPageParam 查询条件
|
||||
* @param searchKey 模糊查询关键字
|
||||
* @param pageNo 当前页
|
||||
* @param pageSize 每页多少条
|
||||
* @param request 请求
|
||||
* @return 就诊患者分页列表
|
||||
*/
|
||||
R<?> getBilledEncounterPatientPage(EncounterPatientPageParam encounterPatientPageParam, String searchKey,
|
||||
Integer pageNo, Integer pageSize, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -3,20 +3,37 @@
|
||||
*/
|
||||
package com.openhis.web.chargemanage.appservice.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
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.IChargeItemService;
|
||||
import com.openhis.common.constant.CommonConstants;
|
||||
import com.openhis.common.enums.PaymentStatus;
|
||||
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.service.IMedicationDispenseService;
|
||||
import com.openhis.web.chargemanage.appservice.IOutpatientRefundAppService;
|
||||
import com.openhis.web.chargemanage.dto.EncounterPatientPageDto;
|
||||
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
|
||||
import com.openhis.web.chargemanage.dto.EncounterPatientPaymentDto;
|
||||
import com.openhis.web.chargemanage.dto.RefundItemDto;
|
||||
import com.openhis.web.chargemanage.mapper.OutpatientRefundAppMapper;
|
||||
import com.openhis.workflow.service.IDeviceDispenseService;
|
||||
import com.openhis.workflow.service.IServiceRequestService;
|
||||
|
||||
/**
|
||||
* 门诊退费 impl
|
||||
@@ -33,6 +50,12 @@ public class OutpatientRefundAppServiceImpl implements IOutpatientRefundAppServi
|
||||
private IPaymentReconciliationService paymentReconciliationService;
|
||||
@Autowired
|
||||
private IChargeItemService chargeItemService;
|
||||
@Autowired
|
||||
private IMedicationDispenseService medicationDispenseService;
|
||||
@Autowired
|
||||
private IDeviceDispenseService deviceDispenseService;
|
||||
@Autowired
|
||||
private IServiceRequestService serviceRequestService;
|
||||
|
||||
/**
|
||||
* 根据就诊id查询患者的账单
|
||||
@@ -56,20 +79,97 @@ public class OutpatientRefundAppServiceImpl implements IOutpatientRefundAppServi
|
||||
*/
|
||||
@Override
|
||||
public R<?> refundPayment(List<Long> paymentIdList) {
|
||||
|
||||
// 医生同意退费
|
||||
// 查询所有的chargeid,对应生成一个负的chargeitem
|
||||
// 根据每个 chargeitem判断对应的服务,药品,耗材是否已发放执行
|
||||
// 若已发放/执行需要对应的发药人/执行人审批(药品耗材需要先退药)
|
||||
|
||||
// todo:医生同意退费(审批流)
|
||||
// 根据支付id获取对应收费项目的id列表
|
||||
List<Long> chargeItemIdList = paymentReconciliationService.getChargeItemIdListByPayment(paymentIdList);
|
||||
|
||||
//根据收费项目id列表查询退费项
|
||||
// 根据收费项目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);
|
||||
|
||||
return null;
|
||||
List<Long> medDisIdList = new ArrayList<>();
|
||||
List<Long> devDisIdList = new ArrayList<>();
|
||||
List<Long> serReqIdList = new ArrayList<>();
|
||||
|
||||
for (RefundItemDto refundItem : refundItemList) {
|
||||
if (CommonConstants.TableName.MED_MEDICATION_REQUEST.equals(refundItem.getServiceTable())) {
|
||||
|
||||
// 药品需要先退药
|
||||
if (DispenseStatus.COMPLETED.getValue().equals(refundItem.getRefundStatus())
|
||||
|| DispenseStatus.PART_COMPLETED.getValue().equals(refundItem.getRefundStatus())) {
|
||||
return R
|
||||
.fail(MessageUtils.createMessage(PromptMsgConstant.ChargeRefund.M00001, new Object[] {"药品"}));
|
||||
} else {
|
||||
// todo:审批流药师同意退费
|
||||
medDisIdList.add(refundItem.getDispenseId());
|
||||
}
|
||||
} else if (CommonConstants.TableName.WOR_SERVICE_REQUEST.equals(refundItem.getServiceTable())) {
|
||||
// 诊疗项目需医技科室同意退费
|
||||
if (RequestStatus.COMPLETED.getValue().equals(refundItem.getRefundStatus())) {
|
||||
return R.fail(MessageUtils.createMessage(PromptMsgConstant.ChargeRefund.M00002, null));
|
||||
} else {
|
||||
// todo:审批流医技师同意退费
|
||||
serReqIdList.add(refundItem.getServiceId());
|
||||
}
|
||||
} else if (CommonConstants.TableName.WOR_DEVICE_REQUEST.equals(refundItem.getServiceTable())) {
|
||||
// 耗材需要先退药
|
||||
if (DispenseStatus.COMPLETED.getValue().equals(refundItem.getRefundStatus())
|
||||
|| DispenseStatus.PART_COMPLETED.getValue().equals(refundItem.getRefundStatus())) {
|
||||
return R
|
||||
.fail(MessageUtils.createMessage(PromptMsgConstant.ChargeRefund.M00001, new Object[] {"耗材"}));
|
||||
} else {
|
||||
devDisIdList.add(refundItem.getDispenseId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 更新收费状态:已退费
|
||||
chargeItemService.updateRefundChargeStatus(chargeItemIdList);
|
||||
// 更新未发放药品状态:停止发放,停止原因:退费
|
||||
medicationDispenseService.updateStopDispenseStatus(medDisIdList, NotPerformedReason.REFUND.getValue());
|
||||
// 更新未发放耗材状态:停止发放,停止原因:退费
|
||||
deviceDispenseService.updateStopDispenseStatus(devDisIdList, NotPerformedReason.REFUND.getValue());
|
||||
// 更新执行诊疗状态:停止
|
||||
serviceRequestService.updateStopRequestStatus(serReqIdList);
|
||||
// 返回退费成功信息
|
||||
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(), AccountType.MEDICAL_INSURANCE.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(AgeCalculatorUtil.getAge(e.getBirthDate()));
|
||||
// 合同类型枚举
|
||||
e.setCategoryEnum_enumText(EnumUtils.getInfoByValue(ContractCategory.class, e.getCategoryEnum()));
|
||||
});
|
||||
return R.ok(encounterPatientPage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,20 @@
|
||||
*/
|
||||
package com.openhis.web.chargemanage.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.web.chargemanage.appservice.IOutpatientRefundAppService;
|
||||
import com.openhis.web.chargemanage.dto.EncounterPatientPageParam;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 门诊退费 controller
|
||||
*
|
||||
@@ -29,6 +32,25 @@ public class OutpatientRefundController {
|
||||
@Autowired
|
||||
private IOutpatientRefundAppService outpatientRefundAppService;
|
||||
|
||||
/**
|
||||
* 查询结算过的就诊患者分页列表
|
||||
*
|
||||
* @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 R.ok(outpatientRefundAppService.getBilledEncounterPatientPage(encounterPatientPageParam, searchKey,
|
||||
pageNo, pageSize, request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据就诊id查询患者的账单
|
||||
*
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Date;
|
||||
|
||||
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;
|
||||
@@ -72,7 +73,9 @@ public class EncounterPatientPageDto {
|
||||
/**
|
||||
* 账户类型编码
|
||||
*/
|
||||
@Dict(dictCode = "account_code")
|
||||
private String typeCode;
|
||||
private String typeCode_dictText;
|
||||
|
||||
/**
|
||||
* 账户余额
|
||||
@@ -92,4 +95,28 @@ public class EncounterPatientPageDto {
|
||||
/** 收费状态 */
|
||||
private Integer statusEnum;
|
||||
private String statusEnum_enumText;
|
||||
|
||||
/**
|
||||
* 医保总额
|
||||
*/
|
||||
private BigDecimal insurancePrice;
|
||||
|
||||
/**
|
||||
* 自费总额
|
||||
*/
|
||||
private BigDecimal selfPrice;
|
||||
|
||||
/**
|
||||
* 付款总额
|
||||
*/
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/** 合同类型 */
|
||||
private Integer categoryEnum;
|
||||
private String categoryEnum_enumText;
|
||||
|
||||
/**
|
||||
* 结算时间
|
||||
*/
|
||||
private Date billDate;
|
||||
}
|
||||
|
||||
@@ -53,13 +53,13 @@ public class EncounterPatientPageParam {
|
||||
*/
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 收费时间
|
||||
*/
|
||||
private Date billTime;
|
||||
|
||||
/**
|
||||
* 收费状态
|
||||
*/
|
||||
private Integer statusEnum;
|
||||
|
||||
/**
|
||||
* 退款标识
|
||||
*/
|
||||
private Integer refundFlag;
|
||||
}
|
||||
|
||||
@@ -14,4 +14,35 @@ import lombok.experimental.Accessors;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RefundItemDto {}
|
||||
public class RefundItemDto {
|
||||
|
||||
/** 收费ID */
|
||||
private Long chargeId;
|
||||
|
||||
/** 医疗服务所在表 */
|
||||
private String serviceTable;
|
||||
|
||||
/** 医疗服务ID */
|
||||
private Long serviceId;
|
||||
|
||||
/** 请求编码 */
|
||||
private String busNo;
|
||||
|
||||
/** 请求数量 */
|
||||
private Integer quantity;
|
||||
|
||||
/** 请求单位编码 */
|
||||
private String unitCode;
|
||||
|
||||
/** 退款状态 */
|
||||
private Integer refundStatus;
|
||||
|
||||
/** 项目id */
|
||||
private Long itemId;
|
||||
|
||||
/** 发放id */
|
||||
private Long dispenseId;
|
||||
|
||||
/** 项目名 */
|
||||
private Long itemName;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@ import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
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.EncounterPatientPaymentDto;
|
||||
import com.openhis.web.chargemanage.dto.RefundItemDto;
|
||||
|
||||
@@ -47,4 +52,17 @@ public interface OutpatientRefundAppMapper {
|
||||
@Param("medMedicationRequest") String medMedicationRequest,
|
||||
@Param("worServiceRequest") String worServiceRequest, @Param("worDeviceRequest") String worDeviceRequest,
|
||||
@Param("three") Integer three);
|
||||
|
||||
/**
|
||||
* 查询已结算就诊患者分页列表
|
||||
*
|
||||
* @param page 分页
|
||||
* @param queryWrapper 查询条件
|
||||
* @param billed 收费状态:已结算
|
||||
* @param insurance 账户类型:医保
|
||||
* @return 已结算就诊患者分页列表
|
||||
*/
|
||||
Page<EncounterPatientPageDto> selectBilledEncounterPatientPage(@Param("page") Page<EncounterPatientPageDto> page,
|
||||
@Param(Constants.WRAPPER) QueryWrapper<EncounterPatientPageParam> queryWrapper, @Param("billed") Integer billed,
|
||||
@Param("insurance") Integer insurance);
|
||||
}
|
||||
|
||||
@@ -246,6 +246,7 @@ public class ReceiptApprovalAppServiceImpl implements IReceiptApprovalAppService
|
||||
List<ItemChargeDetailDto> chargeDetailList) {
|
||||
List<ChargeItemDefDetail> resultList = new ArrayList<>();
|
||||
|
||||
// todo:同一批次不能改价
|
||||
// 将各个项目的定价信息按项目id分组
|
||||
Map<Long, List<ItemChargeDetailDto>> chargeDetailGroup =
|
||||
chargeDetailList.stream().collect(Collectors.groupingBy(ItemChargeDetailDto::getInstanceId));
|
||||
@@ -307,7 +308,7 @@ public class ReceiptApprovalAppServiceImpl implements IReceiptApprovalAppService
|
||||
*/
|
||||
private ChargeItemDefDetail addChargeItemDefApp(String conditionValue, BigDecimal sellPrice, Long definitionId) {
|
||||
ChargeItemDefDetail chargeItemDefDetail = new ChargeItemDefDetail();
|
||||
// todo:命中条件或建成字典枚举,此处为批次号,单位
|
||||
// todo:命中条件或建成字典枚举,此处为批次号,单位,优先级加一
|
||||
chargeItemDefDetail
|
||||
// 命中值
|
||||
.setConditionValue(conditionValue)
|
||||
|
||||
@@ -31,9 +31,6 @@ no.update.permission=您没有修改数据的权限,请联系管理员添加
|
||||
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
||||
|
||||
|
||||
|
||||
apl.common.M00001={0}添加成功
|
||||
apl.common.M00002={0}保存成功
|
||||
apl.common.M00003={0}已经存在
|
||||
@@ -43,4 +40,5 @@ apl.common.M00006=操作失败,该数据已被他人删除,请刷新后重试
|
||||
apl.common.M00007=操作失败,该数据已被他人更改,请刷新后重试
|
||||
apl.common.M00008=请勿重复提交
|
||||
apl.common.M00009=查询成功
|
||||
apl.common.M00010=操作失败,请联系管理员
|
||||
apl.common.M00010=操作失败,请联系管理员
|
||||
apl.chargeRefund.M00001=该收费单相关{0}已经发出,请先退药后再进行退费
|
||||
@@ -4,22 +4,23 @@
|
||||
|
||||
<select id="selectEncounterPatientPage"
|
||||
resultType="com.openhis.web.chargemanage.dto.EncounterPatientPageDto">
|
||||
SELECT T3.encounter_id,
|
||||
T3.encounter_bus_no,
|
||||
T3.start_time,
|
||||
T3.patient_name,
|
||||
T3.patient_bus_no,
|
||||
T3.gender_enum,
|
||||
T3.birth_date,
|
||||
T3.id_card,
|
||||
T3.patient_py_str,
|
||||
T3.patient_wb_str,
|
||||
T3.status_enum
|
||||
SELECT T4.encounter_id,
|
||||
T4.encounter_bus_no,
|
||||
T4.start_time,
|
||||
T4.patient_name,
|
||||
T4.patient_bus_no,
|
||||
T4.gender_enum,
|
||||
T4.birth_date,
|
||||
T4.id_card,
|
||||
T4.patient_py_str,
|
||||
T4.patient_wb_str,
|
||||
T4.status_enum
|
||||
FROM (
|
||||
SELECT T1.id AS encounter_id,
|
||||
SELECT T1.id AS encounter_id,
|
||||
T1.bus_no AS encounter_bus_no,
|
||||
T1.start_time,
|
||||
T1.delete_flag,
|
||||
T1.tenant_id,
|
||||
T2."name" AS patient_name,
|
||||
T2.bus_no AS patient_bus_no,
|
||||
T2.gender_enum,
|
||||
@@ -34,8 +35,8 @@
|
||||
LEFT JOIN adm_charge_item AS T3
|
||||
ON T3.encounter_id = T1.id
|
||||
WHERE T1.delete_flag = '0'
|
||||
ORDER BY T1.encounter_bus_no DESC
|
||||
) AS T3
|
||||
ORDER BY T1.bus_no DESC
|
||||
) AS T4
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
@@ -24,46 +24,144 @@
|
||||
AND T1.delete_flag = '0'
|
||||
</select>
|
||||
<select id="selectRefundItem" resultType="com.openhis.web.chargemanage.dto.RefundItemDto">
|
||||
SELECT (T1.discount_amount + T2.surcharge_amount) AS pay_amount,
|
||||
SELECT T1.id AS charge_id,
|
||||
T1.service_table,
|
||||
T1.service_id,
|
||||
T2.bus_no,
|
||||
T2.prescription_no,
|
||||
T2.quantity,
|
||||
T2.medication_id AS item_id,
|
||||
T2.unit_code,
|
||||
T3.status_enum
|
||||
T3.status_enum AS refund_status,
|
||||
T3.id AS dispense_id,
|
||||
T7.name AS item_name
|
||||
FROM adm_charge_item AS T1
|
||||
LEFT JOIN med_medication_request AS T2
|
||||
ON T2.bus_no = SUBSTRING(T1.bus_no, #{three})
|
||||
LEFT JOIN med_medication_dispense AS T3
|
||||
ON T3.med_req_id = T2.id
|
||||
ON T3.med_req_id = T2.id
|
||||
LEFT JOIN med_medication_definition AS T7
|
||||
ON T1.product_id = T7.id
|
||||
WHERE T1.service_table = #{medMedicationRequest}
|
||||
AND T1.id IN
|
||||
<foreach collection="chargeItemIdList" item="chargeItemId" separator="," open="(" close=")">
|
||||
#{chargeItemId}
|
||||
</foreach>
|
||||
UNION
|
||||
SELECT T1.*,
|
||||
T2.name AS service_name
|
||||
UNION
|
||||
SELECT T1.id AS charge_id,
|
||||
T1.service_table,
|
||||
T1.service_id,
|
||||
T4.bus_no,
|
||||
T4.prescription_no,
|
||||
T4.quantity,
|
||||
T4.device_def_id AS item_id,
|
||||
T4.unit_code,
|
||||
T5.status_enum AS refund_status,
|
||||
T5.id AS dispense_id,
|
||||
T8.name AS item_name
|
||||
FROM adm_charge_item AS T1
|
||||
LEFT JOIN wor_device_request AS T4
|
||||
ON T4.bus_no = SUBSTRING(T1.bus_no, #{three})
|
||||
LEFT JOIN wor_device_dispense AS T5
|
||||
ON T5.device_req_id = T4.id
|
||||
LEFT JOIN adm_device_definition AS T8
|
||||
ON T1.product_id = T8.id
|
||||
WHERE T1.service_table = #{worDeviceRequest}
|
||||
AND T1.id IN
|
||||
<foreach collection="chargeItemIdList" item="chargeItemId" separator="," open="(" close=")">
|
||||
#{chargeItemId}
|
||||
</foreach>
|
||||
UNION
|
||||
SELECT T1.*,
|
||||
T2.name AS service_name
|
||||
SELECT T1.id AS charge_id,,
|
||||
T1.service_table,
|
||||
T1.service_id,
|
||||
T6.bus_no,
|
||||
T6.prescription_no,
|
||||
T6.quantity,
|
||||
T6.activity_id AS item_id,
|
||||
T6.unit_code,
|
||||
T6.status_enum AS refund_status,
|
||||
null AS dispense_id,
|
||||
T9.name AS item_name
|
||||
FROM adm_charge_item AS T1
|
||||
LEFT JOIN wor_service_request AS T6
|
||||
ON T6.bus_no = SUBSTRING(T1.bus_no, #{three})
|
||||
LEFT JOIN wor_activity_definition AS T9
|
||||
ON T1.product_id = T9.id
|
||||
WHERE T1.service_table = #{worServiceRequest}
|
||||
AND T1.id IN
|
||||
<foreach collection="chargeItemIdList" item="chargeItemId" separator="," open="(" close=")">
|
||||
#{chargeItemId}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="selectBilledEncounterPatientPage"
|
||||
resultType="com.openhis.web.chargemanage.dto.EncounterPatientPageDto">
|
||||
SELECT T8.encounter_id,
|
||||
T8.encounter_bus_no,
|
||||
T8.start_time,
|
||||
T8.patient_name,
|
||||
T8.patient_bus_no,
|
||||
T8.gender_enum,
|
||||
T8.birth_date,
|
||||
T8.id_card,
|
||||
T8.patient_py_str,
|
||||
T8.patient_wb_str,
|
||||
T8.type_code,
|
||||
T8.category_enum,
|
||||
T8.total_amount,
|
||||
T8.bill_date
|
||||
FROM (
|
||||
SELECT T1.id AS encounter_id,
|
||||
T1.bus_no AS encounter_bus_no,
|
||||
T1.start_time,
|
||||
T1.delete_flag,
|
||||
T1.tenant_id,
|
||||
T2."name" AS patient_name,
|
||||
T2.bus_no AS patient_bus_no,
|
||||
T2.gender_enum,
|
||||
T2.birth_date,
|
||||
T2.id_card,
|
||||
T2.py_str AS patient_py_str,
|
||||
T2.wb_str AS patient_wb_str,
|
||||
T4.type_code,
|
||||
T5.category_enum,
|
||||
SUM(T6.tendered_amount) AS total_amount,
|
||||
T6.bill_date,
|
||||
CASE WHEN T7.account_enum = #{insurance} THEN SUM(T7.amount) ELSE 0 END AS insurance_amount,
|
||||
CASE WHEN T7.account_enum != #{insurance} THEN SUM(T7.amount) ELSE 0 END AS self_amount
|
||||
FROM adm_encounter AS T1
|
||||
LEFT JOIN adm_patient AS T2
|
||||
ON T1.patient_id = T2.id
|
||||
LEFT JOIN adm_charge_item AS T3
|
||||
ON T3.encounter_id = T1.id
|
||||
LEFT JOIN adm_account AS T4
|
||||
ON T4.id = T3.account_id
|
||||
LEFT JOIN fin_contract AS T5
|
||||
ON T5.bus_no = T4.contract_no
|
||||
LEFT JOIN fin_payment_reconciliation AS T6
|
||||
ON T6.encouter_id = T1.id
|
||||
LEFT JOIN fin_payment_rec_detail AS T7
|
||||
ON T7.reconciliation_id = T6.id
|
||||
WHERE T3.status_enum = #{billed}
|
||||
AND T1.delete_flag = '0'
|
||||
GROUP BY T1.id,
|
||||
T1.bus_no,
|
||||
T1.start_time,
|
||||
T1.delete_flag,
|
||||
T1.tenant_id,
|
||||
T2."name",
|
||||
T2.bus_no,
|
||||
T2.gender_enum,
|
||||
T2.birth_date,
|
||||
T2.id_card,
|
||||
T2.py_str,
|
||||
T2.wb_str,
|
||||
T4.type_code,
|
||||
T5.category_enum,
|
||||
T6.bill_date,
|
||||
T7.account_enum
|
||||
ORDER BY T6.bill_date DESC
|
||||
) AS T8
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user