xufangxiangqing.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. mui.plusReady(function(){
  2. var docInfo = JSON.parse(plus.storage.getItem("docInfo")),
  3. self = plus.webview.currentWebview(),
  4. teamCode = self.teamCode?self.teamCode:'',
  5. info= self.infoStr?JSON.parse(self.infoStr):'',
  6. isLeader;
  7. var $patiInfo = $('#patient-info');
  8. var strOriginalData;//认证专用
  9. var prescriptionCode = info?info.code:self.prescriptionCode;
  10. //判断是否为该团队团队长
  11. if(docInfo.isLeader && teamCode == docInfo.adminTeamCode){
  12. isLeader = 1;
  13. }else{
  14. isLeader=0
  15. }
  16. queryData();
  17. bindEvent();
  18. function queryData(){
  19. plus.nativeUI.showWaiting();
  20. var params ={
  21. code:prescriptionCode,
  22. type:isLeader
  23. }
  24. sendPost("doctor/prescriptionInfo/getContinuedPrescriptionAsDoctor",params, function(){
  25. plus.nativeUI.closeWaiting();
  26. mui.toast("请求失败");
  27. }, function(res){
  28. plus.nativeUI.closeWaiting();
  29. if(res.status == 200){
  30. strOriginalData = res.data;
  31. var html = template('pati_tmp',{data:res.data,isLeader:isLeader})
  32. $patiInfo.html(html);
  33. //判断团队长
  34. if(isLeader){
  35. $('.layer-res').show();
  36. if(res.data.prescription.status == 0){
  37. $('.header-link').show();
  38. $('.header-link2').hide();
  39. }else if(res.data.prescription.status == 2 ||res.data.prescription.status == 3){
  40. $('.header-link2').show();
  41. $('.header-link').hide();
  42. }
  43. //加载插件
  44. if(res.data.prescription.status == 0 || res.data.prescription.status == 31){
  45. $('.os-main').css('padding-bottom','147px')
  46. selectFee();
  47. selectHome();
  48. selectResult();
  49. nopassReason();
  50. }else{
  51. $('.os-main').css('padding-bottom','10px')
  52. }
  53. }
  54. }else{
  55. mui.toast("获取数据失败");
  56. }
  57. },'get')
  58. }
  59. function bindEvent(){
  60. //选择调整平台
  61. $(".header-link").on('tap', function(){
  62. mui('#sheet1').popover('toggle');
  63. })
  64. //防止在调整中,再次请求接口
  65. $(".header-link2").on('tap', function(){
  66. mui.openWindow({
  67. id: "change-chufang1",
  68. url: "change-chufang1.html",
  69. waiting:{autoShow:false},
  70. extras: {
  71. prescriptionCode:prescriptionCode,
  72. state:strOriginalData.prescription.status
  73. }
  74. })
  75. })
  76. $('.j-change-method').click(function(){
  77. var $this = $(this)
  78. mui('#sheet1').popover('toggle');
  79. if($this.index()==1){
  80. mui.openWindow({
  81. id: "change-chufang1",
  82. url: "change-chufang1.html",
  83. waiting:{autoShow:false},
  84. extras: {
  85. state:strOriginalData.prescription.status,
  86. prescriptionCode:prescriptionCode,
  87. jwHospital:strOriginalData.prescription.jwHospital,
  88. jwDoctorCode:strOriginalData.prescription.jwDoctorCode
  89. }
  90. })
  91. }else{
  92. nextPage();
  93. }
  94. })
  95. function nextPage(){
  96. var usefulMsg = {};
  97. usefulMsg.prescriptionCode = prescriptionCode;
  98. usefulMsg.diagnosis = strOriginalData.diagnosis;
  99. usefulMsg.prescriptionInfo = strOriginalData.prescriptionInfo;
  100. mui.openWindow({
  101. id: "change-chufang2",
  102. url: "change-chufang2.html",
  103. extras: {
  104. jsonStr:usefulMsg
  105. }
  106. })
  107. }
  108. //调整处方
  109. $patiInfo.on('click','#changeMethod',function(){
  110. nextPage()
  111. })
  112. //不通过原因
  113. $patiInfo.on('click','.nopass-list li',function(){
  114. var $this = $(this)
  115. if($this.hasClass('active')){
  116. $this.removeClass('active')
  117. }else{
  118. $this.addClass('active')
  119. }
  120. fillWord()
  121. })
  122. function fillWord(){
  123. var str=''
  124. $.map($('.nopass-list li.active'),function(o,i){
  125. str += $('.nopass-list li.active').eq(i).text()+',';
  126. })
  127. $('#textarea').val(str.substr(0,str.length-1))
  128. }
  129. $patiInfo.on('click','#old-data',function(){
  130. mui.openWindow({
  131. id: "chufangxiangqing",
  132. url: "chufangxiangqing.html",
  133. extras: {
  134. code:strOriginalData.prescription.jwCode,
  135. patient:strOriginalData.prescription.patient
  136. }
  137. })
  138. })
  139. //跳转订单
  140. $patiInfo.on('click','#booking',function(){
  141. mui.openWindow({
  142. id: "dingdangenzong",
  143. url: "dingdangenzong.html",
  144. extras: {
  145. prescriptionCode:prescriptionCode,
  146. teamCode:teamCode
  147. }
  148. })
  149. })
  150. $patiInfo.on('click','#history_msg',function(){
  151. var $this = $(this)
  152. mui.openWindow({
  153. id: "juminxufangjilu",
  154. url: "juminxufangjilu.html",
  155. extras: {
  156. patiCode:strOriginalData.prescription.patient,
  157. teamCode:teamCode,
  158. patiName:strOriginalData.prescription.patientName
  159. }
  160. })
  161. })
  162. //回答居民
  163. $('.layer-res').click(function(){
  164. if(strOriginalData.prescription.status == 100){
  165. mui.openWindow({
  166. id: "xufangzixunxiangqing",
  167. url: "xufangzixunxiangqing.html",
  168. extras: {
  169. sessionId:strOriginalData.prescription.patient+'_'+strOriginalData.prescription.consult+'_'+8,
  170. sessionName:strOriginalData.prescription.patientName,
  171. sessionTime:checkDate(strOriginalData.prescription.createTime),
  172. patiCode:strOriginalData.prescription.patient,
  173. status:2,
  174. type:8
  175. }
  176. })
  177. }else{
  178. mui.openWindow({
  179. id: "xufangzixun.html",
  180. url: "../../message/html/xufangzixun.html",
  181. extras: {
  182. type:8,
  183. sessionId:strOriginalData.prescription.patient+'_'+strOriginalData.prescription.consult+'_'+8,
  184. sessionName:strOriginalData.prescription.patientName
  185. }
  186. })
  187. }
  188. })
  189. //提交审核
  190. $patiInfo.on('click','#confirm',function(){
  191. if($('#showResult').attr('data-id')){
  192. if($('#showResult').attr('data-id')==2){
  193. if($('#textarea').val().trim()){
  194. passingReview();
  195. }else{
  196. mui.toast('请填写不通过原因')
  197. }
  198. }else if($('#doctorHome').attr('data-id') && $('#feeCheck').attr('data-id')){
  199. nextDo();
  200. }else{
  201. mui.toast('请完善续方审核')
  202. }
  203. }else{
  204. mui.toast('请完善续方审核')
  205. }
  206. })
  207. function nextDo(){
  208. plus.nativeUI.showWaiting();
  209. sendPost("doctor/isAuthentication",{}, function(){
  210. plus.nativeUI.closeWaiting();
  211. mui.toast("请求失败");
  212. }, function(res){
  213. if(res.status == 200){
  214. plus.nativeUI.closeWaiting();
  215. if(res.data.type != 4){
  216. dialog({
  217. content: '您暂未安装CA证书,无法进行续方审核,点击前往安装',
  218. okValue: '前往安装',
  219. cancelValue: '取消',
  220. cancel: function () {
  221. return;
  222. },
  223. ok: function() {
  224. mui.openWindow({
  225. id: "cazhengshu",
  226. url: "cazhengshu.html",
  227. waiting:{autoShow:false},
  228. extras: {
  229. code:res.data.type
  230. }
  231. })
  232. }
  233. }).showModal();
  234. }else{
  235. $('#doctorName').html(docInfo.name)
  236. $('.layer-bg').show();
  237. }
  238. }else{
  239. plus.nativeUI.closeWaiting();
  240. mui.toast("请求证书信息失败");
  241. }
  242. },'get')
  243. }
  244. //输入密码
  245. var psw = 0;
  246. var $li = $('#password').find('li');
  247. $('.number-pad').on('tap','li',function(){
  248. var $this = $(this)
  249. if(!$this.hasClass('no')){
  250. if(!$this.hasClass('del')){
  251. if(psw <=5){
  252. var $one = $li.eq(psw);
  253. $one.addClass('active');
  254. $one.attr('data-val',$this.text().trim());
  255. psw++;
  256. }else{
  257. mui.toast('请点击确定')
  258. }
  259. }else{
  260. if(psw >=1){
  261. psw--;
  262. var $one = $li.eq(psw);
  263. $one.removeClass('active');
  264. $one.attr('data-val','');
  265. }
  266. }
  267. }else{
  268. if(psw ==6){
  269. submitContent()
  270. }
  271. }
  272. })
  273. //时间格式
  274. function checkDate(d) {
  275. var t = new Date(d);
  276. var month = (t.getMonth() + 1) < 10 ? '0' + (t.getMonth() + 1) : (t.getMonth() + 1);
  277. var day = t.getDate() < 10 ? '0' + t.getDate() : t.getDate();
  278. return month+day
  279. }
  280. //提取密码
  281. function takePassword(){
  282. var str = '';
  283. $li.each(function(){
  284. str += $(this).attr('data-val');
  285. })
  286. return str
  287. }
  288. //忘记密码
  289. $('#forget').click(function(){
  290. mui.openWindow({
  291. id: "shenfenrenzheng",
  292. url: "shenfenrenzheng.html",
  293. waiting:{autoShow:false}
  294. })
  295. })
  296. //取消
  297. $('.layer-bg').click(function(){
  298. cancel();
  299. })
  300. $('.xufang-num').click(function(e){ e.stopPropagation() })
  301. $('#cancel').click(function(){
  302. cancel();
  303. })
  304. function cancel(){
  305. $('.layer-bg').hide();
  306. psw = 0;
  307. $li.removeClass('active');
  308. $li.attr('data-val','');
  309. }
  310. function submitContent(){
  311. plus.nativeUI.showWaiting();
  312. var imporMsg = {};
  313. imporMsg.prescription = {};
  314. imporMsg.prescription.jwCode = strOriginalData.prescription.jwCode;
  315. imporMsg.prescription.patientName = strOriginalData.prescription.patientName;
  316. imporMsg.prescription.doctorName = strOriginalData.prescription.doctorName;
  317. imporMsg.prescription.diagnosis = strOriginalData.diagnosis;
  318. var arr=[]
  319. _.map(strOriginalData.prescriptionInfo,function(item){
  320. var obj = _.pick(item, 'drugCode','drugName','jwSubCode','physicAmount','physicAmountUnit','physicAmountUnitName');
  321. arr.push(obj)
  322. })
  323. imporMsg.prescription.prescriptionInfo = arr;
  324. var params ={
  325. strRealNameSoftCertCalledPasswd:takePassword(),
  326. strOriginalData:JSON.stringify(imporMsg),
  327. prescriptionCode:prescriptionCode
  328. }
  329. sendPost("doctor/requestRealNameSoftCertAndSign",params, function(){
  330. plus.nativeUI.closeWaiting();
  331. mui.toast("请求失败");
  332. }, function(res){
  333. if(res.status==200){
  334. if(res.data){
  335. cancel()
  336. passingReview()
  337. }else{
  338. plus.nativeUI.closeWaiting();
  339. mui.toast(res.msg)
  340. }
  341. }else{
  342. plus.nativeUI.closeWaiting();
  343. mui.toast("用户不存在或密码错误")
  344. psw = 0;
  345. $li.removeClass('active');
  346. $li.attr('data-val','');
  347. }
  348. })
  349. }
  350. function passingReview(){
  351. plus.nativeUI.showWaiting();
  352. //不通过CODE
  353. var reasonCode=[];
  354. $.map($('.nopass-list li.active'),function(o,i){
  355. reasonCode.push($('.nopass-list li.active').eq(i).attr('data-code'))
  356. })
  357. var datas = {
  358. code:prescriptionCode,
  359. registerFee:$('#feeCheck').attr('data-name'),
  360. rateTypeCode:$('#feeCheck').attr('data-id'),
  361. dept:$('#doctorHome').attr('data-id'),
  362. reason:$('#textarea').val(),
  363. reasonCode:reasonCode.join(','),
  364. state:$('#showResult').attr('data-id')
  365. }
  366. sendPost("doctor/prescriptionInfo/reviewPrescription",datas, function(){
  367. plus.nativeUI.closeWaiting();
  368. mui.toast("提交审核超时")
  369. },function(res){
  370. plus.nativeUI.closeWaiting();
  371. if(res.status == 200){
  372. if(res.data){
  373. refreshHz()
  374. if($('#showResult').attr('data-id') == 1){
  375. dialog({
  376. content: '提交审核成功,记得去完成该居民的随访哦',
  377. okValue: '好的',
  378. ok: function() {
  379. mui.back()
  380. }
  381. }).showModal();
  382. }else{
  383. mui.toast('提交成功')
  384. setTimeout(function(){
  385. mui.back()
  386. },500)
  387. }
  388. }else{
  389. refreshHz()
  390. mui.toast("开方失败")
  391. }
  392. }else{
  393. mui.toast("提交审核失败")
  394. }
  395. })
  396. }
  397. }
  398. template.helper('setStatus',function(o){
  399. if(o == -5){return '<span style="color: #999">线下取消</span>'}
  400. if(o == -4){return '<span style="color: #999">线下退费</span>'}
  401. if(o == -3){ return '<span style="color:#999">续方取消(24小时未支付)</span>' }
  402. if(o == -2){ return '<span style="color:#999">续方取消(居民主动取消)</span>' }
  403. if(o == -1){ return '<span style="color:#ff4c4c">审核未通过</span>' }
  404. if(o == 0 || o == 10){ return '<span style="color:#ffa54b">审核中</span>' }
  405. if(o == 2){ return '<span style="color:#ffa54b">调整中</span>' }
  406. if(o == 3){ return '<span style="color:#ffa54b">调整成功/待ca认证</span>' }
  407. if(o == 4){ return '<span style="color:#ffa54b">调整失败</span>' }
  408. if(o == 20){ return '<span style="color:#ffa54b">药师审核中</span>' }
  409. if(o == 21){ return '<span style="color:#ff4c4c">药师审核失败</span>' }
  410. if(o == 30){ return '<span style="color:#ffa54b">开方中</span>' }
  411. if(o == 31){ return '<span style="color:#ff4c4c">开方失败</span>' }
  412. if(o == 40 || o == 41){ return '<span style="color:#db6bbd">待支付</span>' }
  413. if(o == 50){ return '<span style="color:#ffa54b">配药中</span>' }
  414. if(o == 60){ return '<span style="color:#db6bbd">等待领药</span>' }
  415. if(o == 61 || o == 62 || o == 65 || o == 69){ return '<span style="color:#06bf04">配送中</span>' }
  416. if(o == 100){ return '<span style="color:#17b3ec">已完成</span>' }
  417. })
  418. template.helper('setReview',function(o){
  419. if(o == 0){ return '<span style="color:#ffa54b">审核中</span>' }
  420. if(o == 1){ return '<span style="color:#17b3ec">审核通过</span>' }
  421. if(o == -1){ return '<span style="color:#ff4c4c">审核未通过</span>' }
  422. if(o == -2){ return '<span style="color:#ff4c4c">审核无效</span>' }
  423. })
  424. template.helper('setPrescription',function(array){
  425. var arr=[];
  426. $.map(array,function(item,index){
  427. arr.push(item.name)
  428. })
  429. return arr.join(',')
  430. })
  431. template.helper('setRestTime',function(minDate,sDate){
  432. var now = getNowDate();
  433. var createDate = sDate.split(' ');
  434. var diff = getDays(createDate[0],now);
  435. if(diff<minDate){
  436. return '<span style="color:#17b3ec">'+(minDate-diff)+'天</span>'
  437. }else{
  438. return '<span style="color:#ff4c4c">已用完</span>'
  439. }
  440. })
  441. //相隔几天
  442. function getDays(sDate,eDate){
  443. var oDate1;
  444. var oDate2;
  445. var iDays;
  446. oDate1= sDate.split("-");
  447. oDate2= eDate.split("-");
  448. var strDateS = new Date(oDate1[0], oDate1[1]-1, oDate1[2]);
  449. var strDateE = new Date(oDate2[0], oDate2[1]-1, oDate2[2]);
  450. iDays = parseInt(Math.abs(strDateE - strDateS ) / 1000 / 60 / 60 /24)
  451. return iDays ;
  452. }
  453. //现在时间
  454. function getNowDate() {
  455. var date = new Date();
  456. var year = date.getFullYear();
  457. var month = date.getMonth() + 1;
  458. var day = date.getDate();
  459. var hour = date.getHours();
  460. var minute = date.getMinutes();
  461. var second = date.getSeconds();
  462. return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
  463. }
  464. //费用下拉
  465. function selectFee(){
  466. var data={
  467. jwHospital:strOriginalData.prescription.jwHospital,
  468. jwDoctorCode:strOriginalData.prescription.jwDoctorCode
  469. }
  470. sendPost("doctor/prescriptionInfo/getRegisterRee",data, function(){
  471. mui.toast("请求失败");
  472. }, function(res){
  473. if(res.status == 200){
  474. var result = res.data;
  475. var html = '<option disabled selected></option>';
  476. $.map(result,function(item,index){
  477. if(item.registerType == strOriginalData.prescription.jwGisterTypeCode){
  478. html += '<option selected value="'+item.registerType+'">'+item.registerTypeName+' '+item.registerFee+' 元'+'</option>';
  479. }else{
  480. html += '<option value="'+item.registerType+'">'+item.registerTypeName+' '+item.registerFee+' 元'+'</option>';
  481. }
  482. })
  483. $('#feeCheck').html(html);
  484. $('#feeCheck').mobiscroll().select({
  485. theme: 'ios',
  486. lang: 'zh',
  487. display: 'bottom',
  488. placeholder:'请按医生级别选择诊查费用',
  489. rows:4,
  490. onSelect: function ( valueText, inst) {
  491. $('#feeCheck').attr('data-id',inst._tempValue)
  492. $('#feeCheck').attr('data-name',valueText.split(' ')[1])
  493. }
  494. })
  495. }
  496. },'get')
  497. }
  498. // 科室下拉
  499. function selectHome(){
  500. var data={
  501. jwHospital:strOriginalData.prescription.jwHospital,
  502. jwDoctorCode:strOriginalData.prescription.jwDoctorCode
  503. }
  504. sendPost("doctor/prescriptionInfo/getDeptList",data, function(){
  505. mui.toast("请求失败");
  506. }, function(res){
  507. if(res.status == 200){
  508. var result = res.data;
  509. var html = '<option disabled selected></option>';
  510. $.map(result,function(item,index){
  511. if(item.deptCode ==strOriginalData.prescription.jwDeptCode){
  512. html += '<option selected value="'+item.deptCode+'">'+item.deptName+'</option>';
  513. }else{
  514. html += '<option value="'+item.deptCode+'">'+item.deptName+'</option>';
  515. }
  516. })
  517. $('#doctorHome').html(html);
  518. $('#doctorHome').mobiscroll().select({
  519. theme: 'ios',
  520. lang: 'zh',
  521. display: 'bottom',
  522. placeholder:'请选择您所在科室',
  523. rows:4,
  524. onSelect: function ( valueText, inst) {
  525. $('#doctorHome').attr('data-id',inst._tempValue)
  526. }
  527. })
  528. }
  529. },'get')
  530. }
  531. //审核下拉
  532. function selectResult(){
  533. $('#showResult').mobiscroll().select({
  534. theme: 'ios',
  535. lang: 'zh',
  536. display: 'bottom',
  537. placeholder:'请选择审核结果',
  538. rows:4,
  539. onSelect: function ( valueText, inst) {
  540. $('#showResult').attr('data-id',inst._tempValue)
  541. if(inst._tempValue ==2){
  542. $('#nopass').show()
  543. $('#feeList').hide()
  544. $('#homeList').hide()
  545. }else if(inst._tempValue ==1){
  546. $('#nopass').hide()
  547. $('#feeList').show()
  548. $('#homeList').show()
  549. }else{
  550. $('#nopass').hide()
  551. $('#feeList').hide()
  552. $('#homeList').hide()
  553. }
  554. $('.os-main').css('padding-bottom',$('.xf-position').height()+10)
  555. }
  556. })
  557. }
  558. //不通过原因
  559. function nopassReason(){
  560. sendPost("doctor/prescriptionInfo/getReasonByType",{type:0}, function(){
  561. mui.toast("请求失败");
  562. }, function(res){
  563. if(res.status = 200){
  564. var str=""
  565. $.map(res.data,function(o,i){
  566. str += '<li data-code="'+o.code+'">'+o.value+'</li>'
  567. })
  568. $('.nopass-list').html(str)
  569. }
  570. },'get')
  571. }
  572. function reloadPageData(){
  573. queryData()
  574. }
  575. window.addEventListener("refreshXufang", function(){
  576. reloadPageData()
  577. })
  578. function refreshHz(){
  579. var page = plus.webview.getWebviewById("xufangguanli");
  580. if(page){
  581. mui.fire(page, "refreshXufang");
  582. }
  583. var page1 = plus.webview.getWebviewById("juminxufangjilu");
  584. if(page1){
  585. mui.fire(page1, "refreshXufang");
  586. }
  587. var page2 = plus.webview.getWebviewById("xufangxiangqing");
  588. if(page2){
  589. mui.fire(page2, "refreshXufang");
  590. }
  591. var page3 = plus.webview.getWebviewById("xufangxiaoxi");
  592. if(page3){
  593. mui.fire(page3, "refreshPage");
  594. }
  595. var page4 = plus.webview.getWebviewById("xufangzixun");
  596. if(page4){
  597. mui.fire(page4, "refreshPage");
  598. }
  599. }
  600. })