
$(function(){
	$('#hospitalButton').hide();
	var isSTpa= $('#isSTpa').val();
	if(isSTpa == "false"){
		 isSTpa=false;
	}
	if(isSTpa == "true"){
		 isSTpa=true;
	}
	
	if(isSTpa){
		$('#hospitalButton').show();
	}
	
	 $.ajax({
			
		 type:"POST",
		 url:"getProvince.do",
		 data:"",
		 error:function(){
			 alert("获取省份失败");
			 return;
		 },
		 success:function(data){
			 
			 for(var i=0;i<data.length;i++){
				 var province = data[i];
				 $("#provinceContext").append("<li id="+province.cityCode+" onclick=\"getProvinceCode(this)\">"+province.cityName+"</li>");
			 }
			 $(".select").find(".sel_list li").hover( function (){
					$(this).addClass("sel_hov");		
				},function (){
					$(this).removeClass("sel_hov");	
				}).on('click',function(){
					var _this = $(this).html();
					
					var _thisText = $(this).closest(".select").find(".sel_text");
					_thisText.html(_this);
					
				});
		 }
	 });
	 
	 $('#hospitalResultDivId .select').unbind("click");
	 
	 
	 
});


function submitEventForm(){
	
	if(checkInfo()){
		$("#claimEventForm").submit();
	}
}
function checkInfo(){
	var accsby_ = $("#accTypesBy_").val();
	if(accsby_==""||accsby_==undefined){
		alert("请选择索赔事故性质。");
		return false;
	}
	if($("#pregnancyMemo").val().length>200){
		alert("怀孕信息情况字数超限，应为200字。");
		return;
	} 
	var accs = accsby_.split("_");
	for ( var i = 0; i < accs.length; i++) {
		if($("#claimIllsBy_").val()==""){
			alert("请选择疾病诊断信息。");
			return false;
		}
		if(accs[i]=="01"){
			if($("#deadDate").val()==""){
				alert("请选择身故日期。");
				return false;
			}
		}else if(accs[i]=="02"){
			if($("#visitDate").val()==""){
				alert("请选择就诊日期。");
				return false;
			}
			if($("#maimDate").val()==""){
				alert("请选择伤残鉴定日期。");
				return false;
			}
			if($("#hospitalCode").val()==""){
				alert("请选择就诊医院。");
				return false;
			}
			if($("#socialMedicalType").val()==""){
				alert("请选择医保类型。");
				return false;
			}
		}else if(accs[i]=="03"){
			if($("#visitDate").val()==""){
				alert("请选择就诊日期。");
				return false;
			}
			if($("#hospitalCode").val()==""){
				alert("请选择就诊医院。");
				return false;
			}
			if($("#socialMedicalType").val()==""){
				alert("请选择医保类型。");
				return false;
			}
			if($("#illnessCode").val()==""){
				alert("请选择重疾代码。");
				return false;
			}
		}else if(accs[i]=="04"){
			if($("#visitDate").val()==""){
				alert("请选择就诊日期。");
				return false;
			}
			if($("#hospitalCode").val()==""){
				alert("请选择就诊医院。");
				return false;
			}
			if($("#socialMedicalType").val()==""){
				alert("请选择医保类型。");
				return false;
			}
		}else if(accs[i]=="05"){
			if($("#visitDate").val()==""){
				alert("请选择就诊日期。");
				return false;
			}
			if($("#hospitalCode").val()==""){
				alert("请选择就诊医院。");
				return false;
			}
			if($("#socialMedicalType").val()==""){
				alert("请选择医保类型。");
				return false;
			}if($("#admissionDate").val()==""){
				alert("请选择入院日期。");
				return false;
			}
			if($("#dischargeDate").val()==""){
				alert("请选择出院医院。");
				return false;
			}
			if($("#hospitalizedDays").val()==""){
				alert("请选择住院天数。");
				return false;
			}  
		}
	}
	return true;
}
function dispatchClaimPage(){
	 $("#claimEventForm").attr("action","dispatcherClmInfoByMyTask.do");
	 $("#claimEventForm").submit();
}
function afterClaimPage(){
	$("#skipFlag").val("Y");
	 $("#claimEventForm").attr("action","dispatcherClmInfoByMyTask.do");
	 $("#claimEventForm").submit();
}

