}
	
	//is both date of birth and age in years/months missing?
	$dateOfBirth=0;
	if($dateOfBirthYear && $dateOfBirthMonth && $dateOfBirthDay) {
		$dateOfBirth="$dateOfBirthYear-$dateOfBirthMonth-$dateOfBirthDay";
	} else {
		if($dateOfBirthIn=="Months") {
			$dateOfBirth=subtractFromDate($datetime,($dateOfBirthAge*30.5));
			/*
			* 20/Jun/14: suggestion by stakeholders;
			* If Patient Provides "Age in Years", then date of birth should be == 1/Jan (year when the date was computed)
			*/
			$dateOfBirth=getFormattedDateYear($dateOfBirth)."-01-01";
		} elseif($dateOfBirthIn=="Years") {
			$dateOfBirth=subtractFromDate($datetime,($dateOfBirthAge*12*30.5));
			/*
			* 20/Jun/14: suggestion by stakeholders;
			* If Patient Provides "Age in Years", then date of birth should be == 1/Jan (year when the date was computed)
			*/
			$dateOfBirth=getFormattedDateYear($dateOfBirth)."-01-01";
		} else {
			$error.="<br /><strong>Date of Birth is Missing</strong><br />Kindly provide the Date of Birth or Age in Months/Years<br />";
		}
	}
	
	/*
	* is pregnant, ANC # should be provided
	* 20/Jun/14: suggestion by stakeholders;
	* ANC Number is desirable but not mandatory
	if($pregnant=="Yes" && !$pregnantANCNumber) {
Example #2
0
/**
* update patient's ART
*/
function updatePatientData($patientID,$field,$data,$collectionDate) {
	global $datetime,$user;
	if($patientID && $field && $data && getDetailedTableInfo2("vl_patients","id='$patientID' limit 1","id")) {
		//special provisions for date of birth
		if($field=="dateOfBirth") {
			$dateOfBirth=0;
			$dateOfBirth=getFormattedDateYear(subtractFromDate(($collectionDate?$collectionDate:$datetime),($data*12*30.5)))."-01-01";
			//replace data with dateOfBirth
			$data=$dateOfBirth;
		}
		//log table change
		logTableChange("vl_patients","$field",$patientID,getDetailedTableInfo2("vl_patients","id='$patientID'","$field"),$data);
		//update vl_hubs
		mysqlquery("update vl_patients set $field='$data' where id='$patientID'");
	}
}
								
								//Facility
								$facilityID=0;
								$facilityID=logNewFacility(trim($excelData->sheets[0]['cells'][$i][4]),trim($excelData->sheets[0]['cells'][$i][5]));
								
								//District
								$districtID=0;
								$districtID=logNewDistrict(trim($excelData->sheets[0]['cells'][$i][5]));

								//Hub
								$hubID=0;
								$hubID=logNewHub(trim($excelData->sheets[0]['cells'][$i][6]),$facilityID);

								//Date of Collection; deduct by 1 date for reasons I'm yet to figure out
								$collectionDate=0;
								$collectionDate=subtractFromDate(getFormattedDateCRBExcel(trim($excelData->sheets[0]['cells'][$i][7])),1);
								if(!$collectionDate) {
									$collectionDate=getRawFormattedDateLessDay(trim($excelData->sheets[0]['cells'][$i][7]));
								}
								
								//Sample Type
								$sampleTypeID=0;
								$sampleTypeID=getDetailedTableInfo2("vl_appendix_sampletype","lower(appendix)='".strtolower(trim($excelData->sheets[0]['cells'][$i][8]))."' limit 1","id");
								
								//Date of Treatment Initiation
								$treatmentInitiationDate=0;
								$treatmentInitiationDate=getRawFormattedDateLessDay(trim($excelData->sheets[0]['cells'][$i][15]));

								//Current Regimen
								$currentRegimenID=0;
								$currentRegimenID=logNewCurrentRegimen(trim($excelData->sheets[0]['cells'][$i][16]));