|
@@ -86,32 +86,389 @@
|
|
|
cso.if_piece as is_unpacking
|
|
|
FROM
|
|
|
clc_stock_outbound cso
|
|
|
- LEFT JOIN clc_prescription_info cpi ON cpi.prescription_id = cso.prescription_id
|
|
|
- AND cso.clinic_id = cpi.clinic_id
|
|
|
- LEFT JOIN ins_clinic_settlement ics ON cpi.prescription_id = ics.prescription_id
|
|
|
- LEFT JOIN clc_medicine cm ON cso.medicine_id = cm.medicine_id
|
|
|
- LEFT JOIN ins_d_medicine idm ON cso.medicine_id = idm.medicine_id
|
|
|
- LEFT JOIN clc_stock_detail csd ON cso.timestamp_number = csd.timestamp_number and cso.medicine_id = csd.medicine_id
|
|
|
+ LEFT JOIN
|
|
|
+ clc_prescription_info cpi
|
|
|
+ ON
|
|
|
+ cpi.prescription_id = cso.prescription_id
|
|
|
+ AND cso.clinic_id = cpi.clinic_id
|
|
|
+ LEFT JOIN
|
|
|
+ clc_medicine cm
|
|
|
+ ON
|
|
|
+ cso.medicine_id = cm.medicine_id
|
|
|
+ and cpi.clinic_id = cso.clinic_id
|
|
|
+ LEFT JOIN
|
|
|
+ ins_d_medicine idm
|
|
|
+ ON
|
|
|
+ cso.medicine_id = idm.medicine_id
|
|
|
+ and cso.clinic_id = idm.clinic_id
|
|
|
+ LEFT JOIN
|
|
|
+ clc_stock_detail csd
|
|
|
+ ON
|
|
|
+ cso.timestamp_number = csd.timestamp_number
|
|
|
+ and cso.medicine_id = csd.medicine_id
|
|
|
+ and cso.clinic_id = csd.clinic_id
|
|
|
WHERE
|
|
|
cso.clinic_id = #{clinicId}
|
|
|
- AND cpi.prescription_type = 0
|
|
|
+ AND
|
|
|
+ cpi.prescription_type = 0
|
|
|
+ AND
|
|
|
+ cso.change_type in (1, 2)
|
|
|
and cso.source_type = 1
|
|
|
- AND ics.id IS NULL
|
|
|
GROUP BY
|
|
|
cso.id
|
|
|
</select>
|
|
|
|
|
|
- <select id="listInsCliSettlementOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
-
|
|
|
+ <select id="listClcChinaMedOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
+ SELECT
|
|
|
+ cpi.prescription_id AS store_order_no,
|
|
|
+ '99999999' AS mis_no,
|
|
|
+ states AS settledstatus,
|
|
|
+ cpi.price AS total_amt,
|
|
|
+ 0 AS insurance_amt,
|
|
|
+ cso.doctor_name AS operater,
|
|
|
+ SUBSTR( cso.stock_date, 1, 10 ) AS sale_date,
|
|
|
+ cso.stock_date AS sale_time,
|
|
|
+ cso.patient_name AS buy_med_person,
|
|
|
+ '0000000000000' AS credential_num,
|
|
|
+ IF
|
|
|
+ ( ccm.medicine_category = '04', 2, 1 ) AS item_type,
|
|
|
+ ccm.medicine_name AS store_medicine_name,
|
|
|
+ IF
|
|
|
+ ( length( ccm.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,
|
|
|
+ idm.med_ins_backup_id AS item_code,
|
|
|
+ idm.insurance_medicine_name AS item_name,
|
|
|
+ '0000000000000' AS store_precord_code,
|
|
|
+ '0000000000000' AS store_storage_code,
|
|
|
+ cpi.prescription_id AS recipe_no,
|
|
|
+ ifnull( idm.formulation, " " ) AS dosage_id,
|
|
|
+ ccm.medicine_rate_last AS dosage_name,
|
|
|
+ ccm.medicine_specifications AS specification,
|
|
|
+ ccm.medicine_manufacturer_name AS manufacturer,
|
|
|
+ ccm.medicine_address AS place,
|
|
|
+ idm.medicine_package AS pack,
|
|
|
+ " " AS model,
|
|
|
+ csd.stock_batch_number AS batch_no,
|
|
|
+ csd.create_time AS manufacture_time,
|
|
|
+ csd.medicine_deadline AS medicine_deadline,
|
|
|
+ '00000000' AS bar_code,
|
|
|
+ "" AS regist_no,
|
|
|
+ csd.stock_channel AS delivery_company,
|
|
|
+ "999999999" AS distributor,
|
|
|
+ csd.stock_bid AS price,
|
|
|
+ idm.sale_price AS retail_price,
|
|
|
+ cso.change_number AS num,
|
|
|
+ cso.if_piece AS is_unpacking
|
|
|
+ FROM
|
|
|
+ clc_stock_outbound cso
|
|
|
+ LEFT JOIN
|
|
|
+ clc_prescription_info cpi
|
|
|
+ ON
|
|
|
+ cpi.prescription_id = cso.prescription_id
|
|
|
+ AND cso.clinic_id = cpi.clinic_id
|
|
|
+ LEFT JOIN
|
|
|
+ clc_china_medicine ccm
|
|
|
+ ON
|
|
|
+ cso.medicine_id = ccm.medicine_id
|
|
|
+ and cso.clinic_id = ccm.clinic_id
|
|
|
+ LEFT JOIN
|
|
|
+ ins_d_medicine idm
|
|
|
+ ON
|
|
|
+ cso.medicine_id = idm.medicine_id
|
|
|
+ and cso.clinic_id = idm.clinic_id
|
|
|
+ LEFT JOIN
|
|
|
+ clc_stock_detail csd
|
|
|
+ ON
|
|
|
+ cso.timestamp_number = csd.timestamp_number
|
|
|
+ and cso.clinic_id = csd.clinic_id
|
|
|
+ AND cso.medicine_id = csd.medicine_id
|
|
|
+ WHERE
|
|
|
+ cso.clinic_id = #{clinicId}
|
|
|
+ AND
|
|
|
+ cpi.prescription_type = 1
|
|
|
+ AND
|
|
|
+ cso.change_type in (1, 2)
|
|
|
+ and cso.source_type = 1
|
|
|
+ GROUP BY
|
|
|
+ cso.id
|
|
|
</select>
|
|
|
|
|
|
- <select id="listHosSettlementOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
-
|
|
|
+ <select id="listInsClcMedOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
+ SELECT
|
|
|
+ cpi.prescription_id AS store_order_no,
|
|
|
+ '99999999' AS mis_no,
|
|
|
+ states AS settledstatus,
|
|
|
+ cpi.price AS total_amt,
|
|
|
+ ifnull( ids.ordinate_total_score, 0 ) AS insurance_amt,
|
|
|
+ cso.doctor_name AS operater,
|
|
|
+ SUBSTR( cso.stock_date, 1, 10 ) AS sale_date,
|
|
|
+ cso.stock_date AS sale_time,
|
|
|
+ cso.patient_name AS buy_med_person,
|
|
|
+ '0000000000000' AS credential_num,
|
|
|
+ IF( cm.medicine_category = '04', 2, 1 ) AS item_type,
|
|
|
+ cm.medicine_c_name AS store_medicine_name,
|
|
|
+ cm.medicine_id AS store_medicine_code,
|
|
|
+ '' AS plat_item_code,
|
|
|
+ '' AS plat_item_name,
|
|
|
+ idm.med_ins_backup_id AS item_code,
|
|
|
+ idm.insurance_medicine_name AS item_name,
|
|
|
+ '0000000000000' AS store_precord_code,
|
|
|
+ '0000000000000' AS store_storage_code,
|
|
|
+ cpi.prescription_id AS recipe_no,
|
|
|
+ ifnull( idm.formulation, " " ) AS dosage_id,
|
|
|
+ cm.medicine_dosage_forms AS dosage_name,
|
|
|
+ cm.medicine_specifications AS specification,
|
|
|
+ cm.medicine_manufacturer_name AS manufacturer,
|
|
|
+ cm.medicine_place AS place,
|
|
|
+ idm.medicine_package AS pack,
|
|
|
+ " " AS model,
|
|
|
+ csd.stock_batch_number AS batch_no,
|
|
|
+ csd.create_time AS manufacture_time,
|
|
|
+ csd.medicine_deadline AS medicine_deadline,
|
|
|
+ cm.medicine_barcode AS bar_code,
|
|
|
+ "" AS regist_no,
|
|
|
+ csd.stock_channel AS delivery_company,
|
|
|
+ "999999999" AS distributor,
|
|
|
+ csd.stock_bid AS price,
|
|
|
+ idm.sale_price AS retail_price,
|
|
|
+ cso.change_number AS num,
|
|
|
+ cso.if_piece AS is_unpacking
|
|
|
+ FROM
|
|
|
+ clc_stock_outbound cso
|
|
|
+ LEFT JOIN clc_prescription_info cpi ON cpi.prescription_id = cso.prescription_id
|
|
|
+ AND cso.clinic_id = cpi.clinic_id
|
|
|
+ LEFT JOIN clc_medicine cm ON cso.medicine_id = cm.medicine_id
|
|
|
+ AND cpi.clinic_id = cso.clinic_id
|
|
|
+ LEFT JOIN ins_d_medicine idm ON cso.medicine_id = idm.medicine_id
|
|
|
+ AND cso.clinic_id = idm.clinic_id
|
|
|
+ LEFT JOIN clc_stock_detail csd ON cso.timestamp_number = csd.timestamp_number
|
|
|
+ AND cso.medicine_id = csd.medicine_id
|
|
|
+ AND cso.clinic_id = csd.clinic_id
|
|
|
+ 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 )
|
|
|
+ GROUP BY
|
|
|
+ cso.id
|
|
|
</select>
|
|
|
|
|
|
- <select id="listInsHosSettlementOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
-
|
|
|
+ <select id="listInsClcChinaMedOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
+ SELECT
|
|
|
+ cpi.prescription_id AS store_order_no,
|
|
|
+ '99999999' AS mis_no,
|
|
|
+ states AS settledstatus,
|
|
|
+ cpi.price AS total_amt,
|
|
|
+ ifnull( ids.ordinate_total_score, 0 ) AS insurance_amt,
|
|
|
+ cso.doctor_name AS operater,
|
|
|
+ SUBSTR( cso.stock_date, 1, 10 ) AS sale_date,
|
|
|
+ cso.stock_date AS sale_time,
|
|
|
+ cso.patient_name AS buy_med_person,
|
|
|
+ '0000000000000' AS credential_num,
|
|
|
+ IF( ccm.medicine_category = '04', 2, 1 ) AS item_type,
|
|
|
+ ccm.medicine_name AS store_medicine_name,
|
|
|
+ IF( length( ccm.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,
|
|
|
+ idm.med_ins_backup_id AS item_code,
|
|
|
+ idm.insurance_medicine_name AS item_name,
|
|
|
+ '0000000000000' AS store_precord_code,
|
|
|
+ '0000000000000' AS store_storage_code,
|
|
|
+ cpi.prescription_id AS recipe_no,
|
|
|
+ ifnull( idm.formulation, " " ) AS dosage_id,
|
|
|
+ ccm.medicine_rate_last AS dosage_name,
|
|
|
+ ccm.medicine_specifications AS specification,
|
|
|
+ ccm.medicine_manufacturer_name AS manufacturer,
|
|
|
+ ccm.medicine_address AS place,
|
|
|
+ idm.medicine_package AS pack,
|
|
|
+ " " AS model,
|
|
|
+ csd.stock_batch_number AS batch_no,
|
|
|
+ csd.create_time AS manufacture_time,
|
|
|
+ csd.medicine_deadline AS medicine_deadline,
|
|
|
+ '00000000' AS bar_code,
|
|
|
+ "" AS regist_no,
|
|
|
+ csd.stock_channel AS delivery_company,
|
|
|
+ "999999999" AS distributor,
|
|
|
+ csd.stock_bid AS price,
|
|
|
+ idm.sale_price AS retail_price,
|
|
|
+ cso.change_number AS num,
|
|
|
+ cso.if_piece AS is_unpacking
|
|
|
+ FROM
|
|
|
+ clc_stock_outbound cso
|
|
|
+ LEFT JOIN clc_prescription_info cpi ON cpi.prescription_id = cso.prescription_id
|
|
|
+ AND cso.clinic_id = cpi.clinic_id
|
|
|
+ LEFT JOIN clc_china_medicine ccm ON cso.medicine_id = ccm.medicine_id
|
|
|
+ AND cso.clinic_id = ccm.clinic_id
|
|
|
+ LEFT JOIN ins_d_medicine idm ON cso.medicine_id = idm.medicine_id
|
|
|
+ AND cso.clinic_id = idm.clinic_id
|
|
|
+ LEFT JOIN clc_stock_detail csd ON cso.timestamp_number = csd.timestamp_number
|
|
|
+ AND cso.clinic_id = csd.clinic_id
|
|
|
+ AND cso.medicine_id = csd.medicine_id
|
|
|
+ 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)
|
|
|
+ GROUP BY
|
|
|
+ cso.id
|
|
|
</select>
|
|
|
|
|
|
+ <select id="listHosMedOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
+ SELECT
|
|
|
+ cpi.prescription_id AS store_order_no,
|
|
|
+ '99999999' AS mis_no,
|
|
|
+ states AS settledstatus,
|
|
|
+ cpi.price AS total_amt,
|
|
|
+ ifnull( ids.ordinate_total_score, 0 ) AS insurance_amt,
|
|
|
+ cso.doctor_name AS operater,
|
|
|
+ SUBSTR( cso.stock_date, 1, 10 ) AS sale_date,
|
|
|
+ cso.stock_date AS sale_time,
|
|
|
+ cso.patient_name AS buy_med_person,
|
|
|
+ '0000000000000' AS credential_num,
|
|
|
+ IF
|
|
|
+ ( cm.medicine_category = '04', 2, 1 ) AS item_type,
|
|
|
+ cm.medicine_c_name AS store_medicine_name,
|
|
|
+ cm.medicine_id AS store_medicine_code,
|
|
|
+ '' AS plat_item_code,
|
|
|
+ '' AS plat_item_name,
|
|
|
+ idm.med_ins_backup_id AS item_code,
|
|
|
+ idm.insurance_medicine_name AS item_name,
|
|
|
+ '0000000000000' AS store_precord_code,
|
|
|
+ '0000000000000' AS store_storage_code,
|
|
|
+ cpi.prescription_id AS recipe_no,
|
|
|
+ ifnull( idm.formulation, " " ) AS dosage_id,
|
|
|
+ cm.medicine_dosage_forms AS dosage_name,
|
|
|
+ cm.medicine_specifications AS specification,
|
|
|
+ cm.medicine_manufacturer_name AS manufacturer,
|
|
|
+ cm.medicine_place AS place,
|
|
|
+ idm.medicine_package AS pack,
|
|
|
+ " " AS model,
|
|
|
+ csd.stock_batch_number AS batch_no,
|
|
|
+ csd.create_time AS manufacture_time,
|
|
|
+ csd.medicine_deadline AS medicine_deadline,
|
|
|
+ cm.medicine_barcode AS bar_code,
|
|
|
+ "" AS regist_no,
|
|
|
+ csd.stock_channel AS delivery_company,
|
|
|
+ "999999999" AS distributor,
|
|
|
+ csd.stock_bid AS price,
|
|
|
+ idm.sale_price AS retail_price,
|
|
|
+ cso.change_number AS num,
|
|
|
+ cso.if_piece AS is_unpacking
|
|
|
+ FROM
|
|
|
+ clc_stock_outbound cso
|
|
|
+ LEFT JOIN clc_prescription_info cpi ON cpi.prescription_id = cso.prescription_id
|
|
|
+ AND cso.clinic_id = cpi.clinic_id
|
|
|
+ LEFT JOIN clc_medicine cm ON cso.medicine_id = cm.medicine_id
|
|
|
+ AND cso.clinic_id = cm.clinic_id
|
|
|
+ LEFT JOIN ins_d_medicine idm ON cso.medicine_id = idm.medicine_id
|
|
|
+ AND cso.clinic_id = idm.clinic_id
|
|
|
+ LEFT JOIN clc_stock_detail csd ON cso.timestamp_number = csd.timestamp_number
|
|
|
+ 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
|
|
|
+ WHERE
|
|
|
+ cso.clinic_id = #{clinicId}
|
|
|
+ AND cpi.prescription_type = 0
|
|
|
+ AND cso.change_type IN ( 1, 2 )
|
|
|
+ AND cso.source_type = 4
|
|
|
+ GROUP BY
|
|
|
+ cso.id
|
|
|
+ </select>
|
|
|
+ <select id="listHosChinaMedOrder" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
+ SELECT
|
|
|
+ cpi.prescription_id AS store_order_no,
|
|
|
+ '99999999' AS mis_no,
|
|
|
+ states AS settledstatus,
|
|
|
+ cpi.price AS total_amt,
|
|
|
+ ifnull( ids.ordinate_total_score, 0 ) AS insurance_amt,
|
|
|
+ cso.doctor_name AS operater,
|
|
|
+ SUBSTR( cso.stock_date, 1, 10 ) AS sale_date,
|
|
|
+ cso.stock_date AS sale_time,
|
|
|
+ cso.patient_name AS buy_med_person,
|
|
|
+ '0000000000000' AS credential_num,
|
|
|
+ IF
|
|
|
+ ( ccm.medicine_category = '04', 2, 1 ) AS item_type,
|
|
|
+ ccm.medicine_name AS store_medicine_name,
|
|
|
+ IF
|
|
|
+ ( length( ccm.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,
|
|
|
+ idm.med_ins_backup_id AS item_code,
|
|
|
+ idm.insurance_medicine_name AS item_name,
|
|
|
+ '0000000000000' AS store_precord_code,
|
|
|
+ '0000000000000' AS store_storage_code,
|
|
|
+ cpi.prescription_id AS recipe_no,
|
|
|
+ ifnull( idm.formulation, " " ) AS dosage_id,
|
|
|
+ ccm.medicine_rate_last AS dosage_name,
|
|
|
+ ccm.medicine_specifications AS specification,
|
|
|
+ ccm.medicine_manufacturer_name AS manufacturer,
|
|
|
+ ccm.medicine_address AS place,
|
|
|
+ idm.medicine_package AS pack,
|
|
|
+ " " AS model,
|
|
|
+ csd.stock_batch_number AS batch_no,
|
|
|
+ csd.create_time AS manufacture_time,
|
|
|
+ csd.medicine_deadline AS medicine_deadline,
|
|
|
+ '00000000' AS bar_code,
|
|
|
+ "" AS regist_no,
|
|
|
+ csd.stock_channel AS delivery_company,
|
|
|
+ "999999999" AS distributor,
|
|
|
+ csd.stock_bid AS price,
|
|
|
+ idm.sale_price AS retail_price,
|
|
|
+ cso.change_number AS num,
|
|
|
+ cso.if_piece AS is_unpacking
|
|
|
+ FROM
|
|
|
+ clc_stock_outbound cso
|
|
|
+ LEFT JOIN clc_prescription_info cpi ON cpi.prescription_id = cso.prescription_id
|
|
|
+ AND cso.clinic_id = cpi.clinic_id
|
|
|
+ LEFT JOIN clc_china_medicine ccm ON cso.medicine_id = ccm.medicine_id
|
|
|
+ AND cso.clinic_id = ccm.clinic_id
|
|
|
+ LEFT JOIN ins_d_medicine idm ON cso.medicine_id = idm.medicine_id
|
|
|
+ AND cso.clinic_id = idm.clinic_id
|
|
|
+ LEFT JOIN clc_stock_detail csd ON cso.timestamp_number = csd.timestamp_number
|
|
|
+ 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
|
|
|
+ WHERE
|
|
|
+ cso.clinic_id = #{clinicId}
|
|
|
+ AND cpi.prescription_type = 1
|
|
|
+ AND cso.change_type IN ( 1, 2 )
|
|
|
+ AND cso.source_type = 4
|
|
|
+ GROUP BY
|
|
|
+ cso.id
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|