YpZdDictMapper.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. package cn.hnthyy.thmz.mapper.his.yp;
  2. import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
  3. import org.apache.ibatis.annotations.Insert;
  4. import org.apache.ibatis.annotations.Param;
  5. import org.apache.ibatis.annotations.Select;
  6. import org.apache.ibatis.annotations.Update;
  7. import java.util.List;
  8. public interface YpZdDictMapper {
  9. /**
  10. * 根据药品编码和规格查询药品信息
  11. *
  12. * @param code
  13. * @return
  14. */
  15. @Select("select code, serial, name, class_code, dosage, concentration, weight, weigh_unit, volum, vol_unit, mini_unit," +
  16. " pack_size, pack_unit, ltrim(specification)specification, ltrim(specification2)specification2, pack_retprice, retprice, percent_group_mz, percent_group_zy," +
  17. " self_flag, separate_flag, suprice_flag, drug_flag, py_code, d_code as wb_code, infusion_flag, visible_flag, del_flag," +
  18. " country_flag, fix_price, new_flag, manu_code, yb_flag, sort_code, gmp_flag, cold_flag, chem_remark, drug_kind," +
  19. " zb_flag, zb_supplyer, n_code as yn_code, bill_item_mz, bill_item_zy, supply_type, rtrim(frequency)frequency, ps_flag, ex_code, kss_flag," +
  20. " zj_flag, spec_b, yb_code, yb_type, yb_code_zf, init_flag, yp_level, drug_id, serial_old, spec_pack, xnh_flag," +
  21. " buy_price, self_flag_yb, order_dosage, dosage_unit, yb_comment, isnull(rtrim(jb_flag),0) jb_flag, location, zs_flag, rtrim(audit_code)audit_code, comment," +
  22. " categories_flag, father_flag, ybxj_price, ym_flag, dpym_flag, yb_comment2, yb_code2, rtrim(kjyw_flag)kjyw_flag, ygyyjc_type," +
  23. " ddd_value, kj_limit_flag, yp_id, xtpp_name, sp_name, qj_flag, js_flag, rtrim(pzwh)pzwh, xnh_code, xnh_name, xnh_ratio," +
  24. " xnh_quotamoney, xnh_status, xnh_bl, city_bl, syb_bl, cl_flag, avg_price, yb_flag_city, yb_flag_xnh, yb_code_city," +
  25. " yb_code_xnh, yb_comment_city, yb_comment_xnh, ddd_unit, wg_type, fh_name, yb_flag_new, yb_comment_new, rtrim(yb_bl_new)yb_bl_new," +
  26. " wjw_ypid, yjj_ypid, rsb_ypid, mz_restrict, isnull(byj_flag,0) byj_flag, national_code, national_name, national_status, match_oper," +
  27. " match_date, cancel_match_oper, cancel_match_date, new_name, oper_id, oper_date, uploaded_flag, prescription_limit_days," +
  28. " isnull(fz_flag,0)fz_flag,isnull(is_central_purchase,0)is_central_purchase,purchase_code,drug_control_code,selfpay_prop" +
  29. " from yp_zd_dict WITH(NOLOCK) where code = #{code,jdbcType=VARCHAR} and serial = #{serial}")
  30. YpZdDict selectYpZdDictByCodeAndSerial(@Param("code") String code, @Param("serial") String serial);
  31. /**
  32. * 根据药品编码集合查询药品字典列表
  33. *
  34. * @param codes
  35. * @return
  36. */
  37. @Select({"<script>",
  38. "select code, serial, name, class_code, dosage, concentration, weight, weigh_unit, volum, vol_unit, mini_unit," +
  39. " pack_size, pack_unit, ltrim(specification)specification, ltrim(specification2)specification2, pack_retprice, retprice, percent_group_mz, percent_group_zy," +
  40. " self_flag, separate_flag, suprice_flag, drug_flag, py_code, d_code as wb_code, infusion_flag, visible_flag, del_flag," +
  41. " country_flag, fix_price, new_flag, manu_code, yb_flag, sort_code, gmp_flag, cold_flag, chem_remark, drug_kind," +
  42. " zb_flag, zb_supplyer, n_code as yn_code, bill_item_mz, bill_item_zy, supply_type, rtrim(frequency)frequency, ps_flag, ex_code, kss_flag," +
  43. " zj_flag, spec_b, yb_code, yb_type, yb_code_zf, init_flag, yp_level, drug_id, serial_old, spec_pack, xnh_flag," +
  44. " buy_price, self_flag_yb, order_dosage, dosage_unit, yb_comment, isnull(rtrim(jb_flag),0) jb_flag, location, zs_flag, rtrim(audit_code)audit_code, comment," +
  45. " categories_flag, father_flag, ybxj_price, ym_flag, dpym_flag, yb_comment2, yb_code2, rtrim(kjyw_flag)kjyw_flag, ygyyjc_type," +
  46. " ddd_value, kj_limit_flag, yp_id, xtpp_name, sp_name, qj_flag, js_flag, rtrim(pzwh)pzwh, xnh_code, xnh_name, xnh_ratio," +
  47. " xnh_quotamoney, xnh_status, xnh_bl, city_bl, syb_bl, cl_flag, avg_price, yb_flag_city, yb_flag_xnh, yb_code_city," +
  48. " yb_code_xnh, yb_comment_city, yb_comment_xnh, ddd_unit, wg_type, fh_name, yb_flag_new, yb_comment_new, rtrim(yb_bl_new)yb_bl_new," +
  49. " wjw_ypid, yjj_ypid, rsb_ypid, mz_restrict, isnull(byj_flag,0) byj_flag, national_code, national_name, national_status, match_oper," +
  50. " match_date, cancel_match_oper, cancel_match_date, new_name, oper_id, oper_date, uploaded_flag, prescription_limit_days," +
  51. " isnull(fz_flag,0)fz_flag,isnull(is_central_purchase,0)is_central_purchase,purchase_code,drug_control_code,selfpay_prop" +
  52. " from yp_zd_dict WITH(NOLOCK)",
  53. "<when test='codes!=null'>",
  54. " where code in",
  55. "<foreach item='item' index='index' collection='codes' open='(' separator=',' close=')'>",
  56. "#{item}",
  57. "</foreach>",
  58. "</when>",
  59. "</script>"})
  60. List<YpZdDict> selectYpZdDictByCodeList(@Param("codes") List<String> codes);
  61. /**
  62. * 根据药品编码查询药品信息
  63. *
  64. * @param code
  65. * @return
  66. */
  67. @Select("select code, serial, name, class_code, dosage, concentration, weight, weigh_unit, volum, vol_unit, mini_unit," +
  68. " pack_size, pack_unit, ltrim(specification)specification, ltrim(specification2)specification2, pack_retprice, retprice, percent_group_mz, percent_group_zy," +
  69. " self_flag, separate_flag, suprice_flag, drug_flag, py_code, d_code as wb_code, infusion_flag, visible_flag, del_flag," +
  70. " country_flag, fix_price, new_flag, manu_code, yb_flag, sort_code, gmp_flag, cold_flag, chem_remark, drug_kind," +
  71. " zb_flag, zb_supplyer, n_code as yn_code, bill_item_mz, bill_item_zy, supply_type, rtrim(frequency)frequency, ps_flag, ex_code, kss_flag," +
  72. " zj_flag, spec_b, yb_code, yb_type, yb_code_zf, init_flag, yp_level, drug_id, serial_old, spec_pack, xnh_flag," +
  73. " buy_price, self_flag_yb, order_dosage, dosage_unit, yb_comment, isnull(rtrim(jb_flag),0) jb_flag, location, zs_flag, rtrim(audit_code)audit_code, comment," +
  74. " categories_flag, father_flag, ybxj_price, ym_flag, dpym_flag, yb_comment2, yb_code2, rtrim(kjyw_flag)kjyw_flag, ygyyjc_type," +
  75. " ddd_value, kj_limit_flag, yp_id, xtpp_name, sp_name, qj_flag, js_flag, rtrim(pzwh)pzwh, xnh_code, xnh_name, xnh_ratio," +
  76. " xnh_quotamoney, xnh_status, xnh_bl, city_bl, syb_bl, cl_flag, avg_price, yb_flag_city, yb_flag_xnh, yb_code_city," +
  77. " yb_code_xnh, yb_comment_city, yb_comment_xnh, ddd_unit, wg_type, fh_name, yb_flag_new, yb_comment_new, rtrim(yb_bl_new)yb_bl_new," +
  78. " wjw_ypid, yjj_ypid, rsb_ypid, mz_restrict, isnull(byj_flag,0) byj_flag, national_code, national_name, national_status, match_oper," +
  79. " match_date, cancel_match_oper, cancel_match_date, new_name, oper_id, oper_date, uploaded_flag, prescription_limit_days," +
  80. " isnull(fz_flag,0)fz_flag,isnull(is_central_purchase,0)is_central_purchase,purchase_code,drug_control_code,selfpay_prop" +
  81. " from yp_zd_dict WITH(NOLOCK) where code = #{code,jdbcType=VARCHAR} ")
  82. List<YpZdDict> selectYpZdDictByCode(@Param("code") String code);
  83. /**
  84. * 模糊查询药品关联药库
  85. *
  86. * @param searchTextDrug
  87. * @return
  88. */
  89. @Select("SELECT distinct a.code," +
  90. " a.serial," +
  91. " a.name," +
  92. " a.pack_size," +
  93. " a.pack_retprice," +
  94. " ltrim(a.specification)specification," +
  95. " a.drug_flag ," +
  96. " a.fix_price," +
  97. " a.manu_code," +
  98. " a.del_flag," +
  99. " a.class_code," +
  100. " a.prescription_limit_days," +
  101. " a.mz_restrict" +
  102. " FROM yp_zd_dict a WITH(NOLOCK) ,yp_print_name b WITH(NOLOCK) , yp_base c WITH(NOLOCK) " +
  103. " where" +
  104. " (b.py_code like '%${searchTextDrug}%' or a.py_code like '%${searchTextDrug}%' or" +
  105. " b.d_code like '%${searchTextDrug}%' or a.d_code like '%${searchTextDrug}%' or" +
  106. " b.charge_code = #{searchTextDrug} or" +
  107. " b.print_name like '%${searchTextDrug}%' or a.name like '%${searchTextDrug}%') and" +
  108. " a.code=b.charge_code and" +
  109. " a.code=c.charge_code order by a.del_flag")
  110. List<YpZdDict> selectYpBySearchText(@Param("searchTextDrug") String searchTextDrug);
  111. /**
  112. * 模糊查询所有药品
  113. *
  114. * @param searchText
  115. * @return
  116. */
  117. @Select("select d.code, d.serial, d.name, d.class_code, d.dosage, d.concentration, d.weight, d.weigh_unit, d.volum, d.vol_unit, d.mini_unit," +
  118. " pack_size, d.pack_unit, ltrim(d.specification)specification, ltrim(d.specification2)specification2, d.pack_retprice, d.retprice, d.percent_group_mz, d.percent_group_zy," +
  119. " self_flag, d.separate_flag, d.suprice_flag, d.drug_flag, d.py_code, d.d_code as wb_code, d.infusion_flag, d.visible_flag, d.del_flag," +
  120. " country_flag, d.fix_price, d.new_flag, d.manu_code, d.yb_flag, d.sort_code, d.gmp_flag, d.cold_flag, d.chem_remark, d.drug_kind," +
  121. " zb_flag, d.zb_supplyer, d.n_code as yn_code, d.bill_item_mz, d.bill_item_zy, d.supply_type, rtrim(d.frequency)frequency, d.ps_flag, d.ex_code, d.kss_flag," +
  122. " zj_flag, d.spec_b, d.yb_code, d.yb_type, d.yb_code_zf, d.init_flag, d.yp_level, d.drug_id, d.serial_old, d.spec_pack, d.xnh_flag," +
  123. " buy_price, d.self_flag_yb, d.order_dosage, d.dosage_unit, d.yb_comment, isnull(rtrim(jb_flag),0) jb_flag, d.location, d.zs_flag, rtrim(d.audit_code)audit_code, d.comment," +
  124. " categories_flag, d.father_flag, d.ybxj_price, d.ym_flag, d.dpym_flag, d.yb_comment2, d.yb_code2, rtrim(d.kjyw_flag)kjyw_flag, d.ygyyjc_type," +
  125. " ddd_value, d.kj_limit_flag, d.yp_id, d.xtpp_name, d.sp_name, d.qj_flag, d.js_flag, rtrim(d.pzwh)pzwh, d.xnh_code, d.xnh_name, d.xnh_ratio," +
  126. " xnh_quotamoney, d.xnh_status, d.xnh_bl, d.city_bl, d.syb_bl, d.cl_flag, d.avg_price, d.yb_flag_city, d.yb_flag_xnh, d.yb_code_city," +
  127. " yb_code_xnh, d.yb_comment_city, d.yb_comment_xnh, d.ddd_unit, d.wg_type, d.fh_name, d.yb_flag_new, d.yb_comment_new, rtrim(d.yb_bl_new)yb_bl_new," +
  128. " wjw_ypid, d.yjj_ypid, d.rsb_ypid, d.mz_restrict, isnull(byj_flag,0) byj_flag, d.national_code, d.national_name, d.national_status, d.match_oper," +
  129. " match_date, d.cancel_match_oper, d.cancel_match_date, d.new_name, d.oper_id, d.oper_date, d.uploaded_flag, d.prescription_limit_days,d.antitumor_level," +
  130. " isnull(fz_flag,0)fz_flag,isnull(is_central_purchase,0)is_central_purchase,purchase_code,drug_control_code,selfpay_prop" +
  131. " from " +
  132. " (select a.code, max(a.serial)serial" +
  133. " FROM yp_zd_dict a WITH(NOLOCK) ,yp_print_name b WITH(NOLOCK) " +
  134. " where" +
  135. " (b.py_code like '%${searchText}%' or a.py_code like '%${searchText}%' or" +
  136. " b.d_code like '%${searchText}%' or a.d_code like '%${searchText}%' or" +
  137. " b.charge_code = #{searchText} or" +
  138. " b.print_name like '%${searchText}%' or a.name like '%${searchText}%') and" +
  139. " a.code=b.charge_code group by a.code)as cc,yp_zd_dict d where cc.code=d.code and cc.serial=d.serial order by d.del_flag")
  140. List<YpZdDict> selectYpZdDictByLike(@Param("searchText") String searchText);
  141. /**
  142. * 更新药品处方限制天数
  143. *
  144. * @param prescriptionLimitDays
  145. * @param code
  146. * @return
  147. */
  148. @Update("update yp_zd_dict set prescription_limit_days=#{prescriptionLimitDays} where code = #{code}")
  149. int updateYpZdDictPrescriptionLimitDays(@Param("prescriptionLimitDays") Integer prescriptionLimitDays, @Param("code") String code);
  150. /**
  151. * 更新药品门诊月限购量
  152. *
  153. * @param mzRestrict
  154. * @param code
  155. * @return
  156. */
  157. @Update("update yp_zd_dict set mz_restrict=#{mzRestrict} where code = #{code}")
  158. int updateYpZdDictMzRestrict(@Param("mzRestrict") Integer mzRestrict, @Param("code") String code);
  159. /**
  160. * 更新药品信息
  161. *
  162. * @return
  163. */
  164. @Update({"<script>",
  165. "update yp_zd_dict ",
  166. "<trim prefix='set' prefixOverrides=',' >",
  167. "<when test='packRetprice!=null'>",
  168. ",pack_retprice =#{packRetprice,jdbcType=DOUBLE}",
  169. "</when>",
  170. "<when test='retprice!=null'>",
  171. ",retprice =#{retprice,jdbcType=DOUBLE}",
  172. "</when>",
  173. "<when test='buyPrice!=null'>",
  174. ",buy_price =#{buyPrice,jdbcType=DOUBLE}",
  175. "</when>",
  176. "<when test='fixPrice!=null'>",
  177. ",fix_price =#{fixPrice,jdbcType=DOUBLE}",
  178. "</when>",
  179. "<when test='ybxjPrice!=null'>",
  180. ",ybxj_price =#{ybxjPrice,jdbcType=DOUBLE}",
  181. "</when>",
  182. "<when test='avgPrice!=null'>",
  183. ",avg_price =#{avgPrice,jdbcType=DOUBLE}",
  184. "</when>",
  185. "<when test='manuCode!=null'>",
  186. ",manu_code =#{manuCode}",
  187. "</when>",
  188. "</trim>" +
  189. "<where>" +
  190. " <if test=\"code != null and code != ''\">" +
  191. " AND code = #{code}" +
  192. " </if>" +
  193. " <if test=\"serial != null and serial != ''\">" +
  194. " AND serial = #{serial}" +
  195. " </if>" +
  196. "</where>",
  197. "</script>"})
  198. int updateYpZdDict(YpZdDict ypZdDict);
  199. /**
  200. * 更新药品信息
  201. *
  202. * @return
  203. */
  204. @Update({"<script>",
  205. "update yp_zd_dict set ${sql} where code = #{code} AND serial = #{serial}",
  206. "</script>"})
  207. int updateYpZdDictSql(@Param("sql") String sql, @Param("code") String code, @Param("serial") String serial);
  208. /**
  209. * 大包装同步小包装数据
  210. *
  211. * @return
  212. */
  213. @Update({"<script>",
  214. "update yp_zd_dict set" +
  215. " yp_zd_dict.name =b.name , py_code =b.py_code , d_code =b.d_code , specification =b.specification2 , specification2 =b.specification2 ," +
  216. " class_code =b.class_code , dosage =b.dosage , concentration =b.concentration , weight =b.weight , weigh_unit =b.weigh_unit ," +
  217. " volum =b.volum , vol_unit =b.vol_unit , mini_unit =b.mini_unit , pack_unit =b.mini_unit , self_flag =b.self_flag ," +
  218. " separate_flag =b.separate_flag , suprice_flag =b.suprice_flag , drug_flag =b.drug_flag , infusion_flag =b.infusion_flag ," +
  219. " country_flag =b.country_flag , manu_code =b.manu_code , drug_kind =b.drug_kind , gmp_flag =b.gmp_flag , cold_flag =b.cold_flag ," +
  220. " chem_remark =b.chem_remark , bill_item_mz =b.bill_item_mz , bill_item_zy =b.bill_item_zy , percent_group_mz =b.percent_group_mz ," +
  221. " percent_group_zy =b.percent_group_zy , del_flag =b.del_flag , yb_flag =b.yb_flag , self_flag_yb =b.self_flag_yb , n_code =b.n_code , zb_flag =b.zb_flag ," +
  222. " zb_supplyer =b.zb_supplyer , ps_flag =b.ps_flag , ex_code =b.ex_code , supply_type =b.supply_type , frequency =rtrim(b.frequency) ," +
  223. " kss_flag =b.kss_flag , yp_level =b.yp_level , drug_id =b.drug_id , yb_code =b.yb_code, yb_comment =b.yb_comment , xnh_flag =b.xnh_flag , jb_flag =b.jb_flag ," +
  224. " audit_code =b.audit_code , comment =b.comment , categories_flag =b.categories_flag , ym_flag =b.ym_flag , dpym_flag =b.dpym_flag ," +
  225. " father_flag =b.father_flag , yb_code2 =b.yb_code2 , yb_comment2 =b.yb_comment2 , kjyw_flag =rtrim(b.kjyw_flag) , ygyyjc_type =b.ygyyjc_type ," +
  226. " ddd_value =b.ddd_value , yp_id =b.yp_id , xtpp_name =b.xtpp_name , sp_name =b.sp_name , yb_comment_new =b.yb_comment_new ," +
  227. " yb_bl_new =b.yb_bl_new , yb_flag_new =b.yb_flag_new , byj_flag =b.byj_flag,drug_control_code =b.drug_control_code,antitumor_level=b.antitumor_level" +
  228. " from ( select *from yp_zd_dict ) as b" +
  229. " where yp_zd_dict.code =#{code} and yp_zd_dict.serial !=#{serial} and yp_zd_dict.code =b.code and b.serial =#{serial}",
  230. "</script>"})
  231. int updateYpZdDictSync(@Param("code") String code, @Param("serial") String serial);
  232. /**
  233. * 获取范围内最大code
  234. *
  235. * @return
  236. */
  237. @Select("select max ( code ) from yp_zd_dict WITH(NOLOCK) where code >= #{minNum} and code <= #{maxNum}")
  238. String selectMaxCode(@Param("minNum") String minNum, @Param("maxNum") String maxNum);
  239. /**
  240. * 新增药品
  241. *
  242. * @return
  243. */
  244. @Insert("INSERT INTO yp_zd_dict ${sql}")
  245. int insertYpZdDictSql(@Param("sql") String sql);
  246. /**
  247. * 查询入库药品名称
  248. *
  249. * @return
  250. */
  251. @Select("select name,code from yp_zd_dict where code = #{code} group by name,code ")
  252. YpZdDict selectNameByCode(@Param("code") String code);
  253. /**
  254. * 根据输入参数模糊查询药品列表
  255. *
  256. * @param code
  257. * @return
  258. */
  259. @Select({"<script>",
  260. "select rtrim(code) code,rtrim(name) name from yp_zd_dict WITH(NOLOCK) ",
  261. "<when test='code!=null'>",
  262. " where (code like #{code} or name like #{code} or py_code like #{code} or d_code like #{code})",
  263. "</when>",
  264. " GROUP BY code,name </script>"})
  265. List<YpZdDict> selectYpZdDictList(@Param("code") String code);
  266. /**
  267. * @Description 药品编码与医嘱编码冲突重置编码
  268. * @Author hsh
  269. * @param code 新增预置药品编码
  270. * @return int
  271. * @Date 2024/1/29 15:15
  272. */
  273. @Select(" select count(1) from yz_zd_order_item_confirm where yz_zd_order_item_confirm.order_code = #{code} ")
  274. int selectYzOrderItemByCode(String code);
  275. }