var lastId = 0; var prevImage, offTop = 151, offBot = 0; var patientInfo, patiCode, consultCode, prescriptionCode, //续方的code prescriptionStatus, //续方的状态 isFinishZX,//咨询的状态 jwCode; //基卫那边存储的原处方的code var isJieshuCaozuo = false; var prescriptionMsg,followObj; var self; mui.plusReady(function() { self = plus.webview.currentWebview(); $('#title').html(self.otherName); //通过sessionId来获取prescriptionCode和patiCode //续方咨询的sessionId 格式 居民code+咨询code+咨询类型( 8 ) var sessionId = self.sessionId; patiCode = sessionId.split("_")[0]; consultCode = sessionId.split("_")[1]; //初始化个人信息 + 初始化scroller getMineInfo(); //创建session // createSession(self.type, getMembersExt); //获得会话信息 initPage(); //获得续方信息 getPrescriptionInfo(); //获得患者的服务类型 getPatientServiceType(); prevImage = mui.previewImage(); getPatientInfo(); //判断患者是否绑定设备 getPatientDeviceList(); //快捷方式 quickReply() bindEvent(); //返回 var opener = self.opener(); if(opener && (opener.id == "xufangzixunxiangqing")) { var zxxq = plus.webview.getWebviewById("xufangzixunxiangqing"); zxxq.close('none'); backToZdzx(); }else if(opener && (opener.id =="jumingim")){ backToJMim(); }else if(opener && (opener.id == "fzxz-jumingim")){ backToJMim(); } }) function backToZdzx() { var old_back = mui.back; mui.back = function() { var wv = plus.webview.getWebviewById("xufangzixun");//续方咨询列表页 if(wv) { mui.fire(wv, "refreshPage"); } old_back(); } } //刷新消息的居民im页面 function backToJMim() { var old_back = mui.back; mui.back = function() { var wv = plus.webview.getWebviewById("jumingim");//续方咨询列表页 if(wv) { mui.fire(wv, "update"); } var wv1 = plus.webview.getWebviewById("fzxz-jumingim");//非咨询 if(wv1) { mui.fire(wv1, "xiaoxiUpdate"); } old_back(); } } /** * 获得咨询成员信息 */ function getMembersExt() { getMembers(); } /** * 获得续方的内容 */ function getPrescriptionInfo(){ var url = "/doctor/consult/prescriptionDetail", params = {consult: consultCode,}; sendGet(url, params, null, function(res){ if(res.status == 200){ prescriptionMsg = res.data; followObj = prescriptionMsg.followup=="null"?'':JSON.parse(prescriptionMsg.followup); jwCode = res.data.jwCode; prescriptionCode = res.data.code; $("#preDTName").text(res.data.symptoms+"-续方咨询"); var status = res.data.status; prescriptionStatus = status; var statusName = getStatusName(status); $("#xfStatus").text(statusName); var drugmsg=''; for(j=0; j'+data[i].content+'' } html +='
  • + 更多快捷回复
  • ' $(".xf-res-list").empty().append(html) } }) } //获得患者的服务类型 function getPatientServiceType(){ var url = 'doctor/sign/getPatientFamilyServer', params = {patient: patiCode}; sendGet(url, params, null, function(res){ if(res.status == 200){ //slowDiseasePatient: 0 //0表示没有慢病服务类型,1表示有 if(res.data.slowDiseasePatient == 0){ $("#diseaseTips").html("此居民未被标注【慢病】相关标签,是否确认核实?点击核实"); }else{ var disease = ""; for(var i=0; i0){ disease += ','+item.name; }else{ disease += item.name; } } $("#diseaseTips").text("该居民为"+disease+"患者"); } }else{ mui.toast('获得患者服务类型失败'); } }, true); } /** * 初始化页面 */ function initPage() { var url = 'doctor/consult/getConsultStatus', params = {consult: consultCode}; sendPost(url, params, null,function(res){ if(res.status == 200) { //咨询状态(0进行中,1已完成,-1患者取消,-2超时未响应自动关闭) if(res.data == 0) { //咨询未结束 $('.topmsg1').html('审核完成24小时后,将自动结束咨询立即结束'); $('#wrapper1').css({'bottom': '52px', 'top': '187px'}); offBot = 52; $('#input_div').show(); isFinishZX = 0; if(myScroll) myScroll.refresh(); } else { //咨询已结束 $('#wrapper1').css({ top: '175px', bottom: '0px' }); $('#input_div').hide(); isFinishZX = 1; } //获得咨询信息 // getFirstMsgs(); //创建session createSession(self.type, getMembersExt); } else { mui.toast("获取信息失败"); } }, 'get') } //判断object是否为空 function isEmptyObject(e) { var t; for(t in e) return !1; return !0 } //获得患者信息 function getPatientInfo(){ var url = 'doctor/patient_label_info/patient', params = {patient: patiCode}; sendPost(url, params, null, function(res){ if(res.status == 200){ patientInfo = res.data; }else{ mui.toast(res.msg); } }, 'POST', '', true) } //获得患者的绑定的设备信息 function getPatientDeviceList(){ var url = "doctor/device/PatientDeviceList", params = {patient: patiCode, page:1, pagesize: 2}; sendGet(url, params, null, function(res){ if(res.status == 200){ if(res.data.length == 0){ //没有绑定设备 $(".tzjl").hide(); }else{ //绑定了设备 $(".tzjl").show(); } }else{ //获取设备信息失败 } }, true); } //跳转去患者信息页面 function goToPatient(){ mui.openWindow('../../huanzhe/html/huanzhexinxi.html', 'huanzhexinxi.html', { extras: { patiCode: patiCode } }); } function bindEvent(){ /** * 点击查看好友详细信息 */ $('#qun_detail').on("tap", function() { mui.openWindow('../../huanzhe/html/huanzhexinxi.html', 'huanzhexinxi.html', { extras: { patiCode: patiCode } }); }) //顶部内容的展开和收缩 $("#expandBox").on('click', function(e){ e.stopPropagation(); var $this = $(this); if($this.hasClass('expand')){ $this.removeClass('expand'); $this.find('img').attr('src', '../images/zhankai_icon.png'); $("#prescriptionInfo").hide(); var top = $(".top-panel").height()+15; $("#wrapper1").css({ "top" : top+'px' }); }else{ $this.addClass('expand'); $this.find('img').attr('src', '../images/shouqi_icon.png'); $("#prescriptionInfo").show(); var top = $(".top-panel").height()+15; $("#wrapper1").css({ "top" : top+'px' }); } }); //体征记录 $(".tzjl").on('click', function(){ mui.openWindow('../../jkjl/html/health-record.html', 'health-record', { extras: { patientCode: patiCode, patientName: patientInfo.name, qyRelation: 1 } }); }); //检查检验 $(".jcjy").on('click', function(){ openWebview("../../huanzhe/html/jianchajianyan.html",{ patiInfo: { code: patiCode } }); }); //诊断处方 $(".zdcf").on('click', function(){ openWebview("../../prescription/html/chufangxiangqing.html",{ code: jwCode, patient:patiCode }); }); //历史续方 $(".lsxf").on('click', function(){ openWebview('../../prescription/html/juminxufangjilu.html', { teamCode: patientInfo.jtAdminTeam, patiCode: patiCode, patiName: patientInfo.name }); }); $("#prescriptionInfo").on("click", function(){ openWebview('../../prescription/html/xufangxiangqing.html',{ prescriptionCode: prescriptionCode, teamCode: patientInfo.jtAdminTeam }); }); //跳转去续方详情页面 $("body").on('tap', ".view-detail", function(){ openWebview('../../prescription/html/xufangxiangqing.html',{ prescriptionCode: prescriptionCode, teamCode: patientInfo.jtAdminTeam }); }) //随访调查 $("body").on('tap', ".viewData", function(){ var type = $(this).attr('data-type') mui.openWindow('questionaires.html', 'questionaires', { extras: { pro_id:type, prescriptionCode: prescriptionCode, followupid:followObj.id } }) }) //登记随访 function registerSuifang(){ var followClass; if(prescriptionMsg.symptoms == "高血压"){ followClass = 1; }else if(prescriptionMsg.symptoms == "糖尿病"){ followClass = 2; }else{ followClass = '1,2'; } mui.openWindow('../../suifang/html/follow_way.html', 'xf_follow_way', { extras: { followup_id:followObj.id, followClass:followClass, patientInfo:patientInfo, prescriptionCode: prescriptionCode, prescriptionStatus:prescriptionMsg.status } }) } $(".suifang").on('click', function(){ if(! followObj){ registerSuifang() }else{ if(followObj.status == 2){ registerSuifang() }else{ mui.openWindow('../../suifang/html/fvDetail.html', 'xf_fvDetail', { extras: { followup_id:followObj.id, prescriptionCode:prescriptionCode } }) } } }) $(".wenjuan").on('click', function(){ mui.openWindow('wenjuan.html', 'wenjuan', { extras: { prescriptionCode: prescriptionCode, followup_id:followObj.id, zx_Status:isFinishZX } }) }) $("body").on('tap', ".fillData", function(){ if(! followObj){ mui.toast('随访已不存在') return }else{ var type = $(this).attr('data-type'); var healthindexid = $(this).attr('data-health'); var url; if(type == 1){ url="doctor/prescription/followupcontent/importbloodpressure" }else{ url="doctor/prescription/followupcontent/importbloodsugar" } plus.nativeUI.showWaiting(); sendPost(url,{followupid:followObj.id,prescriptioncode:prescriptionCode,healthindexid:healthindexid},function(){ plus.nativeUI.closeWaiting(); mui.toast('请求失败') }, function(res){ plus.nativeUI.closeWaiting(); if(res.status == 200){ mui.toast('成功填入随访记录') }else{ mui.toast(res.msg) } }) } }) $(".follow").click(function(e){ e.stopPropagation(); if(! followObj){ mui.toast('随访已不存在') return }else{ plus.nativeUI.showWaiting(); sendPost('doctor/prescription/followupcontent/importdrugs',{followupid:followObj.id,prescriptioncode:prescriptionCode},function(){ plus.nativeUI.closeWaiting(); mui.toast('请求失败') }, function(res){ plus.nativeUI.closeWaiting(); if(res.status == 200){ mui.toast('成功填入随访记录') }else{ mui.toast(res.msg) } }) } }) //头部导航 mui('#nav').scroll({ deceleration: 0.0005, scrollY: false, //是否竖向滚动 scrollX: true, //是否横向滚动 indicators: false }) //快捷方式 $('.tw-change').on('click',function(){ $ipt_content.blur(); $(".tw-add-detail").hide(); $('.xf-res-list').toggle(200) }) $('.xf-res-list').on('click','.kj-li',function(){ var $this = $(this) var type = $this.attr('data-id') doQuickAnswer(type,$this.text().trim()) $('.xf-res-list').hide() }) $('.xf-res-list').on('click','#kjhf',function(){ $('.xf-res-list').hide() mui.openWindow('../../kjhf/html/list.html', 'xf-kjhf', { extras: { type:'xufang' } }) }) } //处理快捷方式 function doQuickAnswer(type,text){ if(type==0){ $(".tw-add-detail").hide(); $(".xf-res-list").hide(); $("#input_content").show(); var content = text; ui.boxMsgSound.style.display = 'none'; $(".yy-add").find('img:eq(0)').show().next().hide(); $("#input_content").text(content); showSendBtn(true); } if(! followObj){ mui.toast('随访已不存在') return } if(type == 3 || type == 4){ var params = { followupid:followObj.id, prescriptionCode:prescriptionCode, type:type==3?2:1 } plus.nativeUI.showWaiting() sendPost('doctor/consult/addPrescriptionBloodStatusConsult',params,null,function(res){ plus.nativeUI.closeWaiting() if(res.status == 200){ }else{ mui.toast('获取数据失败') } }) } if(type == 1 || type == 2){ var kind = type==1?2:1; var name,time; sendGet('doctor/prescription/followupcontent/list',{prescriptioncode:prescriptionCode},null, function(res){ if(res.status == 200){ var obj = _.find(res.data, function(o){ return o.type ==kind}) time = obj.createtime name = patientInfo.name if(obj.statue == "2"){ var params = { followupid:followObj.id, prescriptionCode:prescriptionCode, type:kind } plus.nativeUI.showWaiting() sendPost('doctor/consult/addPrescriptionFollowupContentConsult',params,null,function(res){ plus.nativeUI.closeWaiting() if(res.status == 200){ }else{ mui.toast('获取数据失败') } }) }else{ dialog({ content:'
    居民'+name+'已在'+time+'填写'+obj.name+'
    ', okValue:'查看问卷', ok: function() { mui.openWindow('questionaires.html', 'questionaires', { extras: { pro_id:kind, prescriptionCode:prescriptionCode, followupid:followObj.id } }) } }).showModal(); } } }) } } /** * 获取聊天图片列表 */ function getImgMsgList(handle) { im.getPrivateMsg(getUserId(), otherCode, lastId, pageSize, function(data) { console.log("imgs:" + JSON.stringify(data)); chatCache.imgs = data.records.reverse(); appendPrevImgs(chatCache.imgs); if(handle) handle(data); }, 2); } /** * 发送消息 */ function uploadMsg(type, content, locSrc, isNotSend, callBack) { service.isConsultFinished(consultCode, function(res) { if(res.data == 0) { //作用: 更新咨询状态 uploadMsgBase(type, content, locSrc, isNotSend, callBack); } else if(res == "timeout" && type == 1) { var tim = new Date().getTime(); var id = "loc" + tim; var d = [{ "sender_id": docInfo.code, "sender_name": docInfo.name, "content_type": 1, "content": content, "timestamp": tim, "id": id, local_src: "", beforeSend: true }]; showMsg(d, false, false, true); addMsgToCache(d, true); $('#contain dl[data-code="' + id + '"]').find('.c-msg').prepend(""); } else { $('.topmsg1').hide(); $('#wrapper1').css({ top: offTop, bottom: '0px' }); $('#input_div').hide(); isFinishZX = 1; myScroll.refresh(); } }) } function jieshu() { //判断续方状态,如果未审核,则不可以结束咨询 if(prescriptionStatus > 0 && prescriptionStatus < 21){ dialog({ content:'续方申请未审核,不能结束咨询', okValue:'我知道了', ok: function() { return; } }).showModal(); return false; } dialog({ content:'结束咨询后,居民及所有医生均无法再次回复,是否确认继续结束?', okValue:'继续结束', ok: function() { sendPost("doctor/consult/finish_consult", { consult: consultCode }, null, function(res) { if(res.status == 200) { isJieshuCaozuo = true; $('.topmsg1').html("咨询求助已结束"); $('#input_div').hide(); isFinishZX = 1; $('#wrapper1').css({ bottom: '0px' }); myScroll.refresh(); mui.toast("已结束该咨询"); } else { mui.toast(res.msg) } }); }, cancelValue: '我再看看', cancel: function(){} }).showModal(); } window.addEventListener('getMember', function(e) { if(e.detail.group2) consultInfo.group2 = e.detail.group2; }); function getStatusName(status){ var name = "", img = ""; status = status + ''; switch (status){ case '-5': name = '线下取消'; break; case '-4': name = '线下退费'; break; case '-3': name = '支付过期'; break; case '-2': name = '患者取消'; break; case '-1': name = '审核不通过'; break; case '0': case '2': case '3': case '4': case '10': name = '审核中'; break; case '20': name = '药师审核中'; break; case '21': name = '药师审核失败'; break; case '30': name = '开方中'; break; case '31': name = '开方失败'; break; case '40': name = '待支付'; break; case '41': name = '支付失败'; break; case '50': name = '配药中'; break; case '60': name = '等待领药'; break; case '61': case '62': case '65': case '69': name = '配送中'; break; case '100': name = '已完成'; break; default: break; } return name; } window.addEventListener("refreshPage", function() { getPrescriptionInfo(); });