prescription-tabs.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. var docInfo = window.localStorage.getItem("docInfo");
  11. docInfo = JSON.parse(docInfo);
  12. var fromTabIdx = request.fromTabIdx; // 记录前一个Tab索引,用于返回按钮
  13. //初始tab的链接
  14. var links = [{
  15. url: 'prescription-consulting.html?from=tab&sessionId='+sessionId,
  16. name: '咨询',
  17. class: ''
  18. },{
  19. url: 'prescription-detail.html?from=tab&code='+prescriptionCode+'&id='+teamCode,
  20. name: '续方详情',
  21. class: ''
  22. },{
  23. url: 'order-tracking.html?from=tab&code='+prescriptionCode,
  24. name: '订单跟踪',
  25. class: '',
  26. },{
  27. url: 'body-record.html?patiCode='+patiCode,
  28. name: '体征记录',
  29. class: ''
  30. },{
  31. url: 'jianchajianyan.html?from=tab&patient='+patiCode,
  32. name: '检查检验',
  33. class: ''
  34. },{
  35. url: 'jw-prescription-list.html?from=tab&patient='+patiCode,
  36. name: '诊断/处方',
  37. class: ''
  38. },{
  39. url: 'prescription-list.html?from=tab&teamCode='+teamCode+'&patient='+patiCode,
  40. name: '历史续方',
  41. class: ''
  42. }];
  43. $(function(){
  44. setTitle(patiName+"续方咨询");
  45. if(!prescriptionCode){
  46. //没有续方的code,就从咨询中获取对应的code
  47. //这种情况下,患者的签约团队一定是医生所在的团队的id
  48. teamCode = docInfo.adminTeamCode;
  49. getPrescriptionInfo();
  50. }else{
  51. //有续方的code,通过code获得续方详情
  52. getPrescriptionInfoByCode();
  53. }
  54. })
  55. // 判断是否有体征设备
  56. function judgeDeviceFn() {
  57. var recordDevice = {patient: patiCode, page: 1, pagesize: 1};
  58. bodyRecordApis.getPatientDevice({data: recordDevice}).then(function(res){
  59. if(res.status == 200){
  60. if(res.data.length == 0){
  61. //没有绑定设备
  62. links[3].class="hidden";
  63. initPage();
  64. } else {
  65. judgeRecordFn()
  66. }
  67. }else{
  68. showWarningMsg(res.msg)
  69. }
  70. })
  71. }
  72. // 判断是否有体征记录
  73. function judgeRecordFn() {
  74. var recordData = {patient: patiCode};
  75. bodyRecordApis.getBodyRecoredLast({data: recordData}).then(function(res){
  76. if(res.status == 200){
  77. if(!res.data.xt || !res.data.xy) {
  78. links[3].class="hidden";
  79. }
  80. initPage();
  81. }else{
  82. showWarningMsg(res.msg)
  83. }
  84. })
  85. }
  86. function initPage(){
  87. links[tab].class="active";
  88. var html = template('tab_tmp', {list: links});
  89. $("#tabs").append(html);
  90. parent.document.getElementById('main').src = links[tab].url;
  91. $("#tabs").on('click', 'a', function(){
  92. var $this = $(this),
  93. $li = $this.parent();
  94. fromTabIdx = $("#tabs li.active").index();
  95. $li.siblings().removeClass("active");
  96. $li.addClass("active");
  97. tab = $this.data('index');
  98. parent.document.getElementById('main').src = links[tab].url+'&from=tab';
  99. })
  100. }
  101. function toPrePrescriptionTab() {
  102. if(fromTabIdx!=null && fromTabIdx != undefined) {
  103. $("#tabs li").eq(fromTabIdx).find('a').trigger('click')
  104. }else{
  105. history.go(-1);
  106. }
  107. }
  108. top.toPrePrescriptionTab = toPrePrescriptionTab
  109. function getPrescriptionInfo(){
  110. patiCode = sessionId.split("_")[0];
  111. consultCode = sessionId.split("_")[1];
  112. var params = { consult: consultCode};
  113. consultingAPI.getPrescriptionInfo({data: params}).then(function(res){
  114. if(res.status == 200){
  115. prescriptionCode = res.data.code;
  116. jwCode = res.data.jwCode;
  117. updateLinkInfo();
  118. if(res.data.status < 50){ //支付成功前不会有订单记录
  119. links[2].class="hidden";
  120. }
  121. judgeDeviceFn();
  122. }else{
  123. showWarningMsg(res.msg);
  124. }
  125. });
  126. }
  127. function getPrescriptionInfoByCode(){
  128. var params = {
  129. code: prescriptionCode,
  130. type: docInfo.isLeader == '1' ? 1 : 2
  131. };
  132. consultingAPI.getPrescriptionInfoByCode({data: params}).then(function(res){
  133. if(res.status == 200){
  134. patiCode = res.data.patient.code;
  135. jwCode = res.data.prescription.jwCode;
  136. consultCode = res.data.prescription.consult;
  137. sessionId = patiCode + '_' + consultCode+'_8';
  138. updateLinkInfo();
  139. //如果不是该续方所在团队的团队长,则不可以显示咨询tab
  140. if(res.data.prescription.doctor != docInfo.code){
  141. links[0].class="hidden";
  142. }
  143. if(res.data.prescription.status < 50){ //支付成功前不会有订单记录
  144. links[2].class="hidden";
  145. }
  146. judgeDeviceFn();
  147. }else{
  148. showWarningMsg(res.msg);
  149. }
  150. });
  151. }
  152. function updateLinkInfo(){
  153. links = [{
  154. url: 'prescription-consulting.html?from=tab&sessionId='+sessionId,
  155. name: '咨询',
  156. class: ''
  157. },{
  158. url: 'prescription-detail.html?from=tab&code='+prescriptionCode+'&id='+teamCode,
  159. name: '续方详情',
  160. class: ''
  161. },{
  162. url: 'order-tracking.html?from=tab&code='+prescriptionCode,
  163. name: '订单跟踪',
  164. class: '',
  165. },{
  166. url: 'body-record.html?patiCode='+patiCode,
  167. name: '体征记录',
  168. class: ''
  169. },{
  170. url: 'jianchajianyan.html?from=tab&patient='+patiCode,
  171. name: '检查检验',
  172. class: ''
  173. },{
  174. url: 'jw-prescription-list.html?from=tab&patient='+patiCode,
  175. name: '诊断/处方',
  176. class: ''
  177. },{
  178. url: 'prescription-list.html?from=tab&teamCode='+teamCode+'&patient='+patiCode,
  179. name: '历史续方',
  180. class: ''
  181. }];
  182. console.log(links);
  183. }