prescription-tabs.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. var request = getRequest(),
  2. tab = request.tab || 0,
  3. sessionId = request.sessionId, //续方咨询的sessionId 格式: 居民code+咨询code+咨询类型( 8 )
  4. patiCode = request.patiCode || '',
  5. patiName = request.patiName ? decodeURI(request.patiName) : '',
  6. consultCode,
  7. prescriptionCode = request.code || '',
  8. teamCode = request.teamCode || '',
  9. jwCode, //基卫那边存储的原处方的code
  10. fv_id, //随访的id
  11. fv_class; //随访的类别
  12. var docInfo = window.localStorage.getItem("docInfo");
  13. docInfo = JSON.parse(docInfo);
  14. var fromTabIdx = request.fromTabIdx; // 记录前一个Tab索引,用于返回按钮
  15. var reqLinkList = []; //记录切换tab时访问的路径集合,方便返回操作时,不修改之前请求路径的参数
  16. //初始tab的链接
  17. var links = [{
  18. url: 'prescription-consulting.html?from=tab&sessionId='+sessionId,
  19. name: '咨询',
  20. class: ''
  21. },{
  22. url: 'prescription-detail.html?from=tab&code='+prescriptionCode+'&id='+teamCode,
  23. name: '续方详情',
  24. class: ''
  25. },{
  26. url: 'order-tracking.html?from=tab&code='+prescriptionCode,
  27. name: '订单跟踪',
  28. class: '',
  29. },{
  30. url: 'body-record.html?from=tab&patiCode='+patiCode,
  31. name: '体征记录',
  32. class: ''
  33. },{
  34. url: 'jianchajianyan.html?from=tab&patient='+patiCode,
  35. name: '检查检验',
  36. class: ''
  37. },{
  38. url: 'jw-prescription-list.html?from=tab&patient='+patiCode,
  39. name: '诊断/处方',
  40. class: ''
  41. },{
  42. url: 'prescription-list.html?from=tab&teamCode='+teamCode+'&patient='+patiCode,
  43. name: '历史续方',
  44. class: ''
  45. },{
  46. url: '',
  47. name: '问卷调查',
  48. class: ''
  49. },{
  50. url: 'page/followup/followup-main.html?fv_id='+fv_id+'&patiCode='+patiCode+'&fv_class='+fv_class,
  51. name: '随访记录',
  52. class: ''
  53. }];
  54. $(function(){
  55. setTitle(patiName+"续方咨询");
  56. if(!prescriptionCode){
  57. //没有续方的code,就从咨询中获取对应的code
  58. //这种情况下,患者的签约团队一定是医生所在的团队的id
  59. teamCode = docInfo.adminTeamCode;
  60. getPrescriptionInfo();
  61. }else{
  62. //有续方的code,通过code获得续方详情
  63. getPrescriptionInfoByCode();
  64. }
  65. })
  66. // 判断是否有体征设备
  67. function judgeDeviceFn() {
  68. var recordDevice = {patient: patiCode, page: 1, pagesize: 1};
  69. bodyRecordApis.getPatientDevice({data: recordDevice}).then(function(res){
  70. if(res.status == 200){
  71. if(res.data.length == 0){
  72. //没有绑定设备
  73. links[3].class="hidden";
  74. initPage();
  75. } else {
  76. judgeRecordFn()
  77. }
  78. }else{
  79. showWarningMsg(res.msg)
  80. }
  81. })
  82. }
  83. // 判断是否有体征记录
  84. function judgeRecordFn() {
  85. var recordData = {patient: patiCode};
  86. bodyRecordApis.getBodyRecoredLast({data: recordData}).then(function(res){
  87. if(res.status == 200){
  88. if(!res.data.xt && !res.data.xy) {
  89. links[3].class="hidden";
  90. }
  91. initPage();
  92. }else{
  93. showWarningMsg(res.msg)
  94. }
  95. })
  96. }
  97. function initPage(){
  98. links[tab].class="active";
  99. var html = template('tab_tmp', {list: links});
  100. $("#tabs").append(html);
  101. parent.document.getElementById('main').src = links[tab].url;
  102. reqLinkList.push(links[tab].url);
  103. $("#tabs").on('click', 'a', function(){
  104. var $this = $(this),
  105. $li = $this.parent();
  106. if($this.text() == "随访记录"){
  107. tab = $this.data('index');
  108. top.layer.open({
  109. type: 2,
  110. title: '随访记录',
  111. shadeClose: true,
  112. // shade: false,
  113. // maxmin: true, //开启最大化最小化按钮
  114. area: ['800px', '570px'],
  115. content: links[tab].url
  116. });
  117. return false;
  118. }else{
  119. fromTabIdx = $("#tabs li.active").index();
  120. $li.siblings().removeClass("active");
  121. $li.addClass("active");
  122. tab = $this.data('index');
  123. reqLinkList.push(links[tab].url+'&from=tab&fromTabIdx='+fromTabIdx);
  124. var url = links[tab].url+'&from=tab&fromTabIdx='+fromTabIdx;
  125. }
  126. // parent.document.getElementById('main').src = url;
  127. })
  128. }
  129. function toPrePrescriptionTab() {
  130. //页面返回的操作不做trigger操作
  131. var oldUrl = reqLinkList.pop();
  132. var fromTabIdx = oldUrl.split("fromTabIdx=")[1];
  133. var length = reqLinkList.length;
  134. if(length>0){
  135. //应跳转去的页面是
  136. // var url = reqLinkList[reqLinkList.length -1];
  137. if(fromTabIdx){
  138. $("#tabs li").removeClass("active");
  139. $("#tabs li").eq(fromTabIdx).addClass("active");
  140. }
  141. }
  142. history.go(-1);
  143. }
  144. top.toPrePrescriptionTab = toPrePrescriptionTab
  145. function getPrescriptionInfo(){
  146. patiCode = sessionId.split("_")[0];
  147. consultCode = sessionId.split("_")[1];
  148. var params = { consult: consultCode};
  149. consultingAPI.getPrescriptionInfo({data: params}).then(function(res){
  150. if(res.status == 200){
  151. prescriptionCode = res.data.code;
  152. jwCode = res.data.jwCode;
  153. var followup = res.data.followup;
  154. if(followup){
  155. followup = JSON.parse(followup);
  156. fv_id = followup.id;
  157. fv_class = followup.followupClass;
  158. }
  159. updateLinkInfo();
  160. if(res.data.status < 50){ //支付成功前不会有订单记录
  161. links[2].class="hidden";
  162. }
  163. if(!followup){
  164. links[7].class="hidden";
  165. links[8].class="hidden";
  166. }
  167. judgeDeviceFn();
  168. }else{
  169. showWarningMsg(res.msg);
  170. }
  171. });
  172. }
  173. function getPrescriptionInfoByCode(){
  174. var params = {
  175. code: prescriptionCode,
  176. type: docInfo.isLeader == '1' ? 1 : 2
  177. };
  178. consultingAPI.getPrescriptionInfoByCode({data: params}).then(function(res){
  179. if(res.status == 200){
  180. patiCode = res.data.patient.code;
  181. jwCode = res.data.prescription.jwCode;
  182. consultCode = res.data.prescription.consult;
  183. sessionId = patiCode + '_' + consultCode+'_8';
  184. //获得随访的信息
  185. fv_id = res.data.followup.id;
  186. fv_class = res.data.followup.followupClass;
  187. updateLinkInfo();
  188. //如果不是该续方所在团队的团队长,则不可以显示咨询tab,也不显示随访tab
  189. if(res.data.prescription.doctor != docInfo.code){
  190. links[0].class="hidden";
  191. links[7].class="hidden";
  192. links[8].class="hidden";
  193. }
  194. if(res.data.prescription.status < 50){ //支付成功前不会有订单记录
  195. links[2].class="hidden";
  196. }
  197. judgeDeviceFn();
  198. }else{
  199. showWarningMsg(res.msg);
  200. }
  201. });
  202. }
  203. function updateLinkInfo(){
  204. links = [{
  205. url: 'prescription-consulting.html?from=tab&sessionId='+sessionId,
  206. name: '咨询',
  207. class: ''
  208. },{
  209. url: 'prescription-detail.html?from=tab&code='+prescriptionCode+'&id='+teamCode,
  210. name: '续方详情',
  211. class: ''
  212. },{
  213. url: 'order-tracking.html?from=tab&code='+prescriptionCode,
  214. name: '订单跟踪',
  215. class: '',
  216. },{
  217. url: 'body-record.html?from=tab&patiCode='+patiCode,
  218. name: '体征记录',
  219. class: ''
  220. },{
  221. url: 'jianchajianyan.html?from=tab&patient='+patiCode,
  222. name: '检查检验',
  223. class: ''
  224. },{
  225. url: 'jw-prescription-list.html?from=tab&patient='+patiCode,
  226. name: '诊断/处方',
  227. class: ''
  228. },{
  229. url: 'prescription-list.html?from=tab&teamCode='+teamCode+'&patient='+patiCode,
  230. name: '历史续方',
  231. class: ''
  232. },{
  233. url: '',
  234. name: '问卷调查',
  235. class: ''
  236. },{
  237. url: 'page/followup/followup-main.html?fv_id='+fv_id+'&patiCode='+patiCode+'&fv_class='+fv_class,
  238. name: '随访记录',
  239. class: ''
  240. }];
  241. }