You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
4.4 KiB
130 lines
4.4 KiB
4 years ago
|
<?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.ccsens.carbasics.persist.dao.PatientDao">
|
||
|
|
||
|
<select id="findByIdCardAndHospitalId" resultType="com.ccsens.carbasics.bean.po.Patient">
|
||
|
SELECT
|
||
|
id,
|
||
|
`name`,
|
||
|
gender,
|
||
|
age,
|
||
|
nation,
|
||
|
idcard,
|
||
|
phone,
|
||
|
hospital_id,
|
||
|
user_id,
|
||
|
operator
|
||
|
FROM
|
||
|
t_qcp_patient
|
||
|
WHERE
|
||
|
rec_status = 0
|
||
|
AND idcard = #{idCard}
|
||
|
AND hospital_id = #{hospitalId}
|
||
|
</select>
|
||
|
<select id="queryByHospital" resultType="com.ccsens.carbasics.bean.vo.PatientVo$QueryPatientList">
|
||
|
SELECT
|
||
|
p.id,
|
||
|
fa.id as firstAidId,
|
||
|
fa.medical_record_num as medicalRecordNum,
|
||
|
p.`name`,
|
||
|
p.gender,
|
||
|
p.age,
|
||
|
fa.time as morbidityTime,
|
||
|
c.id as carId,
|
||
|
r.answer as transformation,
|
||
|
fa.value_type as demonstrate
|
||
|
FROM
|
||
|
t_qcp_patient p
|
||
|
LEFT JOIN t_qcp_first_aid fa on p.id = fa.patient_id
|
||
|
LEFT JOIN t_qcp_first_aid_record r on fa.id = r.first_aid_id and r.rec_status = 0 and r.question_code = 'HZZG'
|
||
|
LEFT JOIN t_qcp_patient_wisdom_car c on fa.id = c.first_aid_id
|
||
|
WHERE
|
||
|
p.hospital_id = #{hospitalId}
|
||
|
<if test="patientName != null and patientName != ''">
|
||
|
AND p.`name` LIKE concat('%',#{patientName},'%')
|
||
|
</if>
|
||
|
and p.rec_status = 0
|
||
|
and fa.rec_status = 0
|
||
|
<if test="type == 2">
|
||
|
and r.id is not null
|
||
|
</if>
|
||
|
<if test="type != 2">
|
||
|
and fa.save_type = #{type}
|
||
|
and r.id is null
|
||
|
</if>
|
||
|
order by fa.time DESC
|
||
|
</select>
|
||
|
<select id="getRecordByAidIdAndCode" resultType="com.ccsens.carbasics.bean.vo.PatientVo$AidRecord">
|
||
|
SELECT
|
||
|
id,
|
||
|
first_aid_id as firstAidId,
|
||
|
question_code as questionCode,
|
||
|
answer
|
||
|
FROM
|
||
|
t_qcp_first_aid_record
|
||
|
WHERE
|
||
|
first_aid_id = #{firstAidId}
|
||
|
and question_code = #{code}
|
||
|
and rec_status = 0
|
||
|
LIMIT 1
|
||
|
</select>
|
||
|
<select id="getAttendanceDoctor" resultType="com.ccsens.carbasics.bean.vo.PatientVo$Doctor">
|
||
|
SELECT
|
||
|
distinct
|
||
|
d.id,
|
||
|
if(w.post is null,d.post,w.post) as post,
|
||
|
d.`name`
|
||
|
FROM
|
||
|
t_qcp_attendance_record r
|
||
|
LEFT JOIN t_qcp_doctor d on r.rfid = d.rfid
|
||
|
LEFT JOIN t_qcp_working w on d.id = w.doctor_id and w.start_time <= r.time and w.end_time >= r.time and w.rec_status = 0
|
||
|
WHERE
|
||
|
r.first_aid_id = #{firstAidId}
|
||
|
and r.rec_status = 0
|
||
|
and d.rec_status = 0
|
||
|
</select>
|
||
|
<select id="queryRecordByAidId" resultType="com.ccsens.carbasics.bean.vo.PatientVo$AidRecord">
|
||
|
SELECT
|
||
|
a.id,
|
||
|
r.question_code as questionCode,
|
||
|
r.answer
|
||
|
FROM
|
||
|
t_qcp_first_aid a LEFT JOIN
|
||
|
t_qcp_first_aid_record r on a.id = r.first_aid_id and r.rec_status = 0
|
||
|
WHERE
|
||
|
a.project_id = #{projectId}
|
||
|
<if test="codeList != null and codeList.size() > 0">
|
||
|
AND r.question_code in
|
||
|
<foreach collection="codeList" item="code" separator="," open="(" close=")">
|
||
|
#{code}
|
||
|
</foreach>
|
||
|
</if>
|
||
|
and a.rec_status = 0
|
||
|
</select>
|
||
|
<select id="querySubordinate" resultType="com.ccsens.carbasics.bean.vo.PatientVo$QuerySubordinate">
|
||
|
SELECT
|
||
|
count(d.id) as totalNum,
|
||
|
count(r.id) as completeNum
|
||
|
FROM
|
||
|
t_qcp_code_dictionaries d
|
||
|
LEFT JOIN t_qcp_first_aid a on a.project_id = #{projectId} and a.rec_status = 0
|
||
|
LEFT JOIN t_qcp_first_aid_record r on d.question_code = r.question_code and r.rec_status = 0 and a.id = r.first_aid_id
|
||
|
WHERE
|
||
|
d.parent_code = #{code}
|
||
|
and d.rec_status = 0
|
||
|
</select>
|
||
|
<select id="queryCarPatient" resultType="com.ccsens.carbasics.bean.vo.PatientVo$QueryPatientList">
|
||
|
SELECT
|
||
|
0 as firstAidId,
|
||
|
'无名氏' as `name`,
|
||
|
c.id as carId
|
||
|
FROM
|
||
|
t_qcp_wisdom_car c
|
||
|
LEFT JOIN t_qcp_first_aid_record ar on c.id = ar.submit_user_id and ar.submit_user_type = 0 and ar.rec_status = 0
|
||
|
WHERE
|
||
|
c.hospital_id = #{hospitalId}
|
||
|
and ar.first_aid_id = 0
|
||
|
and c.rec_status = 0
|
||
|
</select>
|
||
|
|
||
|
</mapper>
|