InpMyPatientMapper.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.xinxin.topro.pubservice.mysqlmapper.InpMyPatientMapper" >
  4. <resultMap id="BaseResultMap" type="com.xinxin.topro.pubservice.mysqlModel.InpMyPatient" >
  5. <id column="IMP_ID" property="impId" jdbcType="INTEGER" />
  6. <result column="PatientNo" property="patientno" jdbcType="VARCHAR" />
  7. <result column="HI_ID" property="hiId" jdbcType="INTEGER" />
  8. <result column="DD_DepDm" property="ddDepdm" jdbcType="VARCHAR" />
  9. <result column="DW_WardDm" property="dwWarddm" jdbcType="VARCHAR" />
  10. <result column="DB_BedNo" property="dbBedno" jdbcType="VARCHAR" />
  11. <result column="IMP_User" property="impUser" jdbcType="VARCHAR" />
  12. <result column="IMP_Recordor" property="impRecordor" jdbcType="VARCHAR" />
  13. <result column="IMP_Record_Time" property="impRecordTime" jdbcType="TIMESTAMP" />
  14. <result column="IMP_IsDel" property="impIsdel" jdbcType="INTEGER" />
  15. </resultMap>
  16. <sql id="Base_Column_List" >
  17. IMP_ID, PatientNo, HI_ID, DD_DepDm, DW_WardDm, DB_BedNo, IMP_User, IMP_Recordor,
  18. IMP_Record_Time, IMP_IsDel
  19. </sql>
  20. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  21. select
  22. <include refid="Base_Column_List" />
  23. from inp_mypatient
  24. where IMP_ID = #{impId,jdbcType=INTEGER}
  25. </select>
  26. <select id="selectByDepartNo" resultMap="BaseResultMap" parameterType="java.lang.String" >
  27. SELECT a.DB_BedNo dbBedno,b.ptName,b.age,b.gender,b.VisitNo AS patientno,
  28. case when b.AdmitTime is null then DATEDIFF(sysdate(),b.BirthDay) + 1 else DATEDIFF(sysdate(),b.AdmitTime) + 1 end admitDays
  29. from inp_mypatient a INNER JOIN v_patientinfo b on a.PatientNo = b.visitNo
  30. where a.DW_WardDm = #{departNo,jdbcType=VARCHAR} AND a.IMP_User = #{userCode,jdbcType=VARCHAR} AND a.IMP_IsDel = 0 and b.InHospitalStatus = 0
  31. </select>
  32. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  33. delete from inp_mypatient
  34. where IMP_ID = #{impId,jdbcType=INTEGER}
  35. </delete>
  36. <insert id="insert" parameterType="com.xinxin.topro.pubservice.mysqlModel.InpMyPatient" >
  37. insert into inp_mypatient (IMP_ID, PatientNo, HI_ID,
  38. DD_DepDm, DW_WardDm, DB_BedNo,
  39. IMP_User, IMP_Recordor, IMP_Record_Time,
  40. IMP_IsDel)
  41. values (#{impId,jdbcType=INTEGER}, #{patientno,jdbcType=VARCHAR}, #{hiId,jdbcType=INTEGER},
  42. #{ddDepdm,jdbcType=VARCHAR}, #{dwWarddm,jdbcType=VARCHAR}, #{dbBedno,jdbcType=VARCHAR},
  43. #{impUser,jdbcType=VARCHAR}, #{impRecordor,jdbcType=VARCHAR}, #{impRecordTime,jdbcType=TIMESTAMP},
  44. #{impIsdel,jdbcType=INTEGER})
  45. </insert>
  46. <insert id="insertSelective" parameterType="com.xinxin.topro.pubservice.mysqlModel.InpMyPatient" >
  47. insert into inp_mypatient
  48. <trim prefix="(" suffix=")" suffixOverrides="," >
  49. <if test="impId != null" >
  50. IMP_ID,
  51. </if>
  52. <if test="patientno != null" >
  53. PatientNo,
  54. </if>
  55. <if test="hiId != null" >
  56. HI_ID,
  57. </if>
  58. <if test="ddDepdm != null" >
  59. DD_DepDm,
  60. </if>
  61. <if test="dwWarddm != null" >
  62. DW_WardDm,
  63. </if>
  64. <if test="dbBedno != null" >
  65. DB_BedNo,
  66. </if>
  67. <if test="impUser != null" >
  68. IMP_User,
  69. </if>
  70. <if test="impRecordor != null" >
  71. IMP_Recordor,
  72. </if>
  73. <if test="impRecordTime != null" >
  74. IMP_Record_Time,
  75. </if>
  76. <if test="impIsdel != null" >
  77. IMP_IsDel,
  78. </if>
  79. </trim>
  80. <trim prefix="values (" suffix=")" suffixOverrides="," >
  81. <if test="impId != null" >
  82. #{impId,jdbcType=INTEGER},
  83. </if>
  84. <if test="patientno != null" >
  85. #{patientno,jdbcType=VARCHAR},
  86. </if>
  87. <if test="hiId != null" >
  88. #{hiId,jdbcType=INTEGER},
  89. </if>
  90. <if test="ddDepdm != null" >
  91. #{ddDepdm,jdbcType=VARCHAR},
  92. </if>
  93. <if test="dwWarddm != null" >
  94. #{dwWarddm,jdbcType=VARCHAR},
  95. </if>
  96. <if test="dbBedno != null" >
  97. #{dbBedno,jdbcType=VARCHAR},
  98. </if>
  99. <if test="impUser != null" >
  100. #{impUser,jdbcType=VARCHAR},
  101. </if>
  102. <if test="impRecordor != null" >
  103. #{impRecordor,jdbcType=VARCHAR},
  104. </if>
  105. <if test="impRecordTime != null" >
  106. #{impRecordTime,jdbcType=TIMESTAMP},
  107. </if>
  108. <if test="impIsdel != null" >
  109. #{impIsdel,jdbcType=INTEGER},
  110. </if>
  111. </trim>
  112. </insert>
  113. <update id="updateByPrimaryKeySelective" parameterType="com.xinxin.topro.pubservice.mysqlModel.InpMyPatient" >
  114. update inp_mypatient
  115. <set >
  116. <if test="patientno != null" >
  117. PatientNo = #{patientno,jdbcType=VARCHAR},
  118. </if>
  119. <if test="hiId != null" >
  120. HI_ID = #{hiId,jdbcType=INTEGER},
  121. </if>
  122. <if test="ddDepdm != null" >
  123. DD_DepDm = #{ddDepdm,jdbcType=VARCHAR},
  124. </if>
  125. <if test="dwWarddm != null" >
  126. DW_WardDm = #{dwWarddm,jdbcType=VARCHAR},
  127. </if>
  128. <if test="dbBedno != null" >
  129. DB_BedNo = #{dbBedno,jdbcType=VARCHAR},
  130. </if>
  131. <if test="impUser != null" >
  132. IMP_User = #{impUser,jdbcType=VARCHAR},
  133. </if>
  134. <if test="impRecordor != null" >
  135. IMP_Recordor = #{impRecordor,jdbcType=VARCHAR},
  136. </if>
  137. <if test="impRecordTime != null" >
  138. IMP_Record_Time = #{impRecordTime,jdbcType=TIMESTAMP},
  139. </if>
  140. <if test="impIsdel != null" >
  141. IMP_IsDel = #{impIsdel,jdbcType=INTEGER},
  142. </if>
  143. </set>
  144. where IMP_ID = #{impId,jdbcType=INTEGER}
  145. </update>
  146. <update id="updateByPrimaryKey" parameterType="com.xinxin.topro.pubservice.mysqlModel.InpMyPatient" >
  147. update inp_mypatient
  148. set PatientNo = #{patientno,jdbcType=VARCHAR},
  149. HI_ID = #{hiId,jdbcType=INTEGER},
  150. DD_DepDm = #{ddDepdm,jdbcType=VARCHAR},
  151. DW_WardDm = #{dwWarddm,jdbcType=VARCHAR},
  152. DB_BedNo = #{dbBedno,jdbcType=VARCHAR},
  153. IMP_User = #{impUser,jdbcType=VARCHAR},
  154. IMP_Recordor = #{impRecordor,jdbcType=VARCHAR},
  155. IMP_Record_Time = #{impRecordTime,jdbcType=TIMESTAMP},
  156. IMP_IsDel = #{impIsdel,jdbcType=INTEGER}
  157. where IMP_ID = #{impId,jdbcType=INTEGER}
  158. </update>
  159. <update id="updateMyPatient" >
  160. update inp_mypatient
  161. set IMP_IsDel = -1
  162. where IMP_User = #{userCode,jdbcType=VARCHAR} AND PatientNo = #{visitNo,jdbcType=VARCHAR} AND IMP_IsDel = 0
  163. </update>
  164. <select id="selectLastUserByPatients" resultMap="BaseResultMap">
  165. select <include refid="Base_Column_List"/>
  166. from inp_mypatient
  167. where IMP_IsDel = 0
  168. and HI_ID = #{hiId,jdbcType=INTEGER}
  169. and PatientNo in
  170. <foreach collection="patientNos" item="item" open="(" close=")" separator=",">
  171. #{item,jdbcType=VARCHAR}
  172. </foreach>
  173. order by IMP_Record_Time desc
  174. </select>
  175. </mapper>