@@ -23,12 +23,10 @@
|
||||
ii.bed_id,
|
||||
ii.bed_name,
|
||||
ii.organization_name,
|
||||
ii.contract_name,
|
||||
COALESCE(ii.time1, ii.time2, ii.time3) AS admission_time
|
||||
ii.contract_name
|
||||
FROM (
|
||||
WITH locations AS (
|
||||
SELECT ael.encounter_id,
|
||||
ael.start_time as admission_time,
|
||||
al.form_enum,
|
||||
al.id AS location_id,
|
||||
al."name" AS location_name
|
||||
@@ -60,10 +58,7 @@
|
||||
alb.location_id AS bed_id,
|
||||
alb.location_name AS bed_name,
|
||||
ao."name" AS organization_name,
|
||||
fc.contract_name,
|
||||
alw.admission_time as time1,
|
||||
alh.admission_time as time2,
|
||||
alb.admission_time as time3
|
||||
fc.contract_name
|
||||
FROM adm_encounter ae
|
||||
LEFT JOIN adm_patient ap
|
||||
ON ae.patient_id = ap.id
|
||||
@@ -90,8 +85,7 @@
|
||||
WHERE ae.delete_flag = '0'
|
||||
AND ae.class_enum = #{imp}
|
||||
AND ae.status_enum != #{toBeRegistered}
|
||||
GROUP BY ae.tenant_id,
|
||||
ae.id,
|
||||
GROUP BY ae.id,
|
||||
ae.bus_no,
|
||||
ae.status_enum,
|
||||
ae.start_time,
|
||||
@@ -111,10 +105,7 @@
|
||||
alb.location_id,
|
||||
alb.location_name,
|
||||
ao."name",
|
||||
fc.contract_name,
|
||||
alw.admission_time,
|
||||
alh.admission_time,
|
||||
alb.admission_time
|
||||
fc.contract_name
|
||||
ORDER BY ae.bus_no DESC
|
||||
) AS ii
|
||||
${ew.customSqlSegment}
|
||||
@@ -199,7 +190,6 @@
|
||||
AND bed.delete_flag = '0'
|
||||
AND bed.status_enum != #{inactive}
|
||||
GROUP BY bed.id,
|
||||
bed.bus_no,
|
||||
bed.tenant_id,
|
||||
bed."name",
|
||||
bed.status_enum,
|
||||
@@ -224,107 +214,112 @@
|
||||
</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,
|
||||
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,
|
||||
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_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,
|
||||
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
|
||||
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'
|
||||
AND ae.delete_flag = '0'
|
||||
GROUP BY ae.id,
|
||||
ae.bus_no,
|
||||
ae.priority_enum,
|
||||
ae.organization_id,
|
||||
ae.bus_no ,
|
||||
ae.priority_enum ,
|
||||
ae.organization_id ,
|
||||
ae.start_time,
|
||||
bed.start_time,
|
||||
bed.location_id,
|
||||
@@ -343,437 +338,10 @@
|
||||
chiefDoctor.practitioner_name,
|
||||
ao."name",
|
||||
ap."name",
|
||||
ap.gender_enum,
|
||||
ap.birth_date,
|
||||
ap.phone,
|
||||
fc.contract_name,
|
||||
ap.gender_enum ,
|
||||
ap.birth_date ,
|
||||
ap.phone ,
|
||||
fc.contract_name ,
|
||||
diagnosis.condition_names
|
||||
</select>
|
||||
<select id="getAmount" resultType="com.openhis.web.inhospitalnursestation.dto.EncounterAccountDto">
|
||||
SELECT aa.id,
|
||||
aa.encounter_id,
|
||||
aa.balance_amount AS advance_amount,
|
||||
COALESCE(SUM(CASE WHEN aci.status_enum IN (#{billed}, #{billable}) THEN aci.total_price ELSE 0 END),
|
||||
0) 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 aci.delete_flag = '0'
|
||||
WHERE aa.type_code = #{personalCashAccount}
|
||||
AND aa.delete_flag = '0'
|
||||
AND aa.encounter_id = #{encounterId}
|
||||
GROUP BY aa.id, aa.encounter_id, aa.balance_amount;
|
||||
</select>
|
||||
<select id="getPendingMedication" resultType="com.openhis.web.inhospitalnursestation.dto.PendingMedicationDto">
|
||||
SELECT mmr.id AS medication_request_id,
|
||||
mmdi.id AS medication_dispense_id,
|
||||
ao.name AS org_name,
|
||||
al.name AS perform_location_name,
|
||||
mmde.name AS medication_name,
|
||||
mm.total_volume AS medication_spec,
|
||||
aci.unit_price,
|
||||
mmr.quantity AS request_quantity,
|
||||
mmr.unit_code,
|
||||
mmdi.dispense_quantity,
|
||||
aci.total_price,
|
||||
mmdi.practitioner_id AS dispense_practitioner_id,
|
||||
ap.name AS dispense_practitioner_name,
|
||||
mmdi.planned_dispense_time,
|
||||
mmdi.status_enum AS dispense_status_enum,
|
||||
mmr.status_enum AS request_status_enum
|
||||
|
||||
FROM med_medication_request AS mmr
|
||||
LEFT JOIN med_medication_definition AS mmde
|
||||
ON mmde.id = mmr.medication_id
|
||||
AND mmde.delete_flag = '0'
|
||||
LEFT JOIN med_medication AS mm
|
||||
ON mm.medication_def_id = mmde.id
|
||||
AND mm.delete_flag = '0'
|
||||
LEFT JOIN adm_location AS al
|
||||
ON al.id = mmr.perform_location
|
||||
AND al.delete_flag = '0'
|
||||
LEFT JOIN med_medication_dispense AS mmdi
|
||||
ON mmdi.med_req_id = mmr.id
|
||||
AND mmdi.delete_flag = '0'
|
||||
LEFT JOIN adm_charge_item AS aci
|
||||
ON aci.service_table = 'med_medication_request'
|
||||
AND aci.encounter_id = #{encounterId}
|
||||
AND aci.delete_flag = '0'
|
||||
LEFT JOIN adm_organization ao
|
||||
ON ao.id = mmr.org_id
|
||||
AND ao.delete_flag = '0'
|
||||
LEFT JOIN adm_practitioner ap
|
||||
ON ap.id = mmdi.practitioner_id
|
||||
AND ap.delete_flag = '0'
|
||||
WHERE mmr.encounter_id = #{encounterId}
|
||||
AND ((mmdi.status_enum = #{preparationStatus}
|
||||
OR mmdi.status_enum = #{summarizedStatus})
|
||||
OR mmr.status_enum = #{requestStatus})
|
||||
</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."bed_name" AS bed_name,
|
||||
ii.gender_enum,
|
||||
ii.birth_date,
|
||||
ii.patient_id,
|
||||
ii.contract_name,
|
||||
ii.condition_names,
|
||||
ii.admitting_doctor_name AS admitting_doctor_name,
|
||||
ii.balance_amount AS balance_amount,
|
||||
ii.account_id AS account_id,
|
||||
ii.performer_check_id,
|
||||
ii.category_code,
|
||||
ii.org_name
|
||||
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,
|
||||
T1.performer_check_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 bed_name,
|
||||
ap.gender_enum,
|
||||
ap.birth_date,
|
||||
ap.id AS patient_id,
|
||||
fc.contract_name,
|
||||
diagnosis.condition_names,
|
||||
pra."name" AS admitting_doctor_name,
|
||||
personal_account.balance_amount,
|
||||
personal_account.id AS account_id,
|
||||
T2.category_code,
|
||||
ao.name AS org_name
|
||||
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 adm_organization AS ao
|
||||
ON ao.id = T1.perform_org
|
||||
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.id,
|
||||
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.id,
|
||||
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 T1.status_enum != #{stopped}
|
||||
AND T1.generate_source_enum = #{doctorPrescription}
|
||||
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,
|
||||
T1.performer_check_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,
|
||||
af.day_times,
|
||||
ae.bus_no,
|
||||
ap."name" AS patient_name,
|
||||
al2."name" AS bed_name,
|
||||
ap.gender_enum,
|
||||
ap.birth_date,
|
||||
ap.id AS patient_id,
|
||||
fc.contract_name,
|
||||
diagnosis.condition_names,
|
||||
pra."name" AS admitting_doctor_name,
|
||||
personal_account.balance_amount,
|
||||
personal_account.id AS account_id,
|
||||
T2.category_code,
|
||||
ao1.name AS org_name
|
||||
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.id,
|
||||
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.id,
|
||||
aa.encounter_id,
|
||||
aa.balance_amount) AS personal_account
|
||||
ON personal_account.encounter_id = ae.id
|
||||
LEFT JOIN adm_frequency af
|
||||
ON af.rate_code = T1.rate_code
|
||||
AND af.delete_flag = '0'
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND T1.status_enum != #{stopped}
|
||||
AND T1.generate_source_enum = #{doctorPrescription}
|
||||
AND T2.category_code != #{transfer}
|
||||
AND T2.category_code != #{discharge}
|
||||
AND T2.category_code != #{nursing}
|
||||
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>
|
||||
<select id="selectPerformRecordList" resultType="com.openhis.web.common.dto.PerformRecordDto">
|
||||
SELECT cp.id AS procedure_id,
|
||||
cp.status_enum,
|
||||
cp.occurrence_time,
|
||||
cp.create_time,
|
||||
al."name" AS location_name,
|
||||
ao."name" AS org_name,
|
||||
cp.request_id,
|
||||
cp.refund_id,
|
||||
cpp.start_time,
|
||||
cpp.end_time,
|
||||
ap."name" AS practitioner_name
|
||||
FROM cli_procedure cp
|
||||
LEFT JOIN cli_procedure_performer cpp
|
||||
ON cpp.procedure_id = cp.id
|
||||
AND cpp.delete_flag = '0'
|
||||
LEFT JOIN adm_organization ao
|
||||
ON ao.id = cp.org_id
|
||||
AND ao.delete_flag = '0'
|
||||
LEFT JOIN adm_location al
|
||||
ON al.id = cp.location_id
|
||||
AND al.delete_flag = '0'
|
||||
LEFT JOIN adm_practitioner ap
|
||||
ON ap.id = cpp.practitioner_id
|
||||
AND ap.delete_flag = '0'
|
||||
WHERE cp.delete_flag = '0'
|
||||
<if test="reqIds!=null and !reqIds.isEmpty()">
|
||||
AND cp.request_id IN
|
||||
<foreach collection="reqIds" item="reqId" open="(" separator="," close=")">
|
||||
#{reqId}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -23,90 +23,83 @@
|
||||
ii.house_name,
|
||||
ii.bed_id,
|
||||
ii.bed_name,
|
||||
ii.organization_name,
|
||||
ii.patient_id,
|
||||
ii.account_id
|
||||
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,
|
||||
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 AS encounter_status,
|
||||
ae.status_enum,
|
||||
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."name",
|
||||
ap.py_str,
|
||||
ap.wb_str,
|
||||
ap.gender_enum,
|
||||
ap.birth_date,
|
||||
ap.id as patient_id,
|
||||
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,
|
||||
aa.id AS account_id
|
||||
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.delete_flag = '0'
|
||||
WHERE ae.delete_flag = '0'
|
||||
AND ae.class_enum = #{imp}
|
||||
AND ae.status_enum != #{toBeRegistered}
|
||||
AND ae.status_enum != #{registered}
|
||||
AND aa.type_code = #{personalCashAccount}
|
||||
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,
|
||||
ap.id,
|
||||
alw.location_id,
|
||||
alw.location_name,
|
||||
alh.location_id,
|
||||
alh.location_name,
|
||||
alb.location_id,
|
||||
alb.location_name,
|
||||
ao."name",
|
||||
aa.id,
|
||||
ae.tenant_id
|
||||
ORDER BY ae.bus_no DESC) AS ii
|
||||
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"
|
||||
@@ -152,8 +145,7 @@
|
||||
ii.admitting_doctor_name AS admitting_doctor_name,
|
||||
ii.balance_amount AS balance_amount,
|
||||
ii.account_id AS account_id,
|
||||
ii.performer_check_id,
|
||||
ii.category_code
|
||||
ii.performer_check_id
|
||||
FROM (( SELECT T1.encounter_id,
|
||||
T1.tenant_id,
|
||||
#{medMedicationRequest} AS advice_table,
|
||||
@@ -196,8 +188,7 @@
|
||||
diagnosis.condition_names,
|
||||
pra."name" AS admitting_doctor_name,
|
||||
personal_account.balance_amount,
|
||||
personal_account.id AS account_id,
|
||||
T2.category_code
|
||||
personal_account.id AS account_id
|
||||
FROM med_medication_request AS T1
|
||||
LEFT JOIN med_medication_definition AS T2
|
||||
ON T2.id = T1.medication_id
|
||||
@@ -280,7 +271,6 @@
|
||||
ON personal_account.encounter_id = ae.id
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND T1.refund_medicine_id IS NULL
|
||||
AND T1.generate_source_enum = #{doctorPrescription}
|
||||
AND CASE WHEN T1.status_enum = #{draft}
|
||||
THEN T1.performer_check_id IS NOT NULL
|
||||
ELSE 1=1 END
|
||||
@@ -330,8 +320,7 @@
|
||||
diagnosis.condition_names,
|
||||
pra."name" AS admitting_doctor_name,
|
||||
personal_account.balance_amount,
|
||||
personal_account.id AS account_id,
|
||||
T2.category_code
|
||||
personal_account.id AS account_id
|
||||
FROM wor_service_request AS T1
|
||||
LEFT JOIN wor_activity_definition AS T2
|
||||
ON T2.id = T1.activity_id
|
||||
@@ -411,7 +400,6 @@
|
||||
ON af.rate_code = T1.rate_code
|
||||
AND af.delete_flag = '0'
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND T1.generate_source_enum = #{doctorPrescription}
|
||||
AND CASE WHEN T1.status_enum = #{draft}
|
||||
THEN T1.performer_check_id IS NOT NULL
|
||||
ELSE 1=1 END
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
<?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.EncounterAutoRollAppMapper">
|
||||
|
||||
<select id="getSource" resultType="com.openhis.web.inhospitalnursestation.dto.AutoRollSourceDto">
|
||||
SELECT ID AS instance_id,
|
||||
NAME AS instance_name,
|
||||
permitted_unit_code
|
||||
FROM wor_activity_definition
|
||||
WHERE delete_flag = '0'
|
||||
AND status_enum = #{status}
|
||||
AND category_code = #{basicService}
|
||||
</select>
|
||||
|
||||
<select id="getEncounter" resultType="com.openhis.web.inhospitalnursestation.dto.EncounterAutoRollQueryDto">
|
||||
SELECT tear.ID,
|
||||
tear.status_enum,
|
||||
tear.quantity,
|
||||
sdd.dict_label AS unit_code_name,
|
||||
CASE
|
||||
WHEN tear.instance_table = 'wor_activity_definition' THEN
|
||||
wor.NAME
|
||||
ELSE NULL
|
||||
END AS definition_name
|
||||
FROM tmp_encounter_auto_roll AS tear
|
||||
LEFT JOIN wor_activity_definition AS wor ON tear.instance_table = 'wor_activity_definition'
|
||||
AND tear.instance_id = wor.
|
||||
ID
|
||||
LEFT JOIN sys_dict_data AS sdd ON sdd.dict_value = wor.permitted_unit_code
|
||||
AND sdd.dict_type = 'unit_code'
|
||||
AND sdd.status = '0'
|
||||
WHERE tear.delete_flag = '0'
|
||||
AND tear.encounter_id = #{encounterId}
|
||||
</select>
|
||||
|
||||
<select id="getInBedPatientInfo" resultType="com.openhis.web.inhospitalnursestation.dto.InBedPatientInfoDto">
|
||||
SELECT ae.ID AS encounter_id,
|
||||
ae.organization_id,
|
||||
ae.patient_id,
|
||||
aa.ID AS account_id,
|
||||
aed.ID AS encounter_diagnosis_id,
|
||||
aed.condition_id
|
||||
FROM adm_encounter AS ae
|
||||
LEFT JOIN adm_account AS aa ON aa.encounter_id = ae.ID
|
||||
AND aa.delete_flag = '0'
|
||||
AND aa.type_code = #{typeCode}
|
||||
LEFT JOIN adm_encounter_diagnosis AS aed ON aed.encounter_id = ae.ID
|
||||
AND aed.delete_flag = '0'
|
||||
AND aed.maindise_flag = #{maindiseFlag}
|
||||
WHERE ae.delete_flag = '0'
|
||||
AND ae.class_enum = #{classEnum}
|
||||
AND EXISTS(
|
||||
SELECT 1
|
||||
FROM adm_encounter_location AS ael
|
||||
WHERE ael.encounter_id = ae.ID
|
||||
AND ael.delete_flag = '0'
|
||||
AND ael.status_enum = #{status}
|
||||
AND ael.form_enum = #{formEnum}
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="getNursingRequest" resultType="com.openhis.web.inhospitalnursestation.dto.AutoRollNursingDto">
|
||||
SELECT
|
||||
wsr.activity_id AS activity_definition_id,
|
||||
wsr.quantity,
|
||||
wsr.patient_id,
|
||||
wsr.encounter_id,
|
||||
wsr.requester_id
|
||||
FROM
|
||||
wor_service_request AS wsr
|
||||
WHERE
|
||||
wsr.delete_flag = '0'
|
||||
AND wsr.category_enum = #{categoryEnum}
|
||||
AND wsr.status_enum = #{status}
|
||||
<if test="encounterIdList != null and !encounterIdList.isEmpty()">
|
||||
AND wsr.encounter_id IN
|
||||
<foreach collection="encounterIdList" item="itemId" open="(" separator="," close=")">
|
||||
#{itemId}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getAutoRollBasicService"
|
||||
resultType="com.openhis.web.inhospitalnursestation.dto.AutoRollBasicServiceDto">
|
||||
SELECT
|
||||
tear.encounter_id,
|
||||
tear.instance_id AS activity_definition_id,
|
||||
tear.quantity,
|
||||
tear.practitioner_id AS requester_id,
|
||||
tear.organization_id
|
||||
FROM
|
||||
tmp_encounter_auto_roll AS tear
|
||||
WHERE
|
||||
tear.delete_flag = '0'
|
||||
AND tear.status_enum = #{status}
|
||||
<if test="encounterIdList != null and !encounterIdList.isEmpty()">
|
||||
AND tear.encounter_id IN
|
||||
<foreach collection="encounterIdList" item="itemId" open="(" separator="," close=")">
|
||||
#{itemId}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user