| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?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="cn.tr.module.smart.common.repository.BizPatientRepository">
- <resultMap id="PatientAndClinicResult" type="cn.tr.module.smart.app.controller.vo.WxDoctorPatientVO">
- <result property="patientId" column="patient_id"/>
- <result property="currentClinicId" column="current_clinic_id"/>
- <result property="patientCode" column="patient_code"/>
- <result property="countResult" column="result_count"/>
- <result property="patientName" column="patient_name"/>
- <result property="patientAge" column="patient_age"/>
- <result property="patientGender" column="patient_gender"/>
- </resultMap>
- <select id="selectPatientList" resultMap="PatientAndClinicResult">
- SELECT
- query_result.result_count,
- bp.ID AS patient_id,
- bp.patient_code,
- bp.current_clinic_id,
- bcr.patient_name,
- bcr.patient_age,
- bcr.patient_gender
- FROM
- ( SELECT patient_id, COUNT ( 1 ) AS result_count FROM biz_clinic_room
- <where>
- <if test="query.queryTime != null and query.queryTime.size() > 0">
- AND clinic_start_time >= #{query.queryTime[0]}
- </if>
- <if test="query.queryTime != null and query.queryTime.size() > 1">
- AND clinic_start_time <= #{query.queryTime[1]}
- </if>
- </where>
- GROUP BY patient_id ) query_result
- JOIN biz_patient AS bp ON query_result.patient_id = bp.ID
- LEFT JOIN biz_clinic_room bcr ON bp.current_clinic_id = bcr.ID
- <where>
- <if test="query.queryCondition != null and query.queryCondition != ''">
- bp.patient_code LIKE concat('%',#{query.queryCondition,jdbcType=VARCHAR},'%')
- or bp.name like concat('%',#{query.queryCondition,jdbcType=VARCHAR},'%')
- </if>
- </where>
- </select>
- <select id="selectPatientByConditionList" resultType="cn.tr.module.smart.common.dto.BizPatientDTO">
- SELECT
- bp.id,
- bcr.patient_name as name,
- bcr.patient_age as age,
- bcr.patient_gender as gender,
- bp.current_clinic_id as currentClinicId,
- bp.create_by as createBy,
- bp.create_time as createTime,
- bp.update_time as updateTime,
- bp.update_by as updateBy
- FROM
- biz_patient bp
- LEFT JOIN biz_clinic_room bcr ON bp.current_clinic_id = bcr.ID
- <where>
- bp.current_clinic_id is not null
- <if test="query.condition != null and query.condition != ''">
- and bcr.patient_name like concat('%',#{query.condition,jdbcType=VARCHAR},'%')
- </if>
- </where>
- </select>
- </mapper>
|