YiZhuLuRuDao.java 87 KB

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