Exemplo n.º 1
0
/**
* function to get up to the hourly difference between two dates
* return even negatives
* @param: $date1, $time1 - should be greater than $date2, $time2 for a positive
* @param: $date2, $time2
*/
function getStandardDetailedDateDifference($date1,$time1,$date2,$time2) {
	if(isDateAuthentic($date1) && isDateAuthentic($date2)) {
		//duration
		$duration=0;
		$duration=getStandardDateDifference($date1,$date2);
		if($duration==0) {
			//get the hourly difference
			$timeStamp1=0;
			$timeStamp1=strtotime("$date1 $time1");
			$timeStamp2=0;
			$timeStamp2=strtotime("$date2 $time2");
			$timeDuration=0;
			$timeDuration=strftime('%H',$timeStamp1)-strftime('%H',$timeStamp2);
			if($timeStamp1 && $timeStamp2) {
				return $timeDuration;
			}
		} else {
			return $duration;
		}
	}
}
		}
	}
	
	if($receiptDateYear && $receiptDateMonth && $receiptDateDay) {
		$receiptDate=0;
		$receiptDate="$receiptDateYear-$receiptDateMonth-$receiptDateDay";
		//ensure received at CPHL date is not greater than the current date
		if(getStandardDateDifference($datetime,$receiptDate)<0) {
			$error.="<br /><strong>Received at CPHL Date ".getFormattedDateLessDay($receiptDate)." should not be in the future.</strong><br />Kindly provide an alternative Date<br />";
		}
		//ensure received at CPHL date is not before 01-05-2014
		if(getStandardDateDifference($receiptDate,"2014-05-01")<0) {
			$error.="<br /><strong>Received at CPHL Date ".getFormattedDateLessDay($receiptDate)." should not be prior to 01/May/2014.</strong><br />Kindly provide an alternative Date<br />";
		}
		//ensure collection date is not greater than the received at CPHL date
		if($collectionDateYear && $collectionDateMonth && $collectionDateDay && getStandardDateDifference($receiptDate,$collectionDate)<0) {
			$error.="<br /><strong>Sample Collection Date ".getFormattedDateLessDay($collectionDate)." should not be greater than the Received at CPHL Date ".getFormattedDateLessDay($receiptDate).".</strong><br />Kindly provide an alternative Sample Collection Date<br />";
		}
	}

	//input data
	if(!$error) {
		//log changes
		logTableChange("vl_samples","lrCategory",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","lrCategory"),$lrCategory);
		logTableChange("vl_samples","lrEnvelopeNumber",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","lrEnvelopeNumber"),$lrEnvelopeNumber);
		logTableChange("vl_samples","lrNumericID",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","lrNumericID"),$lrNumericID);
		
		logTableChange("vl_samples","formNumber",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","formNumber"),$formNumber);
		logTableChange("vl_samples","districtID",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","districtID"),$districtID);
		logTableChange("vl_samples","hubID",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","hubID"),$hubID);
		logTableChange("vl_samples","facilityID",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","facilityID"),$facilityID);
Exemplo n.º 3
0
					mysqlquery("insert into vl_logs_warnings 
								(logCategory,logDetails,logTableID,created,createdby) 
								values 
								('changedPatientsDateOfBirth','Date of Birth changed from ".getDetailedTableInfo2("vl_patients","uniqueID='$uniqueID' and (artNumber='$artNumber' or otherID='$otherID') order by created desc limit 1","dateOfBirth")." to $dateOfBirth for Patient with ".($artNumber?"ART $artNumber":"").($artNumber && $otherID?", ":"").($otherID?"Other ID $otherID":"")." from Facility ".getDetailedTableInfo2("vl_facilities","id='$facilityID' limit 1","facility").".','$dateOfBirthChangeLogID','$datetime','$trailSessionUser')");
				}
				*/
			}
		}

		//log the repeated viral load test
		if($proceedWithWarningVLRepeatTesting) {
			//log the change of gender warning
			mysqlquery("insert into vl_logs_warnings 
						(logCategory,logDetails,logTableID,created,createdby) 
						values 
						('capturedRepeatVLTest','Captured a repeat VL Test after ".round(getStandardDateDifference($datetime,$mostRecentPatientIDTested)/30.5)." month(s) or ".getStandardDateDifference($datetime,$mostRecentPatientIDTested)." day(s) instead of the recommended $default_viralLoadRepeatTestWindow month(s) for Patient with ".($artNumber?"ART $artNumber":"").($artNumber && $otherID?", ":"").($otherID?"Other ID $otherID":"")." from Facility ".getDetailedTableInfo2("vl_facilities","id='$facilityID' limit 1","facility").".','','$datetime','$trailSessionUser')");
		}

		//log the alternative facility captured
		if($proceedWithWarningAlternativeFacilities) {
			//log the change of gender warning
			mysqlquery("insert into vl_logs_warnings 
						(logCategory,logDetails,logTableID,created,createdby) 
						values 
						('capturedAlternativeFacilityForFormNumber','Form Number $formNumber dispatched to Facility ".getDetailedTableInfo2("vl_facilities","id='$facilityID' limit 1","facility")." but received from Facility ".getDetailedTableInfo2("vl_facilities","id='$facilityIDByFormNumber' limit 1","facility").".','','$datetime','$trailSessionUser')");
		}

		//log patient phone number, if unique
		if($patientPhone && !getDetailedTableInfo2("vl_patients_phone","patientID='$patientID' and phone='$patientPhone' limit 1","id")) {
			mysqlquery("insert into vl_patients_phone 
							(patientID,phone,created,createdby)