function dispatcherReceiptPage(receiptNo){
	$("#receiptNo").val(receiptNo);
	$("#claimEventForm").attr("action","dispatcherReceiptPage.do");
	$("#claimEventForm").submit();
}
/** 时间组件初始化 */
function dateCompInit(){
//	var date = new Date();
//	date.setDate(date.getDate()-1);
	$('#accidentDate').datepicker({
	 	yearRange:"-10:+10",
		duration:'fast',
		constrainInput:true,
		changeMonth:true,
		dateFormat:'yy-mm-dd',
		showButtonPanel:true,
		changeYear:true,
		maxDate:null,
		showAnim: ''
	    //onSelect:function(dateText,inst){}
	});	
	$('#firstDiagnoseDate').datepicker({
	 	yearRange:"-10:+10",
		duration:'fast',
		constrainInput:true,
		changeMonth:true,
		dateFormat:'yy-mm-dd',
		showButtonPanel:true,
		changeYear:true,
		maxDate:null,
		showAnim: ''
	    //onSelect:function(dateText,inst){}
	});	
}
//身故
function shenggu(a){
	if($('#shenggu').attr('class')=="re_icon1"){
		$('#shenggu').attr('class','re_icon1 re_icon1_cur');
		saveClaimAcc('add','01');
	}else{
		$('#shenggu').attr('class','re_icon1');
		saveClaimAcc('del','01');
	}
}
//伤残
function shangchang(a){
	if($('#shangchang').attr('class')=="re_icon2"){
		$('#shangchang').attr('class','re_icon2 re_icon2_cur');
		saveClaimAcc('add','02');
	}else{
		$('#shangchang').attr('class','re_icon2');
		saveClaimAcc('del','02');
	}
}
//重大疾病
function zhongda(a){
	if($('#zhongda').attr('class')=="re_icon3"){
		$('#zhongda').attr('class','re_icon3 re_icon3_cur');
		saveClaimAcc('add','03');
	}else{
		saveClaimAcc('del','03');
		$('#zhongda').attr('class','re_icon3');
	}
}
//门争论医疗
function menzhen(a){
	if($('#menzhen').attr('class')=="re_icon4"){
		$('#menzhen').attr('class','re_icon4 re_icon4_cur');
		saveClaimAcc('add','04');
	}else{
		$('#menzhen').attr('class','re_icon4');
		saveClaimAcc('del','04');
	}
	
}
//住院医疗
function zhuyuanyiliao(a){
	if($('#zhuyuanyiliao').attr('class')=="re_icon5"){
		$('#zhuyuanyiliao').attr('class','re_icon5 re_icon5_cur');
		saveClaimAcc('add','05');
	}else{
		$('#zhuyuanyiliao').attr('class','re_icon5');
		saveClaimAcc('del','05');
	}
}
//住院补贴
function zhuyuanbutie(a){
	if($('#zhuyuanbutie').attr('class')=="re_icon6"){
		$('#zhuyuanbutie').attr('class','re_icon6 re_icon6_cur');
		saveClaimAcc('add','06');
	}else{
		$('#zhuyuanbutie').attr('class','re_icon6');
		saveClaimAcc('del','06');
	}
}

