west_pharmacy_send.js 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  1. //@ sourceURL=west_pharmacy_send.js
  2. var LODOP; //声明为全局变量
  3. var zsdPrintIndex;
  4. var bqPrintIndex;
  5. $(function () {
  6. init_daterangepicker();
  7. initTbTable();
  8. //重置查询参数
  9. $('#btn_clean').click(function () {
  10. cleanParams();
  11. });
  12. $("#btn_query").click(function (t) {
  13. initTbTable();
  14. });
  15. $("#btn_ty").click(function (t) {
  16. saveRefundMedicine();
  17. });
  18. $(".selectpicker").selectpicker({
  19. dropuAuto: false
  20. });
  21. });
  22. /**
  23. * 获取按钮组选择的下标
  24. * @param id
  25. * @returns {number}
  26. */
  27. function getIndex(id) {
  28. var index = 0;
  29. var item = $("#" + id).find("button");
  30. for (var i = 0; i <= item.length; i++) {
  31. if ($(item[i]).hasClass("btn-primary")) {
  32. index = i;
  33. break;
  34. }
  35. }
  36. return index;
  37. }
  38. /**
  39. * 设置病人id
  40. */
  41. function setPatientId() {
  42. var patientId_or_cardNo = $("#patientId_or_cardNo").val();
  43. if (patientId_or_cardNo == '') {
  44. return $("#patientId").val("");
  45. }
  46. $.ajax({
  47. type: "GET",
  48. url: '/thmz/getByIcCardNo?icCardNo=' + patientId_or_cardNo,
  49. contentType: "application/json;charset=UTF-8",
  50. dataType: "json",
  51. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  52. success: function (res) {
  53. if (res == '401' || res == 401) {
  54. window.location.href = '/thmz/login/view'
  55. return;
  56. }
  57. if (res.code == 0) {
  58. if (res.data != null) {
  59. $("#patientId").val(res.data.patientId);
  60. } else {
  61. $("#patientId").val(patientId_or_cardNo);
  62. }
  63. }
  64. }
  65. });
  66. }
  67. /**
  68. * 列表类型按钮切换事件
  69. * @param object
  70. * @param realIndex 下标
  71. */
  72. function sendRefundButtonChange(object, realIndex) {
  73. $("#send_refund_group").find("button").each(function (index, element) {
  74. if ($(element).hasClass("btn-primary")) {
  75. $(element).removeClass("btn-primary").addClass("btn-default");
  76. }
  77. });
  78. if (realIndex == 0) {
  79. $("#confirmFlagSearch").empty();
  80. $("#confirmFlagSearch").append("<option value='0' selected>未发药</option>");
  81. $("#confirmFlagSearch").append("<option value='1'>已发药</option>");
  82. $("#confirmFlagSearch").selectpicker('refresh');
  83. $("#tb_table_right_ty").css("display", "none");
  84. $("#btn_ty").addClass("hidden");
  85. } else {
  86. $("#confirmFlagSearch").empty();
  87. $("#confirmFlagSearch").append("<option value='2' selected>待退药</option>");
  88. $("#confirmFlagSearch").append("<option value='3'>已退药</option>");
  89. $("#confirmFlagSearch").selectpicker('refresh');
  90. $("#tb_table_right_ty").css("display", "");
  91. $("#btn_ty").removeClass("hidden");
  92. }
  93. $(object).removeClass("btn-default").addClass("btn-primary");
  94. initTbTable();
  95. }
  96. /**
  97. * 发药处理
  98. */
  99. function sendMedicineProcessing(realNo, groupNo, orderNo, receiptNo, times, patientId, name) {
  100. var temp = {
  101. groupNo: groupNo,
  102. realNo: realNo,
  103. orderNo: orderNo,
  104. receiptNo: receiptNo,
  105. times: times,
  106. patientId: patientId,
  107. windowsNoYf: '04'
  108. };
  109. toMedicineWebSocket.send(JSON.stringify({patient_id: patientId, name: name, type: 'fy'}));
  110. /*$.ajax({
  111. type: "POST",
  112. url: '/thmz/sendMedicineProcessing',
  113. contentType: "application/json;charset=UTF-8",
  114. dataType: "json",
  115. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  116. data: JSON.stringify(temp),
  117. success: function (res) {
  118. if (res == '401' || res == 401) {
  119. window.location.href = '/thmz/login/view'
  120. return;
  121. }
  122. if (res.code == 0) {
  123. successMesage(res);
  124. initTbTable();
  125. toMedicineWebSocket.send(JSON.stringify({patient_id:patientId,name:name,type:'fy'}));
  126. } else {
  127. errorMesage(res);
  128. }
  129. }
  130. });*/
  131. }
  132. /**
  133. * 查询处方信息
  134. */
  135. function initTbTable() {
  136. var sendRefundGroup = getIndex("send_refund_group");
  137. var visible = false;
  138. var url = "/thmz/getSendMedicinePrescription";
  139. if (sendRefundGroup == 1) {
  140. visible = true;
  141. url = "/thmz/getYfRefundMedicine";
  142. $("#tb_table_div").attr("class", "col-md-7 col-sm-7 col-xs-12");
  143. } else {
  144. $("#tb_table_div").attr("class", "");
  145. }
  146. $('#tb_table').bootstrapTable("destroy");
  147. $('#tb_table').bootstrapTable({
  148. url: url, //请求后台的URL(*)
  149. method: 'post', //请求方式(*)
  150. striped: true, //是否显示行间隔色
  151. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  152. pagination: true, //是否显示分页(*)
  153. sortable: true, //是否启用排序
  154. sortOrder: "asc", //排序方式
  155. queryParams: queryParams, //传递参数(*)
  156. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  157. pageNumber: 1, //初始化加载第一页,默认第一页
  158. pageSize: 10, //每页的记录行数(*)
  159. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  160. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  161. singleSelect: true, // 单选checkbox
  162. strictSearch: true,
  163. showColumns: false, //是否显示所有的列
  164. showRefresh: false, //是否显示刷新按钮
  165. minimumCountColumns: 2, //最少允许的列数
  166. clickToSelect: true, //是否启用点击选中行
  167. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  168. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  169. cardView: false, //是否显示详细视图
  170. detailView: false,
  171. //rowStyle:rowStyle,//通过自定义函数设置行样式
  172. ajaxOptions: {
  173. headers: {
  174. 'Accept': 'application/json',
  175. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  176. }
  177. },
  178. columns: [
  179. {
  180. field: 'checked',
  181. checkbox: true,
  182. align: "center",
  183. valign: 'middle',
  184. visible: visible,
  185. formatter: function (value, row, index) {
  186. if (index == 0 && sendRefundGroup == 1) {
  187. fitfymx(row.patientId, row.times, row.receiptNo, row.orderNo, row.groupNo);
  188. return {
  189. checked: true//设置选中
  190. };
  191. }
  192. }
  193. }, {
  194. field: 'patientId',
  195. title: '病人ID',
  196. align: "center",
  197. valign: 'middle'
  198. }, {
  199. field: 'name',
  200. title: '姓名',
  201. align: "center",
  202. valign: 'middle'
  203. }, {
  204. field: 'orderNo',
  205. title: '处方号',
  206. align: "center",
  207. valign: 'middle'
  208. }, {
  209. field: 'warnDeptName',
  210. title: '申请科室',
  211. align: "center",
  212. valign: 'middle',
  213. }, {
  214. field: 'employeeName',
  215. title: '医生',
  216. align: "center",
  217. valign: 'middle',
  218. formatter: function (value, row, index) {
  219. if (value == null) {
  220. return row.doctorName;
  221. }
  222. return value;
  223. }
  224. }, {
  225. field: 'chargeDate',
  226. title: '缴费日期',
  227. align: "center",
  228. valign: 'middle',
  229. formatter: function (value, row, index) {
  230. if (value != null && value != "") {
  231. return format(value, "yyyy-MM-dd HH:mm:ss");
  232. }
  233. return "";
  234. }
  235. }, {
  236. field: 'realNo',
  237. title: '流水号',
  238. align: "center",
  239. valign: 'middle',
  240. }, {
  241. field: 'confirmTime',
  242. title: '确认日期',
  243. align: "center",
  244. valign: 'middle',
  245. visible: visible,
  246. formatter: function (value, row, index) {
  247. if (value != null && value != "") {
  248. return format(value, "yyyy-MM-dd HH:mm:ss");
  249. }
  250. return "";
  251. }
  252. }
  253. /*, {
  254. field: 'doctorFlag',
  255. title: '医生处方',
  256. align: "center",
  257. valign: 'middle',
  258. formatter: function (value, row, index) {
  259. return value == 1 ? "是" : "否";
  260. }
  261. }*/
  262. , {
  263. title: '操作',
  264. align: "center",
  265. valign: 'middle',
  266. visible: !visible,
  267. formatter: function (value, row, index) {
  268. var str = "";
  269. if (sendRefundGroup == 0) {
  270. str = '<button type="button" class="registration-no-color-foot-button" title="打印" onclick="printInjectionOralMedicine(\'' + row.patientId + '\',\'' + row.orderNo + '\',\'' + row.realNo + '\',\'' + row.times + '\',\'' + row.receiptNo + '\');" style="color: #35D082;"><i class="fa fa-print"></i></button>';
  271. str += '<button type="button" class="registration-no-color-foot-button" title="叫号" onclick="callNumber(\'' + row.patientId + '\',\'' + row.name + '\')"><i class="glyphicon glyphicon-bullhorn"></i></button>';
  272. str += '<button type="button" class="registration-no-color-foot-button" title="发药" onclick="sendMedicineProcessing(\'' + row.realNo + '\',\'' + 71 + '\',\'' + row.orderNo + '\',\'' + row.receiptNo + '\',\'' + row.times + '\',\'' + row.patientId + '\',\'' + row.name + '\')"><i class="glyphicon glyphicon-send"></i></button>';
  273. str += '<button type="button" class="registration-no-color-foot-button" title="详细" onclick="prescriptionDetail(\'' + row.realNo + '\',\'' + 71 + '\',\'' + row.orderNo + '\',\'' + row.receiptNo + '\',\'' + row.times + '\',\'' + row.patientId + '\')"><i class="fa fa-plus"></i></button>';
  274. }
  275. return str;
  276. }
  277. }
  278. ],
  279. onClickRow: function (row) {
  280. if (sendRefundGroup == 1) {
  281. fitfymx(row.patientId, row.times, row.receiptNo, row.orderNo, row.groupNo);
  282. }
  283. },
  284. responseHandler: function (res) {
  285. if (res == '401' || res == 401) {
  286. window.location.href = '/thmz/login/view'
  287. return;
  288. }
  289. var ress = eval(res);
  290. if (ress.code == -1) {
  291. if (ress.message != null && ress.message != '') {
  292. new PNotify({
  293. title: '错误提示',
  294. text: ress.message,
  295. type: 'error',
  296. hide: true,
  297. styling: 'bootstrap3'
  298. });
  299. }
  300. return {
  301. "total": 0,//总页数
  302. "rows": {} //数据
  303. };
  304. }
  305. return {
  306. "total": ress.total,//总页数
  307. "rows": ress.data //数据
  308. };
  309. },
  310. });
  311. }
  312. /**
  313. * 打印注射卡口服药品
  314. */
  315. function printInjectionOralMedicine(patientId, orderNo, realNo, times, receiptNo) {
  316. var tem = {
  317. patientId: patientId,
  318. orderNo: orderNo,
  319. realNo: realNo,
  320. times: times,
  321. receiptNo: receiptNo,
  322. groupNo: 71
  323. };
  324. $.ajax({
  325. type: "POST",
  326. url: '/thmz/getPrintInjectionData',
  327. contentType: "application/json;charset=UTF-8",
  328. dataType: "json",
  329. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  330. data: JSON.stringify(tem),
  331. success: function (res) {
  332. if (res == '401' || res == 401) {
  333. window.location.href = '/thmz/login/view'
  334. return;
  335. }
  336. if (res.code == 0) {
  337. var injections = new Array();//注射液
  338. var drugs = new Array();//普通药品
  339. for (let i = 0; i < res.data.length; i++) {
  340. if (res.data[i].classCode == 2 || res.data[i].classCode == 7 ) {
  341. injections[injections.length] = res.data[i];
  342. } else if(res.data[i].classCode != 6 && res.data[i].classCode != 9){
  343. drugs[drugs.length] = res.data[i];
  344. }
  345. }
  346. if(injections.length == 0 && drugs.length == 0){
  347. return new PNotify({
  348. title: '操作成功',
  349. text: '当前处方,无需打印注射单和标签',
  350. type: 'success',
  351. hide: true,
  352. styling: 'bootstrap3'
  353. });
  354. }
  355. setPrint();
  356. if (injections.length > 0) {
  357. $(".zsd_two_tr").remove();
  358. $(".zsd_one_tr").remove();
  359. $(".zsd_yp_tr").remove();
  360. $("#dateTime").html(format(new Date(), "yyyy-MM-dd HH:mm:ss"));
  361. var sex = '';
  362. if (res.data[0].sex == 1) {
  363. sex = '男';
  364. } else if (res.data[0].sex == 2) {
  365. sex = '女';
  366. } else {
  367. sex = '未知';
  368. }
  369. var patientInfoHtm = '<tr class="zsd_one_tr">\n' +
  370. ' <td style="vertical-align: middle !important;width: 35px;text-align: center;"\n' +
  371. ' valign="top">姓名\n' +
  372. ' </td>\n' +
  373. ' <td style="vertical-align: middle !important;width: 75px;">\n' + res.data[0].name +
  374. ' </td>\n' +
  375. ' <td style="vertical-align: middle !important;width: 55px;text-align: center;">\n' +
  376. ' 性别\n' +
  377. ' </td>\n' +
  378. ' <td style="vertical-align: middle !important;width: 45px;text-align: left;">\n' + sex +
  379. ' </td>\n' +
  380. ' <td style="vertical-align: middle !important;width: 55px;text-align: center;">\n' +
  381. ' 年龄\n' +
  382. ' </td>\n' +
  383. ' <td style="vertical-align: middle !important;width: 55px;text-align: left;">\n' + res.data[0].age +
  384. ' </td>\n' +
  385. ' <td style="vertical-align: middle !important;width: 65px;text-align: center;">\n' +
  386. ' ID号\n' +
  387. ' </td>\n' +
  388. ' <td style="vertical-align: middle !important;width: 55px;text-align: left;">\n' + res.data[0].patientId +
  389. ' </td>\n' +
  390. ' <td style="vertical-align: middle !important;width: 55px;text-align: center;">\n' +
  391. ' 诊断\n' +
  392. ' </td>\n' +
  393. ' <td style="vertical-align: middle !important;width: 135px;text-align: left;">\n' + res.data[0].icdText +
  394. ' </td>\n' +
  395. ' <td style="vertical-align: middle !important;width: 55px;text-align: center;">\n' +
  396. ' 医生\n' +
  397. ' </td>\n' +
  398. ' <td style="vertical-align: middle !important;width: 55px;text-align: left;">\n' + res.data[0].employeeName +
  399. ' </td>\n' +
  400. ' </tr>';
  401. $('#zsd_one').prepend(patientInfoHtm);
  402. var zsdYpHtm = '';
  403. for (let i = 0; i < injections.length; i++) {
  404. let data = injections[i];
  405. let manufactoryName = (data.manufactoryName == null || data.manufactoryName == '') ? '' : '(' + data.manufactoryName + ')';
  406. let groupOrder = (data.groupOrder == '' || data.groupOrder == null) ? data.chargeItemCode : data.groupOrder;
  407. zsdYpHtm += '<tr class="zsd_yp_tr">\n' +
  408. ' <td>&nbsp;&nbsp;</td>\n' +
  409. ' <td style="vertical-align: middle !important;width: 10px;text-align: center;">\n' + groupOrder +
  410. ' </td>\n' +
  411. ' <td style="vertical-align: middle !important;width: 200px;text-align: center;">\n' + data.drugname + manufactoryName +
  412. ' </td>\n' +
  413. ' <td style="vertical-align: middle !important;width: 60px;text-align: center;">\n' + data.drugQuan +
  414. ' </td>\n' +
  415. ' <td style="vertical-align: middle !important;width: 60px;text-align: center;">\n' + data.drugUnitName +
  416. ' </td>\n' +
  417. ' <td style="vertical-align: middle !important;width: 120px;text-align: center;">\n' + data.printName +
  418. ' </td>\n' +
  419. ' <td style="vertical-align: middle !important;width: 60px;text-align: center;">\n' + data.frequency +
  420. ' </td>\n' +
  421. ' <td style="vertical-align: middle !important;width: 60px;text-align: center;">\n' + data.orderDays +
  422. ' </td>\n' +
  423. ' <td style="vertical-align: middle !important;width: 120px;text-align: center;">\n' + data.specification +
  424. ' </td>\n' +
  425. ' </tr>';
  426. }
  427. $('#zsd_yp').append(zsdYpHtm);
  428. var htm = '';
  429. for (let i = 0; i < 10; i++) {
  430. htm += '<tr class="zsd_two_tr">\n' +
  431. ' <td style="vertical-align: middle !important;width: 30px;text-align: center;">&nbsp;&nbsp;月&nbsp;&nbsp;日</td>\n' +
  432. ' <td style="vertical-align: middle !important;width: 30px;text-align: right;"></td>\n' +
  433. ' <td style="vertical-align: middle !important;width: 30px;text-align: right;"></td>\n' +
  434. ' <td style="vertical-align: middle !important;width: 30px;text-align: right;"></td>\n' +
  435. ' <td style="vertical-align: middle !important;width: 30px;text-align: right;"></td>\n' +
  436. ' <td style="vertical-align: middle !important;width: 30px;text-align: center;">&nbsp;&nbsp;月&nbsp;&nbsp;日</td>\n' +
  437. ' <td style="vertical-align: middle !important;width: 30px;text-align: right;"></td>\n' +
  438. ' <td style="vertical-align: middle !important;width: 30px;text-align: right;"></td>\n' +
  439. ' <td style="vertical-align: middle !important;width: 30px;text-align: right;"></td>\n' +
  440. ' <td style="vertical-align: middle !important;width: 30px;text-align: right;"></td>\n' +
  441. ' </tr>';
  442. }
  443. $('#zsd_two').append(htm);
  444. LODOP = getLodop();
  445. LODOP.PRINT_INITA(6, 0, "148mm", "210mm", "泰和医院门、急诊注射单");
  446. LODOP.SET_PRINT_STYLE("FontSize", 9); //字体大小
  447. //设置默认打印机
  448. LODOP.SET_PRINTER_INDEX(zsdPrintIndex);
  449. LODOP.SET_PRINT_PAGESIZE(2, '148mm', '210mm', "CreateCustomPage");
  450. LODOP.SET_SHOW_MODE("BKIMG_WIDTH", "148mm");
  451. LODOP.SET_SHOW_MODE("BKIMG_HEIGHT", "210mm");
  452. LODOP.SET_PRINT_MODE("CREATE_CUSTOM_PAGE_NAME", "泰和医院门、急诊注射单");//对新建的纸张重命名
  453. LODOP.ADD_PRINT_HTM("10mm", "5mm", "148mm", "210mm", $("div[id='print_view_zsd']").html());
  454. LODOP.PRINT();
  455. //LODOP.PREVIEW();
  456. }
  457. if(drugs.length > 0){
  458. LODOP = getLodop();
  459. LODOP.PRINT_INITA(6, 0, "60mm", "80mm", "患者药品标签");
  460. LODOP.SET_PRINT_STYLE("FontSize", 9); //字体大小
  461. //设置默认打印机
  462. LODOP.SET_PRINTER_INDEX(bqPrintIndex);
  463. LODOP.SET_PRINT_PAGESIZE(2, '60mm', '80mm', "CreateCustomPage");
  464. LODOP.SET_SHOW_MODE("BKIMG_WIDTH", "60mm");
  465. LODOP.SET_SHOW_MODE("BKIMG_HEIGHT", "80mm");
  466. LODOP.SET_PRINT_MODE("CREATE_CUSTOM_PAGE_NAME", "患者药品标签");//对新建的纸张重命名
  467. for (let j = 0; j < drugs.length; j++) {
  468. for (var key in drugs[j]) {
  469. $("#ypbq_" + key + "").attr("value", drugs[j][key]);
  470. }
  471. $("#dataTime").attr("value",format(new Date(), "yyyy-MM-dd HH:mm"));
  472. $("#ypbq_sex").attr("value",getSex(drugs[0].sex));
  473. $("#ypbq_age").attr("value",drugs[0].age);
  474. $("#NO").attr("value",j+1+"/"+drugs.length);
  475. //每次用量计算 通过一次剂量单位截取同单位的最小药品规格
  476. //drugs[j].specification.slice();
  477. let weight = (drugs[j].weight==''|| drugs[j].weight==null)?drugs[j].volum:drugs[j].weight;
  478. $("#ypbq_comm").attr("value",drugs[j].comm+',每次'+drugs[j].drugQuan/weight+drugs[j].miniUnitName);
  479. LODOP.ADD_PRINT_HTM("5mm", "5mm", "RightMargin:5mm","BottomMargin:5mm", $("div[id='print_view_bq']").html());
  480. LODOP.NewPage();//下一页
  481. }
  482. LODOP.PRINT();
  483. //LODOP.PREVIEW();
  484. }
  485. } else {
  486. errorMesage(res);
  487. }
  488. }
  489. });
  490. }
  491. /**
  492. * 返回性别
  493. */
  494. function getSex(code) {
  495. var sex = '';
  496. if (code == 1) {
  497. sex = '男';
  498. } else if (code == 2) {
  499. sex = '女';
  500. } else {
  501. sex = '未知';
  502. }
  503. return sex;
  504. }
  505. /**
  506. * 构建列表查询参数
  507. * @param params
  508. * @returns {{mzChargeDetail: {patientId: string | number | string[] | undefined | jQuery, warnDept: string | number | string[] | undefined | jQuery, doctorCode: string | number | string[] | undefined | jQuery, name: string | number | string[] | undefined | jQuery, payMark: number}, beginTime: Date, endTime: Date, pageSize: *, pageIndex: number}}
  509. */
  510. function queryParams(params) {
  511. var rePortRangeArr = getRePortRangeArr();
  512. var temp = {
  513. pageSize: params.limit, //页面大小
  514. pageIndex: params.offset / params.limit, //页码
  515. beginDate: rePortRangeArr[0],
  516. endDate: rePortRangeArr[1],
  517. name: $("#nameSearch").val() == "" ? null : $("#nameSearch").val(),
  518. patientId: $("#patientId").val() == "" ? null : $("#patientId").val(),
  519. confirmFlag: $("#confirmFlagSearch").val(),
  520. realNo: $("#realNoSearch").val() == "" ? null : $("#realNoSearch").val(),
  521. groupNoOut: '71'
  522. };
  523. return temp;
  524. };
  525. /**
  526. * 获取时间选择器的时间数组
  527. * @returns {string[]}
  528. */
  529. function getRePortRangeArr() {
  530. var rePortRange = $('#reportrange span').html();
  531. var rePortRangeArr = rePortRange.split(" - ");
  532. rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
  533. rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
  534. return rePortRangeArr;
  535. }
  536. /**
  537. * 清空查询条件
  538. */
  539. function cleanParams() {
  540. $('#reportrange span').html(moment().format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
  541. $("#nameSearch").val(null);
  542. $("#patientId_or_cardNo").val(null);
  543. $("#patientIdSearch").val(null);
  544. $("#realNoSearch").val(null);
  545. var sendRefundGroup = getIndex("send_refund_group");
  546. sendRefundGroup == 0 ? $("#confirmFlagSearch").selectpicker('val', 0) : $("#confirmFlagSearch").selectpicker('val', 2);
  547. $("#confirmFlagSearch").selectpicker('refresh');
  548. $("#patientId_or_cardNo").focus();
  549. }
  550. /**
  551. * 查询病人处方明细
  552. */
  553. var $table;
  554. function prescriptionDetail(realNo, groupNo, orderNo, receiptNo, times, patientId) {
  555. var temp = {
  556. groupNo: groupNo,
  557. realNo: realNo,
  558. orderNo: orderNo,
  559. receiptNo: receiptNo,
  560. times: times,
  561. patientId: patientId
  562. };
  563. $('#tb_table_right').bootstrapTable("destroy");
  564. $table = $('#tb_table_right').bootstrapTable({
  565. url: '/thmz/getFyclPrescriptionDetail', //请求后台的URL(*)
  566. method: 'POST', //请求方式(*)
  567. striped: true, //是否显示行间隔色
  568. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  569. pagination: true, //是否显示分页(*)
  570. sortable: true, //是否启用排序
  571. sortOrder: "asc", //排序方式
  572. queryParams: JSON.stringify(temp), //传递参数(*)
  573. sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
  574. pageNumber: 1, //初始化加载第一页,默认第一页
  575. pageSize: 10, //每页的记录行数(*)
  576. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  577. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  578. strictSearch: true,
  579. showColumns: false, //是否显示所有的列
  580. showRefresh: false, //是否显示刷新按钮
  581. minimumCountColumns: 2, //最少允许的列数
  582. clickToSelect: true, //是否启用点击选中行
  583. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  584. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  585. cardView: false, //是否显示详细视图
  586. detailView: false,
  587. //rowStyle:rowStyle,//通过自定义函数设置行样式
  588. ajaxOptions: {
  589. headers: {
  590. 'Accept': 'application/json',
  591. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  592. }
  593. },
  594. columns: [
  595. {
  596. field: 'location',
  597. title: '货位号',
  598. align: "center",
  599. valign: 'middle'
  600. }, {
  601. field: 'drugname',
  602. title: '品名',
  603. align: "center",
  604. valign: 'middle',
  605. }, {
  606. field: 'specification',
  607. title: '规格',
  608. align: "center",
  609. valign: 'middle',
  610. }, {
  611. field: 'quantity',
  612. title: '<span style="color: green">数量</span>',
  613. align: "center",
  614. valign: 'middle',
  615. formatter: function (value, row, index) {
  616. return '<span style="color: green">' + value + '</span>'
  617. }
  618. }, {
  619. field: 'ypUnitName',
  620. title: '单位',
  621. align: "center",
  622. valign: 'middle',
  623. }, {
  624. field: 'abbrName',
  625. title: '生产厂家',
  626. align: "center",
  627. valign: 'middle',
  628. }, {
  629. field: 'drugQuan',
  630. title: '一次剂量',
  631. align: "center",
  632. valign: 'middle',
  633. }, {
  634. field: 'drugUnitName',
  635. title: '单位',
  636. align: "center",
  637. valign: 'middle',
  638. }, {
  639. field: 'frequency',
  640. title: '频率',
  641. align: "center",
  642. valign: 'middle',
  643. }, {
  644. field: 'decAmount',
  645. title: '<span style="color: red">退药量</span>',
  646. align: "center",
  647. valign: 'middle',
  648. formatter: function (value, row, index) {
  649. return value == null ? '<span style="color: red">-</span>' : '<span style="color: red">' + value + '</span>'
  650. }
  651. }, {
  652. field: 'printName',
  653. title: '给药方式',
  654. align: "center",
  655. valign: 'middle',
  656. }, {
  657. field: 'unitPrice',
  658. title: '单价',
  659. align: "center",
  660. valign: 'middle',
  661. }
  662. /* , {
  663. field: 'drug_flag',//毒麻标志:1:毒;2:麻;3:精神1;4:精神2
  664. title: '<span style="color: red">毒麻</span>',
  665. align: "center",
  666. valign: 'middle',
  667. formatter: function (value, row, index) {
  668. if(value == 1){
  669. return '<span style="color: red">毒</span>'
  670. }else if(value == 2){
  671. return '<span style="color: red">麻</span>'
  672. }else if(value == 3){
  673. return '<span style="color: red">精神1</span>'
  674. }else if(value == 3){
  675. return '<span style="color: red">精神2</span>'
  676. }else{
  677. return '<span style="color: red">-</span>'
  678. }
  679. }
  680. }*/
  681. , {
  682. field: 'stockAmount',
  683. title: '当前库存',
  684. align: "center",
  685. valign: 'middle',
  686. }
  687. ],
  688. responseHandler: function (res) {
  689. if (res == '401' || res == 401) {
  690. window.location.href = '/thmz/login/view'
  691. return;
  692. }
  693. var ress = eval(res);
  694. if (ress.data.length > 0) {
  695. $("#employeeNameLabel").val(ress.data[0].employeeName);
  696. $("#warnDeptNameLabel").val(ress.data[0].warnDeptName);
  697. $("#chargeDateLabel").val(format(ress.data[0].chargeDate, "yyyy-MM-dd HH:mm:ss"));
  698. $("#icdTextLabel").val(ress.data[0].icdText);
  699. }
  700. if (ress.code == -1) {
  701. if (ress.message != null && ress.message != '') {
  702. new PNotify({
  703. title: '错误提示',
  704. text: ress.message,
  705. type: 'error',
  706. hide: true,
  707. styling: 'bootstrap3'
  708. });
  709. }
  710. return {
  711. "total": 0,//总页数
  712. "rows": {} //数据
  713. };
  714. }
  715. return {
  716. "total": ress.data.length,//总页数
  717. "rows": ress.data //数据
  718. };
  719. },
  720. });
  721. $("#cfxxModal").modal();
  722. }
  723. /**
  724. * 查询病人处方药品明细
  725. */
  726. function fitfymx(patientId, times, receiptNo, orderNo, groupNoOut) {
  727. var temp = {
  728. patientId: patientId,
  729. times: times,
  730. receiptNo: receiptNo,
  731. orderNo: orderNo,
  732. groupNoOut: groupNoOut,
  733. confirmFlag: $("#confirmFlagSearch").val()
  734. };
  735. $('#tb_table_right_ty').bootstrapTable("destroy");
  736. $table = $('#tb_table_right_ty').bootstrapTable({
  737. url: '/thmz/getRefundYpMx', //请求后台的URL(*)
  738. method: 'post', //请求方式(*)
  739. striped: true, //是否显示行间隔色
  740. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  741. pagination: true, //是否显示分页(*)
  742. sortable: true, //是否启用排序
  743. sortOrder: "asc", //排序方式
  744. queryParams: temp, //传递参数(*)
  745. sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
  746. pageNumber: 1, //初始化加载第一页,默认第一页
  747. pageSize: 10, //每页的记录行数(*)
  748. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  749. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  750. strictSearch: true,
  751. showColumns: false, //是否显示所有的列
  752. showRefresh: false, //是否显示刷新按钮
  753. minimumCountColumns: 2, //最少允许的列数
  754. clickToSelect: true, //是否启用点击选中行
  755. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  756. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  757. cardView: false, //是否显示详细视图
  758. detailView: false,
  759. //rowStyle:rowStyle,//通过自定义函数设置行样式
  760. ajaxOptions: {
  761. headers: {
  762. 'Accept': 'application/json',
  763. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  764. }
  765. },
  766. columns: [
  767. {
  768. field: 'drugname',
  769. title: '品名',
  770. align: "center",
  771. valign: 'middle',
  772. formatter: function (value, row, index) {
  773. if (value != null && value != "") {
  774. return value.replace("()", "");
  775. }
  776. return "";
  777. }
  778. }, {
  779. field: 'specification',
  780. title: '规格',
  781. align: "center",
  782. valign: 'middle',
  783. }, {
  784. field: 'quantity',
  785. title: '数量',
  786. align: "center",
  787. valign: 'middle',
  788. }, {
  789. field: 'unit_price',
  790. title: '单价',
  791. align: "center",
  792. valign: 'middle',
  793. }, {
  794. field: 'dec_amount',
  795. title: '<span style="color: red">退药量</span>',
  796. align: "center",
  797. valign: 'middle',
  798. formatter: function (value, row, index) {
  799. return '<span style="color: red">' + value + '</span>'
  800. }
  801. }
  802. ],
  803. responseHandler: function (res) {
  804. if (res == '401' || res == 401) {
  805. window.location.href = '/thmz/login/view'
  806. return;
  807. }
  808. var ress = eval(res);
  809. if (ress.code == -1) {
  810. if (ress.message != null && ress.message != '') {
  811. new PNotify({
  812. title: '错误提示',
  813. text: ress.message,
  814. type: 'error',
  815. hide: true,
  816. styling: 'bootstrap3'
  817. });
  818. }
  819. return {
  820. "total": 0,//总页数
  821. "rows": {} //数据
  822. };
  823. }
  824. return {
  825. "total": ress.data.length,//总页数
  826. "rows": ress.data //数据
  827. };
  828. },
  829. });
  830. }
  831. /**
  832. * 退药处理
  833. */
  834. function saveRefundMedicine() {
  835. if (!confirm("确定要对当前处方的药品进行退药处理吗?")) {
  836. return;
  837. }
  838. var data = $table.bootstrapTable('getData');
  839. var datas = [];
  840. var i = 0;
  841. data.forEach(function (item, index, arr) {
  842. if (item.dec_amount != 0) {
  843. var tem = {
  844. "patientId": item.patient_id,
  845. "times": item.times,
  846. "receiptNo": item.receipt_no,
  847. "orderNo": item.order_no,
  848. "realNo": item.real_no,
  849. "decAmount": item.dec_amount,
  850. "unitPrice": item.unit_price,
  851. "chargeCode": item.charge_item_code,
  852. "serial": item.serial,
  853. "groupNo": item.group_no,
  854. "itemNo": item.item_no,
  855. "serialNo": item.serial_no
  856. }
  857. datas[i] = tem;
  858. i++;
  859. }
  860. })
  861. if (datas.length == 0) {
  862. return;
  863. }
  864. $.ajax({
  865. type: "POST",
  866. url: '/thmz/refundMedicineProcessing',
  867. contentType: "application/json;charset=UTF-8",
  868. dataType: "json",
  869. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  870. data: JSON.stringify(datas),
  871. success: function (res) {
  872. if (res == '401' || res == 401) {
  873. window.location.href = '/thmz/login/view'
  874. return;
  875. }
  876. if (res.code == 0) {
  877. successMesage(res);
  878. initTbTable();
  879. } else {
  880. errorMesage(res);
  881. }
  882. }
  883. });
  884. }
  885. /**
  886. * 叫号
  887. * @param patientId
  888. * @param name
  889. */
  890. function callNumber(patientId, name) {
  891. toMedicineWebSocket.send(JSON.stringify({patient_id: patientId, name: name, type: 'jh'}));
  892. }
  893. /**
  894. * 查询默认打印机
  895. */
  896. function setPrint() {
  897. if (zsdPrintIndex >= 0 && bqPrintIndex >= 0) {
  898. return;
  899. }
  900. $.ajax({
  901. type: "GET",
  902. url: '/thmz/getLastDispensingWindowsByCurrentUser',
  903. contentType: "application/json;charset=UTF-8",
  904. dataType: "json",
  905. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  906. async: false,
  907. success: function (res) {
  908. if (res == '401' || res == 401) {
  909. window.location.href = '/thmz/login/view'
  910. return;
  911. }
  912. if (res.code == 0) {
  913. zsdPrintIndex = res.data.zsdPrintIndex;
  914. bqPrintIndex = res.data.bqPrintIndex;
  915. } else {
  916. zsdPrintIndex = -1;
  917. bqPrintIndex = -1;
  918. }
  919. }
  920. });
  921. }
  922. var prescriptionPrintWebSocket = null;
  923. var toMedicineWebSocket = null;
  924. //判断当前浏览器是否支持WebSocket, 主要此处要更换为自己的地址
  925. if ('WebSocket' in window) {
  926. prescriptionPrintWebSocket = new WebSocket("ws://" + window.location.host + "/thmz/prescriptionPrintSocket");
  927. toMedicineWebSocket = new WebSocket("ws://" + window.location.host + "/thmz/toMedicineSocket/sender");
  928. } else {
  929. alert('Not support websocket')
  930. }
  931. //---------prescriptionPrintWebSocket start
  932. //连接发生错误的回调方法
  933. prescriptionPrintWebSocket.onerror = function () {
  934. console.log("发药连接prescriptionPrintWebSocket发生错误")
  935. };
  936. //连接成功建立的回调方法
  937. prescriptionPrintWebSocket.onopen = function (event) {
  938. console.log("发药连接prescriptionPrintWebSocket连接成功");
  939. }
  940. //接收到消息的回调方法
  941. prescriptionPrintWebSocket.onmessage = function (event) {
  942. var confirmFlag = $("#confirmFlagSearch").val();
  943. var data = JSON.parse(event.data);
  944. if (data.type == 'py' && data.content == 1 && confirmFlag == 0) {//来自配药处理成功后的消息
  945. initTbTable();
  946. }
  947. }
  948. //连接关闭的回调方法
  949. prescriptionPrintWebSocket.onclose = function () {
  950. console.log("发药连接prescriptionPrintWebSocket连接关闭");
  951. }
  952. //-----------prescriptionPrintWebSocket end
  953. //---------toMedicineWebSocket start
  954. //连接发生错误的回调方法
  955. toMedicineWebSocket.onerror = function () {
  956. console.log("发药连接toMedicineWebSocket发生错误")
  957. };
  958. //连接成功建立的回调方法
  959. toMedicineWebSocket.onopen = function (event) {
  960. console.log("发药连接toMedicineWebSocket连接成功");
  961. }
  962. //接收到消息的回调方法
  963. toMedicineWebSocket.onmessage = function (event) {
  964. }
  965. //连接关闭的回调方法
  966. toMedicineWebSocket.onclose = function () {
  967. console.log("发药连接toMedicineWebSocket连接关闭");
  968. }
  969. //-----------toMedicineWebSocket end
  970. //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
  971. window.onbeforeunload = function () {
  972. prescriptionPrintWebSocket.close();
  973. toMedicineWebSocket.close();
  974. }
  975. //关闭连接
  976. function closeWebSocket() {
  977. prescriptionPrintWebSocket.close();
  978. toMedicineWebSocket.close();
  979. }