('$patientID','$patientPhone','$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')");
		}
		
		//get latest sample ID, log $otherRegimen if any
		if($otherRegimen) {
			//log other regimen
			logSampleOtherRegimen($modify,$currentRegimenID,$otherRegimen);
		} else {
			logDataRemoval("delete from vl_samples_otherregimen where sampleID='$modify'");
			mysqlquery("delete from vl_samples_otherregimen where sampleID='$modify'");
		}

		//redirect to home with updates on the tracking number
		go("/verify/$pg/modified/");
	}
} else {
	//prepopulate
	$lrCategory=0;
	$lrCategory=getDetailedTableInfo2("vl_samples","id='$modify' limit 1","lrCategory");

	$lrEnvelopeNumber=0;
	$lrEnvelopeNumber=getDetailedTableInfo2("vl_samples","id='$modify' limit 1","lrEnvelopeNumber");
								'".($viralLoadTestingIndication=="vlTestingSuspectedTreatmentFailure"?$suspectedTreatmentFailureValue:"")."',
								'".($viralLoadTestingIndication=="vlTestingSuspectedTreatmentFailure"?$suspectedTreatmentFailureSampleTypeID:"")."',
								
								'$lrCategory','$lrEnvelopeNumber','$lrNumericID',
								
								'$datetime','$trailSessionUser')");
			
			if(mysqlerror())
				die("3: ".mysqlerror());
			
			//get latest sample ID, log $otherRegimen if any
			if($otherRegimen) {
				$latestSampleID=0;
				$latestSampleID=getDetailedTableInfo2("vl_samples","createdby='$trailSessionUser' order by created desc limit 1","id");
				//log other regimen
				logSampleOtherRegimen($latestSampleID,$currentRegimenID,$otherRegimen);
			} else {
				logDataRemoval("delete from vl_samples_otherregimen where sampleID='$latestSampleID'");
				mysqlquery("delete from vl_samples_otherregimen where sampleID='$latestSampleID'");
			}

			//review logs and fix any duplicates
			fixDuplicateSampleIDs();
			
			//redirect accordingly
			go("/samples/success/".vlEncrypt(getDetailedTableInfo2("vl_samples","createdby='$trailSessionUser' order by created desc limit 1","vlSampleID"))."/");
		} else {
			$error.="<br /><strong>Duplicate Data Entry</strong><br /> Patient with ART Number <strong>$artNumber</strong> from <strong>".getDetailedTableInfo2("vl_facilities","id='$facilityID' limit 1","facility")."</strong> has already been entered with Form Number <strong>$formNumber</strong>.<br /> Kindly input this record with an alternative Form or ART Number.<br />";
		}
	}
}