function nvxingshengyu(a){
	if($('#nvxingshengyu').attr('class')=="re_icon7"){
		$('#nvxingshengyu').attr('class','re_icon7 re_icon7_cur');
		saveClaimAcc('add','07');
	}else{
		$('#nvxingshengyu').attr('class','re_icon7');
		saveClaimAcc('del','07');
	}
}  
function dentisty(a){
	if($('#dentisty').attr('class')=="re_icon8"){
		$('#dentisty').attr('class','re_icon8 re_icon8_cur');
		saveClaimAcc('add','08');
	}else{
		$('#dentisty').attr('class','re_icon8');
		saveClaimAcc('del','08');
	}
}
function onculist(a){
	if($('#onculist').attr('class')=="re_icon9"){
		$('#onculist').attr('class','re_icon9 re_icon9_cur');
		saveClaimAcc('add','09');
	}else{
		$('#onculist').attr('class','re_icon9');
		saveClaimAcc('del','09');
	}
}
function dabingmenzhen(a){
	if($('#dabingmenzhen').attr('class')=="re_icon11"){
		$('#dabingmenzhen').attr('class','re_icon11 re_icon11_cur');
		saveClaimAcc('add','11');
	}else{
		$('#dabingmenzhen').attr('class','re_icon11');
		saveClaimAcc('del','11');
	}
}
function jinjiyake(a){
	if($('#jinjiyake').attr('class')=="re_icon10"){
		$('#jinjiyake').attr('class','re_icon10 re_icon10_cur');
		saveClaimAcc('add','10');
	}else{
		$('#jinjiyake').attr('class','re_icon10');
		saveClaimAcc('del','10');
	}
}

