huanzhexinxi.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. var self; //当前页面对象
  2. var patiCode; //居民标识
  3. var currDays = 7; //默认日期类型
  4. var indexType = "1"; //指标类型
  5. var currIndexCode = "" //当前要显示的指标类型
  6. var docType=""//医生类别
  7. var signType = "";
  8. var date_begin = getDateBefore(6);
  9. var date_end = getNowDate();
  10. var oPatiInfo =null;
  11. var iscroller = null;
  12. var doctorCode = null;
  13. var qyRelation;
  14. var overdue; //判断患者与医生的签约状态是否已过期
  15. var currService;
  16. var jtServerCode=[];//服务类型名称
  17. var jtAdminTeamId; // 标记患者的签约团队id
  18. mui.plusReady(function() {
  19. self = plus.webview.currentWebview();
  20. patiCode = self.patiCode;
  21. console.log(patiCode)
  22. doctorCode = JSON.parse(plus.storage.getItem("docInfo")).code;
  23. overdue = self.overdue;
  24. $("#pati_info").attr("code",patiCode);
  25. localStorage.removeItem('updateService');
  26. getPatiInfo();
  27. initScroller();
  28. });
  29. mui.back = function(){
  30. // self.opener().reload(true);
  31. //如果父窗口为im, 更新im
  32. if(self.opener().id=='p2dzixun'){
  33. mui.fire(self.opener(), 'update');
  34. }
  35. self.close();
  36. }
  37. //获取病人信息
  38. function getPatiInfo(){
  39. sendPost("/doctor/patient_label_info/patient",
  40. {patient: patiCode}, null,
  41. function(res){
  42. if(res.status == 200){
  43. oPatiInfo = res.data;
  44. bindEvents();
  45. dealPatiInfoTmpl(oPatiInfo);
  46. $(".div-dianhua").attr("data-mobile",oPatiInfo.mobile).attr("data-phone",oPatiInfo.phone);
  47. } else {
  48. mui.toast("获取病人信息失败");
  49. }
  50. },'POST','',true);
  51. }
  52. function sendWeixinRemind() {
  53. sendPost("doctor/family_contract/wechat_focus_remind",
  54. {patient: patiCode,isAll:0}, null,
  55. function(res){
  56. if(res.status == 200){
  57. oPatiInfo.wechatFocusRemind = 1;
  58. showRemindBtn(true);
  59. } else {
  60. oPatiInfo.wechatFocusRemind = 1;
  61. showRemindBtn(true);
  62. mui.toast(res.msg);
  63. }
  64. },'POST','',true);
  65. }
  66. function showRemindBtn(isReminded) {
  67. var $remind = $("#remind_gz");
  68. $remind.show();
  69. if(isReminded) {
  70. $remind.addClass("ytx");
  71. $remind.find("a").text("已提醒关注");
  72. } else {
  73. $remind.removeClass("ytx");
  74. $remind.find("a").text("提醒关注微信");
  75. }
  76. }
  77. function checkWeixinRemind(data) {
  78. return new Promise(function(resolve, reject) {
  79. sendPost("doctor/family_contract/is_patient_remind_focus",
  80. {patient: patiCode}, null,
  81. function(res){
  82. if(res.status == 200){
  83. if(res.data==0) { // 0: 当日未提醒
  84. isWeiXinRemind(data);
  85. }
  86. } else {
  87. mui.toast(res.msg);
  88. }
  89. },'POST','',true)
  90. });
  91. }
  92. function isWeiXinRemind (data) {
  93. if(data) {
  94. var isReminded = data.wechatFocusRemind=="1"? true: false,
  95. // 签约类型: 1-->三师 2-->家庭 3-->三师 、家庭两者都有
  96. signType = data.signType,
  97. // 缴费状态: 2-->已退费 1-->已缴费 0-->未交费
  98. expensesStatus = data.expensesStatus,
  99. openid = data.openid;
  100. if(!openid) {
  101. // 有签约家庭医生,但未交费,则有该悬浮按钮
  102. if((signType=="2" || signType=="3") && expensesStatus=="1") {
  103. showRemindBtn(isReminded);
  104. }
  105. // 2、如只有三师签约,但无openid,则有该悬浮按钮
  106. else if(signType == "1") {
  107. showRemindBtn(isReminded);
  108. }
  109. }
  110. }
  111. }
  112. // 滚动条实例初始化
  113. function initScroller() {
  114. //阻尼系数
  115. var deceleration = mui.os.ios?0.003:0.0009;
  116. mui('.mui-scroll-wrapper').scroll({
  117. bounce: false,
  118. indicators: true, //是否显示滚动条
  119. deceleration:deceleration
  120. });
  121. iscroller = mui(".mui-scroll").pullToRefresh({
  122. down: {
  123. callback: function() {
  124. var self = this;
  125. setTimeout(function() {
  126. refreshPage();
  127. self.endPullDownToRefresh();
  128. }, 1000);
  129. }
  130. }
  131. });
  132. }
  133. /*
  134. * 拼接居民信息模板
  135. */
  136. function dealPatiInfoTmpl(patiInfoObj) {
  137. $("#pati_info_wrap").html(template("pati_info_tmpl", patiInfoObj));
  138. $('#view_wrap').show();
  139. }
  140. /*
  141. * 查看居民资料
  142. */
  143. function toInfo() {
  144. var $el = $(this);
  145. mui.openWindow("huanzeziliao.html", "huanzeziliao", {
  146. extras: {
  147. patiPhoto: $el.find('.doc-avatar img').attr('src'),
  148. patiCode: patiCode,
  149. signType: signType,
  150. teamCode: self.teamCode,
  151. //添加续签状态值
  152. qyRelation: qyRelation,
  153. renewable: oPatiInfo.isRenewable
  154. }
  155. })
  156. }
  157. function openwdsb(){
  158. // var params={};
  159. // params.patient = patiCode;
  160. // openWebviewExtras("../../wdsb/html/my-equipments.html",params);
  161. mui.openWindow('../../jkjl/html/health-record.html', 'health-record', {
  162. extras: {
  163. patientCode: patiCode,
  164. patientName: oPatiInfo.name,
  165. qyRelation: qyRelation
  166. }
  167. })
  168. }
  169. /*
  170. * 服务记录
  171. */
  172. function fwjl() {
  173. mui.openWindow('fuwujilu.html', 'fuwujilu', {
  174. extras: {
  175. patientCode: patiCode,
  176. patientName: oPatiInfo.name,
  177. qyRelation: qyRelation
  178. }
  179. });
  180. }
  181. /*
  182. * 健康指导
  183. */
  184. function jkzd() {
  185. // diaAdd.close();
  186. mui.openWindow('../../hzzd/html/guidance_list.html', 'jkzd', {
  187. extras: {
  188. code: patiCode
  189. }
  190. });
  191. }
  192. /*
  193. * 体征预警
  194. */
  195. function tzyj() {
  196. // diaAdd.close();
  197. mui.openWindow('tzyj.html', 'tzyj', {
  198. extras: {
  199. code: patiCode
  200. }
  201. });
  202. }
  203. /*
  204. * 健康记录点击事件
  205. */
  206. /*
  207. * 药物记录
  208. */
  209. function ywjl(dom) {
  210. var text = $(dom).find("p").eq(0).text();
  211. if(text == "-") {
  212. mui.toast("暂无健康记录");
  213. return;
  214. }
  215. mui.openWindow('../../hzgl/html/health-record-drug.html', 'health-record-drug', {
  216. extras: {
  217. pCode: patiCode
  218. }
  219. });
  220. }
  221. /*
  222. * 饮食记录
  223. */
  224. function ysjl(dom) {
  225. var text = $(dom).find("p").eq(0).text();
  226. if(text == "-") {
  227. mui.toast("暂无健康记录");
  228. return;
  229. }
  230. mui.openWindow('../../hzgl/html/health-record-diet.html', 'health-record-diet', {
  231. extras: {
  232. pCode: patiCode
  233. }
  234. });
  235. }
  236. /*
  237. * 运动记录
  238. */
  239. function ydjl(dom) {
  240. var text = $(dom).find("p").eq(0).text();
  241. if(text == "-") {
  242. mui.toast("暂无健康记录");
  243. return;
  244. }
  245. mui.openWindow('../../hzgl/html/health-record-sport.html', 'health-record-sport', {
  246. extras: {
  247. pCode: patiCode
  248. }
  249. });
  250. }
  251. /*
  252. * 分组
  253. */
  254. function fz() {
  255. mui.openWindow('../../zxyy/html/xuanzeyiyuan.html', 'xuanzeyiyuan', {
  256. extras: {
  257. pCode: patiCode
  258. }
  259. });
  260. }
  261. function toSelectJb(){
  262. var self = plus.webview.currentWebview();
  263. var update = localStorage.getItem('updateService');
  264. var oldData = jtServerCode.join(',');
  265. mui.openWindow({
  266. url: 'disease-label-edit.html',
  267. id: 'disease-label-edit',
  268. extras: {
  269. patientCode: patiCode,
  270. viewId: self.id,
  271. signCode:oPatiInfo.signCode,//变更服务类型用
  272. serviceCode: update?update:oldData,
  273. isChange:$("#smallTipSev").is(":hidden")?false:true//判断是否处于变更
  274. }
  275. });
  276. }
  277. var labelName =[];
  278. function queryFailed(res){
  279. if(res.msg){
  280. if (res.msg != '查询失败') {
  281. mui.toast(res.msg);
  282. }
  283. }else{
  284. mui.toast("标签加载失败!");
  285. }
  286. }
  287. $('#more_event').on('tap',function() {
  288. openWebview("jiuzhenjilu.html",{patiInfo: oPatiInfo})
  289. });
  290. $('.fix-adds').on('tap', function() {
  291. $(".div-dialog-content").show();
  292. $(".modal-overlay").addClass("modal-overlay-visible");
  293. });
  294. $('.div-dialog-content').on('tap',"div", function() {
  295. if(!$(this).hasClass("quxiao")){
  296. hideBing();
  297. if($(this).hasClass("addjkzd")){//健康指导
  298. jkzd();
  299. }else if($(this).hasClass("addfzgl")){//分组管理
  300. fz();
  301. }else if($(this).hasClass("addtzyj")){//体征预警
  302. tzyj();
  303. }else if($(this).hasClass("addtzsb")){//体征设备
  304. openwdsb();
  305. }else if($(this).hasClass("addjtcy")){//家庭成员
  306. jtcy();
  307. }
  308. }else if($(this).hasClass("quxiao")){//取消
  309. $('.fix-adds').show();
  310. $(".div-dialog-content").hide();
  311. $(".modal-overlay").removeClass("modal-overlay-visible");
  312. }
  313. });
  314. function hideBing(){
  315. $('.fix-adds').show();
  316. $(".div-dialog-content").hide();
  317. $(".modal-overlay").removeClass("modal-overlay-visible");
  318. }
  319. $(".modal-overlay").on('tap', function() {
  320. hideBing();
  321. });
  322. $('#recent_events').on('tap','li',function() {
  323. var data = JSON.parse($(this).attr("data-json"));
  324. openWebview("health-profile.html",{eventInfo: data,patiInfo: oPatiInfo});
  325. });
  326. /*
  327. * 家庭成员
  328. */
  329. function jtcy() {
  330. mui.openWindow('jiatingchengyuan.html', 'jiatingchengyuan', {
  331. extras: {
  332. code: patiCode,
  333. patiInfo: oPatiInfo,
  334. qyRelation: qyRelation
  335. }
  336. });
  337. }
  338. /*
  339. * 咨询记录
  340. */
  341. function zxjl() {
  342. mui.openWindow('zixunjilu.html', 'zixunjilu', {
  343. extras: {
  344. code: patiCode,
  345. qyRelation: qyRelation
  346. }
  347. });
  348. }
  349. /*
  350. * 指导记录
  351. */
  352. function zdjl() {
  353. mui.openWindow('zhidaojilu.html', 'zhidaojilu', {
  354. extras: {
  355. code: patiCode,
  356. qyRelation: qyRelation
  357. }
  358. });
  359. }
  360. /*
  361. * 代预约记录
  362. */
  363. function dyyjl(){
  364. mui.openWindow('../../wdyy/html/my-appointment.html', 'my-appointment', {
  365. extras: {
  366. patient: patiCode,
  367. qyRelation: qyRelation
  368. }
  369. });
  370. }
  371. /*
  372. * 代预约
  373. */
  374. function dyy() {
  375. mui.openWindow('../../wdyy/html/appointment-register.html', 'appointment-register', {
  376. extras: {
  377. patient: patiCode
  378. }
  379. });
  380. }
  381. //拨打电话
  382. $(".div-dianhua").on("tap",function(){
  383. var moblie = $(this).attr("data-mobile");
  384. var phone = $(this).attr("data-phone");
  385. //观察者模式下,不可以拨打被观察者患者的电话
  386. var userAgent = plus.navigator.getUserAgent(),
  387. index = userAgent.indexOf("}"),
  388. s = userAgent.substr(0, index+1),
  389. item = JSON.parse(s);
  390. if(item.observer){
  391. mui.toast("观察者模式无法拨打患者电话");
  392. }else{
  393. if(moblie){
  394. dialog({
  395. content: moblie,
  396. okValue:'立即拨号',
  397. ok: function (){
  398. window.location.href = "tel:"+moblie;
  399. },
  400. cancelValue: '不了,谢谢',
  401. cancel: function () {
  402. return;
  403. }
  404. }).showModal();
  405. }else{
  406. if(phone){
  407. dialog({
  408. content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,是否拨打联系人电话?",
  409. okValue:'立即拨号',
  410. ok: function (){
  411. window.location.href = "tel:"+phone;
  412. },
  413. cancelValue: '不了,谢谢',
  414. cancel: function () {
  415. return;
  416. }
  417. }).showModal();
  418. }else{
  419. dialog({
  420. content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,无法电话联系",
  421. okValue:'我知道了',
  422. ok: function (){
  423. return;
  424. },
  425. }).showModal();
  426. }
  427. }
  428. }
  429. })
  430. function refreshPage () {
  431. labelName =[];
  432. jtServerCode = [];
  433. localStorage.removeItem('updateService');
  434. getPatiInfo();
  435. }
  436. window.addEventListener("refresh1", function(){
  437. refreshPage();
  438. var xxWv = plus.webview.getWebviewById("huanzhe-by-type");
  439. // 如果有打开分组列表也要刷新列表
  440. if(xxWv){
  441. mui.fire(xxWv, "refresh");
  442. }
  443. var xxindex = plus.webview.getWebviewById("huanzhe.html");
  444. // 如果有打开分组列表也要刷新列表
  445. if(xxindex){
  446. mui.fire(xxindex, "refresh");
  447. }
  448. })
  449. window.addEventListener("setDiseaseTypes", function(e){
  450. $('#diseases').html(e.detail.names);
  451. oPatiInfo.diseases = e.detail.diseases;
  452. })
  453. //门诊记录
  454. $(".div-menzhen-btn").on("tap",function(){
  455. // openWebview(templateServer,{itemIndex:0,name:"就诊记录", idcard: "362321199703137824"})
  456. })
  457. //住院记录
  458. $(".div-zhuyuan-btn").on("tap",function(){
  459. // openWebview(templateServer,{itemIndex:0,name:"就诊记录", idcard: oPatiInfo.idcard})
  460. })
  461. //检查检验记录
  462. $(".div-jianche-btn").on("tap",function(){
  463. // openWebview(templateServer,{itemIndex:1,name:"检查检验", idcard: oPatiInfo.idcard})
  464. })
  465. //用药记录
  466. $(".div-yongyao-btn").on("tap",function(){
  467. // openWebview(templateServer,{itemIndex:2,name:"用药记录", idcard: oPatiInfo.idcard})
  468. })
  469. //健康体检
  470. $(".div-jiankangtijian-btn").on("tap",function(){
  471. openWebview("jiankangtijian.html",{patiInfo: oPatiInfo})
  472. })
  473. /*
  474. * 健康教育
  475. */
  476. function jkjy() {
  477. // mui.openWindow('../../jkjy/html/jiankangjiaoyu.html', 'jiankangjiaoyu', {
  478. mui.openWindow('../../jkjy/html/article-store.html', 'jiankangjiaoyu', {
  479. extras: {
  480. patient: patiCode,
  481. patientName: oPatiInfo.name,
  482. teamCode: jtAdminTeamId
  483. }
  484. });
  485. }
  486. function xfjl() {
  487. mui.openWindow('../../prescription/html/juminxufangjilu.html', 'juminxufangjilu', {
  488. extras: {
  489. teamCode:oPatiInfo.jtAdminTeam,
  490. patiCode: patiCode,
  491. patiName: oPatiInfo.name
  492. }
  493. })
  494. }
  495. function fybj() {
  496. mui.openWindow('../../fybj/html/yunjianjihua.html', 'yunjianjihua', {
  497. extras: {
  498. patiCode: patiCode,
  499. doctorCode:doctorCode
  500. }
  501. })
  502. }
  503. function myjl() {
  504. mui.openWindow('../../fybj/html/mianyijihua.html', 'mianyijihua', {
  505. extras: {
  506. patiCode: patiCode
  507. }
  508. })
  509. }
  510. /* 事件绑定*/
  511. function bindEvents(){
  512. //服务记录
  513. $("#fwjl").on('tap', fwjl);
  514. //健康记录
  515. $("#tzsb").on('tap', openwdsb);
  516. //家庭成员
  517. $("#family").on('tap', jtcy);
  518. //提醒关注
  519. $("#remind_gz").on('tap', function(){
  520. mui("#sheet1").popover('toggle');
  521. if($(this).hasClass("ytx")){//今日已提醒
  522. mui.toast("居民今天已经收到过提醒了哦,不可再次提醒");
  523. }else{//今日未提醒
  524. sendWeixinRemind();
  525. }
  526. });
  527. //健康指导
  528. $("#jkzd").on('tap', jkzd);
  529. //体征预警
  530. $("#tzyj").on('tap', tzyj);
  531. //分组
  532. $("#fz").on('tap', fz);
  533. //干预
  534. $("#gy").on('tap', gy);
  535. $("#pati_info_wrap").on('tap', '#pati_info', toInfo);
  536. $("#pati_info_wrap").on('tap', "#diseasesWrap", toSelectJb);
  537. //健康教育
  538. $(".div-jkjy-btn").on('tap', jkjy);
  539. //新增指导
  540. $(".div-add-guide-btn").on('tap', jkzd);
  541. //随访
  542. $(".div-suifang-btn").on('tap',function(){
  543. // openWebview("../../suifang/html/choose_suifang.html", {patiCode: oPatiInfo.code});
  544. openWebview("../../suifang/html/suifang_list.html", {patientCode: oPatiInfo.code});
  545. });
  546. //显示更过操作
  547. $(".header-link").on('tap', function(){
  548. mui('#sheet1').popover('toggle');
  549. });
  550. }