MedicalRecordMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.diagbot.mapper.MedicalRecordMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.MedicalRecord">
  6. <id column="rec_id" property="recId" />
  7. <result column="hospital_id" property="hospitalId" />
  8. <result column="behospital_code" property="behospitalCode" />
  9. <result column="org_code" property="orgCode" />
  10. <result column="rec_type_id" property="recTypeId" />
  11. <result column="rec_date" property="recDate" />
  12. <result column="rec_title" property="recTitle" />
  13. <result column="is_deleted" property="isDeleted" />
  14. <result column="gmt_create" property="gmtCreate" />
  15. <result column="gmt_modified" property="gmtModified" />
  16. <result column="creator" property="creator" />
  17. <result column="modifier" property="modifier" />
  18. </resultMap>
  19. <select id="getRecordData" resultType="com.diagbot.dto.RecordContentDTO">
  20. select t1.hospital_id,t1.rec_id, t1.rec_title, t1.rec_type_id, t1.mode_id , t2.name stand_model_name, t3.content_text, t3.html_text, t3.xml_text
  21. from med_medical_record t1, qc_mode t2, med_medical_record_content t3
  22. where
  23. t1.is_deleted = 'N'
  24. and t2.is_deleted = 'N'
  25. and t3.is_deleted = 'N'
  26. and t1.mode_id = t2.id
  27. and t1.hospital_id = t3.hospital_id
  28. and t1.rec_id = t3.rec_id
  29. and t1.hospital_id = #{hospitalId}
  30. and t1.behospital_code = #{behospitalCode}
  31. and t1.mode_id = #{modeId}
  32. and t3.xml_text != ''
  33. </select>
  34. <select id="getRecordContent" resultType="com.diagbot.dto.RecordContentDTO">
  35. select t1.hospital_id,t1.rec_id, t1.rec_title, t1.rec_type_id, t1.mode_id , t2.name stand_model_name, t3.content_text, t3.html_text, t3.xml_text
  36. from med_medical_record t1, qc_mode t2, med_medical_record_content t3
  37. where
  38. t1.is_deleted = 'N'
  39. and t2.is_deleted = 'N'
  40. and t3.is_deleted = 'N'
  41. and t1.mode_id = t2.id
  42. and t1.hospital_id = t3.hospital_id
  43. and t1.rec_id = t3.rec_id
  44. and t1.hospital_id = #{hospitalId}
  45. and t1.behospital_code = #{behospitalCode}
  46. </select>
  47. <select id="getRecordCount" resultType="java.lang.Integer">
  48. select count(*) as num from
  49. (select DISTINCT behospital_code,mode_id from med_medical_record where behospital_code in
  50. (select behospital_code from med_behospital_info where hospital_id = #{hospitalId}
  51. <if test="isPlacefile !=null and isPlacefile !=''">
  52. and is_placefile =#{isPlacefile}
  53. </if>
  54. <if test="startTime !=null and endTime !=null">
  55. and placefile_date BETWEEN #{startTime} AND #{endTime}
  56. </if>
  57. )
  58. <if test="modeList != null and modeList.size() > 0">
  59. and mode_id in
  60. <foreach collection="modeList" open="(" separator="," close=")" item="item">
  61. '${item}'
  62. </foreach>
  63. </if>
  64. <if test="start != null and end !=null">
  65. limit #{start},#{end}
  66. </if>
  67. ) a
  68. </select>
  69. <select id="getMedicalRecord" resultType="com.diagbot.dto.MedicalRecordDTO">
  70. SELECT DISTINCT
  71. a.behospital_code behospitalCode,
  72. a.hospital_id hospitalId,
  73. c.mode_id
  74. from
  75. med_behospital_info a LEFT JOIN med_behospital_type b
  76. on a.behospital_code = b.behospital_code and a.hospital_id = b.hospital_id and a.is_deleted = 'N' and b.is_deleted = 'N'
  77. LEFT JOIN med_medical_record c
  78. on a.behospital_code = c.behospital_code and a.hospital_id = c.hospital_id and a.is_deleted = 'N' and c.is_deleted = 'N'
  79. where b.`value` is null
  80. <if test="modeList != null and modeList.size() > 0">
  81. and c.mode_id in
  82. <foreach collection="modeList" open="(" separator="," close=")" item="item">
  83. '${item}'
  84. </foreach>
  85. </if>
  86. </select>
  87. <update id="updateBatchByKey">
  88. <foreach collection="list" item="item" separator=";">
  89. update med_medical_record
  90. <set>
  91. <if test="item.orgCode != null">
  92. org_code = #{item.orgCode},
  93. </if>
  94. <if test="item.recTypeId != null">
  95. rec_type_id = #{item.recTypeId},
  96. </if>
  97. <if test="item.recDate != null">
  98. rec_date = #{item.recDate},
  99. </if>
  100. <if test="item.recTitle != null">
  101. rec_title = #{item.recTitle},
  102. </if>
  103. <if test="item.gmtModified != null">
  104. gmt_modified = #{item.gmtModified},
  105. </if>
  106. <if test="item.modifier != null">
  107. modifier = #{item.modifier},
  108. </if>
  109. </set>
  110. where rec_id = #{item.recId} and hospital_id = #{item.hospitalId} and behospital_code = #{item.behospitalCode}
  111. </foreach>
  112. </update>
  113. </mapper>