版本更新
This commit is contained in:
@@ -0,0 +1,347 @@
|
||||
<?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.inhospitalnursestation.mapper.ATDManageAppMapper">
|
||||
<select id="selectAdmissionPatientPage"
|
||||
resultType="com.openhis.web.inhospitalnursestation.dto.AdmissionPatientPageDto">
|
||||
SELECT ii.encounter_id,
|
||||
ii.bus_no,
|
||||
ii.encounter_status,
|
||||
ii.start_time,
|
||||
ii.end_time,
|
||||
ii.admit_source_code,
|
||||
ii.priority_enum,
|
||||
ii.organization_id,
|
||||
ii.patient_name,
|
||||
ii.patient_py_str,
|
||||
ii.patient_wb_str,
|
||||
ii.gender_enum,
|
||||
ii.birth_date,
|
||||
ii.ward_id,
|
||||
ii.ward_name,
|
||||
ii.house_id,
|
||||
ii.house_name,
|
||||
ii.bed_id,
|
||||
ii.bed_name,
|
||||
ii.organization_name,
|
||||
ii.contract_name
|
||||
FROM (
|
||||
WITH locations AS (
|
||||
SELECT ael.encounter_id,
|
||||
al.form_enum,
|
||||
al.id AS location_id,
|
||||
al."name" AS location_name
|
||||
FROM adm_encounter_location ael
|
||||
LEFT JOIN adm_location al
|
||||
ON ael.location_id = al.id
|
||||
AND al.delete_flag = '0'
|
||||
WHERE ael.status_enum = #{active}
|
||||
AND ael.delete_flag = '0'
|
||||
)
|
||||
SELECT ae.tenant_id,
|
||||
ae.id AS encounter_id,
|
||||
ae.bus_no,
|
||||
ae.status_enum AS encounter_status,
|
||||
ae.start_time,
|
||||
ae.end_time,
|
||||
ae.admit_source_code,
|
||||
ae.priority_enum,
|
||||
ae.organization_id,
|
||||
ap."name" AS patient_name,
|
||||
ap.py_str AS patient_py_str,
|
||||
ap.wb_str AS patient_wb_str,
|
||||
ap.gender_enum,
|
||||
ap.birth_date,
|
||||
alw.location_id AS ward_id,
|
||||
alw.location_name AS ward_name,
|
||||
alh.location_id AS house_id,
|
||||
alh.location_name AS house_name,
|
||||
alb.location_id AS bed_id,
|
||||
alb.location_name AS bed_name,
|
||||
ao."name" AS organization_name,
|
||||
fc.contract_name
|
||||
FROM adm_encounter ae
|
||||
LEFT JOIN adm_patient ap
|
||||
ON ae.patient_id = ap.id
|
||||
AND ap.delete_flag = '0'
|
||||
LEFT JOIN locations alw
|
||||
ON alw.encounter_id = ae.id
|
||||
AND alw.form_enum = #{ward}
|
||||
LEFT JOIN locations alh
|
||||
ON alh.encounter_id = ae.id
|
||||
AND alh.form_enum = #{house}
|
||||
LEFT JOIN locations alb
|
||||
ON alb.encounter_id = ae.id
|
||||
AND alb.form_enum = #{bed}
|
||||
LEFT JOIN adm_organization ao
|
||||
ON ao.id = ae.organization_id
|
||||
AND ao.delete_flag = '0'
|
||||
LEFT JOIN adm_account aa
|
||||
ON ae.id = aa.encounter_id
|
||||
AND aa.encounter_flag = 1
|
||||
AND aa.delete_flag = '0'
|
||||
LEFT JOIN fin_contract fc
|
||||
ON aa.contract_no = fc.bus_no
|
||||
AND fc.delete_flag = '0'
|
||||
WHERE ae.delete_flag = '0'
|
||||
AND ae.class_enum = #{imp}
|
||||
AND ae.status_enum != #{toBeRegistered}
|
||||
GROUP BY ae.id,
|
||||
ae.bus_no,
|
||||
ae.status_enum,
|
||||
ae.start_time,
|
||||
ae.end_time,
|
||||
ae.admit_source_code,
|
||||
ae.priority_enum,
|
||||
ae.organization_id,
|
||||
ap."name",
|
||||
ap.py_str,
|
||||
ap.wb_str,
|
||||
ap.gender_enum,
|
||||
ap.birth_date,
|
||||
alw.location_id,
|
||||
alw.location_name,
|
||||
alh.location_id,
|
||||
alh.location_name,
|
||||
alb.location_id,
|
||||
alb.location_name,
|
||||
ao."name",
|
||||
fc.contract_name
|
||||
ORDER BY ae.bus_no DESC
|
||||
) AS ii
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<select id="selectAdmissionBadPage"
|
||||
resultType="com.openhis.web.inhospitalnursestation.dto.AdmissionBedPageDto">
|
||||
SELECT ii.bed_id,
|
||||
ii.bed_name,
|
||||
ii.bed_status,
|
||||
ii.house_id,
|
||||
ii.house_name,
|
||||
ii.ward_id,
|
||||
ii.ward_name,
|
||||
ii.encounter_id ,
|
||||
ii.organization_id ,
|
||||
ii.bus_no ,
|
||||
ii.encounter_status,
|
||||
ii.patient_name,
|
||||
ii.patient_py_str,
|
||||
ii.patient_wb_str,
|
||||
ii.gender_enum ,
|
||||
ii.birth_date ,
|
||||
ii.total_amount,
|
||||
ii.balance_amount
|
||||
FROM ( SELECT bed.id AS bed_id,
|
||||
bed.tenant_id,
|
||||
bed."name" AS bed_name,
|
||||
bed.status_enum AS bed_status,
|
||||
house.id AS house_id,
|
||||
house."name" AS house_name,
|
||||
ward.id AS ward_id,
|
||||
ward."name" AS ward_name,
|
||||
ae.id AS encounter_id ,
|
||||
ae.organization_id ,
|
||||
ae.bus_no ,
|
||||
ae.status_enum AS encounter_status,
|
||||
ap."name" AS patient_name,
|
||||
ap.py_str AS patient_py_str,
|
||||
ap.wb_str AS patient_wb_str,
|
||||
ap.gender_enum ,
|
||||
ap.birth_date ,
|
||||
personal_account.total_amount,
|
||||
personal_account.balance_amount
|
||||
FROM adm_location bed
|
||||
LEFT JOIN adm_location house
|
||||
ON house.bus_no = SPLIT_PART(bed.bus_no,'.',1) || '.' || SPLIT_PART(bed.bus_no,'.',2)
|
||||
AND house.form_enum = #{house}
|
||||
AND house.delete_flag = '0'
|
||||
LEFT JOIN adm_location ward
|
||||
ON ward.bus_no = SPLIT_PART(bed.bus_no,'.',1)
|
||||
AND ward.form_enum = #{ward}
|
||||
AND ward.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter_location aelb
|
||||
ON bed.id = aelb.location_id
|
||||
AND aelb.delete_flag = '0'
|
||||
AND aelb.status_enum = #{active}
|
||||
AND bed.form_enum = #{bed}
|
||||
LEFT JOIN adm_encounter ae
|
||||
ON aelb.encounter_id = ae.id
|
||||
AND ae.delete_flag = '0'
|
||||
LEFT JOIN adm_patient ap
|
||||
ON ap.id = ae.patient_id
|
||||
AND ap.delete_flag = '0'
|
||||
LEFT JOIN ( SELECT aa.encounter_id,
|
||||
aa.balance_amount AS total_amount,
|
||||
(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 personal_account
|
||||
ON personal_account.encounter_id = ae.id
|
||||
WHERE bed.form_enum = #{bed}
|
||||
AND bed.delete_flag = '0'
|
||||
AND bed.status_enum != #{inactive}
|
||||
GROUP BY bed.id,
|
||||
bed.tenant_id,
|
||||
bed."name",
|
||||
bed.status_enum,
|
||||
house.id,
|
||||
house."name",
|
||||
ward.id,
|
||||
ward."name",
|
||||
ae.id,
|
||||
ae.organization_id ,
|
||||
ae.bus_no ,
|
||||
ae.status_enum,
|
||||
ap."name",
|
||||
ap.py_str,
|
||||
ap.wb_str,
|
||||
ap.gender_enum ,
|
||||
ap.birth_date,
|
||||
personal_account.total_amount,
|
||||
personal_account.balance_amount
|
||||
ORDER BY bed.bus_no
|
||||
) AS ii
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<select id="selectAdmissionPatientInfo"
|
||||
resultType="com.openhis.web.inhospitalnursestation.dto.AdmissionPatientInfoDto">
|
||||
WITH locations AS (
|
||||
SELECT ael.encounter_id,
|
||||
ael.start_time,
|
||||
al.form_enum,
|
||||
al.id AS location_id,
|
||||
al."name" AS location_name
|
||||
FROM adm_encounter_location ael
|
||||
LEFT JOIN adm_location al
|
||||
ON ael.location_id = al.id
|
||||
AND al.delete_flag = '0'
|
||||
WHERE ael.status_enum = #{active}
|
||||
AND ael.delete_flag = '0'
|
||||
) , practitioners AS (
|
||||
SELECT aep.encounter_id ,
|
||||
aep.type_code ,
|
||||
pra.id AS practitioner_id,
|
||||
pra."name" AS practitioner_name
|
||||
FROM adm_encounter_participant aep
|
||||
LEFT JOIN adm_practitioner pra
|
||||
ON aep.practitioner_id = pra.id
|
||||
AND pra.delete_flag = '0'
|
||||
WHERE aep.status_enum = #{active}
|
||||
AND aep.delete_flag = '0'
|
||||
)
|
||||
SELECT ae.id AS encounter_id,
|
||||
ae.bus_no ,
|
||||
ae.priority_enum ,
|
||||
ae.organization_id ,
|
||||
ae.start_time AS in_hos_time,
|
||||
bed.start_time,
|
||||
bed.location_id AS bed_id,
|
||||
bed.location_name AS bed_name,
|
||||
house.location_id AS house_id,
|
||||
house.location_name AS house_name,
|
||||
ward.location_id AS ward_id,
|
||||
ward.location_name AS ward_name,
|
||||
primaryNurse.practitioner_id AS primary_nurse_id,
|
||||
primaryNurse.practitioner_name AS primary_nurse_name,
|
||||
attendingDoctor.practitioner_id AS attending_doctor_id,
|
||||
attendingDoctor.practitioner_name AS attending_doctor_name,
|
||||
admittingDoctor.practitioner_id AS admitting_doctor_id,
|
||||
admittingDoctor.practitioner_name AS admitting_doctor_name,
|
||||
chiefDoctor.practitioner_id AS chief_doctor_id,
|
||||
chiefDoctor.practitioner_name AS chief_doctor_name,
|
||||
ao."name" AS organization_name ,
|
||||
ap."name" AS patient_name,
|
||||
ap.gender_enum ,
|
||||
ap.birth_date ,
|
||||
ap.phone ,
|
||||
fc.contract_name ,
|
||||
diagnosis.condition_names
|
||||
FROM adm_encounter ae
|
||||
LEFT JOIN locations AS bed
|
||||
ON bed.encounter_id = ae.id
|
||||
AND bed.form_enum = #{bed}
|
||||
LEFT JOIN locations AS house
|
||||
ON house.encounter_id = ae.id
|
||||
AND house.form_enum = #{house}
|
||||
LEFT JOIN locations AS ward
|
||||
ON ward.encounter_id = ae.id
|
||||
AND ward.form_enum = #{ward}
|
||||
LEFT JOIN practitioners AS primaryNurse
|
||||
ON primaryNurse.encounter_id = ae.id
|
||||
AND primaryNurse.type_code = #{primaryNurse}
|
||||
LEFT JOIN practitioners AS attendingDoctor
|
||||
ON attendingDoctor.encounter_id = ae.id
|
||||
AND attendingDoctor.type_code = #{attendingDoctor}
|
||||
LEFT JOIN practitioners AS admittingDoctor
|
||||
ON admittingDoctor.encounter_id = ae.id
|
||||
AND admittingDoctor.type_code = #{admittingDoctor}
|
||||
LEFT JOIN practitioners AS chiefDoctor
|
||||
ON chiefDoctor.encounter_id = ae.id
|
||||
AND chiefDoctor.type_code = #{chiefDoctor}
|
||||
LEFT JOIN adm_organization ao
|
||||
ON ao.id = ae.organization_id
|
||||
AND ao.delete_flag = '0'
|
||||
LEFT JOIN adm_patient ap
|
||||
ON ae.patient_id = ap.id
|
||||
AND ap.delete_flag = '0'
|
||||
LEFT JOIN adm_account aa
|
||||
ON ae.id = aa.encounter_id
|
||||
AND aa.encounter_flag = 1
|
||||
AND aa.delete_flag = '0'
|
||||
LEFT JOIN fin_contract fc
|
||||
ON aa.contract_no = fc.bus_no
|
||||
AND fc.delete_flag = '0'
|
||||
LEFT JOIN (
|
||||
SELECT aed.encounter_id,
|
||||
STRING_AGG(ccd.name, ', ') AS condition_names
|
||||
FROM adm_encounter_diagnosis aed
|
||||
INNER JOIN cli_condition cc
|
||||
ON cc.id = aed.condition_id
|
||||
AND cc.delete_flag = '0'
|
||||
INNER JOIN cli_condition_definition ccd
|
||||
ON ccd.id = cc.definition_id
|
||||
AND ccd.delete_flag = '0'
|
||||
WHERE aed.delete_flag = '0'
|
||||
GROUP BY aed.encounter_id
|
||||
) AS diagnosis
|
||||
ON ae.id = diagnosis.encounter_id
|
||||
WHERE ae.id = #{encounterId}
|
||||
AND ae.delete_flag = '0'
|
||||
GROUP BY ae.id,
|
||||
ae.bus_no ,
|
||||
ae.priority_enum ,
|
||||
ae.organization_id ,
|
||||
ae.start_time,
|
||||
bed.start_time,
|
||||
bed.location_id,
|
||||
bed.location_name,
|
||||
house.location_id,
|
||||
house.location_name,
|
||||
ward.location_id,
|
||||
ward.location_name,
|
||||
primaryNurse.practitioner_id,
|
||||
primaryNurse.practitioner_name,
|
||||
attendingDoctor.practitioner_id,
|
||||
attendingDoctor.practitioner_name,
|
||||
admittingDoctor.practitioner_id,
|
||||
admittingDoctor.practitioner_name,
|
||||
chiefDoctor.practitioner_id,
|
||||
chiefDoctor.practitioner_name,
|
||||
ao."name",
|
||||
ap."name",
|
||||
ap.gender_enum ,
|
||||
ap.birth_date ,
|
||||
ap.phone ,
|
||||
fc.contract_name ,
|
||||
diagnosis.condition_names
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,396 @@
|
||||
<?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.inhospitalnursestation.mapper.AdviceProcessAppMapper">
|
||||
|
||||
<select id="selectInpatientPage"
|
||||
resultType="com.openhis.web.inhospitalnursestation.dto.AdmissionPatientPageDto">
|
||||
SELECT ii.encounter_id,
|
||||
ii.bus_no,
|
||||
ii.encounter_status,
|
||||
ii.start_time,
|
||||
ii.end_time,
|
||||
ii.admit_source_code,
|
||||
ii.priority_enum,
|
||||
ii.organization_id,
|
||||
ii.patient_name,
|
||||
ii.patient_py_str,
|
||||
ii.patient_wb_str,
|
||||
ii.gender_enum,
|
||||
ii.birth_date,
|
||||
ii.ward_id,
|
||||
ii.ward_name,
|
||||
ii.house_id,
|
||||
ii.house_name,
|
||||
ii.bed_id,
|
||||
ii.bed_name,
|
||||
ii.organization_name
|
||||
FROM (
|
||||
WITH locations AS (
|
||||
SELECT ael.encounter_id,
|
||||
al.form_enum,
|
||||
al.id AS location_id,
|
||||
al."name" AS location_name
|
||||
FROM adm_encounter_location ael
|
||||
LEFT JOIN adm_location al
|
||||
ON ael.location_id = al.id
|
||||
AND al.delete_flag = '0'
|
||||
WHERE ael.status_enum = #{active}
|
||||
AND ael.delete_flag = '0'
|
||||
)
|
||||
SELECT ae.tenant_id,
|
||||
ae.id AS encounter_id,
|
||||
ae.bus_no,
|
||||
ae.status_enum AS encounter_status,
|
||||
ae.start_time,
|
||||
ae.end_time,
|
||||
ae.admit_source_code,
|
||||
ae.priority_enum,
|
||||
ae.organization_id,
|
||||
ap."name" AS patient_name,
|
||||
ap.py_str AS patient_py_str,
|
||||
ap.wb_str AS patient_wb_str,
|
||||
ap.gender_enum,
|
||||
ap.birth_date,
|
||||
alw.location_id AS ward_id,
|
||||
alw.location_name AS ward_name,
|
||||
alh.location_id AS house_id,
|
||||
alh.location_name AS house_name,
|
||||
alb.location_id AS bed_id,
|
||||
alb.location_name AS bed_name,
|
||||
ao."name" AS organization_name
|
||||
FROM adm_encounter ae
|
||||
LEFT JOIN adm_patient ap
|
||||
ON ae.patient_id = ap.id
|
||||
AND ap.delete_flag = '0'
|
||||
LEFT JOIN locations alw
|
||||
ON alw.encounter_id = ae.id
|
||||
AND alw.form_enum = #{ward}
|
||||
LEFT JOIN locations alh
|
||||
ON alh.encounter_id = ae.id
|
||||
AND alh.form_enum = #{house}
|
||||
LEFT JOIN locations alb
|
||||
ON alb.encounter_id = ae.id
|
||||
AND alb.form_enum = #{bed}
|
||||
LEFT JOIN adm_organization ao
|
||||
ON ao.id = ae.organization_id
|
||||
AND ao.delete_flag = '0'
|
||||
WHERE ae.delete_flag = '0'
|
||||
AND ae.class_enum = #{imp}
|
||||
AND ae.status_enum != #{toBeRegistered}
|
||||
AND ae.status_enum != #{registered}
|
||||
GROUP BY ae.id,
|
||||
ae.bus_no,
|
||||
ae.status_enum,
|
||||
ae.start_time,
|
||||
ae.end_time,
|
||||
ae.admit_source_code,
|
||||
ae.priority_enum,
|
||||
ae.organization_id,
|
||||
ap."name",
|
||||
ap.py_str,
|
||||
ap.wb_str,
|
||||
ap.gender_enum,
|
||||
ap.birth_date,
|
||||
alw.location_id,
|
||||
alw.location_name,
|
||||
alh.location_id,
|
||||
alh.location_name,
|
||||
alb.location_id,
|
||||
alb.location_name,
|
||||
ao."name"
|
||||
ORDER BY ae.bus_no DESC
|
||||
) AS ii
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<select id="selectInpatientAdvicePage"
|
||||
resultType="com.openhis.web.inhospitalnursestation.dto.InpatientAdviceDto">
|
||||
SELECT ii.encounter_id,
|
||||
ii.advice_table,
|
||||
ii.request_id,
|
||||
ii.start_time,
|
||||
ii.end_time,
|
||||
ii.requester_id,
|
||||
ii.request_time,
|
||||
ii.skin_test_flag,
|
||||
ii.inject_flag,
|
||||
ii.group_id,
|
||||
ii.advice_name,
|
||||
ii.item_id,
|
||||
ii.volume,
|
||||
ii.lot_number,
|
||||
ii.quantity,
|
||||
ii.unit_code,
|
||||
ii.request_status,
|
||||
ii.method_code,
|
||||
ii.rate_code,
|
||||
ii.dose,
|
||||
ii.dose_unit_code,
|
||||
ii.position_id,
|
||||
ii.position_name,
|
||||
ii.dispense_per_duration,
|
||||
ii.part_percent,
|
||||
ii.condition_definition_name,
|
||||
ii.therapy_enum,
|
||||
ii.sort_number,
|
||||
ii.execute_num,
|
||||
ii.day_times,
|
||||
ii.bus_no,
|
||||
ii."patient_name" AS patient_name,
|
||||
ii."bad_name" AS bad_name,
|
||||
ii.gender_enum ,
|
||||
ii.birth_date ,
|
||||
ii.contract_name ,
|
||||
ii.condition_names,
|
||||
ii.admitting_doctor_name AS admitting_doctor_name,
|
||||
ii.balance_amount AS balance_amount
|
||||
FROM (( SELECT T1.encounter_id,
|
||||
T1.tenant_id,
|
||||
#{medMedicationRequest} AS advice_table,
|
||||
T1.id AS request_id,
|
||||
T1.effective_dose_start AS start_time,
|
||||
T1.effective_dose_end AS end_time,
|
||||
T1.practitioner_id AS requester_id,
|
||||
T1.create_time AS request_time,
|
||||
T1.skin_test_flag AS skin_test_flag,
|
||||
T1.infusion_flag AS inject_flag,
|
||||
T1.group_id AS group_id,
|
||||
T2."name" AS advice_name,
|
||||
T2.id AS item_id,
|
||||
T3.total_volume AS volume,
|
||||
T1.lot_number AS lot_number,
|
||||
T1.quantity AS quantity,
|
||||
T1.unit_code AS unit_code,
|
||||
T1.status_enum AS request_status,
|
||||
T1.method_code AS method_code,
|
||||
T1.rate_code AS rate_code,
|
||||
T1.dose AS dose,
|
||||
T1.dose_unit_code AS dose_unit_code,
|
||||
al1.id AS position_id,
|
||||
al1."name" AS position_name,
|
||||
T1.dispense_per_duration AS dispense_per_duration,
|
||||
T2.part_percent AS part_percent,
|
||||
ccd."name" AS condition_definition_name,
|
||||
T1.therapy_enum AS therapy_enum,
|
||||
T1.sort_number AS sort_number,
|
||||
T1.execute_num,
|
||||
af.day_times,
|
||||
ae.bus_no,
|
||||
ap."name" AS patient_name,
|
||||
al2."name" AS bad_name,
|
||||
ap.gender_enum ,
|
||||
ap.birth_date ,
|
||||
fc.contract_name ,
|
||||
diagnosis.condition_names,
|
||||
pra."name" AS admitting_doctor_name,
|
||||
personal_account.balance_amount
|
||||
FROM med_medication_request AS T1
|
||||
LEFT JOIN med_medication_definition AS T2
|
||||
ON T2.id = T1.medication_id
|
||||
AND T2.delete_flag = '0'
|
||||
LEFT JOIN med_medication AS T3
|
||||
ON T3.medication_def_id = T2.ID
|
||||
AND T3.delete_flag = '0'
|
||||
LEFT JOIN adm_location AS al1
|
||||
ON al1.id = T1.perform_location
|
||||
AND al1.delete_flag = '0'
|
||||
LEFT JOIN cli_condition AS cc
|
||||
ON cc.id = T1.condition_id
|
||||
AND cc.delete_flag = '0'
|
||||
LEFT JOIN cli_condition_definition AS ccd
|
||||
ON ccd.id = cc.definition_id
|
||||
AND ccd.delete_flag = '0'
|
||||
LEFT JOIN adm_frequency af
|
||||
ON af.rate_code = T1.rate_code
|
||||
AND af.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter ae
|
||||
ON ae.id = T1.encounter_id
|
||||
AND ae.class_enum = #{imp}
|
||||
AND ae.delete_flag = '0'
|
||||
LEFT JOIN adm_patient ap
|
||||
ON ae.patient_id = ap.id
|
||||
AND ap.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter_location ael
|
||||
ON ae.id = ael.encounter_id
|
||||
AND ael.delete_flag = '0'
|
||||
AND ael.status_enum = #{active}
|
||||
AND ael.form_enum = #{bed}
|
||||
LEFT JOIN adm_location al2
|
||||
ON ael.location_id = al2.id
|
||||
AND al2.delete_flag = '0'
|
||||
LEFT JOIN adm_account aa
|
||||
ON ae.id = aa.encounter_id
|
||||
AND aa.encounter_flag = 1
|
||||
AND aa.delete_flag = '0'
|
||||
LEFT JOIN fin_contract fc
|
||||
ON aa.contract_no = fc.bus_no
|
||||
AND fc.delete_flag = '0'
|
||||
LEFT JOIN ( SELECT aed.encounter_id,
|
||||
STRING_AGG(ccd.name, ', ') AS condition_names
|
||||
FROM adm_encounter_diagnosis aed
|
||||
INNER JOIN cli_condition cc
|
||||
ON cc.id = aed.condition_id
|
||||
AND cc.delete_flag = '0'
|
||||
INNER JOIN cli_condition_definition ccd
|
||||
ON ccd.id = cc.definition_id
|
||||
AND ccd.delete_flag = '0'
|
||||
WHERE aed.delete_flag = '0'
|
||||
GROUP BY aed.encounter_id
|
||||
) AS diagnosis
|
||||
ON ae.id = diagnosis.encounter_id
|
||||
LEFT JOIN adm_encounter_participant aep
|
||||
ON ae.id = aep.encounter_id
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.status_enum = #{active}
|
||||
AND aep.type_code = #{admittingDoctor}
|
||||
LEFT JOIN adm_practitioner pra
|
||||
ON aep.practitioner_id = pra.id
|
||||
AND pra.delete_flag = '0'
|
||||
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 personal_account
|
||||
ON personal_account.encounter_id = ae.id
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND T1.refund_medicine_id IS NULL
|
||||
AND CASE WHEN T1.status_enum = #{draft}
|
||||
THEN T1.performer_check_id IS NOT NULL
|
||||
ELSE 1=1 END
|
||||
ORDER BY T1.status_enum,
|
||||
T1.sort_number,
|
||||
T1.group_id )
|
||||
UNION
|
||||
( SELECT T1.encounter_id,
|
||||
T1.tenant_id,
|
||||
#{worServiceRequest} AS advice_table,
|
||||
T1.id AS request_id,
|
||||
T1.occurrence_start_time AS start_time,
|
||||
T1.occurrence_end_time AS end_time,
|
||||
T1.requester_id AS requester_id,
|
||||
T1.create_time AS request_time,
|
||||
NULL AS skin_test_flag,
|
||||
NULL AS inject_flag,
|
||||
NULL AS group_id,
|
||||
T2."name" AS advice_name,
|
||||
T2.id AS item_id,
|
||||
NULL AS volume,
|
||||
NULL AS lot_number,
|
||||
T1.quantity AS quantity,
|
||||
T1.unit_code AS unit_code,
|
||||
T1.status_enum AS request_status,
|
||||
NULL AS method_code,
|
||||
NULL AS rate_code,
|
||||
NULL AS dose,
|
||||
NULL AS dose_unit_code,
|
||||
ao1.id AS position_id,
|
||||
ao1."name" AS position_name,
|
||||
NULL AS dispense_per_duration,
|
||||
1 AS part_percent,
|
||||
ccd."name" AS condition_definition_name,
|
||||
T1.therapy_enum AS therapy_enum,
|
||||
NULL AS sort_number,
|
||||
T1.quantity AS execute_num,
|
||||
NULL AS day_times,
|
||||
ae.bus_no,
|
||||
ap."name" AS patient_name,
|
||||
al2."name" AS bad_name,
|
||||
ap.gender_enum ,
|
||||
ap.birth_date ,
|
||||
fc.contract_name ,
|
||||
diagnosis.condition_names,
|
||||
pra."name" AS admitting_doctor_name,
|
||||
personal_account.balance_amount
|
||||
FROM wor_service_request AS T1
|
||||
LEFT JOIN wor_activity_definition AS T2
|
||||
ON T2.id = T1.activity_id
|
||||
AND T2.delete_flag = '0'
|
||||
LEFT JOIN cli_condition AS cc
|
||||
ON cc.id = T1.condition_id
|
||||
AND cc.delete_flag = '0'
|
||||
LEFT JOIN cli_condition_definition AS ccd
|
||||
ON ccd.id = cc.definition_id
|
||||
AND ccd.delete_flag = '0'
|
||||
LEFT JOIN adm_organization AS ao1
|
||||
ON ao1.id = T1.org_id
|
||||
AND ao1.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter ae
|
||||
ON ae.id = T1.encounter_id
|
||||
AND ae.class_enum = #{imp}
|
||||
AND ae.delete_flag = '0'
|
||||
LEFT JOIN adm_patient ap
|
||||
ON ae.patient_id = ap.id
|
||||
AND ap.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter_location ael
|
||||
ON ae.id = ael.encounter_id
|
||||
AND ael.delete_flag = '0'
|
||||
AND ael.status_enum = #{active}
|
||||
AND ael.form_enum = #{bed}
|
||||
LEFT JOIN adm_location al
|
||||
ON ael.location_id = al.id
|
||||
AND al.delete_flag = '0'
|
||||
LEFT JOIN adm_location al2
|
||||
ON ael.location_id = al2.ID
|
||||
AND al2.delete_flag = '0'
|
||||
LEFT JOIN adm_account aa ON ae.ID = aa.encounter_id
|
||||
AND aa.encounter_flag = 1
|
||||
AND aa.delete_flag = '0'
|
||||
LEFT JOIN fin_contract fc ON aa.contract_no = fc.bus_no
|
||||
AND fc.delete_flag = '0'
|
||||
LEFT JOIN ( SELECT aed.encounter_id,
|
||||
STRING_AGG(ccd.name, ', ') AS condition_names
|
||||
FROM adm_encounter_diagnosis aed
|
||||
INNER JOIN cli_condition cc
|
||||
ON cc.id = aed.condition_id
|
||||
AND cc.delete_flag = '0'
|
||||
INNER JOIN cli_condition_definition ccd
|
||||
ON ccd.id = cc.definition_id
|
||||
AND ccd.delete_flag = '0'
|
||||
WHERE aed.delete_flag = '0'
|
||||
GROUP BY aed.encounter_id
|
||||
) AS diagnosis
|
||||
ON ae.id = diagnosis.encounter_id
|
||||
LEFT JOIN adm_encounter_participant aep
|
||||
ON ae.id = aep.encounter_id
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.status_enum = #{active}
|
||||
AND aep.type_code = #{admittingDoctor}
|
||||
LEFT JOIN adm_practitioner pra
|
||||
ON aep.practitioner_id = pra.id
|
||||
AND pra.delete_flag = '0'
|
||||
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 personal_account
|
||||
ON personal_account.encounter_id = ae.id
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND CASE WHEN T1.status_enum = #{draft}
|
||||
THEN T1.performer_check_id IS NOT NULL
|
||||
ELSE 1=1 END
|
||||
AND T1.refund_service_id IS NULL
|
||||
ORDER BY T1.status_enum )
|
||||
) AS ii
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,258 @@
|
||||
<?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.inhospitalnursestation.mapper.InpatientMedicineCollectionMapper">
|
||||
<select id="selectEncounterInfoListPage" resultType="com.openhis.web.inhospitalnursestation.dto.InpatientMedicineEncounterInfoDto">
|
||||
SELECT ii.tenant_id,
|
||||
ii.organization_id,
|
||||
ii.organization_name,
|
||||
ii.encounter_id,
|
||||
ii.bus_no,
|
||||
ii.patient_name,
|
||||
ii.patient_py_str,
|
||||
ii.patient_wb_str,
|
||||
ii.gender_enum,
|
||||
ii.birth_date,
|
||||
ii.inpatient_bed
|
||||
FROM (SELECT T1.tenant_id,
|
||||
T1.organization_id, --科室
|
||||
T3.name AS organization_name,
|
||||
T1.id AS encounter_id, --就诊id
|
||||
T1.bus_no, --住院号
|
||||
T2.name AS patient_name, --患者姓名
|
||||
T2.py_str AS patient_py_str,--拼音码
|
||||
T2.wb_str AS patient_wb_str,--五笔码
|
||||
T2.gender_enum, --性别
|
||||
T2.birth_date, --生日
|
||||
STRING_AGG(T5.NAME, '_' ORDER BY T5.bus_no) AS inpatient_bed --床位
|
||||
FROM adm_encounter AS T1
|
||||
LEFT 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'
|
||||
LEFT JOIN adm_encounter_location AS T4
|
||||
ON T4.encounter_id = T1.id
|
||||
AND T4.status_enum = '2'
|
||||
AND T4.delete_flag = '0'
|
||||
LEFT JOIN adm_location AS T5
|
||||
ON T5.id = T4.location_id
|
||||
AND T5.delete_flag = '0'
|
||||
WHERE T1.class_enum = #{amb}
|
||||
--todo status_enum 的值
|
||||
AND T1.status_enum = 5
|
||||
AND T1.delete_flag = '0'
|
||||
GROUP BY T1.tenant_id,
|
||||
T1.organization_id,
|
||||
T3.name,
|
||||
T1.id,
|
||||
T1.bus_no,
|
||||
T2.name,
|
||||
T2.py_str,
|
||||
T2.wb_str,
|
||||
T2.gender_enum,
|
||||
T2.birth_date) AS ii
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<select id="selectPrescriptionInfoListPage" resultType="com.openhis.web.inhospitalnursestation.dto.InpatientMedicinePrescriptionInfoDto">
|
||||
SELECT ii.tenant_id,
|
||||
ii.dispense_id,--药品发放id
|
||||
ii.therapy_enum,--治疗类型
|
||||
ii.planned_dispense_time,--预定发放时间
|
||||
ii.encounter_id,--就诊id
|
||||
ii.patient_name,--患者姓名
|
||||
ii.status_enum,--发放状态
|
||||
ii.item_table,--项目表
|
||||
ii.item_id,--项目id
|
||||
ii.item_name,--项目名
|
||||
ii.quantity,--请求数量
|
||||
ii.unit_code,--请求单位编码
|
||||
ii.location_id,--发放地点
|
||||
ii.location_name,
|
||||
ii.lot_number,--批号
|
||||
ii.total_volume--规格
|
||||
FROM (SELECT T1.tenant_id,
|
||||
T1.id AS dispense_id,--发放id
|
||||
T2.therapy_enum,--治疗类型
|
||||
T1.planned_dispense_time,--预定发放时间
|
||||
T1.encounter_id,--就诊id
|
||||
T3.name AS patient_name,--患者姓名
|
||||
T1.status_enum,--发放状态
|
||||
#{medMedicationDefinition} AS item_table,--项目表
|
||||
T1.medication_id AS item_id,--项目id
|
||||
T4.name AS item_name,--项目名
|
||||
T1.quantity,--请求数量
|
||||
T1.unit_code,--请求单位编码
|
||||
T1.location_id,--发放地点
|
||||
T6.name AS location_name,
|
||||
T1.lot_number,--批号
|
||||
T5.total_volume--规格
|
||||
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 adm_patient AS T3
|
||||
ON T1.patient_id = T3.id
|
||||
AND T3.delete_flag = '0'
|
||||
LEFT JOIN med_medication_definition AS T4
|
||||
ON T1.medication_id = T4.id
|
||||
AND T4.delete_flag = '0'
|
||||
LEFT JOIN med_medication AS T5
|
||||
ON T4.id = T5.medication_def_id
|
||||
AND T5.delete_flag = '0'
|
||||
LEFT JOIN adm_location AS T6
|
||||
ON T1.location_id = T6.id
|
||||
AND T6.delete_flag = '0'
|
||||
WHERE T1.encounter_id IN
|
||||
<foreach collection="encounterIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND T1.status_enum = #{statusEnum}
|
||||
AND T1.delete_flag = '0'
|
||||
GROUP BY T1.id,
|
||||
T2.therapy_enum,
|
||||
T3.name,
|
||||
T4.name,
|
||||
T6.name,
|
||||
T5.total_volume
|
||||
UNION
|
||||
SELECT T1.tenant_id,
|
||||
T1.id AS dispense_id,--发放id
|
||||
null AS therapy_enum,--治疗类型
|
||||
T1.planned_dispense_time,--预定发放时间
|
||||
T1.encounter_id,--就诊id
|
||||
T3.name AS patient_name,--患者姓名
|
||||
T1.status_enum,--发放状态
|
||||
#{admDeviceDefinition} AS item_table,--项目表
|
||||
T1.device_def_id AS item_id,--项目id
|
||||
T4.name AS item_name,--项目名
|
||||
T1.quantity,--请求数量
|
||||
T1.unit_code,--请求单位编码
|
||||
T1.location_id,--发放地点
|
||||
T6.name AS location_name,
|
||||
T1.lot_number,--批号
|
||||
T4.size AS total_volume--规格
|
||||
FROM wor_device_dispense AS T1
|
||||
LEFT JOIN wor_device_request AS T2
|
||||
ON T1.device_req_id = T2.id
|
||||
AND T2.delete_flag = '0'
|
||||
LEFT JOIN adm_patient AS T3
|
||||
ON T1.patient_id = T3.id
|
||||
AND T3.delete_flag = '0'
|
||||
LEFT JOIN adm_device_definition AS T4
|
||||
ON T1.device_def_id = T4.id
|
||||
AND T4.delete_flag = '0'
|
||||
LEFT JOIN adm_device AS T5
|
||||
ON T4.id = T5.device_def_id
|
||||
AND T5.delete_flag = '0'
|
||||
LEFT JOIN adm_location AS T6
|
||||
ON T1.location_id = T6.id
|
||||
AND T6.delete_flag = '0'
|
||||
WHERE T1.encounter_id IN
|
||||
<foreach collection="encounterIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND T1.status_enum = #{statusEnum}
|
||||
AND T1.delete_flag = '0'
|
||||
GROUP BY T1.id,
|
||||
T3.name,
|
||||
T4.name,
|
||||
T6.name,
|
||||
T4.size
|
||||
) AS ii
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<select id="selectPrescriptionSummaryInfoListPage" resultType="com.openhis.web.inhospitalnursestation.dto.InpatientMedicinePrescriptionInfoDto">
|
||||
SELECT ii.tenant_id,
|
||||
ii.dispense_ids,
|
||||
ii.item_table,
|
||||
ii.item_id,
|
||||
ii.item_name,
|
||||
ii.quantity,
|
||||
ii.unit_code,
|
||||
ii.lot_number,
|
||||
ii.status_enum,
|
||||
ii.location_id,
|
||||
ii.location_enum
|
||||
FROM (SELECT T1.tenant_id,
|
||||
string_agg(T1.id::text, ',' ORDER BY T1.id) AS dispense_ids,
|
||||
#{medMedicationDefinition} AS item_table,--项目表
|
||||
T1.medication_id AS item_id,--项目id
|
||||
T4.name AS item_name,--项目名
|
||||
SUM(T1.quantity) AS quantity,--请求数量
|
||||
T1.unit_code,--请求单位编码
|
||||
T1.lot_number,--批号
|
||||
T1.status_enum,--发放状态
|
||||
T1.location_id,--发放地点
|
||||
T6.form_enum AS location_enum--地点类型
|
||||
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 adm_patient AS T3
|
||||
-- ON T1.patient_id = T3.id
|
||||
-- AND T3.delete_flag = '0'
|
||||
LEFT JOIN med_medication_definition AS T4
|
||||
ON T1.medication_id = T4.id
|
||||
AND T4.delete_flag = '0'
|
||||
LEFT JOIN med_medication AS T5
|
||||
ON T4.id = T5.medication_def_id
|
||||
AND T5.delete_flag = '0'
|
||||
LEFT JOIN adm_location AS T6
|
||||
ON T1.location_id = T6.id
|
||||
AND T6.delete_flag = '0'
|
||||
WHERE T1.id IN
|
||||
<foreach collection="medDispenseId" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND T1.delete_flag = '0'
|
||||
GROUP BY T1.tenant_id,
|
||||
T1.medication_id,
|
||||
T1.unit_code,
|
||||
T1.lot_number,
|
||||
T1.location_id,
|
||||
T4.name,
|
||||
T6.form_enum
|
||||
UNION
|
||||
SELECT T1.tenant_id,
|
||||
string_agg(T1.id::text, ',' ORDER BY T1.id) AS dispense_ids,
|
||||
#{admDeviceDefinition} AS item_table,--项目表
|
||||
T1.device_def_id AS item_id,--项目id
|
||||
T4.name AS item_name,--项目名
|
||||
SUM(T1.quantity) AS quantity,--请求数量
|
||||
T1.unit_code,--请求单位编码
|
||||
T1.lot_number,--批号
|
||||
T1.status_enum,--发放状态
|
||||
T1.location_id,--发放地点
|
||||
T6.form_enum AS location_enum--地点类型
|
||||
FROM wor_device_dispense AS T1
|
||||
LEFT JOIN wor_device_request AS T2
|
||||
ON T1.device_req_id = T2.id
|
||||
AND T2.delete_flag = '0'
|
||||
-- LEFT JOIN adm_patient AS T3
|
||||
-- ON T1.patient_id = T3.id
|
||||
-- AND T3.delete_flag = '0'
|
||||
LEFT JOIN adm_device_definition AS T4
|
||||
ON T1.device_def_id = T4.id
|
||||
AND T4.delete_flag = '0'
|
||||
LEFT JOIN adm_device AS T5
|
||||
ON T4.id = T5.device_def_id
|
||||
AND T5.delete_flag = '0'
|
||||
LEFT JOIN adm_location AS T6
|
||||
ON T1.location_id = T6.id
|
||||
AND T6.delete_flag = '0'
|
||||
WHERE T1.id IN
|
||||
<foreach collection="devDispenseId" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND T1.delete_flag = '0'
|
||||
GROUP BY T1.tenant_id,
|
||||
T1.device_def_id,
|
||||
T1.unit_code,
|
||||
T1.lot_number,
|
||||
T1.location_id,
|
||||
T4.name,
|
||||
T6.form_enum) AS ii
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user