165 lines
6.1 KiB
XML
165 lines
6.1 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.openhis.web.patientmanage.mapper.PatientManageMapper">
|
|
<!-- 病人信息相关查询-->
|
|
<select id="getPatientPage" resultType="com.openhis.web.patientmanage.dto.PatientBaseInfoDto">
|
|
SELECT
|
|
pt.identifier_no,
|
|
pt.tenant_id,
|
|
pt.id,
|
|
pt.active_flag,
|
|
pt.temp_flag,
|
|
pt.name,
|
|
pt.name_json,
|
|
pt.bus_no,
|
|
pt.gender_enum,
|
|
pt.birth_date,
|
|
pt.deceased_date,
|
|
pt.marital_status_enum,
|
|
pt.prfs_enum,
|
|
pt.phone,
|
|
pt.address,
|
|
pt.address_province,
|
|
pt.address_city,
|
|
pt.address_district,
|
|
pt.address_street,
|
|
pt.address_json,
|
|
pt.nationality_code,
|
|
pt.id_card,
|
|
pt.py_str,
|
|
pt.wb_str,
|
|
pt.blood_abo,
|
|
pt.blood_rh,
|
|
pt.work_company,
|
|
pt.native_place,
|
|
pt.country_code,
|
|
pt.link_name,
|
|
pt.link_relation_code,
|
|
pt.link_telcom,
|
|
pt.link_jsons,
|
|
pt.organization_id,
|
|
pt.create_time
|
|
FROM (
|
|
SELECT
|
|
(
|
|
SELECT api.identifier_no
|
|
FROM adm_patient_identifier api
|
|
WHERE api.tenant_id = p.tenant_id
|
|
AND api.patient_id = p.id
|
|
LIMIT 1
|
|
) AS identifier_no,
|
|
p.tenant_id,
|
|
p.id,
|
|
p.active_flag,
|
|
p.temp_flag,
|
|
p.name,
|
|
p.name_json,
|
|
p.bus_no,
|
|
p.gender_enum,
|
|
p.birth_date,
|
|
p.deceased_date,
|
|
p.marital_status_enum,
|
|
p.prfs_enum,
|
|
p.phone,
|
|
p.address,
|
|
p.address_province,
|
|
p.address_city,
|
|
p.address_district,
|
|
p.address_street,
|
|
p.address_json,
|
|
p.nationality_code,
|
|
p.id_card,
|
|
p.py_str,
|
|
p.wb_str,
|
|
p.blood_abo,
|
|
p.blood_rh,
|
|
p.work_company,
|
|
p.native_place,
|
|
p.country_code,
|
|
p.link_name,
|
|
p.link_relation_code,
|
|
p.link_telcom,
|
|
p.link_jsons,
|
|
p.organization_id,
|
|
p.create_time
|
|
FROM adm_patient p
|
|
where p.delete_flag = '0'
|
|
) AS pt
|
|
${ew.customSqlSegment}
|
|
ORDER BY pt.bus_no DESC
|
|
</select>
|
|
|
|
<select id="getPatientIdInfo" resultType="com.openhis.web.patientmanage.dto.PatientIdInfoDto">
|
|
SELECT patient_id,
|
|
type_code,
|
|
identifier_no,
|
|
start_time,
|
|
end_time
|
|
FROM adm_patient_identifier
|
|
WHERE delete_flag = '0'
|
|
<if test="patientIdList != null and !patientIdList.isEmpty()">
|
|
AND patient_id IN
|
|
<foreach collection="patientIdList" item="itemId" open="(" separator="," close=")">
|
|
#{itemId}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 查询门诊记录 -->
|
|
<select id="getOutpatientRecord" resultType="com.openhis.web.patientmanage.dto.OutpatientRecordDto">
|
|
SELECT
|
|
enc.id as encounterId,
|
|
pt.name,
|
|
pt.id_card,
|
|
pt.bus_no as patientBusNo,
|
|
enc.bus_no as encounterBusNo,
|
|
pt.gender_enum,
|
|
pt.phone,
|
|
enc.create_time as encounterTime,
|
|
enc.status_enum as subjectStatusEnum,
|
|
org.name as organizationName,
|
|
prac.name as doctorName
|
|
FROM adm_encounter AS enc
|
|
LEFT JOIN adm_organization AS org ON enc.organization_id = org.ID AND org.delete_flag = '0'
|
|
LEFT JOIN adm_encounter_participant AS ep
|
|
ON enc.ID = ep.encounter_id AND ep.type_code = #{participantType} AND ep.delete_flag = '0'
|
|
LEFT JOIN adm_practitioner AS prac ON ep.practitioner_id = prac.ID AND prac.delete_flag = '0'
|
|
LEFT JOIN adm_patient AS pt ON enc.patient_id = pt.ID AND pt.delete_flag = '0'
|
|
<where>
|
|
enc.delete_flag = '0'
|
|
<if test="ew.sqlSegment != null and ew.sqlSegment != ''">
|
|
AND ${ew.sqlSegment}
|
|
</if>
|
|
</where>
|
|
ORDER BY enc.create_time DESC
|
|
</select>
|
|
|
|
<!-- 获取医生名字列表 -->
|
|
<select id="getDoctorNames" resultType="java.lang.String">
|
|
SELECT DISTINCT prac.name
|
|
FROM adm_practitioner AS prac
|
|
WHERE prac.delete_flag = '0'
|
|
ORDER BY prac.name
|
|
</select>
|
|
|
|
<!-- 根据医生ID和参与者类型获取相关的患者ID列表 -->
|
|
<select id="getPatientIdsByPractitionerId" resultType="java.lang.Long">
|
|
SELECT DISTINCT enc.patient_id
|
|
FROM adm_encounter_participant AS ep
|
|
INNER JOIN adm_encounter AS enc ON ep.encounter_id = enc.ID AND enc.delete_flag = '0'
|
|
INNER JOIN adm_patient AS pt ON enc.patient_id = pt.id AND pt.delete_flag = '0'
|
|
WHERE ep.delete_flag = '0'
|
|
AND ep.practitioner_id = #{practitionerId}
|
|
AND ep.tenant_id = #{tenantId}
|
|
AND enc.tenant_id = #{tenantId}
|
|
AND pt.tenant_id = #{tenantId}
|
|
<if test="typeCodes != null and !typeCodes.isEmpty()">
|
|
AND ep.type_code IN
|
|
<foreach collection="typeCodes" item="typeCode" open="(" separator="," close=")">
|
|
#{typeCode}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
</mapper>
|