huanzhexinxi.js 15 KB

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