@@ -0,0 +1,74 @@
<?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.openhis.medication.mapper.MedicationMapper" >
<select id= "selectDetailList" resultType= "com.openhis.medication.domain.MedicationDetail" >
SELECT T1.id,
T1.medication_product_id,
T1.status_enum,
T1.org_id,
T1.dose_form_code,
T1.total_volume,
T1.ingredient_item,
T1.active_flag,
T1.lot_number,
T1.effective_date,
T1.expiration_date,
T1.effective_date,
T1.method_code,
T1.rate_code,
T1.dose,
T1.dose_unit_code,
T1.max_unit,
T1.definition,
T2.code,
T2.name,
T2.domain_enum,
T2.name_en,
T2.py_code,
T2.wb_code,
T2.category_code,
T2.merchandise_name,
T2.merchandise_py_code,
T2.merchandise_wb_code,
T2.unit_code,
T2.min_unit_code,
T2.part_percent,
T2.dose_from
FROM med_medication AS T1
LEFT JOIN med_medication_definition AS T2
ON T1.medication_product_id = T2.id
WHERE T1.delete_flag = 0
</select>
<!-- 根据关键字查询 如果关键字为空, 查询10条, 否则返回查询到的所有 -->
<select id= "searchMedListByKeyWord" resultType= "com.openhis.medication.dto.AdjustPriceMedListDto" >
select med_def.id as targetId, med_def.name as name, med.total_volume as volume, details.amount as
originRetailPrice,def_details.amount as originBuyingPrice,med_def.bus_no as busNo,med_def.min_unit_code as unitCode
from med_medication med
inner join med_medication_definition med_def on med.medication_def_id = med_def.id
inner join adm_charge_item_definition actd on actd.instance_id = med_def.id
left join adm_charge_item_def_detail details on actd.id = details.definition_id
and details.id = (select cidd.id from adm_charge_item_def_detail cidd where actd.id = cidd.definition_id and
cidd.condition_code = '5' and cidd.delete_flag = '0' ORDER BY create_time DESC
LIMIT 1)
left join adm_charge_item_def_detail def_details on actd.id = def_details.definition_id
and def_details.id = (select cidd.id from adm_charge_item_def_detail cidd where actd.id = cidd.definition_id and
cidd.condition_code = '1' and cidd.delete_flag = '0' ORDER BY create_time DESC
LIMIT 1)
WHERE med.delete_flag = '0' and med_def.id in (select inventoty.item_id FROM wor_inventory_item inventoty where
inventoty.quantity > 0 and inventoty.delete_flag = '0' )
<if test= "keyWord == ''" >
limit 10
</if>
<if test= "keyWord !=''" >
and
(med_def.name like concat('%',#{keyWord},'%') or med_def.merchandise_name like concat('%',#{keyWord},'%') or
med_def.py_str like concat('%',#{keyWord},'%') or
med_def.wb_str like concat('%',#{keyWord},'%') or med_def.merchandise_py_str like concat('%',#{keyWord},'%')
or med_def.merchandise_wb_str like concat('%',#{keyWord},'%'))
</if>
</select>
</mapper>