function checksp(id){
	if($("#"+id).is(".check_no")){
		$("#"+id).attr("class","check_yes");
	}else{
		$("#"+id).attr("class","check_no");
	}
}

	/**疾病诊断保存*/
	function saveDiv(id) {
		var jibing = 0;
		var jbname="";
		$("#jbresultData").html("");
		$("#claimIllsBy_").val("");
		$("#jbzd").find("span").each(function() {
			if ($(this).is(".check_yes")){
				if(jibing==0){
					jbname = $(this).attr("title")+$(this).attr("name");
					$("#claimIllsBy_").val($(this).attr("title"));
				}else{
					$("#claimIllsBy_").val($("#claimIllsBy_").val()+'_'+$(this).attr("title"));
				}
				jibing = jibing+1;
				$("#jbresultData").append("<tr>" +
						"<td width=\"23%\">"+$(this).attr("title")+"</td>" +
						"<td width=\"45%\">"+$(this).attr("name")+"</td>" +
						"<td width=\"21%\"><a  style=\"cursor: pointer;\" class=\"icon_del\" onclick=\"deljbresultData(this,'"+$(this).attr("title")+"')\"></a></td>" +
						"</tr>");
			}
		});

		$("#clmIll").val(jbname);
		if(jibing>1)
			$("#clmIll").val(jbname+"....");
		$.closePopupLayer(id);
	}
	
	/**重疾代码保存*/
	function saveZJDiv(id) {
		var jibing = 0;
		var jbname="";
		$("#zjresultData").html("");
		//重疾代码以“_”分隔
		$("#illnessCode").val("");
		$("#zjdm").find("span").each(function() {
			if ($(this).is(".check_yes")){
				if(jibing==0){
					jbname = $(this).attr("title")+$(this).attr("name");
					$("#illnessCode").val($(this).attr("title"));
				}else{
					$("#illnessCode").val($("#illnessCode").val()+'_'+$(this).attr("title"));
				}
				jibing = jibing+1;
				$("#zjresultData").append("<tr>" +
						"<td width=\"23%\">"+$(this).attr("title")+"</td>" +
						"<td width=\"45%\">"+$(this).attr("name")+"</td>" +
						"<td width=\"21%\"><a href=\"#\" class=\"icon_del\" onclick=\"delzjresultData(this,'"+$(this).attr("title")+"')\"></a></td>" +
						"</tr>");
			}
		});

		$("#zjClmIll").val(jbname);
		if(jibing>1)
			$("#zjClmIll").val(jbname+"....");
		$.closePopupLayer(id);
	}
	
	
	function saveHospital(id) {
		var hospital = 0;
		var hospitalName="";
		var hospitalCode="";
		$("#hospitalInfoList").find("span").each(function() {
			if ($(this).is(".check_yes")){
				if(hospital==0){
					hospitalName = $(this).attr("name");
					hospitalCode = $(this).attr("id");
					$("#hospitalCode").val(hospitalCode);
					$("#hospitalName").val(hospitalName);
					hospital=1;
				}
				else {
					alert("只允许选择一个医院");
					$(this).attr("class","check_no");
				}
			}
		});

		$.closePopupLayer(id);
	}
	
	function saveSurgery(id) {
		var surgery = 0;
		var surgeryCode="";
		$("#surgeryInfoList").find("span").each(function() {
			if ($(this).is(".check_yes")){
				if(surgery==0){
					surgeryCode = $(this).attr("title");
					surgeryName = $(this).attr("name");
					$("#surgeryCode").val(surgeryCode); 
					$("#surgeryName").val(surgeryName); 
					surgery=1;
				}
				else {
					alert("只允许选择一个手术");
					$(this).attr("class","check_no");
				}
			}
		});

		$.closePopupLayer(id);
	}
	
	
	function deljbresultData(data,title){
		if(confirm("是否删除当前行！")){
			var trcurrent = $(data).parent().parent();
			trcurrent.remove();
			
			var jb = 0;
			var jbname="";
			$("#claimIllsBy_").val("");
			$("#jbzd").find("span").each(function() {
				if ($(this).is(".check_yes")){
					if(title==$(this).attr("title")){
						$(this).attr("class","check_no");
					}else{
						if(jb==0){
							jbname = $(this).attr("title")+$(this).attr("name");
							$("#claimIllsBy_").val($(this).attr("title"));
						}else{
							$("#claimIllsBy_").val($("#claimIllsBy_").val()+'_'+$(this).attr("title"));
						}
						jb = jb+1;
					}
				}
			});
			var tr = $("#jbresultData").find("tr");
			if(tr.length>1){
				var code = $(tr[0]).find("td:eq(0)");
				var name = $(tr[0]).find("td:eq(1)");
				$("#clmIll").val(code.text()+" "+name.text()+"....");
			}else if(tr.length==1){
				var code = $(tr[0]).find("td:eq(0)");
				var name = $(tr[0]).find("td:eq(1)");
				$("#clmIll").val(code.text()+" "+name.text());
			}else{
				$("#clmIll").val("");
			}
			
		}
	}
	
	//重疾代码删除
	function delzjresultData(data,title){
		if(confirm("是否删除当前行！")){
			var trcurrent = $(data).parent().parent();
			trcurrent.remove();
			
			var jb = 0; 
			$("#illnessCode").val("");
			$("#zjdm").find("span").each(function() {
				if ($(this).is(".check_yes")){
					if(title==$(this).attr("title")){
						$(this).attr("class","check_no");
					}else{
						if(jb==0){
							$("#illnessCode").val($(this).attr("title"));
						}else{
							$("#illnessCode").val($("#illnessCode").val()+'_'+$(this).attr("title"));
						}
						jb = jb+1;
					}
				}
			});
			
			var tr = $("#zjresultData").find("tr");
			if(tr.length>1){
				var code = $(tr[0]).find("td:eq(0)");
				var name = $(tr[0]).find("td:eq(1)");
				$("#zjClmIll").val(code.text()+" "+name.text()+"....");
			}else if(tr.length==1){
				var code = $(tr[0]).find("td:eq(0)");
				var name = $(tr[0]).find("td:eq(1)");
				$("#zjClmIll").val(code.text()+" "+name.text());
			}else{
				$("#zjClmIll").val("");
			}
		}
	}
	
	/**数据判断是否存在值如果存在则删除掉
	 * @param arr
	 * @param val
	 * @returns {Boolean}
	 */
	function isCon(arr, val){
		for(var i=0; i<arr.length; i++){
			if(arr[i] == val){
				arr.splice(i,1); 
				return true;
			}
				
		}
		return false;
	}
	
	function checkDeadDateNotNull(){
		if($("#deadDate").val()==''){
			return false;
		}else{
			return true;
		}
		
	}
	
	function checkVisitDateNotNull(){
		if($("#visitDate").val()==''){
			return false;
		}else{
			return true;
		}
		
	}
	
	function checkMaimDateNotNull(){
		if($("#maimDate").val()==''){
			return false;
		}else{
			return true;
		}
		
	}
	
	function checkHospitalNameNotNull(){
		if($("#hospitalName").val()==''){
			return false;
		}else{
			return true;
		}
		
	}
	
	function checkSocialMedicalTypeNotNull(){
		if($("#socialMedicalType").val()==''){
			return false;
		}else{
			return true;
		}
		
	}
	
	function checkIllnessCodeNotNull(){
		if($("#illnessCode").val()==''){
			return false;
		}else{
			return true;
		}
		
	}
	
	function checkAdmissionDateNotNull(){
		if($("#admissionDate").val()==''){
			return false;
		}else{
			return true;
		}
		
	}
	
	function checkDischargeDateNotNull(){
		if($("#dischargeDate").val()==''){
			return false;
		}else{
			return true;
		}
		
	}
	
	function checkHospitalizedDaysNotNull(){
		if($("#hospitalizedDays").val()==''){
			return false;
		}else{
			return true;
		}
		
	}
	
	function checkClmIllNotNull(){
		if($("#clmIll").val()==''){
			return false;
		}else{
			return true;
		}
		
	}
	
	
	function claimEventCheckBox(dataId){
		if($("#"+dataId).is(".radio_no")){
			//医保类型
			if(dataId=="haveSocialMedical"){
				$("#notHaveSocialMedical").removeClass().addClass("radio_yes");
				$("#haveSocialMedical").removeClass().addClass("radio_no");
				$("#socialMedicalType").val("1");
			}
			if(dataId=="notHaveSocialMedical"){
				$("#haveSocialMedical").removeClass().addClass("radio_yes");
				$("#notHaveSocialMedical").removeClass().addClass("radio_no");
				$("#socialMedicalType").val("2");
			} 
			//是否转诊
			if(dataId=="changeHospital"){
				$("#notChangeHospital").removeClass().addClass("radio_yes");
				$("#changeHospital").removeClass().addClass("radio_no");
				$("#isChangeHospital").val("Y");
			}
			if(dataId=="notChangeHospital"){
				$("#changeHospital").removeClass().addClass("radio_yes");
				$("#notChangeHospital").removeClass().addClass("radio_no");
				$("#isChangeHospital").val("N");
			}
			//预期是否单胎
			if(dataId=="singleEmbryo"){
				$("#notSingleEmbryo").removeClass().addClass("radio_yes");
				$("#singleEmbryo").removeClass().addClass("radio_no");
				$("#isSingleEmbryo").val("Y");
			}
			if(dataId=="notSingleEmbryo"){
				$("#singleEmbryo").removeClass().addClass("radio_yes");
				$("#notSingleEmbryo").removeClass().addClass("radio_no");
				$("#isSingleEmbryo").val("N");
			}
			//是否使用妊娠辅助医疗或人工授精 
			if(dataId=="useAssistMedical"){
				$("#notUseAssistMedical").removeClass().addClass("radio_yes");
				$("#useAssistMedical").removeClass().addClass("radio_no");
				$("#isUseAssistMedical").val("Y");
			}
			if(dataId=="notUseAssistMedical"){
				$("#useAssistMedical").removeClass().addClass("radio_yes");
				$("#notUseAssistMedical").removeClass().addClass("radio_no");
				$("#isUseAssistMedical").val("N");
			}
		}
	}
	function initclaimacc(){
		//accTypesBy_
		var accTypesStr = $("#accTypesBy_").val();
		var accTypes = accTypesStr.split("_");
		var i = 0 ;
		for(; accTypes != '' && i < accTypes.length ; i++ ){
			if(accTypes[i]=="01"){
    			$('#shenggu').attr('class','re_icon1 re_icon1_cur');
    		}
    		if(accTypes[i]=="02"){
    			$('#shangchang').attr('class','re_icon2 re_icon2_cur'); 
    		}
    		if(accTypes[i]=="03"){
    			$('#zhongda').attr('class','re_icon3 re_icon3_cur');
    		}
    		if(accTypes[i]=="04"){
    			$('#menzhen').attr('class','re_icon4 re_icon4_cur');
    		}
    		if(accTypes[i]=="05"){
    			$('#zhuyuanyiliao').attr('class','re_icon5 re_icon5_cur');
    		}
    		if(accTypes[i]=="06"){
    			$('#zhuyuanbutie').attr('class','re_icon6 re_icon6_cur');
    		}
    		if(accTypes[i]=="07"){
    			$('#nvxingshengyu').attr('class','re_icon7 re_icon7_cur');
    		}if(accTypes[i]=="08"){
    			$('#dentisty').attr('class','re_icon8 re_icon8_cur');
    		}if(accTypes[i]=="09"){
    			$('#onculist').attr('class','re_icon9 re_icon9_cur');
    		}if(accTypes[i]=="11"){
    			$('#jinjiyake').attr('class','re_icon10 re_icon10_cur');
    		}if(accTypes[i]=="10"){
    			$('#dabingmenzhen').attr('class','re_icon11 re_icon11_cur');
    		}
    		if(accTypes[i]=="12"){
    			$('#yaofanggouyao').attr('class','re_icon12 re_icon12_cur');
    		}
    		if(accTypes[i]=="13"){
    			$('#tijian').attr('class','re_icon13 re_icon13_cur');
    		}
    		if(accTypes[i]=="14"){
    			$('#girlDisease').attr('class','re_icon14 re_icon14_cur');
    		}
    		if(accTypes[i]=="15"){
    			$('#aizibing').attr('class','re_icon15 re_icon15_cur');
    		}
    		if(accTypes[i]=="16"){
    			$('#jinjiyiliao').attr('class','re_icon16 re_icon16_cur');
    		}
    		if(accTypes[i]=="17"){
    			$('#tijianyumiao').attr('class','re_icon17 re_icon17_cur');
    		}
    		if(accTypes[i]=="18"){
    			$('#xiantianxingjibing').attr('class','re_icon18 re_icon18_cur');
    		}
    		if(accTypes[i]=="19"){
    			$('#xinxueguan').attr('class','re_icon19 re_icon19_cur');
    		}
            if(accTypes[i]=="20" ){
                $( '#guzhe').attr('class' ,'re_icon20 re_icon20_cur');
            }

		}
		
	}
	
	function saveClaimAcc(method,value){
		if(method=='add'){
			var accTypesStr = $("#accTypesBy_").val();
			var accTypes = accTypesStr.split("_");
			var i = 0 ;
			//判断是否已经保存了这个 索赔事故性质
			var flag = 0;
			for(; accTypes != '' && i < accTypes.length ; i++ ){
				if(accTypes[i]==value){
					flag = 1;
					break;
				}
			}
			if(flag==0){
				if($("#accTypesBy_").val()==''){
					$("#accTypesBy_").val(value);
				}else{
					$("#accTypesBy_").val($("#accTypesBy_").val()+"_"+value);
				}
			}
		}
		
		if(method=='del'){
			var accTypesStr = $("#accTypesBy_").val();
			var accTypes = accTypesStr.split("_");
			var i = 0 ;
			//判断是否已经保存了这个 索赔事故性质
			var flag = 0;
			for(; accTypes != '' && i < accTypes.length ; i++ ){
				if(accTypes[i]==value){
					accTypes[i] = '00';
					flag = 1;
					break;
				}
			}
			if(flag==1){
				var accTypesNew = '';
				i = 0;
				var position = 0;
				for(; accTypes != '' && i < accTypes.length ; i++ ){
					if(accTypes[i]!='00'){
						if(position==0){
							accTypesNew = accTypes[i];
						}else{
							accTypesNew = accTypesNew + '_' + accTypes[i];
						}
						position++; 
					}
				}
				
				$("#accTypesBy_").val(accTypesNew);
			}
		}
		
	}

	
	//事件删除
	var index=0;
	function delTr(){ 
		var tr = $("#rcptBillTBL tr:eq("+index+")");
		var trId=tr.attr("id");
		if(trId!=""&&trId!=undefined){
			if(confirm("是否删除此收据信息？")){
				$.ajax({
					type:"POST",
					url:"delRcptBillInfo.do",
					data:'rcptNo='+trId,
					error :function(){
					},
					success :function(data){
						if(data=="00"){
							alert("删除收据信息成功！");
							if(index!=0){
								$("#rcptBillTBL tr:eq("+index+")").remove();
								index=0;
							}
						}else{
							alert("系统异常，删除收据信息失败。");
						}
					}
				});
			}
			
		}
	}
	function choosEd(flag){
		 
		$(flag).css("background-color", "#e5e5e5").siblings().css("background-color", "#FFFFFF");
		index=$(flag).index();
	}
	
	
	/**继续添加事件信息 **/
	
