Fix Bug #550: AI修复
This commit is contained in:
@@ -1,7 +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.administration.mapper.AccountMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.BizUserMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.BizUserRoleMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,209 +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.administration.mapper.ChangePriceRecordMapper">
|
||||
|
||||
<select id="searchMedChangePriceByBusNo" resultType="com.openhis.administration.dto.ChangePriceDataDto">
|
||||
select md.name as itemName,
|
||||
record.origin_buying_price as originBuyingPrice,
|
||||
record.new_buying_price as newBuyingPrice,
|
||||
record.origin_retail_price as originRetailPrice,
|
||||
record.new_retail_price as newRetailPrice,
|
||||
record.reason as reason,
|
||||
record.bus_no as busNo,
|
||||
record.unit_code as unitCode,
|
||||
med.total_volume as totalVolume,
|
||||
sum(record.item_quantity) as itemQuantity,
|
||||
sum(record.difference_buying_price) as differenceBuyingPrice,
|
||||
sum(record.difference_retail_price) as differenceRetailPrice
|
||||
from adm_change_price_record record
|
||||
left join med_medication_definition md on record.item_id = md.id
|
||||
left join med_medication med on medication_def_id = md.id
|
||||
where record.bus_no = #{busNo}
|
||||
and record.item_category_enum = #{categoryEnum}
|
||||
<if test="statusEnum != null">
|
||||
and record.status_enum = #{statusEnum}
|
||||
</if>
|
||||
group by md.name, record.origin_buying_price, record.new_buying_price, record.origin_retail_price,
|
||||
record.new_retail_price, record.reason, record.bus_no,record.unit_code,med.total_volume
|
||||
</select>
|
||||
|
||||
<select id="searchMedChangePriceByItemId" resultType="com.openhis.administration.dto.ChangePriceDataDto">
|
||||
select md.name as itemName,
|
||||
record.origin_buying_price as originBuyingPrice,
|
||||
record.new_buying_price as newBuyingPrice,
|
||||
record.origin_retail_price as originRetailPrice,
|
||||
record.new_retail_price as newRetailPrice,
|
||||
record.reason as reason,
|
||||
record.bus_no as busNo,
|
||||
record.unit_code as unitCode,
|
||||
med.total_volume as totalVolume,
|
||||
sum(record.item_quantity) as itemQuantity,
|
||||
sum(record.difference_buying_price) as differenceBuyingPrice,
|
||||
sum(record.difference_retail_price) as differenceRetailPrice
|
||||
from adm_change_price_record record
|
||||
left join med_medication_definition md on record.item_id = md.id
|
||||
left join med_medication med on medication_def_id = md.id
|
||||
where record.item_id = #{itemId}
|
||||
and record.item_category_enum = #{categoryEnum}
|
||||
and record.status_enum = #{statusEnum}
|
||||
group by md.name, record.origin_buying_price, record.new_buying_price, record.origin_retail_price,
|
||||
record.new_retail_price, record.reason, record.bus_no,record.unit_code,med.total_volume
|
||||
</select>
|
||||
|
||||
<select id="searchDeviceChangePriceByBusNo" resultType="com.openhis.administration.dto.ChangePriceDataDto">
|
||||
select deivce.name as itemName,
|
||||
record.origin_buying_price as originBuyingPrice,
|
||||
record.new_buying_price as newBuyingPrice,
|
||||
record.origin_retail_price as originRetailPrice,
|
||||
record.new_retail_price as newRetailPrice,
|
||||
record.reason as reason,
|
||||
record.bus_no as busNo,
|
||||
deivce.size as totalVolume,
|
||||
sum(record.item_quantity) as itemQuantity,
|
||||
sum(record.difference_buying_price) as differenceBuyingPrice,
|
||||
sum(record.difference_retail_price) as differenceRetailPrice
|
||||
from adm_change_price_record record
|
||||
left join adm_device_definition deivce on record.item_id = deivce.id
|
||||
where record.bus_no = #{busNo}
|
||||
and record.item_category_enum = #{categoryEnum}
|
||||
<if test="statusEnum != null">
|
||||
and record.status_enum = #{statusEnum}
|
||||
</if>
|
||||
group by deivce.name, record.origin_buying_price, record.new_buying_price, record.origin_retail_price,
|
||||
record.new_retail_price, record.reason, record.bus_no,deivce.size
|
||||
</select>
|
||||
|
||||
<select id="searchDeviceChangePriceByItemId" resultType="com.openhis.administration.dto.ChangePriceDataDto">
|
||||
select deivce.name as itemName,
|
||||
record.origin_buying_price as originBuyingPrice,
|
||||
record.new_buying_price as newBuyingPrice,
|
||||
record.origin_retail_price as originRetailPrice,
|
||||
record.new_retail_price as newRetailPrice,
|
||||
record.reason as reason,
|
||||
record.bus_no as busNo,
|
||||
deivce.size as totalVolume,
|
||||
sum(record.item_quantity) as itemQuantity,
|
||||
sum(record.difference_buying_price) as differenceBuyingPrice,
|
||||
sum(record.difference_retail_price) as differenceRetailPrice
|
||||
from adm_change_price_record record
|
||||
left join adm_device_definition deivce on record.item_id = deivce.id
|
||||
where record.item_id = #{itemId}
|
||||
and record.item_category_enum = #{categoryEnum}
|
||||
and record.status_enum = #{statusEnum}
|
||||
group by deivce.name, record.origin_buying_price, record.new_buying_price, record.origin_retail_price,
|
||||
record.new_retail_price, record.reason, record.bus_no,deivce.size
|
||||
</select>
|
||||
|
||||
<select id="searchActivityChangePriceByBusNo" resultType="com.openhis.administration.dto.ChangePriceDataDto">
|
||||
select activity.name as itemName,
|
||||
record.origin_buying_price as originBuyingPrice,
|
||||
record.new_buying_price as newBuyingPrice,
|
||||
record.origin_retail_price as originRetailPrice,
|
||||
record.new_retail_price as newRetailPrice,
|
||||
record.reason as reason,
|
||||
record.bus_no as busNo,
|
||||
sum(record.item_quantity) as itemQuantity,
|
||||
sum(record.difference_buying_price) as differenceBuyingPrice,
|
||||
sum(record.difference_retail_price) as differenceRetailPrice
|
||||
from adm_change_price_record record
|
||||
left join wor_activity_definition activity on record.item_id = activity.id
|
||||
where record.bus_no = #{busNo}
|
||||
and record.item_category_enum = #{categoryEnum}
|
||||
<if test="statusEnum != null">
|
||||
and record.status_enum = #{statusEnum}
|
||||
</if>
|
||||
group by activity.name, record.origin_buying_price, record.new_buying_price, record.origin_retail_price,
|
||||
record.new_retail_price, record.reason, record.bus_no
|
||||
</select>
|
||||
|
||||
<select id="searchActivityChangePriceByItemId" resultType="com.openhis.administration.dto.ChangePriceDataDto">
|
||||
select activity.name as itemName,
|
||||
record.origin_buying_price as originBuyingPrice,
|
||||
record.new_buying_price as newBuyingPrice,
|
||||
record.origin_retail_price as originRetailPrice,
|
||||
record.new_retail_price as newRetailPrice,
|
||||
record.reason as reason,
|
||||
record.bus_no as busNo,
|
||||
sum(record.item_quantity) as itemQuantity,
|
||||
sum(record.difference_buying_price) as differenceBuyingPrice,
|
||||
sum(record.difference_retail_price) as differenceRetailPrice
|
||||
from adm_change_price_record record
|
||||
left join wor_activity_definition activity on record.item_id = activity.id
|
||||
where record.item_id = #{itemId}
|
||||
and record.item_category_enum = #{categoryEnum}
|
||||
and record.status_enum = #{statusEnum}
|
||||
group by activity.name, record.origin_buying_price, record.new_buying_price, record.origin_retail_price,
|
||||
record.new_retail_price, record.reason, record.bus_no
|
||||
</select>
|
||||
|
||||
<select id="searchHealthChangePriceByBusNo" resultType="com.openhis.administration.dto.ChangePriceDataDto">
|
||||
select hearlth.name as itemName,
|
||||
org.name as orgName,
|
||||
record.origin_buying_price as originBuyingPrice,
|
||||
record.new_buying_price as newBuyingPrice,
|
||||
record.origin_retail_price as originRetailPrice,
|
||||
record.new_retail_price as newRetailPrice,
|
||||
record.reason as reason,
|
||||
record.bus_no as busNo,
|
||||
sum(record.item_quantity) as itemQuantity,
|
||||
sum(record.difference_buying_price) as differenceBuyingPrice,
|
||||
sum(record.difference_retail_price) as differenceRetailPrice
|
||||
from adm_change_price_record record
|
||||
left join adm_healthcare_service hearlth on record.item_id = hearlth.id
|
||||
left join adm_organization org on hearlth.offered_org_id = org.id
|
||||
where record.bus_no = #{busNo}
|
||||
and record.item_category_enum = #{categoryEnum}
|
||||
<if test="statusEnum != null">
|
||||
and record.status_enum = #{statusEnum}
|
||||
</if>
|
||||
group by hearlth.name, record.origin_buying_price, record.new_buying_price, record.origin_retail_price,
|
||||
record.new_retail_price, record.reason, record.bus_no, org.name
|
||||
</select>
|
||||
|
||||
<select id="searchHealthChangePriceByItemId" resultType="com.openhis.administration.dto.ChangePriceDataDto">
|
||||
select hearlth.name as itemName,
|
||||
org.name as orgName,
|
||||
record.origin_buying_price as originBuyingPrice,
|
||||
record.new_buying_price as newBuyingPrice,
|
||||
record.origin_retail_price as originRetailPrice,
|
||||
record.new_retail_price as newRetailPrice,
|
||||
record.reason as reason,
|
||||
record.bus_no as busNo,
|
||||
sum(record.item_quantity) as itemQuantity,
|
||||
sum(record.difference_buying_price) as differenceBuyingPrice,
|
||||
sum(record.difference_retail_price) as differenceRetailPrice
|
||||
from adm_change_price_record record
|
||||
left join adm_healthcare_service hearlth on record.item_id = hearlth.id
|
||||
left join adm_organization org on hearlth.offered_org_id = org.id
|
||||
where record.item_id = #{itemId}
|
||||
and record.item_category_enum = #{categoryEnum}
|
||||
and record.status_enum = #{statusEnum}
|
||||
group by hearlth.name, record.origin_buying_price, record.new_buying_price, record.origin_retail_price,
|
||||
record.new_retail_price, record.reason, record.bus_no, org.name
|
||||
</select>
|
||||
|
||||
<select id="searchChangePriceRecordDataByBusNo" resultType="com.openhis.administration.dto.ChangePriceDataDto">
|
||||
select record.origin_buying_price as originBuyingPrice,
|
||||
record.new_buying_price as newBuyingPrice,
|
||||
record.origin_retail_price as originRetailPrice,
|
||||
record.new_retail_price as newRetailPrice,
|
||||
record.reason as reason,
|
||||
record.bus_no as busNo,
|
||||
cid.id as chargeId,
|
||||
record.id as changePriceRecordId,
|
||||
record.lot_number as lotNumber
|
||||
from adm_change_price_record record
|
||||
left join adm_charge_item_definition cid on record.item_id = cid.instance_id
|
||||
where record.bus_no = #{busNo}
|
||||
and record.status_enum = #{statusEnum}
|
||||
and cid.status_enum = 2
|
||||
</select>
|
||||
|
||||
<select id="searchChangePriceDataGroupByBusNo" resultType="com.openhis.administration.domain.ChangePriceRecord">
|
||||
select
|
||||
bus_no as busNo,applicant_time as applicantTime,status_enum as statusEnum,item_id as itemId
|
||||
from adm_change_price_record where bus_no = #{busNo} group by busNo,applicantTime,statusEnum,item_id
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,14 +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.administration.mapper.ChargeItemDefDetailAppMapper">
|
||||
|
||||
<select id="searchChargeDetailDataByBusNo" resultType="com.openhis.administration.domain.ChargeItemDefDetail">
|
||||
select create_time
|
||||
from adm_charge_item_def_detail
|
||||
where
|
||||
condition_value = #{value} and condition_code = #{code} and (delete_flag = '0' or delete_flag = '1')
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,38 +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.administration.mapper.ChargeItemDefinitionMapper">
|
||||
|
||||
<select id="getMedPriceByParam" resultType="com.openhis.administration.dto.ChargeItemDefDetailPriceDto">
|
||||
SELECT cidd.amount as price, mmd.part_percent as partPercent
|
||||
from adm_charge_item_definition cid
|
||||
left join adm_charge_item_def_detail cidd on cid.id = cidd.definition_id
|
||||
left join med_medication_definition mmd on cid.instance_id = mmd.id
|
||||
where cidd.condition_code = #{conditionCode}
|
||||
and cid.instance_id = #{instanceId}
|
||||
and cidd.delete_flag = '0'
|
||||
order by cidd.create_time desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="getDevicePriceByParam" resultType="com.openhis.administration.dto.ChargeItemDefDetailPriceDto">
|
||||
SELECT cidd.amount as price, device.part_percent as partPercent
|
||||
from adm_charge_item_definition cid
|
||||
left join adm_charge_item_def_detail cidd on cid.id = cidd.definition_id
|
||||
left join adm_device_definition device on cid.instance_id = device.id
|
||||
where cidd.condition_code = #{conditionCode}
|
||||
and cid.instance_id = #{instanceId}
|
||||
and cidd.delete_flag = '0'
|
||||
order by cidd.create_time desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="getProductPrice" resultType="com.openhis.administration.dto.ChargeItemDefDetailPriceDto">
|
||||
SELECT cid.price as price
|
||||
from adm_charge_item_definition cid
|
||||
where cid.instance_id = #{instanceId}
|
||||
and cid.status_enum = #{statusEnum}
|
||||
and cid.delete_flag = '0'
|
||||
order by cid.create_time desc limit 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,353 +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.administration.mapper.ChargeItemMapper">
|
||||
|
||||
<select id="getChargeItemBaseInfoByIds" resultType="com.openhis.administration.dto.ChargeItemBaseInfoDto">
|
||||
SELECT
|
||||
a.id ,
|
||||
a.status_enum ,
|
||||
a.bus_no ,
|
||||
a.patient_id ,
|
||||
a.context_enum ,
|
||||
a.encounter_id ,
|
||||
a.occurrence_time ,
|
||||
a.performer_id ,
|
||||
a.performing_org_id ,
|
||||
a.requesting_org_id ,
|
||||
a.cost_org_id ,
|
||||
a.quantity_value ,
|
||||
a.quantity_unit ,
|
||||
a.unit_price ,
|
||||
a.total_price ,
|
||||
a.definition_id ,
|
||||
a.def_detail_id ,
|
||||
a.base_amount ,
|
||||
a.discount_amount ,
|
||||
a.surcharge_amount ,
|
||||
a.override_reason_code ,
|
||||
a.override_reason_text ,
|
||||
a.enterer_id ,
|
||||
a.entered_date ,
|
||||
a.service_table ,
|
||||
a.service_id ,
|
||||
a.claim_state_enum ,
|
||||
a.account_id ,
|
||||
a.org_id ,
|
||||
a.tenant_id ,
|
||||
a.delete_flag ,
|
||||
a.create_by ,
|
||||
a.create_time ,
|
||||
a.update_by ,
|
||||
a.update_time ,
|
||||
a.print_count ,
|
||||
a.product_table ,
|
||||
a.product_id ,
|
||||
a.refund_id ,
|
||||
a.prescription_no ,
|
||||
a.generate_source_enum ,
|
||||
a.children_json ,
|
||||
a.condition_id ,
|
||||
a.encounter_diagnosis_id ,
|
||||
a.tcm_flag ,
|
||||
COALESCE(b1.bus_no, b2.bus_no, b3.bus_no) AS request_bus_no,
|
||||
COALESCE(b6.bus_no, b7.bus_no, b8.bus_no) AS base_bus_no,
|
||||
COALESCE(b6.name, b7.name, b8.name) AS "name",
|
||||
COALESCE(b6.category_code, b7.category_code, b8.category_code) AS category_code,
|
||||
COALESCE(b6.approval_number, b7.approval_number) AS approval_number,
|
||||
COALESCE(b6.yb_no, b7.yb_no, b8.yb_no) AS yb_no,
|
||||
CASE WHEN b6.children_flag is NOT NULL THEN b6.children_flag ELSE '0' END AS children_flag,
|
||||
COALESCE(b6.chrgitm_lv, b7.chrgitm_lv, b8.chrgitm_lv) AS chrgitm_lv,
|
||||
CASE WHEN b6.rx_flag is NOT NULL THEN b6.rx_flag ELSE 0 END AS children_flag,
|
||||
COALESCE(b1.yb_class_enum, b2.yb_class_enum, b3.yb_class_enum) AS yb_class_enum,
|
||||
COALESCE(b1.trace_no, b2.trace_no) AS trace_no,
|
||||
CASE WHEN b1.suffering_flag is NOT NULL THEN b1.suffering_flag ELSE 0 END AS suffering_flag,
|
||||
b5.yb_type,
|
||||
org."name" as dept_name,
|
||||
org.yb_no as dept_yb_no,
|
||||
pra."name" as doct_name,
|
||||
pra.yb_no as doct_yb_no,
|
||||
contract.bus_no as contract_no,
|
||||
T2.charge_name,
|
||||
T2.title,
|
||||
T2.status_enum,
|
||||
T2.org_id,
|
||||
T2.description,
|
||||
T2.instance_table,
|
||||
T2.instance_id,
|
||||
T2.effective_start,
|
||||
T2.effective_end,
|
||||
T2.type_code,
|
||||
T2.yb_type,
|
||||
T2.condition_flag,
|
||||
T2.price
|
||||
-- 添加更多需要的字段
|
||||
FROM
|
||||
adm_charge_item a
|
||||
LEFT JOIN
|
||||
adm_charge_item_definition T2 ON a.definition_id = T2.ID AND T2.delete_flag = '0'
|
||||
LEFT JOIN
|
||||
med_medication_request b1 ON a.service_id = b1.id AND a.service_table = 'med_medication_request'
|
||||
LEFT JOIN
|
||||
wor_device_request b2 ON a.service_id = b2.id AND a.service_table = 'wor_device_request'
|
||||
LEFT JOIN
|
||||
wor_service_request b3 ON a.service_id = b3.id AND a.service_table = 'wor_service_request'
|
||||
LEFT JOIN
|
||||
adm_healthcare_service b4 ON a.service_id = b4.id AND a.service_table = 'adm_healthcare_service'
|
||||
LEFT JOIN
|
||||
med_medication_definition b6 ON a.product_id = b6.id AND a.product_table = 'med_medication_definition'
|
||||
LEFT JOIN
|
||||
adm_device_definition b7 ON a.product_id = b7.id AND a.product_table = 'adm_device_definition'
|
||||
LEFT JOIN
|
||||
wor_activity_definition b8 ON a.product_id = b8.id AND a.product_table = 'wor_activity_definition'
|
||||
LEFT JOIN
|
||||
adm_charge_item_definition b5 ON a.definition_id = b5.id
|
||||
LEFT JOIN
|
||||
adm_organization org ON a.requesting_org_id = org.id
|
||||
LEFT JOIN
|
||||
adm_practitioner pra ON a.enterer_id = pra.id
|
||||
LEFT JOIN
|
||||
adm_account acc ON a.account_id = acc.id
|
||||
LEFT JOIN
|
||||
fin_contract contract ON acc.contract_no = contract.bus_no
|
||||
WHERE
|
||||
a.delete_flag = '0'
|
||||
AND
|
||||
a.id IN
|
||||
<foreach collection="chargeItemIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getChargeItemDefInfoByIds" resultType="com.openhis.administration.dto.ChargeItemDefInfo">
|
||||
SELECT
|
||||
T1.id,
|
||||
T1.status_enum,
|
||||
T1.generate_source_enum,
|
||||
T1.bus_no,
|
||||
T1.prescription_no,
|
||||
T1.patient_id,
|
||||
T1.context_enum,
|
||||
T1.encounter_id,
|
||||
T1.occurrence_time,
|
||||
T1.performer_id,
|
||||
T1.performing_org_id,
|
||||
T1.requesting_org_id,
|
||||
T1.cost_org_id,
|
||||
T1.quantity_value,
|
||||
T1.quantity_unit,
|
||||
T1.unit_price,
|
||||
T1.total_price,
|
||||
T1.definition_id,
|
||||
T1.def_detail_id,
|
||||
T1.base_amount,
|
||||
T1.discount_amount,
|
||||
T1.surcharge_amount,
|
||||
T1.override_reason_code,
|
||||
T1.override_reason_text,
|
||||
T1.enterer_id,
|
||||
T1.entered_date,
|
||||
T1.service_table,
|
||||
T1.service_id,
|
||||
T1.product_table,
|
||||
T1.product_id,
|
||||
T1.claim_state_enum,
|
||||
T1.print_count,
|
||||
T1.account_id,
|
||||
T1.org_id,
|
||||
T1.refund_id,
|
||||
T1.children_json,
|
||||
T1.condition_id,
|
||||
T1.encounter_diagnosis_id,
|
||||
T1.tcm_flag,
|
||||
T1.create_time,
|
||||
T1.create_by,
|
||||
T1.update_time,
|
||||
T1.update_by,
|
||||
T1.system_discount_price,
|
||||
T1.manual_adjusted_price,
|
||||
T2.charge_name,
|
||||
T2.title,
|
||||
T2.status_enum,
|
||||
T2.org_id,
|
||||
T2.description,
|
||||
T2.instance_table,
|
||||
T2.instance_id,
|
||||
T2.effective_start,
|
||||
T2.effective_end,
|
||||
T2.type_code,
|
||||
T2.yb_type,
|
||||
T2.condition_flag,
|
||||
T2.price
|
||||
FROM
|
||||
adm_charge_item T1
|
||||
LEFT JOIN adm_charge_item_definition T2 ON T1.definition_id = T2.ID
|
||||
AND T2.delete_flag = '0'
|
||||
WHERE
|
||||
T1.id IN
|
||||
<foreach collection="chargeItemIds" item="itemId" open="(" separator="," close=")">
|
||||
#{itemId}
|
||||
</foreach>
|
||||
AND T1.delete_flag = '0'
|
||||
</select>
|
||||
|
||||
<!-- 查询费用明细 -->
|
||||
<select id="getCostDetails" resultType="com.openhis.administration.dto.CostDetailDto">
|
||||
SELECT final_res.charge_name,
|
||||
final_res.charge_item_enum,
|
||||
final_res.unit_price,
|
||||
final_res.quantity_value,
|
||||
final_res.total_price,
|
||||
final_res.org_id,
|
||||
final_res.practitioner,
|
||||
final_res.recorded_time,
|
||||
final_res.chrgitm_lv,
|
||||
final_res.remark,
|
||||
final_res.encounter_id,
|
||||
final_res.patient_id,
|
||||
final_res.patient_name,
|
||||
final_res.birth_date,
|
||||
final_res.gender_enum,
|
||||
final_res.bus_no,
|
||||
final_res.bed_name,
|
||||
final_res.condition_names,
|
||||
final_res.admitting_doctor_name,
|
||||
final_res.balance_amount,
|
||||
final_res.contract_name
|
||||
FROM (WITH execution_table AS (SELECT cp.request_id,
|
||||
cp.org_id,
|
||||
ap.NAME,
|
||||
cp.occurrence_time AS recorded_time
|
||||
FROM cli_procedure cp
|
||||
LEFT JOIN cli_procedure_performer cpp ON cpp.procedure_id = cp.ID
|
||||
AND cpp.delete_flag = '0'
|
||||
LEFT JOIN adm_practitioner ap ON ap.ID = cpp.practitioner_id
|
||||
AND ap.active_flag = 1
|
||||
AND ap.delete_flag = '0'
|
||||
WHERE cp.delete_flag = '0'),
|
||||
diagnosis AS (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),
|
||||
hospitalization AS (SELECT aep.encounter_id,
|
||||
pra.NAME
|
||||
FROM adm_encounter_participant aep
|
||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.ID
|
||||
AND pra.delete_flag = '0'
|
||||
WHERE aep.delete_flag = '0'
|
||||
AND aep.status_enum = #{ active }
|
||||
AND aep.type_code = #{ admittingDoctor }),
|
||||
account AS (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 aci.delete_flag = '0'
|
||||
WHERE aa.type_code = #{ personalCashAccount }
|
||||
AND aa.delete_flag = '0'
|
||||
GROUP BY aa.ID,
|
||||
aa.encounter_id,
|
||||
aa.balance_amount),
|
||||
contract AS (SELECT fc.contract_name, aa.encounter_id
|
||||
FROM adm_account aa
|
||||
LEFT JOIN fin_contract fc ON aa.contract_no = fc.bus_no AND fc.delete_flag = '0'
|
||||
WHERE aa.encounter_flag = 1
|
||||
AND aa.delete_flag = '0')
|
||||
SELECT T1.tenant_id,
|
||||
T2.charge_name,
|
||||
T2.yb_type AS charge_item_enum,
|
||||
T1.unit_price,
|
||||
T1.quantity_value,
|
||||
T1.total_price,
|
||||
T6.org_id,
|
||||
T6.NAME AS practitioner,
|
||||
T6.recorded_time,
|
||||
CASE
|
||||
WHEN T2.instance_table = 'adm_device_definition' THEN
|
||||
T3.chrgitm_lv
|
||||
WHEN T2.instance_table = 'med_medication_definition' THEN
|
||||
T4.chrgitm_lv
|
||||
WHEN T2.instance_table = 'wor_activity_definition' THEN
|
||||
T5.chrgitm_lv
|
||||
ELSE NULL
|
||||
END AS chrgitm_lv,
|
||||
'' AS remark,
|
||||
T1.encounter_id,
|
||||
T1.patient_id,
|
||||
T7.NAME AS patient_name,
|
||||
T7.birth_date,
|
||||
T7.gender_enum,
|
||||
T8.bus_no,
|
||||
T10.NAME AS bed_name,
|
||||
T11.condition_names,
|
||||
T12.NAME AS admitting_doctor_name,
|
||||
T13.balance_amount,
|
||||
T14.contract_name
|
||||
FROM adm_charge_item T1
|
||||
LEFT JOIN adm_charge_item_definition T2 ON T2.ID = T1.definition_id
|
||||
AND T2.delete_flag = '0'
|
||||
LEFT JOIN adm_device_definition T3 ON T2.instance_id = T3.ID
|
||||
AND T2.instance_table = 'adm_device_definition'
|
||||
AND T3.delete_flag = '0'
|
||||
LEFT JOIN med_medication_definition T4 ON T2.instance_id = T4.ID
|
||||
AND T2.instance_table = 'med_medication_definition'
|
||||
AND T4.delete_flag = '0'
|
||||
LEFT JOIN wor_activity_definition T5 ON T2.instance_id = T5.ID
|
||||
AND T2.instance_table = 'wor_activity_definition'
|
||||
AND T5.delete_flag = '0'
|
||||
LEFT JOIN execution_table T6 ON T6.request_id = T1.service_id
|
||||
LEFT JOIN adm_patient T7 ON T7.ID = T1.patient_id
|
||||
AND T7.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter T8 ON T8.ID = T1.encounter_id
|
||||
AND T8.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter_location T9 ON T8.ID = T9.encounter_id
|
||||
AND T9.delete_flag = '0'
|
||||
AND T9.status_enum = #{active}
|
||||
AND T9.form_enum = #{bed}
|
||||
LEFT JOIN adm_location T10 ON T9.location_id = T10.ID
|
||||
AND T10.delete_flag = '0'
|
||||
LEFT JOIN diagnosis T11 ON T1.encounter_id = T11.encounter_id
|
||||
LEFT JOIN hospitalization T12 ON T1.encounter_id = T12.encounter_id
|
||||
LEFT JOIN account T13 ON T1.encounter_id = T13.encounter_id
|
||||
LEFT JOIN contract T14 ON T1.encounter_id = T14.encounter_id
|
||||
WHERE T1.delete_flag = '0'
|
||||
GROUP BY T1.tenant_id,
|
||||
T2.charge_name,
|
||||
T2.yb_type,
|
||||
T1.unit_price,
|
||||
T1.quantity_value,
|
||||
T1.total_price,
|
||||
T6.org_id,
|
||||
T6.NAME,
|
||||
T6.recorded_time,
|
||||
T2.instance_table,
|
||||
T3.chrgitm_lv,
|
||||
T4.chrgitm_lv,
|
||||
T5.chrgitm_lv,
|
||||
T1.encounter_id,
|
||||
T1.patient_id,
|
||||
T7.NAME,
|
||||
T7.birth_date,
|
||||
T7.gender_enum,
|
||||
T8.bus_no,
|
||||
T10.NAME,
|
||||
T11.condition_names,
|
||||
T12.NAME,
|
||||
T13.balance_amount,
|
||||
T14.contract_name
|
||||
ORDER BY T6.recorded_time DESC) final_res
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,33 +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.administration.mapper.DeviceDefinitionMapper">
|
||||
|
||||
<!-- 根据关键字查询 如果关键字为空,查询10条,否则返回查询到的所有 -->
|
||||
<select id="searchDeviceListByKeyWord" resultType="com.openhis.medication.dto.AdjustPriceMedListDto">
|
||||
select df.id as targetId, df.name as name, df.size as volume, details.amount as
|
||||
originRetailPrice,def_details.amount as originBuyingPrice,df.bus_no as busNo,df.min_unit_code as unitCode
|
||||
from adm_device_definition df
|
||||
inner join adm_charge_item_definition actd on actd.instance_id = df.id
|
||||
left join adm_charge_item_def_detail details on actd.id = details.definition_id
|
||||
and details.id = (select cidd.id from adm_charge_item_def_detail cidd where actd.id = cidd.definition_id and
|
||||
cidd.condition_code = '5' and cidd.delete_flag = '0' ORDER BY create_time DESC
|
||||
LIMIT 1)
|
||||
left join adm_charge_item_def_detail def_details on actd.id = def_details.definition_id
|
||||
and def_details.id = (select cidd.id from adm_charge_item_def_detail cidd where actd.id = cidd.definition_id and
|
||||
cidd.condition_code = '1' and cidd.delete_flag = '0' ORDER BY create_time DESC
|
||||
LIMIT 1)
|
||||
WHERE 1 = 1 and df.id in (select inventoty.item_id FROM wor_inventory_item inventoty where
|
||||
inventoty.quantity > 0 and inventoty.delete_flag = '0' )
|
||||
<if test="keyWord == ''">
|
||||
limit 10
|
||||
</if>
|
||||
<if test="keyWord !=''">
|
||||
and
|
||||
(df.name like concat('%',#{keyWord},'%') or df.py_str like concat('%',#{keyWord},'%') or df.wb_str like
|
||||
concat('%',#{keyWord},'%'))
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.DeviceMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,32 +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.administration.mapper.EncounterDiagnosisMapper">
|
||||
|
||||
<delete id="deleteByEncounterId">
|
||||
DELETE
|
||||
FROM adm_encounter_diagnosis
|
||||
WHERE encounter_id = #{encounterId}
|
||||
AND tcm_flag = 0
|
||||
</delete>
|
||||
|
||||
<delete id="deleteTcmByEncounterId">
|
||||
DELETE
|
||||
FROM adm_encounter_diagnosis
|
||||
WHERE encounter_id = #{encounterId}
|
||||
AND tcm_flag = 0
|
||||
</delete>
|
||||
<select id="getEncounterDiagnosisByEncounterConDefId"
|
||||
resultType="com.openhis.administration.domain.EncounterDiagnosis">
|
||||
SELECT *
|
||||
FROM adm_encounter_diagnosis T1
|
||||
INNER JOIN cli_condition T2 ON T1.condition_id = T2.id
|
||||
WHERE T1.encounter_id = #{encounterId}
|
||||
AND T2.definition_id = #{conditionDefId}
|
||||
AND T1.delete_flag = '0'
|
||||
AND T2.delete_flag = '0'
|
||||
AND T1.tenant_id = #{tenantId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,12 +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.administration.mapper.EncounterLocationMapper">
|
||||
|
||||
<select id="searchEncounterDataByLocationId" resultType="com.openhis.administration.dto.PatientBedInfoDto">
|
||||
select encounter_id as encounterId , location_id as bedLocationId
|
||||
from adm_encounter_location where location_id = #{locationId} and status_enum = #{statusEnum} and form_enum = #{formEnum}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,65 +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.administration.mapper.EncounterMapper">
|
||||
|
||||
<select id="getEncounterInfoByTime" resultType="com.openhis.administration.dto.EncounterAccountDto">
|
||||
SELECT T1.ID,
|
||||
T1.patient_id,
|
||||
T1.group_id,
|
||||
T1.bus_no,
|
||||
T1.status_enum,
|
||||
T1.class_enum,
|
||||
T1.yb_class_enum,
|
||||
T1.yb_class_text,
|
||||
T1.class_json,
|
||||
T1.priority_enum,
|
||||
T1.type_enum,
|
||||
T1.service_type_id,
|
||||
T1.subject_status_enum,
|
||||
T1.start_time,
|
||||
T1.end_time,
|
||||
T1.reception_time,
|
||||
T1.organization_id,
|
||||
T1.display_order,
|
||||
T1.first_enum,
|
||||
T1.admit_source_code,
|
||||
T1.in_way_code,
|
||||
T1.amb_encounter_id,
|
||||
T1.registrar_id,
|
||||
T2.status_enum,
|
||||
T2.billing_status_enum,
|
||||
T2.type_code,
|
||||
T2.NO,
|
||||
T2.NAME,
|
||||
T2.patient_id,
|
||||
T2.encounter_id,
|
||||
T2.balance_amount,
|
||||
T2.yb_area_no,
|
||||
T2.contract_no,
|
||||
T2.limit_account,
|
||||
T2.encounter_flag
|
||||
FROM adm_encounter T1
|
||||
LEFT JOIN adm_account T2 ON T1.ID = T2.encounter_id
|
||||
AND T2.encounter_flag = 1
|
||||
AND T2.delete_flag = '0'
|
||||
WHERE T1.create_time >
|
||||
#{startDate}
|
||||
AND T1.create_time <
|
||||
#{endDate};
|
||||
</select>
|
||||
|
||||
<select id="searchEncounterDataByIds" resultType="com.openhis.administration.dto.EncounterDataDto">
|
||||
select * from adm_encounter
|
||||
where (class_enum = #{imp} or class_enum = #{amb}) and status_enum = #{encounterStatus}
|
||||
and id in
|
||||
<foreach collection="encounterIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getPatientIdByParam" resultType="com.openhis.administration.dto.EncounterDataDto">
|
||||
select patient_id as patientId,id as encounterId
|
||||
from adm_encounter encounter where id = #{encounterId} and class_enum = #{classEnum}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.EncounterParticipantMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.EncounterReasonMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,42 +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.administration.mapper.FrequencyMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.openhis.administration.domain.Frequency">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="rateCode" column="rate_code" jdbcType="VARCHAR"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="dayCount" column="day_count" jdbcType="INTEGER"/>
|
||||
<result property="dayInterval" column="day_interval" jdbcType="INTEGER"/>
|
||||
<result property="dayTimes" column="day_times" jdbcType="VARCHAR"/>
|
||||
<result property="weekCycleFlag" column="week_cycle_flag" jdbcType="INTEGER"/>
|
||||
<result property="weekInterval" column="week_interval" jdbcType="INTEGER"/>
|
||||
<result property="weekTimes" column="week_times" jdbcType="INTEGER"/>
|
||||
<result property="continueFlag" column="continue_flag" jdbcType="INTEGER"/>
|
||||
<result property="totalExecutionCount" column="total_execution_count" jdbcType="INTEGER"/>
|
||||
<result property="executionPeriod" column="execution_period" jdbcType="INTEGER"/>
|
||||
<result property="executionPeriodUnit" column="execution_period_unit" jdbcType="VARCHAR"/>
|
||||
<result property="thirdCode" column="third_code" jdbcType="VARCHAR"/>
|
||||
<result property="memo" column="memo" jdbcType="VARCHAR"/>
|
||||
<result property="concurrencyStamp" column="concurrency_stamp" jdbcType="INTEGER"/>
|
||||
<result property="tenantId" column="tenant_id" jdbcType="BIGINT"/>
|
||||
<result property="deleteFlag" column="delete_flag" jdbcType="CHAR"/>
|
||||
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,rate_code,name,
|
||||
day_count,day_interval,day_times,
|
||||
week_cycle_flag,week_interval,week_times,
|
||||
continue_flag,total_execution_count,execution_period,
|
||||
execution_period_unit,third_code,memo,
|
||||
concurrency_stamp,tenant_id,delete_flag,
|
||||
create_by,create_time,update_by,
|
||||
update_time
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -1,27 +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.administration.mapper.HealthcareServiceMapper">
|
||||
|
||||
<select id="searchHealthByIds" resultType="com.openhis.administration.dto.HealthcareDto">
|
||||
<!-- 根据项目id数组 加载挂号集合 -->
|
||||
SELECT
|
||||
health.id as itemId,
|
||||
health.offered_org_id as orgId,health.name as name,health.category_code as categoryCode,health.type_code as
|
||||
typeCode
|
||||
FROM adm_healthcare_service as health
|
||||
WHERE health.ID IN
|
||||
<foreach collection="itemIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
<!-- 查询所有 挂号数据 -->
|
||||
<select id="searchAllHeathData" resultType="com.openhis.medication.dto.AdjustPriceMedListDto">
|
||||
SELECT heal.id AS targetId,heal.name AS name,cid.price AS originRetailPrice,org.name as orgName
|
||||
FROM public.adm_healthcare_service heal
|
||||
INNER JOIN adm_charge_item_definition cid ON heal.id = cid.instance_id
|
||||
INNER JOIN adm_organization org ON heal.offered_org_id = org.id
|
||||
WHERE heal.delete_flag = '0' AND heal.offered_org_id = #{orgId} AND cid.status_enum = #{statusEnum}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.InstrumentMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.InvoiceMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,52 +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.administration.mapper.LocationMapper">
|
||||
|
||||
<!-- 根据区域id数组查询 区域表 -->
|
||||
<select id="searchLocationDataByIds" resultType="com.openhis.administration.dto.LocationDataDto">
|
||||
select id as locationId,
|
||||
bus_no as busNo,
|
||||
name as areaName,
|
||||
status_enum as statusEnum,
|
||||
mode_enum as modeEnum,
|
||||
operational_enum as operationalEnum
|
||||
from adm_location
|
||||
where delete_flag = '0'
|
||||
and id in
|
||||
<foreach collection="locationIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 根据区域id数组查询 区域表 -->
|
||||
<select id="searchLocationDataByBusNo" resultType="com.openhis.administration.dto.PatientBedInfoDto">
|
||||
select id as bedLocationId,
|
||||
bus_no as busNo,
|
||||
name as bedName,
|
||||
status_enum as statusEnum,
|
||||
mode_enum as modeEnum,
|
||||
operational_enum as operationalEnum
|
||||
from adm_location
|
||||
where delete_flag = '0'
|
||||
and bus_no like concat(#{busNo}, '%')
|
||||
and form_enum = #{formEnum}
|
||||
and status_enum = #{statusEnum}
|
||||
</select>
|
||||
|
||||
<select id="isExistName" resultType="java.lang.Boolean">
|
||||
SELECT EXISTS (SELECT 1
|
||||
FROM adm_location
|
||||
WHERE REPLACE(REPLACE(name, ' ', ''), ' ', '') = #{name}
|
||||
<if test="locId != null">
|
||||
AND id != #{locId}
|
||||
</if>
|
||||
<if test="busNo != null">
|
||||
AND bus_no like CONCAT(#{busNo}, '%')
|
||||
</if>
|
||||
AND delete_flag = #{delFlag}) AS exists_flag;
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.ObservationDefinitionMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.OrgContrastMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.OrganizationLocationMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,67 +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.administration.mapper.OrganizationMapper">
|
||||
|
||||
<select id="searchOrgDataByHealth" resultType="com.openhis.administration.dto.OrgDataDto">
|
||||
SELECT org.id AS orgId, org.name AS orgName
|
||||
FROM adm_organization AS org
|
||||
WHERE id IN
|
||||
(SELECT offered_org_id
|
||||
FROM adm_healthcare_service heal
|
||||
WHERE heal.delete_flag = '0'
|
||||
GROUP BY heal.offered_org_id)
|
||||
</select>
|
||||
|
||||
<!-- 分页查询挂号科室列表,关联租户表获取租户名称 -->
|
||||
<select id="selectRegisterOrganizationsWithTenant" resultType="com.openhis.administration.domain.Organization">
|
||||
SELECT
|
||||
org.id,
|
||||
org.bus_no,
|
||||
org.name,
|
||||
org.active_flag,
|
||||
org.type_enum,
|
||||
org.class_enum,
|
||||
org.py_str,
|
||||
org.wb_str,
|
||||
org.yb_no,
|
||||
org.yb_name,
|
||||
org.caty,
|
||||
org.display_order,
|
||||
org.medins_id,
|
||||
org.medins_admdvs,
|
||||
org.medins_type,
|
||||
org.medins_lv,
|
||||
org.def_doctor_id,
|
||||
org.register_flag,
|
||||
org.location,
|
||||
org.intro,
|
||||
org.remark,
|
||||
org.tenant_id,
|
||||
org.delete_flag,
|
||||
org.create_by,
|
||||
org.create_time,
|
||||
org.update_by,
|
||||
org.update_time,
|
||||
st.tenant_name AS tenantName
|
||||
FROM adm_organization org
|
||||
LEFT JOIN sys_tenant st ON org.tenant_id = st.id
|
||||
<where>
|
||||
<if test="registerFlag != null">
|
||||
AND org.register_flag = #{registerFlag}
|
||||
</if>
|
||||
<if test="deleteFlag != null">
|
||||
AND org.delete_flag = #{deleteFlag}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND org.name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="orgName != null and orgName != ''">
|
||||
AND st.tenant_name = #{orgName}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY org.bus_no ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.PatientIdentifierMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,12 +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.administration.mapper.PatientMapper">
|
||||
|
||||
<select id="searchPatientDataByPatientId" resultType="com.openhis.administration.dto.PatientDataDto">
|
||||
select id as patientId,name as patientName,gender_enum as gender,id_card as idCard from adm_patient
|
||||
where delete_flag = '0' and id = #{patientId} and active_flag = #{activeFlag}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.PatientStudentMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.PractitionerMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,111 +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.administration.mapper.PractitionerPatientMapper">
|
||||
|
||||
<resultMap type="com.openhis.administration.domain.PractitionerPatient" id="PractitionerPatientResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="practitionerId" column="practitioner_id" />
|
||||
<result property="patientId" column="patient_id" />
|
||||
<result property="relationshipType" column="relationship_type" />
|
||||
<result property="organizationId" column="organization_id" />
|
||||
<result property="startDate" column="start_date" />
|
||||
<result property="endDate" column="end_date" />
|
||||
<result property="status" column="status" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="tenantId" column="tenant_id" />
|
||||
<result property="deleteFlag" column="delete_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPractitionerPatientVo">
|
||||
select id, practitioner_id, patient_id, relationship_type, organization_id,
|
||||
start_date, end_date, status, remark, tenant_id,
|
||||
delete_flag, create_by, create_time, update_by, update_time
|
||||
from adm_practitioner_patient
|
||||
</sql>
|
||||
|
||||
<select id="selectPractitionerPatientList" parameterType="com.openhis.administration.domain.PractitionerPatient" resultMap="PractitionerPatientResult">
|
||||
<include refid="selectPractitionerPatientVo"/>
|
||||
<where>
|
||||
delete_flag = '0'
|
||||
<if test="practitionerId != null">
|
||||
and practitioner_id = #{practitionerId}
|
||||
</if>
|
||||
<if test="patientId != null">
|
||||
and patient_id = #{patientId}
|
||||
</if>
|
||||
<if test="relationshipType != null">
|
||||
and relationship_type = #{relationshipType}
|
||||
</if>
|
||||
<if test="organizationId != null">
|
||||
and organization_id = #{organizationId}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectPractitionerPatientById" parameterType="Long" resultMap="PractitionerPatientResult">
|
||||
<include refid="selectPractitionerPatientVo"/>
|
||||
where id = #{id} and delete_flag = '0'
|
||||
</select>
|
||||
|
||||
<!-- 获取医生的所有有效患者(带详细信息) -->
|
||||
<select id="getValidPatientsByPractitionerWithDetail" parameterType="Long" resultType="java.util.Map">
|
||||
SELECT
|
||||
pp.id as relationship_id,
|
||||
pp.practitioner_id,
|
||||
pp.patient_id,
|
||||
pp.relationship_type,
|
||||
pp.start_date,
|
||||
pp.end_date,
|
||||
pp.status,
|
||||
pp.remark,
|
||||
pt.name as patient_name,
|
||||
pt.bus_no as patient_bus_no,
|
||||
pt.gender_enum as patient_gender,
|
||||
pt.phone as patient_phone,
|
||||
pt.id_card as patient_id_card,
|
||||
pt.birth_date as patient_birth_date
|
||||
FROM adm_practitioner_patient pp
|
||||
LEFT JOIN adm_patient pt ON pp.patient_id = pt.ID AND pt.delete_flag = '0'
|
||||
WHERE pp.practitioner_id = #{practitionerId}
|
||||
AND pp.status = 1
|
||||
AND pp.delete_flag = '0'
|
||||
ORDER BY pp.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 获取患者的所有有效医生(带详细信息) -->
|
||||
<select id="getValidPractitionersByPatientWithDetail" parameterType="Long" resultType="java.util.Map">
|
||||
SELECT
|
||||
pp.id as relationship_id,
|
||||
pp.practitioner_id,
|
||||
pp.patient_id,
|
||||
pp.relationship_type,
|
||||
pp.start_date,
|
||||
pp.end_date,
|
||||
pp.status,
|
||||
pp.remark,
|
||||
prac.name as practitioner_name,
|
||||
prac.bus_no as practitioner_bus_no,
|
||||
prac.gender_enum as practitioner_gender,
|
||||
prac.phone as practitioner_phone,
|
||||
prac.dr_profttl_code as practitioner_title,
|
||||
org.name as organization_name
|
||||
FROM adm_practitioner_patient pp
|
||||
LEFT JOIN adm_practitioner prac ON pp.practitioner_id = prac.ID AND prac.delete_flag = '0'
|
||||
LEFT JOIN adm_organization org ON pp.organization_id = org.ID AND org.delete_flag = '0'
|
||||
WHERE pp.patient_id = #{patientId}
|
||||
AND pp.status = 1
|
||||
AND pp.delete_flag = '0'
|
||||
ORDER BY pp.relationship_type, pp.create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,53 +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.administration.mapper.PractitionerRoleMapper">
|
||||
<!-- 根据员工ID 查询权限数据集 -->
|
||||
<select id="searchPractitionerRoleByPractitionerId" resultType="com.openhis.administration.dto.RoleDataDto">
|
||||
select id as roleId,org_id as orgId,location_id as locationId,specialty_enum as specialtyEnum,type_code as
|
||||
typeCode
|
||||
from adm_practitioner_role
|
||||
where delete_flag = '0'
|
||||
<if test="practitionerId != null and practitionerId!= ''">
|
||||
and practitioner_id = #{practitionerId}
|
||||
</if>
|
||||
<if test="roleCode != null and roleCode!= ''">
|
||||
and role_code = #{roleCode}
|
||||
</if>
|
||||
and location_id is not null order by id desc
|
||||
</select>
|
||||
|
||||
<!-- 根据员工ID数组 查询权限数据集 -->
|
||||
<select id="searchPractitionerRoleByPractitionerIds" resultType="com.openhis.administration.dto.RoleDataDto">
|
||||
select id as roleId,org_id as orgId,location_id as locationId,specialty_enum as specialtyEnum,type_code as
|
||||
typeCode
|
||||
from adm_practitioner_role
|
||||
where delete_flag = '0'
|
||||
<if test="practitionerId != null and practitionerId!= ''">
|
||||
and practitioner_id in
|
||||
<foreach collection="practitionerIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="roleCode != null and roleCode!= ''">
|
||||
and role_code = #{roleCode}
|
||||
</if>
|
||||
and location_id is not null order by id desc
|
||||
</select>
|
||||
|
||||
<!-- 根据员工ID 查询位置ID数组 -->
|
||||
<select id="searchPractitionerRoleLocationIds" resultType="java.lang.Long">
|
||||
select location_id as locationId
|
||||
from adm_practitioner_role
|
||||
where delete_flag = '0'
|
||||
<if test="practitionerId != null and practitionerId!= ''">
|
||||
and practitioner_id = #{practitionerId}
|
||||
</if>
|
||||
<if test="roleCode != null and roleCode!= ''">
|
||||
and role_code = #{roleCode}
|
||||
</if>
|
||||
and location_id is not null order by id desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,461 +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.appointmentmanage.mapper.ScheduleSlotMapper">
|
||||
|
||||
<!--
|
||||
统一状态值映射: DB 数值 → 规范化输出
|
||||
0=待约 1=已约(签到后) 2=锁定(预约后) 3=已签到 4=已停诊 5=已退号
|
||||
-->
|
||||
<sql id="slotStatusNormExpr">
|
||||
CASE
|
||||
WHEN LOWER(CONCAT('', s.status)) IN ('0', 'unbooked', 'available') THEN 0
|
||||
WHEN LOWER(CONCAT('', s.status)) IN ('1', 'booked') THEN 1
|
||||
WHEN LOWER(CONCAT('', s.status)) IN ('2', 'locked') THEN 2
|
||||
WHEN LOWER(CONCAT('', s.status)) IN ('3', 'checked', 'checked_in', 'checkin') THEN 3
|
||||
WHEN LOWER(CONCAT('', s.status)) IN ('4', 'cancelled', 'canceled', 'stopped') THEN 4
|
||||
WHEN LOWER(CONCAT('', s.status)) IN ('5', 'returned') THEN 5
|
||||
ELSE NULL
|
||||
END
|
||||
</sql>
|
||||
|
||||
<sql id="orderStatusNormExpr">
|
||||
CASE
|
||||
WHEN LOWER(CONCAT('', o.status)) IN ('1', 'booked') THEN 1
|
||||
WHEN LOWER(CONCAT('', o.status)) IN ('2', 'checked', 'checked_in', 'checkin') THEN 2
|
||||
WHEN LOWER(CONCAT('', o.status)) IN ('3', 'cancelled', 'canceled') THEN 3
|
||||
WHEN LOWER(CONCAT('', o.status)) IN ('4', 'returned') THEN 4
|
||||
ELSE NULL
|
||||
END
|
||||
</sql>
|
||||
|
||||
<sql id="poolStatusNormExpr">
|
||||
CASE
|
||||
WHEN LOWER(CONCAT('', p.status)) IN ('0', 'unbooked', 'available') THEN 0
|
||||
WHEN LOWER(CONCAT('', p.status)) IN ('1', 'booked') THEN 1
|
||||
WHEN LOWER(CONCAT('', p.status)) IN ('2', 'locked') THEN 2
|
||||
WHEN LOWER(CONCAT('', p.status)) IN ('3', 'checked', 'checked_in', 'checkin') THEN 3
|
||||
WHEN LOWER(CONCAT('', p.status)) IN ('4', 'cancelled', 'canceled', 'stopped') THEN 4
|
||||
WHEN LOWER(CONCAT('', p.status)) IN ('5', 'returned') THEN 5
|
||||
ELSE NULL
|
||||
END
|
||||
</sql>
|
||||
|
||||
<!-- 注意这里的 resultType 指向了您刚建好的 DTO 实体类 -->
|
||||
<select id="selectAllTicketSlots" resultType="com.openhis.appointmentmanage.domain.TicketSlotDTO">
|
||||
SELECT
|
||||
s.id AS slotId,
|
||||
s.seq_no AS seqNo,
|
||||
p.schedule_id AS scheduleId,
|
||||
p.doctor_name AS doctor,
|
||||
p.dept_id AS departmentId,
|
||||
p.fee AS fee,
|
||||
o.patient_id AS patientId,
|
||||
o.patient_name AS patientName,
|
||||
o.medical_card AS medicalCard,
|
||||
o.phone AS phone,
|
||||
<include refid="orderStatusNormExpr" /> AS orderStatus,
|
||||
<include refid="slotStatusNormExpr" /> AS slotStatus,
|
||||
s.expect_time AS expectTime,
|
||||
p.schedule_date AS scheduleDate,
|
||||
d.reg_type AS regType,
|
||||
<include refid="poolStatusNormExpr" /> AS poolStatus,
|
||||
p.stop_reason AS stopReason,
|
||||
d.is_stopped AS isStopped
|
||||
FROM
|
||||
adm_schedule_slot s
|
||||
INNER JOIN adm_schedule_pool p ON s.pool_id = p.id
|
||||
LEFT JOIN adm_doctor_schedule d ON p.schedule_id = d.id
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT
|
||||
ON (slot_id) slot_id,
|
||||
patient_id,
|
||||
patient_name,
|
||||
medical_card,
|
||||
phone,
|
||||
status
|
||||
FROM
|
||||
order_main
|
||||
WHERE
|
||||
LOWER(CONCAT('', status)) IN ('1', '2', '4', 'booked', 'checked', 'checked_in', 'checkin', 'returned')
|
||||
ORDER BY
|
||||
slot_id,
|
||||
create_time DESC
|
||||
) o ON o.slot_id = s.id
|
||||
WHERE
|
||||
p.delete_flag = '0'
|
||||
AND s.delete_flag = '0'
|
||||
ORDER BY
|
||||
p.schedule_date,
|
||||
p.doctor_id,
|
||||
s.expect_time,
|
||||
s.seq_no ASC
|
||||
</select>
|
||||
|
||||
<select id="selectTicketSlotById" resultType="com.openhis.appointmentmanage.domain.TicketSlotDTO">
|
||||
SELECT
|
||||
s.id AS slotId,
|
||||
s.seq_no AS seqNo,
|
||||
p.schedule_id AS scheduleId,
|
||||
p.doctor_name AS doctor,
|
||||
p.doctor_id AS doctorId,
|
||||
p.dept_id AS departmentId,
|
||||
org.name AS departmentName,
|
||||
p.fee AS fee,
|
||||
o.patient_id AS patientId,
|
||||
o.patient_name AS patientName,
|
||||
o.medical_card AS medicalCard,
|
||||
o.phone AS phone,
|
||||
o.id AS orderId,
|
||||
o.order_no AS orderNo,
|
||||
COALESCE(CAST(o.gender AS VARCHAR), CAST(pinfo.gender_enum AS VARCHAR)) AS patientGender,
|
||||
pinfo.gender_enum AS genderEnum,
|
||||
pinfo.id_card AS idCard,
|
||||
o.appointment_time AS appointmentTime,
|
||||
<include refid="orderStatusNormExpr" /> AS orderStatus,
|
||||
<include refid="slotStatusNormExpr" /> AS slotStatus,
|
||||
s.expect_time AS expectTime,
|
||||
p.schedule_date AS scheduleDate,
|
||||
d.reg_type AS regType,
|
||||
<include refid="poolStatusNormExpr" /> AS poolStatus,
|
||||
p.stop_reason AS stopReason,
|
||||
d.is_stopped AS isStopped
|
||||
FROM
|
||||
adm_schedule_slot s
|
||||
INNER JOIN adm_schedule_pool p ON s.pool_id = p.id
|
||||
LEFT JOIN adm_doctor_schedule d ON p.schedule_id = d.id
|
||||
LEFT JOIN adm_organization org ON p.dept_id = org.id
|
||||
AND org.delete_flag = '0'
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT
|
||||
ON (slot_id) slot_id,
|
||||
patient_id,
|
||||
patient_name,
|
||||
medical_card,
|
||||
phone,
|
||||
id,
|
||||
order_no,
|
||||
gender,
|
||||
appointment_time,
|
||||
status
|
||||
FROM
|
||||
order_main
|
||||
WHERE
|
||||
LOWER(CONCAT('', status)) IN ('1', '2', '4', 'booked', 'checked', 'checked_in', 'checkin', 'returned')
|
||||
ORDER BY
|
||||
slot_id,
|
||||
create_time DESC
|
||||
) o ON o.slot_id = s.id
|
||||
LEFT JOIN adm_patient pinfo ON o.patient_id = pinfo.id
|
||||
WHERE
|
||||
s.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 预约锁定: 0→#{lockedStatus} (AVAILABLE→LOCKED),由枚举传入 -->
|
||||
<update id="lockSlotForBooking">
|
||||
UPDATE adm_schedule_slot
|
||||
SET
|
||||
status = #{lockedStatus},
|
||||
update_time = now()
|
||||
WHERE
|
||||
id = #{slotId}
|
||||
AND status = 0
|
||||
AND delete_flag = '0'
|
||||
</update>
|
||||
|
||||
<!-- status=0(待约)时清空order_id,释放号源,使退号后号源可再被预约 -->
|
||||
<update id="updateSlotStatus">
|
||||
UPDATE adm_schedule_slot
|
||||
SET
|
||||
status = #{status},
|
||||
<if test="status != null and status == 0">
|
||||
order_id = NULL,
|
||||
</if>
|
||||
update_time = now()
|
||||
WHERE
|
||||
id = #{slotId}
|
||||
AND delete_flag = '0'
|
||||
</update>
|
||||
|
||||
<!-- 签到: #{requiredStatus}→#{status} (LOCKED→BOOKED),前置条件由枚举传入 -->
|
||||
<update id="updateSlotStatusAndCheckInTime">
|
||||
UPDATE adm_schedule_slot
|
||||
SET
|
||||
status = #{status},
|
||||
check_in_time = #{checkInTime},
|
||||
update_time = NOW()
|
||||
WHERE
|
||||
id = #{slotId}
|
||||
AND status = #{requiredStatus}
|
||||
AND delete_flag = '0'
|
||||
</update>
|
||||
|
||||
<select id="selectPoolIdBySlotId" resultType="java.lang.Long">
|
||||
SELECT
|
||||
pool_id
|
||||
FROM
|
||||
adm_schedule_slot
|
||||
WHERE
|
||||
id = #{slotId}
|
||||
AND delete_flag = '0'
|
||||
</select>
|
||||
|
||||
<update id="bindOrderToSlot">
|
||||
UPDATE adm_schedule_slot
|
||||
SET
|
||||
order_id = #{orderId},
|
||||
update_time = now()
|
||||
WHERE
|
||||
id = #{slotId}
|
||||
AND status = 2
|
||||
AND delete_flag = '0'
|
||||
</update>
|
||||
|
||||
<select id="selectTicketSlotsPage" resultType="com.openhis.appointmentmanage.domain.TicketSlotDTO">
|
||||
SELECT
|
||||
s.id AS slotId,
|
||||
s.seq_no AS seqNo,
|
||||
p.schedule_id AS scheduleId,
|
||||
p.doctor_name AS doctor,
|
||||
p.doctor_id AS doctorId,
|
||||
p.dept_id AS departmentId,
|
||||
org.name AS departmentName,
|
||||
p.fee AS fee,
|
||||
o.patient_id AS patientId,
|
||||
o.patient_name AS patientName,
|
||||
o.medical_card AS medicalCard,
|
||||
o.phone AS phone,
|
||||
o.id AS orderId,
|
||||
o.order_no AS orderNo,
|
||||
COALESCE(CAST(o.gender AS VARCHAR), CAST(pinfo.gender_enum AS VARCHAR)) AS patientGender,
|
||||
pinfo.gender_enum AS genderEnum,
|
||||
pinfo.id_card AS idCard,
|
||||
o.appointment_time AS appointmentTime,
|
||||
<include refid="orderStatusNormExpr" /> AS orderStatus,
|
||||
<include refid="slotStatusNormExpr" /> AS slotStatus,
|
||||
s.expect_time AS expectTime,
|
||||
p.schedule_date AS scheduleDate,
|
||||
d.reg_type AS regType,
|
||||
<include refid="poolStatusNormExpr" /> AS poolStatus,
|
||||
p.stop_reason AS stopReason,
|
||||
d.is_stopped AS isStopped
|
||||
FROM
|
||||
adm_schedule_slot s
|
||||
INNER JOIN adm_schedule_pool p ON s.pool_id = p.id
|
||||
LEFT JOIN adm_doctor_schedule d ON p.schedule_id = d.id
|
||||
LEFT JOIN adm_organization org ON p.dept_id = org.id
|
||||
AND org.delete_flag = '0'
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT
|
||||
ON (slot_id) slot_id,
|
||||
patient_id,
|
||||
patient_name,
|
||||
medical_card,
|
||||
phone,
|
||||
id,
|
||||
order_no,
|
||||
gender,
|
||||
appointment_time,
|
||||
status
|
||||
FROM
|
||||
order_main
|
||||
WHERE
|
||||
LOWER(CONCAT('', status)) IN ('1', '2', '4', 'booked', 'checked', 'checked_in', 'checkin', 'returned')
|
||||
ORDER BY
|
||||
slot_id,
|
||||
create_time DESC
|
||||
) o ON o.slot_id = s.id
|
||||
LEFT JOIN adm_patient pinfo ON o.patient_id = pinfo.id
|
||||
<where>
|
||||
p.delete_flag = '0'
|
||||
AND s.delete_flag = '0'
|
||||
<!-- 1. 按日期查 -->
|
||||
<if test="query.date != null and query.date != ''">
|
||||
AND p.schedule_date = CAST(#{query.date} AS DATE)
|
||||
</if>
|
||||
<!-- 2. 按科室查 -->
|
||||
<if test="query.department != null and query.department != '' and query.department != 'all'">
|
||||
AND org.name = #{query.department}
|
||||
</if>
|
||||
<if test="query.doctorId != null">
|
||||
AND p.doctor_id = #{query.doctorId}
|
||||
</if>
|
||||
<!-- 3. 按号源类型查 (专家/普通) -->
|
||||
<if test="query.type != null and query.type != ''">
|
||||
<choose>
|
||||
<when test="query.type == 'expert'">
|
||||
AND d.reg_type = 1
|
||||
</when>
|
||||
<when test="query.type == 'general'">
|
||||
AND (
|
||||
d.reg_type != 1
|
||||
OR d.reg_type IS NULL
|
||||
)
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
<!-- 4. 模糊搜索患者信息 -->
|
||||
<if test="query.name != null and query.name != ''">
|
||||
AND o.patient_name LIKE CONCAT('%', #{query.name}, '%')
|
||||
</if>
|
||||
<if test="query.card != null and query.card != ''">
|
||||
AND o.medical_card LIKE CONCAT('%', #{query.card}, '%')
|
||||
</if>
|
||||
<if test="query.phone != null and query.phone != ''">
|
||||
AND o.phone LIKE CONCAT('%', #{query.phone}, '%')
|
||||
</if>
|
||||
<!-- 5. 时间过滤: 仅待约(0)受时间限制,已锁定(2)/已约(1)/已签到(3)/已退号(5)不受影响 -->
|
||||
AND (
|
||||
(<include refid="slotStatusNormExpr" /> = 0 AND (p.schedule_date > CURRENT_DATE OR (p.schedule_date = CURRENT_DATE AND (CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME)) >= NOW())))
|
||||
OR <include refid="slotStatusNormExpr" /> = 1
|
||||
OR <include refid="slotStatusNormExpr" /> = 2
|
||||
OR <include refid="slotStatusNormExpr" /> = 3
|
||||
OR <include refid="slotStatusNormExpr" /> = 5
|
||||
OR <include refid="orderStatusNormExpr" /> = 4
|
||||
)
|
||||
<!-- 6. 状态筛选: unbooked(0) locked(2) booked(2) checked(1) cancelled(4) returned(5) -->
|
||||
<if test="query.status != null and query.status != '' and query.status != 'all'">
|
||||
<choose>
|
||||
<when test="'unbooked'.equals(query.status) or '未预约'.equals(query.status)">
|
||||
AND <include refid="slotStatusNormExpr" /> = 0
|
||||
AND (
|
||||
d.is_stopped IS NULL
|
||||
OR d.is_stopped = FALSE
|
||||
)
|
||||
</when>
|
||||
<when test="'booked'.equals(query.status) or '已预约'.equals(query.status)">
|
||||
AND <include refid="slotStatusNormExpr" /> = 2
|
||||
AND <include refid="orderStatusNormExpr" /> = 1
|
||||
AND (
|
||||
d.is_stopped IS NULL
|
||||
OR d.is_stopped = FALSE
|
||||
)
|
||||
</when>
|
||||
<when test="'locked'.equals(query.status) or '已锁定'.equals(query.status)">
|
||||
AND <include refid="slotStatusNormExpr" /> = 2
|
||||
AND <include refid="orderStatusNormExpr" /> = 1
|
||||
AND (
|
||||
d.is_stopped IS NULL
|
||||
OR d.is_stopped = FALSE
|
||||
)
|
||||
</when>
|
||||
<when test="'checked'.equals(query.status) or '已取号'.equals(query.status)">
|
||||
AND <include refid="slotStatusNormExpr" /> = 1
|
||||
AND (
|
||||
d.is_stopped IS NULL
|
||||
OR d.is_stopped = FALSE
|
||||
)
|
||||
</when>
|
||||
<when test="'cancelled'.equals(query.status) or '已停诊'.equals(query.status) or '已取消'.equals(query.status)">
|
||||
AND (
|
||||
<include refid="slotStatusNormExpr" /> = 4
|
||||
OR d.is_stopped = TRUE
|
||||
)
|
||||
</when>
|
||||
<when test="'returned'.equals(query.status) or '已退号'.equals(query.status)">
|
||||
AND (
|
||||
<include refid="slotStatusNormExpr" /> = 5
|
||||
OR <include refid="orderStatusNormExpr" /> = 4
|
||||
)
|
||||
</when>
|
||||
<otherwise>
|
||||
AND 1 = 2
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY
|
||||
p.schedule_date DESC,
|
||||
s.expect_time ASC,
|
||||
s.seq_no ASC
|
||||
</select>
|
||||
|
||||
<select id="selectDoctorAvailabilitySummary" resultType="com.openhis.appointmentmanage.domain.DoctorAvailabilityDTO">
|
||||
SELECT
|
||||
p.doctor_id AS doctorId,
|
||||
p.doctor_name AS doctorName,
|
||||
p.schedule_date AS scheduleDate,
|
||||
<!-- 直接 COUNT 未预约的号源,前端已经做了时间过滤,这里只按日期统计 -->
|
||||
COUNT(
|
||||
CASE
|
||||
WHEN s.delete_flag = '0'
|
||||
AND <include refid="slotStatusNormExpr" /> = 0
|
||||
<!-- 使用前端传来的当前时间戳过滤过期号源,保证和前端完全一致 -->
|
||||
AND (
|
||||
p.schedule_date > CURRENT_DATE
|
||||
OR (
|
||||
p.schedule_date = CURRENT_DATE
|
||||
AND (CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME)) >= NOW()
|
||||
)
|
||||
)
|
||||
THEN s.id
|
||||
ELSE NULL
|
||||
END
|
||||
) AS available,
|
||||
COUNT(DISTINCT p.id) AS poolCount,
|
||||
CASE
|
||||
WHEN MAX(
|
||||
CASE
|
||||
WHEN d.reg_type = 1 THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
) = 1 THEN 'expert'
|
||||
ELSE 'general'
|
||||
END AS ticketType
|
||||
FROM
|
||||
adm_schedule_pool p
|
||||
LEFT JOIN adm_doctor_schedule d ON p.schedule_id = d.id
|
||||
LEFT JOIN adm_organization org ON p.dept_id = org.id AND org.delete_flag = '0'
|
||||
LEFT JOIN adm_schedule_slot s ON s.pool_id = p.id AND s.delete_flag = '0'
|
||||
<where>
|
||||
p.delete_flag = '0'
|
||||
<!-- 排除医生已停诊的号源 -->
|
||||
AND (d.is_stopped IS NULL OR d.is_stopped = FALSE)
|
||||
<!-- 过滤未来号源:只统计当前日期及未来日期的号源 -->
|
||||
<if test="query.date != null and query.date != ''">
|
||||
AND p.schedule_date = CAST(#{query.date} AS DATE)
|
||||
</if>
|
||||
<!-- 增加时间过滤:排除已过去的就诊日期 -->
|
||||
AND (p.schedule_date > CURRENT_DATE OR (p.schedule_date = CURRENT_DATE AND (CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME)) >= NOW()))
|
||||
<if test="query.department != null and query.department != '' and query.department != 'all'">
|
||||
AND org.name = #{query.department}
|
||||
</if>
|
||||
<if test="query.type != null and query.type != '' and query.type != 'all'">
|
||||
<choose>
|
||||
<when test="query.type == 'expert'">
|
||||
AND d.reg_type = 1
|
||||
</when>
|
||||
<when test="query.type == 'general'">
|
||||
AND (
|
||||
d.reg_type != 1
|
||||
OR d.reg_type IS NULL
|
||||
)
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
<if test="query.doctorId != null">
|
||||
AND p.doctor_id = #{query.doctorId}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY
|
||||
p.doctor_id,
|
||||
p.doctor_name,
|
||||
p.schedule_date
|
||||
ORDER BY
|
||||
p.schedule_date ASC,
|
||||
p.doctor_name ASC
|
||||
</select>
|
||||
|
||||
<select id="selectSeqNoBySlotIds" resultType="com.openhis.appointmentmanage.domain.ScheduleSlot">
|
||||
SELECT id, seq_no
|
||||
FROM adm_schedule_slot
|
||||
WHERE id IN
|
||||
<foreach collection="slotIds" item="slotId" open="(" separator="," close=")">
|
||||
#{slotId}
|
||||
</foreach>
|
||||
AND delete_flag = '0'
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.SpecimenDefinitionMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +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.administration.mapper.SupplierMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,54 +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.administration.mapper.TraceNoManageMapper">
|
||||
<select id="getItemTraceNoInfo" resultType="com.openhis.administration.domain.TraceNoManage">
|
||||
SELECT item_table,
|
||||
item_id,
|
||||
location_id,
|
||||
lot_number,
|
||||
trace_no,
|
||||
MAX(create_time)
|
||||
FROM adm_trace_no_manage
|
||||
WHERE item_table = #{itemTable}
|
||||
AND item_id = #{itemId}
|
||||
AND location_id = #{locationId}
|
||||
AND lot_number = #{lotNumber}
|
||||
AND (trace_no) IN (SELECT trace_no
|
||||
FROM adm_trace_no_manage
|
||||
WHERE item_table = #{itemTable}
|
||||
AND item_id = #{itemId}
|
||||
AND location_id = #{locationId}
|
||||
AND lot_number = #{lotNumber}
|
||||
AND delete_flag = '0'
|
||||
GROUP BY trace_no
|
||||
HAVING SUM(CASE WHEN status_enum = 1 THEN 1 ELSE 0 END) > -- 进库次数
|
||||
SUM(CASE WHEN status_enum = 2 THEN 1 ELSE 0 END) -- 出库次数
|
||||
)
|
||||
AND delete_flag = '0'
|
||||
GROUP BY item_table,
|
||||
item_id,
|
||||
location_id,
|
||||
lot_number,
|
||||
trace_no
|
||||
</select>
|
||||
|
||||
<select id="tracePatient" resultType="com.openhis.administration.dto.TracePatientInfoDto">
|
||||
SELECT T2.name,
|
||||
T2.gender_enum,
|
||||
T2.birth_date,
|
||||
T2.phone,
|
||||
T3.create_time AS register_time
|
||||
FROM med_medication_dispense T1
|
||||
LEFT JOIN adm_patient T2 ON T2.ID = T1.patient_id
|
||||
AND T2.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter T3 ON T3.ID = T1.encounter_id
|
||||
AND T3.delete_flag = '0'
|
||||
WHERE T1.medication_id = #{ medId }
|
||||
<if test="dispenseStatus != null">
|
||||
AND T1.status_enum = #{dispenseStatus}
|
||||
</if>
|
||||
AND T1.trace_no = #{traceNo}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user