<?php

// Global variable for table object
$Hospitalizacion = NULL;

//
// Table class for Hospitalizacion
//
class crHospitalizacion extends crTableBase {

//	var $SelectLimit = TRUE;
	var $Numero_factura;
	var $Codigo_prestador;
	var $Tipo_id;
	var $Numero_id;
	var $Via_ingreso_ins;
	var $Fecha_ingreso_usuario;
	var $Hora_ingreso;
	var $Numero_autorizacion;
	var $Causa_externa;
	var $Diagnostico_principal_ingreso;
	var $Diagnostico_principal_egreso;
	var $Diagnostico_rel_1;
	var $Diagnostico_rel_2;
	var $Diagnostico_rel_3;
	var $Diagnostico_complicacion;
	var $Estado_salida;
	var $Diagnostico_causa_muerte;
	var $Fecha_egreso;
	var $Hora__egreso;

	//
	// Table class constructor
	//
	function __construct() {
		global $ReportLanguage;
		$this->TableVar = 'Hospitalizacion';
		$this->TableName = 'Hospitalizacion';
		$this->TableType = 'TABLE';
		$this->ExportAll = TRUE;
		$this->ExportPageBreakCount = 0;

		// Numero_factura
		$this->Numero_factura = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Numero_factura', 'Numero_factura', '`Numero_factura`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Numero_factura'] = &$this->Numero_factura;
		$this->Numero_factura->DateFilter = "";
		$this->Numero_factura->SqlSelect = "";
		$this->Numero_factura->SqlOrderBy = "";

		// Codigo_prestador
		$this->Codigo_prestador = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Codigo_prestador', 'Codigo_prestador', '`Codigo_prestador`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Codigo_prestador'] = &$this->Codigo_prestador;
		$this->Codigo_prestador->DateFilter = "";
		$this->Codigo_prestador->SqlSelect = "";
		$this->Codigo_prestador->SqlOrderBy = "";

		// Tipo_id
		$this->Tipo_id = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Tipo_id', 'Tipo_id', '`Tipo_id`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Tipo_id'] = &$this->Tipo_id;
		$this->Tipo_id->DateFilter = "";
		$this->Tipo_id->SqlSelect = "";
		$this->Tipo_id->SqlOrderBy = "";

		// Numero_id
		$this->Numero_id = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Numero_id', 'Numero_id', '`Numero_id`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Numero_id'] = &$this->Numero_id;
		$this->Numero_id->DateFilter = "";
		$this->Numero_id->SqlSelect = "";
		$this->Numero_id->SqlOrderBy = "";

		// Via_ingreso_ins
		$this->Via_ingreso_ins = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Via_ingreso_ins', 'Via_ingreso_ins', '`Via_ingreso_ins`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->Via_ingreso_ins->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Via_ingreso_ins'] = &$this->Via_ingreso_ins;
		$this->Via_ingreso_ins->DateFilter = "";
		$this->Via_ingreso_ins->SqlSelect = "";
		$this->Via_ingreso_ins->SqlOrderBy = "";

		// Fecha_ingreso_usuario
		$this->Fecha_ingreso_usuario = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Fecha_ingreso_usuario', 'Fecha_ingreso_usuario', '`Fecha_ingreso_usuario`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Fecha_ingreso_usuario'] = &$this->Fecha_ingreso_usuario;
		$this->Fecha_ingreso_usuario->DateFilter = "";
		$this->Fecha_ingreso_usuario->SqlSelect = "";
		$this->Fecha_ingreso_usuario->SqlOrderBy = "";

		// Hora_ingreso
		$this->Hora_ingreso = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Hora_ingreso', 'Hora_ingreso', '`Hora_ingreso`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Hora_ingreso'] = &$this->Hora_ingreso;
		$this->Hora_ingreso->DateFilter = "";
		$this->Hora_ingreso->SqlSelect = "";
		$this->Hora_ingreso->SqlOrderBy = "";

		// Numero_autorizacion
		$this->Numero_autorizacion = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Numero_autorizacion', 'Numero_autorizacion', '`Numero_autorizacion`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Numero_autorizacion'] = &$this->Numero_autorizacion;
		$this->Numero_autorizacion->DateFilter = "";
		$this->Numero_autorizacion->SqlSelect = "";
		$this->Numero_autorizacion->SqlOrderBy = "";

		// Causa_externa
		$this->Causa_externa = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Causa_externa', 'Causa_externa', '`Causa_externa`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->Causa_externa->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Causa_externa'] = &$this->Causa_externa;
		$this->Causa_externa->DateFilter = "";
		$this->Causa_externa->SqlSelect = "";
		$this->Causa_externa->SqlOrderBy = "";

		// Diagnostico_principal_ingreso
		$this->Diagnostico_principal_ingreso = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Diagnostico_principal_ingreso', 'Diagnostico_principal_ingreso', '`Diagnostico_principal_ingreso`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Diagnostico_principal_ingreso'] = &$this->Diagnostico_principal_ingreso;
		$this->Diagnostico_principal_ingreso->DateFilter = "";
		$this->Diagnostico_principal_ingreso->SqlSelect = "";
		$this->Diagnostico_principal_ingreso->SqlOrderBy = "";

		// Diagnostico_principal_egreso
		$this->Diagnostico_principal_egreso = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Diagnostico_principal_egreso', 'Diagnostico_principal_egreso', '`Diagnostico_principal_egreso`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Diagnostico_principal_egreso'] = &$this->Diagnostico_principal_egreso;
		$this->Diagnostico_principal_egreso->DateFilter = "";
		$this->Diagnostico_principal_egreso->SqlSelect = "";
		$this->Diagnostico_principal_egreso->SqlOrderBy = "";

		// Diagnostico_rel_1
		$this->Diagnostico_rel_1 = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Diagnostico_rel_1', 'Diagnostico_rel_1', '`Diagnostico_rel_1`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Diagnostico_rel_1'] = &$this->Diagnostico_rel_1;
		$this->Diagnostico_rel_1->DateFilter = "";
		$this->Diagnostico_rel_1->SqlSelect = "";
		$this->Diagnostico_rel_1->SqlOrderBy = "";

		// Diagnostico_rel_2
		$this->Diagnostico_rel_2 = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Diagnostico_rel_2', 'Diagnostico_rel_2', '`Diagnostico_rel_2`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Diagnostico_rel_2'] = &$this->Diagnostico_rel_2;
		$this->Diagnostico_rel_2->DateFilter = "";
		$this->Diagnostico_rel_2->SqlSelect = "";
		$this->Diagnostico_rel_2->SqlOrderBy = "";

		// Diagnostico_rel_3
		$this->Diagnostico_rel_3 = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Diagnostico_rel_3', 'Diagnostico_rel_3', '`Diagnostico_rel_3`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Diagnostico_rel_3'] = &$this->Diagnostico_rel_3;
		$this->Diagnostico_rel_3->DateFilter = "";
		$this->Diagnostico_rel_3->SqlSelect = "";
		$this->Diagnostico_rel_3->SqlOrderBy = "";

		// Diagnostico_complicacion
		$this->Diagnostico_complicacion = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Diagnostico_complicacion', 'Diagnostico_complicacion', '`Diagnostico_complicacion`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Diagnostico_complicacion'] = &$this->Diagnostico_complicacion;
		$this->Diagnostico_complicacion->DateFilter = "";
		$this->Diagnostico_complicacion->SqlSelect = "";
		$this->Diagnostico_complicacion->SqlOrderBy = "";

		// Estado_salida
		$this->Estado_salida = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Estado_salida', 'Estado_salida', '`Estado_salida`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->Estado_salida->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Estado_salida'] = &$this->Estado_salida;
		$this->Estado_salida->DateFilter = "";
		$this->Estado_salida->SqlSelect = "";
		$this->Estado_salida->SqlOrderBy = "";

		// Diagnostico_causa_muerte
		$this->Diagnostico_causa_muerte = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Diagnostico_causa_muerte', 'Diagnostico_causa_muerte', '`Diagnostico_causa_muerte`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Diagnostico_causa_muerte'] = &$this->Diagnostico_causa_muerte;
		$this->Diagnostico_causa_muerte->DateFilter = "";
		$this->Diagnostico_causa_muerte->SqlSelect = "";
		$this->Diagnostico_causa_muerte->SqlOrderBy = "";

		// Fecha_egreso
		$this->Fecha_egreso = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Fecha_egreso', 'Fecha_egreso', '`Fecha_egreso`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Fecha_egreso'] = &$this->Fecha_egreso;
		$this->Fecha_egreso->DateFilter = "";
		$this->Fecha_egreso->SqlSelect = "";
		$this->Fecha_egreso->SqlOrderBy = "";

		// Hora _egreso
		$this->Hora__egreso = new crField('Hospitalizacion', 'Hospitalizacion', 'x_Hora__egreso', 'Hora _egreso', '`Hora _egreso`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Hora__egreso'] = &$this->Hora__egreso;
		$this->Hora__egreso->DateFilter = "";
		$this->Hora__egreso->SqlSelect = "";
		$this->Hora__egreso->SqlOrderBy = "";
	}

