xufangzixun.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. var lastId = 0;
  2. var prevImage,
  3. offTop = 151,
  4. offBot = 0;
  5. var patientInfo,
  6. patiCode,
  7. consultCode,
  8. prescriptionCode, //续方的code
  9. prescriptionStatus, //续方的状态
  10. isFinishZX,//咨询的状态
  11. jwCode; //基卫那边存储的原处方的code
  12. var isJieshuCaozuo = false;
  13. var prescriptionMsg,followObj;
  14. var self;
  15. mui.plusReady(function() {
  16. self = plus.webview.currentWebview();
  17. $('#title').html(self.otherName);
  18. //通过sessionId来获取prescriptionCode和patiCode
  19. //续方咨询的sessionId 格式 居民code+咨询code+咨询类型( 8 )
  20. var sessionId = self.sessionId;
  21. patiCode = sessionId.split("_")[0];
  22. consultCode = sessionId.split("_")[1];
  23. //初始化个人信息 + 初始化scroller
  24. getMineInfo();
  25. //创建session
  26. // createSession(self.type, getMembersExt);
  27. //获得会话信息
  28. initPage();
  29. //获得续方信息
  30. getPrescriptionInfo();
  31. //获得患者的服务类型
  32. getPatientServiceType();
  33. prevImage = mui.previewImage();
  34. getPatientInfo();
  35. //判断患者是否绑定设备
  36. getPatientDeviceList();
  37. //快捷方式
  38. quickReply()
  39. bindEvent();
  40. //返回
  41. var opener = self.opener();
  42. if(opener && (opener.id == "xufangzixunxiangqing")) {
  43. var zxxq = plus.webview.getWebviewById("xufangzixunxiangqing");
  44. zxxq.close('none');
  45. backToZdzx();
  46. }else if(opener && (opener.id =="jumingim")){
  47. backToJMim();
  48. }else if(opener && (opener.id == "fzxz-jumingim")){
  49. backToJMim();
  50. }
  51. })
  52. function backToZdzx() {
  53. var old_back = mui.back;
  54. mui.back = function() {
  55. var wv = plus.webview.getWebviewById("xufangzixun");//续方咨询列表页
  56. if(wv) {
  57. mui.fire(wv, "refreshPage");
  58. }
  59. old_back();
  60. }
  61. }
  62. //刷新消息的居民im页面
  63. function backToJMim() {
  64. var old_back = mui.back;
  65. mui.back = function() {
  66. var wv = plus.webview.getWebviewById("jumingim");//续方咨询列表页
  67. if(wv) {
  68. mui.fire(wv, "update");
  69. }
  70. var wv1 = plus.webview.getWebviewById("fzxz-jumingim");//非咨询
  71. if(wv1) {
  72. mui.fire(wv1, "xiaoxiUpdate");
  73. }
  74. old_back();
  75. }
  76. }
  77. /**
  78. * 获得咨询成员信息
  79. */
  80. function getMembersExt() {
  81. getMembers();
  82. }
  83. /**
  84. * 获得续方的内容
  85. */
  86. function getPrescriptionInfo(){
  87. var url = "/doctor/consult/prescriptionDetail",
  88. params = {consult: consultCode,};
  89. sendGet(url, params, null, function(res){
  90. if(res.status == 200){
  91. prescriptionMsg = res.data;
  92. followObj = prescriptionMsg.followup=="null"?'':JSON.parse(prescriptionMsg.followup);
  93. jwCode = res.data.jwCode;
  94. prescriptionCode = res.data.code;
  95. $("#preDTName").text(res.data.symptoms+"-续方咨询");
  96. var status = res.data.status;
  97. prescriptionStatus = status;
  98. var statusName = getStatusName(status);
  99. $("#xfStatus").text(statusName);
  100. var drugmsg='';
  101. for(j=0; j<res.data.prescriptionInfo.length; j++){
  102. var item = res.data.prescriptionInfo[j];
  103. drugmsg += item.drugName+" "+item.num+item.drugNumUnitName+" ";
  104. }
  105. $("#drugInfo").find('.j-msg').text(drugmsg);
  106. $('.top-panel').show()
  107. if(status<0){
  108. $('.suifang').hide()
  109. }
  110. }else{
  111. mui.toast(res.msg);
  112. }
  113. }, true);
  114. }
  115. window.addEventListener('quickReplyRefresh', function() {
  116. quickReply()
  117. })
  118. //快捷方式
  119. function quickReply(){
  120. sendGet("doctor/reply/list",{type:1},null,function(res){
  121. if(res.status==200){
  122. var html="",
  123. data = res.data;
  124. for(var i=0;i<4;i++){
  125. html += '<li class="kj-li" data-id="'+data[i].systag+'">'+data[i].content+'</li>'
  126. }
  127. html +='<li id="kjhf">+ 更多快捷回复</li>'
  128. $(".xf-res-list").empty().append(html)
  129. }
  130. })
  131. }
  132. //获得患者的服务类型
  133. function getPatientServiceType(){
  134. var url = 'doctor/sign/getPatientFamilyServer',
  135. params = {patient: patiCode};
  136. sendGet(url, params, null, function(res){
  137. if(res.status == 200){
  138. //slowDiseasePatient: 0 //0表示没有慢病服务类型,1表示有
  139. if(res.data.slowDiseasePatient == 0){
  140. $("#diseaseTips").html("此居民未被标注【慢病】相关标签,是否确认核实?<a href='javascript:;' onclick='goToPatient()'>点击核实</a>");
  141. }else{
  142. var disease = "";
  143. for(var i=0; i<res.data.signFamilyServer.length; i++){
  144. var item = res.data.signFamilyServer[i];
  145. if(i>0){
  146. disease += ','+item.name;
  147. }else{
  148. disease += item.name;
  149. }
  150. }
  151. $("#diseaseTips").text("该居民为"+disease+"患者");
  152. }
  153. }else{
  154. // mui.toast('获得患者服务类型失败');
  155. }
  156. }, true);
  157. }
  158. /**
  159. * 初始化页面
  160. */
  161. function initPage() {
  162. var url = 'doctor/consult/getConsultStatus',
  163. params = {consult: consultCode};
  164. sendPost(url, params, null,function(res){
  165. if(res.status == 200) {
  166. //咨询状态(0进行中,1已完成,-1患者取消,-2超时未响应自动关闭)
  167. if(res.data == 0) { //咨询未结束
  168. $('.topmsg1').html('审核完成24小时后,将自动结束咨询<a href="javascript:void(0)" onclick="jieshu()">立即结束</a>');
  169. $('#wrapper1').css({'bottom': '52px', 'top': '187px'});
  170. offBot = 52;
  171. $('#input_div').show();
  172. isFinishZX = 0;
  173. if(myScroll) myScroll.refresh();
  174. } else { //咨询已结束
  175. $('#wrapper1').css({
  176. top: '175px',
  177. bottom: '0px'
  178. });
  179. $('#input_div').hide();
  180. isFinishZX = 1;
  181. }
  182. //获得咨询信息
  183. // getFirstMsgs();
  184. //创建session
  185. createSession(self.type, getMembersExt);
  186. } else {
  187. mui.toast("获取信息失败");
  188. }
  189. }, 'get')
  190. }
  191. //判断object是否为空
  192. function isEmptyObject(e) {
  193. var t;
  194. for(t in e)
  195. return !1;
  196. return !0
  197. }
  198. //获得患者信息
  199. function getPatientInfo(){
  200. var url = 'doctor/patient_label_info/patient',
  201. params = {patient: patiCode};
  202. sendPost(url, params, null, function(res){
  203. if(res.status == 200){
  204. patientInfo = res.data;
  205. }else{
  206. mui.toast(res.msg);
  207. }
  208. }, 'POST', '', true)
  209. }
  210. //获得患者的绑定的设备信息
  211. function getPatientDeviceList(){
  212. var url = "doctor/device/PatientDeviceList",
  213. params = {patient: patiCode, page:1, pagesize: 2};
  214. sendGet(url, params, null, function(res){
  215. if(res.status == 200){
  216. if(res.data.length == 0){
  217. //没有绑定设备
  218. $(".tzjl").hide();
  219. }else{
  220. //绑定了设备
  221. $(".tzjl").show();
  222. }
  223. }else{
  224. //获取设备信息失败
  225. }
  226. }, true);
  227. }
  228. //跳转去患者信息页面
  229. function goToPatient(){
  230. mui.openWindow('../../huanzhe/html/huanzhexinxi.html', 'huanzhexinxi.html', {
  231. extras: {
  232. patiCode: patiCode
  233. }
  234. });
  235. }
  236. function bindEvent(){
  237. /**
  238. * 点击查看好友详细信息
  239. */
  240. $('#qun_detail').on("tap", function() {
  241. mui.openWindow('../../huanzhe/html/huanzhexinxi.html', 'huanzhexinxi.html', {
  242. extras: {
  243. patiCode: patiCode
  244. }
  245. });
  246. })
  247. //顶部内容的展开和收缩
  248. $("#expandBox").on('click', function(e){
  249. e.stopPropagation();
  250. var $this = $(this);
  251. if($this.hasClass('expand')){
  252. $this.removeClass('expand');
  253. $this.find('img').attr('src', '../images/zhankai_icon.png');
  254. $("#prescriptionInfo").hide();
  255. var top = $(".top-panel").height()+15;
  256. $("#wrapper1").css({
  257. "top" : top+'px'
  258. });
  259. }else{
  260. $this.addClass('expand');
  261. $this.find('img').attr('src', '../images/shouqi_icon.png');
  262. $("#prescriptionInfo").show();
  263. var top = $(".top-panel").height()+15;
  264. $("#wrapper1").css({
  265. "top" : top+'px'
  266. });
  267. }
  268. });
  269. //体征记录
  270. $(".tzjl").on('click', function(){
  271. mui.openWindow('../../jkjl/html/health-record.html', 'health-record', {
  272. extras: {
  273. patientCode: patiCode,
  274. patientName: patientInfo.name,
  275. qyRelation: 1
  276. }
  277. });
  278. });
  279. //检查检验
  280. $(".jcjy").on('click', function(){
  281. openWebview("../../huanzhe/html/jianchajianyan.html",{
  282. patiInfo: {
  283. code: patiCode
  284. }
  285. });
  286. });
  287. //诊断处方
  288. $(".zdcf").on('click', function(){
  289. openWebview("../../prescription/html/chufangxiangqing.html",{
  290. code: jwCode,
  291. patient:patiCode,
  292. preCode: prescriptionCode
  293. });
  294. });
  295. //历史续方
  296. $(".lsxf").on('click', function(){
  297. openWebview('../../prescription/html/juminxufangjilu.html', {
  298. teamCode: patientInfo.jtAdminTeam,
  299. patiCode: patiCode,
  300. patiName: patientInfo.name
  301. });
  302. });
  303. $("#prescriptionInfo").on("click", function(){
  304. openWebview('../../prescription/html/xufangxiangqing.html',{
  305. prescriptionCode: prescriptionCode,
  306. teamCode: patientInfo.jtAdminTeam
  307. });
  308. });
  309. //跳转去续方详情页面
  310. $("body").on('tap', ".view-detail", function(){
  311. openWebview('../../prescription/html/xufangxiangqing.html',{
  312. prescriptionCode: prescriptionCode,
  313. teamCode: patientInfo.jtAdminTeam
  314. });
  315. })
  316. //随访调查
  317. $("body").on('tap', ".viewData", function(){
  318. var type = $(this).attr('data-type')
  319. mui.openWindow('questionaires.html', 'questionaires', {
  320. extras: {
  321. pro_id:type,
  322. prescriptionCode: prescriptionCode,
  323. followupid:followObj.id
  324. }
  325. })
  326. })
  327. //登记随访
  328. function registerSuifang(){
  329. var followClass;
  330. if(prescriptionMsg.symptoms == "高血压"){
  331. followClass = 1;
  332. }else if(prescriptionMsg.symptoms == "糖尿病"){
  333. followClass = 2;
  334. }else{
  335. followClass = '1,2';
  336. }
  337. mui.openWindow('../../suifang/html/follow_way.html', 'xf_follow_way', {
  338. extras: {
  339. followup_id:followObj.id,
  340. followClass:followClass,
  341. patientInfo:patientInfo,
  342. prescriptionCode: prescriptionCode,
  343. prescriptionStatus:prescriptionMsg.status
  344. }
  345. })
  346. }
  347. $(".suifang").on('click', function(){
  348. if(! followObj){
  349. registerSuifang()
  350. }else{
  351. if(followObj.status == 2){
  352. registerSuifang()
  353. }else{
  354. mui.openWindow('../../suifang/html/fvDetail.html', 'xf_fvDetail', {
  355. extras: {
  356. followup_id:followObj.id,
  357. prescriptionCode:prescriptionCode
  358. }
  359. })
  360. }
  361. }
  362. })
  363. $(".wenjuan").on('click', function(){
  364. mui.openWindow('wenjuan.html', 'wenjuan', {
  365. extras: {
  366. prescriptionCode: prescriptionCode,
  367. followup_id:followObj.id,
  368. zx_Status:isFinishZX
  369. }
  370. })
  371. })
  372. $("body").on('tap', ".fillData", function(){
  373. if(! followObj){
  374. mui.toast('随访已不存在')
  375. return
  376. }else{
  377. var type = $(this).attr('data-type');
  378. var healthindexid = $(this).attr('data-health');
  379. var url;
  380. if(type == 1){
  381. url="doctor/prescription/followupcontent/importbloodpressure"
  382. }else{
  383. url="doctor/prescription/followupcontent/importbloodsugar"
  384. }
  385. plus.nativeUI.showWaiting();
  386. sendPost(url,{followupid:followObj.id,prescriptioncode:prescriptionCode,healthindexid:healthindexid},function(){
  387. plus.nativeUI.closeWaiting();
  388. mui.toast('请求失败')
  389. }, function(res){
  390. plus.nativeUI.closeWaiting();
  391. if(res.status == 200){
  392. mui.toast('成功填入随访记录')
  393. }else{
  394. mui.toast(res.msg)
  395. }
  396. })
  397. }
  398. })
  399. $(".follow").click(function(e){
  400. e.stopPropagation();
  401. if(! followObj){
  402. mui.toast('随访已不存在')
  403. return
  404. }else{
  405. plus.nativeUI.showWaiting();
  406. sendPost('doctor/prescription/followupcontent/importdrugs',{followupid:followObj.id,prescriptioncode:prescriptionCode},function(){
  407. plus.nativeUI.closeWaiting();
  408. mui.toast('请求失败')
  409. }, function(res){
  410. plus.nativeUI.closeWaiting();
  411. if(res.status == 200){
  412. mui.toast('成功填入随访记录')
  413. }else{
  414. mui.toast(res.msg)
  415. }
  416. })
  417. }
  418. })
  419. //头部导航
  420. mui('#nav').scroll({
  421. deceleration: 0.0005,
  422. scrollY: false, //是否竖向滚动
  423. scrollX: true, //是否横向滚动
  424. indicators: false
  425. })
  426. //快捷方式
  427. $('.tw-change').on('click',function(){
  428. $ipt_content.blur();
  429. $(".tw-add-detail").hide();
  430. $('.xf-res-list').toggle(200)
  431. })
  432. $('.xf-res-list').on('click','.kj-li',function(){
  433. var $this = $(this)
  434. var type = $this.attr('data-id')
  435. doQuickAnswer(type,$this.text().trim())
  436. $('.xf-res-list').hide()
  437. })
  438. $('.xf-res-list').on('click','#kjhf',function(){
  439. $('.xf-res-list').hide()
  440. mui.openWindow('../../kjhf/html/list.html', 'xf-kjhf', {
  441. extras: {
  442. type:'xufang'
  443. }
  444. })
  445. })
  446. }
  447. //处理快捷方式
  448. function doQuickAnswer(type,text){
  449. if(type==0){
  450. $(".tw-add-detail").hide();
  451. $(".xf-res-list").hide();
  452. $("#input_content").show();
  453. var content = text;
  454. ui.boxMsgSound.style.display = 'none';
  455. $(".yy-add").find('img:eq(0)').show().next().hide();
  456. $("#input_content").text(content);
  457. showSendBtn(true);
  458. }
  459. if(! followObj){
  460. mui.toast('随访已不存在')
  461. return
  462. }
  463. if(type == 3 || type == 4){
  464. var params = {
  465. followupid:followObj.id,
  466. prescriptionCode:prescriptionCode,
  467. type:type==3?2:1
  468. }
  469. plus.nativeUI.showWaiting()
  470. sendPost('doctor/consult/addPrescriptionBloodStatusConsult',params,null,function(res){
  471. plus.nativeUI.closeWaiting()
  472. if(res.status == 200){
  473. }else{
  474. mui.toast('获取数据失败')
  475. }
  476. })
  477. }
  478. if(type == 1 || type == 2){
  479. var kind = type==1?2:1;
  480. var name,time;
  481. sendGet('doctor/prescription/followupcontent/list',{prescriptioncode:prescriptionCode},null, function(res){
  482. if(res.status == 200){
  483. var obj = _.find(res.data, function(o){ return o.type ==kind})
  484. time = obj.createtime
  485. name = patientInfo.name
  486. if(obj.statue == "2"){
  487. var params = {
  488. followupid:followObj.id,
  489. prescriptionCode:prescriptionCode,
  490. type:kind
  491. }
  492. plus.nativeUI.showWaiting()
  493. sendPost('doctor/consult/addPrescriptionFollowupContentConsult',params,null,function(res){
  494. plus.nativeUI.closeWaiting()
  495. if(res.status == 200){
  496. }else{
  497. mui.toast('获取数据失败')
  498. }
  499. })
  500. }else{
  501. dialog({
  502. content:'<div class="c-f14">居民<span>'+name+'</span>已在<span>'+time+'</span>填写<span>'+obj.name+'</span></div>',
  503. okValue:'查看问卷',
  504. ok: function() {
  505. mui.openWindow('questionaires.html', 'questionaires', {
  506. extras: {
  507. pro_id:kind,
  508. prescriptionCode:prescriptionCode,
  509. followupid:followObj.id
  510. }
  511. })
  512. }
  513. }).showModal();
  514. }
  515. }
  516. })
  517. }
  518. }
  519. /**
  520. * 获取聊天图片列表
  521. */
  522. function getImgMsgList(handle) {
  523. im.getPrivateMsg(getUserId(), otherCode, lastId, pageSize, function(data) {
  524. console.log("imgs:" + JSON.stringify(data));
  525. chatCache.imgs = data.records.reverse();
  526. appendPrevImgs(chatCache.imgs);
  527. if(handle) handle(data);
  528. }, 2);
  529. }
  530. /**
  531. * 发送消息
  532. */
  533. function uploadMsg(type, content, locSrc, isNotSend, callBack) {
  534. service.isConsultFinished(consultCode, function(res) {
  535. if(res.data == 0) {
  536. //作用: 更新咨询状态
  537. uploadMsgBase(type, content, locSrc, isNotSend, callBack);
  538. } else if(res == "timeout" && type == 1) {
  539. var tim = new Date().getTime();
  540. var id = "loc" + tim;
  541. var d = [{
  542. "sender_id": docInfo.code,
  543. "sender_name": docInfo.name,
  544. "content_type": 1,
  545. "content": content,
  546. "timestamp": tim,
  547. "id": id,
  548. local_src: "",
  549. beforeSend: true
  550. }];
  551. showMsg(d, false, false, true);
  552. addMsgToCache(d, true);
  553. $('#contain dl[data-code="' + id + '"]').find('.c-msg').prepend("<i data-info='" + JSON.stringify(d[0]) + "' class='c-tips'></i>");
  554. } else {
  555. $('.topmsg1').hide();
  556. $('#wrapper1').css({
  557. top: offTop,
  558. bottom: '0px'
  559. });
  560. $('#input_div').hide();
  561. isFinishZX = 1;
  562. myScroll.refresh();
  563. }
  564. })
  565. }
  566. function jieshu() {
  567. //判断续方状态,如果未审核,则不可以结束咨询
  568. if(prescriptionStatus > 0 && prescriptionStatus < 21){
  569. dialog({
  570. content:'续方申请未审核,不能结束咨询',
  571. okValue:'我知道了',
  572. ok: function() {
  573. return;
  574. }
  575. }).showModal();
  576. return false;
  577. }
  578. dialog({
  579. content:'结束咨询后,居民及所有医生均无法再次回复,是否确认继续结束?',
  580. okValue:'继续结束',
  581. ok: function() {
  582. sendPost("doctor/consult/finish_consult", {
  583. consult: consultCode
  584. }, null, function(res) {
  585. if(res.status == 200) {
  586. isJieshuCaozuo = true;
  587. $('.topmsg1').html("咨询求助已结束");
  588. $('#input_div').hide();
  589. isFinishZX = 1;
  590. $('#wrapper1').css({
  591. bottom: '0px'
  592. });
  593. myScroll.refresh();
  594. mui.toast("已结束该咨询");
  595. } else {
  596. mui.toast(res.msg)
  597. }
  598. });
  599. },
  600. cancelValue: '我再看看',
  601. cancel: function(){}
  602. }).showModal();
  603. }
  604. window.addEventListener('getMember', function(e) {
  605. if(e.detail.group2)
  606. consultInfo.group2 = e.detail.group2;
  607. });
  608. function getStatusName(status){
  609. var name = "",
  610. img = "";
  611. status = status + '';
  612. switch (status){
  613. case '-5':
  614. name = '线下取消';
  615. break;
  616. case '-4':
  617. name = '线下退费';
  618. break;
  619. case '-3':
  620. name = '支付过期';
  621. break;
  622. case '-2':
  623. name = '患者取消';
  624. break;
  625. case '-1':
  626. name = '审核不通过';
  627. break;
  628. case '0':
  629. case '2':
  630. case '3':
  631. case '4':
  632. case '10':
  633. name = '审核中';
  634. break;
  635. case '20':
  636. name = '药师审核中';
  637. break;
  638. case '21':
  639. name = '药师审核失败';
  640. break;
  641. case '30':
  642. name = '开方中';
  643. break;
  644. case '31':
  645. name = '开方失败';
  646. break;
  647. case '40':
  648. name = '待支付';
  649. break;
  650. case '41':
  651. name = '支付失败';
  652. break;
  653. case '50':
  654. name = '配药中';
  655. break;
  656. case '60':
  657. name = '等待领药';
  658. break;
  659. case '61':
  660. case '62':
  661. case '65':
  662. case '69':
  663. name = '配送中';
  664. break;
  665. case '100':
  666. name = '已完成';
  667. break;
  668. default:
  669. break;
  670. }
  671. return name;
  672. }
  673. window.addEventListener("refreshPage", function() {
  674. getPrescriptionInfo();
  675. });