|
|
@@ -2,6 +2,8 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.miyzh.dao.OrderDetailDao">
|
|
|
<resultMap id="BaseResultMap" type="com.miyzh.entity.OrderDetailTemp" extends="com.miyzh.dao.MedicineDao.BaseResultMap">
|
|
|
+ <!--机构销售订单编号-->
|
|
|
+ <result column="store_order_no" jdbcType="VARCHAR" property="storeOrderNo" />
|
|
|
<!--医保结算单号-->
|
|
|
<result column="mis_no" jdbcType="VARCHAR" property="misNo" />
|
|
|
<!--结算方式编码-->
|
|
|
@@ -42,48 +44,52 @@
|
|
|
<result column="is_unpacking" jdbcType="VARCHAR" property="isUnpacking" />
|
|
|
<!--查询时间-->
|
|
|
<result column="query_time" jdbcType="VARCHAR" property="queryTime" />
|
|
|
+ <!--处方编码-->
|
|
|
+ <result column="recipe_no" jdbcType="VARCHAR" property="recipeNo" />
|
|
|
+
|
|
|
</resultMap>
|
|
|
|
|
|
<select id="listClcMedOrder" 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,
|
|
|
+ cpi.states AS settledstatus,
|
|
|
+ ROUND(cpi.price,2) 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,
|
|
|
+ SUBSTR( cso.create_time, 1, 10 ) AS sale_date,
|
|
|
+ cso.create_time 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,
|
|
|
+ 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,
|
|
|
'' 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,
|
|
|
+ if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
|
+ if(ifnull(idm.insurance_medicine_name,'')='','999999999',idm.insurance_medicine_name) as item_name,
|
|
|
+ if(ifnull(csd.stock_purchase_number,'')='','0000000000000',csd.stock_purchase_number) as store_precord_code,
|
|
|
+ if(ifnull(csd.stock_batch_number,'')='','0000000000000',csd.stock_batch_number) 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,
|
|
|
+ if(ifnull(idm.formulation,'')='','999999999',idm.formulation) as dosage_id,
|
|
|
+ if(ifnull(cm.medicine_dosage_forms,'')='','999999999',cm.medicine_dosage_forms) as dosage_name,
|
|
|
+ if(ifnull(cso.medicine_specifications,'')='','999999999',cso.medicine_specifications) as specification,
|
|
|
+ if(ifnull(cso.medicine_manufacturer_name,'')='','999999999',cso.medicine_manufacturer_name) as manufacturer,
|
|
|
+ if(ifnull(cm.medicine_place,'')='','999999999',cm.medicine_place) as place,
|
|
|
+ if(ifnull(cm.medicine_unit_form,'')='','999999999',cm.medicine_unit_form) as pack,
|
|
|
+ '0000000000000' AS model,
|
|
|
+ if(ifnull(csd.stock_batch_number,'')='','0000000000000',csd.stock_batch_number) as batch_no,
|
|
|
+ SUBSTR( csd.stock_date, 1, 10) AS manufacture_time,
|
|
|
csd.medicine_deadline AS medicine_deadline,
|
|
|
- cm.medicine_barcode AS bar_code,
|
|
|
- "" AS regist_no,
|
|
|
- csd.stock_channel AS delivery_company,
|
|
|
+ if(ifnull(cm.medicine_barcode,'')='','0000000000000',cm.medicine_barcode) as bar_code,
|
|
|
+ '99999999' AS regist_no,
|
|
|
+ if(ifnull(csd.stock_channel,'')='','999999999',csd.stock_channel) as delivery_company,
|
|
|
"999999999" AS distributor,
|
|
|
- csd.stock_bid AS price,
|
|
|
- idm.sale_price AS retail_price,
|
|
|
+ ROUND(csd.stock_bid,2) AS price,
|
|
|
+ ROUND(cso.retail_price,2) AS retail_price,
|
|
|
cso.change_number as num,
|
|
|
- cso.if_piece as is_unpacking
|
|
|
+ if(cso.if_piece = '0', '1', '2') as is_unpacking,
|
|
|
+ now() as query_time
|
|
|
FROM
|
|
|
clc_stock_outbound cso
|
|
|
LEFT JOIN
|
|
|
@@ -104,8 +110,7 @@
|
|
|
LEFT JOIN
|
|
|
clc_stock_detail csd
|
|
|
ON
|
|
|
- cso.timestamp_number = csd.timestamp_number
|
|
|
- and cso.medicine_id = csd.medicine_id
|
|
|
+ cso.stock_detail_id = csd.id
|
|
|
and cso.clinic_id = csd.clinic_id
|
|
|
WHERE
|
|
|
cso.clinic_id = #{clinicId}
|
|
|
@@ -122,118 +127,118 @@
|
|
|
SELECT
|
|
|
cpi.prescription_id AS store_order_no,
|
|
|
'99999999' AS mis_no,
|
|
|
- states AS settledstatus,
|
|
|
- cpi.price AS total_amt,
|
|
|
+ cpi.states AS settledstatus,
|
|
|
+ ROUND(cpi.price,2) 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,
|
|
|
+ ccso.doctor_name AS operater,
|
|
|
+ SUBSTR( ccso.create_time, 1, 10 ) AS sale_date,
|
|
|
+ ccso.create_time AS sale_time,
|
|
|
+ ccso.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,
|
|
|
+ ccso.medicine_name AS store_medicine_name,
|
|
|
+ ccso.med_ins_backup_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,
|
|
|
+ if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
|
+ if(ifnull(idm.insurance_medicine_name,'')='','999999999',idm.insurance_medicine_name) as item_name,
|
|
|
+ if(ifnull(ccsp.stock_purchase_number,'')='','0000000000000',ccsp.stock_purchase_number) as store_precord_code,
|
|
|
+ if(ifnull(ccsp.stock_batch_number,'')='','0000000000000',ccsp.stock_batch_number) 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,
|
|
|
+ if(ifnull(idm.formulation,'')='','999999999',idm.formulation) as dosage_id,
|
|
|
+ if(ifnull(ccm.medicine_rate_last,'')='','999999999',ccm.medicine_rate_last) as dosage_name,
|
|
|
+ if(ifnull(ccso.medicine_specifications,'')='','999999999',ccso.medicine_specifications) as specification,
|
|
|
+ if(ifnull(ccso.medicine_manufacturer_name,'')='','999999999',ccso.medicine_manufacturer_name) as manufacturer,
|
|
|
+ if(ifnull(ccm.medicine_address,'')='','999999999',ccm.medicine_address) as place,
|
|
|
+ if(ifnull(ccm.medicine_unit,'')='','999999999',ccm.medicine_unit) as pack,
|
|
|
+ '0000000000000' AS model,
|
|
|
+ if(ifnull(ccsp.stock_batch_number,'')='','0000000000000',ccsp.stock_batch_number) as batch_no,
|
|
|
+ SUBSTR( ccsp.stock_date, 1, 10) AS manufacture_time,
|
|
|
+ ccsp.medicine_deadline AS medicine_deadline,
|
|
|
+ '0000000000000' AS bar_code,
|
|
|
+ '99999999' AS regist_no,
|
|
|
+ if(ifnull(ccsp.stock_channel,'')='','999999999',ccsp.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
|
|
|
+ ROUND(ccsp.stock_bid,2) AS price,
|
|
|
+ ROUND(ccso.retail_price,2) AS retail_price,
|
|
|
+ ccso.change_number AS num,
|
|
|
+ '1' as is_unpacking,
|
|
|
+ now() as query_time
|
|
|
FROM
|
|
|
- clc_stock_outbound cso
|
|
|
+ clc_china_stock_outbound ccso
|
|
|
LEFT JOIN
|
|
|
clc_prescription_info cpi
|
|
|
ON
|
|
|
- cpi.prescription_id = cso.prescription_id
|
|
|
- AND cso.clinic_id = cpi.clinic_id
|
|
|
+ cpi.prescription_id = ccso.prescription_id
|
|
|
+ AND ccso.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
|
|
|
+ ccso.medicine_id = ccm.medicine_id
|
|
|
+ and ccso.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
|
|
|
+ ccso.medicine_id = idm.medicine_id
|
|
|
+ and ccso.clinic_id = idm.clinic_id
|
|
|
LEFT JOIN
|
|
|
- clc_stock_detail csd
|
|
|
+ clc_china_stock_profit ccsp
|
|
|
ON
|
|
|
- cso.timestamp_number = csd.timestamp_number
|
|
|
- and cso.clinic_id = csd.clinic_id
|
|
|
- AND cso.medicine_id = csd.medicine_id
|
|
|
+ ccso.stock_detail_id = ccsp.id
|
|
|
+ and ccso.clinic_id = ccsp.clinic_id
|
|
|
WHERE
|
|
|
- cso.clinic_id = #{clinicId}
|
|
|
+ ccso.clinic_id = #{clinicId}
|
|
|
AND
|
|
|
cpi.prescription_type = 1
|
|
|
AND
|
|
|
- cso.change_type in (1, 2)
|
|
|
- and cso.source_type = 1
|
|
|
+ ccso.change_type in (1, 2)
|
|
|
+ and ccso.source_type = 1
|
|
|
GROUP BY
|
|
|
- cso.id
|
|
|
+ ccso.id
|
|
|
</select>
|
|
|
|
|
|
<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,
|
|
|
+ cpi.states AS settledstatus,
|
|
|
+ ROUND(cpi.price,2) AS total_amt,
|
|
|
+ ifnull( ROUND(ids.ordinate_total_score,2), '0.00' ) AS insurance_amt,
|
|
|
cso.doctor_name AS operater,
|
|
|
- SUBSTR( cso.stock_date, 1, 10 ) AS sale_date,
|
|
|
- cso.stock_date AS sale_time,
|
|
|
+ SUBSTR( cso.create_time, 1, 10 ) AS sale_date,
|
|
|
+ cso.create_time 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,
|
|
|
+ cso.medicine_name AS store_medicine_name,
|
|
|
+ cso.med_ins_backup_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,
|
|
|
+ if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
|
+ if(ifnull(idm.insurance_medicine_name,'')='','999999999',idm.insurance_medicine_name) as item_name,
|
|
|
+ if(ifnull(csd.stock_purchase_number,'')='','0000000000000',csd.stock_purchase_number) as store_precord_code,
|
|
|
+ if(ifnull(csd.stock_batch_number,'')='','0000000000000',csd.stock_batch_number) 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,
|
|
|
+ if(ifnull(idm.formulation,'')='','999999999',idm.formulation) as dosage_id,
|
|
|
+ if(ifnull(cm.medicine_dosage_forms,'')='','999999999',cm.medicine_dosage_forms) as dosage_name,
|
|
|
+ if(ifnull(cso.medicine_specifications,'')='','999999999',cso.medicine_specifications) as specification,
|
|
|
+ if(ifnull(cso.medicine_manufacturer_name,'')='','999999999',cso.medicine_manufacturer_name) as manufacturer,
|
|
|
+ if(ifnull(cm.medicine_place,'')='','999999999',cm.medicine_place) as place,
|
|
|
+ if(ifnull(cm.medicine_unit_form,'')='','999999999',cm.medicine_unit_form) as pack,
|
|
|
+ '0000000000000' AS model,
|
|
|
+ if(ifnull(csd.stock_batch_number,'')='','0000000000000',csd.stock_batch_number) as batch_no,
|
|
|
+ SUBSTR( csd.stock_date, 1, 10) AS manufacture_time,
|
|
|
csd.medicine_deadline AS medicine_deadline,
|
|
|
- cm.medicine_barcode AS bar_code,
|
|
|
- "" AS regist_no,
|
|
|
- csd.stock_channel AS delivery_company,
|
|
|
+ if(ifnull(cm.medicine_barcode,'')='','0000000000000',cm.medicine_barcode) as bar_code,
|
|
|
+ '99999999' AS regist_no,
|
|
|
+ if(ifnull(csd.stock_channel,'')='','999999999',csd.stock_channel) as delivery_company,
|
|
|
"999999999" AS distributor,
|
|
|
- csd.stock_bid AS price,
|
|
|
- idm.sale_price AS retail_price,
|
|
|
+ ROUND(csd.stock_bid,2) AS price,
|
|
|
+ ROUND(cso.retail_price,2) AS retail_price,
|
|
|
cso.change_number AS num,
|
|
|
- cso.if_piece AS is_unpacking
|
|
|
+ if(cso.if_piece = '0', '1', '2') as is_unpacking,
|
|
|
+ now() as query_time
|
|
|
FROM
|
|
|
clc_stock_outbound cso
|
|
|
LEFT JOIN clc_prescription_info cpi ON cpi.prescription_id = cso.prescription_id
|
|
|
@@ -242,8 +247,7 @@
|
|
|
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
|
|
|
+ LEFT JOIN clc_stock_detail csd ON cso.stock_detail_id = csd.id
|
|
|
AND cso.clinic_id = csd.clinic_id
|
|
|
left join ins_clinic_settlement ics
|
|
|
on ics.prescription_id = cso.prescription_id
|
|
|
@@ -263,56 +267,62 @@
|
|
|
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,
|
|
|
+ cpi.states AS settledstatus,
|
|
|
+ ROUND(cpi.price,2) AS total_amt,
|
|
|
+ ifnull( ROUND(ids.ordinate_total_score,2), '0.00' ) AS insurance_amt,
|
|
|
cso.doctor_name AS operater,
|
|
|
- SUBSTR( cso.stock_date, 1, 10 ) AS sale_date,
|
|
|
- cso.stock_date AS sale_time,
|
|
|
+ SUBSTR( cso.create_time, 1, 10 ) AS sale_date,
|
|
|
+ cso.create_time 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,
|
|
|
+ cso.medicine_name AS store_medicine_name,
|
|
|
+ cso.med_ins_backup_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,
|
|
|
+ if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
|
+ if(ifnull(idm.insurance_medicine_name,'')='','999999999',idm.insurance_medicine_name) as item_name,
|
|
|
+ if(ifnull(csd.stock_purchase_number,'')='','0000000000000',csd.stock_purchase_number) as store_precord_code,
|
|
|
+ if(ifnull(csd.stock_batch_number,'')='','0000000000000',csd.stock_batch_number) 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,
|
|
|
+ if(ifnull(idm.formulation,'')='','999999999',idm.formulation) as dosage_id,
|
|
|
+ if(ifnull(ccm.medicine_rate_last,'')='','999999999',ccm.medicine_rate_last) as dosage_name,
|
|
|
+ if(ifnull(cso.medicine_specifications,'')='','999999999',cso.medicine_specifications) as specification,
|
|
|
+ if(ifnull(cso.medicine_manufacturer_name,'')='','999999999',cso.medicine_manufacturer_name) as manufacturer,
|
|
|
+ if(ifnull(ccm.medicine_address,'')='','999999999',ccm.medicine_address) as place,
|
|
|
+ if(ifnull(ccm.medicine_unit,'')='','999999999',ccm.medicine_unit) as pack,
|
|
|
+ '0000000000000' AS model,
|
|
|
+ if(ifnull(csd.stock_batch_number,'')='','0000000000000',csd.stock_batch_number) as batch_no,
|
|
|
+ SUBSTR( csd.stock_date, 1, 10) AS manufacture_time,
|
|
|
csd.medicine_deadline AS medicine_deadline,
|
|
|
- '00000000' AS bar_code,
|
|
|
- "" AS regist_no,
|
|
|
- csd.stock_channel AS delivery_company,
|
|
|
+ '0000000000000' AS bar_code,
|
|
|
+ '99999999' AS regist_no,
|
|
|
+ if(ifnull(csd.stock_channel,'')='','999999999',csd.stock_channel) as delivery_company,
|
|
|
"999999999" AS distributor,
|
|
|
- csd.stock_bid AS price,
|
|
|
- idm.sale_price AS retail_price,
|
|
|
+ ROUND(csd.stock_bid,2) AS price,
|
|
|
+ ROUND(cso.retail_price,2) AS retail_price,
|
|
|
cso.change_number AS num,
|
|
|
- cso.if_piece AS is_unpacking
|
|
|
+ '1' as is_unpacking,
|
|
|
+ now() as query_time
|
|
|
FROM
|
|
|
- clc_stock_outbound cso
|
|
|
- LEFT JOIN clc_prescription_info cpi ON cpi.prescription_id = cso.prescription_id
|
|
|
+ clc_china_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
|
|
|
+ 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
|
|
|
+ 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
|
|
|
+ LEFT JOIN clc_china_stock_profit csd
|
|
|
+ ON cso.stock_detail_id = csd.id
|
|
|
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
|
|
|
+ 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
|
|
|
+ LEFT JOIN ins_d_settlement ids
|
|
|
+ ON ids.settlement_id = ics.id
|
|
|
AND ids.clinic_id = cso.clinic_id
|
|
|
WHERE
|
|
|
cso.clinic_id = #{clinicId}
|
|
|
@@ -327,52 +337,57 @@
|
|
|
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,
|
|
|
+ cpi.states AS settledstatus,
|
|
|
+ ROUND(cpi.price,2) AS total_amt,
|
|
|
+ ifnull( ROUND(ids.ordinate_total_score,2), '0.00' ) AS insurance_amt,
|
|
|
cso.doctor_name AS operater,
|
|
|
- SUBSTR( cso.stock_date, 1, 10 ) AS sale_date,
|
|
|
- cso.stock_date AS sale_time,
|
|
|
+ SUBSTR( cso.create_time, 1, 10 ) AS sale_date,
|
|
|
+ cso.create_time 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,
|
|
|
+ cso.medicine_name AS store_medicine_name,
|
|
|
+ cso.med_ins_backup_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,
|
|
|
+ if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
|
+ if(ifnull(idm.insurance_medicine_name,'')='','999999999',idm.insurance_medicine_name) as item_name,
|
|
|
+ if(ifnull(csd.stock_purchase_number,'')='','0000000000000',csd.stock_purchase_number) as store_precord_code,
|
|
|
+ if(ifnull(csd.stock_batch_number,'')='','0000000000000',csd.stock_batch_number) 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,
|
|
|
+ if(ifnull(idm.formulation,'')='','999999999',idm.formulation) as dosage_id,
|
|
|
+ if(ifnull(cm.medicine_dosage_forms,'')='','999999999',cm.medicine_dosage_forms) as dosage_name,
|
|
|
+ if(ifnull(cso.medicine_specifications,'')='','999999999',cso.medicine_specifications) as specification,
|
|
|
+ if(ifnull(cso.medicine_manufacturer_name,'')='','999999999',cso.medicine_manufacturer_name) as manufacturer,
|
|
|
+ if(ifnull(cm.medicine_place,'')='','999999999',cm.medicine_place) as place,
|
|
|
+ if(ifnull(idm.medicine_package,'')='','999999999',idm.medicine_package) as pack,
|
|
|
+ '0000000000000' AS model,
|
|
|
+ if(ifnull(csd.stock_batch_number,'')='','0000000000000',csd.stock_batch_number) as batch_no,
|
|
|
+ SUBSTR( csd.stock_date, 1, 10) AS manufacture_time,
|
|
|
csd.medicine_deadline AS medicine_deadline,
|
|
|
- cm.medicine_barcode AS bar_code,
|
|
|
- "" AS regist_no,
|
|
|
- csd.stock_channel AS delivery_company,
|
|
|
+ if(ifnull(cm.medicine_barcode,'')='','0000000000000',cm.medicine_barcode) as bar_code,
|
|
|
+ '99999999' AS regist_no,
|
|
|
+ if(ifnull(csd.stock_channel,'')='','999999999',csd.stock_channel) as delivery_company,
|
|
|
"999999999" AS distributor,
|
|
|
- csd.stock_bid AS price,
|
|
|
- idm.sale_price AS retail_price,
|
|
|
+ ROUND(csd.stock_bid,2) AS price,
|
|
|
+ ROUND(cso.retail_price,2) AS retail_price,
|
|
|
cso.change_number AS num,
|
|
|
- cso.if_piece AS is_unpacking
|
|
|
+ if(cso.if_piece = '0', '1', '2') as is_unpacking,
|
|
|
+ now() as query_time
|
|
|
FROM
|
|
|
clc_stock_outbound cso
|
|
|
- LEFT JOIN clc_prescription_info cpi ON cpi.prescription_id = cso.prescription_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
|
|
|
+ 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
|
|
|
+ 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
|
|
|
+ LEFT JOIN clc_stock_detail csd
|
|
|
+ ON cso.stock_detail_id = csd.id
|
|
|
AND cso.clinic_id = csd.clinic_id
|
|
|
AND cso.medicine_id = csd.medicine_id
|
|
|
LEFT JOIN (
|
|
|
@@ -401,55 +416,58 @@
|
|
|
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,
|
|
|
+ cpi.states AS settledstatus,
|
|
|
+ ROUND(cpi.price,2) AS total_amt,
|
|
|
+ ifnull( ROUND(ids.ordinate_total_score,2), '0.00' ) AS insurance_amt,
|
|
|
cso.doctor_name AS operater,
|
|
|
- SUBSTR( cso.stock_date, 1, 10 ) AS sale_date,
|
|
|
- cso.stock_date AS sale_time,
|
|
|
+ SUBSTR( cso.create_time, 1, 10 ) AS sale_date,
|
|
|
+ cso.create_time 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,
|
|
|
+ cso.medicine_name AS store_medicine_name,
|
|
|
+ cso.med_ins_backup_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,
|
|
|
+ if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
|
+ if(ifnull(idm.insurance_medicine_name,'')='','999999999',idm.insurance_medicine_name) as item_name,
|
|
|
+ if(ifnull(csd.stock_purchase_number,'')='','0000000000000',csd.stock_purchase_number) as store_precord_code,
|
|
|
+ if(ifnull(csd.stock_batch_number,'')='','0000000000000',csd.stock_batch_number) 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,
|
|
|
+ if(ifnull(idm.formulation,'')='','999999999',idm.formulation) as dosage_id,
|
|
|
+ if(ifnull(ccm.medicine_rate_last,'')='','999999999',ccm.medicine_rate_last) as dosage_name,
|
|
|
+ if(ifnull(cso.medicine_specifications,'')='','999999999',cso.medicine_specifications) as specification,
|
|
|
+ if(ifnull(cso.medicine_manufacturer_name,'')='','999999999',cso.medicine_manufacturer_name) as manufacturer,
|
|
|
+ if(ifnull(ccm.medicine_address,'')='','999999999',ccm.medicine_address) as place,
|
|
|
+ if(ifnull(ccm.medicine_unit,'')='','999999999',ccm.medicine_unit) as pack,
|
|
|
+ '0000000000000' AS model,
|
|
|
+ if(ifnull(csd.stock_batch_number,'')='','0000000000000',csd.stock_batch_number) as batch_no,
|
|
|
+ SUBSTR( csd.stock_date, 1, 10) AS manufacture_time,
|
|
|
csd.medicine_deadline AS medicine_deadline,
|
|
|
- '00000000' AS bar_code,
|
|
|
- "" AS regist_no,
|
|
|
- csd.stock_channel AS delivery_company,
|
|
|
+ '0000000000000' AS bar_code,
|
|
|
+ '99999999' AS regist_no,
|
|
|
+ if(ifnull(csd.stock_channel,'')='','999999999',csd.stock_channel) as delivery_company,
|
|
|
"999999999" AS distributor,
|
|
|
- csd.stock_bid AS price,
|
|
|
- idm.sale_price AS retail_price,
|
|
|
+ ROUND(csd.stock_bid,2) AS price,
|
|
|
+ ROUND(cso.retail_price,2) AS retail_price,
|
|
|
cso.change_number AS num,
|
|
|
- cso.if_piece AS is_unpacking
|
|
|
+ '1' as is_unpacking,
|
|
|
+ now() as query_time
|
|
|
FROM
|
|
|
- clc_stock_outbound cso
|
|
|
- LEFT JOIN clc_prescription_info cpi ON cpi.prescription_id = cso.prescription_id
|
|
|
+ clc_china_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
|
|
|
+ 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
|
|
|
+ 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
|
|
|
+ LEFT JOIN clc_china_stock_profit csd
|
|
|
+ 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,
|