Bläddra i källkod

患者列表查询语修改

wangzl 5 månader sedan
förälder
incheckning
cd1e6a06ef

+ 38 - 32
tr-modules/tr-module-smartFollowUp/src/main/resources/mapper/smart/BizPatientMapper.xml

@@ -19,32 +19,21 @@
     </resultMap>
     <select id="selectPatientList" resultMap="PatientAndClinicResult">
         SELECT
-        query_result.result_count,
-        bp.ID AS patient_id,
+        count(1) as countResult,
+        bp.id AS patient_id,
         bp.patient_code,
         bp.current_clinic_id,
         bcr.patient_name,
         bcr.patient_age,
         bcr.patient_gender,
-        bp.create_time ,
+        bp.create_time,
         bp.update_time,
         bp.create_by,
         bp.update_by
         FROM
-        ( SELECT patient_id, COUNT ( 1 ) AS result_count FROM biz_clinic_room
-        <where>
-            and deleted = 0
-            <if test="query.queryTime != null and query.queryTime.size() > 0">
-                AND clinic_start_time &gt;= #{query.queryTime[0]}
-            </if>
-            <if test="query.queryTime != null and query.queryTime.size() > 1">
-                AND clinic_start_time &lt;= #{query.queryTime[1]}
-            </if>
-        </where>
-        GROUP BY patient_id ) query_result
-        JOIN biz_patient AS bp ON query_result.patient_id = bp.ID
-        JOIN biz_clinic_room bcr ON bp.current_clinic_id = bcr.ID
-        JOIN biz_clinic_room_doctor_user bcrmu on bcr.id = bcrmu.clinic_room_id
+        biz_patient bp
+        JOIN biz_clinic_room bcr ON bp.ID = bcr.patient_id
+        JOIN biz_clinic_room_doctor_user bcrmu ON bcr.ID = bcrmu.clinic_room_id
         <where>
             and bcr.deleted = 0
             and bp.deleted = 0
@@ -67,31 +56,48 @@
             <if test="query.currentUserId != null and query.currentUserId != ''">
                 AND bcrmu.user_id = #{query.currentUserId,jdbcType=VARCHAR}
             </if>
+            <if test="query.queryTime != null and query.queryTime.size() > 0">
+                AND clinic_start_time &gt;= #{query.queryTime[0]}
+            </if>
+            <if test="query.queryTime != null and query.queryTime.size() > 1">
+                AND clinic_start_time &lt;= #{query.queryTime[1]}
+            </if>
         </where>
+        GROUP BY
+        bp.id,
+        bp.patient_code,
+        bp.current_clinic_id,
+        bcr.patient_name,
+        bcr.patient_age,
+        bcr.patient_gender,
+        bp.create_time,
+        bp.update_time,
+        bp.create_by,
+        bp.update_by
     </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,
-            bcr.clinic_name as clinicName,
-            bcr.clinic_start_time as clinicStartTime,
-            bp.current_clinic_id as currentClinicId,
-            bp.patient_code as patientCode,
-            bp.create_by as create_by,
-            bp.create_time as create_time,
-            bp.update_time as update_time,
-            bp.update_by as update_by
+        bp.id,
+        bcr.patient_name as name,
+        bcr.patient_age as age,
+        bcr.patient_gender as gender,
+        bcr.clinic_name as clinicName,
+        bcr.clinic_start_time as clinicStartTime,
+        bp.current_clinic_id as currentClinicId,
+        bp.patient_code as patientCode,
+        bp.create_by as create_by,
+        bp.create_time as create_time,
+        bp.update_time as update_time,
+        bp.update_by as update_by
         FROM
-            biz_patient bp
-                LEFT JOIN biz_clinic_room bcr ON bp.current_clinic_id = bcr.ID
+        biz_patient bp
+        LEFT JOIN biz_clinic_room bcr ON bp.current_clinic_id = bcr.ID
         <where>
             and bp.deleted = 0
             and bcr.deleted = 0
             and 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},'%')
+                and bcr.patient_name like concat('%',#{query.condition,jdbcType=VARCHAR},'%')
             </if>
             <if test="query.clinicTime != null and query.clinicTime.size() > 0">
                 and bcr.clinic_start_time &gt;= #{query.clinicTime[0]}