blood/blood_bus_doctor/src/main/resources/mapper/TransfuseApplyMapper.xml

175 lines
9.6 KiB
XML

<?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.czblood.busDoctor.mapper.TransfuseApplyMapper">
<select id="queryList" resultType="map">
SELECT DISTINCT xk_transfuse_apply.bill_no,
xk_transfuse_apply.dept_id,
xk_patient_info.patient_name,
xk_transfuse_apply.apply_date,
xk_transfuse_apply.apply_medic,
xk_transfuse_apply.bill_stasus,
xk_transfuse_apply.beinhos_id ,
xk_transfuse_apply.abo_type,
xk_transfuse_apply.rh_type,
xk_transfuse_apply.is_large_use,
SUBSTRING(( SELECT ',' +xx.breed_name+CONVERT(varchar(255),CONVERT(decimal(10,1),x.blood_num))+x.unit
from xk_transfuse_apply_bloodbreed x join xk_blood_breed xx on xx.breed_code=x.blood_breed where x.bill_no=xk_transfuse_apply.bill_no FOR XML PATH('') ),2,999) as req_breed
FROM xk_patient_info RIGHT OUTER JOIN xk_transfuse_apply ON xk_patient_info.beinhos_id = xk_transfuse_apply.beinhos_id
WHERE ( xk_transfuse_apply.operation_type = 'C' OR ISNULL(xk_transfuse_apply.operation_type,'') = '')
and xk_transfuse_apply.apply_date > getdate() - #{day} and xk_transfuse_apply.hos_id = #{hos_id}
<if test="bill_status != null and bill_status != ''">and xk_transfuse_apply.bill_stasus = #{bill_status}</if>
<if test="dept_code != null and dept_code != ''">and xk_transfuse_apply.dept_id = #{dept_code}</if>
<if test="dept_code != null and dept_code != ''">and (xk_transfuse_apply.dept_id = #{dept_code} or xk_transfuse_apply.input_dept = #{dept_code})</if>
<if test="doctor_code != null and doctor_code != ''">and xk_transfuse_apply.apply_medic = #{doctor_code}</if>
</select>
<select id="queryApplyOne" resultType="com.czblood.busDoctor.pojo.DTO.TransfuseApplyInfoOne">
SELECT top 1 xk_patient_info.hos_id,
xk_patient_info.patient_name,
xk_patient_info.age,
xk_transfuse_apply.zone_id,
xk_patient_info.patient_sex,
xk_patient_info.patient_birthday,
xk_transfuse_apply.patient_bed,
xk_transfuse_apply.casehistory_id,
xk_transfuse_apply.dept_id,
xk_transfuse_apply.card_no,
xk_patient_info.apanage,
xk_transfuse_apply.hos_id,
xk_transfuse_apply.bill_no,
xk_transfuse_apply.beinhos_id,
xk_patient_info.transfuse_history,
xk_patient_info.gestation_history,
xk_patient_info.parturition_history,
xk_patient_info.reaction_history,
xk_transfuse_apply.apply_date,
xk_transfuse_apply.send_person,
xk_transfuse_apply.charge_sign,
xk_transfuse_apply.input_person,
xk_transfuse_apply.receive_date,
xk_transfuse_apply.attending_medic,
xk_transfuse_apply.bank_director,
xk_transfuse_apply.medical_affairs,
xk_transfuse_apply.sample_id,
xk_transfuse_apply.gather_date,
xk_transfuse_apply.abo_type,
xk_transfuse_apply.rh_type,
xk_transfuse_apply.check_sign,
xk_transfuse_apply.bill_stasus,
xk_patient_info.out_sign,
xk_transfuse_apply.apply_medic,
xk_transfuse_apply.diagnoses,
xk_transfuse_apply.intent,
xk_transfuse_apply.treat_medic,
xk_transfuse_apply.causalis,
xk_transfuse_apply.use3_date,
xk_transfuse_apply.use2_date,
xk_transfuse_apply.use1_date,
xk_patient_info.match_history,
xk_transfuse_apply.apply_type,
xk_transfuse_apply.bill_type,
xk_transfuse_apply.operation_type ,
xk_transfuse_apply_bloodbreed.blood_breed ,
xk_transfuse_apply_bloodbreed.blood_num ,
xk_transfuse_apply_bloodbreed.unit ,
xk_transfuse_apply_bloodbreed.onetime_num ,
xk_transfuse_apply_bloodbreed.special_deal ,
xk_transfuse_apply_bloodbreed.replace_bloodbreed,
xk_transfuse_apply_bloodbreed.remark,
xk_transfuse_apply.bill_sort,
xk_transfuse_apply.sample_sign,
xk_transfuse_apply_bloodbreed.apply_bloodtype,
xk_transfuse_apply.check_explain,
xk_transfuse_apply.input_dept,
xk_transfuse_apply.send_able,
xk_transfuse_apply.medic_check_date,
xk_transfuse_apply.check_medic,xk_transfuse_apply.remark,
xk_transfuse_apply.is_large_use,xk_transfuse_apply.agreement_ink,
xk_transfuse_apply.beinhos_number ,xk_transfuse_apply.notify_sign,
xk_transfuse_apply.Use_Type ,xk_transfuse_apply.Valid_Flag,
xk_transfuse_apply.Ill_Code,xk_transfuse_apply.Dept_Type,
xk_transfuse_apply.Ops_Name,xk_transfuse_apply.Use1_Num,xk_transfuse_apply.operation_name,xk_transfuse_apply.operation_level
FROM xk_patient_info RIGHT OUTER JOIN xk_transfuse_apply ON xk_patient_info.beinhos_id = xk_transfuse_apply.beinhos_id ,
xk_transfuse_apply_bloodbreed
WHERE xk_transfuse_apply.bill_no = xk_transfuse_apply_bloodbreed.bill_no AND
xk_transfuse_apply.bill_no = #{bill_no} and xk_transfuse_apply.hos_id = #{hos_id}
</select>
<select id="queryApplyBeforeList" resultType="java.util.Map">
select
xk_transfuse_apply_before.bill_no,
xk_transfuse_apply_before.dept_id,
xk_patient_info.patient_name,
xk_transfuse_apply_before.beinhos_id,
xk_transfuse_apply_before.assess_data,
xk_transfuse_apply_before.assess_person
from
xk_transfuse_apply_before,xk_patient_info
where
xk_transfuse_apply_before.beinhos_id = xk_patient_info.beinhos_id AND
xk_transfuse_apply_before.assess_data>GETDATE() - 1 AND
(xk_transfuse_apply_before.dept_id=#{dept_id} or xk_transfuse_apply_before.assess_person=#{assess_person})
and xk_transfuse_apply_before.hos_id = #{hos_id}
</select>
<select id="queryXkCheckBloodtypeCount" resultType="java.lang.Integer">
SELECT Count (*) FROM xk_check_bloodtype where hos_id = #{hos_id}
<![CDATA[ and isnull( sub_blood , '' ) <> '' ]]>
and beinhos_id = #{beinhos_id};
</select>
<select id="checkSameBloodType" resultType="java.lang.String">
select distinct t1.bill_no
into :ls_pre_billno
from xk_transfuse_apply t1 , xk_transfuse_apply_bloodbreed t2
where t1.apply_date in (
select max ( apply_date )
from xk_transfuse_apply a , xk_transfuse_apply_bloodbreed b , xk_blood_breed d
where a.bill_no =b.bill_no and
b.blood_breed =d.breed_code and
d.blood_kind ='0004' and
a.beinhos_id = #{beinhos_id} and
b.blood_breed = #{blood_breed} and
isnull ( a.check_sign , 'N' ) ='N' and
<![CDATA[DATEDIFF ( day , apply_date , GETDATE ( ) ) < 3 ) and]]>
t2.blood_breed in (
select breed_code
from xk_blood_breed
where blood_kind ='0004' ) and
t1.bill_no =t2.bill_no;
</select>
<select id="checkSelfBlood" resultType="java.util.Map">
SELECT xk_blood_breed.breed_name,
sum(xk_blood_info.capacity) as capacity,
xk_blood_info.unit
FROM xk_blood_breed,
xk_blood_info,
xk_gather_detail,
xk_gather_main,
xk_transfuse_apply
WHERE ( xk_gather_detail.bill_no = xk_gather_main.bill_no ) and
( xk_blood_info.blood_no = xk_gather_detail.blood_no ) and
( xk_blood_info.blood_breed = xk_blood_breed.breed_code ) and
( xk_gather_main.apply_no = xk_transfuse_apply.bill_no ) and
( ( xk_blood_info.blood_sort = 'Z' ) AND
( xk_blood_info.blood_status = '1' ) AND
( xk_transfuse_apply.beinhos_id = #{beinhos_id} ) )
group by xk_blood_breed.breed_name,xk_blood_info.unit
</select>
<select id="queryApplyTransTotalNum" resultType="java.math.BigDecimal">
SELECT sum ( t.blood_num / b.capacity *b.applynum ) rl_qc
FROM xk_transfuse_apply a , xk_blood_apply_trans b , xk_transfuse_apply_bloodbreed t , xk_blood_breed k
WHERE a.beinhos_id = #{beinhos_id} AND
a.Bill_No =t.Bill_No AND
k.blood_kind =b.blood_breed AND
t.blood_breed =k.breed_code AND
<![CDATA[a.bill_stasus <> 'Z' and]]>
a.apply_date Between #{stime} AND #{etime}
<if test="billNo != null and billNo != ''"><![CDATA[and a.bill_no <> #{billNo}]]></if>
<if test="bloodKindList != null and bloodKindList.size() > 0">
and k.blood_kind in
<foreach collection="bloodKindList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
</mapper>