A
download class.Procedure.php
Language: PHP
LOC: 73
Project Info
FreeMED Project(freemed)
Server: SourceForge
Type: cvs
...reemed\freemed\freemed\lib\
   acl.php
   API.php
   bcadd.php
   calendar-functions.php
   class.AdminModule.php
   class.Agata.php
   class.Authorizations.php
   class.BaseModule.php
   class.BillingModule.php
   class.CalendarModule.php
   class.ClaimLog.php
   class.Coverage.php
   class.Debug.php
   class.diagnosis_set.php
   class.Djvu.php
   class.EMRModule.php
   class.Fax.php
   class.FixedFormEntry.php
   ...s.FixedFormRenderer.php
   class.FormRenderer.php
   class.FreeMEDSelfTest.php
   class.GeneralConfig.php
   class.GraphModule.php
   class.Guarantor.php
   class.Handler_HL7v2.php
   ...s.Handler_HL7v2_A04.php
   ...s.Handler_HL7v2_A08.php
   ...s.Handler_HL7v2_S12.php
   ...s.Handler_HL7v2_S15.php
   class.InsuranceCompany.php
   class.LanguageRegistry.php
   class.Ledger.php
   ...s.MaintenanceModule.php
   class.Messages.php
   class.OMBS_Patient.php
   class.OMBS_Wrapper.php
   class.Parser_HL7v2.php
   class.Patient.php
   class.Payer.php
   class.PHPlot.php
   class.Physician.php
   class.Procedure.php
   class.RecordLock.php
   class.Remitt.php
   class.ReportsModule.php
   class.rxlist.php
   class.Scheduler.php
   class.TeX.php
   class.User.php
   class.UtilityModule.php
   class.vCalendar.php
   class.vCalendarEvent.php
   error_handler.php
   freemed.php
   i18n.php
   iso-set.php
   macros.php
   mail-functions.php
   settings.php
   settings.php.tmpl
   xml.php
   xmlrpc_services.php

<?php
	// $Id: class.Procedure.php,v 1.6 2005/08/16 12:15:26 rufustfirefly Exp $
	// $Author: rufustfirefly $

// Class: FreeMED.Procedure
class Procedure {

	// Constructor: Procedure
	//
	// Parameters:
	//
	//	$id - Procedure id
	//
	function Procedure ( $id ) {
		$this->id = $id;
		$this->local_record = freemed::get_link_rec($id, 'procrec', true);
	} // end constructor Procedure

	// Method: current_balance
	//
	//	Determine current balance of this object's procedure
	//
	// Returns:
	//
	//	Monetary balance amount.
	//
	function current_balance ( ) {
		$total_payments = 0.00;
		$total_charges  = 0.00;

		// Process payment records
		$result = $GLOBALS['sql']->query(
			"SELECT * FROM payrec AS a, procrec AS b ".
			"WHERE b.id = a.payrecproc AND ".
			"a.payrecproc = '".addslashes($this->id)."'"
		);
		while ($r = $GLOBALS['sql']->fetch_array($result)) {
			switch ($r['payreccat']) {
				case REFUND:
				case PROCEDURE:
					$total_charges += $r['payrecamt'];
					break;
				case WITHHOLD:
				case DEDUCTABLE:
				case FEEADJUST:
				case WRITEOFF:
				case DENIAL:
					$total_charges -= $r['payrecamt'];
					break;
				case ADJUSTMENT:
					$total_payments -= $r['payrecamt'];
					break;
				case PAYMENT:
				case COPAY:
					$total_payments += $r['payrecamt'];
					break;
				default: break;
			}
		}
		return $total_charges - $total_payments;
	} // end method CurrentBalance

	// Method: check_for_payer
	//
	//	Determine if a procedure has a payer associated with it.
	//
	// Parameters:
	//
	//	$proc - Procedure id or associative array of procedure
	//
	//	$payer - Payer to be checked
	//
	// Returns:
	//
	//	Boolean, whether payer is associated with procedure.
	//
	function check_for_payer ( $proc, $payer ) {
		if (is_array($proc)) {
			$_proc = $proc;
		} else {
			$_proc = freemed::get_link_rec($proc, 'procrec', true);
		}

		// If there is no payer, return true
		if (!$payer) { return true; }

		if ($_proc['proccurcovid'] == $payer) { return true; }

//		print $_proc['id']." != ".$payer."<br/>\n";
//		return true; // KLUDGE FOR TESTING
		return false;
	} // end method

	// Method: get_open_procedures_by_date_and_patient
	//
	//	Get open procedures by date and patient id criteria
	//
	// Parameters:
	//
	//	$patient - Patient id key
	//
	//	$date - Date to limit. If none (or a NULL date), date
	//	is disregarded.
	//
	// Returns:
	//
	//	Array of procedure keys
	//
	function get_open_procedures_by_date_and_patient ( $patient, $date ) {
		static $_cache;
		if (!isset($_cache[$patient][$date])) {
			$query = "SELECT * FROM procrec ".
				"WHERE ".
				( $date ? "procdt='".addslashes($date)."' AND " :
				"" )." procpatient='".addslashes($patient)."'";
			//print "query = $query<br/>\n";
			$result = $GLOBALS['sql']->query ( $query );
			while ( $r = $GLOBALS['sql']->fetch_array ( $result ) ) {
				$procedures[] = $r;
			}
			$_cache[$patient][$date] = $procedures;
		}
		return $_cache[$patient][$date];
	} // end method get_open_procedures_by_date_and_patient
	

	// Method: get_procedure
	//
	//	Get procedure record from the current object, or retrieve
	//	a procedure object based on a passed key.
	//
	// Parameters:
	//
	//	$id - (optional) Procedure id key
	//
	// Returns:
	//
	//	Associative array containing procedure record information.
	//
	function get_procedure ( $id = NULL ) {
		if ($id != NULL) {
			return freemed::get_link_rec($id, 'procrec', true);
		} else {
			return $this->local_record; 
		}
	} // end method get_procedure

} // end class Procedure

?>

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us