InpMedOrderInpMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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.inpnurseservice.mysqlmapper.InpMedOrderInpMapper" >
  4. <resultMap id="BaseResultMap" type="com.xinxin.topro.inpnurseservice.mysqlmodel.InpMedOrderInp" >
  5. <id column="IMO_ID" property="imoId" jdbcType="INTEGER" />
  6. <result column="HI_ID" property="hiId" jdbcType="INTEGER" />
  7. <result column="PatientNo" property="patientno" jdbcType="VARCHAR" />
  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="IMO_Order_ID" property="imoOrderId" jdbcType="VARCHAR" />
  12. <result column="IMO_Item_Code" property="imoItemCode" jdbcType="VARCHAR" />
  13. <result column="IMO_Order_Name" property="imoOrderName" jdbcType="VARCHAR" />
  14. <result column="IMO_Item_Explain" property="imoItemExplain" jdbcType="VARCHAR" />
  15. <result column="IMO_Item_SupID" property="imoItemSupid" jdbcType="VARCHAR" />
  16. <result column="IMO_Item_OrderID" property="imoItemOrderid" jdbcType="VARCHAR" />
  17. <result column="IMO_FirstDay_Times" property="imoFirstdayTimes" jdbcType="DOUBLE" />
  18. <result column="IMO_Entrust" property="imoEntrust" jdbcType="VARCHAR" />
  19. <result column="IMO_Med_Usage" property="imoMedUsage" jdbcType="VARCHAR" />
  20. <result column="IMO_IsLong" property="imoIslong" jdbcType="INTEGER" />
  21. <result column="IMO_Status" property="imoStatus" jdbcType="INTEGER" />
  22. <result column="IMO_Order_Type" property="imoOrderType" jdbcType="INTEGER" />
  23. <result column="IMO_Med_Type" property="imoMedType" jdbcType="INTEGER" />
  24. <result column="IMO_Med_Way" property="imoMedWay" jdbcType="VARCHAR" />
  25. <result column="IMO_Item_Name" property="imoItemName" jdbcType="VARCHAR" />
  26. <result column="IMO_Item_Spec" property="imoItemSpec" jdbcType="VARCHAR" />
  27. <result column="IMO_Item_Dose" property="imoItemDose" jdbcType="DOUBLE" />
  28. <result column="IMO_Item_DoseUnit" property="imoItemDoseunit" jdbcType="VARCHAR" />
  29. <result column="IMO_Once_Dose" property="imoOnceDose" jdbcType="DOUBLE" />
  30. <result column="IMO_Once_DoseUnit" property="imoOnceDoseunit" jdbcType="VARCHAR" />
  31. <result column="IMO_IsEmer" property="imoIsemer" jdbcType="INTEGER" />
  32. <result column="IMO_PIVA" property="imoPiva" jdbcType="INTEGER" />
  33. <result column="IMO_AdviceNo" property="imoAdviceno" jdbcType="VARCHAR" />
  34. <result column="IMO_IsSkinTest" property="imoIsskintest" jdbcType="INTEGER" />
  35. <result column="IMO_SkinTest_Result" property="imoSkintestResult" jdbcType="VARCHAR" />
  36. <result column="IMO_Opener" property="imoOpener" jdbcType="VARCHAR" />
  37. <result column="IMO_Open_Time" property="imoOpenTime" jdbcType="TIMESTAMP" />
  38. <result column="IMO_Stoper" property="imoStoper" jdbcType="VARCHAR" />
  39. <result column="IMO_Stop_Time" property="imoStopTime" jdbcType="TIMESTAMP" />
  40. <result column="IMO_StopChecker" property="imoStopchecker" jdbcType="VARCHAR" />
  41. <result column="IMO_StopCheck_Time" property="imoStopcheckTime" jdbcType="TIMESTAMP" />
  42. <result column="IMO_Revoker" property="imoRevoker" jdbcType="VARCHAR" />
  43. <result column="IMO_Revoke_Time" property="imoRevokeTime" jdbcType="TIMESTAMP" />
  44. <result column="IMO_Revoke_Reason" property="imoRevokeReason" jdbcType="VARCHAR" />
  45. <result column="IMO_Checker" property="imoChecker" jdbcType="VARCHAR" />
  46. <result column="IMO_Check_Time" property="imoCheckTime" jdbcType="TIMESTAMP" />
  47. <result column="IMO_Excutor" property="imoExcutor" jdbcType="VARCHAR" />
  48. <result column="IMO_Excute_Time" property="imoExcuteTime" jdbcType="TIMESTAMP" />
  49. <result column="IMO_Drug_Days" property="imoDrugDays" jdbcType="INTEGER" />
  50. <result column="IMO_Rate" property="imoRate" jdbcType="VARCHAR" />
  51. <result column="IMO_Rate_Unit" property="imoRateUnit" jdbcType="VARCHAR" />
  52. <result column="IMO_Prescription_Num" property="imoPrescriptionNum" jdbcType="INTEGER" />
  53. <result column="IMO_Dosage_Form" property="imoDosageForm" jdbcType="VARCHAR" />
  54. </resultMap>
  55. <resultMap id="ListResultMap" type="com.xinxin.topro.inpnurseservice.vo.InpMedOrderInpVO" extends="BaseResultMap">
  56. <result column="adviceNo" property="adviceNo" jdbcType="VARCHAR" />
  57. </resultMap>
  58. <sql id="Base_Column_List" >
  59. IMO_ID, HI_ID, PatientNo, DD_DepDm, DW_WardDm, DB_BedNo, IMO_Order_ID, IMO_Item_Code,
  60. IMO_Order_Name, IMO_Item_Explain, IMO_Item_SupID, IMO_Item_OrderID, IMO_FirstDay_Times,
  61. IMO_Entrust, IMO_Med_Usage, IMO_IsLong, IMO_Status, IMO_Order_Type, IMO_Med_Type,
  62. IMO_Med_Way, IMO_Item_Name, IMO_Item_Spec, IMO_Item_Dose, IMO_Item_DoseUnit, IMO_Once_Dose,
  63. IMO_Once_DoseUnit, IMO_IsEmer, IMO_PIVA, IMO_AdviceNo, IMO_IsSkinTest, IMO_SkinTest_Result,
  64. IMO_Opener, IMO_Open_Time, IMO_Stoper, IMO_Stop_Time, IMO_StopChecker, IMO_StopCheck_Time,
  65. IMO_Revoker, IMO_Revoke_Time, IMO_Revoke_Reason, IMO_Checker, IMO_Check_Time, IMO_Excutor,
  66. IMO_Excute_Time, IMO_Drug_Days, IMO_Rate, IMO_Rate_Unit, IMO_Prescription_Num, IMO_Dosage_Form
  67. </sql>
  68. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  69. select
  70. <include refid="Base_Column_List" />
  71. from inp_med_order
  72. where IMO_ID = #{imoId,jdbcType=INTEGER}
  73. </select>
  74. <select id="selectActiveByNamePatient" resultMap="ListResultMap">
  75. select
  76. <include refid="Base_Column_List" />,
  77. (select DMW_Name from dic_med_way dmw where dmw.DMW_IsDel = 0 and dmw.DMW_Code = imo.IMO_AdviceNo) adviceNo
  78. from inp_med_order imo
  79. where imo.IMO_Revoke_Time is null
  80. and imo.PatientNo = #{patientNo,jdbcType=VARCHAR}
  81. and imo.HI_ID = #{hiId,jdbcType=INTEGER}
  82. <if test="name != null and name != ''">
  83. and imo.IMO_Order_Name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  84. </if>
  85. </select>
  86. <select id="selectByItemCode" resultType="com.xinxin.topro.inpnurseservice.response.InpMedOrderResponse">
  87. SELECT
  88. imo.IMO_ID AS imoId,
  89. dd.DD_DepName AS dept,
  90. ip.IP_Med_Rec AS medRec,
  91. ip.DB_BedNo AS bedNo,
  92. ip.IP_Name AS ipName,
  93. CASE
  94. WHEN ip.IP_Sex='1' THEN '男'
  95. WHEN ip.IP_Sex='2' THEN '女'
  96. ELSE '其他'
  97. END AS sex,
  98. f_getAge(ip.IP_Birth, ip.IP_Admit_Time) AS age,
  99. imo.IMO_Order_Name AS orderName,
  100. CASE
  101. WHEN imo.IMO_Open_Time IS NULL THEN ''
  102. ELSE DATE_FORMAT(imo.IMO_Open_Time,'%Y-%m-%d %H:%i:%s')
  103. END AS begTime,
  104. CASE
  105. WHEN imo.IMO_Stop_Time IS NULL THEN ''
  106. ELSE DATE_FORMAT(imo.IMO_Stop_Time,'%Y-%m-%d %H:%i:%s')
  107. END AS endTime,
  108. imo.IMO_Med_Usage AS medUsage,
  109. su.UI_Name AS openerName
  110. FROM
  111. inp_med_order imo
  112. LEFT JOIN inp_patient ip ON ip.IP_PatientNo = imo.PatientNo
  113. LEFT JOIN dic_department dd ON dd.DD_DepDm = imo.DD_DepDm
  114. LEFT JOIN sys_userinfo su ON su.UI_Code = imo.IMO_Opener
  115. WHERE
  116. imo.IMO_Item_Code = #{imoItemCode,jdbcType=VARCHAR}
  117. AND imo.DW_WardDm = #{dwWardDm,jdbcType=VARCHAR}
  118. AND imo.IMO_Open_Time <![CDATA[>]]> #{begDate}
  119. AND imo.IMO_Open_Time <![CDATA[<=]]> #{endDate}
  120. AND imo.IMO_Status IN (1, 2, 3, 4, 5)
  121. GROUP BY IMO_ID
  122. ORDER BY imo.IMO_Open_Time DESC
  123. </select>
  124. <select id="selectLongByCode" resultMap="BaseResultMap">
  125. select
  126. <include refid="Base_Column_List" />
  127. from inp_med_order
  128. where IMO_Status IN (1, 2, 3, 4, 5)
  129. and IMO_IsLong = 1
  130. and PatientNo = #{patientNo,jdbcType=VARCHAR}
  131. and HI_ID = #{hiId,jdbcType=INTEGER}
  132. and IMO_Item_Code = #{imoItemCode,jdbcType=VARCHAR}
  133. <if test="begDate != null">
  134. AND (IMO_Stop_Time <![CDATA[>]]> #{begDate,jdbcType=TIMESTAMP} or IMO_Stop_Time is null)
  135. </if>
  136. <if test="endDate != null">
  137. AND IMO_Open_Time <![CDATA[<]]> #{endDate,jdbcType=TIMESTAMP}
  138. </if>
  139. order by IMO_Open_Time
  140. </select>
  141. <select id="selectPatientNoAndOrderCode" resultMap="BaseResultMap">
  142. select
  143. <include refid="Base_Column_List" />
  144. from inp_med_order a
  145. where a.PatientNo = #{patientNo,jdbcType=VARCHAR}
  146. and a.IMO_Status in(1,2,3,4,5)
  147. AND a.IMO_Item_Code in
  148. <foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>#{item} </foreach>
  149. order by a.IMO_Open_Time desc
  150. </select>
  151. <select id="selectByHiId" resultMap="BaseResultMap">
  152. select
  153. <include refid="Base_Column_List" />
  154. from inp_med_order
  155. where IMO_Status <![CDATA[<>]]> -1
  156. <if test="hiId != null">
  157. AND HI_ID = #{hiId,jdbcType=INTEGER}
  158. </if>
  159. <if test="dwWarddm != null">
  160. AND DW_WardDm = #{dwWarddm,jdbcType=VARCHAR}
  161. </if>
  162. <if test="time != null">
  163. AND IMO_Stop_Time <![CDATA[>]]> #{time,jdbcType=TIMESTAMP}
  164. </if>
  165. <if test="time != null">
  166. AND IMO_Open_Time <![CDATA[<=]]> #{time,jdbcType=TIMESTAMP}
  167. </if>
  168. order by IMO_Open_Time desc
  169. </select>
  170. <select id="selectByHiIdOrderCode" resultMap="BaseResultMap">
  171. select
  172. <include refid="Base_Column_List" />
  173. from inp_med_order
  174. where IMO_Status <![CDATA[<>]]> -1
  175. <if test="hiId != null">
  176. AND HI_ID = #{hiId,jdbcType=INTEGER}
  177. </if>
  178. <if test="dwWarddm != null">
  179. AND DW_WardDm = #{dwWarddm,jdbcType=VARCHAR}
  180. </if>
  181. <if test="list != null">
  182. AND IMO_Item_Code in
  183. <foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>#{item} </foreach>
  184. </if>
  185. order by IMO_Open_Time desc
  186. </select>
  187. <select id="selectByHiIdNewOrderCode" resultMap="BaseResultMap">
  188. select
  189. PatientNo,DW_WardDm, DB_BedNo,IMO_Item_Code,IMO_Med_Usage,IMO_Open_Time,IMO_Stop_Time
  190. from inp_med_order
  191. where IMO_Status <![CDATA[<>]]> -1
  192. <if test="hiId != null">
  193. AND HI_ID = #{hiId,jdbcType=INTEGER}
  194. </if>
  195. <if test="dwWarddm != null">
  196. AND DW_WardDm = #{dwWarddm,jdbcType=VARCHAR}
  197. </if>
  198. <if test="list != null">
  199. AND IMO_Item_Code in
  200. <foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>#{item} </foreach>
  201. </if>
  202. order by IMO_Open_Time desc
  203. </select>
  204. <select id="selectByDwWardDm" resultType="java.lang.String">
  205. SELECT PatientNo FROM
  206. inp_med_order
  207. WHERE
  208. DW_WardDm = #{dwWardDm,jdbcType=VARCHAR}
  209. AND IMO_Stop_Time <![CDATA[>]]> #{startTime,jdbcType=TIMESTAMP}
  210. AND IMO_Open_Time <![CDATA[<=]]> #{endTime,jdbcType=TIMESTAMP}
  211. AND IMO_Status IN (1, 2, 3, 4, 5)
  212. </select>
  213. <select id="selectByPatientNos" resultMap="BaseResultMap">
  214. select
  215. <include refid="Base_Column_List" />
  216. from inp_med_order
  217. where IMO_Status IN (1, 2, 3, 4, 5)
  218. AND DW_WardDm = #{dwWarddm,jdbcType=VARCHAR}
  219. AND PatientNo IN
  220. <foreach collection="patientNos" index="index" item="item" separator="," open="(" close=")">
  221. #{item,jdbcType=VARCHAR}
  222. </foreach>
  223. order by IMO_Open_Time desc
  224. </select>
  225. </mapper>