myEMR.js 6.89 KB
Newer Older
hanpeng committed
1 2
define(['zepto','medtap'],function($,medtap){
	var myEmr = {
hanpeng committed
3
		emrId:0,
hanpeng committed
4
		init:function(){
hanpeng committed
5
			myEmr.getMyEmr();
hanpeng committed
6
			myEmr.bindEve();
hanpeng committed
7
			myEmr.getWechatTicket();
hanpeng committed
8 9
		},
		bindEve:function(){
hanpeng committed
10 11
			$('.change_emr').unbind().bind('click',function(){
				medtap.pushWindow('createPatientInfo.html?id=' + myEmr.emrId);
12
			});
hanpeng committed
13
			$('.add_new_btn').unbind().bind('click',function(){
14
				medtap.pushWindow('createPatientInfo.html');
hanpeng committed
15
			})
hanpeng committed
16
		},
hanpeng committed
17
		getMyEmr:function(){
hanpeng committed
18 19
			medtap.loading(1);
			medtap.submitAjax({
hanpeng committed
20 21
				url:'https://testdevgw.medtap.cn/user/patientEMR/getPatientEMRInfo',
				type:'post',
hanpeng committed
22 23 24
				async:false,
				contentType: 'application/json',
				data:{
hanpeng committed
25
					
hanpeng committed
26 27 28 29
				},
				success:function(res){
					medtap.loading(0);
					if(res.success == true){
hanpeng committed
30 31 32
						var data = res.content;
						//填充用户信息
						var userInfo = data.userInfo;
hanpeng committed
33
						$('.user_name').text(userInfo.username)
hanpeng committed
34
						$('.user_profile').attr('src',userInfo.profile);
hanpeng committed
35
						$('.user_type').text('(' + (userInfo.hasOwnProperty('healthType') ? userInfo.healthType.value : '') + ')');
hanpeng committed
36 37
						$('.user_type').text('(' + userInfo.healthType.value + ')');
						$('.user_sex').text(userInfo.sex == 'M' ? '男' : '女');
hanpeng committed
38 39
						var emrInfo = data.emr;
						if($.isEmptyObject(emrInfo) == false){
hanpeng committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
							//有病历信息
							$('.user_patient_info_detail').show();
							$('.add_new_patient').hide();
							$('body').css('background','#F6F6FC');
							myEmr.emrId = data.emr.emrId;
							$('.patient_name').text(data.emr.patientName);
							$('.patient_sex').text(data.emr.sex == 'M' ? '男' : '女');
							$('.patient_age').text(data.emr.age);
							if(data.emr.hasOwnProperty('height')){
								$('.patient_height').text(data.emr.height);
							}else{
								$('.patient_height').text('未知').css('color','#999999');
							}
							if(data.emr.hasOwnProperty('weight')){
								$('.patient_weight').text(data.emr.weight);
							}else{
								$('.patient_weight').text('未知').css('color','#999999');
							}
							$('#diseases').text(data.emr.diseaseDiagnosisName);
							$('#pathologyType').text(data.emr.pathologyTypeName);
							if(data.emr.hasOwnProperty('tumorStageItem')){
								$('#tumorStage').text(data.emr.tumorStageItem.value);
							}else{
								$('#tumorStage').text('未知').css('color','#999999');
							}
hanpeng committed
65
							if(data.emr.hasOwnProperty('tnmStage') && data.emr.tnmStage !== ''){
hanpeng committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79
								$('#tnmStage').text(data.emr.tnmStage);
							}else{
								$('#tnmStage').text('未知').css('color','#999999');
							}
							if(data.emr.hasOwnProperty('transferNidusItem')){
								$('#transferNidus').text(data.emr.transferNidusItem.value);
							}else{
								$('#transferNidus').text('未知').css('color','#999999');
							}
							if(data.emr.hasOwnProperty('ecogGradeItem')){
								$('#ecogGrade').text(data.emr.ecogGradeItem.value.substring(0,2));
							}else{
								$('#ecogGrade').text('未知').css('color','#999999');
							}
hanpeng committed
80
							/* if(data.emr.smokingFlg == true){
hanpeng committed
81 82 83 84
								var smokeStr = data.emr.smokingDailyNum + '支/天 ' + data.emr.smokingYear +'年';
								$('#somke').text(smokeStr);
							}else{
								$('#somke').text('无');
hanpeng committed
85 86 87 88 89 90 91 92 93 94
							} */
							if(data.emr.hasOwnProperty('smokingFlg')){
								if(data.emr.smokingFlg == true){
									var smokeStr = data.emr.smokingDailyNum + '支/天 ' + data.emr.smokingYear +'年';
									$('#somke').text(smokeStr);
								}else if(data.emr.smokingFlg == false){
									$('#somke').text('无');
								}
							}else{
								$('#somke').text('未知').css('color','#999999');
hanpeng committed
95
							}
hanpeng committed
96
							if(data.emr.hasOwnProperty('patientHospitalIdNum') && data.emr.patientHospitalIdNum !== ''){
hanpeng committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
								$('#patientHospitalIdNum').text(data.emr.patientHospitalIdNum);
							}else{
								$('#patientHospitalIdNum').text('未知').css('color','#999');
							}
							if(data.emr.hasOwnProperty('areaItem')){
								$('#area').text(data.emr.areaItem.fullName);
							}else{
								$('#area').text('未知').css('color','#999');
							}
							if(data.emr.hasOwnProperty('targetedMutationsItem')){
								var str = [];
								for(var i = 0;i < data.emr.targetedMutationsItem.length;i++){
									str.push(data.emr.targetedMutationsItem[i].value);
								}
								str.join(',');
								$('#targetedMutations').text(str);
							}else{
								$('#targetedMutations').text('未知').css('color','#999');
							}
hanpeng committed
116
							if(data.emr.hasOwnProperty('acceptingCureItem') && data.emr.acceptingCure !=''){
hanpeng committed
117 118 119 120 121 122
								var str = [];
								for(var i = 0; i < data.emr.acceptingCureItem.length;i++){
									str.push(data.emr.acceptingCureItem[i].value);
								}
								str.join(',');
								$('#acceptingCureItem').text(str);
hanpeng committed
123 124
							}else if(data.emr.acceptingCure == ''){
								$('#acceptingCureItem').text('无');
hanpeng committed
125 126 127
							}else{
								$('#acceptingCureItem').text('未知').css('color','#999');
							}
hanpeng committed
128
							if(data.emr.hasOwnProperty('acceptedCureItem') && data.emr.acceptedCure != ''){
hanpeng committed
129 130 131 132 133 134
								var str = [];
								for(var i = 0; i < data.emr.acceptedCureItem.length;i++){
									str.push(data.emr.acceptedCureItem[i].value);
								}
								str.join(',');
								$('#acceptedCureItem').text(str);
hanpeng committed
135 136
							}else if(data.emr.acceptedCure == ''){
								$('#acceptedCureItem').text('无')
hanpeng committed
137 138 139 140 141 142
							}else{
								$('#acceptedCureItem').text('未知').css('color','#999');
							}
							if(data.emr.curePicList == ''){
								var str = '<img src="../images/post_no picture@2x.png" >';
								$('.img_warp').html(str);
hanpeng committed
143
							}else{
hanpeng committed
144 145 146 147 148
								var html = '';
								for(var i = 0;i <data.emr.curePicList.length;i++){
									html +=' <img src="'+data.emr.curePicList[i]+'" >'
								}
								$('.img_warp').html(html);
hanpeng committed
149
							}
hanpeng committed
150 151 152 153 154
						}else{
							//无病历信息
							$('.user_patient_info_detail').hide();
							$('.add_new_patient').show();
							$('body').css('background','#fff');
hanpeng committed
155
						}
hanpeng committed
156 157 158
					}
				}
			})
hanpeng committed
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
		},
		//获取微信票据
		getWechatTicket: function() {
			medtap.submitAjax({
				url: 'https://testdevgw.medtap.cn/wechat/lung/fetchWechatTicket',
				type: 'GET',
				async: false,
				data: {
					url: window.location.href
				},
				success: function(res) {
					var data = res.content;
					wx.config({
						debug: false,
						appId: data.appId, // 必填,公众号的唯一标识
						timestamp: data.timestamp, // 必填,生成签名的时间戳
						nonceStr: data.nonceStr, // 必填,生成签名的随机串
						signature: data.signature, // 必填,签名,见附录1
						jsApiList: [
							'previewImage'
						]
					})
				}
			})
		}, 
		//图片预览
		previewImage: function() {
			$('.img_warp').on('click', 'img', function() {
				var imgArray = [];
				var curImageSrc = $(this).attr('src');
				if (curImageSrc) {
					$('.img_warp img').each(function(index, el) {
						var itemSrc = $(this).attr('src');
						imgArray.push(itemSrc);
					});
					wx.previewImage({
						current: curImageSrc,
						urls: imgArray
					});
				}
			});
hanpeng committed
200 201 202
		}
	}
	myEmr.init();
hanpeng committed
203
	myEmr.previewImage();
hanpeng committed
204
})