|
|
@@ -22,19 +22,19 @@
|
|
|
IF( length( cm.med_ins_backup_id ) > 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
cm.medicine_c_name AS store_medicine_name,
|
|
|
cm.medicine_c_name AS store_medicine_trade_name,
|
|
|
- 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(cm.medicine_specifications,'')='','999999999',cm.medicine_specifications) as specification,
|
|
|
- if(ifnull(cm.medicine_manufacturer_name,'')='','999999999',cm.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,
|
|
|
+ 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,
|
|
|
'0000000000000' as model,
|
|
|
- if(ifnull(cso.timestamp_number,'')='','0000000000000',cso.timestamp_number) as batch_no,
|
|
|
+ cso.timestamp_number as batch_no,
|
|
|
SUBSTR( csd.stock_date, 1, 10) AS manufacture_time,
|
|
|
- csd.medicine_deadline AS medicine_deadline,
|
|
|
- if(ifnull(cm.medicine_barcode,'')='','0000000000000',cm.medicine_barcode) as bar_code,
|
|
|
+ csd.medicine_deadline as medicine_deadline,
|
|
|
+ cm.medicine_barcode as bar_code,
|
|
|
'99999999' AS regist_no,
|
|
|
- if(ifnull(cso.medicine_manufacturer_name,'')='','999999999',cso.medicine_manufacturer_name) as delivery_company,
|
|
|
+ cso.medicine_manufacturer_name as delivery_company,
|
|
|
'999999999' AS distributor,
|
|
|
'999999999' AS store_storage_code,
|
|
|
sum( cso.change_number ) AS return_quantity,
|
|
|
@@ -42,8 +42,8 @@
|
|
|
ROUND(cso.retail_price,2) AS retail_price,
|
|
|
"" AS plat_item_code,
|
|
|
"" AS plat_item_name,
|
|
|
- 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,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ idm.insurance_medicine_name as item_name,
|
|
|
cso.create_name AS return_man,
|
|
|
cso.create_time AS return_time,
|
|
|
cso.create_id as store_return_code
|
|
|
@@ -51,7 +51,7 @@
|
|
|
clc_stock_outbound cso
|
|
|
LEFT JOIN clc_medicine cm ON cso.medicine_id = cm.medicine_id
|
|
|
AND cso.clinic_id = cm.clinic_id
|
|
|
- LEFT JOIN clc_stock_detail csd ON csd.timestamp_number = cso.timestamp_number
|
|
|
+ LEFT JOIN clc_stock_detail csd ON csd.medicine_id = cso.medicine_id and csd.timestamp_number = cso.timestamp_number
|
|
|
AND cso.clinic_id = csd.clinic_id
|
|
|
LEFT JOIN ins_d_medicine idm ON idm.medicine_id = cso.medicine_id
|
|
|
AND idm.clinic_id = cso.clinic_id
|
|
|
@@ -86,24 +86,24 @@
|
|
|
<!--中药销售出库记录-->
|
|
|
<select id="listChinaMedicineOutbound" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
SELECT
|
|
|
- if(ccm.medicine_category='04', '2','1') as item_type,
|
|
|
+ '1' as item_type,
|
|
|
IF
|
|
|
( length( ccm.med_ins_backup_id ) > 0, ccm.med_ins_backup_id, ccm.medicine_id ) AS store_medicine_code,
|
|
|
ccm.medicine_name AS store_medicine_name,
|
|
|
ccm.medicine_name AS store_medicine_trade_name,
|
|
|
- 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(ccm.medicine_specifications,'')='','999999999',ccm.medicine_specifications) as specification,
|
|
|
- if(ifnull(ccm.medicine_manufacturer_name,'')='','999999999',ccm.medicine_manufacturer_name) as manufacturer,
|
|
|
- if(ifnull(ccm.medicine_address,'')='','999999999',ccm.medicine_address) as place,
|
|
|
- if(ifnull(idm.medicine_package,'')='','999999999',idm.medicine_package) as pack,
|
|
|
+ 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,
|
|
|
'0000000000000' AS model,
|
|
|
- if(ifnull(ccso.timestamp_number,'')='','0000000000000',ccso.timestamp_number) as batch_no,
|
|
|
+ ccso.timestamp_number as batch_no,
|
|
|
SUBSTR( ccsp.stock_date, 1, 10) AS manufacture_time,
|
|
|
- ccsp.medicine_deadline AS medicine_deadline,
|
|
|
+ ccsp.medicine_deadline as medicine_deadline,
|
|
|
'0000000000000' AS bar_code,
|
|
|
'99999999' AS regist_no,
|
|
|
- if(ifnull(ccso.medicine_manufacturer_name,'')='','999999999',ccso.medicine_manufacturer_name) as delivery_company,
|
|
|
+ ccso.medicine_manufacturer_name as delivery_company,
|
|
|
"999999999" AS distributor,
|
|
|
'999999999' AS store_storage_code,
|
|
|
sum( ccso.change_number ) AS return_quantity,
|
|
|
@@ -111,8 +111,8 @@
|
|
|
ROUND(ccso.retail_price,2) AS retail_price,
|
|
|
"" AS plat_item_code,
|
|
|
"" AS plat_item_name,
|
|
|
- if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
|
- if(ifnull(insurance_medicine_name,'')='','999999999',insurance_medicine_name) as item_name,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ insurance_medicine_name as item_name,
|
|
|
ccso.create_name AS return_man,
|
|
|
ccso.create_time AS return_time,
|
|
|
ccso.create_id as store_return_code
|
|
|
@@ -120,7 +120,7 @@
|
|
|
clc_china_stock_outbound ccso
|
|
|
LEFT JOIN clc_china_medicine ccm ON ccso.medicine_id = ccm.medicine_id
|
|
|
AND ccso.clinic_id = ccm.clinic_id
|
|
|
- LEFT JOIN clc_china_stock_profit ccsp ON ccsp.timestamp_number = ccso.timestamp_number
|
|
|
+ LEFT JOIN clc_china_stock_profit ccsp ON ccsp.medicine_id = ccso.medicine_id and ccsp.timestamp_number = ccso.timestamp_number
|
|
|
AND ccso.clinic_id = ccsp.clinic_id
|
|
|
LEFT JOIN ins_d_medicine idm ON idm.medicine_id = ccso.medicine_id
|
|
|
AND idm.clinic_id = ccso.clinic_id
|
|
|
@@ -163,19 +163,19 @@
|
|
|
) AS store_medicine_code,
|
|
|
cm.medicine_c_name AS store_medicine_name,
|
|
|
cm.medicine_c_name AS store_medicine_trade_name,
|
|
|
- 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(cm.medicine_specifications,'')='','999999999',cm.medicine_specifications) as specification,
|
|
|
- if(ifnull(cm.medicine_manufacturer_name,'')='','999999999',cm.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,
|
|
|
+ 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,
|
|
|
'0000000000000' AS model,
|
|
|
- if(ifnull(cod.batch_number,'')='','0000000000000',cod.batch_number) as batch_no,
|
|
|
+ cod.batch_number as batch_no,
|
|
|
SUBSTR( cod.stock_date, 1, 10) AS manufacture_time,
|
|
|
- cod.deadline_date AS medicine_deadline,
|
|
|
- if(ifnull(cm.medicine_barcode,'')='','0000000000000',cm.medicine_barcode) as bar_code,
|
|
|
+ cod.deadline_date as medicine_deadline,
|
|
|
+ cm.medicine_barcode as bar_code,
|
|
|
'99999999' AS regist_no,
|
|
|
- if(ifnull(cod.medicine_manufacture,'')='','999999999',cod.medicine_manufacture) as delivery_company,
|
|
|
+ cod.medicine_manufacture as delivery_company,
|
|
|
"999999999" AS distributor,
|
|
|
'999999999' AS store_storage_code,
|
|
|
sum(cod.out_num) AS return_quantity,
|
|
|
@@ -183,8 +183,8 @@
|
|
|
ROUND(cod.sale_price,2) AS retail_price,
|
|
|
" " AS plat_item_code,
|
|
|
" " AS plat_item_name,
|
|
|
- if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
|
- if(ifnull(insurance_medicine_name,'')='','999999999',insurance_medicine_name) as item_name,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ insurance_medicine_name as item_name,
|
|
|
co.create_userName AS return_man,
|
|
|
co.create_time AS return_time,
|
|
|
co.outtreasury_no as store_return_code
|
|
|
@@ -240,19 +240,19 @@
|
|
|
) AS store_medicine_code,
|
|
|
ccm.medicine_name AS store_medicine_name,
|
|
|
ccm.medicine_name AS store_medicine_trade_name,
|
|
|
- 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(ccm.medicine_specifications,'')='','999999999',ccm.medicine_specifications) as specification,
|
|
|
- if(ifnull(ccm.medicine_manufacturer_name,'')='','999999999',ccm.medicine_manufacturer_name) as manufacturer,
|
|
|
- if(ifnull(ccm.medicine_address,'')='','999999999',ccm.medicine_address) as place,
|
|
|
- if(ifnull(idm.medicine_package,'')='','999999999',idm.medicine_package) as pack,
|
|
|
+ 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,
|
|
|
'0000000000000' AS model,
|
|
|
- if(ifnull(cod.batch_number,'')='','0000000000000',cod.batch_number) as batch_no,
|
|
|
+ cod.batch_number as batch_no,
|
|
|
SUBSTR( cod.stock_date, 1, 10) AS manufacture_time,
|
|
|
- cod.deadline_date AS medicine_deadline,
|
|
|
+ cod.deadline_date as medicine_deadline,
|
|
|
'0000000000000' AS bar_code,
|
|
|
'99999999' AS regist_no,
|
|
|
- if(ifnull(cod.medicine_manufacture,'')='','999999999',cod.medicine_manufacture) as delivery_company,
|
|
|
+ cod.medicine_manufacture as delivery_company,
|
|
|
"999999999" AS distributor,
|
|
|
'999999999' AS store_storage_code,
|
|
|
sum(cod.out_num) AS return_quantity,
|
|
|
@@ -260,8 +260,8 @@
|
|
|
ROUND(cod.sale_price,2) AS retail_price,
|
|
|
"" AS plat_item_code,
|
|
|
"" AS plat_item_name,
|
|
|
- if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
|
- if(ifnull(insurance_medicine_name,'')='','999999999',insurance_medicine_name) as item_name,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ insurance_medicine_name as item_name,
|
|
|
co.create_userName AS return_man,
|
|
|
co.create_time AS return_time,
|
|
|
co.outtreasury_no as store_return_code
|
|
|
@@ -314,19 +314,19 @@
|
|
|
( length( cm.med_ins_backup_id ) > 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
cm.medicine_c_name AS store_medicine_name,
|
|
|
cm.medicine_c_name AS store_medicine_trade_name,
|
|
|
- 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(cm.medicine_specifications,'')='','999999999',cm.medicine_specifications) as specification,
|
|
|
- if(ifnull(cm.medicine_manufacturer_name,'')='','999999999',cm.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,
|
|
|
+ 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,
|
|
|
'0000000000000' AS model,
|
|
|
- if(ifnull(cpbd.stock_purchase_number,'')='','0000000000000',cpbd.stock_purchase_number) as batch_no,
|
|
|
- csd.medicine_deadline AS medicine_deadline,
|
|
|
+ cpbd.stock_purchase_number as batch_no,
|
|
|
+ csd.medicine_deadline as medicine_deadline,
|
|
|
SUBSTR( csd.stock_date, 1, 10) AS manufacture_time,
|
|
|
- if(ifnull(cm.medicine_barcode,'')='','0000000000000',cm.medicine_barcode) as bar_code,
|
|
|
+ cm.medicine_barcode as bar_code,
|
|
|
'99999999' AS regist_no,
|
|
|
- if(ifnull(cpb.supplier_name,'')='','999999999',cpb.supplier_name) as delivery_company,
|
|
|
+ cpb.supplier_name as delivery_company,
|
|
|
"999999999" AS distributor,
|
|
|
'999999999' AS store_storage_code,
|
|
|
sum( cpbd.return_count ) AS return_quantity,
|
|
|
@@ -334,8 +334,8 @@
|
|
|
ROUND(cpbd.current_sale_price,2) AS retail_price,
|
|
|
" " AS plat_item_code,
|
|
|
" " AS plat_item_name,
|
|
|
- if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
|
- if(ifnull(insurance_medicine_name,'')='','999999999',insurance_medicine_name) as item_name,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ insurance_medicine_name as item_name,
|
|
|
cpb.create_userName AS return_man,
|
|
|
cpb.create_time AS return_time,
|
|
|
cpb.purchase_id as store_return_code
|
|
|
@@ -346,12 +346,13 @@
|
|
|
ins_d_medicine AS idm,
|
|
|
clc_stock_detail csd
|
|
|
WHERE
|
|
|
- cpbd.medicine_id = cm.medicine_id
|
|
|
- AND cpbd.clinic_id = cm.clinic_id
|
|
|
+ cpbd.clinic_id = cm.clinic_id
|
|
|
AND cpbd.clinic_id = cpb.clinic_id
|
|
|
+ AND cm.clinic_id = idm.clinic_id
|
|
|
+ AND cm.clinic_id = csd.clinic_id
|
|
|
+ AND cpbd.medicine_id = cm.medicine_id
|
|
|
AND cpb.id = cpbd.back_id
|
|
|
AND cm.medicine_id = idm.medicine_id
|
|
|
- AND cm.clinic_id = idm.clinic_id
|
|
|
AND cpbd.stock_purchase_number = csd.stock_purchase_number
|
|
|
AND cpbd.clinic_id = #{clinicId}
|
|
|
AND cpb.biz_type in (1, 2, 3)
|
|
|
@@ -393,19 +394,19 @@
|
|
|
) AS store_medicine_code,
|
|
|
ccm.medicine_name AS store_medicine_name,
|
|
|
ccm.medicine_name AS store_medicine_trade_name,
|
|
|
- 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(ccm.medicine_specifications,'')='','999999999',ccm.medicine_specifications) as specification,
|
|
|
- if(ifnull(ccm.medicine_manufacturer_name,'')='','999999999',ccm.medicine_manufacturer_name) as manufacturer,
|
|
|
- if(ifnull(ccm.medicine_address,'')='','999999999',ccm.medicine_address) as place,
|
|
|
- if(ifnull(idm.medicine_package,'')='','999999999',idm.medicine_package) as pack,
|
|
|
+ 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,
|
|
|
'0000000000000' AS model,
|
|
|
- if(ifnull(cpbd.stock_purchase_number,'')='','0000000000000',cpbd.stock_purchase_number) as batch_no,
|
|
|
- ccsp.medicine_deadline AS medicine_deadline,
|
|
|
+ cpbd.stock_purchase_number as batch_no,
|
|
|
+ ccsp.medicine_deadline as medicine_deadline,
|
|
|
SUBSTR( ccsp.stock_date, 1, 10) AS manufacture_time,
|
|
|
'0000000000000' AS bar_code,
|
|
|
'99999999' AS regist_no,
|
|
|
- if(ifnull(cpb.supplier_name,'')='','999999999',cpb.supplier_name) as delivery_company,
|
|
|
+ cpb.supplier_name as delivery_company,
|
|
|
"999999999" AS distributor,
|
|
|
'999999999' AS store_storage_code,
|
|
|
sum(cpbd.return_count) AS return_quantity,
|
|
|
@@ -413,8 +414,8 @@
|
|
|
ROUND(cpbd.current_sale_price,2) AS retail_price,
|
|
|
"" AS plat_item_code,
|
|
|
"" AS plat_item_name,
|
|
|
- if(ifnull(idm.standard_menu_code,'')='','999999999',idm.standard_menu_code) as item_code,
|
|
|
- if(ifnull(insurance_medicine_name,'')='','999999999',insurance_medicine_name) as item_name,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ insurance_medicine_name as item_name,
|
|
|
cpb.create_userName AS return_man,
|
|
|
cpb.create_time AS return_time,
|
|
|
cpb.purchase_id as store_return_code
|
|
|
@@ -469,19 +470,19 @@
|
|
|
( length( cm.med_ins_backup_id ) > 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
cm.medicine_c_name AS store_medicine_name,
|
|
|
cm.medicine_c_name AS store_medicine_trade_name,
|
|
|
- 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(cm.medicine_specifications,'')='','999999999',cm.medicine_specifications) as specification,
|
|
|
- if(ifnull(cm.medicine_manufacturer_name,'')='','999999999',cm.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,
|
|
|
+ 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,
|
|
|
'0000000000000' AS model,
|
|
|
- if(ifnull(cid.batch_number,'')='','0000000000000',cid.batch_number) as batch_no,
|
|
|
+ cid.batch_number as batch_no,
|
|
|
SUBSTR( cid.stock_date, 1, 10) AS manufacture_time,
|
|
|
- cid.deadline_date AS medicine_deadline,
|
|
|
- if(ifnull(cm.medicine_barcode,'')='','0000000000000',cm.medicine_barcode) as bar_code,
|
|
|
+ cid.deadline_date as medicine_deadline,
|
|
|
+ cm.medicine_barcode as bar_code,
|
|
|
'99999999' AS regist_no,
|
|
|
- if(ifnull(cid.medicine_manufacture,'')='','999999999',cid.medicine_manufacture) as delivery_company,
|
|
|
+ cid.medicine_manufacture as delivery_company,
|
|
|
'999999999' AS distributor,
|
|
|
'999999999' AS store_storage_code,
|
|
|
sum( cid.stock_num ) AS return_quantity,
|
|
|
@@ -489,24 +490,21 @@
|
|
|
ROUND(cid.sale_price,2) AS retail_price,
|
|
|
"" AS plat_item_code,
|
|
|
"" AS plat_item_name,
|
|
|
- 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,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ idm.insurance_medicine_name as item_name,
|
|
|
ci.create_userName AS return_man,
|
|
|
ci.create_time AS return_time,
|
|
|
ci.inventory_no as store_return_code
|
|
|
FROM
|
|
|
- clc_inventory_detail cid,
|
|
|
- clc_medicine cm,
|
|
|
- clc_inventory ci,
|
|
|
- ins_d_medicine AS idm
|
|
|
- WHERE
|
|
|
- cid.medicine_id = cm.medicine_id
|
|
|
- AND cid.clinic_id = cm.clinic_id
|
|
|
- AND cid.clinic_id = ci.clinic_id
|
|
|
+ clc_inventory_detail AS cid
|
|
|
+ LEFT JOIN clc_medicine AS cm ON cid.clinic_id = cm.clinic_id
|
|
|
+ AND cid.medicine_id = cm.medicine_id
|
|
|
+ LEFT JOIN clc_inventory AS ci ON cid.clinic_id = ci.clinic_id
|
|
|
AND cid.inventory_id = ci.id
|
|
|
- AND cm.medicine_id = idm.medicine_id
|
|
|
- AND cm.clinic_id = idm.clinic_id
|
|
|
- AND cid.inventory_type = 2
|
|
|
+ LEFT JOIN ins_d_medicine AS idm ON idm.clinic_id = ci.clinic_id
|
|
|
+ AND idm.medicine_id = cm.medicine_id
|
|
|
+ WHERE
|
|
|
+ cid.inventory_type = 2
|
|
|
AND cid.clinic_id = #{clinicId}
|
|
|
AND cid.biz_type != 4
|
|
|
<choose>
|
|
|
@@ -547,19 +545,19 @@
|
|
|
) AS store_medicine_code,
|
|
|
ccm.medicine_name AS store_medicine_name,
|
|
|
ccm.medicine_name AS store_medicine_trade_name,
|
|
|
- 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(ccm.medicine_specifications,'')='','999999999',ccm.medicine_specifications) as specification,
|
|
|
- if(ifnull(ccm.medicine_manufacturer_name,'')='','999999999',ccm.medicine_manufacturer_name) as manufacturer,
|
|
|
- if(ifnull(ccm.medicine_address,'')='','999999999',ccm.medicine_address) as place,
|
|
|
- if(ifnull(idm.medicine_package,'')='','999999999',idm.medicine_package) as pack,
|
|
|
+ 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,
|
|
|
'0000000000000' AS model,
|
|
|
- if(ifnull(cid.batch_number,'')='','0000000000000',cid.batch_number) as batch_no,
|
|
|
+ cid.batch_number as batch_no,
|
|
|
SUBSTR( cid.stock_date, 1, 10) AS manufacture_time,
|
|
|
- cid.deadline_date AS medicine_deadline,
|
|
|
+ cid.deadline_date as medicine_deadline,
|
|
|
'0000000000000' AS bar_code,
|
|
|
'99999999' AS regist_no,
|
|
|
- if(ifnull(cid.medicine_manufacture,'')='','999999999',cid.medicine_manufacture) as delivery_company,
|
|
|
+ cid.medicine_manufacture as delivery_company,
|
|
|
"999999999" AS distributor,
|
|
|
'999999999' AS store_storage_code,
|
|
|
sum(cid.stock_num) AS return_quantity,
|
|
|
@@ -567,24 +565,24 @@
|
|
|
ROUND(cid.sale_price,2) AS retail_price,
|
|
|
"" AS plat_item_code,
|
|
|
"" AS plat_item_name,
|
|
|
- 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,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ idm.insurance_medicine_name as item_name,
|
|
|
ci.create_userName AS return_man,
|
|
|
ci.create_time AS return_time,
|
|
|
ci.inventory_no as store_return_code
|
|
|
FROM
|
|
|
- clc_inventory_detail cid,
|
|
|
- clc_china_medicine ccm,
|
|
|
- clc_inventory ci ,
|
|
|
- ins_d_medicine as idm
|
|
|
- WHERE
|
|
|
- cid.medicine_id = ccm.medicine_id
|
|
|
- AND cid.clinic_id = ccm.clinic_id
|
|
|
- AND cid.clinic_id = ci.clinic_id
|
|
|
+ clc_inventory_detail cid
|
|
|
+ left join clc_china_medicine ccm
|
|
|
+ on cid.clinic_id = ccm.clinic_id
|
|
|
+ and cid.medicine_id = ccm.medicine_id
|
|
|
+ left join clc_inventory ci
|
|
|
+ on cid.clinic_id = ci.clinic_id
|
|
|
AND cid.inventory_id = ci.id
|
|
|
+ left join ins_d_medicine as idm
|
|
|
+ on cid.clinic_id = idm.clinic_id
|
|
|
AND ccm.medicine_id = idm.medicine_id
|
|
|
- AND ccm.clinic_id = idm.clinic_id
|
|
|
- AND cid.inventory_type = 2
|
|
|
+ WHERE
|
|
|
+ cid.inventory_type = 2
|
|
|
AND cid.clinic_id = #{clinicId}
|
|
|
AND cid.biz_type = 4
|
|
|
<choose>
|