YiZhuLuRuDao.java 85 KB

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