提交merge1.3
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
SELECT T4.encounter_id,
|
||||
T4.encounter_bus_no,
|
||||
T4.patient_id,
|
||||
T4.encounter_status,
|
||||
T4.reception_time,
|
||||
T4.patient_name,
|
||||
T4.patient_bus_no,
|
||||
@@ -16,47 +17,62 @@
|
||||
T4.start_time,
|
||||
T4.patient_py_str,
|
||||
T4.patient_wb_str,
|
||||
T4.status_enum
|
||||
FROM (
|
||||
SELECT T1.id AS encounter_id,
|
||||
T1.bus_no AS encounter_bus_no,
|
||||
T1.patient_id,
|
||||
T1.reception_time,
|
||||
T1.delete_flag,
|
||||
T1.tenant_id,
|
||||
T2."name" AS patient_name,
|
||||
T2.bus_no AS patient_bus_no,
|
||||
T2.gender_enum,
|
||||
T2.birth_date,
|
||||
T1.start_time,
|
||||
T2.id_card,
|
||||
T2.py_str AS patient_py_str,
|
||||
T2.wb_str AS patient_wb_str,
|
||||
T3.status_enum
|
||||
FROM adm_encounter AS T1
|
||||
LEFT JOIN adm_patient AS T2
|
||||
ON T1.patient_id = T2.id
|
||||
INNER JOIN adm_charge_item AS T3
|
||||
ON T3.encounter_id = T1.id
|
||||
AND T3.delete_flag = '0'
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND T1.class_enum = #{classEnum}
|
||||
GROUP BY T1.id,
|
||||
T1.bus_no,
|
||||
T1.patient_id,
|
||||
T1.reception_time,
|
||||
T1.delete_flag,
|
||||
T1.tenant_id,
|
||||
T2."name",
|
||||
T2.bus_no,
|
||||
T2.gender_enum,
|
||||
T2.birth_date,
|
||||
T2.id_card,
|
||||
T2.py_str,
|
||||
T2.wb_str,
|
||||
T3.status_enum
|
||||
ORDER BY T1.bus_no DESC
|
||||
) AS T4
|
||||
T4.balance_amount
|
||||
FROM (SELECT T1.id AS encounter_id,
|
||||
T1.bus_no AS encounter_bus_no,
|
||||
T1.patient_id,
|
||||
T1.reception_time,
|
||||
T1.delete_flag,
|
||||
T1.tenant_id,
|
||||
T1.start_time,
|
||||
T1.status_enum AS encounter_status,
|
||||
T2."name" AS patient_name,
|
||||
T2.bus_no AS patient_bus_no,
|
||||
T2.gender_enum,
|
||||
T2.birth_date,
|
||||
T2.id_card,
|
||||
T2.py_str AS patient_py_str,
|
||||
T2.wb_str AS patient_wb_str,
|
||||
T3.balance_amount
|
||||
FROM adm_encounter AS T1
|
||||
LEFT JOIN adm_patient AS T2
|
||||
ON T1.patient_id = T2.id
|
||||
LEFT JOIN (SELECT aa.encounter_id,
|
||||
(aa.balance_amount -
|
||||
COALESCE(SUM(CASE
|
||||
WHEN aci.status_enum IN (#{billed}, #{billable})
|
||||
THEN aci.total_price
|
||||
ELSE 0 END), 0) +
|
||||
COALESCE(
|
||||
SUM(CASE WHEN aci.status_enum = #{refunded} THEN aci.total_price ELSE 0 END),
|
||||
0)) AS balance_amount
|
||||
FROM adm_account aa
|
||||
LEFT JOIN adm_charge_item aci ON aa.encounter_id = aci.encounter_id
|
||||
AND aa.delete_flag = '0'
|
||||
WHERE aa.type_code = #{personalCashAccount}
|
||||
AND aa.delete_flag = '0'
|
||||
GROUP BY aa.encounter_id,
|
||||
aa.balance_amount) AS T3 ON T3.encounter_id = T1.id
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND T1.class_enum = #{classEnum}
|
||||
AND T1.status_enum IN (#{dischargedFromHospital}, #{alreadySettled})
|
||||
GROUP BY T1.id,
|
||||
T1.bus_no,
|
||||
T1.patient_id,
|
||||
T1.reception_time,
|
||||
T1.delete_flag,
|
||||
T1.tenant_id,
|
||||
T1.start_time,
|
||||
T1.status_enum,
|
||||
T2."name",
|
||||
T2.bus_no,
|
||||
T2.gender_enum,
|
||||
T2.birth_date,
|
||||
T2.id_card,
|
||||
T2.py_str,
|
||||
T2.wb_str,
|
||||
T3.balance_amount
|
||||
ORDER BY T1.bus_no DESC) AS T4
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
@@ -132,8 +148,6 @@
|
||||
, #{refunded}
|
||||
, #{partRefund})
|
||||
AND T1.context_enum != #{register}
|
||||
AND T1.entered_date >= #{startTime}
|
||||
AND T1.entered_date <= #{endTime}
|
||||
AND T1.delete_flag = '0'
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -77,7 +77,10 @@
|
||||
T1.unit_price,
|
||||
T1.total_price,
|
||||
mmr.prescription_no,
|
||||
<<<<<<< HEAD
|
||||
mmr.prescription_no,
|
||||
=======
|
||||
>>>>>>> v1.3
|
||||
mmr.method_code,
|
||||
mmr.rate_code,
|
||||
mmr.dose,
|
||||
@@ -147,4 +150,97 @@
|
||||
AND T1.delete_flag = '0'
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectEncounterPatientPrescriptionWithPrice"
|
||||
resultType="com.openhis.web.chargemanage.dto.EncounterPatientPrescriptionDto">
|
||||
SELECT final_res.*,
|
||||
(SELECT SUM(amount)
|
||||
FROM fin_payment_rec_detail
|
||||
WHERE reconciliation_id = final_res.payment_id
|
||||
AND pay_enum IN (#{self}, #{selfVx}, #{selfAli}, #{selfUnion})) AS received_amount,
|
||||
(SELECT amount
|
||||
FROM fin_payment_rec_detail
|
||||
WHERE reconciliation_id = final_res.payment_id
|
||||
AND pay_enum = #{discountCode}) AS discount_amount
|
||||
FROM (SELECT T1.encounter_id,
|
||||
T1.id,
|
||||
T1.patient_id,
|
||||
T1.context_enum,
|
||||
T1.status_enum,
|
||||
T1.requesting_org_id,
|
||||
T1.quantity_value,
|
||||
T1.quantity_unit,
|
||||
T1.unit_price,
|
||||
T1.total_price,
|
||||
mmr.prescription_no,
|
||||
mmr.method_code,
|
||||
mmr.rate_code,
|
||||
mmr.dose,
|
||||
mmr.dose_unit_code,
|
||||
T1.bus_no,
|
||||
T1.entered_date,
|
||||
T1.account_id,
|
||||
T1.service_table,
|
||||
T1.service_id,
|
||||
T5.enterer_id,
|
||||
T5.bill_date,
|
||||
T5.id AS payment_id,
|
||||
T6.contract_no,
|
||||
T7.med_type_code,
|
||||
T8.contract_name,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} THEN T2."name"
|
||||
WHEN T1.context_enum = #{medication} THEN T3."name"
|
||||
WHEN T1.context_enum = #{device} THEN T4."name"
|
||||
END AS item_name,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} THEN T2.yb_no
|
||||
WHEN T1.context_enum = #{medication} THEN T3.yb_no
|
||||
WHEN T1.context_enum = #{device} THEN T4.yb_no
|
||||
END AS yb_no,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} THEN T2.id
|
||||
WHEN T1.context_enum = #{medication} THEN T3.id
|
||||
WHEN T1.context_enum = #{device} THEN T4.id
|
||||
END AS item_id,
|
||||
T5.tendered_amount AS receivable_amount
|
||||
FROM adm_charge_item AS T1
|
||||
LEFT JOIN wor_activity_definition AS T2
|
||||
ON T1.context_enum = #{activity}
|
||||
AND T1.product_id = T2.id
|
||||
AND T2.delete_flag = '0'
|
||||
LEFT JOIN med_medication_definition AS T3
|
||||
ON T1.context_enum = #{medication}
|
||||
AND T1.product_id = T3.id
|
||||
AND T3.delete_flag = '0'
|
||||
LEFT JOIN adm_device_definition AS T4
|
||||
ON T1.context_enum = #{device}
|
||||
AND T1.product_id = T4.id
|
||||
AND T4.delete_flag = '0'
|
||||
LEFT JOIN fin_payment_reconciliation AS T5
|
||||
ON T1.id::TEXT = ANY(string_to_array(T5.charge_item_ids, ','))
|
||||
AND T5.delete_flag = '0'
|
||||
AND T5.status_enum = 1
|
||||
LEFT JOIN adm_account AS T6
|
||||
ON T1.account_id = T6.id
|
||||
AND T6.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter_diagnosis AS T7
|
||||
ON T1.encounter_id = T7.encounter_id
|
||||
AND T1.condition_id = T7.condition_id
|
||||
AND T7.delete_flag = '0'
|
||||
LEFT JOIN fin_contract AS T8
|
||||
ON T6.contract_no = T8.bus_no
|
||||
AND T8.delete_flag = '0'
|
||||
LEFT JOIN med_medication_request AS mmr ON mmr.id = T1.service_id AND mmr.delete_flag = '0'
|
||||
WHERE T1.encounter_id = #{encounterId}
|
||||
AND T1.status_enum IN (#{planned}
|
||||
, #{billable}
|
||||
, #{billed}
|
||||
, #{refunding}
|
||||
, #{refunded}
|
||||
, #{partRefund})
|
||||
AND T1.context_enum != #{register}
|
||||
AND T1.delete_flag = '0') final_res
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -75,10 +75,6 @@
|
||||
T2.unit_code,
|
||||
T1.unit_price,
|
||||
T1.total_price,
|
||||
T3.status_enum AS dispense_status,
|
||||
T3.not_performed_reason_enum AS not_performed_reason,
|
||||
0 AS service_status,
|
||||
T3.id AS dispense_id,
|
||||
T2.id AS request_id,
|
||||
T7.name AS item_name,
|
||||
T10.id AS payment_id,
|
||||
@@ -87,9 +83,6 @@
|
||||
LEFT JOIN med_medication_request AS T2
|
||||
ON T2.id = T1.service_id
|
||||
AND T2.delete_flag = '0'
|
||||
LEFT JOIN med_medication_dispense AS T3
|
||||
ON T3.med_req_id = T2.id
|
||||
AND T3.delete_flag = '0'
|
||||
LEFT JOIN med_medication_definition AS T7
|
||||
ON T1.product_id = T7.id
|
||||
AND T7.delete_flag = '0'
|
||||
@@ -117,10 +110,6 @@
|
||||
T4.unit_code,
|
||||
T1.unit_price,
|
||||
T1.total_price,
|
||||
T5.status_enum AS dispense_status,
|
||||
T5.not_performed_reason_enum AS not_performed_reason,
|
||||
0 AS service_status,
|
||||
T5.id AS dispense_id,
|
||||
T4.id AS request_id,
|
||||
T8.name AS item_name,
|
||||
T10.id AS payment_id,
|
||||
@@ -129,9 +118,6 @@
|
||||
LEFT JOIN wor_device_request AS T4
|
||||
ON T4.id = T1.service_id
|
||||
AND T4.delete_flag = '0'
|
||||
LEFT JOIN wor_device_dispense AS T5
|
||||
ON T5.device_req_id = T4.id
|
||||
AND T5.delete_flag = '0'
|
||||
LEFT JOIN adm_device_definition AS T8
|
||||
ON T1.product_id = T8.id
|
||||
AND T8.delete_flag = '0'
|
||||
@@ -159,10 +145,6 @@
|
||||
T6.unit_code,
|
||||
T1.unit_price,
|
||||
T1.total_price,
|
||||
0 AS dispense_status,
|
||||
null AS not_performed_reason,
|
||||
T6.status_enum AS service_status,
|
||||
null AS dispense_id,
|
||||
T6.id AS request_id,
|
||||
T9.name AS item_name,
|
||||
T10.id AS payment_id,
|
||||
@@ -282,10 +264,7 @@
|
||||
aci.service_table,
|
||||
mmr.prescription_no,
|
||||
mmr.id AS request_id,
|
||||
dis.status_enum AS dispense_status,
|
||||
0 AS service_status,
|
||||
dis.dispense_quantity,
|
||||
dis.id AS dispense_id,
|
||||
mmd."name" AS item_name,
|
||||
fpr.id AS payment_id,
|
||||
fpr.enterer_id,
|
||||
@@ -310,9 +289,6 @@
|
||||
ON aci.service_id = mmr.refund_medicine_id
|
||||
AND mmr.refund_medicine_id IS NOT NULL
|
||||
AND mmr.delete_flag = '0'
|
||||
LEFT JOIN med_medication_dispense dis
|
||||
ON mmr.id = dis.med_req_id
|
||||
AND dis.delete_flag = '0'
|
||||
INNER JOIN med_medication_definition mmd
|
||||
ON aci.product_id = mmd.id
|
||||
AND mmd.delete_flag = '0'
|
||||
@@ -350,10 +326,7 @@
|
||||
aci.service_table,
|
||||
wdr.prescription_no,
|
||||
wdr.id AS request_id,
|
||||
wdd.status_enum AS dispense_status,
|
||||
0 AS service_status,
|
||||
wdd.dispense_quantity,
|
||||
wdd.id AS dispense_id,
|
||||
dev."name" AS item_name,
|
||||
fpr.id AS payment_id,
|
||||
fpr.enterer_id,
|
||||
@@ -378,9 +351,6 @@
|
||||
ON aci.service_id = wdr.refund_device_id
|
||||
AND wdr.refund_device_id IS NOT NULL
|
||||
AND wdr.delete_flag = '0'
|
||||
LEFT JOIN wor_device_dispense wdd
|
||||
ON wdr.id = wdd.device_req_id
|
||||
AND wdd.delete_flag = '0'
|
||||
INNER JOIN adm_device_definition dev
|
||||
ON aci.product_id = dev.id
|
||||
AND dev.delete_flag = '0'
|
||||
@@ -418,10 +388,7 @@
|
||||
aci.service_table,
|
||||
wsr.prescription_no,
|
||||
wsr.id AS request_id,
|
||||
0 AS dispense_status,
|
||||
wsr.status_enum AS service_status,
|
||||
0 AS dispense_quantity,
|
||||
null AS dispense_id,
|
||||
wad."name" AS item_name,
|
||||
fpr.id AS payment_id,
|
||||
fpr.enterer_id,
|
||||
|
||||
@@ -10,14 +10,16 @@
|
||||
T3.NAME,
|
||||
T3.gender_enum,
|
||||
T3.py_str,
|
||||
T3.wb_str
|
||||
T3.wb_str,
|
||||
T3.dr_profttl_code
|
||||
FROM (
|
||||
SELECT T1.tenant_id,
|
||||
T1.ID,
|
||||
T1.NAME,
|
||||
T1.gender_enum,
|
||||
T1.py_str,
|
||||
T1.wb_str
|
||||
T1.wb_str,
|
||||
T1.dr_profttl_code
|
||||
FROM adm_practitioner AS T1
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND EXISTS(SELECT 1
|
||||
@@ -93,6 +95,7 @@
|
||||
T13.charge_item_ids,
|
||||
T13.id AS payment_id,
|
||||
ai.picture_url AS picture_url,
|
||||
<<<<<<< HEAD
|
||||
T8.birth_date AS birth_date,
|
||||
T14.create_time AS return_date,
|
||||
T14.return_reason AS return_reason,
|
||||
@@ -101,6 +104,9 @@
|
||||
T14.display_amount AS refund_amount,
|
||||
T6.contract_no AS contract_no,
|
||||
T16.refund_method AS refund_method
|
||||
=======
|
||||
T8.birth_date AS birth_date
|
||||
>>>>>>> v1.3
|
||||
FROM adm_encounter AS T1
|
||||
LEFT JOIN adm_organization AS T2 ON T1.organization_id = T2.ID AND T2.delete_flag = '0'
|
||||
LEFT JOIN adm_healthcare_service AS T3 ON T1.service_type_id = T3.ID AND T3.delete_flag = '0'
|
||||
|
||||
Reference in New Issue
Block a user