提交merge1.3
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
<select id="selectAmbPractitionerDetailPage"
|
||||
resultType="com.openhis.web.pharmacymanage.dto.MedDetailedAccountPageDto">
|
||||
select A.outpatient_no,
|
||||
<<<<<<< HEAD
|
||||
A.prescription_no,
|
||||
A.patient_name,
|
||||
A.practitioner_id,
|
||||
@@ -191,6 +192,232 @@
|
||||
ORDER BY A.dispense_time DESC
|
||||
</when>
|
||||
<when test="dispenseEnum == 2">
|
||||
=======
|
||||
A.prescription_no,
|
||||
A.patient_name,
|
||||
A.practitioner_id,
|
||||
A.practitioner_name,
|
||||
A.medication_name,
|
||||
A.py_str,
|
||||
A.bus_no,
|
||||
A.dispense_no,
|
||||
A.yb_no,
|
||||
A.total_volume,
|
||||
A.dispense_quantity,
|
||||
A.dispense_price,
|
||||
A.refund_quantity,
|
||||
A.refund_price,
|
||||
A.lot_number,
|
||||
A.manufacturer_text,
|
||||
A.supplier_name,
|
||||
A.unit_code,
|
||||
A.refund_unit_code,
|
||||
A.dispense_time,
|
||||
A.location_id,
|
||||
A.item_table,
|
||||
A.cost_price
|
||||
from (
|
||||
WITH refund_info AS (
|
||||
SELECT mmr.refund_medicine_id,
|
||||
mmd.dispense_quantity,
|
||||
mmd.unit_code,
|
||||
aci.total_price
|
||||
FROM med_medication_dispense mmd
|
||||
LEFT JOIN med_medication_request mmr
|
||||
ON mmd.med_req_id = mmr.id
|
||||
AND mmr.delete_flag = '0'
|
||||
INNER JOIN adm_charge_item aci
|
||||
ON aci.service_id = mmr.refund_medicine_id
|
||||
AND aci.delete_flag = '0'
|
||||
WHERE mmd.status_enum = #{refunded}
|
||||
AND mmd.delete_flag = '0'
|
||||
AND mmr.refund_medicine_id IS not null
|
||||
),
|
||||
refund_device_info AS (
|
||||
SELECT wdr.refund_device_id,
|
||||
wdd.dispense_quantity,
|
||||
wdd.unit_code,
|
||||
aci.total_price
|
||||
FROM wor_device_dispense wdd
|
||||
LEFT JOIN wor_device_request wdr
|
||||
ON wdd.device_req_id = wdr.id
|
||||
AND wdr.delete_flag = '0'
|
||||
INNER JOIN adm_charge_item aci
|
||||
ON aci.service_id = wdr.refund_device_id
|
||||
AND aci.delete_flag = '0'
|
||||
WHERE wdd.status_enum = #{refunded}
|
||||
AND wdd.delete_flag = '0'
|
||||
AND wdr.refund_device_id IS not null
|
||||
)
|
||||
SELECT def."name" AS medication_name,
|
||||
def.py_str,
|
||||
def.bus_no,
|
||||
def.yb_no,
|
||||
def.manufacturer_text,
|
||||
mmr.prescription_no,
|
||||
ae.bus_no AS outpatient_no,
|
||||
pat.name AS patient_name,
|
||||
mm.total_volume,
|
||||
mmd.unit_code,
|
||||
mmd.bus_no AS dispense_no,
|
||||
mmd.lot_number,
|
||||
mmd.dispense_quantity,
|
||||
mmd.encounter_id,
|
||||
mmd.practitioner_id,
|
||||
mmd.dispense_time,
|
||||
ap.name AS practitioner_name,
|
||||
mmd.location_id,
|
||||
aci.total_price AS dispense_price,
|
||||
ri.dispense_quantity AS refund_quantity,
|
||||
ri.unit_code AS refund_unit_code,
|
||||
ri.total_price AS refund_price,
|
||||
wii.supplier_id,
|
||||
sup.name AS supplier_name,
|
||||
mmd.tenant_id,
|
||||
#{medMedicationDefinition} AS item_table,
|
||||
CASE
|
||||
WHEN mmd.unit_code = def.min_unit_code THEN
|
||||
(mmd.dispense_quantity * acidd.amount) / COALESCE(def.part_percent, 1)
|
||||
ELSE
|
||||
mmd.dispense_quantity * acidd.amount
|
||||
END AS cost_price
|
||||
FROM med_medication_dispense mmd
|
||||
LEFT JOIN med_medication_request mmr
|
||||
ON mmd.med_req_id = mmr.id
|
||||
AND mmr.delete_flag = '0'
|
||||
INNER JOIN adm_charge_item aci
|
||||
ON aci.service_id = mmr.id
|
||||
AND aci.delete_flag = '0'
|
||||
LEFT JOIN med_medication_definition def
|
||||
ON mmd.medication_id = def.id
|
||||
AND def.delete_flag = '0'
|
||||
LEFT JOIN med_medication mm
|
||||
ON mm.medication_def_id = def.id
|
||||
AND mm.delete_flag = '0'
|
||||
LEFT JOIN wor_inventory_item wii
|
||||
ON wii.item_id = mmd.medication_id
|
||||
AND wii.lot_number = mmd.lot_number
|
||||
AND wii.location_id = mmd.location_id
|
||||
AND wii.delete_flag = '0'
|
||||
LEFT JOIN refund_info AS ri
|
||||
ON ri.refund_medicine_id = mmr.id
|
||||
LEFT JOIN adm_location al
|
||||
ON al.id = mmd.location_id
|
||||
LEFT JOIN adm_practitioner ap
|
||||
ON ap.id = mmd.practitioner_id
|
||||
LEFT JOIN adm_patient pat
|
||||
ON pat.id = mmd.patient_id
|
||||
LEFT JOIN adm_encounter ae
|
||||
ON ae.id = mmd.encounter_id
|
||||
LEFT JOIN adm_supplier sup
|
||||
ON sup.id = wii.supplier_id
|
||||
LEFT JOIN adm_charge_item_definition acid on acid.instance_table = #{medMedicationDefinition} AND
|
||||
acid.instance_id = def.id AND acid.delete_flag = '0'
|
||||
LEFT JOIN adm_charge_item_def_detail acidd
|
||||
ON acid.id = acidd.definition_id
|
||||
AND acidd.id = (
|
||||
SELECT cidd.id
|
||||
FROM adm_charge_item_def_detail cidd
|
||||
WHERE acid.id = cidd.definition_id
|
||||
AND cidd.condition_code = #{costEnum}
|
||||
AND cidd.delete_flag = '0'
|
||||
AND cidd.condition_value = mmd.lot_number
|
||||
ORDER BY create_time DESC
|
||||
LIMIT 1
|
||||
)
|
||||
WHERE mmd.status_enum = #{completed}
|
||||
AND mmr.status_enum = #{agree}
|
||||
AND ae.class_enum = #{flg}
|
||||
AND mmd.delete_flag = '0'
|
||||
UNION
|
||||
SELECT def."name" AS medication_name,
|
||||
def.py_str,
|
||||
def.bus_no,
|
||||
def.yb_no,
|
||||
def.manufacturer_text,
|
||||
mmr.prescription_no,
|
||||
ae.bus_no AS outpatient_no,
|
||||
pat.name AS patient_name,
|
||||
def.size AS total_volume,
|
||||
mmd.unit_code,
|
||||
mmd.bus_no AS dispense_no,
|
||||
mmd.lot_number,
|
||||
mmd.dispense_quantity,
|
||||
mmd.encounter_id,
|
||||
mmd.performer_id AS practitioner_id,
|
||||
mmd.dispense_time,
|
||||
ap.name AS practitioner_name,
|
||||
mmd.location_id,
|
||||
aci.total_price AS dispense_price,
|
||||
ri.dispense_quantity AS refund_quantity,
|
||||
ri.unit_code AS refund_unit_code,
|
||||
ri.total_price AS refund_price,
|
||||
wii.supplier_id,
|
||||
sup.name AS supplier_name,
|
||||
mmd.tenant_id,
|
||||
#{admDeviceDefinition} AS item_table,
|
||||
CASE
|
||||
WHEN mmd.unit_code = def.min_unit_code THEN
|
||||
(mmd.dispense_quantity * acidd.amount) / COALESCE(def.part_percent, 1)
|
||||
ELSE
|
||||
mmd.dispense_quantity * acidd.amount
|
||||
END AS cost_price
|
||||
FROM wor_device_dispense mmd
|
||||
LEFT JOIN wor_device_request mmr
|
||||
ON mmd.device_req_id = mmr.id
|
||||
AND mmr.delete_flag = '0'
|
||||
INNER JOIN adm_charge_item aci
|
||||
ON aci.service_id = mmr.id
|
||||
AND aci.delete_flag = '0'
|
||||
LEFT JOIN adm_device_definition def
|
||||
ON mmd.device_def_id = def.id
|
||||
AND def.delete_flag = '0'
|
||||
LEFT JOIN adm_device mm
|
||||
ON mm.device_def_id = def.id
|
||||
AND mm.delete_flag = '0'
|
||||
LEFT JOIN wor_inventory_item wii
|
||||
ON wii.item_id = mmd.device_def_id
|
||||
AND wii.lot_number = mmd.lot_number
|
||||
AND wii.location_id = mmd.location_id
|
||||
AND wii.delete_flag = '0'
|
||||
LEFT JOIN refund_device_info AS ri
|
||||
ON ri.refund_device_id = mmr.id
|
||||
LEFT JOIN adm_location al
|
||||
ON al.id = mmd.location_id
|
||||
LEFT JOIN adm_practitioner ap
|
||||
ON ap.id = mmd.performer_id
|
||||
LEFT JOIN adm_patient pat
|
||||
ON pat.id = mmd.patient_id
|
||||
LEFT JOIN adm_encounter ae
|
||||
ON ae.id = mmd.encounter_id
|
||||
LEFT JOIN adm_supplier sup
|
||||
ON sup.id = wii.supplier_id
|
||||
LEFT JOIN adm_charge_item_definition acid ON acid.instance_table = #{admDeviceDefinition} AND acid.instance_id
|
||||
= def.id AND acid.delete_flag = '0'
|
||||
LEFT JOIN adm_charge_item_def_detail acidd
|
||||
ON acid.id = acidd.definition_id
|
||||
AND acidd.id = (
|
||||
SELECT cidd.id
|
||||
FROM adm_charge_item_def_detail cidd
|
||||
WHERE acid.id = cidd.definition_id
|
||||
AND cidd.condition_code = #{costEnum}
|
||||
AND cidd.delete_flag = '0'
|
||||
AND cidd.condition_value = mmd.lot_number
|
||||
ORDER BY create_time DESC
|
||||
LIMIT 1
|
||||
)
|
||||
WHERE mmd.status_enum = #{completed}
|
||||
AND mmr.status_enum = #{agree}
|
||||
AND ae.class_enum = #{flg}
|
||||
AND mmd.delete_flag = '0'
|
||||
) AS A
|
||||
${ew.customSqlSegment}
|
||||
<choose>
|
||||
<when test="statisticalType == 1 || statisticalType ==3 || statisticalType ==5">
|
||||
ORDER BY A.dispense_time DESC
|
||||
</when>
|
||||
<when test="statisticalType == 2 || statisticalType ==4 || statisticalType ==6">
|
||||
>>>>>>> v1.3
|
||||
ORDER BY A.outpatient_no DESC, A.prescription_no DESC
|
||||
</when>
|
||||
</choose>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<mapper namespace="com.openhis.web.pharmacymanage.mapper.ReturnMedicineMapper">
|
||||
<select id="selectEncounterInfoListPage" resultType="com.openhis.web.pharmacymanage.dto.EncounterInfoDto">
|
||||
SELECT ii.reception_time,
|
||||
ii.start_time,
|
||||
ii.encounter_id,
|
||||
ii.encounter_no,
|
||||
ii.tenant_id,
|
||||
@@ -19,7 +20,9 @@
|
||||
ae.id AS encounter_id,
|
||||
ae.bus_no AS encounter_no,
|
||||
ae.tenant_id,
|
||||
mmr.status_enum AS refund_enum,
|
||||
ae.start_time,
|
||||
ae.class_enum,
|
||||
mmd.status_enum AS refund_enum,
|
||||
ap."name" AS patient_name,
|
||||
ap.wb_str AS patient_wb_str,
|
||||
ap.py_str AS patient_py_str,
|
||||
@@ -30,18 +33,25 @@
|
||||
FROM adm_encounter ae
|
||||
LEFT JOIN med_medication_request mmr
|
||||
ON mmr.encounter_id = ae.id
|
||||
AND mmr.delete_flag = '0'
|
||||
LEFT JOIN med_medication_dispense mmd
|
||||
ON mmd.med_req_id = mmr.id
|
||||
AND mmd.delete_flag = '0'
|
||||
LEFT JOIN adm_patient ap
|
||||
ON ae.patient_id = ap.id
|
||||
AND ap.delete_flag = '0'
|
||||
LEFT JOIN adm_organization ao
|
||||
ON ao.id = ae.organization_id
|
||||
AND ao.delete_flag = '0'
|
||||
WHERE mmr.refund_medicine_id IS NOT NULL
|
||||
AND ae.class_enum = #{amb}
|
||||
UNION
|
||||
SELECT ae.reception_time,
|
||||
ae.id AS encounter_id,
|
||||
ae.bus_no AS encounter_no,
|
||||
ae.tenant_id,
|
||||
wdr.status_enum AS refund_enum,
|
||||
ae.start_time,
|
||||
ae.class_enum,
|
||||
wdd.status_enum AS refund_enum,
|
||||
ap."name" AS patient_name,
|
||||
ap.wb_str AS patient_wb_str,
|
||||
ap.py_str AS patient_py_str,
|
||||
@@ -52,12 +62,17 @@
|
||||
FROM adm_encounter ae
|
||||
LEFT JOIN wor_device_request wdr
|
||||
ON wdr.encounter_id = ae.id
|
||||
AND wdr.delete_flag = '0'
|
||||
LEFT JOIN wor_device_dispense wdd
|
||||
ON wdd.device_req_id = wdr.id
|
||||
AND wdd.delete_flag = '0'
|
||||
LEFT JOIN adm_patient ap
|
||||
ON ae.patient_id = ap.id
|
||||
AND ap.delete_flag = '0'
|
||||
LEFT JOIN adm_organization ao
|
||||
ON ao.id = ae.organization_id
|
||||
AND ao.delete_flag = '0'
|
||||
WHERE wdr.refund_device_id IS NOT NULL
|
||||
AND ae.class_enum = #{amb}
|
||||
) AS ii
|
||||
${ew.customSqlSegment}
|
||||
ORDER BY ii.reception_time DESC
|
||||
@@ -68,6 +83,7 @@
|
||||
<when test="(medDispenseIdList != null and !medDispenseIdList.isEmpty())
|
||||
or (devDispenseIdList != null and !devDispenseIdList.isEmpty())">
|
||||
<if test="medDispenseIdList != null and !medDispenseIdList.isEmpty()">
|
||||
<<<<<<< HEAD
|
||||
SELECT
|
||||
T1.id AS dispense_id,
|
||||
T1.unit_code AS dispense_unit,
|
||||
@@ -83,16 +99,35 @@
|
||||
T3.part_percent,
|
||||
T3."name" AS item_name,
|
||||
T3.id AS item_id
|
||||
=======
|
||||
SELECT T1.id AS dispense_id,
|
||||
T1.unit_code AS dispense_unit,
|
||||
T1.quantity,
|
||||
T1.location_id,
|
||||
T1.lot_number,
|
||||
T1.dispense_quantity,
|
||||
T1.status_enum AS dispense_status,
|
||||
T1.trace_no,
|
||||
T1.med_req_id AS request_id,
|
||||
T2.id AS inventory_id,
|
||||
T2.unit_code AS inventory_unit_code,
|
||||
T2.quantity AS inventory_quantity,
|
||||
T2.inventory_status_enum,
|
||||
T2.expiration_date,
|
||||
T3.part_percent,
|
||||
T3."name" AS item_name,
|
||||
T1.medication_id AS item_id
|
||||
>>>>>>> v1.3
|
||||
FROM med_medication_dispense AS T1
|
||||
INNER JOIN wor_inventory_item AS T2
|
||||
ON T1.medication_id = T2.item_id
|
||||
AND T2.delete_flag = '0'
|
||||
AND T2.item_table = #{medMedicationDefinition}
|
||||
AND T1.lot_number = T2.lot_number
|
||||
AND T1.location_id = T2.location_id
|
||||
INNER JOIN med_medication_definition AS T3
|
||||
ON T1.medication_id = T3.id
|
||||
AND T3.delete_flag = '0'
|
||||
INNER JOIN wor_inventory_item AS T2
|
||||
ON T1.medication_id = T2.item_id
|
||||
AND T2.delete_flag = '0'
|
||||
AND T2.item_table = #{medMedicationDefinition}
|
||||
AND T1.lot_number = T2.lot_number
|
||||
AND T1.location_id = T2.location_id
|
||||
INNER JOIN med_medication_definition AS T3
|
||||
ON T1.medication_id = T3.id
|
||||
AND T3.delete_flag = '0'
|
||||
WHERE T1.id IN
|
||||
<foreach collection="medDispenseIdList" item="medDispenseId" open="(" separator="," close=")">
|
||||
#{medDispenseId}
|
||||
@@ -104,6 +139,7 @@
|
||||
UNION
|
||||
</if>
|
||||
<if test="devDispenseIdList != null and !devDispenseIdList.isEmpty()">
|
||||
<<<<<<< HEAD
|
||||
SELECT
|
||||
T4.id AS dispense_id,
|
||||
T4.unit_code AS dispense_unit,
|
||||
@@ -119,16 +155,35 @@
|
||||
T5.part_percent,
|
||||
T5."name" AS item_name,
|
||||
T5.id AS item_id
|
||||
=======
|
||||
SELECT T4.id AS dispense_id,
|
||||
T4.unit_code AS dispense_unit,
|
||||
T4.quantity,
|
||||
T4.location_id,
|
||||
T4.lot_number,
|
||||
T4.dispense_quantity,
|
||||
T4.status_enum AS dispense_status,
|
||||
T4.trace_no,
|
||||
T4.device_req_id AS request_id,
|
||||
T2.id AS inventory_id,
|
||||
T2.unit_code AS inventory_unit_code,
|
||||
T2.quantity AS inventory_quantity,
|
||||
T2.inventory_status_enum,
|
||||
T2.expiration_date,
|
||||
T5.part_percent,
|
||||
T5."name" AS item_name,
|
||||
T4.device_def_id AS item_id
|
||||
>>>>>>> v1.3
|
||||
FROM wor_device_dispense AS T4
|
||||
INNER JOIN wor_inventory_item AS T2
|
||||
ON T4.device_def_id = T2.item_id
|
||||
AND T2.delete_flag = '0'
|
||||
AND T2.item_table = #{admDeviceDefinition}
|
||||
AND T4.lot_number = T2.lot_number
|
||||
AND T4.location_id = T2.location_id
|
||||
INNER JOIN adm_device_definition AS T5
|
||||
ON T4.device_def_id = T5.id
|
||||
AND T5.delete_flag = '0'
|
||||
INNER JOIN wor_inventory_item AS T2
|
||||
ON T4.device_def_id = T2.item_id
|
||||
AND T2.delete_flag = '0'
|
||||
AND T2.item_table = #{admDeviceDefinition}
|
||||
AND T4.lot_number = T2.lot_number
|
||||
AND T4.location_id = T2.location_id
|
||||
INNER JOIN adm_device_definition AS T5
|
||||
ON T4.device_def_id = T5.id
|
||||
AND T5.delete_flag = '0'
|
||||
WHERE T4.id IN
|
||||
<foreach collection="devDispenseIdList" item="devDispenseId" open="(" separator="," close=")">
|
||||
#{devDispenseId}
|
||||
@@ -143,9 +198,9 @@
|
||||
SELECT mmd.status_enum AS refund_enum,
|
||||
mmr.refund_medicine_id,
|
||||
mmr.id AS request_id,
|
||||
mmr.quantity,
|
||||
mmd.quantity,
|
||||
mmr.unit_code,
|
||||
mmr.lot_number,
|
||||
mmd.lot_number,
|
||||
mmr.status_enum AS req_status,
|
||||
mmd.dispense_quantity,
|
||||
mmd.id AS dispense_id,
|
||||
@@ -157,7 +212,7 @@
|
||||
mmd.trace_no
|
||||
FROM med_medication_request mmr
|
||||
LEFT JOIN med_medication_dispense mmd
|
||||
ON mmr.refund_medicine_id = mmd.med_req_id
|
||||
ON mmr.id = mmd.med_req_id
|
||||
AND mmd.delete_flag = '0'
|
||||
INNER JOIN med_medication_definition med
|
||||
ON mmr.medication_id = med.id
|
||||
@@ -172,13 +227,10 @@
|
||||
AND mmr.encounter_id = #{encounterId}
|
||||
AND aci.service_table =#{medMedicationRequest}
|
||||
<if test="refundStatus == null">
|
||||
AND mmr.status_enum IN (#{inRefund},#{completed})
|
||||
AND mmd.status_enum IN (#{refunded},#{pendingRefund})
|
||||
</if>
|
||||
<if test="refundStatus == 5">
|
||||
AND mmr.status_enum = #{inRefund}
|
||||
</if>
|
||||
<if test="refundStatus == 3">
|
||||
AND mmr.status_enum = #{completed}
|
||||
<if test="refundStatus != null">
|
||||
AND mmd.status_enum = #{refundStatus}
|
||||
</if>
|
||||
AND mmr.delete_flag = '0'
|
||||
UNION
|
||||
@@ -187,7 +239,7 @@
|
||||
wdr.id AS request_id,
|
||||
wdr.quantity,
|
||||
wdr.unit_code,
|
||||
wdr.lot_number,
|
||||
wdd.lot_number,
|
||||
wdr.status_enum AS req_status,
|
||||
wdd.dispense_quantity,
|
||||
wdd.id AS dispense_id,
|
||||
@@ -199,7 +251,7 @@
|
||||
wdd.trace_no
|
||||
FROM wor_device_request wdr
|
||||
LEFT JOIN wor_device_dispense wdd
|
||||
ON wdr.refund_device_id = wdd.device_req_id
|
||||
ON wdr.id = wdd.device_req_id
|
||||
AND wdd.delete_flag = '0'
|
||||
INNER JOIN adm_device_definition dev
|
||||
ON wdr.device_def_id = dev.id
|
||||
@@ -213,15 +265,12 @@
|
||||
WHERE wdr.refund_device_id IS NOT NULL
|
||||
AND wdr.encounter_id =#{encounterId}
|
||||
AND aci.service_table =#{worDeviceRequest}
|
||||
<if test="refundStatus == null">
|
||||
AND wdr.status_enum IN (#{inRefund},#{completed})
|
||||
</if>
|
||||
<if test="refundStatus == 5">
|
||||
AND wdr.status_enum = #{inRefund}
|
||||
</if>
|
||||
<if test="refundStatus == 3">
|
||||
AND wdr.status_enum = #{completed}
|
||||
</if>
|
||||
<if test="refundStatus == null">
|
||||
AND wdd.status_enum IN (#{refunded},#{pendingRefund})
|
||||
</if>
|
||||
<if test="refundStatus != null">
|
||||
AND wdd.status_enum = #{refundStatus}
|
||||
</if>
|
||||
AND wdr.delete_flag = '0'
|
||||
</select>
|
||||
<select id="selectReturnItemDetail" resultType="com.openhis.web.pharmacymanage.dto.DispenseInventoryDto">
|
||||
@@ -238,6 +287,7 @@
|
||||
T1.dispense_time,
|
||||
T1.bus_no AS dispense_no,
|
||||
T1.trace_no,
|
||||
T2.refund_medicine_id AS refund_id,
|
||||
T3.Id AS inventory_id,
|
||||
T3.unit_code AS inventory_unit_code,
|
||||
T3.quantity AS inventory_quantity,
|
||||
@@ -305,6 +355,7 @@
|
||||
T10.dispense_time,
|
||||
T10.bus_no AS dispense_no,
|
||||
T10.trace_no,
|
||||
T11.refund_device_id AS refund_id,
|
||||
T3.Id AS inventory_id,
|
||||
T3.unit_code AS inventory_unit_code,
|
||||
T3.quantity AS inventory_quantity,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?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.web.pharmacymanage.mapper.SummaryDispenseMedicineMapper">
|
||||
<<<<<<< HEAD
|
||||
<select id="selectMedicationSummaryInfo" resultType="com.openhis.web.pharmacymanage.dto.MedicineSummaryDto">
|
||||
SELECT ii.tenant_id,
|
||||
ii.bus_no,--单据号
|
||||
@@ -181,4 +182,6 @@
|
||||
) AS li
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
=======
|
||||
>>>>>>> v1.3
|
||||
</mapper>
|
||||
|
||||
@@ -1,6 +1,56 @@
|
||||
<?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.web.pharmacymanage.mapper.WesternMedicineDispenseMapper">
|
||||
<resultMap id="medicineDispenseOrderMap" type="com.openhis.web.pharmacymanage.dto.ItemDispenseOrderDto">
|
||||
<result property="lotNumber" column="lot_number"/>
|
||||
<result property="departmentName" column="department_name"/>
|
||||
<result property="doctorId" column="doctor_id"/>
|
||||
<result property="doctorName" column="doctor_name"/>
|
||||
<result property="itemType" column="item_type"/>
|
||||
<result property="conditionName" column="condition_name"/>
|
||||
<result property="prescriptionNo" column="prescription_no"/>
|
||||
<result property="requestId" column="request_id"/>
|
||||
<result property="tcmFlag" column="tcm_flag"/>
|
||||
<result property="itemName" column="item_name"/>
|
||||
<result property="itemId" column="item_id"/>
|
||||
<result property="totalVolume" column="total_volume"/>
|
||||
<result property="unitCode" column="unit_code"/>
|
||||
<result property="encounterId" column="encounter_id"/>
|
||||
<result property="dose" column="dose"/>
|
||||
<result property="statusEnum" column="status_enum"/>
|
||||
<result property="rateCode" column="rate_code"/>
|
||||
<result property="locationId" column="location_id"/>
|
||||
<result property="methodCode" column="method_code"/>
|
||||
<result property="doseUnitCode" column="dose_unit_code"/>
|
||||
<result property="dispensePerQuantity" column="dispense_per_quantity"/>
|
||||
<result property="dispensePerDuration" column="dispense_per_duration"/>
|
||||
<result property="requestQuantity" column="request_quantity"/>
|
||||
<result property="quantity" column="quantity"/>
|
||||
<result property="dispenseId" column="dispense_id"/>
|
||||
<result property="unitPrice" column="unit_price"/>
|
||||
<result property="totalPrice" column="total_price"/>
|
||||
<result property="dispenseDoctorName" column="dispense_doctor_name"/>
|
||||
<result property="locationName" column="location_name"/>
|
||||
<result property="encounterBusNo" column="encounter_bus_no"/>
|
||||
<result property="reqAuthoredTime" column="req_authored_time"/>
|
||||
<result property="skinTestFlag" column="skin_test_flag"/>
|
||||
<result property="injectFlag" column="inject_flag"/>
|
||||
<result property="groupId" column="group_id"/>
|
||||
<result property="manufacturerText" column="manufacturer_text"/>
|
||||
<result property="medTypeCode" column="med_type_code"/>
|
||||
<result property="merchandiseName" column="merchandise_name"/>
|
||||
<result property="traceNo" column="trace_no"/>
|
||||
<result property="partAttributeEnum" column="part_attribute_enum"/>
|
||||
<collection property="inventoryDetailList" ofType="com.openhis.web.pharmacymanage.dto.InventoryDetailDto">
|
||||
<result property="inventoryId" column="inventory_id"/>
|
||||
<result property="maxUnitCode" column="max_unit_code"/>
|
||||
<result property="partPercent" column="part_percent"/>
|
||||
<result property="inventoryUnitCode" column="inventory_unit_code"/>
|
||||
<result property="inventoryQuantity" column="inventory_quantity"/>
|
||||
<result property="inventoryLotNumber" column="inventory_lot_number"/>
|
||||
<result property="expirationDate" column="expiration_date"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
<select id="selectEncounterInfoListPage" resultType="com.openhis.web.pharmacymanage.dto.EncounterInfoDto">
|
||||
SELECT ii.encounter_id,
|
||||
ii.encounter_no,
|
||||
@@ -12,8 +62,11 @@
|
||||
ii.department_id,
|
||||
ii.id_card,
|
||||
ii.birth_date,
|
||||
ii.phone,
|
||||
ii.reception_time,
|
||||
ii.start_time,
|
||||
ii.status_enum
|
||||
<<<<<<< HEAD
|
||||
FROM ( SELECT T1.tenant_id,
|
||||
T1.id AS encounter_id,
|
||||
T1.bus_no AS encounter_no,
|
||||
@@ -50,6 +103,46 @@
|
||||
<if test="statusEnum == 4">
|
||||
T4.status_enum = #{completed}
|
||||
</if>
|
||||
=======
|
||||
FROM ( SELECT T1.tenant_id,
|
||||
T1.id AS encounter_id,
|
||||
T1.bus_no AS encounter_no,
|
||||
T1.reception_time,
|
||||
T1.start_time,
|
||||
T1.organization_id AS department_id,
|
||||
T1.class_enum,
|
||||
T2.gender_enum,
|
||||
T2.name AS patient_name,
|
||||
T2.wb_str AS patient_wb_str,
|
||||
T2.py_str AS patient_py_str,
|
||||
T2.id_card,
|
||||
T2.birth_date,
|
||||
T2.phone,
|
||||
T3.name AS department_name,
|
||||
T4.status_enum
|
||||
FROM adm_encounter AS T1
|
||||
INNER JOIN adm_patient AS T2
|
||||
ON T1.patient_id = T2.id
|
||||
AND T2.delete_flag = '0'
|
||||
LEFT JOIN adm_organization AS T3
|
||||
ON T1.organization_id = T3.id
|
||||
AND T3.delete_flag = '0'
|
||||
INNER JOIN med_medication_dispense AS T4
|
||||
ON T4.encounter_id = T1.id
|
||||
AND T4.delete_flag = '0'
|
||||
INNER JOIN med_medication_request AS T5
|
||||
ON T4.med_req_id = T5.id
|
||||
AND T5.delete_flag = '0'
|
||||
WHERE <if test="statusEnum == null">
|
||||
T4.status_enum IN (#{inProgress},#{completed},#{preparation},#{prepared})
|
||||
</if>
|
||||
<if test="statusEnum == 3">
|
||||
T4.status_enum IN (#{inProgress},#{preparation},#{prepared})
|
||||
</if>
|
||||
<if test="statusEnum == 4">
|
||||
T4.status_enum = #{completed}
|
||||
</if>
|
||||
>>>>>>> v1.3
|
||||
) AS ii
|
||||
${ew.customSqlSegment}
|
||||
GROUP BY ii.encounter_id,
|
||||
@@ -62,10 +155,14 @@
|
||||
ii.department_id,
|
||||
ii.id_card,
|
||||
ii.birth_date,
|
||||
ii.phone,
|
||||
ii.reception_time,
|
||||
ii.start_time,
|
||||
ii.status_enum
|
||||
ORDER BY ii.reception_time DESC
|
||||
ORDER BY ii.reception_time,
|
||||
ii.start_time DESC
|
||||
</select>
|
||||
<<<<<<< HEAD
|
||||
<select id="selectMedicineDispenseOrderPage" resultType="com.openhis.web.pharmacymanage.dto.ItemDispenseOrderDto">
|
||||
SELECT ii.department_name,
|
||||
ii.doctor_id,
|
||||
@@ -183,17 +280,218 @@
|
||||
T1.status_enum = #{completed}
|
||||
</if>
|
||||
ORDER BY prescription_no DESC
|
||||
=======
|
||||
<select id="selectMedicineDispenseOrderPage" resultMap="medicineDispenseOrderMap">
|
||||
SELECT ii.department_name,
|
||||
ii.doctor_id,
|
||||
ii.doctor_name,
|
||||
ii.item_type,
|
||||
ii.condition_name,
|
||||
ii.prescription_no,
|
||||
ii.lot_number,
|
||||
ii.request_id,
|
||||
ii.tcm_flag,
|
||||
ii.item_name,
|
||||
ii.merchandise_name,
|
||||
ii.item_id,
|
||||
ii.total_volume,
|
||||
ii.unit_code,
|
||||
ii.encounter_id,
|
||||
ii.dose,
|
||||
ii.status_enum,
|
||||
ii.rate_code,
|
||||
ii.location_id,
|
||||
ii.method_code,
|
||||
ii.dose_unit_code,
|
||||
ii.dispense_per_quantity,
|
||||
ii.dispense_per_duration,
|
||||
ii.request_quantity,
|
||||
ii.quantity,
|
||||
ii.dispense_id,
|
||||
ii.unit_price,
|
||||
ii.total_price,
|
||||
ii.dispense_doctor_name,
|
||||
ii.location_name,
|
||||
ii.encounter_bus_no,
|
||||
ii.req_authored_time,
|
||||
ii.skin_test_flag,
|
||||
ii.group_id,
|
||||
ii.manufacturer_text,
|
||||
ii.trace_no,
|
||||
ii.max_unit_code,
|
||||
ii.part_percent,
|
||||
ii.inject_flag,
|
||||
ii.part_attribute_enum,
|
||||
ii.inventory_id,
|
||||
ii.inventory_unit_code,
|
||||
ii.inventory_quantity,
|
||||
ii.inventory_lot_number,
|
||||
ii.expiration_date,
|
||||
ii.med_type_code
|
||||
FROM ( SELECT T8."name" AS department_name,
|
||||
T9.id AS doctor_id,
|
||||
T9."name" AS doctor_name,
|
||||
T3.category_code AS item_type,
|
||||
T7."name" AS condition_name,
|
||||
T2.prescription_no,
|
||||
T2.id AS request_id,
|
||||
T2.tcm_flag,
|
||||
T3."name" AS item_name,
|
||||
T3.merchandise_name,
|
||||
T3.id AS item_id,
|
||||
T4.total_volume,
|
||||
T1.unit_code,
|
||||
T1.encounter_id,
|
||||
T1.dose,
|
||||
T1.status_enum,
|
||||
T2.rate_code,
|
||||
T1.location_id,
|
||||
T1.method_code,
|
||||
T1.lot_number,
|
||||
T2.dose_unit_code,
|
||||
T2.dispense_per_quantity,
|
||||
T2.dispense_per_duration,
|
||||
T2.quantity AS request_quantity,
|
||||
T1.quantity,
|
||||
T1.id AS dispense_id,
|
||||
T5.unit_price,
|
||||
T5.total_price,
|
||||
T10."name" AS dispense_doctor_name,
|
||||
T13."name" AS location_name,
|
||||
T6.bus_no AS encounter_bus_no,
|
||||
T2.req_authored_time,
|
||||
T3.skin_test_flag,
|
||||
T2.group_id AS group_id,
|
||||
T1.tenant_id,
|
||||
T3.manufacturer_text,
|
||||
T1.trace_no,
|
||||
T3.unit_code AS max_unit_code,
|
||||
T3.part_percent,
|
||||
T3.inject_flag,
|
||||
T3.part_attribute_enum,
|
||||
T14.id AS inventory_id,
|
||||
T14.unit_code AS inventory_unit_code,
|
||||
T14.quantity AS inventory_quantity,
|
||||
T14.lot_number AS inventory_lot_number,
|
||||
T14.expiration_date,
|
||||
T15.med_type_code
|
||||
FROM med_medication_dispense AS T1
|
||||
LEFT JOIN med_medication_request AS T2
|
||||
ON T1.med_req_id = T2.id
|
||||
AND T2.delete_flag = '0'
|
||||
LEFT JOIN med_medication_definition AS T3
|
||||
ON T1.medication_id = T3.id
|
||||
AND T3.delete_flag = '0'
|
||||
LEFT JOIN med_medication AS T4
|
||||
ON T3.id = T4.medication_def_id
|
||||
AND T4.delete_flag = '0'
|
||||
INNER JOIN adm_charge_item AS T5
|
||||
ON T1.med_req_id = T5.service_id
|
||||
AND T5.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter AS T6
|
||||
ON T1.encounter_id = T6.id
|
||||
AND T6.delete_flag = '0'
|
||||
LEFT JOIN cli_condition AS T12
|
||||
ON T2.condition_id = T12.id
|
||||
AND T12.delete_flag = '0'
|
||||
LEFT JOIN cli_condition_definition AS T7
|
||||
ON T12.definition_id = T7.id
|
||||
AND T7.delete_flag = '0'
|
||||
LEFT JOIN adm_organization AS T8
|
||||
ON T6.organization_id = T8.id
|
||||
AND T8.delete_flag = '0'
|
||||
LEFT JOIN adm_practitioner AS T9
|
||||
ON T2.practitioner_id = T9.id
|
||||
AND T9.delete_flag = '0'
|
||||
LEFT JOIN adm_practitioner AS T10
|
||||
ON T1.practitioner_id = T10.id
|
||||
AND T10.delete_flag = '0'
|
||||
LEFT JOIN adm_location AS T13
|
||||
ON T1.location_id = T13.id
|
||||
AND T13.delete_flag = '0'
|
||||
LEFT JOIN wor_inventory_item AS T14
|
||||
ON T2.medication_id = T14.item_id
|
||||
AND T1.location_id = T14.location_id
|
||||
AND T14.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter_diagnosis AS T15
|
||||
ON T2.encounter_diagnosis_id = T15.id
|
||||
AND T15.delete_flag = '0'
|
||||
WHERE T1.delete_flag = '0'
|
||||
-- 因发药配药合并,前台只能看到待发药,已发药状态,但是后台配药发药状态都查
|
||||
AND
|
||||
<if test="dispenseStatus == null">
|
||||
T1.status_enum IN (#{inProgress},#{completed},#{preparation},#{prepared})
|
||||
</if>
|
||||
<if test="dispenseStatus == 3">
|
||||
T1.status_enum IN (#{inProgress},#{preparation},#{prepared})
|
||||
</if>
|
||||
<if test="dispenseStatus == 4">
|
||||
T1.status_enum = #{completed}
|
||||
</if>
|
||||
AND T14.inventory_status_enum = #{active}
|
||||
ORDER BY prescription_no DESC
|
||||
>>>>>>> v1.3
|
||||
) AS ii
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<select id="getPreparerDoctorList" resultType="com.openhis.administration.domain.Practitioner">
|
||||
SELECT ap.id,
|
||||
ap."name"
|
||||
ap."name",
|
||||
su.status
|
||||
FROM adm_practitioner ap
|
||||
LEFT JOIN adm_practitioner_role apr
|
||||
ON ap.id = apr.practitioner_id
|
||||
LEFT JOIN adm_practitioner_role apr
|
||||
ON ap.id = apr.practitioner_id
|
||||
LEFT JOIN sys_user AS su ON su.user_id = ap.user_id
|
||||
AND su.delete_flag = '0'
|
||||
WHERE apr.role_code = #{pharmacist}
|
||||
AND ap.delete_flag = '0'
|
||||
AND su.status = '0'
|
||||
GROUP BY ap.id,
|
||||
ap."name"
|
||||
ap."name",
|
||||
su.status
|
||||
</select>
|
||||
<select id="selectMedicineInventoryDetail"
|
||||
resultType="com.openhis.web.pharmacymanage.dto.InventoryDetailDto">
|
||||
SELECT wii.expiration_date ,
|
||||
wii.location_id ,
|
||||
wii.item_id ,
|
||||
wii.lot_number AS inventory_lot_number,
|
||||
wii.unit_code AS inventory_unit_code,
|
||||
wii.quantity AS inventory_quantity,
|
||||
mmd.part_percent ,
|
||||
mmd.unit_code AS max_unit_code
|
||||
FROM wor_inventory_item wii
|
||||
LEFT JOIN med_medication_definition mmd
|
||||
ON wii.item_id = mmd.id
|
||||
AND mmd.delete_flag = '0'
|
||||
WHERE wii.delete_flag = '0'
|
||||
AND wii.item_id IN
|
||||
<foreach item="itemId" collection="medicationIdList" index="index"
|
||||
separator="," close=")" open="(">
|
||||
#{itemId}
|
||||
</foreach>
|
||||
AND wii.location_id IN
|
||||
<foreach item="locationId" collection="locationIdList" index="index"
|
||||
separator="," close=")" open="(">
|
||||
#{locationId}
|
||||
</foreach>
|
||||
AND wii.inventory_status_enum = #{active}
|
||||
ORDER BY wii.expiration_date
|
||||
</select>
|
||||
|
||||
<select id="getOutTraceNo" resultType="string">
|
||||
SELECT atnm.trace_no
|
||||
FROM adm_trace_no_manage AS atnm
|
||||
WHERE atnm.delete_flag = '0'
|
||||
AND atnm.trace_no != '22000000000000000000'
|
||||
AND atnm.status_enum = #{status}
|
||||
AND atnm.operation_type = #{operationType}
|
||||
AND NOT EXISTS(SELECT 1
|
||||
FROM med_medication_definition AS mmd
|
||||
WHERE mmd.ID = atnm.item_id
|
||||
AND mmd.delete_flag = '0'
|
||||
AND (mmd.inject_flag = #{injectFlag} OR mmd.part_attribute_enum = #{outpatientMinUnitCeil} OR
|
||||
mmd.part_attribute_enum = #{outpatientMinUnitTotalCeil}))
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user