CaoYaoYiZhuDao.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. package thyyxxk.webserver.dao.his.zhuyuanyisheng;
  2. import com.baomidou.mybatisplus.core.conditions.Wrapper;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import com.baomidou.mybatisplus.core.toolkit.Constants;
  6. import org.apache.ibatis.annotations.*;
  7. import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
  8. import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
  9. import thyyxxk.webserver.entity.zhuyuanyisheng.caoyaoyizhu.YzActOrderCy;
  10. import thyyxxk.webserver.entity.zhuyuanyisheng.caoyaoyizhu.YzActOrderCyDetail;
  11. import thyyxxk.webserver.entity.zhuyuanyisheng.caoyaoyizhu.YzOrderPatternCy;
  12. import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.YiZhuMingChen;
  13. import java.math.BigDecimal;
  14. import java.util.List;
  15. /**
  16. * <p>
  17. * 描述: 草药医嘱
  18. * </p>
  19. *
  20. * @author xc
  21. * @date 2022-02-26 08:38
  22. */
  23. @Mapper
  24. public interface CaoYaoYiZhuDao {
  25. @Select("select order_no," +
  26. " inpatient_no," +
  27. " admiss_times, " +
  28. " order_name, " +
  29. " doctor_code_name = (select rtrim(name) from a_employee_mi where code = doctor_code), " +
  30. " status_flag /* 1-录入 2-收费 3-提交 4-以发药 d-删除*/, " +
  31. " order_je, " +
  32. " order_je_dj, " +
  33. " quantity, " +
  34. " quantity_dj, " +
  35. " order_code_dj," +
  36. " cy_jssm," +
  37. " cy_mtjs," +
  38. " cy_ffcs," +
  39. " cy_fysm," +
  40. " cy_fysm_name = (select name from mzysh_zd_fysm where code = cy_fysm)," +
  41. " input_date," +
  42. " exec_dept, " +
  43. " exec_dept_name = (select name from zd_unit_code where code = exec_dept) " +
  44. "from yz_act_order_cy with (NOLOCK) " +
  45. "${ew.customSqlSegment} ")
  46. IPage<YzActOrderCy> huoQuCaoYaoShuJu(IPage<YzActOrderCy> page,
  47. @Param(Constants.WRAPPER) Wrapper<?> wp);
  48. /**
  49. * 获取代煎费
  50. *
  51. * @return 返回金额
  52. */
  53. @Select("select isnull(charge_amount,0) from zd_charge_item " +
  54. "with (NOLOCK) where code = (select charge_code_zydj from yz_sequence) ")
  55. BigDecimal huoQuDaiJianFei();
  56. @Select("select chargeCodeName = (select rtrim(name) from view_yp_zd_dict_base_yf with (NOLOCK) where code = charge_code)," +
  57. " group_no_name = (select rtrim(group_name) " +
  58. " from yp_zd_group_name with (NOLOCK) " +
  59. " where yz_act_order_cy_detail.group_no = yp_zd_group_name.group_no), " +
  60. " * " +
  61. "from yz_act_order_cy_detail with (NOLOCK) " +
  62. "where order_no = #{orderNo}")
  63. List<YzActOrderCyDetail> huoQuChaoYaoMingXi(BigDecimal orderNo);
  64. @Select("SELECT code, name FROM mzysh_zd_fysm with (NOLOCK)")
  65. List<GetDropdownBox> fuYongFangFa();
  66. @Select("SELECT code as chargeCode, " +
  67. " name as chargeCodeName, " +
  68. " specification, " +
  69. " 'z' as asorderType, " +
  70. " serial, " +
  71. " group_no, " +
  72. " infusion_flag, " +
  73. " drug_flag, " +
  74. " group_name, " +
  75. " pack_size, " +
  76. " order_class ='Y', " +
  77. " retprice=pack_retprice, " +
  78. " self_flag = isnull(self_flag, '0'), " +
  79. " suprice_flag " +
  80. "FROM view_yp_zd_dict_base_yf with (NOLOCK) " +
  81. "${ew.customSqlSegment} AND isnull(visible_flag_zy, '') <> '1' ")
  82. List<YiZhuMingChen> huoQuCaoYao(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
  83. @Select("select pattern_name, " +
  84. " group_no =max(group_no), " +
  85. " dept_code=max(dept_code) " +
  86. "from yz_order_pattern_cy with (NOLOCK) " +
  87. " ${ew.customSqlSegment} ")
  88. IPage<YzOrderPatternCy> huoQuMuBan(IPage<YzOrderPatternCy> page,
  89. @Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
  90. @Select("SELECT distinct charge_code=a.charge_code, " +
  91. " serial=a.serial, " +
  92. " group_no=a.group_no, " +
  93. " quantity=a.quantity, " +
  94. " retprice=b.pack_retprice, " +
  95. " supply_code=a.supply_code, " +
  96. " instruction=a.instruction, " +
  97. " charge_code_name=b.name," +
  98. " b.specification, " +
  99. " b.self_flag, " +
  100. " b.suprice_flag " +
  101. "FROM yz_order_pattern_cy a with (NOLOCK), " +
  102. " yp_zd_dict b with (NOLOCK), " +
  103. " yp_base_yf c with (NOLOCK) " +
  104. "where a.charge_code = b.code " +
  105. " and a.serial = b.serial " +
  106. " and a.charge_code = c.charge_code " +
  107. " and a.serial = c.serial " +
  108. " and (case " +
  109. " when isnull(b.del_flag, '0') = '1' then '1' " +
  110. " when isnull(b.del_flag, '0') = '1' then '1' " +
  111. " when isnull(c.visible_flag_zy, '0') = '1' then '1' " +
  112. " else '0' end) <> 1 " +
  113. " and a.pattern_name = #{name} " +
  114. " and a.dept_code = #{deptCode} ")
  115. List<YzOrderPatternCy> muBanXiangQing(@Param("name") String name,
  116. @Param("deptCode") String deptCode);
  117. @Select("select count(1) " +
  118. "from yz_order_pattern_cy with (NOLOCK) " +
  119. "where pattern_name = #{name}")
  120. Integer chongFuMuBanMing(String name);
  121. @Insert("<script>" +
  122. "insert into yz_order_pattern_cy (pattern_name, charge_code, serial, group_no, quantity, supply_code, instruction, " +
  123. " dept_code, create_id, py_code, d_code) " +
  124. "values " +
  125. "<foreach collection='list' item='item' separator=','>" +
  126. "(#{name}, #{item.chargeCode}, #{item.serial}, #{item.groupNo}, " +
  127. "#{item.quantity} , null, #{item.instruction}, #{deptCode}, " +
  128. " #{userCode}, #{pyCode}, #{dCode})" +
  129. "</foreach>" +
  130. "</script>")
  131. void chaRuMuBan(@Param("list") List<YzOrderPatternCy> list,
  132. @Param("name") String name,
  133. @Param("userCode") String userCode,
  134. @Param("pyCode") String pyCode,
  135. @Param("dCode") String dCode,
  136. @Param("deptCode") String deptCode);
  137. @Insert("insert into yz_act_order_cy (inpatient_no, admiss_times, order_no, serial_no, order_name, order_je, " +
  138. " order_je_dj, quantity, quantity_dj, order_code_dj, doctor_code, input_id, input_date, " +
  139. " page_no, status_flag, dept_code, " +
  140. " ward_code, cy_mtjs, cy_jsl, cy_zql, cy_fj, cy_ffcs, cy_fysm, cy_jssm, " +
  141. " exec_dept, group_no, source_flag) " +
  142. "values (#{cy.inpatientNo}, #{cy.admissTimes}, #{cy.orderNo}, '1', #{cy.orderName}, " +
  143. " cast(#{cy.orderJe,jdbcType=DECIMAL} as decimal(10,2)), " +
  144. " cast(#{cy.orderJeDj,jdbcType=DECIMAL} as decimal(10,2)), #{cy.quantity}, #{cy.quantityDj}, " +
  145. " (select charge_code_zydj from yz_sequence), #{cy.inputId}, #{cy.inputId}, getdate(), #{cy.pageNo}, '2', " +
  146. " #{deptCode}, " +
  147. " #{wardCode}, #{cy.cyMtjs}, #{cy.cyJsl}, #{cy.cyZql}, #{cy.cyFj}, " +
  148. " #{cy.cyFfcs}, #{cy.cyFysm}, #{cy.cyJssm}, #{execDept}, #{cy.groupNo}, 1)")
  149. void chaRuCaoYaoYiZhu(@Param("cy") YzActOrderCy cy,
  150. @Param("deptCode") String deptCode,
  151. @Param("wardCode") String wardCode,
  152. @Param("execDept") String execDept);
  153. @Insert("<script>" +
  154. "insert into yz_act_order_cy_detail (order_no, serial_no, charge_code, serial, group_no, " +
  155. " quantity, unit_price, supply_code, instruction) " +
  156. "values " +
  157. "<foreach collection='list' item='item' separator=','>" +
  158. "(#{orderNo}, 1, #{item.chargeCode}, #{item.serial}, #{item.groupNo}, " +
  159. " #{item.quantity}, cast(#{item.retprice,jdbcType=DECIMAL} as decimal(10,2)), null, #{item.instruction})" +
  160. "</foreach>" +
  161. "</script>")
  162. void chaRuCaoYaoXiangQing(@Param("list") List<YzActOrderCyDetail> list,
  163. @Param("orderNo") BigDecimal orderNo);
  164. @Insert("insert into yz_act_order (act_order_no, inpatient_no, admiss_times, order_code/*77592*/, order_time, frequ_code/*once*/, " +
  165. " enter_time, " +
  166. " enter_oper, start_time, infant_flag, drug_flag, " +
  167. " physician, confirm_time, signer, status_flag, " +
  168. " self_buy, order_name, pay_self, serial, group_no, ward_code, " +
  169. " doctor_flag, dept_code, exec_unit) " +
  170. "values (#{yz.orderNo}, #{yz.inpatientNo}, #{yz.admissTimes}, '77592', getdate(), 'ONCE', getdate(), " +
  171. " #{yz.inputId}, getdate(), #{infantFlag}, 'o', #{yz.inputId}, getdate(), #{yz.inputId}, '2', 0, " +
  172. " #{orderName}, '0', '00', '00', #{wardCode}, 1, #{deptCode}, #{execDept})")
  173. void chaRuYiZhu(@Param("yz") YzActOrderCy cy,
  174. @Param("orderName") String orderName,
  175. @Param("deptCode") String deptCode,
  176. @Param("wardCode") String wardCode,
  177. @Param("execDept") String execDept,
  178. @Param("infantFlag") Integer infantFlag);
  179. @Select("select top(1) * from yz_order_pattern_cy with (NOLOCK) where pattern_name = #{name}")
  180. YzOrderPatternCy caoYaoMuBanXiangQing(String name);
  181. @Delete("delete from yz_order_pattern_cy where pattern_name = #{name} ")
  182. void shanChuMuBan(String name);
  183. @Select("select * from yz_act_order_cy with (NOLOCK) " +
  184. "where inpatient_no = #{patNo} and admiss_times = #{times} and order_no = #{orderNo}")
  185. YzActOrderCy caoYaoXinXi(@Param("patNo") String patNo,
  186. @Param("times") Integer times,
  187. @Param("orderNo") BigDecimal orderNo);
  188. @Update("update yz_act_order_cy set status_flag = 'd' " +
  189. "where inpatient_no = #{patNo} and admiss_times = #{times} and order_no = #{orderNo} ")
  190. void genXingCaoYaoShanChuBiaoZhi(@Param("patNo") String patNo,
  191. @Param("times") Integer times,
  192. @Param("orderNo") BigDecimal orderNo);
  193. @Update("update yz_act_order " +
  194. "set status_flag = '-1', " +
  195. " instruction = N'作废'," +
  196. " order_name = N'作废' + order_name " +
  197. "where act_order_no = #{orderNo}")
  198. void shanChuYiZhu(@Param("orderNo") BigDecimal orderNo);
  199. @Select("select * from zy_detail_charge where inpatient_no = #{cy.inpatientNo} and admiss_times = #{cy.admissTimes} and order_no = #{cy.orderNo} and charge_fee > 0")
  200. List<ZyDetailCharge> caoYaoFeiYong(@Param("cy") YzActOrderCy cy);
  201. @Update("update zy_detail_charge " +
  202. "set ori_detail_sn = -1 where inpatient_no = #{cy.inpatientNo} and admiss_times = #{cy.admissTimes} and order_no = #{cy.orderNo} and ori_detail_sn is null ")
  203. void modifyTheExpenseFlag(@Param("cy") YzActOrderCy cy);
  204. }