//	function goonAddEventInfo(){
//		$("#claimEventForm").attr("action","dispatcherEventPage.do");
//		$("#claimEventForm").submit();
//		
//	}
	
	
	/**
	 * 729需求 cyj新增
	 */
	  function showHospitalDetailDiv(){
		  $('#hospitalButton').attr("disabled",true);
		  //AJAX通过医院代码 hospitalCode 获取所选医院
		 	 $.ajax({
		 		 type:"POST",
		 		 url:"getHospitalObj.do",
		 		 data:{"hospitalCode":$("#hospitalCode").val()},
		 		 error:function(){
		 			$('#hospitalButton').attr("disabled",false);
		 			 alert("获取医院信息错误");
		 			 return;
		 		 },
		 		 success:function(data){
		 			
			 			if((data==null)||(data.length==0)){
			 				$('#hospitalButton').attr("disabled",false);
			 				alert("无就诊医院");
			 			}
		 			 
		 		if(data.length>0){
		 				 
		 			 var hospital = data[0];
		 			 //送入信息至输入框
		 			 $("#head-or-branch").html(hospital.headOrBranchCN);
		 			 $("#head-or-branch").attr("code",hospital.headOrBranch);
		 			 $("#hospital-level-code").attr("code",hospital.hospitalLevelCode);
		 			 
		 			 //医保类别
		 			 $("#medical-insurance-type").html(hospital.medicalInsuranceTypeCN);
		 			 $("#medical-insurance-type").attr("code",hospital.medicalInsuranceType);
		 			 
		 			 $("#hospital-level-code").html(hospital.hospitalLevelString);
		 			 $("#hospital-economic-type").html(hospital.hospitalEconomicTypeCN);
		 			 $("#hospital-economic-type").attr("code",hospital.hospitalEconomicType);
		 			 
		 			 $("#hospital-hospitalName").val(hospital.hospitalName);
		 			 
		 			 if(hospital.hosProvinceString!=null&&hospital.hosProvinceString!=""){
		 				 $("#province").html(hospital.hosProvinceString);
		 			 }else{
		 				 $("#province").html("请选择");
		 			 }
		 			 
		 			 if(hospital.hosCityString != null && hospital.hosCityString != ""){
		 				 $("#citySpan").html(hospital.hosCityString);
		 			 }else{
		 				 $("#citySpan").html("请选择");
		 			 }
		 			 
		 			 $("#hosProvince").val(hospital.hosProvince);
		 			 $("#province").attr("provcode",hospital.hosProvince);
		 			 $("#citySpan").attr("citycode",hospital.hosCityCode);
		 			 $("#hosCityCode").val(hospital.hosCityCode);
		 			 $("#hosAddress").val(hospital.hosAddress);
		 			 $("#hosContactPhone").val(hospital.hosContactPhone);
		 			 $("#hostPostcode").val(hospital.hosPostcode);
		 			 $("#hospcode").html(hospital.hospitalLevelString);//医院等级中文
		 			 $("#hospitalLevelCode").val(hospital.hospitalLevelCode);//医院等级代码
		 			 $("#hospAttr").html(hospital.hospitalAttrString);//医院属性中文
		 			 $("#hospitalAttrCode").val(hospital.hospitalAttrCode);//属性代码
		 			 $("#hospCap").html(hospital.hospitalCapitalString);//医院性质名称
		 			 $("#hospitalCapitalCode").val(hospital.hospitalCapitalCode);//医院性质code
		 			 $("#keyDepartment").val(hospital.keyDepartment);//
		 			 $("#isBlacklist").html(hospital.isBlacklist);
		 			 $("#isSpecialHospital").html(hospital.isSpecialHospital);
		 			 $("#addBlacklistReason").val(hospital.addBlacklistReason);
		 			 
		 			 //显示操作员
		 			 
		 			 //先清空缓存的操作员信息
		 			 $("#addBlacklistUser").html("");
		 			 $("#delBlacklistUser").html("");
		 			 
		 			 if(hospital.addBlacklistUser!=""&&hospital.addBlacklistUser!=null){
		 				 $("#addBlacklistUser").html(hospital.addBlacklistUser+" "+hospital.addBlacklistUserName);
		 			 }
		 			 $("#addBlacklistDate").html(hospital.addBlacklistShowDate);
		 			 $("#delBlacklistDate").html(hospital.delBlacklistShowDate);
		 			 
		 			 if(hospital.delBlacklistUser!=""&&hospital.delBlacklistUser!=null){
		 			 $("#delBlacklistUser").html(hospital.delBlacklistUser+" "+hospital.delBlacklistUserName);
		 			 }
		 			 showDiv('hospitalResultDivId');
		 			$('#hospitalButton').attr("disabled",false);
		 			 }		
		 		
		 		
		 		$('#hospitalButton').attr("disabled",false);
		 		 }
		 	 });

		  
			
	  }
	
	  
	  //根据是否黑名单,禁用加入黑名单原因
	  function autoTextarea(elements){
	 	 var id = elements.id;
	 	 if(id=="N"){
	 		 $("#addBlacklistReason").val("");
	 		 $("#addBlacklistReason").attr("disabled",true);
	 		 
	 	 }else{
	 		 $("#addBlacklistReason").attr("disabled",false);
	 	 }
	  }
	  
	//根据所选省份获取市
	  function findCity(provinceCode){
	 	 $("#citySpan").html("请选择市");
	 	 $("#cityContext").html("");
	 	 $.ajax({
	 		 type:"POST",
	 		 url:"findCity.do",
	 		 data:{"provinceCode":provinceCode},
	 		 error:function(){
	 			 alert("获取市级单位失败");
	 			 return;
	 		 },
	 		 success:function(data){
	 			 for(var i=0;i<data.length;i++){
	 				 var city = data[i];
	 				 $("#cityContext").append("<li id=\""+city.cityCode+"\" onclick=\"getCityCode(this)\">"+city.cityName+"</li>");
	 			 }
	 			 //选中
	 			 $(".select").find(".sel_list li").hover( function (){
	 					$(this).addClass("sel_hov");		
	 				},function (){
	 					$(this).removeClass("sel_hov");	
	 				}).on('click',function(){
	 					var _this = $(this).html();
	 					
	 					var _thisText = $(this).closest(".select").find(".sel_text");
	 					_thisText.html(_this);
	 					
	 				});
	 		 }
	 		 
	 	 });
	  }
	  
	  //获取所选省份
	  var provinceName = null;
	  var provinceCode = null;
	  function getProvinceCode(obj){
	 	 provinceCode = obj.id;
	 	 
	 	 $("#hosCityCode").val("");
	 	 cityCode = "";
	 	 $("#hosProvince").val(provinceCode);
	 	 provinceName = obj.innerHTML;
	 	 findCity(provinceCode);
	  }

	 //获取所选市的代码
	  var cityCode = null;
	  function getCityCode(obj){
	 	 cityCode = obj.id;
	 	 $("#hosCityCode").val(cityCode);
	  }
	  
	  
	  //如果是定点医院，就加跳转链接至定点医院查询页面
	  function specialHospitalSkip(value,id,hospitalCode){
	 	 if(value=="Y"){
	 		 $("#"+id).html("<a onclick=\"SkipByPost(\'designatedHospitalSearch.do\',{hospitalCode:\'"+hospitalCode+"\'})\" style='color:blue'>是</a>");
	 	 }else{
	 		 $("#"+id).html("否");
	 	 }
	  }
	  

	  
	
	
	
	