huanzhexinxi.js 14 KB

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