123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- var request = getRequest(),
- tab = request.tab || 0,
- sessionId = request.sessionId, //续方咨询的sessionId 格式: 居民code+咨询code+咨询类型( 8 )
- patiCode = request.patiCode || '',
- patiName = request.patiName ? decodeURI(request.patiName) : '',
- consultCode,
- prescriptionCode = request.code || '',
- teamCode = request.teamCode || '',
- jwCode; //基卫那边存储的原处方的code
- var docInfo = window.localStorage.getItem("docInfo");
- docInfo = JSON.parse(docInfo);
- var fromTabIdx = request.fromTabIdx; // 记录前一个Tab索引,用于返回按钮
- //初始tab的链接
- var links = [{
- url: 'prescription-consulting.html?from=tab&sessionId='+sessionId,
- name: '咨询',
- class: ''
- },{
- url: 'prescription-detail.html?from=tab&code='+prescriptionCode+'&id='+teamCode,
- name: '续方详情',
- class: ''
- },{
- url: 'order-tracking.html?from=tab&code='+prescriptionCode,
- name: '订单跟踪',
- class: '',
- },{
- url: 'body-record.html?patiCode='+patiCode,
- name: '体征记录',
- class: ''
- },{
- url: 'jianchajianyan.html?from=tab&patient='+patiCode,
- name: '检查检验',
- class: ''
- },{
- url: 'jw-prescription-list.html?from=tab&patient='+patiCode,
- name: '诊断/处方',
- class: ''
- },{
- url: 'prescription-list.html?from=tab&teamCode='+teamCode+'&patient='+patiCode,
- name: '历史续方',
- class: ''
- }];
- $(function(){
- setTitle(patiName+"续方咨询");
- if(!prescriptionCode){
- //没有续方的code,就从咨询中获取对应的code
- //这种情况下,患者的签约团队一定是医生所在的团队的id
- teamCode = docInfo.adminTeamCode;
- getPrescriptionInfo();
- }else{
- //有续方的code,通过code获得续方详情
- getPrescriptionInfoByCode();
- }
- })
- // 判断是否有体征设备
- function judgeDeviceFn() {
- var recordDevice = {patient: patiCode, page: 1, pagesize: 1};
- bodyRecordApis.getPatientDevice({data: recordDevice}).then(function(res){
- if(res.status == 200){
- if(res.data.length == 0){
- //没有绑定设备
- links[3].class="hidden";
- initPage();
- } else {
- judgeRecordFn()
- }
- }else{
- showWarningMsg(res.msg)
- }
- })
- }
- // 判断是否有体征记录
- function judgeRecordFn() {
- var recordData = {patient: patiCode};
- bodyRecordApis.getBodyRecoredLast({data: recordData}).then(function(res){
- if(res.status == 200){
- if(!res.data.xt || !res.data.xy) {
- links[3].class="hidden";
- }
- initPage();
- }else{
- showWarningMsg(res.msg)
- }
- })
- }
- function initPage(){
- links[tab].class="active";
- var html = template('tab_tmp', {list: links});
- $("#tabs").append(html);
- parent.document.getElementById('main').src = links[tab].url;
- $("#tabs").on('click', 'a', function(){
- var $this = $(this),
- $li = $this.parent();
- fromTabIdx = $("#tabs li.active").index();
- $li.siblings().removeClass("active");
- $li.addClass("active");
- tab = $this.data('index');
- parent.document.getElementById('main').src = links[tab].url+'&from=tab';
- })
- }
- function toPrePrescriptionTab() {
- if(fromTabIdx!=null && fromTabIdx != undefined) {
- $("#tabs li").eq(fromTabIdx).find('a').trigger('click')
- }else{
- history.go(-1);
- }
- }
- top.toPrePrescriptionTab = toPrePrescriptionTab
- function getPrescriptionInfo(){
- patiCode = sessionId.split("_")[0];
- consultCode = sessionId.split("_")[1];
- var params = { consult: consultCode};
- consultingAPI.getPrescriptionInfo({data: params}).then(function(res){
- if(res.status == 200){
- prescriptionCode = res.data.code;
- jwCode = res.data.jwCode;
- updateLinkInfo();
- if(res.data.status < 50){ //支付成功前不会有订单记录
- links[2].class="hidden";
- }
- judgeDeviceFn();
- }else{
- showWarningMsg(res.msg);
- }
- });
- }
- function getPrescriptionInfoByCode(){
- var params = {
- code: prescriptionCode,
- type: docInfo.isLeader == '1' ? 1 : 2
- };
- consultingAPI.getPrescriptionInfoByCode({data: params}).then(function(res){
- if(res.status == 200){
- patiCode = res.data.patient.code;
- jwCode = res.data.prescription.jwCode;
- consultCode = res.data.prescription.consult;
- sessionId = patiCode + '_' + consultCode+'_8';
- updateLinkInfo();
- //如果不是该续方所在团队的团队长,则不可以显示咨询tab
- if(res.data.prescription.doctor != docInfo.code){
- links[0].class="hidden";
- }
- if(res.data.prescription.status < 50){ //支付成功前不会有订单记录
- links[2].class="hidden";
- }
- judgeDeviceFn();
- }else{
- showWarningMsg(res.msg);
- }
- });
- }
- function updateLinkInfo(){
- links = [{
- url: 'prescription-consulting.html?from=tab&sessionId='+sessionId,
- name: '咨询',
- class: ''
- },{
- url: 'prescription-detail.html?from=tab&code='+prescriptionCode+'&id='+teamCode,
- name: '续方详情',
- class: ''
- },{
- url: 'order-tracking.html?from=tab&code='+prescriptionCode,
- name: '订单跟踪',
- class: '',
- },{
- url: 'body-record.html?patiCode='+patiCode,
- name: '体征记录',
- class: ''
- },{
- url: 'jianchajianyan.html?from=tab&patient='+patiCode,
- name: '检查检验',
- class: ''
- },{
- url: 'jw-prescription-list.html?from=tab&patient='+patiCode,
- name: '诊断/处方',
- class: ''
- },{
- url: 'prescription-list.html?from=tab&teamCode='+teamCode+'&patient='+patiCode,
- name: '历史续方',
- class: ''
- }];
- console.log(links);
- }
|