<%@ include file="/project/include.jsp" %>

<center>
<shell:fieldset title="Informazioni generali">
	<table border="0" cellspacing="3" cellpadding="0" width="100%" >
		<tr>
			<td class="form-label">
				<shell:label prop="dataCollocazione" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="dataDiagnosi" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="dataCollocazione">
						<j:text class="form-date" id="dataCollocazioneCLD" onChange="getOperatoriRiferimento('storicizzaOperatoreRiferimento');" />
						<shell:calendar inputId="dataCollocazioneCLD" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>
 		</tr>
	
		<tr>
			<td class="form-label">
				<shell:label prop="patologia" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="patologia" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="patologia">
						<j:select class="form-input" emptyOptionDescr=" " onChange="impostaICD9()" id="id_patologia"/>
						<shell:error />
					</j:bind>
				</bui:out>	
			</td>
		</tr>
	
		<tr>
			<td class="form-label">
				<shell:label prop="icd9" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="icd9" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="codiceIcd9">
						<j:text id="codice_prICD9" class="form-short-text" onBlur="javascript:onChangeIcd9(this, 'icd9');" /> 
						<shell:lookup lookupId="prICD9" identifier="tabelle.tabella" 
							init="it.cedaf.icare.tabelle.control.initializer.ICD9LookupInitializer" 
							formParams="codice_prICD9|codice" />
						<j:tile slave="${_slave}" name="shell.plaintext" prop="icd9" />
						<input type="hidden" id="descrizione_prICD9"/>
						<shell:error />
					</j:bind>
				</bui:out>	
			</td>
		</tr>	
	
		<tr>
			<td class="form-label">
				<shell:label prop="tipoFonte" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="tipoFonte" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="tipoFonte">
						<j:select class="form-input" emptyOptionDescr=" " />
						<shell:error />
					</j:bind>
				</bui:out>	
			</td>
		</tr>
	
		<tr>
			<td class="form-label">
				<shell:label prop="fonte" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="fonte" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="fonte">
						<j:text class="form-long-text" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>
 		</tr>
	
		<tr>
			<td class="form-label">
				<shell:label prop="dataDimissione" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="dataDimissione" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="dataDimissione">
						<j:text class="form-date" id="dataDimissioneCLD" />
						<shell:calendar inputId="dataDimissioneCLD" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>
 		</tr>
	
		<tr>
			<td class="form-label">
				<shell:label prop="motivoDimissione" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="motivoDimissione" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="motivoDimissione">
						<j:select class="form-input" emptyOptionDescr=" " />
						<shell:error />
					</j:bind>
				</bui:out>	
			</td>
		</tr>
	</table>
	</td>
	<td valign="top">
		<table border="0" cellpadding="0" cellspacing="3">
		<j:tile name="commons.opRifStoricizzato" objectName="RegistroPatologia" idField="idPatologia"/>
		<j:tile name="commons.opAbilitato" objectName="RegistroPatologia" idField="idPatologia"/>
	</table>		
</shell:fieldset>

<shell:fieldset title="Informazioni aggiuntive">
	<table border="0" cellspacing="3" cellpadding="0" width="100%" >
		<tr>
			<td class="form-label">
				<shell:label prop="note" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="note" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="note">
						<j:textarea class="form-normal-textarea" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>
		</tr>
	</table>
</shell:fieldset>

</center>


<script type="text/javascript">
function onChangeIcd9(txtIcd9, idTag) {
	var codIcd9 = txtIcd9.value;
	var textValue = '';
	if (codIcd9 != '') {
		textValue = jsLoadString('it.cedaf.icare.tabelle.commons.findPatologiaExecutor',  '&codPatologia=' + codIcd9);
	}
	scriviDescrizioneIcd9(idTag, textValue);
}

function scriviDescrizioneIcd9(idTag, descrizione) {
	var elSpan = document.getElementById('cpmt_' + idTag); 
	if (elSpan) {
		elSpan.innerHTML = descrizione;
	}
}

function impostaICD9(){
	var patologia = $("#id_patologia").val();
	var icd9 = $("#codice_prICD9").val();
	if (patologia!="" && icd9==""){
		jsLoadMap("it.cedaf.icare.anagrafiche.control.action.FindIcd9ByPatologiaExecutor", "patologia=" + patologia, "fn_impostaICD9", JS_SYNC);
	}
}

function fn_impostaICD9(map){	
	var icd9 = map.get('icd9');
	var descrizione = map.get('descrizione');
	
	if (icd9!=null) {
		$("#codice_prICD9").val(icd9);
		scriviDescrizioneIcd9("icd9", descrizione);
	}
}

registerOnChangeLookup('prICD9', function() { scriviDescrizioneIcd9('icd9', document.getElementById('descrizione_prICD9').value); });
registerOnClearLookup('prICD9', function() { scriviDescrizioneIcd9('icd9', ''); });

</script>