XiangMuLuRuDao.java 66 KB

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