	// Single column sort
	function UpdateSort(&$ofld) {
		if ($this->CurrentOrder == $ofld->FldName) {
			$sLastSort = $ofld->getSort();
			if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
				$sThisSort = $this->CurrentOrderType;
			} else {
				$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			}
			$ofld->setSort($sThisSort);
		} else {
			if ($ofld->GroupingFieldId == 0) $ofld->setSort("");
		}
	}

	// Get Sort SQL
	function SortSql() {
		$sDtlSortSql = "";
		$argrps = array();
		foreach ($this->fields as $fld) {
			if ($fld->getSort() <> "") {
				if ($fld->GroupingFieldId > 0) {
					if ($fld->FldGroupSql <> "")
						$argrps[$fld->GroupingFieldId] = str_replace("%s", $fld->FldExpression, $fld->FldGroupSql) . " " . $fld->getSort();
					else
						$argrps[$fld->GroupingFieldId] = $fld->FldExpression . " " . $fld->getSort();
				} else {
					if ($sDtlSortSql <> "") $sDtlSortSql .= ", ";
					$sDtlSortSql .= $fld->FldExpression . " " . $fld->getSort();
				}
			}
		}
		$sSortSql = "";
		foreach ($argrps as $grp) {
			if ($sSortSql <> "") $sSortSql .= ", ";
			$sSortSql .= $grp;
		}
		if ($sDtlSortSql <> "") {
			if ($sSortSql <> "") $sSortSql .= ",";
			$sSortSql .= $sDtlSortSql;
		}
		return $sSortSql;
	}

	// Table level SQL
	// From

	var $_SqlFrom = "";

	function getSqlFrom() {
		return ($this->_SqlFrom <> "") ? $this->_SqlFrom : "`Hospitalizacion`";
	}

	function SqlFrom() { // For backward compatibility
		return $this->getSqlFrom();
	}

	function setSqlFrom($v) {
		$this->_SqlFrom = $v;
	}

	// Select
	var $_SqlSelect = "";

	function getSqlSelect() {
		return ($this->_SqlSelect <> "") ? $this->_SqlSelect : "SELECT * FROM " . $this->getSqlFrom();
	}

	function SqlSelect() { // For backward compatibility
		return $this->getSqlSelect();
	}

	function setSqlSelect($v) {
		$this->_SqlSelect = $v;
	}

	// Where
	var $_SqlWhere = "";

	function getSqlWhere() {
		$sWhere = ($this->_SqlWhere <> "") ? $this->_SqlWhere : "";
		return $sWhere;
	}

	function SqlWhere() { // For backward compatibility
		return $this->getSqlWhere();
	}

	function setSqlWhere($v) {
		$this->_SqlWhere = $v;
	}

	// Group By
	var $_SqlGroupBy = "";

	function getSqlGroupBy() {
		return ($this->_SqlGroupBy <> "") ? $this->_SqlGroupBy : "";
	}

	function SqlGroupBy() { // For backward compatibility
		return $this->getSqlGroupBy();
	}

	function setSqlGroupBy($v) {
		$this->_SqlGroupBy = $v;
	}

	// Having
	var $_SqlHaving = "";

	function getSqlHaving() {
		return ($this->_SqlHaving <> "") ? $this->_SqlHaving : "";
	}

	function SqlHaving() { // For backward compatibility
		return $this->getSqlHaving();
	}

	function setSqlHaving($v) {
		$this->_SqlHaving = $v;
	}

	// Order By
	var $_SqlOrderBy = "";

	function getSqlOrderBy() {
		return ($this->_SqlOrderBy <> "") ? $this->_SqlOrderBy : "";
	}

	function SqlOrderBy() { // For backward compatibility
		return $this->getSqlOrderBy();
	}

	function setSqlOrderBy($v) {
		$this->_SqlOrderBy = $v;
	}

	// Select Aggregate
	var $_SqlSelectAgg = "";

	function getSqlSelectAgg() {
		return ($this->_SqlSelectAgg <> "") ? $this->_SqlSelectAgg : "SELECT * FROM " . $this->getSqlFrom();
	}

	function SqlSelectAgg() { // For backward compatibility
		return $this->getSqlSelectAgg();
	}

	function setSqlSelectAgg($v) {
		$this->_SqlSelectAgg = $v;
	}

	// Aggregate Prefix
	var $_SqlAggPfx = "";

	function getSqlAggPfx() {
		return ($this->_SqlAggPfx <> "") ? $this->_SqlAggPfx : "";
	}

	function SqlAggPfx() { // For backward compatibility
		return $this->getSqlAggPfx();
	}

	function setSqlAggPfx($v) {
		$this->_SqlAggPfx = $v;
	}

	// Aggregate Suffix
	var $_SqlAggSfx = "";

	function getSqlAggSfx() {
		return ($this->_SqlAggSfx <> "") ? $this->_SqlAggSfx : "";
	}

	function SqlAggSfx() { // For backward compatibility
		return $this->getSqlAggSfx();
	}

	function setSqlAggSfx($v) {
		$this->_SqlAggSfx = $v;
	}

	// Select Count
	var $_SqlSelectCount = "";

	function getSqlSelectCount() {
		return ($this->_SqlSelectCount <> "") ? $this->_SqlSelectCount : "SELECT COUNT(*) FROM " . $this->getSqlFrom();
	}

	function SqlSelectCount() { // For backward compatibility
		return $this->getSqlSelectCount();
	}

	function setSqlSelectCount($v) {
		$this->_SqlSelectCount = $v;
	}

	// Sort URL
	function SortUrl(&$fld) {
		return "";
	}

	// Table level events
	// Page Selecting event
	function Page_Selecting(&$filter) {

		// Enter your code here	
	}

	// Page Breaking event
	function Page_Breaking(&$break, &$content) {

		// Example:
		//$break = FALSE; // Skip page break, or
		//$content = "<div style=\"page-break-after:always;\">&nbsp;</div>"; // Modify page break content

	}

	// Row Rendering event
	function Row_Rendering() {

		// Enter your code here	
	}

	// Cell Rendered event
	function Cell_Rendered(&$Field, $CurrentValue, &$ViewValue, &$ViewAttrs, &$CellAttrs, &$HrefValue, &$LinkAttrs) {

		//$ViewValue = "xxx";
		//$ViewAttrs["style"] = "xxx";

	}

	// Row Rendered event
	function Row_Rendered() {

		// To view properties of field class, use:
		//var_dump($this-><FieldName>); 

	}

	// User ID Filtering event
	function UserID_Filtering(&$filter) {

		// Enter your code here
	}

	// Load Filters event
	function Page_FilterLoad() {

		// Enter your code here
		// Example: Register/Unregister Custom Extended Filter
		//ewr_RegisterFilter($this-><Field>, 'StartsWithA', 'Starts With A', 'GetStartsWithAFilter'); // With function, or
		//ewr_RegisterFilter($this-><Field>, 'StartsWithA', 'Starts With A'); // No function, use Page_Filtering event
		//ewr_UnregisterFilter($this-><Field>, 'StartsWithA');

	}

	// Page Filter Validated event
	function Page_FilterValidated() {

		// Example:
		//$this->MyField1->SearchValue = "your search criteria"; // Search value

	}

	// Page Filtering event
	function Page_Filtering(&$fld, &$filter, $typ, $opr = "", $val = "", $cond = "", $opr2 = "", $val2 = "") {

		// Note: ALWAYS CHECK THE FILTER TYPE ($typ)! Example:
		// if ($typ == "dropdown" && $fld->FldName == "MyField") // Dropdown filter
		//     $filter = "..."; // Modify the filter
		// if ($typ == "extended" && $fld->FldName == "MyField") // Extended filter
		//     $filter = "..."; // Modify the filter
		// if ($typ == "popup" && $fld->FldName == "MyField") // Popup filter
		//     $filter = "..."; // Modify the filter
		// if ($typ == "custom" && $opr == "..." && $fld->FldName == "MyField") // Custom filter, $opr is the custom filter ID
		//     $filter = "..."; // Modify the filter

	}

	// Email Sending event
	function Email_Sending(&$Email, &$Args) {

		//var_dump($Email); var_dump($Args); exit();
		return TRUE;
	}

	// Lookup Selecting event
	function Lookup_Selecting($fld, &$filter) {

		// Enter your code here
	}
}
?>
