PatientInfoMapper.xml 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.PatientInfoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.PatientInfo">
  6. <id column="id" property="id" />
  7. <result column="is_deleted" property="isDeleted" />
  8. <result column="gmt_create" property="gmtCreate" />
  9. <result column="gmt_modified" property="gmtModified" />
  10. <result column="creator" property="creator" />
  11. <result column="modifier" property="modifier" />
  12. <result column="hospital_code" property="hospitalCode" />
  13. <result column="code" property="code" />
  14. <result column="name" property="name" />
  15. <result column="sex" property="sex" />
  16. <result column="birthday" property="birthday" />
  17. <result column="id_type" property="idType" />
  18. <result column="id_no" property="idNo" />
  19. <result column="address" property="address" />
  20. <result column="phone" property="phone" />
  21. <result column="identity_num" property="identityNum" />
  22. <result column="postcode" property="postcode" />
  23. <result column="contacts" property="contacts" />
  24. <result column="contact_phone" property="contactPhone" />
  25. <result column="work_unit" property="workUnit" />
  26. <result column="operation" property="operation" />
  27. <result column="country" property="country" />
  28. <result column="nationality" property="nationality" />
  29. <result column="matrimony" property="matrimony" />
  30. <result column="remark" property="remark" />
  31. </resultMap>
  32. <select id="getPatientInfos" resultType="com.diagbot.dto.PatientInfoDTO">
  33. SELECT a.* FROM `tran_patient_info` a
  34. LEFT JOIN tran_hospital_info b ON a.hospital_code = b.`code`
  35. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N'
  36. AND a.`code` = #{patientCode} AND b.`code` = #{hospitalCode}
  37. </select>
  38. <select id="getTopPatientInfo" parameterType="com.diagbot.vo.GetTopPatientInfoVO" resultType="com.diagbot.dto.GetTopPatientInfoDTO">
  39. SELECT
  40. a.id as hospitalId,
  41. a.`code` as hospitalCode,
  42. a.`name` as hospitalName,
  43. b.id as hospitalDeptId,
  44. b.concept_dept_name as selfDeptName,
  45. b.`code` as hospitalDeptCode,
  46. b.`name` as hospitalDeptName,
  47. c.id as doctorId,
  48. c.`code` as doctorCode,
  49. c.`name` as doctorName,
  50. d.id as patientId,
  51. d.`code` as patientCode,
  52. d.`name` as patientName,
  53. case when d.sex=1 then '男' when d.sex=2 then '女' else '未知' end as patientSex,
  54. d.id_no as patientIdNo,
  55. d.birthday as birthday
  56. FROM tran_hospital_info a LEFT JOIN tran_hospital_dept b
  57. ON a.`code`=b.hospital_code and b.`status`=1 and b.is_deleted='N' and b.`code`=#{hospitalDeptCode}
  58. LEFT JOIN tran_doctor_info c
  59. ON a.code=c.hospital_code
  60. <!-- and b.`code`=c.hospital_dept_code -->
  61. and c.is_deleted='N' and c.`code`=#{doctorCode}
  62. LEFT JOIN tran_patient_info d
  63. ON a.code=d.hospital_code and d.is_deleted='N' and d.`code`=#{patientCode}
  64. WHERE a.is_deleted='N'
  65. AND a.`status`=1
  66. AND a.`code`=#{hospitalCode}
  67. </select>
  68. <select id="getTopPatientInfoDj" parameterType="com.diagbot.vo.GetTopPatientInfoDjVO" resultType="com.diagbot.dto.GetTopPatientInfoDjDTO">
  69. SELECT
  70. a.id as hospitalId,
  71. a.`code` as hospitalCode,
  72. a.`name` as hospitalName,
  73. c.id as doctorId,
  74. c.`code` as doctorCode,
  75. c.`name` as doctorName,
  76. d.id as patientId,
  77. d.`code` as patientCode,
  78. d.`name` as patientName,
  79. case when d.sex=1 then '男' when d.sex=2 then '女' else '未知' end as patientSex,
  80. d.id_no as patientIdNo,
  81. d.birthday as birthday
  82. FROM tran_hospital_info a
  83. LEFT JOIN tran_doctor_info c
  84. ON a.code=c.hospital_code
  85. and c.is_deleted='N' and c.`code`=#{doctorCode}
  86. LEFT JOIN tran_patient_info d
  87. ON a.code=d.hospital_code and d.is_deleted='N' and d.`code`=#{patientCode}
  88. WHERE a.is_deleted='N'
  89. AND a.`status`=1
  90. AND a.`code`=#{hospitalCode}
  91. </select>
  92. </mapper>