BizPatientMapper.xml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="cn.tr.module.smart.common.repository.BizPatientRepository">
  6. <resultMap id="PatientAndClinicResult" type="cn.tr.module.smart.app.controller.vo.WxDoctorPatientVO">
  7. <result property="patientId" column="patient_id"/>
  8. <result property="currentClinicId" column="current_clinic_id"/>
  9. <result property="patientCode" column="patient_code"/>
  10. <result property="countResult" column="result_count"/>
  11. <result property="patientName" column="patient_name"/>
  12. <result property="patientAge" column="patient_age"/>
  13. <result property="patientGender" column="patient_gender"/>
  14. </resultMap>
  15. <select id="selectPatientList" resultMap="PatientAndClinicResult">
  16. SELECT
  17. query_result.result_count,
  18. bp.ID AS patient_id,
  19. bp.patient_code,
  20. bp.current_clinic_id,
  21. bcr.patient_name,
  22. bcr.patient_age,
  23. bcr.patient_gender
  24. FROM
  25. ( SELECT patient_id, COUNT ( 1 ) AS result_count FROM biz_clinic_room
  26. <where>
  27. <if test="query.queryTime != null and query.queryTime.size() > 0">
  28. AND clinic_start_time &gt;= #{query.queryTime[0]}
  29. </if>
  30. <if test="query.queryTime != null and query.queryTime.size() > 1">
  31. AND clinic_start_time &lt;= #{query.queryTime[1]}
  32. </if>
  33. </where>
  34. GROUP BY patient_id ) query_result
  35. JOIN biz_patient AS bp ON query_result.patient_id = bp.ID
  36. LEFT JOIN biz_clinic_room bcr ON bp.current_clinic_id = bcr.ID
  37. <where>
  38. <if test="query.queryCondition != null and query.queryCondition != ''">
  39. bp.patient_code LIKE concat('%',#{query.queryCondition,jdbcType=VARCHAR},'%')
  40. or bp.name like concat('%',#{query.queryCondition,jdbcType=VARCHAR},'%')
  41. </if>
  42. </where>
  43. </select>
  44. <select id="selectPatientByConditionList" resultType="cn.tr.module.smart.common.dto.BizPatientDTO">
  45. SELECT
  46. bp.id,
  47. bcr.patient_name as name,
  48. bcr.patient_age as age,
  49. bcr.patient_gender as gender,
  50. bp.current_clinic_id as currentClinicId,
  51. bp.create_by as createBy,
  52. bp.create_time as createTime,
  53. bp.update_time as updateTime,
  54. bp.update_by as updateBy
  55. FROM
  56. biz_patient bp
  57. LEFT JOIN biz_clinic_room bcr ON bp.current_clinic_id = bcr.ID
  58. <where>
  59. bp.current_clinic_id is not null
  60. <if test="query.condition != null and query.condition != ''">
  61. and bcr.patient_name like concat('%',#{query.condition,jdbcType=VARCHAR},'%')
  62. </if>
  63. </where>
  64. </select>
  65. </mapper>