XiangMuLuRuDao.java 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. package thyyxxk.webserver.dao.his.inpatient;
  2. import com.baomidou.mybatisplus.core.conditions.Wrapper;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5. import com.baomidou.mybatisplus.core.metadata.IPage;
  6. import com.baomidou.mybatisplus.core.toolkit.Constants;
  7. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  8. import org.apache.ibatis.annotations.*;
  9. import thyyxxk.webserver.entity.datamodify.FeiYongLeiXin;
  10. import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
  11. import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
  12. import thyyxxk.webserver.entity.inpatient.WeiGuiFeiYongFenXi;
  13. import java.math.BigDecimal;
  14. import java.util.List;
  15. /**
  16. * <p>
  17. * 描述: 项目录入
  18. * </p>
  19. *
  20. * @author xc
  21. * @date 2021-08-02 10:37
  22. */
  23. @Mapper
  24. public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
  25. @Select("<script>" +
  26. "select a.admiss_times, a.inpatient_no, a.order_no, a.gen_time, a.ledger_sn, a.detail_sn, " +
  27. " a.trans_flag_yb, " +
  28. " a.charge_date, a.op_id_code, d.name op_name, a.charge_code, a.charge_fee, a.charge_status , " +
  29. " bill_item_code= b.bill_item_zy, bill_item_name=(select name from zy_bill_item where code = b.bill_item_zy), " +
  30. " charge_name=b.name, spec=b.charge_unit, a.charge_code_mx, a.serial, price=0.0000, charge_amount=a.charge_amount, " +
  31. " exec_dept=(select name from zd_unit_code where code = a.exec_unit), " +
  32. " dept_code = (select name from zd_unit_code where code = a.ward_code) , " +
  33. " self_flag=isnull(a.self_flag,0), suppress_flag=a.suppress_flag, group_no='00', " +
  34. " separate_flag=a.separate_flag, ope_flag=a.ope_flag, drugname=c.name, isnull(a.ori_detail_sn,0) ori_detail_sn " +
  35. " FROM (select top ${pageSize} * from (select ROW_NUMBER() OVER (order by charge_date ${riQiPaiXu} ) as RowNumber,* from zy_detail_charge a " +
  36. "where a.charge_code " +
  37. "like 'BILL%' and a.ledger_sn = #{ledgerSn} and trans_flag_yb &lt;&gt; 2 and a.order_no &lt;&gt; 6 and inpatient_no = #{inpatientNo} " +
  38. "and admiss_times = #{admissTimes} and a.infant_flag = #{infantFlag} " +
  39. "<if test=\"chargeCode != null and chargeCode != '' \">" +
  40. "and charge_code_mx = #{chargeCode} " +
  41. "</if>" +
  42. "<if test=\"startTime != null and startTime!= '' \">" +
  43. "and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
  44. "</if>" +
  45. "<if test=\"dept != null and dept != '' \"> " +
  46. "and exec_unit=#{dept} " +
  47. "</if>" +
  48. "<if test=\"orderNo != 2 and orderNo != 1 \">" +
  49. "and order_no = #{orderNo} " +
  50. "</if>" +
  51. "<if test=\"orderNo !=2 and orderNo == 1\">" +
  52. "and len(order_no) &gt;2 " +
  53. "</if>" +
  54. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 0 \">" +
  55. "and ori_detail_sn is null and charge_fee > 0" +
  56. "</if>" +
  57. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 1 \">" +
  58. "and (ori_detail_sn &gt; 0 or charge_fee &lt; 0) " +
  59. "</if>" +
  60. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 2 \">" +
  61. "and (ori_detail_sn = -1 )" +
  62. "</if>" +
  63. "<if test=\"actOrderNo != null\">" +
  64. " and order_no = #{actOrderNo} " +
  65. "</if>" +
  66. ") temp where RowNumber > ${pageSize} * (${currentPage} - 1 )) a " +
  67. " left join zd_charge_item b on (a.charge_code = b.code) " +
  68. " left join yp_zd_dict c on (a.serial = c.serial and c.code= a.charge_code_mx) " +
  69. " left join a_employee_mi d on (d.code = a.op_id_code) " +
  70. "</script>")
  71. List<ZyDetailCharge> huanZheYaoPinFeiYong(@Param("currentPage") long currentPage,
  72. @Param("pageSize") long pageSize,
  73. @Param("inpatientNo") String inpatientNo,
  74. @Param("admissTimes") Integer admissTimes,
  75. @Param("ledgerSn") Integer ledgerSn,
  76. @Param("chargeCode") String chargeCode,
  77. @Param("infantFlag") int infantFlag,
  78. @Param("startTime") String startTime,
  79. @Param("endTime") String endTime,
  80. @Param("orderNo") BigDecimal orderNo,
  81. @Param("actOrderNo") BigDecimal actOrderNo,
  82. @Param("dept") String dept,
  83. @Param("riQiPaiXu") String riQiPaiXu,
  84. @Param("tuiFeiFlag") Integer tuiFeiFlag);
  85. @Select("<script>" +
  86. "select count(*) total,sum(charge_fee) charge_fee" +
  87. " FROM zy_detail_charge a " +
  88. "where a.charge_code " +
  89. "like 'BILL%' and a.ledger_sn = #{ledgerSn} and trans_flag_yb &lt;&gt; 2 and a.order_no &lt;&gt; 6 and inpatient_no = #{inpatientNo} " +
  90. "and admiss_times = #{admissTimes} and a.infant_flag = #{infantFlag} " +
  91. "<if test=\"chargeCode != null and chargeCode != '' \">" +
  92. "and charge_code_mx = #{chargeCode} " +
  93. "</if>" +
  94. "<if test=\"startTime != null and startTime!= '' \">" +
  95. "and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
  96. "</if>" +
  97. "<if test=\"dept != null and dept != '' \"> " +
  98. "and exec_unit=#{dept} " +
  99. "</if>" +
  100. "<if test=\"orderNo != 2 and orderNo != 1 \">" +
  101. "and order_no = #{orderNo} " +
  102. "</if>" +
  103. "<if test=\"orderNo !=2 and orderNo == 1\">" +
  104. "and len(order_no) &gt;2 " +
  105. "</if>" +
  106. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 0 \">" +
  107. "and ori_detail_sn is null and charge_fee > 0" +
  108. "</if>" +
  109. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 1 \">" +
  110. "and (ori_detail_sn &gt; 0 or charge_fee &lt; 0) " +
  111. "</if>" +
  112. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 2 \">" +
  113. "and (ori_detail_sn = -1 )" +
  114. "</if>" +
  115. "<if test=\"actOrderNo != null\">" +
  116. " and order_no = #{actOrderNo} " +
  117. "</if>" +
  118. "</script>")
  119. long huanZheYaoPinFeiYongTotal(@Param("inpatientNo") String inpatientNo,
  120. @Param("admissTimes") Integer admissTimes,
  121. @Param("ledgerSn") Integer ledgerSn,
  122. @Param("chargeCode") String chargeCode,
  123. @Param("infantFlag") int infantFlag,
  124. @Param("startTime") String startTime,
  125. @Param("endTime") String endTime,
  126. @Param("orderNo") BigDecimal orderNo,
  127. @Param("actOrderNo") BigDecimal actOrderNo,
  128. @Param("dept") String dept,
  129. @Param("tuiFeiFlag") Integer tuiFeiFlag);
  130. @Select("<script>" +
  131. " SELECT a.admiss_times, " +
  132. " a.inpatient_no, " +
  133. " a.order_no, " +
  134. " a.gen_time, " +
  135. " a.ledger_sn," +
  136. " a.trans_flag_yb, " +
  137. " a.detail_sn, " +
  138. " a.charge_date, " +
  139. " a.op_id_code, " +
  140. " c.name op_name, " +
  141. " a.charge_code, " +
  142. " a.charge_fee, " +
  143. " a.charge_status , " +
  144. " bill_item_code = b.bill_item_zy, " +
  145. " bill_item_name=(select name from zy_bill_item where code = b.bill_item_zy), " +
  146. " charge_name=b.name, " +
  147. " spec=b.charge_unit, " +
  148. " a.charge_code_mx, " +
  149. " a.serial, " +
  150. " price=0.0000, " +
  151. " charge_amount=a.charge_amount, " +
  152. " exec_dept=(select name from zd_unit_code where code = a.exec_unit), " +
  153. " dept_code = (select name from zd_unit_code where code = a.ward_code) , " +
  154. " self_flag=a.self_flag, " +
  155. " suppress_flag=a.suppress_flag, " +
  156. " group_no='00', " +
  157. " separate_flag=a.separate_flag, " +
  158. " ope_flag=a.ope_flag," +
  159. " specification, " +
  160. " drugname=b.name, " +
  161. " isnull(a.ori_detail_sn,0) ori_detail_sn " +
  162. " FROM (select top ${pageSize} * from (select ROW_NUMBER() OVER (order by charge_date ${riQiPaiXu} ) as RowNumber,* from zy_detail_charge where inpatient_no= #{inpatientNo} and " +
  163. "admiss_times= #{admissTimes} and ledger_sn = #{ledgerSn} and infant_flag = #{infantFlag} and trans_flag_yb &lt;&gt; 2 AND charge_code not like 'BILL%' and order_no &lt;&gt; 6" +
  164. "<if test=\"chargeCode != null and chargeCode != '' \">" +
  165. "and charge_code_mx = #{chargeCode} " +
  166. "</if>" +
  167. "<if test=\"startTime != null and startTime!= '' \">" +
  168. "and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
  169. "</if>" +
  170. "<if test=\"dept != null and dept != '' \"> " +
  171. "and exec_unit = #{dept} " +
  172. "</if>" +
  173. "<if test=\"orderNo != 2 and orderNo != 1 \">" +
  174. "and order_no = #{orderNo} " +
  175. "</if>" +
  176. "<if test=\"orderNo !=2 and orderNo == 1\">" +
  177. "and len(order_no) &gt;2 " +
  178. "</if>" +
  179. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 0 \">" +
  180. "and ori_detail_sn is null and charge_fee > 0" +
  181. "</if>" +
  182. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 1 \">" +
  183. "and (ori_detail_sn &gt; 0 or charge_fee &lt; 0) " +
  184. "</if>" +
  185. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 2 \">" +
  186. "and (ori_detail_sn = -1 )" +
  187. "</if>" +
  188. "<if test=\"actOrderNo != null\">" +
  189. " and order_no = #{actOrderNo} " +
  190. "</if>" +
  191. ") temp where RowNumber > ${pageSize} * (${currentPage}-1) ) a " +
  192. " left join zd_charge_item b on (a.charge_code=b.code) " +
  193. " left join a_employee_mi c on (c.code = a.op_id_code)" +
  194. "</script>")
  195. List<ZyDetailCharge> huanZheXiangMuFeiYong(@Param("currentPage") long currentPage,
  196. @Param("pageSize") long pageSize,
  197. @Param("inpatientNo") String inpatientNo,
  198. @Param("admissTimes") Integer admissTimes,
  199. @Param("ledgerSn") Integer ledgerSn,
  200. @Param("chargeCode") String chargeCode,
  201. @Param("infantFlag") int infantFlag,
  202. @Param("startTime") String startTime,
  203. @Param("endTime") String endTime,
  204. @Param("orderNo") BigDecimal orderNo,
  205. @Param("actOrderNo") BigDecimal actOrderNo,
  206. @Param("dept") String dept,
  207. @Param("riQiPaiXu") String riQiPaiXu,
  208. @Param("tuiFeiFlag") Integer tuiFeiFlag);
  209. @Select("<script>" +
  210. " select count(*) total,sum(charge_fee) charge_fee from zy_detail_charge where inpatient_no= #{inpatientNo} and " +
  211. "admiss_times= #{admissTimes} and ledger_sn = #{ledgerSn} and infant_flag = #{infantFlag} and trans_flag_yb &lt;&gt; 2 AND charge_code not like 'BILL%' and order_no &lt;&gt; 6" +
  212. "<if test=\"chargeCode != null and chargeCode != '' \">" +
  213. "and charge_code_mx = #{chargeCode} " +
  214. "</if>" +
  215. "<if test=\"startTime != null and startTime!= '' \">" +
  216. "and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
  217. "</if>" +
  218. "<if test=\"dept != null and dept != '' \"> " +
  219. "and exec_unit = #{dept} " +
  220. "</if>" +
  221. "<if test=\"orderNo != 2 and orderNo != 1 \">" +
  222. "and order_no = #{orderNo} " +
  223. "</if>" +
  224. "<if test=\"orderNo !=2 and orderNo == 1\">" +
  225. "and len(order_no) &gt;2 " +
  226. "</if>" +
  227. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 0 \">" +
  228. "and ori_detail_sn is null and charge_fee > 0" +
  229. "</if>" +
  230. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 1 \">" +
  231. "and (ori_detail_sn &gt; 0 or charge_fee &lt; 0) " +
  232. "</if>" +
  233. "<if test=\"tuiFeiFlag != null and tuiFeiFlag == 2 \">" +
  234. "and (ori_detail_sn = -1 )" +
  235. "</if>" +
  236. "<if test=\"actOrderNo != null\">" +
  237. " and order_no = #{actOrderNo} " +
  238. "</if>" +
  239. "</script>")
  240. long huanZheFeiYongToatal(@Param("inpatientNo") String inpatientNo,
  241. @Param("admissTimes") Integer admissTimes,
  242. @Param("ledgerSn") Integer ledgerSn,
  243. @Param("chargeCode") String chargeCode,
  244. @Param("infantFlag") int infantFlag,
  245. @Param("startTime") String startTime,
  246. @Param("endTime") String endTime,
  247. @Param("orderNo") BigDecimal orderNo,
  248. @Param("actOrderNo") BigDecimal actOrderNo,
  249. @Param("dept") String dept,
  250. @Param("tuiFeiFlag") Integer tuiFeiFlag);
  251. @Select("select detail_sn,ori_detail_sn from zy_detail_charge where inpatient_no=#{inpatientNo} and admiss_times = #{admissTimes} " +
  252. "and charge_fee <= 0 and ori_detail_sn is not null and infant_flag = #{infantFlag}")
  253. List<ZyDetailCharge> tuiFeiList(@Param("inpatientNo") String inpatientNo,
  254. @Param("admissTimes") Integer admissTimes,
  255. @Param("infantFlag") int infantFlag);
  256. /**
  257. * @param pyCode 拼音编码
  258. * @return 获取项目的名称和code
  259. */
  260. @Select("select distinct code,name from zd_charge_item where (py_code like #{pyCode} or code like #{pyCode} or name like #{pyCode})" +
  261. "union all " +
  262. "select distinct code,name from yp_zd_dict where (py_code like #{pyCode} or code like #{pyCode} or name like #{pyCode})")
  263. List<GetDropdownBox> getChargeCode(String pyCode);
  264. /**
  265. * @param inpatientNo 住院次数
  266. * @param admissTimes 住院号
  267. * @param list 需要退费的流水号
  268. * @return 获取患者的全部详细信息 因为要生成一条一样的数据 只是 费用和数量不一致 以及录入人 和 录入时间
  269. */
  270. @Select("<script>" +
  271. "select " +
  272. "inpatient_no, " +
  273. " admiss_times, " +
  274. " ledger_sn, " +
  275. " detail_sn, " +
  276. " charge_date, " +
  277. " op_id_code, " +
  278. " charge_code, " +
  279. " bill_item_code = (select bill_item_zy from zd_charge_item where code = charge_code), " +
  280. " infant_flag, " +
  281. " charge_status, " +
  282. " retprice, " +
  283. " charge_amount, " +
  284. " charge_fee, " +
  285. " self_flag, " +
  286. " separate_flag, " +
  287. " suppress_flag, " +
  288. " ward_code, " +
  289. " dept_code, " +
  290. " order_no, " +
  291. " ope_flag, " +
  292. " exec_unit, " +
  293. " gen_time, " +
  294. " pay_percent, " +
  295. " zj_flag, " +
  296. " zfl, " +
  297. " rtrim(charge_code_mx) as charge_code_mx, " +
  298. " rtrim(serial) as serial, " +
  299. " zy_serial_no, " +
  300. " doctor_code, " +
  301. " yb_self_flag, " +
  302. " orig_charge_fee, " +
  303. " confirm_id, " +
  304. " trans_flag_yb, " +
  305. " ss_code, " +
  306. " gs_flag, " +
  307. " refer_physician, " +
  308. " consult_physician, " +
  309. " ori_detail_sn" +
  310. " from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and detail_sn in " +
  311. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  312. "#{item.detailSn}" +
  313. "</foreach>" +
  314. "</script>")
  315. List<ZyDetailCharge> huoQuJuTiFeiYong(@Param("inpatientNo") String inpatientNo,
  316. @Param("admissTimes") Integer admissTimes,
  317. @Param("ledgerSn") Integer ledgerSn,
  318. @Param("list") List<ZyDetailCharge> list);
  319. /**
  320. * 查询出 有哪些数据已经退过了 费用
  321. *
  322. * @param inpatientNo 住院号
  323. * @param admissTimes 住院次数
  324. * @param list 流水号
  325. * @return 返回 已经退过费用的数据
  326. */
  327. @Select("<script>" +
  328. "select " +
  329. "inpatient_no, " +
  330. " admiss_times, " +
  331. " ledger_sn, " +
  332. " detail_sn, " +
  333. " charge_date, " +
  334. " op_id_code, " +
  335. " charge_code, " +
  336. " bill_item_code = (select bill_item_zy from zd_charge_item where code = charge_code), " +
  337. " infant_flag, " +
  338. " charge_status, " +
  339. " retprice, " +
  340. " charge_amount, " +
  341. " charge_fee, " +
  342. " self_flag, " +
  343. " separate_flag, " +
  344. " suppress_flag, " +
  345. " ward_code, " +
  346. " dept_code, " +
  347. " order_no, " +
  348. " ope_flag, " +
  349. " exec_unit, " +
  350. " gen_time, " +
  351. " pay_percent, " +
  352. " zj_flag, " +
  353. " zfl, " +
  354. " charge_code_mx, " +
  355. " serial, " +
  356. " zy_serial_no, " +
  357. " doctor_code, " +
  358. " yb_self_flag, " +
  359. " orig_charge_fee, " +
  360. " confirm_id, " +
  361. " trans_flag_yb, " +
  362. " ss_code, " +
  363. " gs_flag, " +
  364. " refer_physician, " +
  365. " consult_physician, " +
  366. " ori_detail_sn" +
  367. " from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and detail_sn in " +
  368. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  369. "#{item.detailSn}" +
  370. "</foreach>" +
  371. "</script>")
  372. List<ZyDetailCharge> chaKanSFYiJingTuiFeiLe(@Param("inpatientNo") String inpatientNo,
  373. @Param("admissTimes") Integer admissTimes,
  374. @Param("ledgerSn") Integer ledgerSn,
  375. @Param("list") List<ZyDetailCharge> list);
  376. /**
  377. * 插入数据
  378. *
  379. * @param list 插入退费的数据 生成一条一样的数据 只是 费用和数量不一致 以及录入人 和 录入时间 ori_detail_sn 保存退费的原流水号
  380. */
  381. @Insert("<script>" +
  382. "insert into zy_detail_charge(inpatient_no, admiss_times, ledger_sn, detail_sn, charge_date, op_id_code, charge_code, infant_flag, " +
  383. "charge_status, retprice, charge_amount, charge_fee, self_flag, separate_flag, suppress_flag, ward_code, dept_code, order_no, ope_flag, exec_unit, gen_time, " +
  384. "pay_percent, zj_flag, zfl, charge_code_mx, serial, zy_serial_no, doctor_code, yb_self_flag, orig_charge_fee, confirm_id, trans_flag_yb, ss_code, gs_flag, " +
  385. "refer_physician, consult_physician, ori_detail_sn) " +
  386. "values " +
  387. "<foreach collection='list' item='item' separator=','>" +
  388. "(#{item.inpatientNo},#{item.admissTimes},#{item.ledgerSn},#{item.detailSn},getdate(),#{item.opIdCode},#{item.chargeCode},#{item.infantFlag}," +
  389. "#{item.chargeStatus},#{item.retprice},cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)),cast(#{item.chargeFee,jdbcType=DECIMAL} as decimal(14,5))," +
  390. "#{item.selfFlag},#{item.separateFlag},#{item.suppressFlag},#{item.wardCode},#{item.deptCode},#{item.orderNo}," +
  391. "#{item.opeFlag},#{item.execUnit},#{item.oldGenTime}," +
  392. "#{item.payPercent},#{item.zjFlag},#{item.zfl},#{item.chargeCodeMx},#{item.serial},#{item.zySerialNo},#{item.doctorCode}," +
  393. "#{item.ybSelfFlag},cast(#{item.origChargeFee,jdbcType=DECIMAL} as decimal(14,5)),#{item.confirmId},0,#{item.ssCode},#{item.gsFlag}," +
  394. "#{item.referPhysician},#{item.consultPhysician},#{item.oriDetailSn})" +
  395. "</foreach>" +
  396. "</script>")
  397. void xiangMuTuiFei(@Param("list") List<ZyDetailCharge> list);
  398. /**
  399. * 更新对应 退费的正数 流水
  400. *
  401. * @param inpatientNo 住院号
  402. * @param admissTimes 住院次数
  403. * @param ledgerSn 账页号
  404. * @param list 正流水
  405. */
  406. @Update("<script>" +
  407. "update zy_detail_charge set ori_detail_sn = #{flag} where " +
  408. "inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} " +
  409. "and ledger_sn = #{ledgerSn} " +
  410. "and charge_fee &gt; 0 and charge_amount &gt; 0 and detail_sn in " +
  411. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  412. "#{item}" +
  413. "</foreach>" +
  414. "</script>")
  415. void genXinZhenShuTuiFeiLiuShui(@Param("inpatientNo") String inpatientNo,
  416. @Param("admissTimes") Integer admissTimes,
  417. @Param("ledgerSn") Integer ledgerSn,
  418. @Param("list") List<Integer> list,
  419. @Param("flag") int flag);
  420. /**
  421. * 退药汇总单
  422. */
  423. @Insert("insert into yz_yp_page_no (page_no, dept_code, ward_code, submit_time, submit_name,\n" +
  424. " submit_flag, page_class, page_name, group_no)\n" +
  425. "values (#{pageNo}, #{wardCode}, #{wardCode}, getdate(), #{userCode}, 1, 'HT', '护士退药单', #{groupNo})")
  426. void drugReturnForm(@Param("pageNo") Integer pageNo,
  427. @Param("wardCode") String wardCode,
  428. @Param("userCode") String userCode,
  429. @Param("groupNo") String groupNo);
  430. @Insert("<script>" +
  431. "insert into yz_yp_zy_order (inpatient_no, admiss_times, name, bed_no, dept_code, ward_code, charge_code, amount,\n" +
  432. " retprice, charge_date, infant_flag, drawer, always_flag, status_flag, drug_class, serail,\n" +
  433. " occ_time, act_order_no, serial, group_no, doctor_name, page_no_ty, page_class,page_no)\n" +
  434. "values " +
  435. "<foreach collection='list' item='item' separator=','>" +
  436. "(#{patNo}, #{times}, #{name}, #{bedNo}, #{wardCode}, #{wardCode}, #{item.chargeCodeMx}, #{item.chargeAmount,jdbcType=REAL},\n" +
  437. " #{item.chargeFee,jdbcType=REAL}, getdate(), #{infantFlag}, #{userCode}, 'a', '1',\n" +
  438. " (select case infusion_flag\n" +
  439. " when '1' then 'i'\n" +
  440. " else\n" +
  441. " (case\n" +
  442. " when code &gt;= '30000' and code &lt; '50000' then 'd'\n" +
  443. " else 'j' end) end\n" +
  444. " from yp_zd_dict\n" +
  445. " where rtrim(code) + rtrim(serial) = '${item.chargeCodeMx}${item.serial}'), #{item.detailSn}, getdate(), 0, #{item.serial}, #{groupNo},\n" +
  446. " #{item.doctorCode}, #{pageNo}, null,#{ledgerSn})" +
  447. "</foreach>" +
  448. "</script>")
  449. void detailsOfDrugReturnForm(@Param("list") List<ZyDetailCharge> list,
  450. @Param("patNo") String patNo,
  451. @Param("times") Integer times,
  452. @Param("name") String name,
  453. @Param("bedNo") String bedNo,
  454. @Param("wardCode") String wardCode,
  455. @Param("infantFlag") Integer infantFlag,
  456. @Param("groupNo") String groupNo,
  457. @Param("userCode") String userCode,
  458. @Param("pageNo") Integer pageNo,
  459. @Param("ledgerSn") Integer ledgerSn);
  460. /**
  461. * 获取模板
  462. *
  463. * @param queryWrapper 根据科室来搜索
  464. * @return 返回模板信息
  465. */
  466. @Select("SELECT rtrim(pattern_name) as name, " +
  467. " max(group_no) as group_no, " +
  468. " max(op_id_code) as op_id_code, " +
  469. " op_dept " +
  470. "FROM zy_charge_pattern " +
  471. " ${ew.customSqlSegment} " +
  472. "group by pattern_name, op_dept ")
  473. Page<ZyDetailCharge> getMuBan(IPage<ZyDetailCharge> page,
  474. @Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
  475. /**
  476. * 这个是获取模板下面的那些项目具体信息
  477. *
  478. * @param patternName 模板名称
  479. * @param opIdCode 录入人id
  480. * @return 返回模板 下面的详细信息
  481. */
  482. @Select("SELECT charge_name=RTRIM(b.name), " +
  483. " charge_code_mx=b.code, " +
  484. " amount=a.amount, " +
  485. " charge_amount=b.charge_amount, " +
  486. " op_id_code=a.op_id_code, " +
  487. " bill_item_code=b.bill_item_zy, " +
  488. " bill_item_name=(select name from zy_bill_item where code = b.bill_item_zy)," +
  489. " national_code," +
  490. " national_name," +
  491. " descriptions " +
  492. "FROM zy_charge_pattern a, " +
  493. " zd_charge_item b " +
  494. "WHERE (a.pattern_name = #{patternName}) " +
  495. " and a.op_id_code = #{opIdCode} " +
  496. " and a.charge_code = b.code " +
  497. " and isnull(a.serial, '01') = '00' " +
  498. " and (isnull(b.del_flag, '0') <> '1') " +
  499. "union all " +
  500. "SELECT charge_name=RTRIM(d.name), " +
  501. " charge_code_mx=b.charge_code, " +
  502. " amount=a.amount, " +
  503. " charge_amount=d.pack_retprice, " +
  504. " op_id_code=a.op_id_code, " +
  505. " bill_item_code=d.bill_item_zy, " +
  506. " bill_item_name=(select name from zy_bill_item where code = d.bill_item_zy)," +
  507. " national_code," +
  508. " national_name," +
  509. " specification as descriptions " +
  510. "FROM zy_charge_pattern a, " +
  511. " yp_base_yf b, " +
  512. " yp_zd_dict d " +
  513. "WHERE (a.pattern_name = #{patternName}) " +
  514. " and a.op_id_code = #{opIdCode} " +
  515. " and a.group_no = b.group_no " +
  516. " and a.charge_code = b.charge_code " +
  517. " and isnull(a.serial, '01') = b.serial " +
  518. " and b.charge_code = d.code " +
  519. " and b.serial = d.serial " +
  520. " and isnull(d.del_flag, '0') <> '1' " +
  521. " and isnull(b.visible_flag_zy, '0') <> '1'")
  522. List<ZyDetailCharge> getMuBanXinXi(@Param("patternName") String patternName, @Param("opIdCode") String opIdCode);
  523. /**
  524. * 搜索项目信息
  525. *
  526. * @param pyCode 拼音码
  527. * @return 返回模板信息
  528. */
  529. @Select("SELECT a.code charge_code," +
  530. " a.code charge_code_mx, " +
  531. " a.exec_unit dept_code," +
  532. " rtrim(a.yb_comment) yb_comment, " +
  533. " RTRIM(a.name) charge_name, " +
  534. " a.charge_amount," +
  535. " amount = 1, " +
  536. " bill_item_code=a.bill_item_zy, " +
  537. " bill_item_name=(select name from zy_bill_item where code = a.bill_item_zy)," +
  538. " a.py_code, " +
  539. " a.d_code, " +
  540. " a.suppress_flag, " +
  541. " a.bill_item_out, " +
  542. " a.n_code, " +
  543. " self_flag =isnull(a.self_flag,'0'), " +
  544. " a.separate_flag , " +
  545. " spec=charge_unit, " +
  546. " a.yb_comment, " +
  547. " exec_unit_name=b.name, " +
  548. " serial='00', " +
  549. " group_no='00'," +
  550. " national_code," +
  551. " national_name," +
  552. " descriptions " +
  553. "FROM zd_charge_item a left join zd_unit_code b on (a.exec_unit = b.code) " +
  554. "where isnull(a.del_flag,'') <> '1' and " +
  555. " isnull(a.in_out_flag,'') <> '1' and " +
  556. " (a.py_code like #{pyCode} or a.code like #{pyCode} or a.name like #{pyCode})")
  557. List<ZyDetailCharge> queryXiangMu(String pyCode);
  558. @Select("SELECT distinct a.code charge_code_mx, " +
  559. " charge_code = (select charge_code from zy_bill_item where a.bill_item_zy = zy_bill_item.code), " +
  560. " a.serial, " +
  561. " RTRIM(a.name) charge_name, " +
  562. " a.pack_size amount, " +
  563. " charge_amount=a.pack_retprice, " +
  564. " spec=a.specification, " +
  565. " a.drug_flag , " +
  566. " a.fix_price, " +
  567. " c.stock_amount, " +
  568. " self_flag=isnull(a.self_flag,'0'), " +
  569. " suppress_flag=a.suprice_flag, " +
  570. " group_no=c.group_no, " +
  571. " bill_item_code=a.bill_item_zy, " +
  572. " bill_item_name=(select name from zy_bill_item where code = a.bill_item_zy), " +
  573. " ybbz=a.yb_comment_new, " +
  574. " yblx=(select name from yp_zd_yb_type where code=a.yb_flag_new), " +
  575. " xnh=a.xnh_flag," +
  576. " national_code," +
  577. " national_name " +
  578. "FROM yp_zd_dict a ,yp_print_name b , " +
  579. " yp_base_yf c " +
  580. "where " +
  581. "(a.py_code like #{pyCode} or a.name like #{pyCode} or a.code like #{pyCode}) and" +
  582. " a.code=b.charge_code and " +
  583. " a.code=c.charge_code and " +
  584. " a.serial=c.serial and " +
  585. " c.visible_flag_mz <> '1' and " +
  586. " c.visible_flag_zy <> '1' and" +
  587. " isnull(a.del_flag,0) = 0 and " +
  588. " c.group_no='73'")
  589. List<ZyDetailCharge> queryYaoPin(String pyCode);
  590. /**
  591. * 插入项目录入费用
  592. *
  593. * @param zyDetailCharge 插入的信息
  594. * @param list 费用详情
  595. */
  596. @Insert("<script>" +
  597. "INSERT INTO zy_detail_charge (inpatient_no, admiss_times, ledger_sn, detail_sn, charge_date " +
  598. " , op_id_code, charge_code, infant_flag, charge_status, charge_fee " +
  599. " , self_flag, separate_flag, suppress_flag, ward_code, dept_code " +
  600. " , order_no, ope_flag, exec_unit, charge_amount, gen_time " +
  601. " , zy_serial_no, charge_code_mx, serial,ss_code,yb_self_flag,refer_physician,doctor_code) " +
  602. "VALUES " +
  603. "<foreach collection='list' item='item' separator=','>" +
  604. "(#{zyDetailCharge.inpatientNo}, #{zyDetailCharge.admissTimes}, #{ledgerSn}, #{item.detailSn}, getdate() " +
  605. " , #{zyDetailCharge.opIdCode}, #{item.chargeCode}, #{infantFlag}, '2', cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)) " +
  606. " , '0', '0', NULL, #{zyDetailCharge.ward}, #{zyDetailCharge.dept} " +
  607. " , #{item.orderNo}, '0', #{item.deptCode}, cast(#{item.amount,jdbcType=DECIMAL} as decimal(14,5)), getdate() " +
  608. " , #{zyDetailCharge.zySerialNo}, #{item.chargeCodeMx}, #{item.serial},#{zyDetailCharge.ssCode}," +
  609. // 是否医保报销 标志 默认为空值
  610. "<if test=\"item.ybSelfFlag == null\">" +
  611. "0" +
  612. "</if>" +
  613. "<if test=\"item.ybSelfFlag != null\">" +
  614. "#{item.ybSelfFlag}" +
  615. "</if>" +
  616. ",#{zyDetailCharge.referPhysician}," +
  617. "null)" +
  618. "</foreach>" +
  619. "</script>")
  620. void chaRuFeiYong(@Param("zyDetailCharge") ZyDetailCharge zyDetailCharge,
  621. @Param("list") List<ZyDetailCharge> list,
  622. @Param("infantFlag") int infantFlag,
  623. @Param("ledgerSn") Integer ledgerSn);
  624. @Select("<script>" +
  625. "SELECT charge_code charge_code_mx,group_no,serial FROM yp_base_yf WHERE charge_code in " +
  626. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  627. "#{item.chargeCodeMx}" +
  628. "</foreach>" +
  629. "</script>")
  630. List<ZyDetailCharge> yaoFang(List<ZyDetailCharge> yaoPingCode);
  631. @Insert("<script>" +
  632. "insert into zy_drug ( inpatient_no , admiss_times , ledger_sn , detail_sn , charge_date , op_id_code , charge_code , infant_flag , " +
  633. "charge_fee , self_flag , separate_flag , supress_flag , ward_code , dept_code , ope_flag , exec_unit , retprice , amount , zy_serial_no , " +
  634. "serial , group_no , occ_cate ) values " +
  635. "<foreach collection='list' item='item' separator=','>" +
  636. "( #{zyDetailCharge.inpatientNo} , #{zyDetailCharge.admissTimes} , #{ledgerSn} , #{item.detailSn} , getdate() , #{opIdCode} , " +
  637. "#{item.chargeCodeMx} , #{infantFlag} , " +
  638. // 金额
  639. "cast(#{item.chargeFee,jdbcType=DECIMAL} as decimal(14,5))," +
  640. " '0' , '0' , null , #{zyDetailCharge.ward} , #{zyDetailCharge.dept} , '0' , #{item.deptCode} ," +
  641. // 单价
  642. " cast(#{item.chargeFee,jdbcType=DECIMAL} / #{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)) , " +
  643. // 数量
  644. "cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)) " +
  645. ", #{zyDetailCharge.zySerialNo} , #{item.serial} , 73 ,'1' )" +
  646. "</foreach>" +
  647. "</script>")
  648. void shenQingYaoPing(@Param("zyDetailCharge") ZyDetailCharge zyDetailCharge,
  649. @Param("list") List<ZyDetailCharge> list,
  650. @Param("infantFlag") int infantFlag,
  651. @Param("ledgerSn") Integer ledgerSn,
  652. @Param("opIdCode") String opIdCode);
  653. /**
  654. * 需要更新患者的总费用
  655. *
  656. * @param fy 费用
  657. * @param inpatientNo 住院号
  658. * @param admissTimes 住院次数
  659. */
  660. @Update("<script>" +
  661. "update ${tableName} " +
  662. "<trim prefix='set' suffixOverrides=','> " +
  663. "total_charge = total_charge + #{fy.totalCharge} , " +
  664. "balance = balance - #{fy.totalCharge}," +
  665. "<if test=\"fy.charge1 !=null \">" +
  666. "charge1 =charge1 + #{fy.charge1} ," +
  667. "</if>" +
  668. "<if test=\"fy.charge2 !=null \">" +
  669. "charge2 =charge2 + #{fy.charge2} ," +
  670. "</if>" +
  671. "<if test=\"fy.charge3 !=null \">" +
  672. "charge3 =charge3 + #{fy.charge3} ," +
  673. "</if>" +
  674. "<if test=\"fy.charge4 !=null \">" +
  675. "charge4 =charge4 + #{fy.charge4} ," +
  676. "</if>" +
  677. "<if test=\"fy.charge5 !=null \">" +
  678. "charge5 =charge5 + #{fy.charge5} ," +
  679. "</if>" +
  680. "<if test=\"fy.charge6 !=null \">" +
  681. "charge6 =charge6 + #{fy.charge6} ," +
  682. "</if>" +
  683. "<if test=\"fy.charge7 !=null \">" +
  684. "charge7 =charge7 + #{fy.charge7} ," +
  685. "</if>" +
  686. "<if test=\"fy.charge8 !=null \">" +
  687. "charge8 =charge8 + #{fy.charge8} ," +
  688. "</if>" +
  689. "<if test=\"fy.charge9 !=null \">" +
  690. "charge9 =charge9 + #{fy.charge9} ," +
  691. "</if>" +
  692. "<if test=\"fy.charge10 !=null \">" +
  693. "charge10 =charge10 + #{fy.charge10} ," +
  694. "</if>" +
  695. "<if test=\"fy.charge11 !=null \">" +
  696. "charge11 =charge11 + #{fy.charge11} ," +
  697. "</if>" +
  698. "<if test=\"fy.charge12 !=null \">" +
  699. "charge12 =charge12 + #{fy.charge12} ," +
  700. "</if>" +
  701. "<if test=\"fy.charge13 !=null \">" +
  702. "charge13 =charge13 + #{fy.charge13} ," +
  703. "</if>" +
  704. "<if test=\"fy.charge14 !=null \">" +
  705. "charge14 =charge14 + #{fy.charge14} ," +
  706. "</if>" +
  707. "<if test=\"fy.charge15 !=null \">" +
  708. "charge15 =charge15 + #{fy.charge15} ," +
  709. "</if>" +
  710. "<if test=\"fy.charge16 !=null \">" +
  711. "charge16 =charge16 + #{fy.charge16} ," +
  712. "</if>" +
  713. "<if test=\"fy.charge17 !=null \">" +
  714. "charge17 =charge17 + #{fy.charge17} ," +
  715. "</if>" +
  716. "<if test=\"fy.charge18 !=null \">" +
  717. "charge18 =charge18 + #{fy.charge18} ," +
  718. "</if>" +
  719. "<if test=\"fy.charge19 !=null \">" +
  720. "charge19 =charge19 + #{fy.charge19} ," +
  721. "</if>" +
  722. "<if test=\"fy.charge20 !=null \">" +
  723. "charge20 =charge20 + #{fy.charge20} ," +
  724. "</if>" +
  725. "<if test=\"fy.charge21 !=null \">" +
  726. "charge21 =charge21 + #{fy.charge21} ," +
  727. "</if>" +
  728. "<if test=\"fy.charge22 !=null \">" +
  729. "charge22 =charge22 + #{fy.charge22} ," +
  730. "</if>" +
  731. "<if test=\"fy.charge23 !=null \">" +
  732. "charge23 =charge23 + #{fy.charge23} ," +
  733. "</if>" +
  734. "<if test=\"fy.charge24 !=null \">" +
  735. "charge24 =charge24 + #{fy.charge24} ," +
  736. "</if>" +
  737. "<if test=\"fy.charge25 !=null \">" +
  738. "charge25 =charge25 + #{fy.charge25} ," +
  739. "</if>" +
  740. "<if test=\"fy.charge26 !=null \">" +
  741. "charge26 =charge26 + #{fy.charge26} ," +
  742. "</if>" +
  743. "<if test=\"fy.charge27 !=null \">" +
  744. "charge27 =charge27 + #{fy.charge27} ," +
  745. "</if>" +
  746. "<if test=\"fy.charge28 !=null \">" +
  747. "charge28 =charge28 + #{fy.charge28} ," +
  748. "</if>" +
  749. "<if test=\"fy.charge29 !=null \">" +
  750. "charge29 =charge29 + #{fy.charge29} ," +
  751. "</if>" +
  752. "<if test=\"fy.charge30 !=null \">" +
  753. "charge30 =charge30 + #{fy.charge30} ," +
  754. "</if>" +
  755. "</trim>" +
  756. "WHERE inpatient_no = #{inpatientNo} and admiss_times=#{admissTimes}" +
  757. "</script>")
  758. void huanZheZongFeiYong(@Param("fy") FeiYongLeiXin fy,
  759. @Param("inpatientNo") String inpatientNo,
  760. @Param("admissTimes") Integer admissTimes,
  761. @Param("tableName") String tableName);
  762. /**
  763. * 查看模板名称是否存在
  764. *
  765. * @param patternName 模板名字
  766. * @param opIdCode 创建模板的人 code
  767. * @return 返回条数
  768. */
  769. @Select("select count(*) from zy_charge_pattern where pattern_name = #{patternName} and op_id_code <> #{opIdCode} ")
  770. Integer chaKanMuBanMingChengSFcunZi(@Param("patternName") String patternName,
  771. @Param("opIdCode") String opIdCode);
  772. /**
  773. * 删除模板
  774. *
  775. * @param patternName 模板名字
  776. * @param opIdCode 创建模板的人 code
  777. */
  778. @Select("delete zy_charge_pattern where pattern_name = #{patternName} and op_id_code = #{opIdCode} ")
  779. Integer delMuBan(@Param("patternName") String patternName,
  780. @Param("opIdCode") String opIdCode);
  781. /**
  782. * 保存模板
  783. *
  784. * @param param 保存的数据
  785. */
  786. @Insert("<script>" +
  787. "INSERT INTO zy_charge_pattern ( charge_name, " +
  788. " pattern_name, " +
  789. " charge_code, " +
  790. " group_no," +
  791. " serial, " +
  792. " amount, " +
  793. " self, " +
  794. " separate," +
  795. " suppress, " +
  796. " infant, " +
  797. " per1," +
  798. " per2," +
  799. " per3," +
  800. " per4," +
  801. " per5," +
  802. " item_no, " +
  803. " op_id_code, " +
  804. " py_code, " +
  805. " d_code, " +
  806. " charge_fee, " +
  807. " op_dept, " +
  808. " default_no " +
  809. " )" +
  810. " VALUES " +
  811. "<foreach collection='param.list' item='item' index='index' separator=','>" +
  812. "( substring(#{item.chargeName},0,15) , #{param.name} , #{item.chargeCodeMx} , #{item.groupNo}, #{item.serial}, cast(#{item.amount,jdbcType=DECIMAL} as decimal(14,5)) , " +
  813. "'0', '0', '0', '0', 1, 1, 1, 1, 1, #{index} + 1 , #{param.opIdCode} , #{param.pyCode} , #{param.dCode} , cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)) ," +
  814. " #{param.deptCode} , " +
  815. "#{param.defaultNo} )" +
  816. "</foreach>" +
  817. "</script>")
  818. void baoCunMuBan(@Param("param") ZyDetailCharge param);
  819. /**
  820. * 获取医嘱的费用
  821. *
  822. * @param inpatientNo 住院号
  823. * @param admissTimes 住院次数
  824. * @param ZF 正的费用还是负的费用
  825. * @return 返回list 费用集合
  826. */
  827. @Select("<script>" +
  828. "select charge_date,charge_fee,charge_amount,charge_code_mx,detail_sn,ori_detail_sn,ABS(order_no),order_no,ledger_sn,exec_unit " +
  829. "from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
  830. "and ori_detail_sn is null and charge_amount ${ZF} 0 and charge_fee ${ZF} 0 and infant_flag = #{infantFlag} and trans_flag_yb &lt;&gt; 2 " +
  831. "<if test=\"list.size >0 \">" +
  832. "and exec_unit in " +
  833. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  834. "#{item}" +
  835. "</foreach>" +
  836. "</if>" +
  837. "</script>")
  838. List<ZyDetailCharge> getYiZhuFeiYong(@Param("inpatientNo") String inpatientNo,
  839. @Param("admissTimes") Integer admissTimes,
  840. @Param("ledgerSn") Integer ledgerSn,
  841. @Param("ZF") String ZF,
  842. @Param("infantFlag") int infantFlag,
  843. @Param("list") List<String> list);
  844. /**
  845. * @param inpatientNo 住院号
  846. * @param admissTimes 住院次数
  847. * @param yiZhuPiPei 需要匹配的流水信息
  848. */
  849. @Update("<script>" +
  850. "<foreach collection='list' item='item' index='index' open='' close='' separator=';'>" +
  851. "update zy_detail_charge set ori_detail_sn = #{item.oriDetailSn} where inpatient_no= #{inpatientNo} and admiss_times = #{admissTimes} " +
  852. "and detail_sn = #{item.detailSn} and infant_flag = #{infantFlag} and ledger_sn = #{item.ledgerSn} " +
  853. "</foreach>" +
  854. "</script>")
  855. void yiZhuTuiFeiPiPei(@Param("inpatientNo") String inpatientNo,
  856. @Param("admissTimes") Integer admissTimes,
  857. @Param("list") List<ZyDetailCharge> yiZhuPiPei,
  858. @Param("infantFlag") int infantFlag);
  859. @Select("SELECT small_dept FROM zd_dept_all where dept = #{dept}")
  860. List<String> chaXunZhiZXinKeShi(@Param("dept") String dept);
  861. @Select("select role_id from dj_user_role where user_code = #{code}")
  862. List<Integer> huoQuJueSe(@Param("code") String code);
  863. @Select("select code,rtrim(name) name from zd_unit_code where code not like '8%'")
  864. List<GetDropdownBox> getDpet();
  865. @Select("select code,rtrim(name) name from zd_unit_code where code like '8%'")
  866. List<GetDropdownBox> getWard();
  867. @Select("SELECT small_dept code,name=(select name from zd_unit_code where code = small_dept) FROM zd_dept_all where dept = #{dept}")
  868. List<GetDropdownBox> getBingQuDuiYingKeShi(@Param("dept") String dept);
  869. @Select("select count(*) from zy_actpatient where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes}")
  870. Integer getHuanZheSFZaiYuan(@Param("inpatientNo") String inpatientNo,
  871. @Param("admissTimes") Integer admissTimes);
  872. @Select("select case settle_type when '1' then '0' else settle_type end as settle_type from zy_ledger_file where " +
  873. "inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} " +
  874. "and ledger_sn = (select max(ledger_sn)ledger_sn from zy_ledger_file where zy_ledger_file.inpatient_no = #{inpatientNo} " +
  875. "and zy_ledger_file.admiss_times = #{admissTimes}) ")
  876. Integer getHuanZheSFJieSuan(@Param("inpatientNo") String inpatientNo,
  877. @Param("admissTimes") Integer admissTimes);
  878. @Select("select detail_sn,ori_detail_sn,trans_flag_yb from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  879. "and detail_sn = #{detailSn} and order_no <> 6 and trans_flag_yb <> 2 ")
  880. ZyDetailCharge beiTuiFeiYongXinXi(@Param("inpatientNo") String inpatientNo,
  881. @Param("admissTimes") Integer admissTimes,
  882. @Param("ledger") Integer ledger,
  883. @Param("detailSn") Integer detailSn);
  884. @Select("<script>" +
  885. "select code from yp_zd_dict where code in " +
  886. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  887. " #{item}" +
  888. "</foreach> " +
  889. " and serial = '01' and isnull(del_flag,0) = 1 " +
  890. "union all " +
  891. "select code from zd_charge_item where code in " +
  892. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  893. " #{item}" +
  894. "</foreach> " +
  895. " and isnull(del_flag,0) = 1" +
  896. "</script>")
  897. List<String> chaXunFeiYongShiFouTingYong(List<String> bianMa);
  898. @Select("<script>" +
  899. "select charge_code from yp_base_yf where stock_amount &lt;= 0 and serial = '01' and charge_code in " +
  900. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  901. " #{item}" +
  902. "</foreach> " +
  903. "</script>")
  904. List<String> kuCun(List<String> bianMa);
  905. @Delete("delete zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  906. "and detail_sn = #{detailSn} and order_no <> 6 and trans_flag_yb <> 2")
  907. void cheXiaoFeiYong(@Param("inpatientNo") String inpatientNo,
  908. @Param("admissTimes") Integer admissTimes,
  909. @Param("ledger") Integer ledger,
  910. @Param("detailSn") Integer detailSn);
  911. @Update("update zy_detail_charge set ori_detail_sn = null where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  912. "and detail_sn = #{detailSn} and order_no <> 6 and trans_flag_yb <> 2")
  913. void cheXiaoHouHuanYuanZhenShuJu(@Param("inpatientNo") String inpatientNo,
  914. @Param("admissTimes") Integer admissTimes,
  915. @Param("ledger") Integer ledger,
  916. @Param("detailSn") Integer detailSn);
  917. @Select("select act_order_no as order_no,exec_unit from yz_erase_order where act_order_no in " +
  918. "(select order_no from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  919. "and exec_unit is null AND charge_fee < 0 and ori_detail_sn is null)")
  920. List<ZyDetailCharge> huoQuYaoPingZhongKeShiWeiKongDe(@Param("inpatientNo") String inpatientNo,
  921. @Param("admissTimes") Integer admissTimes,
  922. @Param("ledger") Integer ledger);
  923. @Update("<script>" +
  924. " <foreach collection='list' item='item' separator=';' >" +
  925. "update zy_detail_charge set exec_unit = #{item.execUnit} where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  926. "and order_no = #{item.orderNo} and exec_unit is null and charge_fee &lt; 0" +
  927. "</foreach> " +
  928. "</script> ")
  929. void yiZhuTuiFeiGenXingZhiXingKeShi(@Param("inpatientNo") String inpatientNo,
  930. @Param("admissTimes") Integer admissTimes,
  931. @Param("ledger") Integer ledger,
  932. @Param("list") List<ZyDetailCharge> genXingDeZhiXinKeShi);
  933. @Select("select b.code from zy_detail_charge a, yp_zd_dict b " +
  934. "where order_no <> 6 and trans_flag_yb not in (1,2) and charge_code like 'BILL%' " +
  935. " and isnull(b.national_code,'') = '' and inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  936. "and a.infant_flag = #{infantFlag} " +
  937. " and a.charge_code_mx = b.code " +
  938. "group by b.code ")
  939. List<String> weiGuiYaoPinInt(@Param("inpatientNo") String inpatientNo,
  940. @Param("admissTimes") Integer admissTimes,
  941. @Param("ledger") Integer ledger,
  942. @Param("infantFlag") Integer infantFlag);
  943. @Update("<script>" +
  944. "<foreach collection='list' item='item' separator=';'>" +
  945. "update yp_zd_dict set national_code = (select top(1) national_code from yp_zd_dict where code = #{item} and national_code is not null ) " +
  946. "where code = #{item} and national_code is null" +
  947. "</foreach>" +
  948. "</script>")
  949. void genXinYaoPingPiPeiXinXi(@Param("list") List<String> list);
  950. @Select("select a.charge_code_mx,case when (select top(1) rtrim(name) from zd_charge_item where code = a.charge_code_mx) != '' then " +
  951. "(select top(1) rtrim(name) from zd_charge_item where code = a.charge_code_mx) else " +
  952. "(select top(1) rtrim(name) from yp_zd_dict where code = a.charge_code_mx) end as name " +
  953. "from zy_detail_charge a left join zd_charge_item_hnsgs b " +
  954. "on (a.charge_code_mx = b.hosp_code) where " +
  955. "inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} and infant_flag = #{infantFlag} and ori_detail_sn is null and isnull(b.hnsyb_item_code,'') = '' " +
  956. "group by a.charge_code_mx ")
  957. List<WeiGuiFeiYongFenXi> gongShangWeiPiPei(@Param("inpatientNo") String inpatientNo,
  958. @Param("admissTimes") Integer admissTimes,
  959. @Param("ledger") Integer ledger,
  960. @Param("infantFlag") Integer infantFlag);
  961. /**
  962. * 违规药品 信息 没有匹配的
  963. *
  964. * @param inpatientNo 住院号
  965. * @param admissTimes 住院次数
  966. * @param ledger 账页号
  967. * @return 返回违规药品 没有匹配的
  968. */
  969. @Select("select charge_code_mx,b.name from zy_detail_charge a, yp_zd_dict b " +
  970. "where trans_flag_yb not in (1,2) and charge_code like 'BILL%' " +
  971. " and isnull(b.national_code,'') = '' and inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  972. "and a.infant_flag = #{infantFlag} " +
  973. " and a.charge_code_mx = b.code " +
  974. "group by charge_code_mx, b.name")
  975. List<WeiGuiFeiYongFenXi> weiGuiYaoPin(@Param("inpatientNo") String inpatientNo,
  976. @Param("admissTimes") Integer admissTimes,
  977. @Param("ledger") Integer ledger,
  978. @Param("infantFlag") Integer infantFlag);
  979. @Select("select charge_code_mx,b.name from zy_detail_charge a, zd_charge_item b " +
  980. "where trans_flag_yb not in (1,2) and charge_code not like 'BILL%' " +
  981. " and isnull(b.national_code,'') = '' and inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  982. " and a.infant_flag = #{infantFlag} " +
  983. " and a.charge_code_mx = b.code " +
  984. "group by charge_code_mx, b.name")
  985. List<WeiGuiFeiYongFenXi> weiGuiXiangMu(@Param("inpatientNo") String inpatientNo,
  986. @Param("admissTimes") Integer admissTimes,
  987. @Param("ledger") Integer ledger,
  988. @Param("infantFlag") Integer infantFlag);
  989. @Select("<script>" +
  990. "select rtrim(inpatient_no) inpatient_no,admiss_times,ledger_sn,charge_code_mx,detail_sn,ori_detail_sn,order_no,charge_fee,charge_amount, " +
  991. " exec_unit_name = (select rtrim(name) name from zd_unit_code where exec_unit = code),charge_date,trans_flag_yb, exec_unit, " +
  992. " op_id_code = (select rtrim(name) name from a_employee_mi where code = op_id_code)," +
  993. " charge_code_name = (select rtrim(name) name from zd_charge_item where code = charge_code_mx),charge_code = 'xm' from zy_detail_charge " +
  994. "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} and infant_flag = #{infantFlag} " +
  995. " and charge_fee &lt; 0 and charge_code not like 'BILL%' " +
  996. " and trans_flag_yb not in (1,2) " +
  997. " and ori_detail_sn is null " +
  998. "<if test=\"chuYuanYiZhu == 0\">" +
  999. " and CONVERT(varchar(100), charge_date, 23) &lt;= CONVERT(varchar(100), GETDATE(), 23)" +
  1000. "</if>" +
  1001. "<if test=\"list.size >0 \">" +
  1002. " and exec_unit in " +
  1003. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  1004. "#{item}" +
  1005. "</foreach>" +
  1006. "</if>" +
  1007. "</script>")
  1008. List<ZyDetailCharge> weiXieDaiYuanLiuShuiXiangMu(@Param("inpatientNo") String inpatientNo,
  1009. @Param("admissTimes") Integer admissTimes,
  1010. @Param("ledger") Integer ledger,
  1011. @Param("infantFlag") Integer infantFlag,
  1012. @Param("list") List<String> execUnit,
  1013. @Param("chuYuanYiZhu") Integer chuYuanYiZhu);
  1014. @Select("<script>" +
  1015. "select rtrim(inpatient_no) inpatient_no,admiss_times,ledger_sn,charge_code_mx,detail_sn,order_no,ori_detail_sn,charge_fee,charge_amount, " +
  1016. " exec_unit_name = (select rtrim(name) name from zd_unit_code where exec_unit = code),charge_date,trans_flag_yb,exec_unit, " +
  1017. " op_id_code = (select rtrim(name) name from a_employee_mi where code = op_id_code)," +
  1018. " charge_code_name = (select top(1) rtrim(name) name from yp_zd_dict where code = charge_code_mx),charge_code = 'yp' from zy_detail_charge " +
  1019. "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} and infant_flag = #{infantFlag} " +
  1020. " and charge_fee &lt; 0 and charge_code like 'BILL%' " +
  1021. " and trans_flag_yb not in (1,2) " +
  1022. " and ori_detail_sn is null" +
  1023. "<if test=\"chuYuanYiZhu == 0\">" +
  1024. " and CONVERT(varchar(100), charge_date, 23) &lt;= CONVERT(varchar(100), GETDATE(), 23)" +
  1025. "</if>" +
  1026. "<if test=\"list.size > 0 \">" +
  1027. " and exec_unit in " +
  1028. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  1029. "#{item}" +
  1030. "</foreach>" +
  1031. "</if>" +
  1032. "</script>")
  1033. List<ZyDetailCharge> weiXieDaiYuanLiuShuiYaoPing(@Param("inpatientNo") String inpatientNo,
  1034. @Param("admissTimes") Integer admissTimes,
  1035. @Param("ledger") Integer ledger,
  1036. @Param("infantFlag") Integer infantFlag,
  1037. @Param("list") List<String> execUnit,
  1038. @Param("chuYuanYiZhu") Integer chuYuanYiZhu);
  1039. @Select("<script>" +
  1040. "select inpatient_no,admiss_times,ledger_sn,detail_sn,charge_amount,charge_fee,order_no,charge_code_mx,charge_date,ori_detail_sn " +
  1041. "from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx} " +
  1042. "<choose>" +
  1043. "<when test=\"execUnit != null and execUnit != ''\">" +
  1044. "and exec_unit = #{execUnit} " +
  1045. "</when>" +
  1046. "<otherwise>" +
  1047. "and order_no = #{orderNo}" +
  1048. "</otherwise>" +
  1049. "</choose>" +
  1050. "and trans_flag_yb &lt;&gt; 2 and order_no &lt;&gt; 6 and charge_fee &gt; 0 and charge_amount &gt; 0 " +
  1051. "and infant_flag = #{infantFlag} " +
  1052. "<if test=\"startTime != null and startTime != '' \">" +
  1053. "and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
  1054. "</if>" +
  1055. " order by charge_date ${riQiPaiXu}" +
  1056. "</script>")
  1057. List<ZyDetailCharge> weiGuiZhenShuPiPei(@Param("inpatientNo") String inpatientNo,
  1058. @Param("admissTimes") Integer admissTimes,
  1059. @Param("ledgerSn") Integer ledgerSn,
  1060. @Param("infantFlag") Integer infantFlag,
  1061. @Param("chargeCodeMx") String chargeCodeMx,
  1062. @Param("execUnit") String execUnit,
  1063. @Param("orderNo") String orderNo,
  1064. @Param("startTime") String startTime,
  1065. @Param("endTime") String endTime,
  1066. @Param("riQiPaiXu") String riQiPaiXu);
  1067. @Select("select inpatient_no,admiss_times,ledger_sn,detail_sn,charge_code_mx,sum(charge_fee) yi_tui_fei from ( " +
  1068. "select inpatient_no,admiss_times,ledger_sn,detail_sn,charge_code_mx,charge_fee " +
  1069. "from zy_detail_charge where " +
  1070. "inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx} " +
  1071. "and exec_unit = #{execUnit} and trans_flag_yb <> 2 and order_no <> 6 and" +
  1072. " detail_sn in(select ori_detail_sn from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and " +
  1073. "ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx}" +
  1074. " and charge_fee <0 and ori_detail_sn is not null) " +
  1075. "union all " +
  1076. "select inpatient_no,admiss_times,ledger_sn,ori_detail_sn,charge_code_mx,charge_fee " +
  1077. "from zy_detail_charge where " +
  1078. "inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx} " +
  1079. "and exec_unit = #{execUnit} and trans_flag_yb <> 2 and order_no <> 6 and " +
  1080. "ori_detail_sn in(select ori_detail_sn from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} " +
  1081. "and ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx} and charge_fee <0 and ori_detail_sn is not null) " +
  1082. ") temp " +
  1083. "group by inpatient_no, admiss_times, ledger_sn, detail_sn, charge_code_mx")
  1084. List<ZyDetailCharge> tuiFeiYuEr1(@Param("inpatientNo") String inpatientNo,
  1085. @Param("admissTimes") Integer admissTimes,
  1086. @Param("ledgerSn") Integer ledgerSn,
  1087. @Param("chargeCodeMx") String chargeCodeMx,
  1088. @Param("execUnit") String execUnit);
  1089. @Select("<script>" +
  1090. "select detail_sn,ori_detail_sn,order_no,charge_fee,charge_amount,charge_code_mx,charge_date, " +
  1091. " exec_unit_name = (select rtrim(name) from zd_unit_code where code =exec_unit), " +
  1092. " ward_code = (select rtrim(name) from zd_unit_code where code = ward_code) " +
  1093. " from zy_detail_charge where " +
  1094. " inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
  1095. "and infant_flag = #{infantFlag} " +
  1096. "and charge_code_mx = #{chargeCodeMx} and trans_flag_yb &lt;&gt; 2 and order_no &lt;&gt; 6 " +
  1097. "and charge_amount &gt; 0 " +
  1098. "<if test=\"startTime != null and startTime != '' \">" +
  1099. "and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
  1100. "</if>" +
  1101. "order by charge_date ${riQiPaiXu}" +
  1102. "</script>")
  1103. List<ZyDetailCharge> genJuBianMaChaZhaoZhenShuFeiYong(@Param("inpatientNo") String inpatientNo,
  1104. @Param("admissTimes") Integer admissTimes,
  1105. @Param("ledgerSn") Integer ledgerSn,
  1106. @Param("infantFlag") Integer infantFlag,
  1107. @Param("chargeCodeMx") String chargeCodeMx,
  1108. @Param("startTime") String startTime,
  1109. @Param("endTime") String endTime,
  1110. @Param("riQiPaiXu") String riQiPaiXu);
  1111. @Select("<script>" +
  1112. "select * from zy_detail_charge " +
  1113. "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and infant_flag = #{infantFlag} and detail_sn in " +
  1114. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  1115. "#{item}" +
  1116. "</foreach>" +
  1117. " and charge_fee &gt; 0 and charge_amount &gt; 0 " +
  1118. "</script>")
  1119. List<ZyDetailCharge> piPeiXinXi(@Param("inpatientNo") String inpatientNo,
  1120. @Param("admissTimes") Integer admissTimes,
  1121. @Param("ledgerSn") Integer ledgerSn,
  1122. @Param("infantFlag") Integer infantFlag,
  1123. @Param("list") int[] detailSnList);
  1124. @Select("<script>" +
  1125. "select inpatient_no,admiss_times,ledger_sn,ori_detail_sn,sum(charge_fee) charge_fee from zy_detail_charge " +
  1126. " where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and infant_flag = #{infantFlag} and ori_detail_sn in " +
  1127. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  1128. "#{item} " +
  1129. "</foreach>" +
  1130. "and charge_fee &lt; 0 and charge_amount &lt; 0 " +
  1131. "group by inpatient_no, admiss_times, ledger_sn, ori_detail_sn " +
  1132. "</script>")
  1133. List<ZyDetailCharge> tuiFeiYuEr2(@Param("inpatientNo") String inpatientNo,
  1134. @Param("admissTimes") Integer admissTimes,
  1135. @Param("ledgerSn") Integer ledgerSn,
  1136. @Param("infantFlag") Integer infantFlag,
  1137. @Param("list") int[] detailSnList);
  1138. @Select("select inpatient_no,admiss_times,ledger_sn,detail_sn,charge_fee,charge_amount,ori_detail_sn,trans_flag_yb,exec_unit from zy_detail_charge " +
  1139. "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and detail_sn = #{detailSn} " +
  1140. "and infant_flag = #{infantFlag} and charge_fee < 0 and charge_amount < 0 ")
  1141. ZyDetailCharge piPeiXinXiFuShu(@Param("inpatientNo") String inpatientNo,
  1142. @Param("admissTimes") Integer admissTimes,
  1143. @Param("ledgerSn") Integer ledgerSn,
  1144. @Param("infantFlag") Integer infantFlag,
  1145. @Param("detailSn") Integer detailSn);
  1146. @Update("update zy_detail_charge set ori_detail_sn = #{oriDetailSn} where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
  1147. "and detail_sn = #{detailSn} ")
  1148. void zhiYouYiGeJiuGenXingFuShuLiuShui(@Param("inpatientNo") String inpatientNo,
  1149. @Param("admissTimes") Integer admissTimes,
  1150. @Param("ledgerSn") Integer ledgerSn,
  1151. @Param("detailSn") Integer detailSn,
  1152. @Param("oriDetailSn") Integer oriDetailSn);
  1153. @Update("update zy_detail_charge set yb_self_flag = 0 ${ew.customSqlSegment}")
  1154. void xiuGaiZiFeiZhiYiBaoBiaoZhi(@Param(Constants.WRAPPER) Wrapper<?> wq);
  1155. }