//判断是否是ie8
var isIE = function(ver) {
	var b = document.createElement('b')
	b.innerHTML = '<!--[if IE ' + ver + ']><i></i><![endif]-->'
	return b.getElementsByTagName('i').length === 1
}
//初始化函数
$(function(){
	$('.contentDiv').css('height', '100%').css('height', '-=140px');
	var ie = isIE(8);
	if(ie) {
		//ie8加载iframe
		$("#iframe").prop("src",path+"/font/showRecordIframeFontSouth?patientId="+$("#patientId").val()+"&flag=file_path");
	}else{
		//谷歌
		$("#iframe").prop("src",path+"/commom/showRecordIframeSouth?patientId="+$("#patientId").val()+"&flag=file_path"+"&rootPaths="+$("#rootPaths").val());
	}
	//加载其他诊断名称鼠标滑过显示全部文本
	//loadQtip('.otherDiagName');
	//加载病案信息
	loadRecord();
	//加载住院次数
	loadAdmissTimes();
})

//加载病案信息
function loadRecord(){
	$.ajax({
		type:'get',
		url:path+'/commom/getRecord',
		data:{patientId:$("#patientId").val(),flag:$("#flag").val()},
		async:false,
		dataType:'json',
		success:function (data) {
			if(null != data && data != ''){
				$("#inpatientNo").val(data.inpatientNo);
				$("#name").val(data.name);
				$("#admissTimes1").val(data.admissTimes);
				$("#inpatientNo1").val(data.inpatientNo);
				$("#name1").val(data.name);
				$("#admissTimesValue").val(data.admissTimes);
				$("#disDate").val(data.disDate);
				$("#disDeptName").val(data.disDept);
				$("#diagName").val(data.mainDiagName);
				$("#otherDiagName").val(data.otherDiagName);
				//判断哪家医院赋值扫描图片和新上传图片的根目录集合
				var flag = $("#flag").val();
				var rootPaths = "";
				if(flag != '' && flag == 'home_addr'){
					//脐血库
					rootPaths = data.homeAddr + ",";
				}else if(flag != '' && flag == 'file_path'){
					//祈福医院
					rootPaths = data.filePath + ",";
				}
				//拼接新上传图片根目录
				if(data.newFile != null && data.newFile != ''){
					rootPaths += data.newFile;
				}
				$("#rootPaths").val(rootPaths);
			}
		}
	})
}

//加载住院次数
function loadAdmissTimes(){
	$.ajax({
		type:'get',
		url:path+'/commom/getAdmissTimes',
		data:{name:$("#name").val(),inpatientNo:$("#inpatientNo").val()},
		dataType:'json',
		success:function (data) {
			if(null != data && data != ''){
				$("#admissTimes").empty();
				var html = '';
				for (var i = 0; i < data.length; i++) {
					if($("#admissTimesValue").val() == (data[i].admissTimes)){
						html += '<option value="'+data[i].admissTimes+'" selected>'+data[i].admissTimesName+'</option>';
					}else{
						html += '<option value="'+data[i].admissTimes+'">'+data[i].admissTimesName+'</option>';
					}
				}
				$("#admissTimes").append(html);
			}
		}
	})
}

