PatientInfoMapper.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.identity_num as patientIdentityNum,
  56. d.phone as patientPhone,
  57. d.birthday as birthday
  58. FROM tran_hospital_info a LEFT JOIN tran_hospital_dept b
  59. ON a.`code`=b.hospital_code and b.`status`=1 and b.is_deleted='N' and b.`code`=#{hospitalDeptCode}
  60. LEFT JOIN tran_doctor_info c
  61. ON a.code=c.hospital_code
  62. <!-- and b.`code`=c.hospital_dept_code -->
  63. and c.is_deleted='N' and c.`code`=#{doctorCode}
  64. LEFT JOIN tran_patient_info d
  65. ON a.code=d.hospital_code and d.is_deleted='N' and d.`code`=#{patientCode}
  66. WHERE a.is_deleted='N'
  67. AND a.`status`=1
  68. AND a.`code`=#{hospitalCode}
  69. </select>
  70. <select id="getTopPatientInfoDj" parameterType="com.diagbot.vo.GetTopPatientInfoDjVO" resultType="com.diagbot.dto.GetTopPatientInfoDjDTO">
  71. SELECT
  72. a.id as hospitalId,
  73. a.`code` as hospitalCode,
  74. a.`name` as hospitalName,
  75. a.id as sonHospitalId,
  76. a.`code` as sonHospitalCode,
  77. a.`name` as sonHospitalName,
  78. c.id as doctorId,
  79. c.`code` as doctorCode,
  80. c.`name` as doctorName,
  81. d.id as patientId,
  82. d.`code` as patientCode,
  83. d.`name` as patientName,
  84. case when d.sex=1 then '男' when d.sex=2 then '女' else '未知' end as patientSex,
  85. case when d.identity_num is null or d.identity_num='' then d.id_no else d.identity_num end as patientIdNo,
  86. d.phone as patientPhone,
  87. d.birthday as birthday
  88. FROM tran_hospital_info a
  89. LEFT JOIN tran_doctor_info c
  90. ON a.code=c.hospital_code
  91. and c.is_deleted='N' and c.`code`=#{doctorCode}
  92. LEFT JOIN tran_patient_info d
  93. ON a.code=d.hospital_code and d.is_deleted='N' and d.`code`=#{patientCode}
  94. WHERE a.is_deleted='N'
  95. AND a.`status`=1
  96. AND a.`code`=#{sonHospitalCode}
  97. </select>
  98. </mapper>