YiZhuLuRuDao.java 74 KB

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