bugfix:对账对平
This commit is contained in:
@@ -247,22 +247,37 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 医保对账:按险种和清算类别分组统计(不限制PayType) -->
|
||||
<!-- 医保对账:按险种和清算类别分组统计(按ReceiptNO去重,即HisTransId)
|
||||
1. 医疗总金额(MEDFEE_SUMAMT):统计同一收据号(HisTransId)下的自费总额,取该收据号的ZFAmount并按组求和
|
||||
2. 统筹金额(FUND_PAY_SUMAMT)和账户金额(ACCT_PAY):只统计PayType为9和10的记录,按收据号合并
|
||||
3. 按HisTransId去重合并统计金额 -->
|
||||
<select id="findMedicalInsuranceGroupData" parameterType="HashMap" resultType="HashMap">
|
||||
select
|
||||
insutype as INSUTYPE,
|
||||
clr_type as CLR_TYPE,
|
||||
count(1) as FIXMEDINS_SETL_CNT,
|
||||
cast(IFNULL(sum(Amount),0) as decimal(19,2)) as MEDFEE_SUMAMT,
|
||||
cast(IFNULL(sum(ybtcAmount),0) as decimal(19,2)) as FUND_PAY_SUMAMT,
|
||||
cast(IFNULL(sum(ybzhAmount),0) as decimal(19,2)) as ACCT_PAY
|
||||
from hisbill_history
|
||||
where trade_date = #{trade_date}
|
||||
and insutype is not null
|
||||
and insutype != ''
|
||||
and clr_type is not null
|
||||
and clr_type != ''
|
||||
group by insutype, clr_type
|
||||
order by insutype, clr_type
|
||||
select
|
||||
t.insutype as INSUTYPE,
|
||||
t.clr_type as CLR_TYPE,
|
||||
count(distinct t.HisTransId) as FIXMEDINS_SETL_CNT,
|
||||
cast(IFNULL(sum(t.ybtc),0) + IFNULL(sum(t.ybzh),0) + IFNULL(sum(t.zf),0) as decimal(19,2)) as MEDFEE_SUMAMT,
|
||||
cast(IFNULL(sum(t.ybtc),0) as decimal(19,2)) as FUND_PAY_SUMAMT,
|
||||
cast(IFNULL(sum(t.ybzh),0) as decimal(19,2)) as ACCT_PAY
|
||||
from (
|
||||
select
|
||||
insutype,
|
||||
clr_type,
|
||||
HisTransId,
|
||||
max(cast(IFNULL(ybtcAmount,0) as decimal(19,2))) as ybtc,
|
||||
max(cast(IFNULL(ybzhAmount,0) as decimal(19,2))) as ybzh,
|
||||
max(cast(IFNULL(zfAmount,0) as decimal(19,2))) as zf
|
||||
from hisbill_history
|
||||
where trade_date = #{trade_date}
|
||||
and insutype is not null
|
||||
and insutype != ''
|
||||
and clr_type is not null
|
||||
and clr_type != ''
|
||||
and HisTransId is not null
|
||||
and HisTransId != ''
|
||||
group by insutype, clr_type, HisTransId
|
||||
) as t
|
||||
group by t.insutype, t.clr_type
|
||||
order by t.insutype, t.clr_type
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
@@ -55,7 +55,9 @@
|
||||
|
||||
from hisbill_history
|
||||
where trade_date=#{trade_date}
|
||||
and PayMethod != '2' <!-- 排除PayMethod=2的记录,不参与对账 -->
|
||||
and PayMethod != '2'
|
||||
and cast(IFNULL(ybzhAmount,0) as decimal(19,2)) = 0
|
||||
and cast(IFNULL(ybtcAmount,0) as decimal(19,2)) = 0
|
||||
<if test="military_code != null and military_code != ''">
|
||||
and PayType != #{military_code}
|
||||
</if>
|
||||
@@ -68,6 +70,9 @@
|
||||
<if test="military_payment_code != null and military_payment_code != ''">
|
||||
and PayType != #{military_payment_code}
|
||||
</if>
|
||||
<if test="payType!=null and payType!=''">
|
||||
and PayType = #{payType}
|
||||
</if>
|
||||
<if test="tranID!=null and tranID!=''">
|
||||
and HisTransId=#{tranID}
|
||||
</if>
|
||||
@@ -140,4 +145,4 @@
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
156
src/main/resources/mapper/InpatientBillMapper.xml
Normal file
156
src/main/resources/mapper/InpatientBillMapper.xml
Normal file
@@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.saye.hospitalgd.mapper.InpatientBillMapper">
|
||||
|
||||
<!-- 查询HIS住院账单明细 -->
|
||||
<select id="findHisInpatientDetail" parameterType="HashMap" resultType="HashMap">
|
||||
select HisOperCode,
|
||||
PayMethod,
|
||||
TradingStatus,
|
||||
BizType,
|
||||
PayType,
|
||||
TradeTime,
|
||||
Amount,
|
||||
PlatformTransId,
|
||||
HisTransId,
|
||||
PatientId as PATIENTID,
|
||||
PatientName,
|
||||
trade_date
|
||||
from hisbill_history
|
||||
<where>
|
||||
PayMethod = '2' <!-- 住院账单 -->
|
||||
and PayType != '5' <!-- 排除现金支付 -->
|
||||
and PayType != '3' <!-- 排除军保支付(医院垫支) -->
|
||||
and PayType != '7' <!-- 排除预交金 -->
|
||||
and PayType != '9' <!-- 排除统筹支付 -->
|
||||
and PayType != '10' <!-- 排除账户支付 -->
|
||||
and PayType != '8'
|
||||
and PayType != '11'
|
||||
<if test="military_payment_code != null and military_payment_code != ''">
|
||||
and PayType != #{military_payment_code}
|
||||
</if>
|
||||
<if test="check_payment_code != null and check_payment_code != ''">
|
||||
and PayType != #{check_payment_code}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
and trade_date >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
and trade_date <= #{endTime}
|
||||
</if>
|
||||
<if test="payType != null and payType != ''">
|
||||
and PayType = #{payType}
|
||||
</if>
|
||||
<if test="bizType != null and bizType != ''">
|
||||
and BizType = #{bizType}
|
||||
</if>
|
||||
<if test="likeFiled != null and likeFiled != ''">
|
||||
and (PlatformTransId like concat('%', #{likeFiled}, '%')
|
||||
or HisTransId like concat('%', #{likeFiled}, '%')
|
||||
or PatientId like concat('%', #{likeFiled}, '%')
|
||||
or PatientName like concat('%', #{likeFiled}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
order by trade_date desc, TradeTime desc
|
||||
</select>
|
||||
|
||||
<!-- 查询银行住院账单明细 -->
|
||||
<select id="findBankInpatientDetail" parameterType="HashMap" resultType="HashMap">
|
||||
select C_JYRQ,
|
||||
C_JYSJ,
|
||||
C_QSRQ,
|
||||
C_LSH,
|
||||
C_SHDDH,
|
||||
C_YSDDH,
|
||||
C_JYLX,
|
||||
C_CARD,
|
||||
C_FKH,
|
||||
C_JYJE,
|
||||
C_QSJE,
|
||||
C_SXF,
|
||||
C_SJZFJE,
|
||||
C_ZDH,
|
||||
C_ZFFS,
|
||||
C_KLX
|
||||
from bankbill_history
|
||||
<where>
|
||||
is_inpatient = '1' <!-- 住院订单 -->
|
||||
<if test="startTime != null and startTime != ''">
|
||||
and C_JYRQ >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
and C_JYRQ <= #{endTime}
|
||||
</if>
|
||||
<if test="c_zffs != null and c_zffs != ''">
|
||||
and C_ZFFS = #{c_zffs}
|
||||
</if>
|
||||
<if test="likeFiled != null and likeFiled != ''">
|
||||
and (C_YSDDH like concat('%', #{likeFiled}, '%')
|
||||
or C_SHDDH like concat('%', #{likeFiled}, '%')
|
||||
or C_LSH like concat('%', #{likeFiled}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
order by C_JYRQ desc, C_JYSJ desc
|
||||
</select>
|
||||
|
||||
<!-- 查询每日汇总数据(按日期汇总 HIS 与 银行住院账单,各一条记录) -->
|
||||
<select id="findDailySummary" parameterType="HashMap" resultType="HashMap">
|
||||
select
|
||||
t.TRADE_DATE,
|
||||
sum(t.HIS_COUNT) as HIS_COUNT,
|
||||
sum(t.HIS_AMOUNT) as HIS_AMOUNT,
|
||||
sum(t.BANK_COUNT) as BANK_COUNT,
|
||||
sum(t.BANK_AMOUNT) as BANK_AMOUNT
|
||||
from (
|
||||
-- HIS 住院汇总
|
||||
select
|
||||
trade_date as TRADE_DATE,
|
||||
count(distinct PlatformTransId) as HIS_COUNT,
|
||||
ifnull(sum(cast(Amount as decimal(18,2))), 0) as HIS_AMOUNT,
|
||||
0 as BANK_COUNT,
|
||||
0 as BANK_AMOUNT
|
||||
from hisbill_history
|
||||
where PayMethod = '2'
|
||||
and PayType != '5' <!-- 排除现金支付 -->
|
||||
and PayType != '3' <!-- 排除军保支付(医院垫支) -->
|
||||
and PayType != '7' <!-- 排除预交金 -->
|
||||
and PayType != '9' <!-- 排除统筹支付 -->
|
||||
and PayType != '10' <!-- 排除账户支付 -->
|
||||
<if test="military_payment_code != null and military_payment_code != ''">
|
||||
and PayType != #{military_payment_code}
|
||||
</if>
|
||||
<if test="check_payment_code != null and check_payment_code != ''">
|
||||
and PayType != #{check_payment_code}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
and trade_date >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
and trade_date <= #{endTime}
|
||||
</if>
|
||||
group by trade_date
|
||||
|
||||
union all
|
||||
|
||||
-- 银行住院汇总
|
||||
select
|
||||
C_JYRQ as TRADE_DATE,
|
||||
0 as HIS_COUNT,
|
||||
0 as HIS_AMOUNT,
|
||||
count(1) as BANK_COUNT,
|
||||
ifnull(sum(cast(C_JYJE as decimal(18,2))), 0) as BANK_AMOUNT
|
||||
from bankbill_history
|
||||
where is_inpatient = '1'
|
||||
<if test="startTime != null and startTime != ''">
|
||||
and C_JYRQ >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
and C_JYRQ <= #{endTime}
|
||||
</if>
|
||||
group by C_JYRQ
|
||||
) t
|
||||
group by t.TRADE_DATE
|
||||
order by t.TRADE_DATE desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -123,6 +123,8 @@
|
||||
, '1'
|
||||
from (select * from hisbill_history where trade_date = #{trade_date} and payType!=#{cash_code}
|
||||
and PayMethod != '2' -- 排除不参与对账的记录
|
||||
and PayType != '9' -- 排除账户支付,不参与常规对账
|
||||
and PayType != '10' -- 排除统筹支付,不参与常规对账
|
||||
<if test="military_code != null and military_code != ''">
|
||||
and payType!=#{military_code}
|
||||
</if>
|
||||
@@ -167,6 +169,8 @@
|
||||
, '1'
|
||||
from (select * from hisbill_history where trade_date = #{trade_date} and payType!=#{cash_code}
|
||||
and PayMethod != '2' -- 排除不参与对账的记录
|
||||
and PayType != '9' -- 排除账户支付,不参与常规对账
|
||||
and PayType != '10' -- 排除统筹支付,不参与常规对账
|
||||
<if test="military_code != null and military_code != ''">
|
||||
and payType!=#{military_code}
|
||||
</if>
|
||||
@@ -212,6 +216,8 @@
|
||||
, '1'
|
||||
from (select * from hisbill_history where trade_date = #{trade_date} and payType!=#{cash_code}
|
||||
and PayMethod != '2' -- 排除不参与对账的记录
|
||||
and PayType != '9' -- 排除账户支付,不参与常规对账
|
||||
and PayType != '10' -- 排除统筹支付,不参与常规对账
|
||||
<if test="military_code != null and military_code != ''">
|
||||
and payType!=#{military_code}
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user