targetedTherapy.js 16.3 KB
Newer Older
1 2
define(['zepto', 'medtap', 'mui', 'mui.picker'], function($, medtap, mui) { 
  var targetedTherapy = {
zujiaozhang committed
3 4 5 6 7 8 9 10
    // 获取问卷id
    followUpId: medtap.getRequest('followUpId'),
    	// 获取本题序号
		questionNo: medtap.getRequest('questionNo'),
		//  获取本题id
    questionId: medtap.getRequest('questionId'),	
    //  获取parentId
    parentId: medtap.getRequest('parentId')||'',	
11 12
    // 修改人员id
    adminId: medtap.getRequest('adminId')||'',
13 14 15 16 17 18
    // 奥西替尼药物类型
    drugTypesPicker: '',
    // 报销的picker
    reimbursementPicker: '',
    // 城市picker
    cityPicker: '',
19 20 21 22 23 24 25 26
    // 医保类型picker
    medicalTypePicker: '',
    // 停药时间picker
    stopTimepicker: '',
    // 停药原因
    stopCausepicker: '',
    // 是否下一步治疗
    isNextpicker: '',
zujiaozhang committed
27
    // 选择有或者无
28
    flag: '',
zujiaozhang committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
    // 使用的奥西替尼
    drugTypesVal:'',
    // 所在的地区能否报销泰瑞沙的费用
    reimbursementVal: '',
    // 每盒金额
    drugCostVal: '',
    // 社保城市
    cityVal: '',
    // 医保类型
    medicalType: '',
    // 停药时间
    stopTimeVal: '',
    // 停药原因
    stopCauseVal: '',
    // 是否下一步治疗
    isNextVal: '',
    // 描述方案
    programme:'',
47
    init: function(){
zujiaozhang committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
      	// 用户点击了无
			$('.noHas').on('tap',function(){
				targetedTherapy.flag=false
        console.log(targetedTherapy.flag)
         // 如果选是 那显示输入框
       if($('.input_item_isNext').val()=='是'){
        console.log(1)
        $('.content_body_programme').show()
       }
			})
			// 用户点击了有
			$('.has').on('tap',function(){
				targetedTherapy.flag=true
				console.log(targetedTherapy.flag)
      })
     
64
    // 点击下一题
zujiaozhang committed
65 66 67 68 69 70 71 72
      $('.next').on('tap',function(){
        // 先判断必填项
        if(targetedTherapy.flag){
          targetedTherapy.drugTypesVal = $.trim($('.input_item_drugTypes').val())
          if(targetedTherapy.drugTypesVal==''){
            medtap.winPop('请选择您正在使用的奥西替尼')
						return
          }
zujiaozhang committed
73 74 75 76 77 78
          if(targetedTherapy.drugTypesVal=='泰瑞沙'){
            targetedTherapy.reimbursementVal = $.trim($('.input_item_reimbursement').val())
            if(targetedTherapy.reimbursementVal==''){
              medtap.winPop('请选择您所在的地区能否报销泰瑞沙的费用')
              return
            }
zujiaozhang committed
79
          }
zujiaozhang committed
80
        
zujiaozhang committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
          targetedTherapy.drugCostVal = $.trim($('.input_item_drugCost').val())
          if(targetedTherapy.drugCostVal==''){
            medtap.winPop('请输入每盒的自付金额')
						return
          }
          targetedTherapy.cityVal = $.trim($('.input_item_city').val())
          if(targetedTherapy.cityVal==''){
            medtap.winPop('请选择医保所在城市')
						return
          }
          targetedTherapy.medicalType = $.trim($('.input_item_medicalType').val())
          if(targetedTherapy.medicalType==''){
            medtap.winPop('请选择医保类型')
						return
          }
          var hasUrl = 'otherTreatment.html'
           // 选择有的时候的数据
          var dataHas = 	{
            "parentId":targetedTherapy.parentId,
						"questionId":targetedTherapy.questionId,
						"answer":{
              "drugTypesVal":targetedTherapy.drugTypesVal,
              "reimbursementVal":targetedTherapy.reimbursementVal,
              "drugCostVal":targetedTherapy.drugCostVal,
              "cityVal": targetedTherapy.cityVal,
              "medicalType": targetedTherapy.medicalType,
              "status":1
            },
						"questionNo":Number(targetedTherapy.questionNo),
						"followUpId": targetedTherapy.followUpId
					}
          targetedTherapy.getNextQuestion(dataHas,hasUrl)
          // else 为选择 ‘无’ 时判断必填项
        }else{
          targetedTherapy.stopTimeVal = $.trim($('.input_item_stopTime').val())
          if(targetedTherapy.stopTimeVal==''){
            medtap.winPop('请选择停药时间')
						return
          }
          targetedTherapy.stopCauseVal = $.trim($('.input_item_stopCause').val())
          if(targetedTherapy.stopCauseVal==''){
            medtap.winPop('请选择停药原因')
						return
          }
          targetedTherapy.isNextVal = $.trim($('.input_item_isNext').val())
          if(targetedTherapy.isNextVal==''){
            medtap.winPop('请选择是否已开启下一步治疗')
						return
          }
          targetedTherapy.programme =  $.trim($('#content_body_programme').val())
          // 选择无的时候的数据
          var noUrl = 'examination.html'
          var dataNo = 	{
            "parentId":targetedTherapy.parentId,
						"questionId":targetedTherapy.questionId,
						"answer":{
              "stopTimeVal": targetedTherapy.stopTimeVal,
              "stopCauseVal":targetedTherapy.stopCauseVal,
              "isNextVal": targetedTherapy.isNextVal,
              "programme": targetedTherapy.programme,
              "status":0
            },
						"questionNo":Number(targetedTherapy.questionNo),
						"followUpId": targetedTherapy.followUpId
					}
          targetedTherapy.getNextQuestion(dataNo,noUrl)
        }
        
149 150
      })
       // 点击上一题
zujiaozhang committed
151 152 153
			$('.pre').on('tap',function(){
        // medtap.pushWindow('furtherConsultation.html?followUpId='+targetedTherapy.followUpId);
        targetedTherapy.getPreQuestion()
154
      })
155 156 157 158 159 160 161 162 163
        // tab切换
    $(".tabbox li").click(function ()
      {
        //获取点击的元素给其添加样式,讲其兄弟元素的样式移除
        $(this).addClass("active").siblings().removeClass("active");
        //获取选中元素的下标
        var index = $(this).index();
        $(this).parent().siblings().children().eq(index).addClass("active")
        .siblings().removeClass("active");
zujiaozhang committed
164
     });
165 166 167
    targetedTherapy.inintDrugTypes();
    targetedTherapy.initReimbursementPicker();
    targetedTherapy.initCity();
zujiaozhang committed
168
    targetedTherapy.initCityl();
169 170 171 172
    targetedTherapy.initmedicalTypePicker();
    targetedTherapy.initstopTimepicker();
    targetedTherapy.initstopCausepicker();
    targetedTherapy.initisNextpicker();
173 174 175
    targetedTherapy.selectItems();

    },
176
    //  ---------- 有 ---------
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
    // 初始化drugTypesPicker
    inintDrugTypes:function(){
      targetedTherapy.drugTypesPicker = new mui.PopPicker();
      targetedTherapy.drugTypesPicker.setData([
        {value:'1',text:'泰瑞沙'},
        {value:'2',text:'东南亚仿药'},
        {value:'3',text:'原料'}
      ]);
    },
    // 初始化报销reimbursementPicker
    initReimbursementPicker: function(){
      targetedTherapy.reimbursementPicker = new mui.PopPicker();
      targetedTherapy.reimbursementPicker.setData([
        {value:'1',text:'可以'},
        {value:'2',text:'部分可以'},
        {value:'3',text:'完全自费'}
      ]);
    },
zujiaozhang committed
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
    initCityl: function() {
			medtap.loading(1);
			$.ajax({
				url: "https://testdevgw.medtap.cn/common/listAreaV0",
				data: {},
				type: 'get',
				async: true,
				success: function(data) {
          console.log(data)
					medtap.loading(0);
					if (data.success) {
						var arr = data.content.areas;
						var cityData = [];
						for (var i = 0, len = arr.length; i < len; i++) {
							var obj = {};
							obj.text = arr[i].name;
							obj.value = arr[i].provinceId;
							var temp = [];
							for (var j = 0, len2 = arr[i].city.length; j < len2; j++) {
								var item = arr[i].city[j];
								var o = {};
								o.text = item.name;
								o.value = item.cityId;
								temp.push(o);
							}
							obj.children = temp;
							cityData.push(obj);
            }
            targetedTherapy.initCity(cityData)
					}
				},
				error: function(data) {
					medtapCore.jzz(0);
					mui.toast('获取所在地失败');
				}
			});
		},
232
    // 初始化城市cityPicker数据
zujiaozhang committed
233
    initCity:function(cityData){
234 235 236 237 238 239
    var _getParam = function(obj, param) {
        return obj[param] || '';
    };
    //-----------------------------------------
    //					//级联示例
    targetedTherapy.cityPicker = new mui.PopPicker({
zujiaozhang committed
240
        layer: 2
241
    });
zujiaozhang committed
242
    targetedTherapy.cityPicker.setData(cityData);
243
    },
244 245 246 247
     // 初始化医保类型picker
     initmedicalTypePicker:function(){
      targetedTherapy.medicalTypePicker = new mui.PopPicker();
      targetedTherapy.medicalTypePicker.setData([
zujiaozhang committed
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
        {
          text: '城镇职工基本医疗保险',
          value: 'HT1'
         },
         {
          text: '城镇居民基本医疗保险',
          value: 'HT2'
         },
         {
          text: '新型农村合作医疗',
          value: 'HT3'
         },
         {
          text: '商业医疗保险',
          value: 'HT4'
         },
         {
          text: '全自费',
          value: 'HT5'
         },
         {
          text: '全公费',
          value: 'HT6'
         },
         {
          text: '贫困救助',
          value: 'HT7'
         },
         {
          text: '其他社会保险',
          value: 'HT8'
         }
280 281 282
      ]);
     },
     //  ------ 无 -----------
zujiaozhang committed
283
     //  停药时间
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
     initstopTimepicker: function(){
      targetedTherapy.stopTimepicker = new mui.DtPicker({type:'month'});
     },
    //  停药原因
     initstopCausepicker: function(){
      targetedTherapy.stopCausepicker = new mui.PopPicker();
      targetedTherapy.stopCausepicker.setData([
        {value:'1',text:'副反应严重'},
        {value:'2',text:'耐药/疾病进展'},
        {value:'3',text:'经济难以承受'},
        {value:'4',text:'买不到'},
        {value:'5',text:'好转无需继续治疗'},
        {value:'6',text:'其他'},
      ]);
     },
    //  是否下一步治疗
     initisNextpicker: function(){
      targetedTherapy.isNextpicker = new mui.PopPicker();
      targetedTherapy.isNextpicker.setData([
        {value:'1',text:'是'},
        {value:'2',text:'否'}
      ]);
     },
307 308 309 310 311
     // 点击picker后的事件注册
    selectItems:function(){
          // 点击药物类型的判断
      $('.content_body_drugTypes').click(function(){
        targetedTherapy.drugTypesPicker.show(function (Items) {
zujiaozhang committed
312
      
313
          $('.input_item_drugTypes').val(Items[0].text)
zujiaozhang committed
314 315 316 317 318 319
          if(Items[0].text=='泰瑞沙'){
            $('.content_body_reimbursement').show()
            $('.input_item_reimbursement').val('')
          }else{
            $('.content_body_reimbursement').hide()
          }
320 321 322 323 324
        })
      })
      // 点击了费用报销
      $('.input_item_reimbursement').click(function(){
        targetedTherapy.reimbursementPicker.show(function (Items) {
zujiaozhang committed
325
         
326 327 328
          $('.input_item_reimbursement').val(Items[0].text)
        })
      })
329
      // 点击医保所在城市选择
330 331
      $('.input_item_city').click(function(){
        targetedTherapy.cityPicker.show(function (Items) {
zujiaozhang committed
332
          $('.input_item_city').val(Items[0].text+Items[1].text)
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
        })
      })
      // 点击医保类型
      $('.content_body_medicalType').click(function(){
        targetedTherapy.medicalTypePicker.show(function (Items) {
          $('.input_item_medicalType').val(Items[0].text)
        })
      })
      //  ----------- 无 ---------
      // 点击停药时间
      $('.content_body_stopTime').click(function(){
        targetedTherapy.stopTimepicker.show(function (selectItems) { 
          var timer = selectItems.y.text + '年' + selectItems.m.text + '月'
          $('.input_item_stopTime').val(timer)
      })
      })
      // 点击停药原因
      $('.content_body_stopCause').click(function(){
        targetedTherapy.stopCausepicker.show(function (Items) {
          $('.input_item_stopCause').val(Items[0].text)
        })
      })
       // 是否下一步治疗
      $('.content_body_isNext').click(function(){
        targetedTherapy.isNextpicker.show(function (Items) {
          if(Items[0].value=='1'){
            $('.input_item_isNext').val(Items[0].text)
            $('.content_body_programme').show()
          }else{
            $('.input_item_isNext').val(Items[0].text)
            $('.content_body_programme').hide()
            $('#content_body_programme').val('')
          }
366 367 368
        })
      })
    },
zujiaozhang committed
369 370
    // 获取问题答案
    getQuestionAnswer: function(){
371
      var crm = targetedTherapy.adminId==''? '':'/crm'
zujiaozhang committed
372
      medtap.submitAjax({
373
        url: 'https://testdevgw.medtap.cn/operation/followUp'+crm+'/getAnswer',
zujiaozhang committed
374 375 376 377 378 379 380 381 382 383
        type: 'post',
        async: false,
        contentType: 'application/json',
        data: {
          "followUpId": targetedTherapy.followUpId,
          "questionId": targetedTherapy.questionId,
        },
        success: function(res) {
          console.log(res) 
          if(!res.success) return medtap.winPop('获取数据失败')
384 385 386 387 388
          // 如果没做过题那么answer没有
					if(!res.content.followAnswer.answer) {
            targetedTherapy.flag=true
            return
          }
zujiaozhang committed
389
          // 有
390 391 392
          var status = res.content.followAnswer.answer.status=undefined?  '1':res.content.followAnswer.answer.status
          if(status=='1'){
            targetedTherapy.flag=true
zujiaozhang committed
393 394 395
            if(res.content.followAnswer.answer.drugTypesVal=='泰瑞沙'){
              $('.content_body_reimbursement').show()
            }
zujiaozhang committed
396
            $('.input_item_drugTypes').val(res.content.followAnswer.answer.drugTypesVal||'') 
zujiaozhang committed
397
            
zujiaozhang committed
398 399 400 401
            $('.input_item_reimbursement').val(res.content.followAnswer.answer.reimbursementVal||'')
            $('.input_item_drugCost').val(res.content.followAnswer.answer.drugCostVal||'')
            $('.input_item_city').val(res.content.followAnswer.answer.cityVal||'')
            $('.input_item_medicalType').val(res.content.followAnswer.answer.medicalType||'')
402 403
          }else if(status=='0'){
            console.log('1')
zujiaozhang committed
404 405 406 407 408 409 410 411 412 413 414 415
            // 无
              targetedTherapy.flag=false
              $('.noHas').addClass('active').siblings('.has').removeClass('active')
              $('.content_select_no').addClass('active').siblings('.content_select').removeClass('active')
              if(res.content.followAnswer.answer.isNextVal=='是'){
                $('.content_body_programme').show()
              }
             $('.input_item_stopTime').val(res.content.followAnswer.answer.stopTimeVal||'')
             $('.input_item_stopCause').val(res.content.followAnswer.answer.stopCauseVal||'')
             $('.input_item_isNext').val(res.content.followAnswer.answer.isNextVal||'')
             $('#content_body_programme').val(res.content.followAnswer.answer.programme||'')
          } 
416
          console.log(targetedTherapy.flag)
zujiaozhang committed
417 418 419 420 421
        }
      })
    },
      // 上一题
		getPreQuestion:function(){
422
      var crm = targetedTherapy.adminId==''? '':'/crm'
zujiaozhang committed
423
			medtap.submitAjax({
424
				url: 'https://testdevgw.medtap.cn/operation/followUp'+crm+'/previousQuestion',
zujiaozhang committed
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
				type: 'post',
				async: false,
				contentType: 'application/json',
				data: {
					"questionId":targetedTherapy.questionId,
					"questionNo":targetedTherapy.questionNo,
					"followUpId":targetedTherapy.followUpId,
				},
				success: function(res) {
          console.log(res)
          if(!res.success) return medtap.winPop('获取数据失败')
          var parentId = res.content.previousQuestion.parentId||''
					var questionId = res.content.previousQuestion.questionId||''
					var questionNo = res.content.previousQuestion.questionNo||''
						medtap.pushWindow('furtherConsultation.html?followUpId='+targetedTherapy.followUpId+'&questionId='+questionId+'&questionNo='+questionNo
440
            +'&parentId='+parentId+'&adminId='+targetedTherapy.adminId);
zujiaozhang committed
441 442 443 444 445
				}
			})
		},
    	 // 下一题
		getNextQuestion:function(data,url){
446
      var crm = targetedTherapy.adminId==''? '':'/crm'
zujiaozhang committed
447
			medtap.submitAjax({
448
				url: 'https://testdevgw.medtap.cn/operation/followUp'+crm+'/nextQuestion',
zujiaozhang committed
449 450 451 452 453 454 455 456 457 458 459
				type: 'post',
				async: false,
				contentType: 'application/json',
				data: data,
				success: function(res) {
          console.log(res)
          if(!res.success) return medtap.winPop('获取数据失败')
            // 获取下一题的id和序号通过url传递
          var parentId = res.content.nextQuestion.parentId||''
					var questionId = res.content.nextQuestion.questionId||''
					var questionNo = res.content.nextQuestion.questionNo||''
460
					medtap.pushWindow(url+'?followUpId='+targetedTherapy.followUpId+'&questionId='+questionId+'&questionNo='+questionNo+'&parentId='+parentId+'&adminId='+targetedTherapy.adminId);
zujiaozhang committed
461 462 463
				}
			})
		}
464 465
  }
  targetedTherapy.init()
zujiaozhang committed
466
  targetedTherapy.getQuestionAnswer()
467
  })