YiZhuLuRuDao.java 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423
  1. package thyyxxk.webserver.dao.his.zhuyuanyisheng;
  2. import com.baomidou.mybatisplus.core.conditions.Wrapper;
  3. import com.baomidou.mybatisplus.core.toolkit.Constants;
  4. import org.apache.ibatis.annotations.*;
  5. import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
  6. import thyyxxk.webserver.entity.datamodify.SelectV2;
  7. import thyyxxk.webserver.entity.datamodify.YzActOrder;
  8. import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
  9. import thyyxxk.webserver.entity.inpatient.patient.Overview;
  10. import thyyxxk.webserver.entity.inpatient.patient.Patient;
  11. import thyyxxk.webserver.entity.login.UserInfo;
  12. import thyyxxk.webserver.entity.zhuyuanyisheng.DoctorSOrderFee;
  13. import thyyxxk.webserver.entity.zhuyuanyisheng.ZyOrderZk;
  14. import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.*;
  15. import java.math.BigDecimal;
  16. import java.util.Date;
  17. import java.util.List;
  18. import java.util.Set;
  19. /**
  20. * <p>
  21. * 描述: 医嘱录入dao
  22. * </p>
  23. *
  24. * @author xc
  25. * &#064;date 2022-01-04 17:00
  26. */
  27. @Mapper
  28. public interface YiZhuLuRuDao {
  29. @Select("SELECT " +
  30. "RTRIM(a.bed_no) bedNo, " +
  31. "RTRIM(a.inpatient_no) inpatientNo, " +
  32. "a.admiss_times, " +
  33. "RTRIM(a.name) as name, " +
  34. "sex=isnull(a.sex, 9), " +
  35. "mdtrtId=(select b.mdtrt_id from t_si_pat_info b where b.pat_no=a.inpatient_no " +
  36. "and b.times=a.admiss_times and b.ledger_sn=a.times_billed), " +
  37. "injurySerialNo=(select serial_no from t_injury_si_pat_info where pat_no=a.inpatient_no " +
  38. "and times=a.admiss_times and ledger_sn=a.times_billed), " +
  39. "medType=a.med_type, " +
  40. "dismissOrder=(select count(1) from yz_act_order b where b.inpatient_no=a.inpatient_no " +
  41. "and b.admiss_times=a.admiss_times and status_flag > '1' and isnull(group_no,'00')='00' " +
  42. "and order_code in ('06026','06053','05973'))," +
  43. "orderNoCount = (select count(1) " +
  44. " from yz_act_order c " +
  45. " where a.inpatient_no = c.inpatient_no " +
  46. " and c.admiss_times = a.admiss_times " +
  47. " and c.status_flag = '1' " +
  48. " and c.enter_oper = #{userCode}), " +
  49. " refer_physician, " +
  50. " (select name from a_employee_mi where code = refer_physician) as refer_physician_name, " +
  51. " consult_physician, " +
  52. " (select name from a_employee_mi where code = refer_physician) as consult_physician_name, " +
  53. " dept_director, " +
  54. " (select name from a_employee_mi where code = refer_physician) as dept_director_name " +
  55. "FROM zy_actpatient a with (NOLOCK) " +
  56. "where refer_physician = #{code} " +
  57. "ORDER BY cast(bed_no AS int) ")
  58. List<Patient> getMyPatient(String code);
  59. @Select("select isnull(balance,0) balance, " +
  60. " total_charge, " +
  61. " charge1, " +
  62. " charge2, " +
  63. " charge3, " +
  64. " charge4, " +
  65. " charge5, " +
  66. " charge6, " +
  67. " charge7, " +
  68. " charge8, " +
  69. " charge9, " +
  70. " charge10, " +
  71. " charge11, " +
  72. " charge12, " +
  73. " charge13, " +
  74. " charge14, " +
  75. " charge15, " +
  76. " charge16, " +
  77. " charge17, " +
  78. " charge18, " +
  79. " charge19, " +
  80. " charge20, " +
  81. " charge21, " +
  82. " charge22, " +
  83. " charge23, " +
  84. " charge24, " +
  85. " charge25, " +
  86. " charge26, " +
  87. " charge27, " +
  88. " charge28, " +
  89. " charge29, " +
  90. " charge30, " +
  91. " yp = (isnull(charge1 + charge2 + charge28, 0))," +
  92. " jyjc = (isnull(charge8 + charge9 + charge11 + charge18 + charge13, 0))," +
  93. " isnull(charge_yb, 0) charge_yb " +
  94. "from zy_ledger_file with (NOLOCK) " +
  95. "where inpatient_no = #{inpatientNo} " +
  96. " and admiss_times = #{admissTimes} " +
  97. " and ledger_sn = #{ledgerSn} ")
  98. HuanZheFeiYong feiYongXinXi(@Param("inpatientNo") String inpatientNo,
  99. @Param("admissTimes") Integer admissTimes,
  100. @Param("ledgerSn") Integer ledgerSn);
  101. @Select("select a.act_order_no, " +
  102. " cast(cast(a.act_order_no as decimal) as varchar) id, " +
  103. " newOrderFlag = (select count(*) " +
  104. " from new_act_order_recording " +
  105. " where new_act_order_recording.act_order_no = a.act_order_no), " +
  106. " order_code, " +
  107. " order_name, " +
  108. " rtrim(frequ_code) frequ_code, " +
  109. " frequ_code_name = (select rtrim(comm) " +
  110. " from yz_order_frequency " +
  111. " where code = frequ_code), " +
  112. " instruction, " +
  113. " discription, " +
  114. " infant_flag, " +
  115. " order_time, " +
  116. " physician, " +
  117. " start_time, " +
  118. " drug_specification, " +
  119. " drug_quan, " +
  120. " mini_unit_name = (select name " +
  121. " from yp_zd_unit with (NOLOCK) " +
  122. " where code = mini_unit), " +
  123. " rtrim(supply_code) supply_code, " +
  124. " supply_code_name = (select rtrim(supply_name) " +
  125. " from yz_supply_type with (NOLOCK) " +
  126. " where yz_supply_type.supply_code = a.supply_code), " +
  127. " a.inpatient_no, " +
  128. " a.admiss_times, " +
  129. " drug_flag, " +
  130. " enter_oper, " +
  131. " enter_oper_name = (select top (1) rtrim(name) " +
  132. " from a_employee_mi with (NOLOCK) " +
  133. " where code = enter_oper) /* 录入人 */, " +
  134. " enter_time, " +
  135. " mini_unit, " +
  136. " drug_weight, " +
  137. " drug_weight_unit, " +
  138. " rtrim(status_flag) status_flag, " +
  139. " status_time, " +
  140. " parent_no, " +
  141. " parent_no_name = (select kfc.order_name from yz_act_order kfc where kfc.act_order_no = a.parent_no), " +
  142. " self_buy, " +
  143. " dose, " +
  144. " dose_unit, " +
  145. " dose_unit_name = (select name " +
  146. " from yp_zd_unit with (NOLOCK) " +
  147. " where dose_unit = code), " +
  148. " drug_occ, " +
  149. " drug_volume, " +
  150. " drug_vol_unit, " +
  151. " exclu_back_time, " +
  152. " exclu_act_order_no, " +
  153. " pay_self, " +
  154. " serial, " +
  155. " group_no, " +
  156. " signer, " +
  157. " cl_code, " +
  158. " doctor_flag, " +
  159. " emergency_flag, " +
  160. " exclu_type='', " +
  161. " end_time_b=end_time, " +
  162. " new_flag='0', " +
  163. " order_no_pattern=0, " +
  164. " suprice_flag='', " +
  165. " self_flag ='', " +
  166. " pack_size=0.0, " +
  167. " parent_no_c= -1000, " +
  168. " reg_flag, " +
  169. " parent_flag='', " +
  170. " yb_self_flag, " +
  171. " kf_flag, " +
  172. " refer_physician, " +
  173. " consult_physician, " +
  174. " physician_name = (select top (1) rtrim(name) " +
  175. " from a_employee_mi with (NOLOCK) " +
  176. " where code = physician) /* 开这个医嘱的医生 */, " +
  177. " exec_unit, " +
  178. " exec_unit_name = (select top (1) rtrim(name) " +
  179. " from zd_unit_code with (NOLOCK) " +
  180. " where code = exec_unit), " +
  181. " a.dept_code, " +
  182. " dept_name = (select top (1) rtrim(name) " +
  183. " from zd_unit_code with (NOLOCK) " +
  184. " where code = dept_code), " +
  185. " a.ward_code, " +
  186. " ward_name = (select top (1) rtrim(name) " +
  187. " from zd_unit_code with (NOLOCK) " +
  188. " where code = a.ward_code), " +
  189. " /*管床医生*/ " +
  190. " refer_physician_name = (select rtrim(name) " +
  191. " from a_employee_mi with (NOLOCK) " +
  192. " where code = refer_physician), " +
  193. " group_no_name = (select rtrim(group_name) " +
  194. " from yp_zd_group_name with (NOLOCK) " +
  195. " where a.group_no = group_no), " +
  196. " signer_name = (select top (1) rtrim(name) " +
  197. " from a_employee_mi with (NOLOCK) " +
  198. " where code = signer) /*确认人*/, " +
  199. " confirm_time /*确认时间*/, " +
  200. " modifier, " +
  201. " modifier_name = (select top (1) rtrim(name) " +
  202. " from a_employee_mi with (NOLOCK) " +
  203. " where code = modifier) /*停止人*/, " +
  204. " end_time /*停止时间*/, " +
  205. " b.new_ward as zkWardCode, " +
  206. " b.new_dept as zkDeptCode, " +
  207. " kss.yyfs, " +
  208. " kss.ssqk, " +
  209. " kss.yysj, " +
  210. " executer1 = (select name from a_employee_mi where code = executer1), " +
  211. " executer2= (select name from a_employee_mi where code = executer2) " +
  212. "from view_xc_all_yz a with (NOLOCK) left join " +
  213. "zy_order_zk b with (NOLOCK) on (a.act_order_no = b.act_order_no) left join " +
  214. "yz_act_record_kss kss on (a.act_order_no = kss.act_order_no) " +
  215. " ${ew.customSqlSegment} ")
  216. List<XinZhenYzActOrder> selectOrderNo(@Param(Constants.WRAPPER) Wrapper<?> wq);
  217. @Select("select act_order_no, " +
  218. "rtrim(status_flag) status_flag," +
  219. "frequ_code," +
  220. "enter_oper," +
  221. "inpatient_no " +
  222. "from yz_act_order with (NOLOCK) " +
  223. "${ew.customSqlSegment}")
  224. List<XinZhenYzActOrder> getOrdersToDelete(@Param(Constants.WRAPPER) Wrapper<?> wq);
  225. @Update("update yz_act_order " +
  226. "set " +
  227. " order_time = #{order.orderTime,jdbcType=TIMESTAMP}, " +
  228. " start_time = #{order.startTime,jdbcType=TIMESTAMP}, " +
  229. " end_time = #{order.endTime,jdbcType=TIMESTAMP}, " +
  230. " supply_code = '044', " +
  231. " frequ_code = #{order.frequCode}," +
  232. " group_no = #{order.groupNo}," +
  233. " exec_unit = #{order.execUnit}, " +
  234. " modifier = #{order.modifier} " +
  235. "where act_order_no = ${orderNo} ")
  236. void updateSubOrderStatus(BigDecimal orderNo, XinZhenYzActOrder order);
  237. @Delete("delete yz_act_order ${ew.customSqlSegment} ")
  238. void deleteMultipleOrders(@Param(Constants.WRAPPER) Wrapper<?> wq);
  239. @Update("<script>" +
  240. "update yz_act_order " +
  241. "set parent_no = null " +
  242. "where inpatient_no = #{patNo} " +
  243. " and admiss_times = #{times} " +
  244. " and parent_no in " +
  245. "<foreach collection='list' item='item' open='(' close=')' separator=','>" +
  246. "#{item}" +
  247. "</foreach>" +
  248. "</script>")
  249. void deleteParentChildRelationship(String patNo,
  250. Integer times,
  251. List<BigDecimal> list);
  252. @Select("<script>" +
  253. "<foreach collection=\"list\" item=\"item\" index=\"index\" separator=\";\">" +
  254. "update yz_act_order " +
  255. "set modifier = #{userCode}, " +
  256. " end_time = #{item.endTime} " +
  257. "where inpatient_no = #{patNo} " +
  258. " and admiss_times = #{times}" +
  259. " and (act_order_no = #{item.actOrderNo} or parent_no = #{item.actOrderNo}) " +
  260. " and end_time is null" +
  261. "</foreach>" +
  262. "</script>")
  263. void setStopTime(List<XinZhenYzActOrder> list,
  264. String userCode,
  265. String patNo,
  266. Integer times);
  267. @Select("SELECT rtrim(a.code) + rtrim(serial) as id, " +
  268. " py_code=a.py_code, " +
  269. " d_code =a.d_code, " +
  270. " order_code =a.code, " +
  271. " order_name =a.name, " +
  272. " drug_specification=a.specification, " +
  273. " drug_flag =case a.infusion_flag " +
  274. " when '1' then 'i' " +
  275. " else (case categories_flag " +
  276. " when '0' " +
  277. " then 'd' " +
  278. " else 'z' " +
  279. " end) " +
  280. " end, " +
  281. " parent_code=null, " +
  282. " exclu_group_type=null, " +
  283. " discription=case a.infusion_flag " +
  284. " when '1' then '大输液' " +
  285. " else (case " +
  286. " when a.code >= '30000' and a.code < '50000' then '中药' " +
  287. " else '西药 ' end) end + convert(char(10), a.pack_retprice) + '元' + '(医保类别:' + " +
  288. " ltrim(rtrim(yb_flag_new)) + ';报销比例:' + ltrim(rtrim(yb_bl_new)) + ';医保说明:' + " +
  289. " ltrim(rtrim(yb_comment_new)) + ')', " +
  290. " serial=a.serial, " +
  291. " group_no=a.group_no, " +
  292. " infusion_flag=a.infusion_flag, " +
  293. " group_name =a.group_name, " +
  294. " pack_size=a.pack_size," +
  295. " (select name " +
  296. " from yp_zd_unit with (NOLOCK) " +
  297. " where code = pack_unit) as pack_size_name, " +
  298. " order_class='Y', " +
  299. " spec_pack=a.spec_pack, " +
  300. " jsy_flag =a.jsy_flag, " +
  301. " xnh_flag, " +
  302. " yb_comment, " +
  303. " dosage = a.dosage, " +
  304. " yb_type, " +
  305. " yb_flag_new," +
  306. " father_flag, " +
  307. " manu_name=(select name from yp_zd_manufactory with (NOLOCK) where code = a.manu_code), " +
  308. " stock_amount=a.stock_amount, " +
  309. " national_code," +
  310. " national_name " +
  311. "FROM view_yp_zd_dict_base_yf a with (NOLOCK) " +
  312. "WHERE isnull(a.visible_flag_zy, '') <> '1' " +
  313. " and (a.py_code like #{code} or a.name like #{code} or code like #{code}) " +
  314. " and group_no = '${groupNo}' ")
  315. List<YiZhuMingChen> yiZhuYaoPing(@Param("code") String code,
  316. @Param("groupNo") String groupNo);
  317. @Select("select act_order_no, " +
  318. "rtrim(status_flag) as status_flag," +
  319. "rtrim(frequ_code) as frequ_code," +
  320. "rtrim(supply_code) as supply_code, " +
  321. "inpatient_no," +
  322. "admiss_times," +
  323. "enter_oper," +
  324. "rtrim(serial) as serial," +
  325. "order_time," +
  326. "start_time," +
  327. "end_time," +
  328. "group_no," +
  329. "ward_code," +
  330. "parent_no " +
  331. "from yz_act_order with (NOLOCK) " +
  332. "where act_order_no = #{orderNo} ")
  333. XinZhenYzActOrder getActOrderNoOne(String orderNo);
  334. @Select("select cast(cast(act_order_no as decimal) as varchar) " +
  335. "from yz_act_order with (NOLOCK) " +
  336. "where parent_no = #{orderNo}")
  337. List<String> getParentChildOrders(String orderNo);
  338. @Select("<script>" +
  339. "select * " +
  340. "from zy_detail_charge with (NOLOCK) " +
  341. "where inpatient_no = #{patNo} " +
  342. " and admiss_times = #{times} " +
  343. " and ori_detail_sn is null" +
  344. " and charge_fee > 0 " +
  345. " and order_no in " +
  346. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  347. " #{item}" +
  348. "</foreach>" +
  349. "</script>")
  350. List<ZyDetailCharge> getExpenseData(String patNo,
  351. Integer times,
  352. List<String> list);
  353. @Update("<script>" +
  354. "update zy_detail_charge " +
  355. "set ori_detail_sn = -1 " +
  356. "where inpatient_no = #{patNo} " +
  357. " and admiss_times = #{times} " +
  358. " and ori_detail_sn is null " +
  359. " and charge_fee > 0 " +
  360. " and order_no in " +
  361. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  362. " #{item}" +
  363. "</foreach>" +
  364. "</script>")
  365. void updateItemFlag(String patNo,
  366. Integer times,
  367. List<String> list);
  368. @Update("update yz_act_order " +
  369. "set status_flag = '-1', " +
  370. " end_time = getdate(), " +
  371. " modifier = #{userCode}, " +
  372. " instruction = #{reasonForCancellation}," +
  373. " order_name = cast('(作废)' + yz_act_order.order_name as char(100))" +
  374. "where act_order_no = #{orderNo}")
  375. void updateVoidedOrders(String orderNo,
  376. String userCode,
  377. String reasonForCancellation);
  378. @Update("update yz_yp_zy_order set status_flag = 2 where act_order_no = #{order} and status_flag = 1")
  379. void refusalToDispenseMedication(String order);
  380. @Update("update yz_act_order " +
  381. "set status_flag = '-1', " +
  382. " end_time = getdate(), " +
  383. " modifier = #{userCode}, " +
  384. " instruction = #{reasonForCancellation}, " +
  385. " order_name = cast('(作废)' + yz_act_order.order_name as char(100))" +
  386. "where parent_no = #{orderNo}")
  387. void updateChildOrders(String orderNo,
  388. String userCode,
  389. String reasonForCancellation);
  390. /**
  391. * @param deptCode 科室编码
  392. * @return 获取医生下面的病区
  393. */
  394. @Select("select dept " +
  395. "from zd_dept_all with (NOLOCK) " +
  396. "where small_dept = #{deptCode} " +
  397. " and dept is not null")
  398. List<String> getTheDoctorSDepartment(String deptCode);
  399. /**
  400. * @param orderNo 医嘱号
  401. * @return 获取已经确认收费的医嘱
  402. */
  403. @Select("select count(*) " +
  404. "from yz_zy_patient_fee with (NOLOCK) " +
  405. "where " +
  406. "inpatient_no = #{patNo} and " +
  407. "admiss_times = #{times} and " +
  408. "act_order_no = #{orderNo} and " +
  409. "charge_status = '3'")
  410. Integer getADoctorSOrderWithADefiniteFee(String patNo,
  411. Integer times,
  412. String orderNo);
  413. @Select("select count(*) " +
  414. "from zy_detail_charge with (NOLOCK) " +
  415. "where inpatient_no = #{patNo} " +
  416. " and admiss_times = #{times} " +
  417. " and order_no = #{orderNo} " +
  418. " and ori_detail_sn is null" +
  419. " and charge_fee > 0 ")
  420. Integer getDetailChargeFee(String patNo,
  421. Integer times,
  422. String orderNo);
  423. @Update("UPDATE " +
  424. " yz_zy_patient_fee " +
  425. "SET charge_status = '2', " +
  426. " op_id = #{userid}, " +
  427. " op_date = GETDATE() " +
  428. "WHERE act_order_no = #{orderNo} " +
  429. " AND inpatient_no = #{patNo} " +
  430. " AND admiss_times = #{times} ")
  431. void cancelMedicalTechnologyAssuranceFee(String userid,
  432. String orderNo,
  433. String patNo,
  434. Integer times);
  435. /**
  436. * 获取,有未确认和未执行的医嘱
  437. *
  438. * @param patNo 住院号
  439. * @param times 住院次数
  440. * @param orderNo 医嘱号
  441. * @return 数据
  442. */
  443. @Select("select count(1) " +
  444. "from yz_act_order with (NOLOCK) " +
  445. "where inpatient_no = #{patNo} " +
  446. " and admiss_times = #{times} " +
  447. " and status_flag in (1, 2)" +
  448. " and frequ_code <> 'ONCE' " +
  449. " and act_order_no <> #{orderNo}")
  450. Integer thereAreUnexecutedOrders(String patNo,
  451. Integer times,
  452. BigDecimal orderNo);
  453. @Select("select count(1) " +
  454. "from yz_act_order " +
  455. "where inpatient_no = #{yz.inpatientNo} " +
  456. " and admiss_times = #{yz.admissTimes} " +
  457. " and status_flag = 1 " +
  458. " and isnull(self_buy, '0') <> '4' " +
  459. " and enter_oper = #{userCode} " +
  460. " and order_code in (select rtrim(order_code) " +
  461. " from yz_zd_order_item_confirm " +
  462. " where item_name = N'出院')")
  463. int selectDischargeOrde(@Param("yz") XinZhenYiZhu yz,
  464. @Param("userCode") String userCode);
  465. @Update("update yz_act_order " +
  466. "set modifier = #{userCode}, " +
  467. " end_time = #{date}, " +
  468. " exclu_act_order_no = #{orderNo}, " +
  469. " status_flag = '5' " +
  470. "where inpatient_no = #{patNo} " +
  471. " and admiss_times = #{times} " +
  472. " and status_flag in ('1', '2') " +
  473. " and act_order_no <> #{orderNo} ")
  474. void stopNotConfirmedOrder(String patNo, Integer times, Date date, String userCode, BigDecimal orderNo);
  475. @Update("update yz_act_order " +
  476. "set modifier = #{userCode}, " +
  477. " end_time = #{date}, " +
  478. " exclu_act_order_no = #{orderNo} " +
  479. "where inpatient_no = #{patNo} " +
  480. " and admiss_times = #{times} " +
  481. " and status_flag in ('3', '4') " +
  482. " and frequ_code != 'ONCE' " +
  483. " and act_order_no <> #{orderNo} " +
  484. " AND (end_time IS NULL or end_time < #{date}) ")
  485. void stopOrder(String patNo, Integer times, Date date, String userCode, BigDecimal orderNo);
  486. @Update("update yz_act_order " +
  487. "set confirm_time = #{confirmDate}, " +
  488. " signer = #{userCode}, " +
  489. " status_time = #{confirmDate}, " +
  490. " status_flag = '2'," +
  491. " supply_code = case " +
  492. " when parent_no is not null then (select isnull(nullif(supply_child, ''), '044') " +
  493. " from yz_supply_type c " +
  494. " where c.supply_code = (select supply_code " +
  495. " from yz_act_order b " +
  496. " where b.act_order_no = yz_act_order.parent_no)) " +
  497. " else " +
  498. " yz_act_order.supply_code end " +
  499. " where act_order_no = #{decimal}")
  500. void confirmOrders(BigDecimal decimal, String userCode, Date confirmDate);
  501. @Update("update yz_act_order " +
  502. "set confirm_time = #{confirmDate}, " +
  503. " signer = #{userCode}, " +
  504. " status_time = #{confirmDate}, " +
  505. " status_flag = '2'," +
  506. " modifier = #{userCode}," +
  507. " end_time = #{confirmDate}, " +
  508. " frequ_code = 'ONCE' " +
  509. " where act_order_no = #{decimal} ")
  510. void takeMedicineAfterDischargeStopOrder(BigDecimal decimal, String userCode, Date confirmDate);
  511. @Delete("delete yz_act_record_kss where act_order_no =#{orderNo}; " +
  512. "delete zy_order_zk where act_order_no =#{orderNo};" +
  513. "delete op_record where inpatient_no = #{patNo} and act_order_no =#{orderNo};" +
  514. "delete ysh_yj_req where inpatient_no =#{patNo} and act_order_no =#{orderNo};" +
  515. "DELETE FROM yz_act_order WHERE act_order_no = #{orderNo}; ")
  516. void toDeleteAnOrder(String orderNo, String patNo);
  517. @Update("UPDATE yz_act_order SET parent_no = NULL WHERE parent_no = #{orderNo} ")
  518. void deleteGroup(String orderNo);
  519. @Delete("delete yz_act_order where " +
  520. "act_order_no = #{orderNo} ")
  521. void deleteOrderNo(String orderNo);
  522. @Insert("INSERT INTO yz_act_order (order_code, order_name, frequ_code, instruction, discription, infant_flag, order_time, " +
  523. " /*录入人*/physician, start_time, drug_specification, drug_quan, supply_code, act_order_no, inpatient_no, " +
  524. " admiss_times, drug_flag/*药品中找这个是 药品的类型 a i d*/, enter_oper, /*录入时间*/ " +
  525. " enter_time, " +
  526. " mini_unit /*药品中找 最小包装规格*/, " +
  527. " drug_weight/*药品的重量*/, drug_weight_unit/*药品重量单位*/, " +
  528. " status_flag/*1*/, self_buy, dose, dose_unit, drug_occ, drug_volume/*药品中的 volum 找*/, " +
  529. " drug_vol_unit/* 药品中的 vol_unit */, pay_self/*0*/, " +
  530. " serial/*前端传*/, group_no/*药房 */, doctor_flag/*写死为 1*/, exec_unit, dept_code/* 在院病人表中的 dept */, " +
  531. " ward_code /* 在院病人表中的 zk_ward*/, " +
  532. " reg_flag/* 0 */, " +
  533. " yb_self_flag/*医保自费标志*/, emergency_flag, " +
  534. " kf_flag /*饭前饭后*/, parent_no, refer_physician/*患者的管床医生*/, end_time," +
  535. " modifier) " +
  536. "values (#{pa.orderCode}, #{pa.orderName}, #{pa.frequCode}, #{pa.instruction}, #{pa.discription}, #{patInfo.infantFlag}, " +
  537. " #{pa.orderTime}, #{userCode}, " +
  538. " #{pa.startTime}, cast(#{pa.drugSpecification} as varchar(16)), #{pa.drugQuan,jdbcType=REAL}, #{pa.supplyCode}, #{pa.actOrderNo,jdbcType=REAL}, #{patInfo.inpatientNo}, " +
  539. " #{patInfo.admissTimes}, #{pa.drugFlag}, #{userCode}, getdate(), " +
  540. " #{pa.miniUnit}, #{pa.drugWeight,jdbcType = REAL}, #{pa.drugWeightUnit,jdbcType=REAL}, '1', #{pa.selfBuy}, " +
  541. " #{pa.dose ,jdbcType = REAL}, #{pa.doseUnit}, #{pa.drugOcc ,jdbcType = REAL}, " +
  542. " #{pa.drugVolume,jdbcType=REAL}, #{pa.drugVolUnit}, '0', #{pa.serial}, #{pa.groupNo}, '1', #{pa.execUnit}, " +
  543. " #{patInfo.deptCode}, #{patInfo.deptCode}, '0', #{pa.ybSelfFlag}, #{pa.emergencyFlag}, " +
  544. " #{pa.kfFlag}, #{pa.parentNo,jdbcType=REAL}, #{patInfo.referPhysician}, #{pa.endTime}," +
  545. " #{pa.modifier})")
  546. void insertEntryOrder(XinZhenYiZhu patInfo, XinZhenYzActOrder pa, String userCode);
  547. @Update("update yz_act_order set " +
  548. "frequ_code = #{frequCode}," +
  549. "exec_unit = #{execUnit}," +
  550. "order_time = #{orderTime}," +
  551. "start_time = #{startTime,jdbcType=TIMESTAMP}," +
  552. "end_time = #{endTime,jdbcType=TIMESTAMP}," +
  553. "group_no = #{groupNo}," +
  554. "modifier = #{modifier} " +
  555. "where parent_no = #{actOrderNo,jdbcType=REAL}")
  556. void howOftenTheSubPhysicianOrderIsModified(XinZhenYzActOrder pa);
  557. @Select("SELECT rtrim(a.order_code) + '00' as id," +
  558. "a.py_code, " +
  559. " a.d_code, " +
  560. " a.order_code , " +
  561. " rtrim(a.order_name) order_name, " +
  562. " drug_specification='诊疗项目', " +
  563. " drug_flag = isnull(operation,'o') , " +
  564. " a.parent_code , " +
  565. " a.exclu_group_type, " +
  566. " discription=a.discription + ' ' + a.yb_comment, " +
  567. " serial ='00', " +
  568. " group_no='00', " +
  569. " infusion_flag='', " +
  570. " group_name ='', " +
  571. " pack_size=1, " +
  572. " order_class=a.order_class, " +
  573. " spec_pack='', " +
  574. " jsy_flag ='', " +
  575. " xnh_flag='', " +
  576. " yb_comment =null, " +
  577. " dosage='', " +
  578. " yb_type='', " +
  579. " father_flag='0', " +
  580. " manu_name='', " +
  581. " stock_amount=0 " +
  582. "FROM yz_order_item a with (NOLOCK) " +
  583. "WHERE isnull(a.del_flag, '') <> '1' " +
  584. " and (py_code like #{code} or order_name like #{code} or order_code like #{code}) " +
  585. " and order_code not in (select zy_order_code from jc_zd_item) " +
  586. " and isnull(exec_dept, '') <> '2010000' ")
  587. List<YiZhuMingChen> yiZhuXiangMu(String code);
  588. @Select("SELECT a.py_code, " +
  589. " a.d_code, " +
  590. " a.pattern_code as order_code, " +
  591. " a.pattern_name as order_name, " +
  592. " specification=' ', " +
  593. " order_type ='t', " +
  594. " parent_code=space(7), " +
  595. " exclu_group_type=space(1), " +
  596. " discription='成组医嘱', " +
  597. " serial ='0000', " +
  598. " group_no='0000', " +
  599. " infusion_flag='', " +
  600. " drug_flag ='', " +
  601. " group_name ='', " +
  602. " pack_size =1, " +
  603. " order_class ='', " +
  604. " spec_pack='', " +
  605. " jsy_flag ='', " +
  606. " exclu_group_type='', " +
  607. " xnh_flag='', " +
  608. " yb_comment =null, " +
  609. " dosage = '', " +
  610. " yb_type='', " +
  611. " father_flag='0', " +
  612. " manu_name='', " +
  613. " stock_amount=0 " +
  614. "FROM yz_OrderPattern a with (NOLOCK) " +
  615. "where (py_code like #{code} or " +
  616. "pattern_name like #{code} or " +
  617. "d_code like #{code}) and dept_code = #{deptCode} ")
  618. List<YiZhuMingChen> composeOrders(String code, String deptCode);
  619. @Select("SELECT act_order_no, " +
  620. " order_name, " +
  621. " order_time, " +
  622. " start_time, " +
  623. " rtrim(frequ_code) frequ_code, " +
  624. " frequ_code_name = (select rtrim(comm) from yz_order_frequency where frequ_code = code), " +
  625. " rtrim(supply_code) supply_code, " +
  626. " supply_code_name = (select rtrim(supply_name) " +
  627. " from yz_supply_type " +
  628. " where yz_act_order.supply_code = yz_supply_type.supply_code)," +
  629. " group_no, " +
  630. " group_no_name = (select rtrim(group_name) " +
  631. " from yp_zd_group_name " +
  632. " where yp_zd_group_name.group_no = yz_act_order.group_no) " +
  633. "FROM yz_act_order with (NOLOCK) " +
  634. "WHERE inpatient_no = #{patNo} " +
  635. " AND admiss_times = #{times} " +
  636. " AND isnull(parent_no, 0) = 0 " +
  637. " and status_flag = '1' " +
  638. " and serial <> '00' ")
  639. List<XinZhenYzActOrder> getParentOrders(String patNo, Integer times);
  640. @Select("SELECT cast(rtrim(isnull(nullif(del_flag, " +
  641. " ''), " +
  642. " 0)) as int) as del_flag, " +
  643. " national_code as national_code, " +
  644. " name as order_name " +
  645. "FROM yz_order_occurence a with (NOLOCK), " +
  646. " zd_charge_item b with (NOLOCK) " +
  647. "where a.occ_code = b.code " +
  648. " and a.order_code = #{code}")
  649. List<XinZhenYzActOrder> huoQuXiangMu(String code);
  650. @Select("select isnull(exclu_group_type, 0) " +
  651. "from yz_order_item with (NOLOCK) where order_code = #{code}")
  652. Integer shiFouPaiChiYiZhu(String code);
  653. @Select("select " +
  654. " drug_flag, categories_flag," +
  655. " a.serial, " +
  656. " /* 医保自费 */ " +
  657. " cast(isnull(NULLIF(self_flag_yb, " +
  658. " ''), " +
  659. " 0) as int) as self_flag_yb, " +
  660. " /* 重量 */ " +
  661. " weight, " +
  662. " /* 重量单位 */ " +
  663. " weigh_unit, " +
  664. " weigh_unit_name = (select name " +
  665. " from yp_zd_unit with (NOLOCK) " +
  666. " where code = weigh_unit), " +
  667. " /*体积*/ " +
  668. " volum, " +
  669. " /*体积单位*/ " +
  670. " vol_unit, " +
  671. " vol_unit_name = (select name " +
  672. " from yp_zd_unit with (NOLOCK) " +
  673. " where code = vol_unit), " +
  674. " /*包装体积*/ " +
  675. " pack_size, " +
  676. " /*包装单位*/ " +
  677. " pack_unit, " +
  678. " pack_unit_name = (select name " +
  679. " from yp_zd_unit with (NOLOCK) " +
  680. " where code = pack_unit), " +
  681. " /*最小单位*/ " +
  682. " mini_unit, " +
  683. " mini_unit_name = (select name " +
  684. " from yp_zd_unit with (NOLOCK) " +
  685. " where code = mini_unit), " +
  686. " /* 需要判断医生的权限 在 select " +
  687. " doctor_xz_yp " +
  688. " from " +
  689. " a_employee_mi */ " +
  690. " cast(isnull(NULLIF(yp_level, " +
  691. " ''), " +
  692. " 0) as int) as yp_level, " +
  693. " /*需要皮试*/ " +
  694. " cast(isnull(NULLIF(ps_flag, " +
  695. " ''), " +
  696. " 0) as int) as ps_flag, " +
  697. " cast(isnull(NULLIF(kss_flag, " +
  698. " ''), " +
  699. " 0) as int) as kss_flag, " +
  700. " cast(isnull(NULLIF(kjyw_flag, " +
  701. " ''), " +
  702. " 0) as int) as kjyw_flag, " +
  703. " code as order_code, " +
  704. " name as order_name, " +
  705. " frequency as frequCode, " +
  706. " (select isnull(rtrim(comm), " +
  707. " '') " +
  708. " from yz_order_frequency " +
  709. " where yz_order_frequency.code = frequency) as frequCodeName, " +
  710. " supply_type as supply_code, " +
  711. " supply_code_name = (select supply_name " +
  712. " from yz_supply_type with (NOLOCK) " +
  713. " where yz_supply_type.supply_code = supply_type), " +
  714. " national_code, " +
  715. " stock_amount," +
  716. " cast(isnull(nullif(visible_flag_zy, ''), 0) as int) as visible_flag_zy " +
  717. "from yp_zd_dict a with (NOLOCK) " +
  718. " left join yp_base_yf b on (code = b.charge_code and a.serial = b.serial) " +
  719. "where rtrim(code) + rtrim(a.serial) = #{code} " +
  720. " and cast(isnull(NULLIF(del_flag, ''), 0) as int) = 0 " +
  721. " and group_no = #{groupNo} ")
  722. YaoPinXinXi huoQuYaoPin(@Param("code") String code,
  723. @Param("groupNo") String groupNo);
  724. @Select("select count(1) " +
  725. "from yp_zd_dept " +
  726. "where charge_code = #{code} " +
  727. " and dept_code = #{dept} ")
  728. Integer restrictedUseInTheDepartment(@Param("code") String code,
  729. @Param("dept") String dept);
  730. @Select("select cast(isnull(NULLIF(doctor_xz_yp, ''), 0) as int) + 1 from a_employee_mi with (NOLOCK) where code = #{code}")
  731. Integer huoQuYiShenDengJi(String code);
  732. @Select("select cast(isnull(NULLIF(doctor_xz_yp, ''), 0) as int) + 1 as doctorLevel, " +
  733. " dept_code," +
  734. " code " +
  735. "from a_employee_mi with (NOLOCK) " +
  736. "where code = #{code} ")
  737. UserInfo selectedUserInfoByCode(String code);
  738. @Select("select rtrim(supply_code) code,rtrim(supply_name) name " +
  739. "from yz_supply_type with (NOLOCK) " +
  740. "where ps_flag in ('1', '0')")
  741. List<GetDropdownBox> piShiGeiYaoFangShi();
  742. @Select("select rtrim(code) code, rtrim(comm) name " +
  743. "from yz_order_frequency with (NOLOCK) " +
  744. "where (code like #{code} or comm like #{code})")
  745. List<GetDropdownBox> huoQuZhuYuanPinLv(String code);
  746. @Select("select rtrim(code) as code, rtrim(comm) name " +
  747. "from yz_order_frequency")
  748. List<GetDropdownBox> selectFrequency();
  749. @Select("select rtrim(supply_code) code, " +
  750. " rtrim(supply_name) name, " +
  751. " py_code, " +
  752. " d_code as w_code " +
  753. "from yz_supply_type with (NOLOCK)")
  754. List<SelectV2> selectSupplyType();
  755. @Select("select rtrim(supply_code) code, rtrim(supply_name) name " +
  756. "from yz_supply_type with (NOLOCK) " +
  757. "where (supply_code like #{code} or supply_name like #{code} or py_code like #{code} )")
  758. List<GetDropdownBox> huoQuGeiYaoFangShi(String code);
  759. @Select("SELECT a.code code, " +
  760. " a.name name " +
  761. "FROM zd_unit_code a with (NOLOCK), " +
  762. " zd_dept_all b with (NOLOCK) " +
  763. "where isnull(a.del_flag, '0') <> '1' " +
  764. " and a.code = b.small_dept " +
  765. " and (a.code like #{code} or a.name like #{code} or py_code like #{code}) " +
  766. "group by code,name")
  767. List<GetDropdownBox> huoQuZhiXinKeShi(String code);
  768. @Select("<script>" +
  769. "select rtrim(code) order_code, " +
  770. " rtrim(a.serial) serial, " +
  771. " rtrim(group_no) group_no, " +
  772. " rtrim(name) order_name," +
  773. " case infusion_flag " +
  774. " when '1' then 'i' " +
  775. " else " +
  776. " (case " +
  777. " when rtrim(code) &gt;= '30000' and rtrim(code) &lt; '50000' then 'z' " +
  778. " else 'd' end) end as drug_flag, " +
  779. " mini_unit, " +
  780. " isnull(weight,1) drug_weight, " +
  781. " weigh_unit drug_weight_unit, " +
  782. " isnull(volum,1) drug_volume, " +
  783. " vol_unit drug_vol_unit," +
  784. " isnull(pack_size,1) pack_size, " +
  785. " pack_unit," +
  786. " a.pack_retprice, " +
  787. " national_code," +
  788. " cast(isnull(NULLIF(kjyw_flag, ''), 0) as int) as kjyw_flag," +
  789. " cast(isnull(NULLIF(yp_level, ''), 0) as int) as yp_level," +
  790. " cast(isnull(NULLIF(del_flag, ''), 0) as int) as del_flag, " +
  791. " CASE " +
  792. " WHEN isnull(b.open_virtual2, '') = '1' then isnull(b.stock_amount_virtual2, 0) " +
  793. " else isnull(stock_amount,0) end as stock_amount," +
  794. " cast(isnull(nullif(visible_flag_zy, ''), 0) as int) as visible_flag_zy," +
  795. " deptRestrictions = (select count(1) from yp_zd_dept where code = yp_zd_dept.charge_code and dept_code = '${dept}') " +
  796. " from yp_zd_dict a with (NOLOCK) " +
  797. " left join yp_base_yf b on (code = b.charge_code and a.serial = b.serial) " +
  798. "where rtrim(code) + rtrim(a.serial) + rtrim(group_no) in " +
  799. "<foreach collection='code' item='item' index='index' open='(' close=')' separator=','>" +
  800. "#{item}" +
  801. "</foreach>" +
  802. "</script>")
  803. List<XinZhenYzActOrder> huoQuYaoPinXinXi(@Param("code") Set<String> code,
  804. @Param("dept") String dept);
  805. @Select("<script>" +
  806. "select b.order_code, " +
  807. " rtrim(c.name) order_name, " +
  808. " national_code, " +
  809. " kjyw_flag = 0, " +
  810. " cast(rtrim(isnull(nullif(c.del_flag, " +
  811. " ''), " +
  812. " 0)) as int) del_flag " +
  813. " from " +
  814. " yz_order_occurence b with (NOLOCK) , " +
  815. " zd_charge_item c with (NOLOCK) " +
  816. "where b.order_code in " +
  817. "<foreach collection='code' item='item' index='index' open='(' close=')' separator=','>" +
  818. "#{item}" +
  819. "</foreach>" +
  820. " and b.occ_code = c.code" +
  821. "</script>")
  822. List<XinZhenYzActOrder> huoQuXiangMuXinXi(Set<String> code);
  823. @Select("select b.order_code, " +
  824. " rtrim(c.name) order_name, " +
  825. " national_code, " +
  826. " kjyw_flag = 0, " +
  827. " cast(rtrim(isnull(nullif(c.del_flag, " +
  828. " ''), " +
  829. " 0)) as int) as del_flag " +
  830. "from yz_order_occurence b with (NOLOCK), " +
  831. " zd_charge_item c with (NOLOCK) " +
  832. "where b.order_code = #{code} " +
  833. " and b.occ_code = c.code")
  834. List<XinZhenYzActOrder> itemDataOne(String code);
  835. @Select("select rtrim(code) order_code, " +
  836. " rtrim(a.serial) as serial, " +
  837. " rtrim(group_no) as group_no, " +
  838. " rtrim(name) order_name, " +
  839. " case infusion_flag " +
  840. " when '1' then 'i' " +
  841. " else " +
  842. " (case " +
  843. " when rtrim(code) >= '30000' and rtrim(code) < " +
  844. " '50000' then 'z' " +
  845. " else 'd' end) end as drug_flag, " +
  846. " mini_unit, " +
  847. " isnull(weight, 1) drug_weight, " +
  848. " weigh_unit drug_weight_unit, " +
  849. " isnull(volum, 1) drug_volume, " +
  850. " vol_unit drug_vol_unit, " +
  851. " isnull(pack_size, 1) as pack_size, " +
  852. " pack_unit, " +
  853. " a.pack_retprice, " +
  854. " national_code, " +
  855. " cast(isnull(NULLIF(kjyw_flag, ''), 0) as int) as kjyw_flag, " +
  856. " cast(isnull(NULLIF(yp_level, ''), 0) as int) as yp_level, " +
  857. " cast(isnull(NULLIF(del_flag, ''), 0) as int) as del_flag, " +
  858. " CASE " +
  859. " WHEN isnull(b.open_virtual2, '') = '1' then isnull(b.stock_amount_virtual2, 0) " +
  860. " else isnull(stock_amount, 0) end as stock_amount, " +
  861. " cast(isnull(nullif(visible_flag_zy, ''), 0) as int) as visible_flag_zy, " +
  862. " deptRestrictions = (select count(1) from yp_zd_dept where code = yp_zd_dept.charge_code and dept_code = '${dept}') " +
  863. "from yp_zd_dict a " +
  864. " with (NOLOCK) " +
  865. " left join yp_base_yf b on (code = b.charge_code and a.serial = b.serial) " +
  866. "where rtrim(code) + rtrim(a.serial) + rtrim(group_no) = #{code} ")
  867. XinZhenYzActOrder drugDataOne(String code, String dept);
  868. @Select("select rtrim(inpatient_no) as inpatient_no, " +
  869. " admiss_times, " +
  870. " rtrim(name) as name, " +
  871. " rtrim(dept) as dept_code, " +
  872. " rtrim(zk_ward) as ward_code, " +
  873. " refer_physician, " +
  874. " times_billed, " +
  875. " admiss_date, " +
  876. " small_dept, " +
  877. " bed_no," +
  878. " zk_ward, " +
  879. " ledger_sn = (select max(ledger_sn) " +
  880. " from zy_ledger_file with (NOLOCK) " +
  881. " where zy_actpatient.inpatient_no = zy_ledger_file.inpatient_no " +
  882. " and zy_actpatient.admiss_times = zy_ledger_file.admiss_times) " +
  883. " from zy_actpatient with (NOLOCK) " +
  884. "where inpatient_no = #{patNo} " +
  885. " and admiss_times = #{times} ")
  886. XinZhenYiZhu queryPatientInfo(@Param("patNo") String patNo,
  887. @Param("times") Integer times);
  888. @Insert("<script>" +
  889. "INSERT INTO yz_act_order (order_code, order_name, frequ_code, instruction, discription, infant_flag, order_time, " +
  890. " /*录入人*/physician, start_time, drug_specification, drug_quan, supply_code, act_order_no, inpatient_no, " +
  891. " admiss_times, drug_flag/*药品中找这个是 药品的类型 a i d*/, enter_oper, /*录入时间*/ enter_time, " +
  892. " mini_unit /*药品中找 最小包装规格*/, " +
  893. " drug_weight/*药品的重量*/, drug_weight_unit/*药品重量单位*/, " +
  894. " status_flag/*2*/, self_buy, dose, dose_unit, /*这个是算出来的 输入的 dose 除以选中的单位 */drug_occ, drug_volume/*药品中的 volum 找*/, " +
  895. " drug_vol_unit/* 药品中的 vol_unit */, pay_self/*0*/, " +
  896. " serial/*前端传*/, group_no/*药房 */, doctor_flag/*写死为 1*/, exec_unit, dept_code/* 在院病人表中的 dept */, " +
  897. " ward_code /* 在院病人表中的 zk_ward*/, " +
  898. " reg_flag/* 0 */, " +
  899. " yb_self_flag/*医保自费标志*/,emergency_flag, " +
  900. " kf_flag /*饭前饭后*/,parent_no, refer_physician/*患者的管床医生*/, confirm_time/*确认时间*/, signer/*确认人*/,end_time,modifier) " +
  901. "VALUES " +
  902. "<foreach collection='list' item='item' separator=','>" +
  903. "(#{item.orderCode,jdbcType=VARCHAR}, #{item.orderName,jdbcType=VARCHAR}, #{item.frequCode,jdbcType=VARCHAR}," +
  904. " #{item.instruction,jdbcType=VARCHAR}, #{item.discription,jdbcType=VARCHAR}, #{infantFlag,jdbcType=VARCHAR}, " +
  905. "#{item.orderTime,jdbcType=VARCHAR}, " +
  906. " #{inputCode,jdbcType=TIMESTAMP}, #{item.startTime,jdbcType=TIMESTAMP}, #{item.drugSpecification}, " +
  907. "#{item.drugQuan,jdbcType=DECIMAL}," +
  908. " #{item.supplyCode}," +
  909. " #{item.actOrderNo,jdbcType=DECIMAL}, #{patNo}, #{times}, " +
  910. "#{item.drugFlag}," +
  911. " #{inputCode}, " +
  912. " getdate(), #{item.miniUnit}, " +
  913. "#{item.drugWeight,jdbcType=DECIMAL}, " +
  914. "#{item.drugWeightUnit}, '2', #{item.selfBuy}, " +
  915. "cast(#{item.dose,jdbcType=DECIMAL} as decimal(10,2))," +
  916. " #{item.doseUnit}, " +
  917. "cast(#{item.drugOcc,jdbcType=DECIMAL} as decimal(10,2))," +
  918. "cast(#{item.drugVolume,jdbcType=DECIMAL} as decimal(10,2))," +
  919. " #{item.drugVolUnit}, 0, #{item.serial}, " +
  920. "#{item.groupNo}," +
  921. "'1', #{item.execUnit}, " +
  922. "#{deptCode}, #{wardCode}, '0', #{item.ybSelfFlag},#{item.emergencyFlag}, #{item.kfFlag}," +
  923. "#{item.parentNo,jdbcType=DECIMAL}," +
  924. " #{referPhysician}, getdate(), #{inputCode},#{item.endTime,jdbcType=TIMESTAMP},#{item.modifier})" +
  925. "</foreach>" +
  926. "</script>")
  927. void chaRuYiZhu(@Param("patNo") String patNo,
  928. @Param("times") Integer times,
  929. @Param("inputCode") String inputCode,
  930. @Param("infantFlag") Integer infantFlag,
  931. @Param("deptCode") String deptCode,
  932. @Param("wardCode") String wardCode,
  933. @Param("referPhysician") String referPhysician,
  934. @Param("list") List<XinZhenYzActOrder> list);
  935. @Select("<script>" +
  936. "select top 20 * from (" +
  937. "SELECT row_number() over (order by pattern_code ) row_number," +
  938. " rtrim(pattern_code) pattern_code, " +
  939. " rtrim(pattern_name) pattern_name," +
  940. " rtrim(input_id) input_id," +
  941. " input_date," +
  942. " rtrim(input_type) input_type, " +
  943. " sort_no," +
  944. " yiBeiShouCang = (select count(1) from yz_OrderPattern b with (NOLOCK) where b.collect_code = a.pattern_code " +
  945. " and b.input_id = #{inputId})," +
  946. " collect_code " +
  947. "FROM yz_OrderPattern a with (NOLOCK) " +
  948. "where 1=1 " +
  949. "<if test=\"code != null and code != '' \">" +
  950. "and (py_code like #{code} " +
  951. " or pattern_code like #{code} " +
  952. " or pattern_name like #{code}) " +
  953. "</if>" +
  954. "<if test=\"muBanLeiXing == 2 \">" +
  955. " and dept_code = #{deptCode} AND input_type = '2' " +
  956. "</if>" +
  957. "<if test=\"muBanLeiXing == 3 \">" +
  958. " and input_id = #{inputId} AND input_type = '3' " +
  959. "</if>" +
  960. "<if test=\"muBanLeiXing == 1\">" +
  961. " and input_type = '1' " +
  962. "</if>" +
  963. "<if test=\"muBanLeiXing == 4\">" +
  964. " and input_id = #{inputId} AND input_type = '4' " +
  965. "</if>" +
  966. "<if test=\"muBanLeiXing == 0\">" +
  967. " AND input_type &lt;&gt; '4' " +
  968. "</if>" +
  969. ") temp where row_number > (${currentPage} - 1) * 20 " +
  970. "<if test=\"muBanLeiXing == 3 \">" +
  971. " order by sort_no desc " +
  972. "</if>" +
  973. "</script>")
  974. List<YzOrderPattern> huoQuMuBan(@Param("code") String code,
  975. @Param("inputId") String inputId,
  976. @Param("deptCode") String deptCode,
  977. @Param("muBanLeiXing") Integer muBanLeiXing,
  978. @Param("currentPage") long currentPage);
  979. @Select("select max(sort_no + 1) " +
  980. "from yz_OrderPattern " +
  981. "where input_id = #{code}")
  982. Integer getMyTemplateMaxSortNo(String code);
  983. @Select("<script>" +
  984. "SELECT count(*) " +
  985. "FROM yz_OrderPattern with (NOLOCK) " +
  986. "where 1=1 " +
  987. "<if test=\"code != null and code != '' \">" +
  988. "and (py_code like #{code} " +
  989. " or pattern_code like #{code} " +
  990. " or pattern_name like #{code}) " +
  991. "</if>" +
  992. "<if test=\"muBanLeiXing == 2 \">" +
  993. " and dept_code = #{deptCode} AND input_type = '2' " +
  994. "</if>" +
  995. "<if test=\"muBanLeiXing == 3 \">" +
  996. " and input_id = #{inputId} AND input_type = '3' " +
  997. "</if>" +
  998. "<if test=\"muBanLeiXing == 1\">" +
  999. " and input_type = '1' " +
  1000. "</if>" +
  1001. "<if test=\"muBanLeiXing == 4\">" +
  1002. " and input_id = #{inputId} AND input_type = '4' " +
  1003. "</if>" +
  1004. "<if test=\"muBanLeiXing == 0\">" +
  1005. " AND input_type &lt;&gt; '4' " +
  1006. "</if>" +
  1007. "</script>")
  1008. long huoQuMuBanTotal(@Param("code") String code,
  1009. @Param("inputId") String inputId,
  1010. @Param("deptCode") String deptCode,
  1011. @Param("muBanLeiXing") Integer muBanLeiXing);
  1012. @Select("SELECT cast(cast(act_order_no as decimal) as varchar) id, " +
  1013. " act_order_no, " +
  1014. " rtrim(a.order_name) order_name, " +
  1015. " rtrim(a.order_code) order_code, " +
  1016. " a.frequ_code, " +
  1017. " frequ_code_name = (select rtrim(comm) " +
  1018. " from yz_order_frequency with (NOLOCK) " +
  1019. " where yz_order_frequency.code = a.frequ_code), " +
  1020. " a.drug_specification, " +
  1021. " a.supply_code, " +
  1022. " supply_code_name = (select rtrim(supply_name) " +
  1023. " from yz_supply_type with (NOLOCK) " +
  1024. " where yz_supply_type.supply_code = a.supply_code), " +
  1025. " a.drug_quan, " +
  1026. " a.instruction, " +
  1027. " a.mini_unit, " +
  1028. " mini_unit_name = (select rtrim(name) from yp_zd_unit with (NOLOCK) where code = mini_unit), " +
  1029. " a.drug_weight, " +
  1030. " a.drug_weight_unit, " +
  1031. " a.parent_no, " +
  1032. " a.drug_volume, " +
  1033. " a.drug_vol_unit, " +
  1034. " a.dose, " +
  1035. " a.dose_unit, " +
  1036. " dose_unit_name = (select rtrim(name) from yp_zd_unit with (NOLOCK) where code = dose_unit), " +
  1037. " a.exclu_act_order_no, " +
  1038. " a.discription, " +
  1039. " a.pattern_code, " +
  1040. " a.order_type, " +
  1041. " a.serial, " +
  1042. " self_buy=isnull(a.self_buy, '0'), " +
  1043. " del_flag=isnull(b.del_flag, ''), " +
  1044. " a.drug_flag, " +
  1045. " suprice_flag='', " +
  1046. " self_flag ='', " +
  1047. " parent_flag='', " +
  1048. " a.exec_unit, " +
  1049. " exec_unit_name = (select rtrim(name) from zd_unit_code with (NOLOCK) where code = exec_unit)," +
  1050. " group_no = '00', " +
  1051. " group_no_name = N'项目' " +
  1052. "FROM yz_pattern_order a with (NOLOCK), " +
  1053. " yz_order_item b with (NOLOCK) " +
  1054. "WHERE a.pattern_code = #{code} " +
  1055. " and isnull(a.group_no, '00') = '00' " +
  1056. " and a.order_code = b.order_code " +
  1057. "UNION " +
  1058. "SELECT cast(cast(act_order_no as decimal) as varchar) id," +
  1059. " act_order_no, " +
  1060. " a.order_name, " +
  1061. " a.order_code, " +
  1062. " a.frequ_code, " +
  1063. " frequ_code_name = (select rtrim(comm) " +
  1064. " from yz_order_frequency with (NOLOCK) " +
  1065. " where yz_order_frequency.code = a.frequ_code), " +
  1066. " a.drug_specification, " +
  1067. " a.supply_code, " +
  1068. " supply_code_name = (select rtrim(supply_name) " +
  1069. " from yz_supply_type with (NOLOCK) " +
  1070. " where yz_supply_type.supply_code = a.supply_code), " +
  1071. " a.drug_quan, " +
  1072. " a.instruction, " +
  1073. " b.pack_unit as mini_unit, " +
  1074. " mini_unit_name = (select rtrim(name) from yp_zd_unit with (NOLOCK) where code = b.pack_unit), " +
  1075. " a.drug_weight, " +
  1076. " a.drug_weight_unit, " +
  1077. " a.parent_no, " +
  1078. " a.drug_volume, " +
  1079. " a.drug_vol_unit, " +
  1080. " a.dose, " +
  1081. " a.dose_unit, " +
  1082. " dose_unit_name = (select rtrim(name) from yp_zd_unit with (NOLOCK) where code = dose_unit), " +
  1083. " a.exclu_act_order_no, " +
  1084. " a.discription, " +
  1085. " a.pattern_code, " +
  1086. " a.order_type, " +
  1087. " a.serial, " +
  1088. " self_buy=isnull(a.self_buy, case when b.jsy_flag = '1' then '3' else '0' end), " +
  1089. " del_flag=isnull(b.visible_flag_zy, ''), " +
  1090. " a.drug_flag, " +
  1091. " suprice_flag=b.suprice_flag, " +
  1092. " self_flag =b.self_flag, " +
  1093. " parent_flag='', " +
  1094. " a.exec_unit, " +
  1095. " exec_unit_name = (select rtrim(name) from zd_unit_code with (NOLOCK) where code = exec_unit)," +
  1096. " a.group_no, " +
  1097. " (select yp_zd_group_name.group_name " +
  1098. " from yp_zd_group_name " +
  1099. " where yp_zd_group_name.group_no = a.group_no) " +
  1100. "FROM yz_pattern_order a with (NOLOCK), " +
  1101. " view_yp_zd_dict_base_yf b with (NOLOCK) " +
  1102. "WHERE a.pattern_code = #{code} " +
  1103. " and a.group_no = b.group_no " +
  1104. " and a.order_code = b.code " +
  1105. " and a.serial = b.serial " +
  1106. " and isnull(b.visible_flag_zy, '') <> '1'")
  1107. List<YzActOrder> huoQuMuBanShuJu(String code);
  1108. @Select("select pattern_code," +
  1109. " rtrim(input_type) as input_type," +
  1110. " input_id " +
  1111. "from yz_OrderPattern with (NOLOCK) " +
  1112. "where pattern_name = #{patternName} " +
  1113. " and input_id = #{inputId}" +
  1114. " and input_type <> 4 ")
  1115. YzOrderPattern yuanLaiDeMuBanBianMa(@Param("patternName") String patternName,
  1116. @Param("inputId") String inputId);
  1117. @Delete("<script>" +
  1118. "delete yz_OrderPattern " +
  1119. "where pattern_code = #{patternCode}; " +
  1120. "delete yz_pattern_order " +
  1121. "where pattern_code = #{patternCode} " +
  1122. "</script>")
  1123. void shanChuLaoMuBan(@Param("patternCode") String patternCode);
  1124. @Insert("insert yz_OrderPattern (pattern_code, pattern_name, py_code, d_code, dept_code, " +
  1125. " ward_code, input_id, " +
  1126. " input_type, input_date, sort_no) " +
  1127. "values (#{patternCode},#{patternName},#{pyCode},#{dCode},#{deptCode},#{deptCode}," +
  1128. "#{inputId},#{inputType}," +
  1129. "getdate(),#{sortNo})")
  1130. void chaRuMuBan(YzOrderPattern param);
  1131. @Select("select count(1) " +
  1132. "from yz_OrderPattern " +
  1133. "where pattern_name = #{name} and input_id = #{userCode} ")
  1134. Integer duplicateTemplateName(@Param("name") String name,
  1135. @Param("userCode") String userCode);
  1136. @Insert("<script>" +
  1137. "INSERT INTO yz_pattern_order (act_order_no, order_code, frequ_code, drug_flag, supply_code, drug_quan, instruction, " +
  1138. " drug_specification, mini_unit, drug_weight, drug_weight_unit, parent_no, drug_volume, " +
  1139. " drug_vol_unit, dose, dose_unit, drug_occ, order_name, discription, " +
  1140. " pattern_code, serial, self_buy, exec_unit,group_no) " +
  1141. "VALUES " +
  1142. "<foreach collection='list' item='item' separator=','>" +
  1143. "(#{item.actOrderNo}, #{item.orderCode}, #{item.frequCode}," +
  1144. "<if test=\"item.drugFlag !=null and item.drugFlag != '' \">" +
  1145. "#{item.drugFlag}," +
  1146. "</if>" +
  1147. "<if test=\"item.drugFlag == null or item.drugFlag == '' \">" +
  1148. "'o'," +
  1149. "</if>" +
  1150. " #{item.supplyCode}," +
  1151. "<if test=\"item.drugQuan != null \">" +
  1152. "#{item.drugQuan}," +
  1153. "</if>" +
  1154. "<if test=\"item.drugQuan == null \">" +
  1155. "null," +
  1156. "</if>" +
  1157. "#{item.instruction}, #{item.drugSpecification}, #{item.miniUnit}, " +
  1158. "<if test=\"item.drugWeight != null\">" +
  1159. "#{item.drugWeight}, " +
  1160. "</if>" +
  1161. "<if test=\"item.drugWeight == null\">" +
  1162. "null, " +
  1163. "</if>" +
  1164. "#{item.drugWeightUnit}, " +
  1165. "<if test=\"item.parentNo != null \">" +
  1166. "#{item.parentNo}," +
  1167. "</if>" +
  1168. "<if test=\"item.parentNo == null \">" +
  1169. "null," +
  1170. "</if>" +
  1171. "<if test=\"item.drugVolume != null\">" +
  1172. "cast(#{item.drugVolume,jdbcType=DECIMAL} as decimal(10,2))," +
  1173. "</if>" +
  1174. "<if test=\"item.drugVolume == null\">" +
  1175. "null," +
  1176. "</if>" +
  1177. " #{item.drugVolUnit}, " +
  1178. "<if test=\"item.dose != null\">" +
  1179. "cast(#{item.dose,jdbcType=DECIMAL} as decimal(10,2))," +
  1180. "</if>" +
  1181. "<if test=\"item.dose == null\">" +
  1182. "null," +
  1183. "</if>" +
  1184. "#{item.doseUnit}," +
  1185. "<if test=\"item.drugOcc != null \">" +
  1186. "cast(#{item.drugOcc,jdbcType=DECIMAL} as decimal(10,2))," +
  1187. "</if>" +
  1188. "<if test=\"item.drugOcc == null \">" +
  1189. "null," +
  1190. "</if>" +
  1191. " #{item.orderName},#{item.discription},#{patternCode},#{item.serial},#{item.selfBuy},#{item.execUnit},#{item.groupNo})" +
  1192. "</foreach>" +
  1193. "</script>")
  1194. void chaRuMuBanShuJu(List<XinZhenYzActOrder> list, String patternCode);
  1195. @Select("select * " +
  1196. "from yz_OrderPattern with (NOLOCK) " +
  1197. "where pattern_code = #{code}")
  1198. YzOrderPattern huoQuMuBanXinXi(@Param("code") String code);
  1199. @Update("update yz_OrderPattern " +
  1200. "set pattern_name = #{patternName}, " +
  1201. " py_code = #{pyCode}, " +
  1202. " d_code = #{dCode}, " +
  1203. " input_date = getdate()," +
  1204. " sort_no = #{sortNo} " +
  1205. "where pattern_code = #{patternCode} ")
  1206. void genXingMuBan(@Param("patternName") String patternName,
  1207. @Param("pyCode") String pyCode,
  1208. @Param("dCode") String dCode,
  1209. @Param("patternCode") String patternCode,
  1210. @Param("sortNo") Integer sortNo);
  1211. @Select("select rtrim(dept_code) from a_employee_mi where code = '${code}'")
  1212. String userDeptCode(@Param("code") String code);
  1213. @Delete("/* 父模板 */ " +
  1214. "delete yz_OrderPattern " +
  1215. "where pattern_code = #{patternCode}; " +
  1216. "/* 模板下面的数据 */ " +
  1217. "delete yz_pattern_order " +
  1218. "where pattern_code = #{patternCode} ")
  1219. void shanChuMuBan(@Param("patternCode") String patternCode);
  1220. @Select("select pattern_code " +
  1221. "from yz_OrderPattern " +
  1222. "where collect_code = #{patternCode} and input_id = #{userId}")
  1223. String whetherToSaveTheDoctorSOrderTemplate(@Param("patternCode") String patternCode,
  1224. @Param("userId") String userId);
  1225. @Select("select collect_code " +
  1226. "from yz_OrderPattern with (NOLOCK) " +
  1227. "where input_id = #{inputId} " +
  1228. " and collect_code = #{collectCode} ")
  1229. String chongFuShouCang(@Param("inputId") String inputId,
  1230. @Param("collectCode") String collectCode);
  1231. @Insert("insert into yz_OrderPattern (pattern_code, pattern_name, py_code, d_code, dept_code, ward_code, " +
  1232. " input_id, input_type, input_date, sort_no, collect_code) " +
  1233. "values (#{patternCode},#{patternName},#{pyCode},#{dCode},#{deptCode},#{deptCode},#{inputId},'4',getdate(),0,#{collectCode});")
  1234. void chaRuShouCang(@Param("patternCode") String patternCode,
  1235. @Param("patternName") String patternName,
  1236. @Param("pyCode") String pyCode,
  1237. @Param("dCode") String dCode,
  1238. @Param("deptCode") String deptCode,
  1239. @Param("inputId") String inputId,
  1240. @Param("collectCode") String collectCode);
  1241. @Delete("delete yz_act_record_kss where act_order_no = #{orderNo}")
  1242. void deleteAntimicrobialInformation(String orderNo);
  1243. @Insert("insert into yz_act_record_kss " +
  1244. "(act_order_no, charge_code, input_id, inpatient_no, " +
  1245. "admiss_times, yyfs, ssqk, yysj)" +
  1246. "values " +
  1247. "(#{orderNo},#{kss.chargeCode},#{userCode},#{patNo}," +
  1248. "#{times},#{kss.yyfs},#{kss.ssqk},#{kss.yysj})")
  1249. void insertAntimicrobialInformation(String orderNo,
  1250. YzActRecordKss kss,
  1251. String userCode,
  1252. String patNo,
  1253. Integer times);
  1254. @Delete("delete zy_order_zk where act_order_no = #{orderNo}")
  1255. void deleteTransferOrder(String orderNo);
  1256. @Insert("insert into zy_order_zk (act_order_no, old_ward, " +
  1257. "old_dept, new_ward, new_dept) " +
  1258. "values (#{actOrderNo},#{oldWard},#{oldDept},#{newWard},#{newDept})")
  1259. void insertDoctorSOrder(ZyOrderZk zk);
  1260. @Select("execute dbo.xc_zy_order_fee;1 @in_no = #{patNo}, @in_times = #{times}")
  1261. List<DoctorSOrderFee> expensesForGettingADoctorSOrder(@Param("patNo") String patNo,
  1262. @Param("times") Integer times);
  1263. @Update("UPDATE zy_actpatient " +
  1264. "SET refer_physician = #{param.referPhysician}, " +
  1265. " consult_physician = #{param.consultPhysician}, " +
  1266. " dept_director = #{param.deptDirector} " +
  1267. "WHERE inpatient_no = #{param.inpatientNo} " +
  1268. " AND admiss_times = #{param.admissTimes} ")
  1269. void updateTheThirdLevelDoctor(@Param("param") Overview param);
  1270. @Update("update yz_act_order " +
  1271. " set " +
  1272. " parent_no = ${order.actOrderNo}," +
  1273. " order_time = #{order.orderTime,jdbcType=TIMESTAMP}, " +
  1274. " start_time = #{order.startTime,jdbcType=TIMESTAMP}, " +
  1275. " end_time = #{order.endTime,jdbcType=TIMESTAMP}, " +
  1276. " supply_code = '044', " +
  1277. " frequ_code = #{order.frequCode}," +
  1278. " group_no = #{order.groupNo} " +
  1279. "where act_order_no = ${children} " +
  1280. " and status_flag = '1' ")
  1281. void associateOrders(BigDecimal children, XinZhenYzActOrder order);
  1282. @Select("SELECT a.gen_time, " +
  1283. " inpatient_no, " +
  1284. " admiss_times, " +
  1285. " ledger_sn, " +
  1286. " a.detail_sn, " +
  1287. " a.charge_date, " +
  1288. " a.charge_code_mx, " +
  1289. " charge_code_name = (case " +
  1290. " when serial = '99' or serial = '01' " +
  1291. " then (select top 1 rtrim(name) " +
  1292. " from yp_zd_dict " +
  1293. " where code = charge_code_mx " +
  1294. " and yp_zd_dict.serial = a.serial) " +
  1295. " else (select rtrim(name) from zd_charge_item where code = charge_code_mx) end), " +
  1296. " a.charge_fee, " +
  1297. " a.charge_status, " +
  1298. " a.serial, " +
  1299. " charge_amount=a.charge_amount, " +
  1300. " exec_dept=(select name from zd_unit_code where code = a.exec_unit), " +
  1301. " dept_code = (select name from zd_unit_code where code = a.ward_code), " +
  1302. " isnull(a.ori_detail_sn, 0) as ori_detail_sn " +
  1303. "FROM zy_detail_charge a " +
  1304. "where order_no = #{yz.actOrderNo} " +
  1305. " and inpatient_no = #{yz.inpatientNo} " +
  1306. " and admiss_times = #{yz.admissTimes} order by charge_date desc ")
  1307. List<ZyDetailCharge> selectOrderFee(@Param("yz") XinZhenYzActOrder yz);
  1308. }