FsPrescribeMapper.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.his.mapper.FsPrescribeMapper">
  6. <resultMap type="FsPrescribe" id="FsPrescribeResult">
  7. <result property="prescribeId" column="prescribe_id" />
  8. <result property="prescribeType" column="prescribe_type" />
  9. <result property="inquiryOrderId" column="inquiry_order_id" />
  10. <result property="storeOrderId" column="store_order_id" />
  11. <result property="userId" column="user_id" />
  12. <result property="patientId" column="patient_id" />
  13. <result property="prescribeCode" column="prescribe_code" />
  14. <result property="patientDescs" column="patient_descs" />
  15. <result property="nowIllness" column="now_illness" />
  16. <result property="historyIllness" column="history_illness" />
  17. <result property="patientAge" column="patient_age" />
  18. <result property="patientName" column="patient_name" />
  19. <result property="weight" column="weight" />
  20. <result property="isHistoryAllergic" column="is_history_allergic" />
  21. <result property="historyAllergic" column="history_allergic" />
  22. <result property="liverUnusual" column="liver_unusual" />
  23. <result property="renalUnusual" column="renal_unusual" />
  24. <result property="isLactation" column="is_lactation" />
  25. <result property="patientTel" column="patient_tel" />
  26. <result property="patientGender" column="patient_gender" />
  27. <result property="recordPic" column="record_pic" />
  28. <result property="prescribeImgUrl" column="prescribe_img_url" />
  29. <result property="auditReason" column="audit_reason" />
  30. <result property="diagnose" column="diagnose" />
  31. <result property="doctorId" column="doctor_id" />
  32. <result property="drugDoctorId" column="drug_doctor_id" />
  33. <result property="createTime" column="create_time" />
  34. <result property="status" column="status" />
  35. <result property="auditTime" column="audit_time" />
  36. <result property="remark" column="remark" />
  37. <result property="usageJson" column="usage_json" />
  38. <result property="storeId" column="store_id" />
  39. <result property="prescribeDoctorId" column="prescribe_doctor_id" />
  40. <result property="doctorSignUrl" column="doctor_sign_url" />
  41. <result property="prescribeDoctorSignUrl" column="prescribe_doctor_sign_url" />
  42. <result property="drugDoctorSignUrl" column="drug_doctor_sign_url" />
  43. <result property="patientBirthday" column="patient_birthday" />
  44. <result property="recipeType" column="recipe_type" />
  45. <result property="prescribeCodeUrl" column="prescribe_code_url" />
  46. <result property="cycle" column="cycle" />
  47. <result property="icdCode" column="icd_code" />
  48. <result property="source" column="source" />
  49. <result property="prescribeImgStoreUrl" column="prescribe_img_store_url" />
  50. </resultMap>
  51. <sql id="selectFsPrescribeVo">
  52. select prescribe_id,prescribe_code_url,prescribe_img_store_url,source,cycle,icd_code,prescribe_type,recipe_type,patient_birthday,drug_doctor_sign_url,prescribe_doctor_id,doctor_sign_url,prescribe_doctor_sign_url, inquiry_order_id, store_order_id, user_id, patient_id, prescribe_code, patient_descs, now_illness, history_illness, patient_age, patient_name, weight, is_history_allergic, history_allergic, liver_unusual, renal_unusual, is_lactation, patient_tel, patient_gender, record_pic, prescribe_img_url, audit_reason, diagnose, doctor_id,drug_doctor_id, create_time, status, audit_time,remark,usage_json,store_id from fs_prescribe
  53. </sql>
  54. <select id="selectFsPrescribeList" parameterType="FsPrescribe" resultMap="FsPrescribeResult">
  55. <include refid="selectFsPrescribeVo"/>
  56. <where>
  57. <if test="prescribeType != null "> and prescribe_type = #{prescribeType}</if>
  58. <if test="inquiryOrderId != null "> and inquiry_order_id = #{inquiryOrderId}</if>
  59. <if test="storeOrderId != null "> and store_order_id = #{storeOrderId}</if>
  60. <if test="userId != null "> and user_id = #{userId}</if>
  61. <if test="patientId != null "> and patient_id = #{patientId}</if>
  62. <if test="prescribeCode != null and prescribeCode != ''"> and prescribe_code = #{prescribeCode}</if>
  63. <if test="patientDescs != null and patientDescs != ''"> and patient_descs = #{patientDescs}</if>
  64. <if test="nowIllness != null and nowIllness != ''"> and now_illness = #{nowIllness}</if>
  65. <if test="historyIllness != null and historyIllness != ''"> and history_illness = #{historyIllness}</if>
  66. <if test="patientAge != null and patientAge != ''"> and patient_age = #{patientAge}</if>
  67. <if test="patientName != null and patientName != ''"> and patient_name like concat('%', #{patientName}, '%')</if>
  68. <if test="weight != null and weight != ''"> and weight = #{weight}</if>
  69. <if test="isHistoryAllergic != null and isHistoryAllergic != ''"> and is_history_allergic = #{isHistoryAllergic}</if>
  70. <if test="historyAllergic != null and historyAllergic != ''"> and history_allergic = #{historyAllergic}</if>
  71. <if test="liverUnusual != null and liverUnusual != ''"> and liver_unusual = #{liverUnusual}</if>
  72. <if test="renalUnusual != null and renalUnusual != ''"> and renal_unusual = #{renalUnusual}</if>
  73. <if test="isLactation != null and isLactation != ''"> and is_lactation = #{isLactation}</if>
  74. <if test="patientTel != null and patientTel != ''"> and patient_tel = #{patientTel}</if>
  75. <if test="patientGender != null and patientGender != ''"> and patient_gender = #{patientGender}</if>
  76. <if test="recordPic != null and recordPic != ''"> and record_pic = #{recordPic}</if>
  77. <if test="prescribeImgUrl != null and prescribeImgUrl != ''"> and prescribe_img_url = #{prescribeImgUrl}</if>
  78. <if test="auditReason != null and auditReason != ''"> and audit_reason = #{auditReason}</if>
  79. <if test="diagnose != null and diagnose != ''"> and diagnose = #{diagnose}</if>
  80. <if test="doctorId != null and doctorId != ''"> and doctor_id = #{doctorId}</if>
  81. <if test="status != null "> and status = #{status}</if>
  82. <if test="auditTime != null "> and audit_time = #{auditTime}</if>
  83. </where>
  84. order by prescribe_id desc
  85. </select>
  86. <select id="selectFsPrescribeByPrescribeId" parameterType="Long" resultMap="FsPrescribeResult">
  87. <include refid="selectFsPrescribeVo"/>
  88. where prescribe_id = #{prescribeId}
  89. </select>
  90. <insert id="insertFsPrescribe" parameterType="FsPrescribe" useGeneratedKeys="true" keyProperty="prescribeId">
  91. insert into fs_prescribe
  92. <trim prefix="(" suffix=")" suffixOverrides=",">
  93. <if test="prescribeType != null">prescribe_type,</if>
  94. <if test="inquiryOrderId != null">inquiry_order_id,</if>
  95. <if test="storeOrderId != null">store_order_id,</if>
  96. <if test="userId != null">user_id,</if>
  97. <if test="patientId != null">patient_id,</if>
  98. <if test="prescribeCode != null">prescribe_code,</if>
  99. <if test="patientDescs != null">patient_descs,</if>
  100. <if test="nowIllness != null">now_illness,</if>
  101. <if test="historyIllness != null">history_illness,</if>
  102. <if test="patientAge != null">patient_age,</if>
  103. <if test="patientName != null">patient_name,</if>
  104. <if test="weight != null">weight,</if>
  105. <if test="isHistoryAllergic != null">is_history_allergic,</if>
  106. <if test="historyAllergic != null">history_allergic,</if>
  107. <if test="liverUnusual != null">liver_unusual,</if>
  108. <if test="renalUnusual != null">renal_unusual,</if>
  109. <if test="isLactation != null">is_lactation,</if>
  110. <if test="patientTel != null">patient_tel,</if>
  111. <if test="patientGender != null">patient_gender,</if>
  112. <if test="recordPic != null">record_pic,</if>
  113. <if test="prescribeImgUrl != null">prescribe_img_url,</if>
  114. <if test="auditReason != null">audit_reason,</if>
  115. <if test="diagnose != null">diagnose,</if>
  116. <if test="doctorId != null">doctor_id,</if>
  117. <if test="drugDoctorId != null">drug_doctor_id,</if>
  118. <if test="createTime != null">create_time,</if>
  119. <if test="status != null">status,</if>
  120. <if test="auditTime != null">audit_time,</if>
  121. <if test="remark != null">remark,</if>
  122. <if test="usageJson != null">usage_json,</if>
  123. <if test="storeId != null">store_id,</if>
  124. <if test="prescribeDoctorId != null">prescribe_doctor_id,</if>
  125. <if test="doctorSignUrl != null">doctor_sign_url,</if>
  126. <if test="prescribeDoctorSignUrl != null">prescribe_doctor_sign_url,</if>
  127. <if test="drugDoctorSignUrl != null">drug_doctor_sign_url,</if>
  128. <if test="patientBirthday != null">patient_birthday,</if>
  129. <if test="recipeType != null">recipe_type,</if>
  130. <if test="prescribeCodeUrl != null">prescribe_code_url,</if>
  131. <if test="cycle != null">cycle,</if>
  132. <if test="icdCode != null">icd_code,</if>
  133. <if test="source != null">source,</if>
  134. <if test="prescribeImgStoreUrl != null">prescribe_img_store_url,</if>
  135. </trim>
  136. <trim prefix="values (" suffix=")" suffixOverrides=",">
  137. <if test="prescribeType != null">#{prescribeType},</if>
  138. <if test="inquiryOrderId != null">#{inquiryOrderId},</if>
  139. <if test="storeOrderId != null">#{storeOrderId},</if>
  140. <if test="userId != null">#{userId},</if>
  141. <if test="patientId != null">#{patientId},</if>
  142. <if test="prescribeCode != null">#{prescribeCode},</if>
  143. <if test="patientDescs != null">#{patientDescs},</if>
  144. <if test="nowIllness != null">#{nowIllness},</if>
  145. <if test="historyIllness != null">#{historyIllness},</if>
  146. <if test="patientAge != null">#{patientAge},</if>
  147. <if test="patientName != null">#{patientName},</if>
  148. <if test="weight != null">#{weight},</if>
  149. <if test="isHistoryAllergic != null">#{isHistoryAllergic},</if>
  150. <if test="historyAllergic != null">#{historyAllergic},</if>
  151. <if test="liverUnusual != null">#{liverUnusual},</if>
  152. <if test="renalUnusual != null">#{renalUnusual},</if>
  153. <if test="isLactation != null">#{isLactation},</if>
  154. <if test="patientTel != null">#{patientTel},</if>
  155. <if test="patientGender != null">#{patientGender},</if>
  156. <if test="recordPic != null">#{recordPic},</if>
  157. <if test="prescribeImgUrl != null">#{prescribeImgUrl},</if>
  158. <if test="auditReason != null">#{auditReason},</if>
  159. <if test="diagnose != null">#{diagnose},</if>
  160. <if test="doctorId != null">#{doctorId},</if>
  161. <if test="drugDoctorId != null">#{drugDoctorId},</if>
  162. <if test="createTime != null">#{createTime},</if>
  163. <if test="status != null">#{status},</if>
  164. <if test="auditTime != null">#{auditTime},</if>
  165. <if test="remark != null">#{remark},</if>
  166. <if test="usageJson != null">#{usageJson},</if>
  167. <if test="storeId != null">#{storeId},</if>
  168. <if test="prescribeDoctorId != null">#{prescribeDoctorId},</if>
  169. <if test="doctorSignUrl != null">#{doctorSignUrl},</if>
  170. <if test="prescribeDoctorSignUrl != null">#{prescribeDoctorSignUrl},</if>
  171. <if test="drugDoctorSignUrl != null">#{drugDoctorSignUrl},</if>
  172. <if test="patientBirthday != null">#{patientBirthday},</if>
  173. <if test="recipeType != null">#{recipeType},</if>
  174. <if test="prescribeCodeUrl != null">#{prescribeCodeUrl},</if>
  175. <if test="cycle != null">#{cycle},</if>
  176. <if test="icdCode != null">#{icdCode},</if>
  177. <if test="source != null">#{source},</if>
  178. <if test="prescribeImgStoreUrl != null">#{prescribeImgStoreUrl},</if>
  179. </trim>
  180. </insert>
  181. <update id="updateFsPrescribe" parameterType="FsPrescribe">
  182. update fs_prescribe
  183. <trim prefix="SET" suffixOverrides=",">
  184. <if test="prescribeType != null">prescribe_type = #{prescribeType},</if>
  185. <if test="inquiryOrderId != null">inquiry_order_id = #{inquiryOrderId},</if>
  186. <if test="storeOrderId != null">store_order_id = #{storeOrderId},</if>
  187. <if test="userId != null">user_id = #{userId},</if>
  188. <if test="patientId != null">patient_id = #{patientId},</if>
  189. <if test="prescribeCode != null">prescribe_code = #{prescribeCode},</if>
  190. <if test="patientDescs != null">patient_descs = #{patientDescs},</if>
  191. <if test="nowIllness != null">now_illness = #{nowIllness},</if>
  192. <if test="historyIllness != null">history_illness = #{historyIllness},</if>
  193. <if test="patientAge != null">patient_age = #{patientAge},</if>
  194. <if test="patientName != null">patient_name = #{patientName},</if>
  195. <if test="weight != null">weight = #{weight},</if>
  196. <if test="isHistoryAllergic != null">is_history_allergic = #{isHistoryAllergic},</if>
  197. <if test="historyAllergic != null">history_allergic = #{historyAllergic},</if>
  198. <if test="liverUnusual != null">liver_unusual = #{liverUnusual},</if>
  199. <if test="renalUnusual != null">renal_unusual = #{renalUnusual},</if>
  200. <if test="isLactation != null">is_lactation = #{isLactation},</if>
  201. <if test="patientTel != null">patient_tel = #{patientTel},</if>
  202. <if test="patientGender != null">patient_gender = #{patientGender},</if>
  203. <if test="recordPic != null">record_pic = #{recordPic},</if>
  204. <if test="prescribeImgUrl != null">prescribe_img_url = #{prescribeImgUrl},</if>
  205. <if test="auditReason != null">audit_reason = #{auditReason},</if>
  206. <if test="diagnose != null">diagnose = #{diagnose},</if>
  207. <if test="doctorId != null">doctor_id = #{doctorId},</if>
  208. <if test="drugDoctorId != null">drug_doctor_id = #{drugDoctorId},</if>
  209. <if test="createTime != null">create_time = #{createTime},</if>
  210. <if test="status != null">status = #{status},</if>
  211. <if test="auditTime != null">audit_time = #{auditTime},</if>
  212. <if test="remark != null">remark = #{remark},</if>
  213. <if test="usageJson != null">usage_json = #{usageJson},</if>
  214. <if test="storeId != null">store_id = #{storeId},</if>
  215. <if test="prescribeDoctorId != null">prescribe_doctor_id = #{prescribeDoctorId},</if>
  216. <if test="doctorSignUrl != null">doctor_sign_url = #{doctorSignUrl},</if>
  217. <if test="prescribeDoctorSignUrl != null">prescribe_doctor_sign_url = #{prescribeDoctorSignUrl},</if>
  218. <if test="drugDoctorSignUrl != null">drug_doctor_sign_url = #{drugDoctorSignUrl},</if>
  219. <if test="patientBirthday != null">patient_birthday = #{patientBirthday},</if>
  220. <if test="recipeType != null">recipe_type = #{recipeType},</if>
  221. <if test="prescribeCodeUrl != null">prescribe_code_url = #{prescribeCodeUrl},</if>
  222. <if test="cycle != null">cycle = #{cycle},</if>
  223. <if test="icdCode != null">icd_code = #{icdCode},</if>
  224. <if test="source != null">source = #{source},</if>
  225. <if test="prescribeImgStoreUrl != null">prescribe_img_store_url = #{prescribeImgStoreUrl},</if>
  226. </trim>
  227. where prescribe_id = #{prescribeId}
  228. </update>
  229. <delete id="deleteFsPrescribeByPrescribeId" parameterType="Long">
  230. delete from fs_prescribe where prescribe_id = #{prescribeId}
  231. </delete>
  232. <delete id="deleteFsPrescribeByPrescribeIds" parameterType="String">
  233. delete from fs_prescribe where prescribe_id in
  234. <foreach item="prescribeId" collection="array" open="(" separator="," close=")">
  235. #{prescribeId}
  236. </foreach>
  237. </delete>
  238. <select id="selectFsPrescribeListVO_COUNT" parameterType="com.fs.his.param.FsStoreOrderParam" resultType="Long">
  239. select count(1) from fs_prescribe so
  240. <if test="companyId != null or companyUserId != null or orderCode != null or orderStatus != null "> LEFT JOIN fs_store_order fso ON fso.order_id = so.store_order_id </if>
  241. <if test="doctorName != null and doctorName != ''"> LEFT JOIN fs_doctor dc ON dc.doctor_id = so.doctor_id </if>
  242. where 1=1
  243. <if test="companyId != null "> and fso.company_id = #{companyId}</if>
  244. <if test="companyUserId != null "> and fso.company_user_id = #{companyUserId}</if>
  245. <if test="prescribeType != null "> and so.prescribe_type = #{prescribeType}</if>
  246. <if test="inquiryOrderId != null "> and so.inquiry_order_id = #{inquiryOrderId}</if>
  247. <if test="storeOrderId != null "> and so.store_order_id = #{storeOrderId}</if>
  248. <if test="userId != null "> and so.user_id = #{userId}</if>
  249. <if test="prescribeCode != null and prescribeCode != ''"> and so.prescribe_code = #{prescribeCode}</if>
  250. <if test="patientName != null and patientName != ''"> and so.patient_name like concat('%', #{patientName}, '%')</if>
  251. <if test="doctorName != null and doctorName != ''"> and dc.doctor_name like concat('%', #{doctorName}, '%')</if>
  252. <if test="patientTel != null and patientTel != ''"> and so.patient_tel = #{patientTel}</if>
  253. <if test="doctorId != null and doctorId != ''"> and so.doctor_id = #{doctorId}</if>
  254. <if test="status != null "> and so.status = #{status}</if>
  255. <if test="sTime != null "> and DATE(so.create_time) &gt;= DATE(#{sTime})</if>
  256. <if test="eTime != null "> and DATE(so.create_time) &lt;= DATE(#{eTime})</if>
  257. <if test="auditSTime != null "> and DATE(so.audit_time) &gt;= DATE(#{auditSTime})</if>
  258. <if test="auditETime != null "> and DATE(so.audit_time) &lt;= DATE(#{auditETime})</if>
  259. <if test="auditTime != null "> and so.audit_time = #{auditTime}</if>
  260. <if test="orderCode != null "> and fso.order_code = #{orderCode}</if>
  261. <if test="orderStatus != null "> and fso.`status` = #{orderStatus}</if>
  262. <if test="storeId != null "> and so.store_id = #{storeId}</if>
  263. </select>
  264. <select id="selectFsPrescribeListVOWithConfirm" resultType="com.fs.his.vo.FsPrescribeListVO">
  265. select so.*,us.nick_name,dc.doctor_name,
  266. dp.doctor_name doctor_drug_name,
  267. fso.order_code,fso.`status` order_status,
  268. fse.store_name FROM fs_prescribe so
  269. LEFT JOIN fs_user us ON us.user_id=so.user_id
  270. LEFT JOIN fs_doctor dc ON dc.doctor_id = so.doctor_id
  271. LEFT JOIN fs_doctor dp ON dp.doctor_id =so.drug_doctor_id
  272. LEFT JOIN fs_store_order fso ON fso.order_id = so.store_order_id
  273. LEFT JOIN fs_store fse ON fse.store_id = so.store_id
  274. <where>
  275. doctor_confirm != -1
  276. <if test="companyId != null "> and fso.company_id = #{companyId}</if>
  277. <if test="companyUserId != null "> and fso.company_user_id = #{companyUserId}</if>
  278. <if test="prescribeType != null "> and so.prescribe_type = #{prescribeType}</if>
  279. <if test="inquiryOrderId != null "> and so.inquiry_order_id = #{inquiryOrderId}</if>
  280. <if test="storeOrderId != null "> and so.store_order_id = #{storeOrderId}</if>
  281. <if test="userId != null "> and so.user_id = #{userId}</if>
  282. <if test="prescribeCode != null and prescribeCode != ''"> and so.prescribe_code = #{prescribeCode}</if>
  283. <if test="patientName != null and patientName != ''"> and so.patient_name like concat('%', #{patientName}, '%')</if>
  284. <if test="doctorName != null and doctorName != ''"> and dc.doctor_name like concat('%', #{doctorName}, '%')</if>
  285. <if test="patientTel != null and patientTel != ''"> and so.patient_tel = #{patientTel}</if>
  286. <if test="doctorId != null and doctorId != ''"> and so.doctor_id = #{doctorId}</if>
  287. <if test="status != null "> and so.status = #{status}</if>
  288. <if test="sTime != null "> and DATE(so.create_time) &gt;= DATE(#{sTime})</if>
  289. <if test="eTime != null "> and DATE(so.create_time) &lt;= DATE(#{eTime})</if>
  290. <if test="auditSTime != null "> and DATE(so.audit_time) &gt;= DATE(#{auditSTime})</if>
  291. <if test="auditETime != null "> and DATE(so.audit_time) &lt;= DATE(#{auditETime})</if>
  292. <if test="auditTime != null "> and so.audit_time = #{auditTime}</if>
  293. <if test="orderCode != null "> and fso.order_code = #{orderCode}</if>
  294. <if test="orderStatus != null "> and fso.`status` = #{orderStatus}</if>
  295. <if test="storeId != null "> and so.store_id = #{storeId}</if>
  296. </where>
  297. order by prescribe_id desc
  298. </select>
  299. </mapper>