class ManipulacaoCodigoTabelaPorBuscaIphRN {

	protected Long obterCodigoTabelaConformeBuscaIph(
			Integer eaiCthSeq,
			Short iphPhoSeq,
			Integer iphSeq) {

		Long result = null;
		List<FatCompatExclusItem> listaIct = null;
		List<FatAtoMedicoAih> listaAma = null;
		FatItensProcedHospitalar iph = null;

		listaIct = this.obterListaFatCompatExclusItemPorIphOrdenadaPorQtdDesc(
				iphPhoSeq, iphSeq);
		if ((listaIct != null) && !listaIct.isEmpty()) {
			for (FatCompatExclusItem ict : listaIct) {
				listaAma = this.obterListaFatAtoMedicoAihPorCthIph(
						eaiCthSeq, ict.getItemProcedHosp());
				if ((listaAma != null) && !listaAma.isEmpty()) {
					for (FatAtoMedicoAih ama : listaAma) {
						iph = ama.getItemProcedimentoHospitalar();
						if ((iph != null) && (iph.getCodTabela() != null)) {
							result = iph.getCodTabela();
							break;
						}
					}
					if (result != null) {
						break;
					}
				}
			}
		}

		return result;
	}

}