XiangMuLuRuDao.java 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  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 > 0 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("list") List<ZyDetailCharge> list);
  296. /**
  297. * 查询出 有哪些数据已经退过了 费用
  298. *
  299. * @param inpatientNo 住院号
  300. * @param admissTimes 住院次数
  301. * @param list 流水号
  302. * @return 返回 已经退过费用的数据
  303. */
  304. @Select("<script>" +
  305. "select " +
  306. "inpatient_no, " +
  307. " admiss_times, " +
  308. " ledger_sn, " +
  309. " detail_sn, " +
  310. " charge_date, " +
  311. " op_id_code, " +
  312. " charge_code, " +
  313. " bill_item_code = (select bill_item_zy from zd_charge_item where code = charge_code), " +
  314. " infant_flag, " +
  315. " charge_status, " +
  316. " retprice, " +
  317. " charge_amount, " +
  318. " charge_fee, " +
  319. " self_flag, " +
  320. " separate_flag, " +
  321. " suppress_flag, " +
  322. " ward_code, " +
  323. " dept_code, " +
  324. " order_no, " +
  325. " ope_flag, " +
  326. " exec_unit, " +
  327. " gen_time, " +
  328. " pay_percent, " +
  329. " zj_flag, " +
  330. " zfl, " +
  331. " charge_code_mx, " +
  332. " serial, " +
  333. " zy_serial_no, " +
  334. " doctor_code, " +
  335. " yb_self_flag, " +
  336. " orig_charge_fee, " +
  337. " confirm_id, " +
  338. " trans_flag_yb, " +
  339. " ss_code, " +
  340. " gs_flag, " +
  341. " refer_physician, " +
  342. " consult_physician, " +
  343. " ori_detail_sn" +
  344. " from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ori_detail_sn in " +
  345. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  346. "#{item.detailSn}" +
  347. "</foreach>" +
  348. "</script>")
  349. List<ZyDetailCharge> chaKanSFYiJingTuiFeiLe(@Param("inpatientNo") String inpatientNo,
  350. @Param("admissTimes") Integer admissTimes,
  351. @Param("list") List<ZyDetailCharge> list);
  352. /**
  353. * 插入数据
  354. *
  355. * @param list 插入退费的数据 生成一条一样的数据 只是 费用和数量不一致 以及录入人 和 录入时间 ori_detail_sn 保存退费的原流水号
  356. */
  357. @Insert("<script>" +
  358. "insert into zy_detail_charge(inpatient_no, admiss_times, ledger_sn, detail_sn, charge_date, op_id_code, charge_code, infant_flag, " +
  359. "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, " +
  360. "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, " +
  361. "refer_physician, consult_physician, ori_detail_sn) " +
  362. "values " +
  363. "<foreach collection='list' item='item' separator=','>" +
  364. "(#{item.inpatientNo},#{item.admissTimes},#{item.ledgerSn},#{item.detailSn},getdate(),#{item.opIdCode},#{item.chargeCode},#{item.infantFlag}," +
  365. "#{item.chargeStatus},#{item.retprice},cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)),cast(#{item.chargeFee,jdbcType=DECIMAL} as decimal(14,5))," +
  366. "#{item.selfFlag},#{item.separateFlag},#{item.suppressFlag},#{item.wardCode},#{item.deptCode},#{item.orderNo}," +
  367. "#{item.opeFlag},#{item.execUnit},#{item.oldGenTime}," +
  368. "#{item.payPercent},#{item.zjFlag},#{item.zfl},#{item.chargeCodeMx},#{item.serial},#{item.zySerialNo},#{item.doctorCode}," +
  369. "#{item.ybSelfFlag},cast(#{item.origChargeFee,jdbcType=DECIMAL} as decimal(14,5)),#{item.confirmId},0,#{item.ssCode},#{item.gsFlag}," +
  370. "#{item.referPhysician},#{item.consultPhysician},#{item.oriDetailSn})" +
  371. "</foreach>" +
  372. "</script>")
  373. void xiangMuTuiFei(@Param("list") List<ZyDetailCharge> list);
  374. /**
  375. * 更新对应 退费的正数 流水
  376. *
  377. * @param inpatientNo 住院号
  378. * @param admissTimes 住院次数
  379. * @param ledgerSn 账页号
  380. * @param list 正流水
  381. */
  382. @Update("<script>" +
  383. "update zy_detail_charge set ori_detail_sn = -1 where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} " +
  384. "and ledger_sn = #{ledgerSn} " +
  385. "and charge_fee &gt; 0 and charge_amount &gt; 0 and detail_sn in " +
  386. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  387. "#{item}" +
  388. "</foreach>" +
  389. "</script>")
  390. void genXinZhenShuTuiFeiLiuShui(@Param("inpatientNo") String inpatientNo,
  391. @Param("admissTimes") Integer admissTimes,
  392. @Param("ledgerSn") Integer ledgerSn,
  393. @Param("list") List<Integer> list);
  394. /**
  395. * 获取模板
  396. *
  397. * @param deptCode 根据科室来搜索
  398. * @return 返回模板信息
  399. */
  400. @Select("<script>" +
  401. "SELECT rtrim(a.pattern_name) name, " +
  402. " group_no=max(a.group_no), " +
  403. " op_id_code=max(op_id_code), " +
  404. " rtrim(b.name) op_name, " +
  405. " a.op_dept " +
  406. "FROM zy_charge_pattern a, " +
  407. " a_employee_mi b " +
  408. "WHERE " +
  409. " ( a.op_id_code = b.code ) and " +
  410. " a.pattern_name &lt;&gt; '' " +
  411. "<if test=\"deptCode != '3100000' \">" +
  412. " and op_dept=#{deptCode} " +
  413. "</if>" +
  414. "<if test=\"defaultNo == 0\">" +
  415. "and default_no &gt; 0 " +
  416. "</if>" +
  417. "group by a.pattern_name,a.op_dept, b.name" +
  418. "</script>")
  419. List<ZyDetailCharge> getMuBan(@Param("deptCode") String deptCode,
  420. @Param("defaultNo") Integer defaultNo);
  421. /**
  422. * 这个是获取模板下面的那些项目具体信息
  423. *
  424. * @param patternName 模板名称
  425. * @param opIdCode 录入人id
  426. * @return 返回模板 下面的详细信息
  427. */
  428. @Select("SELECT charge_name=RTRIM(b.name), " +
  429. " pattern_name=zy_charge_pattern.pattern_name, " +
  430. " charge_code_mx=b.code, " +
  431. " spec=charge_unit, " +
  432. " group_no='00', " +
  433. " serial='00', " +
  434. " amount=zy_charge_pattern.amount, " +
  435. " charge_amount=b.charge_amount , " +
  436. " self =b.self_flag, " +
  437. " separate_flag=b.separate_flag, " +
  438. " suprice_flag=b.suppress_flag, " +
  439. " infant='0', " +
  440. " per1=zy_charge_pattern.per1, " +
  441. " per2=zy_charge_pattern.per2, " +
  442. " per3=zy_charge_pattern.per3, " +
  443. " per4=zy_charge_pattern.per4, " +
  444. " per5=zy_charge_pattern.per5, " +
  445. " exec_unit_b=b.exec_unit, " +
  446. " item_no=zy_charge_pattern.item_no, " +
  447. " exec_unit_name=c.name, " +
  448. " exec_unit=zy_charge_pattern.exec_unit, " +
  449. " op_id_code=zy_charge_pattern.op_id_code, " +
  450. " zy_charge_pattern.py_code, " +
  451. " zy_charge_pattern.d_code, " +
  452. " price_b=b.charge_amount, " +
  453. " bill_item_code=b.bill_item_zy ," +
  454. " bill_item_name=(select name from zy_bill_item where code = b.bill_item_zy) " +
  455. "FROM zy_charge_pattern ,zd_charge_item b ,zd_unit_code c " +
  456. "WHERE ( zy_charge_pattern.pattern_name = #{patternName}) and " +
  457. " zy_charge_pattern.op_id_code=#{opIdCode} and " +
  458. " zy_charge_pattern.charge_code=b.code and " +
  459. " (isnull(b.del_flag,'0') <> '1' ) and " +
  460. " zy_charge_pattern.exec_unit*=c.code " +
  461. "union all " +
  462. "SELECT charge_name=RTRIM(d.name), " +
  463. " pattern_name=zy_charge_pattern.pattern_name, " +
  464. " charge_code_mx=b.charge_code, " +
  465. " spec=d.specification, " +
  466. " group_no=b.group_no, " +
  467. " serial=isnull(b.serial,'01'), " +
  468. " amount=zy_charge_pattern.amount, " +
  469. " charge_amount=d.pack_retprice, " +
  470. " self =d.self_flag, " +
  471. " separate_flag=d.separate_flag, " +
  472. " suprice=d.suprice_flag, " +
  473. " infant='0', " +
  474. " per1=zy_charge_pattern.per1, " +
  475. " per2=zy_charge_pattern.per2, " +
  476. " per3=zy_charge_pattern.per3, " +
  477. " per4=zy_charge_pattern.per4, " +
  478. " per5=zy_charge_pattern.per5, " +
  479. " exec_unit_b='' , " +
  480. " item_no=zy_charge_pattern.item_no, " +
  481. " exec_unit_name=c.name, " +
  482. " exec_unit=zy_charge_pattern.exec_unit, " +
  483. " op_id_code=zy_charge_pattern.op_id_code, " +
  484. " zy_charge_pattern.py_code, " +
  485. " zy_charge_pattern.d_code, " +
  486. " price_b=d.pack_retprice, " +
  487. " bill_item_code=d.bill_item_zy ," +
  488. " bill_item_name=(select name from zy_bill_item where code = d.bill_item_zy) " +
  489. "FROM zy_charge_pattern ,zd_unit_code c,yp_base_yf b,yp_zd_dict d " +
  490. "WHERE ( zy_charge_pattern.pattern_name = #{patternName}) and " +
  491. " zy_charge_pattern.op_id_code=#{opIdCode} and " +
  492. " zy_charge_pattern.group_no=b.group_no and " +
  493. " zy_charge_pattern.charge_code=b.charge_code and " +
  494. " isnull(zy_charge_pattern.serial,'01')=b.serial and " +
  495. " b.charge_code=d.code and " +
  496. " b.serial=d.serial and " +
  497. " isnull(d.del_flag,'0') <> '1' and " +
  498. " isnull(b.visible_flag_zy,'0') <> '1' and " +
  499. " zy_charge_pattern.exec_unit*=c.code")
  500. List<ZyDetailCharge> getMuBanXinXi(@Param("patternName") String patternName, @Param("opIdCode") String opIdCode);
  501. /**
  502. * 搜索项目信息
  503. *
  504. * @param pyCode 拼音码
  505. * @return 返回模板信息
  506. */
  507. @Select("SELECT a.code charge_code," +
  508. " a.code charge_code_mx, " +
  509. " a.exec_unit dept_code," +
  510. " rtrim(a.yb_comment) yb_comment, " +
  511. " RTRIM(a.name) charge_name, " +
  512. " a.charge_amount," +
  513. " amount = 1, " +
  514. " bill_item_code=a.bill_item_zy, " +
  515. " bill_item_name=(select name from zy_bill_item where code = a.bill_item_zy)," +
  516. " a.py_code, " +
  517. " a.d_code, " +
  518. " a.suppress_flag, " +
  519. " a.bill_item_out, " +
  520. " a.n_code, " +
  521. " self_flag =isnull(a.self_flag,'0'), " +
  522. " a.separate_flag , " +
  523. " spec=charge_unit, " +
  524. " a.yb_comment, " +
  525. " exec_unit_name=b.name, " +
  526. " serial='00', " +
  527. " group_no='00' " +
  528. "FROM zd_charge_item a,zd_unit_code b " +
  529. "where isnull(a.del_flag,'') <> '1' and " +
  530. " isnull(a.in_out_flag,'') <> '1' and " +
  531. " a.exec_unit*=b.code and " +
  532. " (a.py_code like #{pyCode} or a.code like #{pyCode} or a.name like #{pyCode})")
  533. List<ZyDetailCharge> queryXiangMu(String pyCode);
  534. @Select("SELECT distinct a.code charge_code_mx, " +
  535. " charge_code = (select charge_code from zy_bill_item where a.bill_item_zy = zy_bill_item.code), " +
  536. " a.serial, " +
  537. " RTRIM(a.name) charge_name, " +
  538. " a.pack_size amount, " +
  539. " charge_amount=a.pack_retprice, " +
  540. " spec=a.specification, " +
  541. " a.drug_flag , " +
  542. " a.fix_price, " +
  543. " c.stock_amount, " +
  544. " self_flag=isnull(a.self_flag,'0'), " +
  545. " suppress_flag=a.suprice_flag, " +
  546. " group_no=c.group_no, " +
  547. " bill_item_code=a.bill_item_zy, " +
  548. " bill_item_name=(select name from zy_bill_item where code = a.bill_item_zy), " +
  549. " ybbz=a.yb_comment_new, " +
  550. " yblx=(select name from yp_zd_yb_type where code=a.yb_flag_new), " +
  551. " xnh=a.xnh_flag " +
  552. "FROM yp_zd_dict a ,yp_print_name b , " +
  553. " yp_base_yf c " +
  554. "where " +
  555. "(a.py_code like #{pyCode} or a.name like #{pyCode} or a.code like #{pyCode}) and" +
  556. " a.code=b.charge_code and " +
  557. " a.code=c.charge_code and " +
  558. " a.serial=c.serial and " +
  559. " c.visible_flag_mz <> '1' and " +
  560. " c.visible_flag_zy <> '1' and" +
  561. " isnull(a.del_flag,0) = 0 and " +
  562. " c.group_no='73'")
  563. List<ZyDetailCharge> queryYaoPin(String pyCode);
  564. /**
  565. * 插入项目录入费用
  566. *
  567. * @param zyDetailCharge 插入的信息
  568. * @param list 费用详情
  569. */
  570. @Insert("<script>" +
  571. "INSERT INTO zy_detail_charge (inpatient_no, admiss_times, ledger_sn, detail_sn, charge_date " +
  572. " , op_id_code, charge_code, infant_flag, charge_status, charge_fee " +
  573. " , self_flag, separate_flag, suppress_flag, ward_code, dept_code " +
  574. " , order_no, ope_flag, exec_unit, charge_amount, gen_time " +
  575. " , zy_serial_no, charge_code_mx, serial,ss_code,yb_self_flag,refer_physician) " +
  576. "VALUES " +
  577. "<foreach collection='list' item='item' separator=','>" +
  578. "(#{zyDetailCharge.inpatientNo}, #{zyDetailCharge.admissTimes}, #{ledgerSn}, #{item.detailSn}, getdate() " +
  579. " , #{zyDetailCharge.opIdCode}, #{item.chargeCode}, #{infantFlag}, '2', cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)) " +
  580. " , '0', '0', NULL, #{zyDetailCharge.ward}, #{zyDetailCharge.dept} " +
  581. " , #{item.orderNo}, '0', #{item.deptCode}, cast(#{item.amount,jdbcType=DECIMAL} as decimal(14,5)), getdate() " +
  582. " , #{zyDetailCharge.zySerialNo}, #{item.chargeCodeMx}, #{item.serial},#{zyDetailCharge.ssCode}," +
  583. // 是否医保报销 标志 默认为空值
  584. "<if test=\"item.ybSelfFlag == null\">" +
  585. "0" +
  586. "</if>" +
  587. "<if test=\"item.ybSelfFlag != null\">" +
  588. "#{item.ybSelfFlag}" +
  589. "</if>" +
  590. ",#{zyDetailCharge.referPhysician})" +
  591. "</foreach>" +
  592. "</script>")
  593. void chaRuFeiYong(@Param("zyDetailCharge") ZyDetailCharge zyDetailCharge,
  594. @Param("list") List<ZyDetailCharge> list,
  595. @Param("infantFlag") int infantFlag,
  596. @Param("ledgerSn") Integer ledgerSn);
  597. @Insert("<script>" +
  598. "insert into zy_drug ( inpatient_no , admiss_times , ledger_sn , detail_sn , charge_date , op_id_code , charge_code , infant_flag , " +
  599. "charge_fee , self_flag , separate_flag , supress_flag , ward_code , dept_code , ope_flag , exec_unit , retprice , amount , zy_serial_no , " +
  600. "serial , group_no , occ_cate ) values " +
  601. "<foreach collection='list' item='item' separator=','>" +
  602. "( #{zyDetailCharge.inpatientNo} , #{zyDetailCharge.admissTimes} , #{ledgerSn} , #{item.detailSn} , getdate() , #{opIdCode} , " +
  603. "#{item.chargeCodeMx} , #{infantFlag} , " +
  604. // 金额
  605. "cast(#{item.chargeFee,jdbcType=DECIMAL} as decimal(14,5))," +
  606. " '0' , '0' , null , #{zyDetailCharge.ward} , #{zyDetailCharge.dept} , '0' , #{item.deptCode} ," +
  607. // 单价
  608. " cast(#{item.chargeFee,jdbcType=DECIMAL} / #{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)) , " +
  609. // 数量
  610. "cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)) " +
  611. ", #{zyDetailCharge.zySerialNo} , #{item.serial} , #{item.groupNo} ,'1' )" +
  612. "</foreach>" +
  613. "</script>")
  614. void shenQingYaoPing(@Param("zyDetailCharge") ZyDetailCharge zyDetailCharge,
  615. @Param("list") List<ZyDetailCharge> list,
  616. @Param("infantFlag") int infantFlag,
  617. @Param("ledgerSn") Integer ledgerSn,
  618. @Param("opIdCode") String opIdCode);
  619. /**
  620. * 需要更新患者的总费用
  621. *
  622. * @param fy 费用
  623. * @param inpatientNo 住院号
  624. * @param admissTimes 住院次数
  625. */
  626. @Update("<script>" +
  627. "update ${tableName} " +
  628. "<trim prefix='set' suffixOverrides=','> " +
  629. "total_charge = total_charge + #{fy.totalCharge} , " +
  630. "balance = balance - #{fy.totalCharge}," +
  631. "<if test=\"fy.charge1 !=null \">" +
  632. "charge1 =charge1 + #{fy.charge1} ," +
  633. "</if>" +
  634. "<if test=\"fy.charge2 !=null \">" +
  635. "charge2 =charge2 + #{fy.charge2} ," +
  636. "</if>" +
  637. "<if test=\"fy.charge3 !=null \">" +
  638. "charge3 =charge3 + #{fy.charge3} ," +
  639. "</if>" +
  640. "<if test=\"fy.charge4 !=null \">" +
  641. "charge4 =charge4 + #{fy.charge4} ," +
  642. "</if>" +
  643. "<if test=\"fy.charge5 !=null \">" +
  644. "charge5 =charge5 + #{fy.charge5} ," +
  645. "</if>" +
  646. "<if test=\"fy.charge6 !=null \">" +
  647. "charge6 =charge6 + #{fy.charge6} ," +
  648. "</if>" +
  649. "<if test=\"fy.charge7 !=null \">" +
  650. "charge7 =charge7 + #{fy.charge7} ," +
  651. "</if>" +
  652. "<if test=\"fy.charge8 !=null \">" +
  653. "charge8 =charge8 + #{fy.charge8} ," +
  654. "</if>" +
  655. "<if test=\"fy.charge9 !=null \">" +
  656. "charge9 =charge9 + #{fy.charge9} ," +
  657. "</if>" +
  658. "<if test=\"fy.charge10 !=null \">" +
  659. "charge10 =charge10 + #{fy.charge10} ," +
  660. "</if>" +
  661. "<if test=\"fy.charge11 !=null \">" +
  662. "charge11 =charge11 + #{fy.charge11} ," +
  663. "</if>" +
  664. "<if test=\"fy.charge12 !=null \">" +
  665. "charge12 =charge12 + #{fy.charge12} ," +
  666. "</if>" +
  667. "<if test=\"fy.charge13 !=null \">" +
  668. "charge13 =charge13 + #{fy.charge13} ," +
  669. "</if>" +
  670. "<if test=\"fy.charge14 !=null \">" +
  671. "charge14 =charge14 + #{fy.charge14} ," +
  672. "</if>" +
  673. "<if test=\"fy.charge15 !=null \">" +
  674. "charge15 =charge15 + #{fy.charge15} ," +
  675. "</if>" +
  676. "<if test=\"fy.charge16 !=null \">" +
  677. "charge16 =charge16 + #{fy.charge16} ," +
  678. "</if>" +
  679. "<if test=\"fy.charge17 !=null \">" +
  680. "charge17 =charge17 + #{fy.charge17} ," +
  681. "</if>" +
  682. "<if test=\"fy.charge18 !=null \">" +
  683. "charge18 =charge18 + #{fy.charge18} ," +
  684. "</if>" +
  685. "<if test=\"fy.charge19 !=null \">" +
  686. "charge19 =charge19 + #{fy.charge19} ," +
  687. "</if>" +
  688. "<if test=\"fy.charge20 !=null \">" +
  689. "charge20 =charge20 + #{fy.charge20} ," +
  690. "</if>" +
  691. "<if test=\"fy.charge21 !=null \">" +
  692. "charge21 =charge21 + #{fy.charge21} ," +
  693. "</if>" +
  694. "<if test=\"fy.charge22 !=null \">" +
  695. "charge22 =charge22 + #{fy.charge22} ," +
  696. "</if>" +
  697. "<if test=\"fy.charge23 !=null \">" +
  698. "charge23 =charge23 + #{fy.charge23} ," +
  699. "</if>" +
  700. "<if test=\"fy.charge24 !=null \">" +
  701. "charge24 =charge24 + #{fy.charge24} ," +
  702. "</if>" +
  703. "<if test=\"fy.charge25 !=null \">" +
  704. "charge25 =charge25 + #{fy.charge25} ," +
  705. "</if>" +
  706. "<if test=\"fy.charge26 !=null \">" +
  707. "charge26 =charge26 + #{fy.charge26} ," +
  708. "</if>" +
  709. "<if test=\"fy.charge27 !=null \">" +
  710. "charge27 =charge27 + #{fy.charge27} ," +
  711. "</if>" +
  712. "<if test=\"fy.charge28 !=null \">" +
  713. "charge28 =charge28 + #{fy.charge28} ," +
  714. "</if>" +
  715. "<if test=\"fy.charge29 !=null \">" +
  716. "charge29 =charge29 + #{fy.charge29} ," +
  717. "</if>" +
  718. "<if test=\"fy.charge30 !=null \">" +
  719. "charge30 =charge30 + #{fy.charge30} ," +
  720. "</if>" +
  721. "</trim>" +
  722. "WHERE inpatient_no = #{inpatientNo} and admiss_times=#{admissTimes}" +
  723. "</script>")
  724. void huanZheZongFeiYong(@Param("fy") FeiYongLeiXin fy,
  725. @Param("inpatientNo") String inpatientNo,
  726. @Param("admissTimes") Integer admissTimes,
  727. @Param("tableName") String tableName);
  728. /**
  729. * 查看模板名称是否存在
  730. *
  731. * @param patternName 模板名字
  732. * @param opIdCode 创建模板的人 code
  733. * @return 返回条数
  734. */
  735. @Select("select count(*) from zy_charge_pattern where pattern_name = #{patternName} and op_id_code <> #{opIdCode} ")
  736. Integer chaKanMuBanMingChengSFcunZi(@Param("patternName") String patternName,
  737. @Param("opIdCode") String opIdCode);
  738. /**
  739. * 删除模板
  740. *
  741. * @param patternName 模板名字
  742. * @param opIdCode 创建模板的人 code
  743. */
  744. @Select("delete zy_charge_pattern where pattern_name = #{patternName} and op_id_code = #{opIdCode} ")
  745. Integer delMuBan(@Param("patternName") String patternName,
  746. @Param("opIdCode") String opIdCode);
  747. /**
  748. * 保存模板
  749. *
  750. * @param param 保存的数据
  751. */
  752. @Insert("<script>" +
  753. "INSERT INTO zy_charge_pattern ( charge_name, " +
  754. " pattern_name, " +
  755. " charge_code, " +
  756. " group_no," +
  757. " serial, " +
  758. " amount, " +
  759. " self, " +
  760. " separate," +
  761. " suppress, " +
  762. " infant, " +
  763. " per1," +
  764. " per2," +
  765. " per3," +
  766. " per4," +
  767. " per5," +
  768. " item_no, " +
  769. " op_id_code, " +
  770. " py_code, " +
  771. " d_code, " +
  772. " charge_fee, " +
  773. " op_dept, " +
  774. " default_no " +
  775. " )" +
  776. " VALUES " +
  777. "<foreach collection='param.list' item='item' index='index' separator=','>" +
  778. "( substring(#{item.chargeName},0,15) , #{param.name} , #{item.chargeCodeMx} , #{item.groupNo}, #{item.serial}, cast(#{item.amount,jdbcType=DECIMAL} as decimal(14,5)) , " +
  779. "'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)) ," +
  780. " #{param.deptCode} , " +
  781. "#{param.defaultNo} )" +
  782. "</foreach>" +
  783. "</script>")
  784. void baoCunMuBan(@Param("param") ZyDetailCharge param);
  785. /**
  786. * 获取医嘱的费用
  787. *
  788. * @param inpatientNo 住院号
  789. * @param admissTimes 住院次数
  790. * @param ZF 正的费用还是负的费用
  791. * @return 返回list 费用集合
  792. */
  793. @Select("select charge_date,charge_fee,charge_amount,charge_code_mx,detail_sn,ori_detail_sn,ABS(order_no),order_no,ledger_sn,exec_unit " +
  794. "from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
  795. "and ori_detail_sn is null and charge_amount ${ZF} 0 and charge_fee ${ZF} 0 and ledger_sn > 0 and infant_flag = #{infantFlag} and trans_flag_yb <> 2")
  796. List<ZyDetailCharge> getYiZhuFeiYong(@Param("inpatientNo") String inpatientNo,
  797. @Param("admissTimes") Integer admissTimes,
  798. @Param("ledgerSn") Integer ledgerSn,
  799. @Param("ZF") String ZF,
  800. @Param("infantFlag") int infantFlag);
  801. /**
  802. * @param inpatientNo 住院号
  803. * @param admissTimes 住院次数
  804. * @param yiZhuPiPei 需要匹配的流水信息
  805. */
  806. @Update("<script>" +
  807. "<foreach collection='list' item='item' index='index' open='' close='' separator=';'>" +
  808. "update zy_detail_charge set ori_detail_sn = #{item.oriDetailSn} where inpatient_no= #{inpatientNo} and admiss_times = #{admissTimes} " +
  809. "and detail_sn = #{item.detailSn} and infant_flag = #{infantFlag} and ledger_sn = #{item.ledgerSn} " +
  810. "</foreach>" +
  811. "</script>")
  812. void yiZhuTuiFeiPiPei(@Param("inpatientNo") String inpatientNo,
  813. @Param("admissTimes") Integer admissTimes,
  814. @Param("list") List<ZyDetailCharge> yiZhuPiPei,
  815. @Param("infantFlag") int infantFlag);
  816. @Select("SELECT small_dept FROM zd_dept_all where dept = #{dept}")
  817. List<String> chaXunZhiZXinKeShi(@Param("dept") String dept);
  818. @Select("select role_id from dj_user_role where user_code = #{code}")
  819. List<Integer> huoQuJueSe(@Param("code") String code);
  820. @Select("select code,rtrim(name) name from zd_unit_code where code not like '8%'")
  821. List<GetDropdownBox> getDpet();
  822. @Select("select code,rtrim(name) name from zd_unit_code where code like '8%'")
  823. List<GetDropdownBox> getWard();
  824. @Select("SELECT small_dept code,name=(select name from zd_unit_code where code = small_dept) FROM zd_dept_all where dept = #{dept}")
  825. List<GetDropdownBox> getBingQuDuiYingKeShi(@Param("dept") String dept);
  826. @Select("select count(*) from zy_actpatient where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes}")
  827. Integer getHuanZheSFZaiYuan(@Param("inpatientNo") String inpatientNo,
  828. @Param("admissTimes") Integer admissTimes);
  829. @Select("select settle_type from zy_ledger_file where " +
  830. "inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} " +
  831. "and ledger_sn = (select max(ledger_sn)ledger_sn from zy_ledger_file where zy_ledger_file.inpatient_no = #{inpatientNo} " +
  832. "and zy_ledger_file.admiss_times = #{admissTimes}) ")
  833. Integer getHuanZheSFJieSuan(@Param("inpatientNo") String inpatientNo,
  834. @Param("admissTimes") Integer admissTimes);
  835. @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} " +
  836. "and detail_sn = #{detailSn} and order_no <> 6 and trans_flag_yb <> 2 ")
  837. ZyDetailCharge beiTuiFeiYongXinXi(@Param("inpatientNo") String inpatientNo,
  838. @Param("admissTimes") Integer admissTimes,
  839. @Param("ledger") Integer ledger,
  840. @Param("detailSn") Integer detailSn);
  841. @Select("<script>" +
  842. "select code from yp_zd_dict where code in " +
  843. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  844. " #{item}" +
  845. "</foreach> " +
  846. " and serial = '01' and isnull(del_flag,0) = 1 " +
  847. "union all " +
  848. "select code from zd_charge_item where code in " +
  849. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  850. " #{item}" +
  851. "</foreach> " +
  852. " and isnull(del_flag,0) = 1" +
  853. "</script>")
  854. List<String> chaXunFeiYongShiFouTingYong(List<String> bianMa);
  855. @Delete("delete zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  856. "and detail_sn = #{detailSn} and order_no <> 6 and trans_flag_yb <> 2")
  857. void cheXiaoFeiYong(@Param("inpatientNo") String inpatientNo,
  858. @Param("admissTimes") Integer admissTimes,
  859. @Param("ledger") Integer ledger,
  860. @Param("detailSn") Integer detailSn);
  861. @Update("update zy_detail_charge set ori_detail_sn = null where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  862. "and detail_sn = #{detailSn} and order_no <> 6 and trans_flag_yb <> 2")
  863. void cheXiaoHouHuanYuanZhenShuJu(@Param("inpatientNo") String inpatientNo,
  864. @Param("admissTimes") Integer admissTimes,
  865. @Param("ledger") Integer ledger,
  866. @Param("detailSn") Integer detailSn);
  867. @Select("select isnull(sum(charge_fee),0) from zy_detail_charge\n" +
  868. "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} and trans_flag_yb=2")
  869. BigDecimal zhenFuXingDiFeiYong(@Param("inpatientNo") String inpatientNo,
  870. @Param("admissTimes") Integer admissTimes,
  871. @Param("ledger") Integer ledger);
  872. @Update("update zy_detail_charge set trans_flag_yb = 0 where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} and trans_flag_yb = 2")
  873. void chongXingZhengFuXiangDi(@Param("inpatientNo") String inpatientNo,
  874. @Param("admissTimes") Integer admissTimes,
  875. @Param("ledger") Integer ledger);
  876. @Select("select b.code from zy_detail_charge a, yp_zd_dict b " +
  877. "where order_no <> 6 and trans_flag_yb not in (1,2) and charge_code like 'BILL%' " +
  878. " and isnull(b.national_code,'') = '' and inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  879. "and a.infant_flag = #{infantFlag} " +
  880. " and a.charge_code_mx = b.code " +
  881. "group by b.code ")
  882. List<Integer> weiGuiYaoPinInt(@Param("inpatientNo") String inpatientNo,
  883. @Param("admissTimes") Integer admissTimes,
  884. @Param("ledger") Integer ledger,
  885. @Param("infantFlag") Integer infantFlag);
  886. @Update("<script>" +
  887. "<foreach collection='list' item='item' separator=';'>" +
  888. "update yp_zd_dict set national_code = (select national_code from yp_zd_dict where code = #{item} and national_code is not null ) " +
  889. "where code = #{item} and national_code is null" +
  890. "</foreach>" +
  891. "</script>")
  892. void genXinYaoPingPiPeiXinXi(@Param("list") List<Integer> list);
  893. /**
  894. * 违规药品 信息 没有匹配的
  895. *
  896. * @param inpatientNo 住院号
  897. * @param admissTimes 住院次数
  898. * @param ledger 账页号
  899. * @return 返回违规药品 没有匹配的
  900. */
  901. @Select("select charge_code_mx,b.name,national_code from zy_detail_charge a, yp_zd_dict b " +
  902. "where order_no <> 6 and trans_flag_yb not in (1,2) and charge_code like 'BILL%' " +
  903. " and isnull(b.national_code,'') = '' and inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  904. "and a.infant_flag = #{infantFlag} " +
  905. " and a.charge_code_mx = b.code " +
  906. "group by charge_code_mx, b.name, national_code")
  907. List<WeiGuiFeiYongFenXi> weiGuiYaoPin(@Param("inpatientNo") String inpatientNo,
  908. @Param("admissTimes") Integer admissTimes,
  909. @Param("ledger") Integer ledger,
  910. @Param("infantFlag") Integer infantFlag);
  911. @Select("select charge_code_mx,b.name,national_code from zy_detail_charge a, zd_charge_item b " +
  912. "where order_no <> 6 and trans_flag_yb not in (1,2) and charge_code not like 'BILL%' " +
  913. " and isnull(b.national_code,'') = '' and inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  914. " and a.infant_flag = #{infantFlag} " +
  915. " and a.charge_code_mx = b.code " +
  916. "group by charge_code_mx, b.name, national_code")
  917. List<WeiGuiFeiYongFenXi> weiGuiXiangMu(@Param("inpatientNo") String inpatientNo,
  918. @Param("admissTimes") Integer admissTimes,
  919. @Param("ledger") Integer ledger,
  920. @Param("infantFlag") Integer infantFlag);
  921. @Select("<script>" +
  922. "select rtrim(inpatient_no) inpatient_no,admiss_times,ledger_sn,charge_code_mx,detail_sn,ori_detail_sn,charge_fee,charge_amount, " +
  923. " exec_unit_name = (select rtrim(name) name from zd_unit_code where exec_unit = code),charge_date,trans_flag_yb, exec_unit, " +
  924. " op_id_code = (select rtrim(name) name from a_employee_mi where code = op_id_code)," +
  925. " charge_code_name = (select rtrim(name) name from zd_charge_item where code = charge_code_mx),charge_code = 'xm' from zy_detail_charge " +
  926. "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  927. " and charge_fee &lt; 0 and charge_code not like 'BILL%' " +
  928. " and trans_flag_yb not in (1,2) " +
  929. " and ori_detail_sn is null" +
  930. "<if test=\"execUnit != null and execUnit != '' \">" +
  931. " and exec_unit = #{execUnit} " +
  932. "</if>" +
  933. "</script>")
  934. List<ZyDetailCharge> weiXieDaiYuanLiuShuiXiangMu(@Param("inpatientNo") String inpatientNo,
  935. @Param("admissTimes") Integer admissTimes,
  936. @Param("ledger") Integer ledger,
  937. @Param("infantFlag") Integer infantFlag,
  938. @Param("execUnit") String execUnit);
  939. @Select("<script>" +
  940. "select rtrim(inpatient_no) inpatient_no,admiss_times,ledger_sn,charge_code_mx,detail_sn,ori_detail_sn,charge_fee,charge_amount, " +
  941. " exec_unit_name = (select rtrim(name) name from zd_unit_code where exec_unit = code),charge_date,trans_flag_yb,exec_unit, " +
  942. " op_id_code = (select rtrim(name) name from a_employee_mi where code = op_id_code)," +
  943. " 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 " +
  944. "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
  945. " and charge_fee &lt; 0 and charge_code like 'BILL%' " +
  946. " and trans_flag_yb not in (1,2) " +
  947. " and ori_detail_sn is null" +
  948. "<if test=\"execUnit != null and execUnit != '' \">" +
  949. " and exec_unit = #{execUnit} " +
  950. "</if>" +
  951. "</script>")
  952. List<ZyDetailCharge> weiXieDaiYuanLiuShuiYaoPing(@Param("inpatientNo") String inpatientNo,
  953. @Param("admissTimes") Integer admissTimes,
  954. @Param("ledger") Integer ledger,
  955. @Param("infantFlag") Integer infantFlag,
  956. @Param("execUnit") String execUnit);
  957. @Select("<script>" +
  958. "select inpatient_no,admiss_times,ledger_sn,detail_sn,charge_amount,charge_fee,charge_code_mx,charge_date " +
  959. "from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx} and ori_detail_sn is null " +
  960. "and exec_unit = #{execUnit} and trans_flag_yb &lt;&gt; 2 and order_no &lt;&gt; 6 and charge_fee &gt; 0 and charge_amount &gt; 0 " +
  961. "<if test=\"startTime != null and startTime != '' \">" +
  962. "and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
  963. "</if>" +
  964. " order by charge_date ${riQiPaiXu}" +
  965. "</script>")
  966. List<ZyDetailCharge> weiGuiZhenShuPiPei(@Param("inpatientNo") String inpatientNo,
  967. @Param("admissTimes") Integer admissTimes,
  968. @Param("ledgerSn") Integer ledgerSn,
  969. @Param("chargeCodeMx") String chargeCodeMx,
  970. @Param("execUnit") String execUnit,
  971. @Param("startTime") String startTime,
  972. @Param("endTime") String endTime,
  973. @Param("riQiPaiXu") String riQiPaiXu);
  974. @Select("<script>" +
  975. "select * from zy_detail_charge " +
  976. "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and infant_flag = #{infantFlag} and detail_sn in " +
  977. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  978. "#{item}" +
  979. "</foreach>" +
  980. " and charge_fee > 0 and charge_amount > 0 " +
  981. "</script>")
  982. List<ZyDetailCharge> piPeiXinXi(@Param("inpatientNo") String inpatientNo,
  983. @Param("admissTimes") Integer admissTimes,
  984. @Param("ledgerSn") Integer ledgerSn,
  985. @Param("infantFlag") Integer infantFlag,
  986. @Param("list") int[] detailSnList);
  987. @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 " +
  988. "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and detail_sn = #{detailSn} " +
  989. "and infant_flag = #{infantFlag} and charge_fee < 0 and charge_amount < 0 ")
  990. ZyDetailCharge piPeiXinXiFuShu(@Param("inpatientNo") String inpatientNo,
  991. @Param("admissTimes") Integer admissTimes,
  992. @Param("ledgerSn") Integer ledgerSn,
  993. @Param("infantFlag") Integer infantFlag,
  994. @Param("detailSn") Integer detailSn);
  995. @Update("update zy_detail_charge set ori_detail_sn = #{oriDetailSn} where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
  996. "and detail_sn = #{detailSn} ")
  997. void zhiYouYiGeJiuGenXingFuShuLiuShui(@Param("inpatientNo") String inpatientNo,
  998. @Param("admissTimes") Integer admissTimes,
  999. @Param("ledgerSn") Integer ledgerSn,
  1000. @Param("detailSn") Integer detailSn,
  1001. @Param("oriDetailSn") Integer oriDetailSn);
  1002. }