PatientMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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="org.example.mapper.PatientMapper">
  4. <resultMap id="PatientResultMap" type="org.example.entity.Patient">
  5. <result property="admissionDateTime" column="admission_date_time"/>
  6. <result property="inpatientNo" column="inpatient_no"/>
  7. <result property="name" column="name"/>
  8. <result property="sex" column="sex"/>
  9. <result property="age" column="age"/>
  10. <result property="medicalInsuranceType" column="medical_insurance_type"/>
  11. <result property="deptCode" column="dept_code"/>
  12. <result property="wardCode" column="ward_code"/>
  13. <result property="roomNo" column="room_no"/>
  14. <result property="bedNo" column="bed_no"/>
  15. <result property="doctorCode" column="doctor_code"/>
  16. <result property="nurseCode" column="nurse_code"/>
  17. <result property="inpatientSerialNo" column="inpatient_serial_no"/>
  18. <result property="deptDateTime" column="dept_date_time"/>
  19. <result property="dischargedDateTime" column="discharged_date_time"/>
  20. <result property="inpatientStatus" column="inpatient_status"/>
  21. <result property="diagnose" column="diagnose"/>
  22. <result property="conditionStatus" column="condition_status"/>
  23. <result property="nurseLevel" column="nurse_level"/>
  24. <result property="allergen" column="allergen"/>
  25. <result property="dietType" column="diet_type"/>
  26. <result property="notice" column="notice"/>
  27. </resultMap>
  28. <!-- 查询所有患者 -->
  29. <select id="findAll" resultMap="PatientResultMap">
  30. SELECT admission_date_time, inpatient_no, name, sex, age,
  31. medical_insurance_type, dept_code, ward_code, room_no, bed_no,
  32. doctor_code, nurse_code, inpatient_serial_no,
  33. dept_date_time, discharged_date_time,
  34. inpatient_status, diagnose, condition_status,
  35. nurse_level, allergen, diet_type, notice
  36. FROM tb_hospital_patient
  37. </select>
  38. <!-- 根据条件查询患者 -->
  39. <select id="findWithConditions" resultMap="PatientResultMap">
  40. SELECT admission_date_time, inpatient_no, name, sex, age,
  41. medical_insurance_type, dept_code, ward_code, room_no, bed_no,
  42. doctor_code, nurse_code, inpatient_serial_no,
  43. dept_date_time, discharged_date_time,
  44. inpatient_status, diagnose, condition_status,
  45. nurse_level, allergen, diet_type, notice
  46. FROM tb_hospital_patient
  47. WHERE 1=1
  48. <if test="name != null and name != ''">AND name LIKE CONCAT('%', #{name}, '%')</if>
  49. <if test="department != null and department != ''">AND dept_code = #{department}</if>
  50. <if test="ward != null and ward != ''">AND ward_code = #{ward}</if>
  51. <if test="roomNo != null and roomNo != ''">AND room_no = #{roomNo}</if>
  52. <if test="bedNo != null and bedNo != ''">AND bed_no = #{bedNo}</if>
  53. <if test="inpatientNo != null and inpatientNo != ''">AND inpatient_no LIKE CONCAT('%', #{inpatientNo}, '%')</if>
  54. <if test="nurseLevel != null and nurseLevel != ''">AND nurse_level = #{nurseLevel}</if>
  55. <if test="status != null and status != ''">AND inpatient_status = #{status}</if>
  56. <if test="admissionDateTime != null and admissionDateTime != ''">AND admission_date_time LIKE CONCAT('%', #{admissionDateTime}, '%')</if>
  57. </select>
  58. <!-- 查询所有不同的护理级别 -->
  59. <select id="findDistinctNurseLevels" resultType="string">
  60. SELECT DISTINCT nurse_level
  61. FROM tb_hospital_patient
  62. WHERE nurse_level IS NOT NULL AND nurse_level != ''
  63. </select>
  64. <!-- 查询所有不同的在院状态 -->
  65. <select id="findDistinctInpatientStatuses" resultType="string">
  66. SELECT DISTINCT inpatient_status
  67. FROM tb_hospital_patient
  68. WHERE inpatient_status IS NOT NULL AND inpatient_status != ''
  69. </select>
  70. <!-- 根据住院号查询患者 -->
  71. <select id="findByInpatientNo" parameterType="string" resultMap="PatientResultMap">
  72. SELECT admission_date_time, inpatient_no, name, sex, age,
  73. medical_insurance_type, dept_code, ward_code, room_no, bed_no,
  74. doctor_code, nurse_code, inpatient_serial_no,
  75. dept_date_time, discharged_date_time,
  76. inpatient_status, diagnose, condition_status,
  77. nurse_level, allergen, diet_type, notice
  78. FROM tb_hospital_patient
  79. WHERE inpatient_no = #{inpatientNo}
  80. </select>
  81. <!-- 插入新患者 -->
  82. <insert id="insert" parameterType="org.example.entity.Patient">
  83. INSERT INTO tb_hospital_patient(admission_date_time, inpatient_no, name, sex, age,
  84. medical_insurance_type, dept_code, ward_code, room_no, bed_no,
  85. doctor_code, nurse_code, inpatient_serial_no, dept_date_time, discharged_date_time,
  86. inpatient_status, diagnose, condition_status, nurse_level, allergen, diet_type, notice)
  87. VALUES(#{admissionDateTime}, #{inpatientNo}, #{name}, #{sex}, #{age},
  88. #{medicalInsuranceType}, #{deptCode}, #{wardCode}, #{roomNo}, #{bedNo},
  89. #{doctorCode}, #{nurseCode}, #{inpatientSerialNo}, #{deptDateTime}, #{dischargedDateTime},
  90. #{inpatientStatus}, #{diagnose}, #{conditionStatus}, #{nurseLevel}, #{allergen}, #{dietType}, #{notice})
  91. </insert>
  92. <!-- 更新患者信息 -->
  93. <update id="update" parameterType="org.example.entity.Patient">
  94. UPDATE tb_hospital_patient
  95. SET admission_date_time=#{admissionDateTime}, name=#{name}, sex=#{sex}, age=#{age},
  96. medical_insurance_type=#{medicalInsuranceType}, dept_code=#{deptCode}, ward_code=#{wardCode},
  97. room_no=#{roomNo}, bed_no=#{bedNo}, doctor_code=#{doctorCode}, nurse_code=#{nurseCode},
  98. inpatient_serial_no=#{inpatientSerialNo}, dept_date_time=#{deptDateTime},
  99. discharged_date_time=#{dischargedDateTime}, inpatient_status=#{inpatientStatus},
  100. diagnose=#{diagnose}, condition_status=#{conditionStatus}, nurse_level=#{nurseLevel},
  101. allergen=#{allergen}, diet_type=#{dietType}, notice=#{notice}
  102. WHERE inpatient_no=#{inpatientNo}
  103. </update>
  104. <!-- 根据住院号删除患者 -->
  105. <delete id="deleteByInpatientNo" parameterType="string">
  106. DELETE FROM tb_hospital_patient WHERE inpatient_no = #{inpatientNo}
  107. </delete>
  108. </mapper>