xufangzixun.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. var lastId = 0;
  2. var prevImage,
  3. offTop = 151,
  4. offBot = 0;
  5. var patientInfo,
  6. patiCode,
  7. consultCode,
  8. prescriptionCode, //续方的code
  9. prescriptionStatus, //续方的状态
  10. isFinishZX,//咨询的状态
  11. jwCode; //基卫那边存储的原处方的code
  12. var isJieshuCaozuo = false;
  13. var prescriptionMsg,followObj;
  14. var self;
  15. mui.plusReady(function() {
  16. self = plus.webview.currentWebview();
  17. $('#title').html(self.otherName);
  18. //通过sessionId来获取prescriptionCode和patiCode
  19. //续方咨询的sessionId 格式 居民code+咨询code+咨询类型( 8 )
  20. var sessionId = self.sessionId;
  21. patiCode = sessionId.split("_")[0];
  22. consultCode = sessionId.split("_")[1];
  23. //初始化个人信息 + 初始化scroller
  24. getMineInfo();
  25. //创建session
  26. // createSession(self.type, getMembersExt);
  27. //获得会话信息
  28. initPage();
  29. //获得续方信息
  30. getPrescriptionInfo();
  31. //获得患者的服务类型
  32. getPatientServiceType();
  33. prevImage = mui.previewImage();
  34. getPatientInfo();
  35. //判断患者是否绑定设备
  36. getPatientDeviceList();
  37. //快捷方式
  38. quickReply()
  39. bindEvent();
  40. //返回
  41. var opener = self.opener();
  42. if(opener && (opener.id == "xufangzixunxiangqing")) {
  43. var zxxq = plus.webview.getWebviewById("xufangzixunxiangqing");
  44. zxxq.close('none');
  45. backToZdzx();
  46. }else if(opener && (opener.id =="jumingim")){
  47. backToJMim();
  48. }else if(opener && (opener.id == "fzxz-jumingim")){
  49. backToJMim();
  50. }
  51. })
  52. function backToZdzx() {
  53. var old_back = mui.back;
  54. mui.back = function() {
  55. var wv = plus.webview.getWebviewById("xufangzixun");//续方咨询列表页
  56. if(wv) {
  57. mui.fire(wv, "refreshPage");
  58. }
  59. old_back();
  60. }
  61. }
  62. //刷新消息的居民im页面
  63. function backToJMim() {
  64. var old_back = mui.back;
  65. mui.back = function() {
  66. var wv = plus.webview.getWebviewById("jumingim");//续方咨询列表页
  67. if(wv) {
  68. mui.fire(wv, "update");
  69. }
  70. var wv1 = plus.webview.getWebviewById("fzxz-jumingim");//非咨询
  71. if(wv1) {
  72. mui.fire(wv1, "xiaoxiUpdate");
  73. }
  74. old_back();
  75. }
  76. }
  77. /**
  78. * 获得咨询成员信息
  79. */
  80. function getMembersExt() {
  81. getMembers();
  82. }
  83. /**
  84. * 获得续方的内容
  85. */
  86. function getPrescriptionInfo(){
  87. var url = "/doctor/consult/prescriptionDetail",
  88. params = {consult: consultCode,};
  89. sendGet(url, params, null, function(res){
  90. if(res.status == 200){
  91. prescriptionMsg = res.data;
  92. followObj = prescriptionMsg.followup=="null"?'':JSON.parse(prescriptionMsg.followup);
  93. jwCode = res.data.jwCode;
  94. prescriptionCode = res.data.code;
  95. $("#preDTName").text(res.data.symptoms+"-续方咨询");
  96. var status = res.data.status;
  97. prescriptionStatus = status;
  98. var statusName = getStatusName(status);
  99. $("#xfStatus").text(statusName);
  100. var drugmsg='';
  101. for(j=0; j<res.data.prescriptionInfo.length; j++){
  102. var item = res.data.prescriptionInfo[j];
  103. drugmsg += item.drugName+" "+item.num+item.drugNumUnitName+" ";
  104. }
  105. $("#drugInfo").find('.j-msg').text(drugmsg);
  106. $('.top-panel').show()
  107. if(status<0){
  108. $('.suifang').hide()
  109. }
  110. }else{
  111. mui.toast(res.msg);
  112. }
  113. }, true);
  114. }
  115. window.addEventListener('quickReplyRefresh', function() {
  116. quickReply()
  117. })
  118. //快捷方式
  119. function quickReply(){
  120. sendGet("doctor/reply/list",{type:1},null,function(res){
  121. if(res.status==200){
  122. var html="",
  123. data = res.data;
  124. for(var i=0;i<4;i++){
  125. html += '<li class="kj-li" data-id="'+data[i].systag+'">'+data[i].content+'</li>'
  126. }
  127. html +='<li id="kjhf">+ 更多快捷回复</li>'
  128. $(".xf-res-list").empty().append(html)
  129. }
  130. })
  131. }
  132. //获得患者的服务类型
  133. function getPatientServiceType(){
  134. var url = 'doctor/sign/getPatientFamilyServer',
  135. params = {patient: patiCode};
  136. sendGet(url, params, null, function(res){
  137. if(res.status == 200){
  138. //slowDiseasePatient: 0 //0表示没有慢病服务类型,1表示有
  139. if(res.data.slowDiseasePatient == 0){
  140. $("#diseaseTips").html("此居民未被标注【慢病】相关标签,是否确认核实?<a href='javascript:;' onclick='goToPatient()'>点击核实</a>");
  141. }else{
  142. var disease = "";
  143. for(var i=0; i<res.data.signFamilyServer.length; i++){
  144. var item = res.data.signFamilyServer[i];
  145. if(i>0){
  146. disease += ','+item.name;
  147. }else{
  148. disease += item.name;
  149. }
  150. }
  151. $("#diseaseTips").text("该居民为"+disease+"患者");
  152. }
  153. }else{
  154. mui.toast('获得患者服务类型失败');
  155. }
  156. }, true);
  157. }
  158. /**
  159. * 初始化页面
  160. */
  161. function initPage() {
  162. var url = 'doctor/consult/getConsultStatus',
  163. params = {consult: consultCode};
  164. sendPost(url, params, null,function(res){
  165. if(res.status == 200) {
  166. //咨询状态(0进行中,1已完成,-1患者取消,-2超时未响应自动关闭)
  167. if(res.data == 0) { //咨询未结束
  168. $('.topmsg1').html('审核完成24小时后,将自动结束咨询<a href="javascript:void(0)" onclick="jieshu()">立即结束</a>');
  169. $('#wrapper1').css({'bottom': '52px', 'top': '187px'});
  170. offBot = 52;
  171. $('#input_div').show();
  172. isFinishZX = 0;
  173. if(myScroll) myScroll.refresh();
  174. } else { //咨询已结束
  175. $('#wrapper1').css({
  176. top: '175px',
  177. bottom: '0px'
  178. });
  179. $('#input_div').hide();
  180. isFinishZX = 1;
  181. }
  182. //获得咨询信息
  183. // getFirstMsgs();
  184. //创建session
  185. createSession(self.type, getMembersExt);
  186. } else {
  187. mui.toast("获取信息失败");
  188. }
  189. }, 'get')
  190. }
  191. //判断object是否为空
  192. function isEmptyObject(e) {
  193. var t;
  194. for(t in e)
  195. return !1;
  196. return !0
  197. }
  198. //获得患者信息
  199. function getPatientInfo(){
  200. var url = 'doctor/patient_label_info/patient',
  201. params = {patient: patiCode};
  202. sendPost(url, params, null, function(res){
  203. if(res.status == 200){
  204. patientInfo = res.data;
  205. }else{
  206. mui.toast(res.msg);
  207. }
  208. }, 'POST', '', true)
  209. }
  210. //获得患者的绑定的设备信息
  211. function getPatientDeviceList(){
  212. var url = "doctor/device/PatientDeviceList",
  213. params = {patient: patiCode, page:1, pagesize: 2};
  214. sendGet(url, params, null, function(res){
  215. if(res.status == 200){
  216. if(res.data.length == 0){
  217. //没有绑定设备
  218. $(".tzjl").hide();
  219. }else{
  220. //绑定了设备
  221. $(".tzjl").show();
  222. }
  223. }else{
  224. //获取设备信息失败
  225. }
  226. }, true);
  227. }
  228. //跳转去患者信息页面
  229. function goToPatient(){
  230. mui.openWindow('../../huanzhe/html/huanzhexinxi.html', 'huanzhexinxi.html', {
  231. extras: {
  232. patiCode: patiCode
  233. }
  234. });
  235. }
  236. function bindEvent(){
  237. /**
  238. * 点击查看好友详细信息
  239. */
  240. $('#qun_detail').on("tap", function() {
  241. mui.openWindow('../../huanzhe/html/huanzhexinxi.html', 'huanzhexinxi.html', {
  242. extras: {
  243. patiCode: patiCode
  244. }
  245. });
  246. })
  247. //顶部内容的展开和收缩
  248. $("#expandBox").on('click', function(e){
  249. e.stopPropagation();
  250. var $this = $(this);
  251. if($this.hasClass('expand')){
  252. $this.removeClass('expand');
  253. $this.find('img').attr('src', '../images/zhankai_icon.png');
  254. $("#prescriptionInfo").hide();
  255. var top = $(".top-panel").height()+15;
  256. $("#wrapper1").css({
  257. "top" : top+'px'
  258. });
  259. }else{
  260. $this.addClass('expand');
  261. $this.find('img').attr('src', '../images/shouqi_icon.png');
  262. $("#prescriptionInfo").show();
  263. var top = $(".top-panel").height()+15;
  264. $("#wrapper1").css({
  265. "top" : top+'px'
  266. });
  267. }
  268. });
  269. //体征记录
  270. $(".tzjl").on('click', function(){
  271. mui.openWindow('../../jkjl/html/health-record.html', 'health-record', {
  272. extras: {
  273. patientCode: patiCode,
  274. patientName: patientInfo.name,
  275. qyRelation: 1
  276. }
  277. });
  278. });
  279. //检查检验
  280. $(".jcjy").on('click', function(){
  281. openWebview("../../huanzhe/html/jianchajianyan.html",{
  282. patiInfo: {
  283. code: patiCode
  284. }
  285. });
  286. });
  287. //诊断处方
  288. $(".zdcf").on('click', function(){
  289. openWebview("../../prescription/html/chufangxiangqing.html",{
  290. code: jwCode,
  291. patient:patiCode
  292. });
  293. });
  294. //历史续方
  295. $(".lsxf").on('click', function(){
  296. openWebview('../../prescription/html/juminxufangjilu.html', {
  297. teamCode: patientInfo.jtAdminTeam,
  298. patiCode: patiCode,
  299. patiName: patientInfo.name
  300. });
  301. });
  302. $("#prescriptionInfo").on("click", function(){
  303. openWebview('../../prescription/html/xufangxiangqing.html',{
  304. prescriptionCode: prescriptionCode,
  305. teamCode: patientInfo.jtAdminTeam
  306. });
  307. });
  308. //跳转去续方详情页面
  309. $("body").on('tap', ".view-detail", function(){
  310. openWebview('../../prescription/html/xufangxiangqing.html',{
  311. prescriptionCode: prescriptionCode,
  312. teamCode: patientInfo.jtAdminTeam
  313. });
  314. })
  315. //随访调查
  316. $("body").on('tap', ".viewData", function(){
  317. var type = $(this).attr('data-type')
  318. mui.openWindow('questionaires.html', 'questionaires', {
  319. extras: {
  320. pro_id:type,
  321. prescriptionCode: prescriptionCode,
  322. followupid:followObj.id
  323. }
  324. })
  325. })
  326. //登记随访
  327. function registerSuifang(){
  328. var followClass;
  329. if(prescriptionMsg.symptoms == "高血压"){
  330. followClass = 1;
  331. }else if(prescriptionMsg.symptoms == "糖尿病"){
  332. followClass = 2;
  333. }else{
  334. followClass = '1,2';
  335. }
  336. mui.openWindow('../../suifang/html/follow_way.html', 'xf_follow_way', {
  337. extras: {
  338. followup_id:followObj.id,
  339. followClass:followClass,
  340. patientInfo:patientInfo,
  341. prescriptionCode: prescriptionCode,
  342. prescriptionStatus:prescriptionMsg.status
  343. }
  344. })
  345. }
  346. $(".suifang").on('click', function(){
  347. if(! followObj){
  348. registerSuifang()
  349. }else{
  350. if(followObj.status == 2){
  351. registerSuifang()
  352. }else{
  353. mui.openWindow('../../suifang/html/fvDetail.html', 'xf_fvDetail', {
  354. extras: {
  355. followup_id:followObj.id,
  356. prescriptionCode:prescriptionCode
  357. }
  358. })
  359. }
  360. }
  361. })
  362. $(".wenjuan").on('click', function(){
  363. mui.openWindow('wenjuan.html', 'wenjuan', {
  364. extras: {
  365. prescriptionCode: prescriptionCode,
  366. followup_id:followObj.id,
  367. zx_Status:isFinishZX
  368. }
  369. })
  370. })
  371. $("body").on('tap', ".fillData", function(){
  372. if(! followObj){
  373. mui.toast('随访已不存在')
  374. return
  375. }else{
  376. var type = $(this).attr('data-type');
  377. var healthindexid = $(this).attr('data-health');
  378. var url;
  379. if(type == 1){
  380. url="doctor/prescription/followupcontent/importbloodpressure"
  381. }else{
  382. url="doctor/prescription/followupcontent/importbloodsugar"
  383. }
  384. plus.nativeUI.showWaiting();
  385. sendPost(url,{followupid:followObj.id,prescriptioncode:prescriptionCode,healthindexid:healthindexid},function(){
  386. plus.nativeUI.closeWaiting();
  387. mui.toast('请求失败')
  388. }, function(res){
  389. plus.nativeUI.closeWaiting();
  390. if(res.status == 200){
  391. mui.toast('成功填入随访记录')
  392. }else{
  393. mui.toast(res.msg)
  394. }
  395. })
  396. }
  397. })
  398. $(".follow").click(function(e){
  399. e.stopPropagation();
  400. if(! followObj){
  401. mui.toast('随访已不存在')
  402. return
  403. }else{
  404. plus.nativeUI.showWaiting();
  405. sendPost('doctor/prescription/followupcontent/importdrugs',{followupid:followObj.id,prescriptioncode:prescriptionCode},function(){
  406. plus.nativeUI.closeWaiting();
  407. mui.toast('请求失败')
  408. }, function(res){
  409. plus.nativeUI.closeWaiting();
  410. if(res.status == 200){
  411. mui.toast('成功填入随访记录')
  412. }else{
  413. mui.toast(res.msg)
  414. }
  415. })
  416. }
  417. })
  418. //头部导航
  419. mui('#nav').scroll({
  420. deceleration: 0.0005,
  421. scrollY: false, //是否竖向滚动
  422. scrollX: true, //是否横向滚动
  423. indicators: false
  424. })
  425. //快捷方式
  426. $('.tw-change').on('click',function(){
  427. $ipt_content.blur();
  428. $(".tw-add-detail").hide();
  429. $('.xf-res-list').toggle(200)
  430. })
  431. $('.xf-res-list').on('click','.kj-li',function(){
  432. var $this = $(this)
  433. var type = $this.attr('data-id')
  434. doQuickAnswer(type,$this.text().trim())
  435. $('.xf-res-list').hide()
  436. })
  437. $('.xf-res-list').on('click','#kjhf',function(){
  438. $('.xf-res-list').hide()
  439. mui.openWindow('../../kjhf/html/list.html', 'xf-kjhf', {
  440. extras: {
  441. type:'xufang'
  442. }
  443. })
  444. })
  445. }
  446. //处理快捷方式
  447. function doQuickAnswer(type,text){
  448. if(type==0){
  449. $(".tw-add-detail").hide();
  450. $(".xf-res-list").hide();
  451. $("#input_content").show();
  452. var content = text;
  453. ui.boxMsgSound.style.display = 'none';
  454. $(".yy-add").find('img:eq(0)').show().next().hide();
  455. $("#input_content").text(content);
  456. showSendBtn(true);
  457. }
  458. if(! followObj){
  459. mui.toast('随访已不存在')
  460. return
  461. }
  462. if(type == 3 || type == 4){
  463. var params = {
  464. followupid:followObj.id,
  465. prescriptionCode:prescriptionCode,
  466. type:type==3?2:1
  467. }
  468. plus.nativeUI.showWaiting()
  469. sendPost('doctor/consult/addPrescriptionBloodStatusConsult',params,null,function(res){
  470. plus.nativeUI.closeWaiting()
  471. if(res.status == 200){
  472. }else{
  473. mui.toast('获取数据失败')
  474. }
  475. })
  476. }
  477. if(type == 1 || type == 2){
  478. var kind = type==1?2:1;
  479. var name,time;
  480. sendGet('doctor/prescription/followupcontent/list',{prescriptioncode:prescriptionCode},null, function(res){
  481. if(res.status == 200){
  482. var obj = _.find(res.data, function(o){ return o.type ==kind})
  483. time = obj.createtime
  484. name = patientInfo.name
  485. if(obj.statue == "2"){
  486. var params = {
  487. followupid:followObj.id,
  488. prescriptionCode:prescriptionCode,
  489. type:kind
  490. }
  491. plus.nativeUI.showWaiting()
  492. sendPost('doctor/consult/addPrescriptionFollowupContentConsult',params,null,function(res){
  493. plus.nativeUI.closeWaiting()
  494. if(res.status == 200){
  495. }else{
  496. mui.toast('获取数据失败')
  497. }
  498. })
  499. }else{
  500. dialog({
  501. content:'<div class="c-f14">居民<span>'+name+'</span>已在<span>'+time+'</span>填写<span>'+obj.name+'</span></div>',
  502. okValue:'查看问卷',
  503. ok: function() {
  504. mui.openWindow('questionaires.html', 'questionaires', {
  505. extras: {
  506. pro_id:kind,
  507. prescriptionCode:prescriptionCode,
  508. followupid:followObj.id
  509. }
  510. })
  511. }
  512. }).showModal();
  513. }
  514. }
  515. })
  516. }
  517. }
  518. /**
  519. * 获取聊天图片列表
  520. */
  521. function getImgMsgList(handle) {
  522. im.getPrivateMsg(getUserId(), otherCode, lastId, pageSize, function(data) {
  523. console.log("imgs:" + JSON.stringify(data));
  524. chatCache.imgs = data.records.reverse();
  525. appendPrevImgs(chatCache.imgs);
  526. if(handle) handle(data);
  527. }, 2);
  528. }
  529. /**
  530. * 发送消息
  531. */
  532. function uploadMsg(type, content, locSrc, isNotSend, callBack) {
  533. service.isConsultFinished(consultCode, function(res) {
  534. if(res.data == 0) {
  535. //作用: 更新咨询状态
  536. uploadMsgBase(type, content, locSrc, isNotSend, callBack);
  537. } else if(res == "timeout" && type == 1) {
  538. var tim = new Date().getTime();
  539. var id = "loc" + tim;
  540. var d = [{
  541. "sender_id": docInfo.code,
  542. "sender_name": docInfo.name,
  543. "content_type": 1,
  544. "content": content,
  545. "timestamp": tim,
  546. "id": id,
  547. local_src: "",
  548. beforeSend: true
  549. }];
  550. showMsg(d, false, false, true);
  551. addMsgToCache(d, true);
  552. $('#contain dl[data-code="' + id + '"]').find('.c-msg').prepend("<i data-info='" + JSON.stringify(d[0]) + "' class='c-tips'></i>");
  553. } else {
  554. $('.topmsg1').hide();
  555. $('#wrapper1').css({
  556. top: offTop,
  557. bottom: '0px'
  558. });
  559. $('#input_div').hide();
  560. isFinishZX = 1;
  561. myScroll.refresh();
  562. }
  563. })
  564. }
  565. function jieshu() {
  566. //判断续方状态,如果未审核,则不可以结束咨询
  567. if(prescriptionStatus > 0 && prescriptionStatus < 21){
  568. dialog({
  569. content:'续方申请未审核,不能结束咨询',
  570. okValue:'我知道了',
  571. ok: function() {
  572. return;
  573. }
  574. }).showModal();
  575. return false;
  576. }
  577. dialog({
  578. content:'结束咨询后,居民及所有医生均无法再次回复,是否确认继续结束?',
  579. okValue:'继续结束',
  580. ok: function() {
  581. sendPost("doctor/consult/finish_consult", {
  582. consult: consultCode
  583. }, null, function(res) {
  584. if(res.status == 200) {
  585. isJieshuCaozuo = true;
  586. $('.topmsg1').html("咨询求助已结束");
  587. $('#input_div').hide();
  588. isFinishZX = 1;
  589. $('#wrapper1').css({
  590. bottom: '0px'
  591. });
  592. myScroll.refresh();
  593. mui.toast("已结束该咨询");
  594. } else {
  595. mui.toast(res.msg)
  596. }
  597. });
  598. },
  599. cancelValue: '我再看看',
  600. cancel: function(){}
  601. }).showModal();
  602. }
  603. window.addEventListener('getMember', function(e) {
  604. if(e.detail.group2)
  605. consultInfo.group2 = e.detail.group2;
  606. });
  607. function getStatusName(status){
  608. var name = "",
  609. img = "";
  610. status = status + '';
  611. switch (status){
  612. case '-5':
  613. name = '线下取消';
  614. break;
  615. case '-4':
  616. name = '线下退费';
  617. break;
  618. case '-3':
  619. name = '支付过期';
  620. break;
  621. case '-2':
  622. name = '患者取消';
  623. break;
  624. case '-1':
  625. name = '审核不通过';
  626. break;
  627. case '0':
  628. case '2':
  629. case '3':
  630. case '4':
  631. case '10':
  632. name = '审核中';
  633. break;
  634. case '20':
  635. name = '药师审核中';
  636. break;
  637. case '21':
  638. name = '药师审核失败';
  639. break;
  640. case '30':
  641. name = '开方中';
  642. break;
  643. case '31':
  644. name = '开方失败';
  645. break;
  646. case '40':
  647. name = '待支付';
  648. break;
  649. case '41':
  650. name = '支付失败';
  651. break;
  652. case '50':
  653. name = '配药中';
  654. break;
  655. case '60':
  656. name = '等待领药';
  657. break;
  658. case '61':
  659. case '62':
  660. case '65':
  661. case '69':
  662. name = '配送中';
  663. break;
  664. case '100':
  665. name = '已完成';
  666. break;
  667. default:
  668. break;
  669. }
  670. return name;
  671. }
  672. window.addEventListener("refreshPage", function() {
  673. getPrescriptionInfo();
  674. });