var self; //当前页面对象 var patiCode; //居民标识 var currDays = 7; //默认日期类型 var indexType = "1"; //指标类型 var currIndexCode = "" //当前要显示的指标类型 var docType=""//医生类别 var signType = ""; var oPatiInfo =null; var iscroller = null; var doctorCode = null; var qyRelation; var overdue; //判断患者与医生的签约状态是否已过期 var currService; var jtServerCode=[];//服务类型名称 var jtAdminTeamId; // 标记患者的签约团队id var isDebug=true;//开放点击函数直接改为false Function.prototype.isdebug=function(callback){ if(isDebug) return mui.toast("功能开发中,敬请期待"); if(callback) callback(); this.call(this.constructor); } function getNowDate() { var date = new Date(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var currentdate = date.getFullYear() + "-" + month + "-" + strDate; return currentdate; } var date_end = getNowDate(); function getDateBefore(days){//获取多少天前的日期 var now = new Date(); var date = new Date(now.getTime() - days * 24 * 3600 * 1000); var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); var hour = date.getHours(); var minute = date.getMinutes(); var second = date.getSeconds(); return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day); }; var date_begin = getDateBefore(6); mui.plusReady(function() { self = plus.webview.currentWebview(); patiCode = self.patiCode || '915cc456-5b1d-11e6-8344-fa163e8aee56'; doctorCode = JSON.parse(plus.storage.getItem("docInfo")).code; overdue = self.overdue; var docType = plus.storage.getItem("docType"); if(docType!=3){//健康医生不查看家庭成员 $(".jtcyli").show() } $("#pati_info").attr("code",patiCode); localStorage.removeItem('updateService'); getPatiInfo(); initScroller(); }); mui.back = function(){ // self.opener().reload(true); //如果父窗口为im, 更新im if(self.opener().id=='p2dzixun'){ mui.fire(self.opener(), 'update'); } self.close(); } //获取病人信息 function getPatiInfo(){ sendPost("/doctor/patient_label_info/patient", {patient: patiCode}, null, function(res){ if(res.status == 200){ oPatiInfo = res.data; oPatiInfo.signType = 0; jtAdminTeamId = res.data.jtAdminTeam; //判断居民类型 如果是慢病病人 则续方管理模块出现否则隐藏 for(var i in oPatiInfo.serverTypes){ if(oPatiInfo.serverTypes[i].server_type==4||oPatiInfo.serverTypes[i].server_type==5){ $("#mbda").show(); } } //判断居民是否为女性 则产检模块出现否则隐藏 if(oPatiInfo.sex == 2){ $("#fybj").show(); } if(oPatiInfo.ssDoctor==doctorCode || oPatiInfo.ssDoctorHealth==doctorCode){ oPatiInfo.signType = 1; } if(oPatiInfo.jtDoctor==doctorCode || oPatiInfo.jtDoctorHealth==doctorCode){ oPatiInfo.signType = oPatiInfo.signType == 1 ? 3 : 2; oPatiInfo.expensesStatus1 = oPatiInfo.expensesStatus; } //服务类型 if(oPatiInfo.serverTypes){ $.map(oPatiInfo.serverTypes,function(item,index){ jtServerCode.push(item.server_type) }) } bindEvents(); dealPatiInfoTmpl(oPatiInfo); $(".div-dianhua").attr("data-mobile",oPatiInfo.mobile).attr("data-phone",oPatiInfo.phone); } else { mui.toast("获取病人信息失败"); } },'POST','',true); } function sendWeixinRemind() { sendPost("doctor/family_contract/wechat_focus_remind", {patient: patiCode,isAll:0}, null, function(res){ if(res.status == 200){ oPatiInfo.wechatFocusRemind = 1; showRemindBtn(true); } else { oPatiInfo.wechatFocusRemind = 1; showRemindBtn(true); mui.toast(res.msg); } },'POST','',true); } function showRemindBtn(isReminded) { var $remind = $("#remind_gz"); $remind.show(); if(isReminded) { $remind.addClass("ytx"); $remind.find("a").text("已提醒关注"); } else { $remind.removeClass("ytx"); $remind.find("a").text("提醒关注微信"); } } function checkWeixinRemind(data) { return new Promise(function(resolve, reject) { sendPost("doctor/family_contract/is_patient_remind_focus", {patient: patiCode}, null, function(res){ if(res.status == 200){ if(res.data==0) { // 0: 当日未提醒 isWeiXinRemind(data); } } else { mui.toast(res.msg); } },'POST','',true) }); } function isWeiXinRemind (data) { if(data) { var isReminded = data.wechatFocusRemind=="1"? true: false, // 签约类型: 1-->三师 2-->家庭 3-->三师 、家庭两者都有 signType = data.signType, // 缴费状态: 2-->已退费 1-->已缴费 0-->未交费 expensesStatus = data.expensesStatus, openid = data.openid; if(!openid) { // 有签约家庭医生,但未交费,则有该悬浮按钮 if((signType=="2" || signType=="3") && expensesStatus=="1") { showRemindBtn(isReminded); } // 2、如只有三师签约,但无openid,则有该悬浮按钮 else if(signType == "1") { showRemindBtn(isReminded); } } } } //查询某个患者今天是否已提醒 function isYitixing(){ sendPost("/doctor/family_contract/is_patient_remind_expenses",{patient:patiCode},null,function(res){ if(res.status==200){ if(res.data==1){//data为1已提醒 为0未提醒 $("#remindPay").addClass("ytx"); //则显示“已提醒缴费" $("#remindPay a").text("已提醒缴费"); }else{ $("#remindPay").removeClass("ytx"); $("#remindPay a").text("提醒缴费"); } } }) } //缴费提醒 function jiaofeitixing(){ sendPost("/doctor/family_contract/expenses_remind",{patient:patiCode,isAll:"0"},null,function(res){ mui.toast(res.msg); if(res.status==200){ isYitixing();//查询某个患者今天是否已提醒 } }) } //提醒缴费 $("#remindPay").on("tap",function(){ mui("#sheet1").popover('toggle'); if($(this).hasClass("ytx")){//今日已提醒 mui.toast("居民今天已经收到过缴费提醒了哦,不可再次提醒"); }else{//今日未提醒,则缴费提醒 jiaofeitixing(); } }) /*提醒续签*/ function sendRenewRemind(){ var url = "/doctor/sign/remindPatientRenew", params = {patient: oPatiInfo.code}; sendPost(url, params, null, function(res){ if(res.status == 200){ if(res.data == 1 || res.data == 2){ $("#remindXQ").find("a").text("已提醒续签"); $("#remindXQ").addClass("ytx"); } mui.toast(res.msg); }else{ mui.toast(res.msg) } }, "post", "", true); } ////获取服务类型 function getServiceDropdown(){ sendPost("/doctor/sign/getSigndict",{}, null, function(res){ if(res.status == 200){ fillServiceDropdown(res); }else{ mui.toast(res.msg) } }, "get", "", true); } //普通 老年 高血 糖尿 孕妇 儿童 贫困 计生 重性 残疾 结核 function filterSer(name){ var $li = $('.dw-bf').find('div.dw-li'); $li.addClass('dw-v'); var nameArr = name.split(','); $.map(nameArr,function(item,index){ if(item.trim() == '普通人群'){ var arr = [2,3,6,7,8,9,10] $.map(arr,function(it,index){ $li.eq(it).removeClass('dw-v') }) } if(item.trim() == '老年人'){ var arr = [4,5] $.map(arr,function(it,index){ $li.eq(it).removeClass('dw-v') }) } if(item.trim() == '高血压' ||item.trim() == '糖尿病'||item.trim() == '贫困人口'||item.trim() == '计生特殊人群'||item.trim() == '重性精神疾病'||item.trim() == '残疾人'||item.trim() == '结核病' ){ var arr = [0] $.map(arr,function(it,index){ $li.eq(it).removeClass('dw-v') }) } if(item.trim() == '0-6岁儿童'){ var arr = [1,4] $.map(arr,function(it,index){ $li.eq(it).removeClass('dw-v') }) } if(item.trim() == '孕产妇'){ var arr = [1,5] $.map(arr,function(it,index){ $li.eq(it).removeClass('dw-v') }) } }) } ////设置服务类型下拉 function fillServiceDropdown(data){ var $serviceSel = $('#selFuwu'), data = data.data, has = false, saveOldData ='', html=""; for(i=0; i'+data[i].name+''; has = true; } } if(!has){ html += '' } } $serviceSel.html(html); $serviceSel.mobiscroll().select({ theme: 'ios', lang: 'zh', display: 'bottom', rows:6, placeholder: '请选择服务类型', onSelect: function ( valueText, inst) { if(valueText != saveOldData){ currService = inst._tempValue?inst._tempValue.join(','):''; localStorage.setItem('updateService',currService); $('#smallTipSev').show(); $("#diseases").html("无"); } }, onChange: function (event, inst){ filterSer(event) }, onShow: function (event, inst) { saveOldData = inst; filterSer(inst) } }) } // 滚动条实例初始化 function initScroller() { //阻尼系数 var deceleration = mui.os.ios?0.003:0.0009; mui('.mui-scroll-wrapper').scroll({ bounce: false, indicators: true, //是否显示滚动条 deceleration:deceleration }); iscroller = mui(".mui-scroll").pullToRefresh({ down: { callback: function() { var self = this; setTimeout(function() { refreshPage(); self.endPullDownToRefresh(); }, 1000); } } }); } /* * 拼接居民信息模板 */ function dealPatiInfoTmpl(patiInfoObj) { signType = patiInfoObj.signType; $("#pati_info_wrap").html(template("pati_info_tmpl", patiInfoObj)); $('#view_wrap').show(); initPatientData(3); getServiceDropdown(); } /* * 获取患者续签状态 */ function getPatientRenewInfo(patiInfo){ var url = "/doctor/sign/checkCanRenew", params = {patient: patiInfo.code}; sendGet(url, params, null, function(res){ if(res.status == 200){ var state = res.data.code; if(state != "1" && state != "2"){ oPatiInfo.isRenewable = 0; }else{ oPatiInfo.isRenewable = 1; } //增加判断说是否显示右上角”更多”的图片 if(oPatiInfo.expensesStatus == "1" && oPatiInfo.openid && !oPatiInfo.isRenewable){ $(".header-link").hide(); }else{ $(".header-link").show(); isWeiXinRemind(oPatiInfo); if(oPatiInfo && oPatiInfo.expensesStatus!=1 && oPatiInfo.expensesStatus!=2){ if(oPatiInfo.signType!=1) { $("#remindPay").show(); isYitixing();//查询某个患者今天是否已提醒 } } if(oPatiInfo.isRenewable){ $("#remindXQ").show(); if(oPatiInfo.isRemindRenew == "1"){ $("#remindXQ").find("a").text("已提醒续签"); $("#remindXQ").addClass("ytx"); } } } }else{ mui.toast(res.msg); } }, true); } /* * 查看居民资料 */ function toInfo() { var $el = $(this); mui.openWindow("denizen-info.html", "denizen-info", { extras: { patiPhoto: $el.find('.doc-avatar img').attr('src'), patiCode: patiCode, signType: signType, teamCode: self.teamCode, //添加续签状态值 qyRelation: qyRelation, renewable: oPatiInfo.isRenewable } }) } function openwdsb(){ // var params={}; // params.patient = patiCode; // openWebviewExtras("../../wdsb/html/my-equipments.html",params); mui.openWindow('../../jkjl/html/health-record.html', 'health-record', { extras: { patientCode: patiCode, patientName: oPatiInfo.name, qyRelation: qyRelation } }) } /* * 服务记录 */ function fwjl() { mui.openWindow('fuwujilu.html', 'fuwujilu', { extras: { patientCode: patiCode, patientName: oPatiInfo.name, qyRelation: qyRelation } }); } /* * 健康指导 */ function jkzd() { // diaAdd.close(); mui.openWindow('../../hzzd/html/guidance_list.html', 'jkzd', { extras: { code: patiCode } }); } /* * 体征预警 */ function tzyj() { // diaAdd.close(); mui.openWindow('tzyj.html', 'tzyj', { extras: { code: patiCode } }); } /* * 健康记录点击事件 */ /* * 药物记录 */ function ywjl(dom) { var text = $(dom).find("p").eq(0).text(); if(text == "-") { mui.toast("暂无健康记录"); return; } mui.openWindow('../../hzgl/html/health-record-drug.html', 'health-record-drug', { extras: { pCode: patiCode } }); } /* * 饮食记录 */ function ysjl(dom) { var text = $(dom).find("p").eq(0).text(); if(text == "-") { mui.toast("暂无健康记录"); return; } mui.openWindow('../../hzgl/html/health-record-diet.html', 'health-record-diet', { extras: { pCode: patiCode } }); } /* * 运动记录 */ function ydjl(dom) { var text = $(dom).find("p").eq(0).text(); if(text == "-") { mui.toast("暂无健康记录"); return; } mui.openWindow('../../hzgl/html/health-record-sport.html', 'health-record-sport', { extras: { pCode: patiCode } }); } /* * 分组 */ function fz() { mui.openWindow('../../zxyy/html/xuanzeyiyuan.html', 'xuanzeyiyuan', { extras: { pCode: patiCode } }); } function toSelectJb(){ var self = plus.webview.currentWebview(); var update = localStorage.getItem('updateService'); var oldData = jtServerCode.join(','); mui.openWindow({ url: 'disease-label-edit.html', id: 'disease-label-edit', extras: { patientCode: patiCode, viewId: self.id, signCode:oPatiInfo.signCode,//变更服务类型用 serviceCode: update?update:oldData, isChange:$("#smallTipSev").is(":hidden")?false:true//判断是否处于变更 } }); } var labelName =[]; function initPatientData(){ sendPost("doctor/family_contract/doctor_patient_sign_exist", {doctor: doctorCode, patient: patiCode}, null, function(res){ if(res.status==200){ if(res.data.status==-1 || res.data.status==0){ qyRelation = 0; //没有签约关系 //判断医生是否是该患者所在的团队的团队长 var teamInfo = JSON.parse(plus.storage.getItem('teamInfo')), isTeamLeader = false; for(var i=0; i0){ $("#diseases").html(_.uniq(labelName).join(",")); }else{ $("#diseases").html("无"); } }else{ queryFailed(res); } }); } function queryFailed(res){ if(res.msg){ if (res.msg != '查询失败') { mui.toast(res.msg); } }else{ mui.toast("标签加载失败!"); } } function loadRecentEvents() { template.helper("toJson", function(v, i) { return JSON.stringify(v); }); // strSSID: "B09036263193" getReqPromise(healthProfileServer+"wlyy_service/record/outpatient",{ strSSID: oPatiInfo.ssc, startNum: 0, endNum: 50 },'GET',true).then(function(res){ if(res.status == 200) { var list = JSON.parse(res.data); if(list && list.length) { $('#no_result_wrap').hide(); $('#recent_events').show(); $('#recent_events').append(template('recent_event_tmpl',{list: list.slice(0,4)})); $('#more_event').show(); iscroller.refresh(); } else { $('#recent_events').hide(); $('#more_event').hide(); $('#no_result_wrap').show(); } } else { mui.toast(res.msg); } }).catch(function(e) { console && console.error(e)}); } $('#more_event').on('tap',function() { openWebview("jiuzhenjilu.html",{patiInfo: oPatiInfo}) }.isdebug); $('.fix-adds').on('tap', function() { $(".div-dialog-content").show(); $(".modal-overlay").addClass("modal-overlay-visible"); }.isdebug); $('.div-dialog-content').on('tap',"div", function() { if(!$(this).hasClass("quxiao")){ hideBing(); if($(this).hasClass("addjkzd")){//健康指导 jkzd(); }else if($(this).hasClass("addfzgl")){//分组管理 fz(); }else if($(this).hasClass("addtzyj")){//体征预警 tzyj(); }else if($(this).hasClass("addtzsb")){//体征设备 openwdsb(); }else if($(this).hasClass("addjtcy")){//家庭成员 jtcy(); } }else if($(this).hasClass("quxiao")){//取消 $('.fix-adds').show(); $(".div-dialog-content").hide(); $(".modal-overlay").removeClass("modal-overlay-visible"); } }.isdebug); function hideBing(){ $('.fix-adds').show(); $(".div-dialog-content").hide(); $(".modal-overlay").removeClass("modal-overlay-visible"); } $(".modal-overlay").on('tap', function() { hideBing(); }.isdebug); $('#recent_events').on('tap','li',function() { var data = JSON.parse($(this).attr("data-json")); openWebview("health-profile.html",{eventInfo: data,patiInfo: oPatiInfo}); }.isdebug); /* * 家庭成员 */ function jtcy() { mui.openWindow('jiatingchengyuan.html', 'jiatingchengyuan', { extras: { code: patiCode, patiInfo: oPatiInfo, qyRelation: qyRelation } }); } /* * 咨询记录 */ function zxjl() { mui.openWindow('zixunjilu.html', 'zixunjilu', { extras: { code: patiCode, qyRelation: qyRelation } }); } /* * 指导记录 */ function zdjl() { mui.openWindow('zhidaojilu.html', 'zhidaojilu', { extras: { code: patiCode, qyRelation: qyRelation } }); } /* * 代预约记录 */ function dyyjl(){ mui.openWindow('../../wdyy/html/my-appointment.html', 'my-appointment', { extras: { patient: patiCode, qyRelation: qyRelation } }); } /* * 代预约 */ function dyy() { mui.openWindow('../../wdyy/html/appointment-register.html', 'appointment-register', { extras: { patient: patiCode } }); } /* * 康复管理 */ function kfgl(){ console.log("aaa"); mui.toast("功能开发中,敬请期待"); } //拨打电话 $(".div-dianhua").on("tap",function(){ var moblie = $(this).attr("data-mobile"); var phone = $(this).attr("data-phone"); //观察者模式下,不可以拨打被观察者患者的电话 var userAgent = plus.navigator.getUserAgent(), index = userAgent.indexOf("}"), s = userAgent.substr(0, index+1), item = JSON.parse(s); if(item.observer){ mui.toast("观察者模式无法拨打患者电话"); }else{ if(moblie){ dialog({ content: moblie, okValue:'立即拨号', ok: function (){ window.location.href = "tel:"+moblie; }, cancelValue: '不了,谢谢', cancel: function () { return; } }).showModal(); }else{ if(phone){ dialog({ content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,是否拨打联系人电话?", okValue:'立即拨号', ok: function (){ window.location.href = "tel:"+phone; }, cancelValue: '不了,谢谢', cancel: function () { return; } }).showModal(); }else{ dialog({ content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,无法电话联系", okValue:'我知道了', ok: function (){ return; }, }).showModal(); } } } }) function refreshPage () { labelName =[]; jtServerCode = []; localStorage.removeItem('updateService'); getPatiInfo(); } window.addEventListener("refresh1", function(){ refreshPage(); var xxWv = plus.webview.getWebviewById("huanzhe-by-type"); // 如果有打开分组列表也要刷新列表 if(xxWv){ mui.fire(xxWv, "refresh"); } var xxindex = plus.webview.getWebviewById("huanzhe.html"); // 如果有打开分组列表也要刷新列表 if(xxindex){ mui.fire(xxindex, "refresh"); } }) window.addEventListener("setDiseaseTypes", function(e){ $('#diseases').html(e.detail.names); oPatiInfo.diseases = e.detail.diseases; }) //门诊记录 $(".div-menzhen-btn").on("tap",function(){ openWebview("menzhenjilu.html",{patiInfo: oPatiInfo}) }.isdebug) //住院记录 $(".div-zhuyuan-btn").on("tap",function(){ openWebview("zhuyuanjilu.html",{patiInfo: oPatiInfo}) }.isdebug) //检查检验记录 $(".div-jianche-btn").on("tap",function(){ openWebview("jianchajianyan.html",{patiInfo: oPatiInfo}) }.isdebug) //用药记录 $(".div-yongyao-btn").on("tap",function(){ openWebview("yongyaojilu.html",{patiInfo: oPatiInfo}) }.isdebug) //健康体检 $(".div-jiankangtijian-btn").on("tap",function(){ openWebview("jiankangtijian.html",{patiInfo: JSON.parse(self.patiInfo)}) }.isdebug) /* * 健康教育 */ function jkjy() { // mui.openWindow('../../jkjy/html/jiankangjiaoyu.html', 'jiankangjiaoyu', { mui.openWindow('../../jkjy/html/article-store.html', 'jiankangjiaoyu', { extras: { patient: patiCode, patientName: oPatiInfo.name, teamCode: jtAdminTeamId } }); } function xfjl() { mui.openWindow('../../prescription/html/juminxufangjilu.html', 'juminxufangjilu', { extras: { teamCode:oPatiInfo.jtAdminTeam, patiCode: patiCode, patiName: oPatiInfo.name } }) } function fybj() { mui.openWindow('../../fybj/html/yunjianjihua.html', 'yunjianjihua', { extras: { patiCode: patiCode, doctorCode:doctorCode } }) } function myjl() { mui.openWindow('../../fybj/html/mianyijihua.html', 'mianyijihua', { extras: { patiCode: patiCode } }) } /* 事件绑定*/ function bindEvents(){ //服务记录 $("#fwjl,#gxb,#jmbq").on('tap', fwjl.isdebug); //健康记录 $("#tzsb").on('tap', openwdsb.isdebug); //康复管理 $("#kfbg").on('tap', kfgl.isdebug); //家庭成员 $("#family").on('tap', jtcy.isdebug); //提醒关注 $("#remind_gz").on('tap', function(){ mui("#sheet1").popover('toggle'); if($(this).hasClass("ytx")){//今日已提醒 mui.toast("居民今天已经收到过提醒了哦,不可再次提醒"); }else{//今日未提醒 sendWeixinRemind(); } }.isdebug); //健康指导 $("#jkzd").on('tap', jkzd.isdebug); //体征预警 $("#tzyj").on('tap', tzyj.isdebug); //分组 $("#fz").on('tap', fz.isdebug); //干预 $("#gy").on('tap', gy); //转慢病 // $("#zmbicon").on('tap', adddoc); //体征设备2 $("#tzsbicon").on('tap', openwdsb.isdebug); $("#pati_info_wrap").on('tap', '#pati_info', toInfo); $("#pati_info_wrap").on('tap', "#diseasesWrap", toSelectJb.isdebug); //健康教育 $(".div-jkjy-btn").on('tap', jkjy.isdebug); //代预约 $(".div-dyy-btn").on('tap', dyy.isdebug); //康复管理 $(".div-kfgl-btn").on('tap', kfgl.isdebug); //续方记录 // $(".div-xufangjilu-btn").on('tap', xfjl); //慢病管理 $(".div-manbing-btn").on('tap', function(){ openWebview("../../mbgl/html/jumin-manbingdangan.html", {patient: oPatiInfo.code}); }.isdebug) //产检计划 $('.div-fybj-btn').on('tap', fybj.isdebug) //免疫记录 $('.div-myjl-btn').on('tap', myjl.isdebug) //新增指导 $(".div-add-guide-btn").on('tap', jkzd.isdebug); //随访 $(".div-suifang-btn").on('tap',function(){ // openWebview("../../suifang/html/choose_suifang.html", {patiCode: oPatiInfo.code}); openWebview("../../suifang/html/suifang_list.html", {patientCode: oPatiInfo.code}); }.isdebug); //显示更过操作 $(".header-link").on('tap', function(){ mui('#sheet1').popover('toggle'); }); /*提醒续签*/ $("#remindXQ").on('tap', function(){ mui("#sheet1").popover('toggle'); if($(this).hasClass("ytx")){//今日已提醒 mui.toast("居民今天已经收到过提醒了哦,不可再次提醒"); }else{//今日未提醒 sendRenewRemind(); } }.isdebug); }