|
@@ -52,7 +52,7 @@
|
|
|
<select id="listClcMedOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
SELECT
|
|
|
cpi.prescription_id AS store_order_no,
|
|
|
- '99999999' AS mis_no,
|
|
|
+ if(ifnull(ics.settle_transaction_id,'')='','999999999',ics.settle_transaction_id) as mis_no,
|
|
|
cpi.states AS settledstatus,
|
|
|
ROUND(cpi.price,2) AS total_amt,
|
|
|
0 AS insurance_amt,
|
|
@@ -63,7 +63,7 @@
|
|
|
'0000000000000' AS credential_num,
|
|
|
IF( cm.medicine_category = '04', '2', '1') AS item_type,
|
|
|
cso.medicine_name AS store_medicine_name,
|
|
|
- cso.med_ins_backup_id AS store_medicine_code,
|
|
|
+ IF( length( cso.med_ins_backup_id ) > 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
'' AS plat_item_code,
|
|
|
'' AS plat_item_name,
|
|
|
if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
@@ -112,6 +112,11 @@
|
|
|
ON
|
|
|
cso.stock_detail_id = csd.id
|
|
|
and cso.clinic_id = csd.clinic_id
|
|
|
+ left join
|
|
|
+ ins_clinic_settlement as ics
|
|
|
+ on
|
|
|
+ ics.clinic_id = csd.clinic_id
|
|
|
+ and cpi.prescription_id = ics.prescription_id
|
|
|
WHERE
|
|
|
cso.clinic_id = #{clinicId}
|
|
|
AND
|
|
@@ -119,6 +124,27 @@
|
|
|
AND
|
|
|
cso.change_type in (1, 2)
|
|
|
and cso.source_type = 1
|
|
|
+ <choose>
|
|
|
+ <when test='dateType == "d" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} day) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "m" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} month) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "y" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} year) and now()
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ <if test='dateType == "s" and startDate != "" and startDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and cso.create_time >= str_to_date(#{startDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
+ <if test='dateType == "s" and endDate != "" and endDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and cso.create_time <= str_to_date(#{endDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
cso.id
|
|
|
</select>
|
|
@@ -126,7 +152,7 @@
|
|
|
<select id="listClcChinaMedOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
SELECT
|
|
|
cpi.prescription_id AS store_order_no,
|
|
|
- '99999999' AS mis_no,
|
|
|
+ if(ifnull(ics.settle_transaction_id,'')='','999999999',ics.settle_transaction_id) as mis_no,
|
|
|
cpi.states AS settledstatus,
|
|
|
ROUND(cpi.price,2) AS total_amt,
|
|
|
0 AS insurance_amt,
|
|
@@ -138,7 +164,7 @@
|
|
|
IF
|
|
|
( ccm.medicine_category = '04', 2, 1 ) AS item_type,
|
|
|
ccso.medicine_name AS store_medicine_name,
|
|
|
- ccso.med_ins_backup_id AS store_medicine_code,
|
|
|
+ IF( length( ccso.med_ins_backup_id ) > 0, ccm.med_ins_backup_id, ccm.medicine_id ) AS store_medicine_code,
|
|
|
'' AS plat_item_code,
|
|
|
'' AS plat_item_name,
|
|
|
if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
@@ -187,6 +213,11 @@
|
|
|
ON
|
|
|
ccso.stock_detail_id = ccsp.id
|
|
|
and ccso.clinic_id = ccsp.clinic_id
|
|
|
+ left join
|
|
|
+ ins_clinic_settlement as ics
|
|
|
+ on
|
|
|
+ ics.clinic_id = ccso.clinic_id
|
|
|
+ and cpi.prescription_id = ics.prescription_id
|
|
|
WHERE
|
|
|
ccso.clinic_id = #{clinicId}
|
|
|
AND
|
|
@@ -194,6 +225,27 @@
|
|
|
AND
|
|
|
ccso.change_type in (1, 2)
|
|
|
and ccso.source_type = 1
|
|
|
+ <choose>
|
|
|
+ <when test='dateType == "d" and count != null'>
|
|
|
+ and ccso.create_time between date_sub(curdate(), interval #{count} day) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "m" and count != null'>
|
|
|
+ and ccso.create_time between date_sub(curdate(), interval #{count} month) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "y" and count != null'>
|
|
|
+ and ccso.create_time between date_sub(curdate(), interval #{count} year) and now()
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ <if test='dateType == "s" and startDate != "" and startDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and ccso.create_time >= str_to_date(#{startDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
+ <if test='dateType == "s" and endDate != "" and endDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and ccso.create_time <= str_to_date(#{endDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
ccso.id
|
|
|
</select>
|
|
@@ -201,10 +253,10 @@
|
|
|
<select id="listInsClcMedOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
SELECT
|
|
|
cpi.prescription_id AS store_order_no,
|
|
|
- '99999999' AS mis_no,
|
|
|
+ if(ifnull(ics.settle_transaction_id,'')='','999999999',ics.settle_transaction_id) as mis_no,
|
|
|
cpi.states AS settledstatus,
|
|
|
ROUND(cpi.price,2) AS total_amt,
|
|
|
- ifnull( ROUND(ids.ordinate_total_score,2), '0.00' ) AS insurance_amt,
|
|
|
+ ifnull( ROUND(ics.insurance_pay,2), '0.00' ) AS insurance_amt,
|
|
|
cso.doctor_name AS operater,
|
|
|
SUBSTR( cso.create_time, 1, 10 ) AS sale_date,
|
|
|
cso.create_time AS sale_time,
|
|
@@ -212,7 +264,7 @@
|
|
|
'0000000000000' AS credential_num,
|
|
|
IF( cm.medicine_category = '04', 2, 1 ) AS item_type,
|
|
|
cso.medicine_name AS store_medicine_name,
|
|
|
- cso.med_ins_backup_id AS store_medicine_code,
|
|
|
+ IF( length( cso.med_ins_backup_id ) > 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
'' AS plat_item_code,
|
|
|
'' AS plat_item_name,
|
|
|
if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
@@ -252,13 +304,32 @@
|
|
|
left join ins_clinic_settlement ics
|
|
|
on ics.prescription_id = cso.prescription_id
|
|
|
and ics.clinic_id = cso.clinic_id
|
|
|
- LEFT JOIN ins_d_settlement ids ON ids.settlement_id = ics.id
|
|
|
- AND ids.clinic_id = cso.clinic_id
|
|
|
WHERE
|
|
|
cso.clinic_id = #{clinicId}
|
|
|
AND cpi.prescription_type = 0
|
|
|
AND cso.change_type IN ( 1, 2 )
|
|
|
AND cso.source_type IN ( 2, 3 )
|
|
|
+ <choose>
|
|
|
+ <when test='dateType == "d" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} day) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "m" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} month) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "y" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} year) and now()
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ <if test='dateType == "s" and startDate != "" and startDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and cso.create_time >= str_to_date(#{startDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
+ <if test='dateType == "s" and endDate != "" and endDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and cso.create_time <= str_to_date(#{endDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
cso.id
|
|
|
</select>
|
|
@@ -266,10 +337,10 @@
|
|
|
<select id="listInsClcChinaMedOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
SELECT
|
|
|
cpi.prescription_id AS store_order_no,
|
|
|
- '99999999' AS mis_no,
|
|
|
+ if(ifnull(ics.settle_transaction_id,'')='','999999999',ics.settle_transaction_id) as mis_no,
|
|
|
cpi.states AS settledstatus,
|
|
|
ROUND(cpi.price,2) AS total_amt,
|
|
|
- ifnull( ROUND(ids.ordinate_total_score,2), '0.00' ) AS insurance_amt,
|
|
|
+ ifnull( ROUND(ics.insurance_pay,2), '0.00' ) AS insurance_amt,
|
|
|
cso.doctor_name AS operater,
|
|
|
SUBSTR( cso.create_time, 1, 10 ) AS sale_date,
|
|
|
cso.create_time AS sale_time,
|
|
@@ -277,7 +348,7 @@
|
|
|
'0000000000000' AS credential_num,
|
|
|
IF( ccm.medicine_category = '04', 2, 1 ) AS item_type,
|
|
|
cso.medicine_name AS store_medicine_name,
|
|
|
- cso.med_ins_backup_id AS store_medicine_code,
|
|
|
+ IF( length( cso.med_ins_backup_id ) > 0, ccm.med_ins_backup_id, ccm.medicine_id ) AS store_medicine_code,
|
|
|
'' AS plat_item_code,
|
|
|
'' AS plat_item_name,
|
|
|
if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
@@ -321,14 +392,32 @@
|
|
|
LEFT JOIN ins_clinic_settlement ics
|
|
|
ON ics.prescription_id = cso.prescription_id
|
|
|
AND ics.clinic_id = cso.clinic_id
|
|
|
- LEFT JOIN ins_d_settlement ids
|
|
|
- ON ids.settlement_id = ics.id
|
|
|
- AND ids.clinic_id = cso.clinic_id
|
|
|
WHERE
|
|
|
cso.clinic_id = #{clinicId}
|
|
|
AND cpi.prescription_type = 1
|
|
|
AND cso.change_type IN ( 1, 2 )
|
|
|
AND cso.source_type in (2, 3)
|
|
|
+ <choose>
|
|
|
+ <when test='dateType == "d" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} day) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "m" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} month) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "y" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} year) and now()
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ <if test='dateType == "s" and startDate != "" and startDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and cso.create_time >= str_to_date(#{startDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
+ <if test='dateType == "s" and endDate != "" and endDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and cso.create_time <= str_to_date(#{endDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
cso.id
|
|
|
</select>
|
|
@@ -336,10 +425,10 @@
|
|
|
<select id="listHosMedOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
SELECT
|
|
|
cpi.prescription_id AS store_order_no,
|
|
|
- '99999999' AS mis_no,
|
|
|
+ if(ifnull(ics.settle_transaction_id,'')='','999999999',ics.settle_transaction_id) as mis_no,
|
|
|
cpi.states AS settledstatus,
|
|
|
ROUND(cpi.price,2) AS total_amt,
|
|
|
- ifnull( ROUND(ids.ordinate_total_score,2), '0.00' ) AS insurance_amt,
|
|
|
+ ifnull( ROUND(ics.insurance_pay,2), '0.00' ) AS insurance_amt,
|
|
|
cso.doctor_name AS operater,
|
|
|
SUBSTR( cso.create_time, 1, 10 ) AS sale_date,
|
|
|
cso.create_time AS sale_time,
|
|
@@ -348,7 +437,7 @@
|
|
|
IF
|
|
|
( cm.medicine_category = '04', 2, 1 ) AS item_type,
|
|
|
cso.medicine_name AS store_medicine_name,
|
|
|
- cso.med_ins_backup_id AS store_medicine_code,
|
|
|
+ IF( length( cso.med_ins_backup_id ) > 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
'' AS plat_item_code,
|
|
|
'' AS plat_item_name,
|
|
|
if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
@@ -390,24 +479,35 @@
|
|
|
ON cso.stock_detail_id = csd.id
|
|
|
AND cso.clinic_id = csd.clinic_id
|
|
|
AND cso.medicine_id = csd.medicine_id
|
|
|
- LEFT JOIN (
|
|
|
- SELECT
|
|
|
- t.clinic_id,
|
|
|
- t.total_score,
|
|
|
- t.ordinate_total_score,
|
|
|
- t.settlement_id,
|
|
|
- t.visit_code
|
|
|
- FROM
|
|
|
- ins_d_settlement t
|
|
|
- WHERE
|
|
|
- t.settlement_id IN ( SELECT settlement_id FROM ins_d_settlement GROUP BY settlement_id HAVING count( settlement_id ) = 1 )
|
|
|
- ) ids ON ids.visit_code = cpi.visit_code
|
|
|
- AND ids.clinic_id = cso.clinic_id
|
|
|
+ LEFT JOIN ins_clinic_settlement ics
|
|
|
+ ON ics.prescription_id = cso.prescription_id
|
|
|
+ AND ics.clinic_id = cso.clinic_id
|
|
|
WHERE
|
|
|
cso.clinic_id = #{clinicId}
|
|
|
AND cpi.prescription_type = 0
|
|
|
AND cso.change_type IN ( 1, 2 )
|
|
|
AND cso.source_type = 4
|
|
|
+ <choose>
|
|
|
+ <when test='dateType == "d" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} day) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "m" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} month) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "y" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} year) and now()
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ <if test='dateType == "s" and startDate != "" and startDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and cso.create_time >= str_to_date(#{startDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
+ <if test='dateType == "s" and endDate != "" and endDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and cso.create_time <= str_to_date(#{endDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
cso.id
|
|
|
</select>
|
|
@@ -415,10 +515,10 @@
|
|
|
<select id="listHosChinaMedOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
SELECT
|
|
|
cpi.prescription_id AS store_order_no,
|
|
|
- '99999999' AS mis_no,
|
|
|
+ if(ifnull(ics.settle_transaction_id,'')='','999999999',ics.settle_transaction_id) as mis_no,
|
|
|
cpi.states AS settledstatus,
|
|
|
ROUND(cpi.price,2) AS total_amt,
|
|
|
- ifnull( ROUND(ids.ordinate_total_score,2), '0.00' ) AS insurance_amt,
|
|
|
+ ifnull( ROUND(ics.ordinate_total_score,2), '0.00' ) AS insurance_amt,
|
|
|
cso.doctor_name AS operater,
|
|
|
SUBSTR( cso.create_time, 1, 10 ) AS sale_date,
|
|
|
cso.create_time AS sale_time,
|
|
@@ -427,7 +527,7 @@
|
|
|
IF
|
|
|
( ccm.medicine_category = '04', 2, 1 ) AS item_type,
|
|
|
cso.medicine_name AS store_medicine_name,
|
|
|
- cso.med_ins_backup_id AS store_medicine_code,
|
|
|
+ IF( length( cso.med_ins_backup_id ) > 0, ccm.med_ins_backup_id, ccm.medicine_id ) AS store_medicine_code,
|
|
|
'' AS plat_item_code,
|
|
|
'' AS plat_item_name,
|
|
|
if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
@@ -468,24 +568,35 @@
|
|
|
LEFT JOIN clc_china_stock_profit csd
|
|
|
ON cso.stock_detail_id = csd.id
|
|
|
AND cso.clinic_id = csd.clinic_id
|
|
|
- LEFT JOIN (
|
|
|
- SELECT
|
|
|
- t.clinic_id,
|
|
|
- t.total_score,
|
|
|
- t.ordinate_total_score,
|
|
|
- t.settlement_id,
|
|
|
- t.visit_code
|
|
|
- FROM
|
|
|
- ins_d_settlement t
|
|
|
- WHERE
|
|
|
- t.settlement_id IN ( SELECT settlement_id FROM ins_d_settlement GROUP BY settlement_id HAVING count( settlement_id ) = 1 )
|
|
|
- ) ids ON ids.visit_code = cpi.visit_code
|
|
|
- AND ids.clinic_id = cso.clinic_id
|
|
|
+ LEFT JOIN ins_clinic_settlement ics
|
|
|
+ ON ics.prescription_id = cso.prescription_id
|
|
|
+ AND ics.clinic_id = cso.clinic_id
|
|
|
WHERE
|
|
|
cso.clinic_id = #{clinicId}
|
|
|
AND cpi.prescription_type = 1
|
|
|
AND cso.change_type IN ( 1, 2 )
|
|
|
AND cso.source_type = 4
|
|
|
+ <choose>
|
|
|
+ <when test='dateType == "d" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} day) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "m" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} month) and now()
|
|
|
+ </when>
|
|
|
+ <when test='dateType == "y" and count != null'>
|
|
|
+ and cso.create_time between date_sub(curdate(), interval #{count} year) and now()
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ <if test='dateType == "s" and startDate != "" and startDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and cso.create_time >= str_to_date(#{startDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
+ <if test='dateType == "s" and endDate != "" and endDate != null'>
|
|
|
+ <![CDATA[
|
|
|
+ and cso.create_time <= str_to_date(#{endDate},'%Y%m%d')
|
|
|
+ ]]>
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
cso.id
|
|
|
</select>
|