} //update regimen for($i=2;$i<=$excelData->sheets[2]['numRows'];$i++) { //Current Regimen $currentRegimenID=0; $currentRegimenID=logNewCurrentRegimen(trim($excelData->sheets[2]['cells'][$i][1])); //Which Treatment Line is Patient on $treatmentStatusID=0; $treatmentStatusID=logNewTreatmentStatus(trim($excelData->sheets[2]['cells'][$i][2])); //ensure this treatment line is matched to the regimen if($currentRegimenID && $treatmentStatusID && !getDetailedTableInfo2("vl_appendix_regimen","id='$currentRegimenID' and treatmentStatusID='$treatmentStatusID' limit 1","id")) { //log table change logTableChange("vl_appendix_regimen","treatmentStatusID",$currentRegimenID,getDetailedTableInfo2("vl_appendix_regimen","id='$currentRegimenID'","treatmentStatusID"),$treatmentStatusID); //update vl_appendix_regimen mysqlquery("update vl_appendix_regimen set treatmentStatusID='$treatmentStatusID' where id='$currentRegimenID'"); } } //flag $success=1; } } else { $error.="<br>File could not be uploaded. Consider contacting your Systems Administrator."; } } break; default: if($modify) { $task="modify";
//log table change $query=0; $query=mysqlquery("select * from vl_samples where formNumber='$formNumber'"); if(mysqlnumrows($query)) { while($q=mysqlfetcharray($query)) { logTableChange("vl_samples","patientID",$q["id"],$q["patientID"],""); logTableChange("vl_samples","patientUniqueID",$q["id"],$q["patientID"],""); } } //update vl_samples mysqlquery("update vl_samples set patientID='',patientUniqueID='' where formNumber='$formNumber'"); } //log table change logTableChange("vl_samples","patientID",$sampleUniqueID,getDetailedTableInfo2("vl_samples","id='$sampleUniqueID'","patientID"),$q["patientID"]); logTableChange("vl_samples","patientUniqueID",$sampleUniqueID,getDetailedTableInfo2("vl_samples","id='$sampleUniqueID'","patientUniqueID"),$q["patientID"]); //update vl_samples mysqlquery("update vl_samples set patientID='$patientID',patientUniqueID='$uniqueID' where id='$sampleUniqueID'"); //flag $linked=1; //redirect go("?act=linkPatient&nav=datamanagement&linked=1"); } break; default: if($modify) { $task="modify"; } break;
//insert into vl_appendix_sampletype mysqlquery("insert into vl_appendix_sampletype (appendix,position,created,createdby) values ('$appendix','$position','$datetime','$_SESSION[VLADMIN]')"); //flag $added=1; } else { $error.="<br>The supplied Appendix <strong>$appendix</strong> is already within the system"; } } break; case modify: //log table change logTableChange("vl_appendix_sampletype","appendix",$id,getDetailedTableInfo2("vl_appendix_sampletype","id='$id'","appendix"),$appendix); logTableChange("vl_appendix_sampletype","position",$id,getDetailedTableInfo2("vl_appendix_sampletype","id='$id'","position"),$position); //update vl_appendix_sampletype mysqlquery("update vl_appendix_sampletype set appendix='$appendix',position='$position' where id='$id'"); //flag $modified=1; break; case remove: if(isQuery("select * from vl_appendix_sampletype where id='$id'")) { //remove logDataRemoval("delete from vl_appendix_sampletype where id='$id'"); mysqlquery("delete from vl_appendix_sampletype where id='$id'"); //remove logDataRemoval("delete from vl_appendix_samplerejectionreason where sampleTypeID='$id'"); mysqlquery("delete from vl_appendix_samplerejectionreason where sampleTypeID='$id'"); //flag $removed=1;
$added=1; } else { $error.="<br>The supplied Facility <strong>$facility</strong> has already been provided for ".getDetailedTableInfo2("vl_districts","id='$districtID'","district")." District."; } } break; case modify: //log table change logTableChange("vl_facilities","districtID",$id,getDetailedTableInfo2("vl_facilities","id='$id'","districtID"),$districtID); logTableChange("vl_facilities","facility",$id,getDetailedTableInfo2("vl_facilities","id='$id'","facility"),$facility); logTableChange("vl_facilities","phone",$id,getDetailedTableInfo2("vl_facilities","id='$id'","phone"),$phone); logTableChange("vl_facilities","email",$id,getDetailedTableInfo2("vl_facilities","id='$id'","email"),$email); logTableChange("vl_facilities","contactPerson",$id,getDetailedTableInfo2("vl_facilities","id='$id'","contactPerson"),$contactPerson); logTableChange("vl_facilities","physicalAddress",$id,getDetailedTableInfo2("vl_facilities","id='$id'","physicalAddress"),$physicalAddress); logTableChange("vl_facilities","returnAddress",$id,getDetailedTableInfo2("vl_facilities","id='$id'","returnAddress"),$returnAddress); logTableChange("vl_facilities","active",$id,getDetailedTableInfo2("vl_facilities","id='$id'","active"),$active); //update vl_facilities mysqlquery("update vl_facilities set facility='$facility', phone='$phone', email='$email', contactPerson='$contactPerson', physicalAddress='$physicalAddress', returnAddress='$returnAddress', districtID='$districtID', active='$active' where id='$id'"); //flag $modified=1; break;
$resultNumeric=getVLNumericResultOnly($resultAlphanumeric); //results merged sample ID $resultsMergedSampleID=0; $resultsMergedSampleID=getDetailedTableInfo2("vl_results_merged","machine='$machine' and vlSampleID='$sampleID' and worksheetID='$worksheetID'","id"); if(!$resultsMergedSampleID) { //log into vl_results_merged mysqlquery("insert ignore into vl_results_merged (machine,worksheetID,vlSampleID,resultAlphanumeric, resultNumeric,created,createdby) values ('$machine','$worksheetID','$sampleID','$resultAlphanumeric', '$resultNumeric','$datetime','$trailSessionUser')"); } else { //update logTableChange("vl_results_merged","resultAlphanumeric",$resultsMergedSampleID,getDetailedTableInfo2("vl_results_merged","id='$resultsMergedSampleID'","resultAlphanumeric"),$resultsMergedSampleID); logTableChange("vl_results_merged","resultNumeric",$resultsMergedSampleID,getDetailedTableInfo2("vl_results_merged","id='$resultsMergedSampleID'","resultNumeric"),$resultsMergedSampleID); //implement the changes mysqlquery("update vl_results_merged set resultAlphanumeric='$resultAlphanumeric', resultNumeric='$resultNumeric' where id='$resultsMergedSampleID'"); } //modified $modified+=1; } } } break; default:
//insert into vl_districts mysqlquery("insert into vl_districts (district,regionID,created,createdby) values ('$district','$formRegionID','$datetime','$_SESSION[VLADMIN]')"); //flag $added=1; } else { $error.="<br>The supplied District <strong>$district</strong> is already within the system"; } } break; case modify: //log table change logTableChange("vl_districts","regionID",$id,getDetailedTableInfo2("vl_districts","id='$id'","regionID"),$formRegionID); logTableChange("vl_districts","district",$id,getDetailedTableInfo2("vl_districts","id='$id'","district"),$district); //update vl_districts mysqlquery("update vl_districts set district='$district',regionID='$formRegionID' where id='$id'"); //flag $modified=1; break; case remove: if(isQuery("select * from vl_districts where id='$id'")) { //remove dependencies logDataRemoval("delete from vl_facilities where districtID='$id'"); mysqlquery("delete from vl_facilities where districtID='$id'"); //remove logDataRemoval("delete from vl_districts where id='$id'"); mysqlquery("delete from vl_districts where id='$id'"); //flag
if(!isQuery("select * from vl_regions where region='$region'")) { //insert into vl_regions mysqlquery("insert into vl_regions (region,created,createdby) values ('$region','$datetime','$_SESSION[VLADMIN]')"); //flag $added=1; } else { $error.="<br>The supplied Region <strong>$region</strong> is already within the system"; } } break; case modify: //log table change logTableChange("vl_regions","region",$id,getDetailedTableInfo2("vl_regions","id='$id'","region"),$region); //update vl_regions mysqlquery("update vl_regions set region='$region' where id='$id'"); //flag $modified=1; break; case remove: if(isQuery("select * from vl_regions where id='$id'")) { $query=0; $query=mysqlquery("select * from vl_districts where regionID='$id'"); if(mysqlnumrows($query)) { while($q=mysqlfetcharray($query)) { //remove dependencies logDataRemoval("delete from vl_facilities where districtID='$q[id]'"); mysqlquery("delete from vl_facilities where districtID='$q[id]'"); }
".($viralLoadTestingIndication=="vlTestingSuspectedTreatmentFailure"?"vlTestingSuspectedTreatmentFailure='1',":"vlTestingSuspectedTreatmentFailure='0',")." ".($viralLoadTestingIndication=="vlTestingSuspectedTreatmentFailure"?"suspectedTreatmentFailureLastVLDate='$suspectedTreatmentFailureLastVLDate',":"suspectedTreatmentFailureLastVLDate='',")." ".($viralLoadTestingIndication=="vlTestingSuspectedTreatmentFailure"?"suspectedTreatmentFailureValue='$suspectedTreatmentFailureValue',":"suspectedTreatmentFailureValue='',")." ".($viralLoadTestingIndication=="vlTestingSuspectedTreatmentFailure"?"suspectedTreatmentFailureSampleTypeID='$suspectedTreatmentFailureSampleTypeID',":"suspectedTreatmentFailureSampleTypeID='',")." arvAdherenceID='$arvAdherenceID' where id='$modify'"); //log changes logTableChange("vl_patients","artNumber",$patientID,getDetailedTableInfo2("vl_patients","id='$patientID'","artNumber"),$artNumber); logTableChange("vl_patients","otherID",$patientID,getDetailedTableInfo2("vl_patients","id='$patientID'","otherID"),$otherID); logTableChange("vl_patients","gender",$patientID,getDetailedTableInfo2("vl_patients","id='$patientID'","gender"),$gender); $genderChangeLogID=0; $genderChangeLogID=getDetailedTableInfo2("vl_logs_tables","createdby='$trailSessionUser' order by id desc limit 1","id"); if(!$noDateOfBirthSupplied) { logTableChange("vl_patients","dateOfBirth",$patientID,getDetailedTableInfo2("vl_patients","id='$patientID'","dateOfBirth"),$dateOfBirth); } //update patient information mysqlquery("update vl_patients set artNumber='$artNumber', otherID='$otherID', ".(!$noDateOfBirthSupplied?"dateOfBirth='$dateOfBirth', ":"dateOfBirth='', ")." gender='$gender' where id='$patientID'"); //log the change of gender warning if($mostRecentGender && (($mostRecentGender=="Female" && $gender=="Male") || ($mostRecentGender=="Male" && $gender=="Female"))) { mysqlquery("insert into vl_logs_warnings (logCategory,logDetails,logTableID,created,createdby)
//insert into vl_appendix_failurereason mysqlquery("insert into vl_appendix_failurereason (appendix,position,created,createdby) values ('$appendix','$position','$datetime','$_SESSION[VLADMIN]')"); //flag $added=1; } else { $error.="<br>The supplied Appendix <strong>$appendix</strong> is already within the system"; } } break; case modify: //log table change logTableChange("vl_appendix_failurereason","appendix",$id,getDetailedTableInfo2("vl_appendix_failurereason","id='$id'","appendix"),$appendix); logTableChange("vl_appendix_failurereason","position",$id,getDetailedTableInfo2("vl_appendix_failurereason","id='$id'","position"),$position); //update vl_appendix_failurereason mysqlquery("update vl_appendix_failurereason set appendix='$appendix',position='$position' where id='$id'"); //flag $modified=1; break; case remove: if(isQuery("select * from vl_appendix_failurereason where id='$id'")) { //remove logDataRemoval("delete from vl_appendix_failurereason where id='$id'"); mysqlquery("delete from vl_appendix_failurereason where id='$id'"); //flag $removed=1; } break; default:
".($viralLoadTestingIndication=="vlTestingSuspectedTreatmentFailure"?"suspectedTreatmentFailureLastVLDate='$suspectedTreatmentFailureLastVLDate',":"suspectedTreatmentFailureLastVLDate='',")." ".($viralLoadTestingIndication=="vlTestingSuspectedTreatmentFailure"?"suspectedTreatmentFailureValue='$suspectedTreatmentFailureValue',":"suspectedTreatmentFailureValue='',")." ".($viralLoadTestingIndication=="vlTestingSuspectedTreatmentFailure"?"suspectedTreatmentFailureSampleTypeID='$suspectedTreatmentFailureSampleTypeID',":"suspectedTreatmentFailureSampleTypeID='',")." arvAdherenceID='$arvAdherenceID' where id='$modify'"); //log changes logTableChange("vl_patients","artNumber",$patientID,getDetailedTableInfo2("vl_patients","id='$patientID'","artNumber"),$artNumber); logTableChange("vl_patients","otherID",$patientID,getDetailedTableInfo2("vl_patients","id='$patientID'","otherID"),$otherID); logTableChange("vl_patients","gender",$patientID,getDetailedTableInfo2("vl_patients","id='$patientID'","gender"),$gender); $genderChangeLogID=0; $genderChangeLogID=getDetailedTableInfo2("vl_logs_tables","createdby='$trailSessionUser' order by id desc limit 1","id"); if(!$noDateOfBirthSupplied) { logTableChange("vl_patients","dateOfBirth",$patientID,getDetailedTableInfo2("vl_patients","id='$patientID'","dateOfBirth"),$dateOfBirth); $dateOfBirthChangeLogID=0; $dateOfBirthChangeLogID=getDetailedTableInfo2("vl_logs_tables","createdby='$trailSessionUser' order by id desc limit 1","id"); } //update patient information mysqlquery("update vl_patients set artNumber='$artNumber', otherID='$otherID', ".(!$noDateOfBirthSupplied?"dateOfBirth='$dateOfBirth', ":"dateOfBirth='', ")." gender='$gender' where id='$patientID'"); //log the change of gender warning if($mostRecentGender && (($mostRecentGender=="Female" && $gender=="Male") ||
gender='$gender' where id='$modify'"); //log patient phone number, if unique if($patientPhone) { $phoneID=0; $phoneID=getDetailedTableInfo2("vl_patients_phone","patientID='$modify' and phone='$patientPhone' limit 1","id"); if(!$phoneID) { mysqlquery("insert into vl_patients_phone (patientID,phone,created,createdby) values ('$modify','$patientPhone','$datetime','$trailSessionUser')"); } else { //log this change logTableChange("vl_patients_phone","created",$phoneID,getDetailedTableInfo2("vl_patients_phone","id='$phoneID'","created"),$datetime); mysqlquery("update vl_patients_phone set created='$datetime' where id='$phoneID'"); } } //redirect to home with updates on the tracking number go("/samples/modified/"); } } else { //prepopulate $artNumber=0; $artNumber=getDetailedTableInfo2("vl_patients","id='$modify' limit 1","artNumber"); $otherID=0; $otherID=getDetailedTableInfo2("vl_patients","id='$modify' limit 1","otherID");
mysqlquery("insert into vl_appendix_regimen (appendix,position,treatmentStatusID,created,createdby) values ('$appendix','$position','$treatmentLineStatusID','$datetime','$_SESSION[VLADMIN]')"); //flag $added=1; } else { $error.="<br>The supplied Appendix <strong>$appendix</strong> is already within the system"; } } break; case modify: //log table change logTableChange("vl_appendix_regimen","appendix",$id,getDetailedTableInfo2("vl_appendix_regimen","id='$id'","appendix"),$appendix); logTableChange("vl_appendix_regimen","position",$id,getDetailedTableInfo2("vl_appendix_regimen","id='$id'","position"),$position); logTableChange("vl_appendix_regimen","treatmentStatusID",$id,getDetailedTableInfo2("vl_appendix_regimen","id='$id'","treatmentStatusID"),$treatmentLineStatusID); //update vl_appendix_regimen mysqlquery("update vl_appendix_regimen set appendix='$appendix',position='$position',treatmentStatusID='$treatmentLineStatusID' where id='$id'"); //flag $modified=1; break; case remove: if(isQuery("select * from vl_appendix_regimen where id='$id'")) { //remove logDataRemoval("delete from vl_appendix_regimen where id='$id'"); mysqlquery("delete from vl_appendix_regimen where id='$id'"); //flag $removed=1; } break; default:
if(!isQuery("select * from vl_ips where ip='$ip'")) { //insert into vl_ips mysqlquery("insert into vl_ips (ip,created,createdby) values ('$ip','$datetime','$_SESSION[VLADMIN]')"); //flag $added=1; } else { $error.="<br>The supplied IP <strong>$ip</strong> is already within the system"; } } break; case modify: //log table change logTableChange("vl_ips","ip",$id,getDetailedTableInfo2("vl_ips","id='$id'","ip"),$ip); //update vl_ips mysqlquery("update vl_ips set ip='$ip' where id='$id'"); //flag $modified=1; break; case remove: if(isQuery("select * from vl_ips where id='$id'")) { //remove logDataRemoval("delete from vl_ips where id='$id'"); mysqlquery("delete from vl_ips where id='$id'"); //flag $removed=1; } break; default:
//insert into vl_appendix_arvadherence mysqlquery("insert into vl_appendix_arvadherence (appendix,position,created,createdby) values ('$appendix','$position','$datetime','$_SESSION[VLADMIN]')"); //flag $added=1; } else { $error.="<br>The supplied Appendix <strong>$appendix</strong> is already within the system"; } } break; case modify: //log table change logTableChange("vl_appendix_arvadherence","appendix",$id,getDetailedTableInfo2("vl_appendix_arvadherence","id='$id'","appendix"),$appendix); logTableChange("vl_appendix_arvadherence","position",$id,getDetailedTableInfo2("vl_appendix_arvadherence","id='$id'","position"),$position); //update vl_appendix_arvadherence mysqlquery("update vl_appendix_arvadherence set appendix='$appendix',position='$position' where id='$id'"); //flag $modified=1; break; case remove: if(isQuery("select * from vl_appendix_arvadherence where id='$id'")) { //remove logDataRemoval("delete from vl_appendix_arvadherence where id='$id'"); mysqlquery("delete from vl_appendix_arvadherence where id='$id'"); //flag $removed=1; } break; default:
/** * function to change a user's setting * @param: $userID * @param: $setting * @param: $value */ function alterUserSetting($userID,$setting,$value) { //globals global $datetime,$trailSessionUser; //does user have a setting account? $query=0; $query=mysqlquery("select * from vl_users_settings where userID='$userID'"); if(mysqlnumrows($query)) { //log table change logTableChange("vl_users_settings","$setting",getDetailedTableInfo2("vl_users_settings","userID='$userID'","id"),getDetailedTableInfo2("vl_users_settings","userID='$userID'","$setting"),$value); //update mysqlquery("update vl_users_settings set $setting='$value' where userID='$userID'"); } else { //insert mysqlquery("insert into vl_users_settings (userID,$setting,created,createdby) values ('$userID','$value','$datetime','$trailSessionUser')"); } }
//insert into vl_appendix_viralloadtesting mysqlquery("insert into vl_appendix_viralloadtesting (appendix,position,created,createdby) values ('$appendix','$position','$datetime','$_SESSION[VLADMIN]')"); //flag $added=1; } else { $error.="<br>The supplied Appendix <strong>$appendix</strong> is already within the system"; } } break; case modify: //log table change logTableChange("vl_appendix_viralloadtesting","appendix",$id,getDetailedTableInfo2("vl_appendix_viralloadtesting","id='$id'","appendix"),$appendix); logTableChange("vl_appendix_viralloadtesting","position",$id,getDetailedTableInfo2("vl_appendix_viralloadtesting","id='$id'","position"),$position); //update vl_appendix_viralloadtesting mysqlquery("update vl_appendix_viralloadtesting set appendix='$appendix',position='$position' where id='$id'"); //flag $modified=1; break; case remove: if(isQuery("select * from vl_appendix_viralloadtesting where id='$id'")) { //remove logDataRemoval("delete from vl_appendix_viralloadtesting where id='$id'"); mysqlquery("delete from vl_appendix_viralloadtesting where id='$id'"); //flag $removed=1; } break; default:
</tr> </table> <? } ?> <? switch($option) { case modify: $query=0; $query=mysqlquery("select * from vl_users_permissions where userID='$id'"); if(mysqlnumrows($query)) { while($q=mysqlfetcharray($query)) { $permission=0; $xpermission=0; $xpermission=$q["permission"]; $permission=$$xpermission; //log table change logTableChange("vl_users_permissions","permission",$q["id"],$q["permission"],$permission); } } //delete all user permissions mysqlquery("delete from vl_users_permissions where userID='$id'"); //insert if($samples) { mysqlquery("insert into vl_users_permissions (userID,permission,created,createdby) values ('$id','samples','$datetime','$_SESSION[VLADMIN]')"); $added+=1; } if($verifySamples) { mysqlquery("insert into vl_users_permissions (userID,permission,created,createdby) values ('$id','verifySamples','$datetime','$_SESSION[VLADMIN]')"); $added+=1; } if($unVerifySamples) { mysqlquery("insert into vl_users_permissions (userID,permission,created,createdby) values ('$id','unVerifySamples','$datetime','$_SESSION[VLADMIN]')"); $added+=1; } if($worksheets) { mysqlquery("insert into vl_users_permissions (userID,permission,created,createdby) values ('$id','worksheets','$datetime','$_SESSION[VLADMIN]')"); $added+=1; } if($generateForms) { mysqlquery("insert into vl_users_permissions (userID,permission,created,createdby) values ('$id','generateForms','$datetime','$_SESSION[VLADMIN]')"); $added+=1; } if($results) { mysqlquery("insert into vl_users_permissions (userID,permission,created,createdby) values ('$id','results','$datetime','$_SESSION[VLADMIN]')"); $added+=1; } if($reports) { mysqlquery("insert into vl_users_permissions (userID,permission,created,createdby) values ('$id','reports','$datetime','$_SESSION[VLADMIN]')"); $added+=1; } if($reportsQC) { mysqlquery("insert into vl_users_permissions (userID,permission,created,createdby) values ('$id','reportsQC','$datetime','$_SESSION[VLADMIN]')"); $added+=1; }
if(mysqlnumrows($query)) { while($q=mysqlfetcharray($query)) { //get the uniqueID $uniqueID=0; $uniqueID=$q["uniqueID"]; //split uniqueID based on -A- $uniqueIDArray=array(); $uniqueIDArray=explode("-A-",$uniqueID); $uniqueIDstring1=""; $uniqueIDstring2=""; $uniqueIDstring1=$uniqueIDArray[0]."-A-"; if(count($uniqueIDArray)) { for($i=1;$i<count($uniqueIDArray);$i++) { $uniqueIDstring2.=$uniqueIDArray[$i]; } //clean $uniqueIDstring by removing - . / and spaces $uniqueIDstring2=preg_replace("/\-/s","",$uniqueIDstring2); $uniqueIDstring2=preg_replace("/\./s","",$uniqueIDstring2); $uniqueIDstring2=preg_replace("/\//s","",$uniqueIDstring2); $uniqueIDstring2=preg_replace("/\s/s","",$uniqueIDstring2); //update vl_patients.uniqueID logTableChange("vl_patients","uniqueID",$q["id"],$q["uniqueID"],"$uniqueIDstring1$uniqueIDstring2"); mysqlquery("update vl_patients set uniqueID='$uniqueIDstring1$uniqueIDstring2' where id='$q[id]'"); //update vl_samples.patientUniqueID logTableChange("vl_samples","patientUniqueID",getDetailedTableInfo2("vl_samples","patientUniqueID='$q[uniqueID]' limit 1","id"),$q["uniqueID"],"$uniqueIDstring1$uniqueIDstring2"); mysqlquery("update vl_samples set patientUniqueID='$uniqueIDstring1$uniqueIDstring2' where patientUniqueID='$q[uniqueID]'"); } } } ?>
} } //log dispatch $id=0; $id=getDetailedTableInfo2("vl_logs_dispatchedresults","sampleID='$sampleID' and worksheetID='$worksheetID' limit 1","id"); if(!$id) { mysqlquery("insert into vl_logs_dispatchedresults (sampleID,worksheetID,facilityID,dateDispatched,created,createdby) values ('$sampleID','$worksheetID','$facilityID','$dispatchedDate','$datetime','$trailSessionUser')"); //flags $added+=1; } else { //log changes logTableChange("vl_logs_dispatchedresults","dateDispatched",$id,getDetailedTableInfo2("vl_logs_dispatchedresults","id='$id'","dateDispatched"),$dispatchedDate); logTableChange("vl_logs_dispatchedresults","facilityID",$id,getDetailedTableInfo2("vl_logs_dispatchedresults","id='$id'","facilityID"),$facilityID); mysqlquery("update vl_logs_dispatchedresults set dispatchDate='$dispatchedDate', facilityID='$facilityID' where id='$id'"); //flags $modified+=1; } } } //redirect to home with updates on the tracking number go("/results/dispatched/".($added?$added:"0")."/".($modified?$modified:"0")."/$machineType/"); } }
/** * 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'"); } }
(username,password,email,phone,created,createdby) values ('$username','".vlSimpleEncrypt($password)."','$email','$phone','$datetime','$_SESSION[VLADMIN]')"); //flag $added=1; } else { $error.="<br>The supplied Username <strong>$username</strong> is already within the system"; } } break; case modify: //log table change logTableChange("vl_admins","username",$id,getDetailedTableInfo2("vl_admins","id='$id'","username"),$username); logTableChange("vl_admins","email",$id,getDetailedTableInfo2("vl_admins","id='$id'","email"),$email); logTableChange("vl_admins","phone",$id,getDetailedTableInfo2("vl_admins","id='$id'","phone"),$phone); logTableChange("vl_admins","password",$id,"old password","new password"); //update vl_admins mysqlquery("update vl_admins set username='******', email='$email', ".($password?"password='******',":"")." phone='$phone' where id='$id'"); //flag $modified=1; break; case remove: if(isQuery("select * from vl_admins where id='$id'")) { //remove logDataRemoval("delete from vl_admins where id='$id'"); mysqlquery("delete from vl_admins where id='$id'");
if(mysqlnumrows($query)) { while($q=mysqlfetcharray($query)) { //remove logDataRemoval("delete from vl_appendix_treatmentstatus where id='$q[id]'"); mysqlquery("delete from vl_appendix_treatmentstatus where id='$q[id]'"); } } //task 8: match the districtID and hubID within vl_samples to the facility within vl_facilities $query=0; $query=mysqlquery("select distinct facilityID,districtID,hubID from vl_samples"); if(mysqlnumrows($query)) { while($q=mysqlfetcharray($query)) { //log table change logTableChange("vl_facilities","districtID",$q["facilityID"],getDetailedTableInfo2("vl_facilities","id='$q[facilityID]'","districtID"),$q["districtID"]); logTableChange("vl_facilities","hubID",$q["facilityID"],getDetailedTableInfo2("vl_facilities","id='$q[facilityID]'","hubID"),$q["hubID"]); //update vl_facilities mysqlquery("update vl_facilities set districtID='$q[districtID]', hubID='$q[hubID]' where id='$q[facilityID]'"); } } //task 9: remove facilities with no samples $query=0; $query=mysqlquery("select * from vl_facilities where id not in (select facilityID from vl_samples)"); if(mysqlnumrows($query)) { while($q=mysqlfetcharray($query)) { //remove logDataRemoval("delete from vl_facilities where id='$q[id]'"); mysqlquery("delete from vl_facilities where id='$q[id]'"); } }
//logTableChange("vl_samples_worksheetcredentials","worksheetName",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","worksheetName"),$worksheetName); logTableChange("vl_samples_worksheetcredentials","worksheetReferenceNumber",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","worksheetReferenceNumber"),$worksheetReferenceNumber); logTableChange("vl_samples_worksheetcredentials","worksheetType",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","worksheetType"),$worksheetType); logTableChange("vl_samples_worksheetcredentials","machineType",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","machineType"),$machineType); logTableChange("vl_samples_worksheetcredentials","samplePrep",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","samplePrep"),$samplePrep); logTableChange("vl_samples_worksheetcredentials","samplePrepExpiryDate",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","samplePrepExpiryDate"),$samplePrepExpiryDate); logTableChange("vl_samples_worksheetcredentials","bulkLysisBuffer",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","bulkLysisBuffer"),$bulkLysisBuffer); logTableChange("vl_samples_worksheetcredentials","bulkLysisBufferExpiryDate",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","bulkLysisBufferExpiryDate"),$bulkLysisBufferExpiryDate); logTableChange("vl_samples_worksheetcredentials","control",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","control"),$control); logTableChange("vl_samples_worksheetcredentials","controlExpiryDate",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","controlExpiryDate"),$controlExpiryDate); logTableChange("vl_samples_worksheetcredentials","calibrator",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","calibrator"),$calibrator); logTableChange("vl_samples_worksheetcredentials","calibratorExpiryDate",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","calibratorExpiryDate"),$calibratorExpiryDate); logTableChange("vl_samples_worksheetcredentials","amplificationKit",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","amplificationKit"),$amplificationKit); logTableChange("vl_samples_worksheetcredentials","amplificationKitExpiryDate",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","amplificationKitExpiryDate"),$amplificationKitExpiryDate); logTableChange("vl_samples_worksheetcredentials","assayDate",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","assayDate"),$assayDate); logTableChange("vl_samples_worksheetcredentials","includeCalibrators",$modify,getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$modify'","includeCalibrators"),$includeCalibrators); //implement the changes mysqlquery("update vl_samples_worksheetcredentials set worksheetReferenceNumber='$worksheetReferenceNumber', worksheetType='$worksheetType', machineType='$machineType', samplePrep='$samplePrep', samplePrepExpiryDate='$samplePrepExpiryDate', bulkLysisBuffer='$bulkLysisBuffer', bulkLysisBufferExpiryDate='$bulkLysisBufferExpiryDate', control='$control', controlExpiryDate='$controlExpiryDate', calibrator='$calibrator', calibratorExpiryDate='$calibratorExpiryDate', amplificationKit='$amplificationKit',
//flag $modified=1; } break; case activate: //log table change logTableChange("vl_users","activate",$id,getDetailedTableInfo2("vl_users","id='$id'","activate"),"1"); //update vl_users mysqlquery("update vl_users set active='1' where id='$id'"); //flag $id=0; $activated=1; break; case deactivate: //log table change logTableChange("vl_users","activate",$id,getDetailedTableInfo2("vl_users","id='$id'","activate"),"0"); //update vl_users mysqlquery("update vl_users set active='0' where id='$id'"); //flag $id=0; $deactivated=1; break; case remove: if(isQuery("select * from vl_users where id='$id'")) { //remove if(is_file(getDetailedTableInfo2("vl_users","id='$id'","signaturePATH"))) { unlink(getDetailedTableInfo2("vl_users","id='$id'","signaturePATH")); } logDataRemoval("delete from vl_users where id='$id'"); mysqlquery("delete from vl_users where id='$id'"); logDataRemoval("delete from vl_users_history where userID='$id'");
//insert into vl_appendix_tbtreatmentphase mysqlquery("insert into vl_appendix_tbtreatmentphase (appendix,position,created,createdby) values ('$appendix','$position','$datetime','$_SESSION[VLADMIN]')"); //flag $added=1; } else { $error.="<br>The supplied Appendix <strong>$appendix</strong> is already within the system"; } } break; case modify: //log table change logTableChange("vl_appendix_tbtreatmentphase","appendix",$id,getDetailedTableInfo2("vl_appendix_tbtreatmentphase","id='$id'","appendix"),$appendix); logTableChange("vl_appendix_tbtreatmentphase","position",$id,getDetailedTableInfo2("vl_appendix_tbtreatmentphase","id='$id'","position"),$position); //update vl_appendix_tbtreatmentphase mysqlquery("update vl_appendix_tbtreatmentphase set appendix='$appendix',position='$position' where id='$id'"); //flag $modified=1; break; case remove: if(isQuery("select * from vl_appendix_tbtreatmentphase where id='$id'")) { //remove logDataRemoval("delete from vl_appendix_tbtreatmentphase where id='$id'"); mysqlquery("delete from vl_appendix_tbtreatmentphase where id='$id'"); //flag $removed=1; } break; default:
$error.="<br />Another Envelope with the same Batch Number <strong>$batchNumber</strong> already exists.<br />Kindly provide an alternative Batch Number<br />"; } //input data if(!$error) { //formate date $currentDateTime=0; $currentDateTime="$receivedDateYear-$receivedDateMonth-$receivedDateDay ".getFormattedTime(getDetailedTableInfo2("vl_envelopes","id='$modify' limit 1","created")); //log changes logTableChange("vl_envelopes","envelopeNumber",$modify,getDetailedTableInfo2("vl_envelopes","id='$modify'","envelopeNumber"),$envelopeNumber); logTableChange("vl_envelopes","batchNumber",$modify,getDetailedTableInfo2("vl_envelopes","id='$modify'","batchNumber"),$batchNumber); logTableChange("vl_envelopes","districtID",$modify,getDetailedTableInfo2("vl_envelopes","id='$modify'","districtID"),$districtID); logTableChange("vl_envelopes","hubID",$modify,getDetailedTableInfo2("vl_envelopes","id='$modify'","hubID"),$hubID); logTableChange("vl_envelopes","facilityID",$modify,getDetailedTableInfo2("vl_envelopes","id='$modify'","facilityID"),$facilityID); logTableChange("vl_envelopes","created",$modify,getDetailedTableInfo2("vl_envelopes","id='$modify'","created"),$currentDateTime); mysqlquery("update vl_envelopes set envelopeNumber='$envelopeNumber', batchNumber='$batchNumber', districtID='$districtID', hubID='$hubID', facilityID='$facilityID', created='$currentDateTime' where id='$modify'"); //redirect to home with updates on the tracking number go("/envelopes/modified/"); } } else {
/** * function to log result overrides */ function logResultOverride($sampleID,$worksheetID,$result) { global $datetime,$trailSessionUser; //validate $sampleID=validate($sampleID); $worksheetID=validate($worksheetID); $result=validate($result); $id=0; $id=getDetailedTableInfo2("vl_results_override","sampleID='$sampleID' and worksheetID='$worksheetID'","id"); //avoid duplicates if(!$id) { //insert into vl_results_override mysqlquery("insert into vl_results_override (sampleID,worksheetID,result,created,createdby) values ('$sampleID','$worksheetID','$result','$datetime','$trailSessionUser')"); } else { //log table change logTableChange("vl_results_override","result",$id,getDetailedTableInfo2("vl_results_override","id='$id'","result"),$result); //update vl_results_override mysqlquery("update vl_results_override set result='$result' where id='$id'"); } }
//log the forms mysqlquery("delete from vl_forms_clinicalrequest where refNumber='$refNumber'"); for($i=$serialNumberStart;$i<=$serialNumberEnd;$i++) { generateFormNumber($i,$refNumber); } //log issue if(!getDetailedTableInfo2("vl_forms_clinicalrequest_dispatch","refNumber='$refNumber' limit 1","id")) { mysqlquery("insert into vl_forms_clinicalrequest_dispatch (refNumber,dispatchDate,facilityID,created,createdby) values ('$refNumber','$dispatchedDate','$facilityID','$datetime','$trailSessionUser')"); } else { //log changes logTableChange("vl_forms_clinicalrequest_dispatch","dispatchDate",getDetailedTableInfo2("vl_forms_clinicalrequest_dispatch","refNumber='$refNumber'","id"),getDetailedTableInfo2("vl_forms_clinicalrequest_dispatch","refNumber='$refNumber'","dispatchDate"),$dispatchedDate); logTableChange("vl_forms_clinicalrequest_dispatch","facilityID",getDetailedTableInfo2("vl_forms_clinicalrequest_dispatch","refNumber='$refNumber'","id"),getDetailedTableInfo2("vl_forms_clinicalrequest_dispatch","refNumber='$refNumber'","facilityID"),$facilityID); mysqlquery("update vl_forms_clinicalrequest_dispatch set dispatchDate='$dispatchedDate', facilityID='$facilityID' where refNumber='$refNumber'"); } //redirect to home with updates on the tracking number go("/generateforms/dispatch/success/"); } } ?> <script Language="JavaScript" Type="text/javascript"> <!-- function validate(envelopes) {
logTableChange("vl_samples","tbTreatmentPhaseID",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","tbTreatmentPhaseID"),$tbTreatmentPhaseID); logTableChange("vl_samples","arvAdherenceID",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","arvAdherenceID"),$arvAdherenceID); logTableChange("vl_samples","viralLoadTestingIndication",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","viralLoadTestingIndication"),$viralLoadTestingIndication); logTableChange("vl_samples","routineMonitoringLastVLDate",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","routineMonitoringLastVLDate"),$routineMonitoringLastVLDate); logTableChange("vl_samples","routineMonitoringValue",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","routineMonitoringValue"),$routineMonitoringValue); logTableChange("vl_samples","routineMonitoringSampleTypeID",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","routineMonitoringSampleTypeID"),$routineMonitoringSampleTypeID); logTableChange("vl_samples","repeatVLTestLastVLDate",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","repeatVLTestLastVLDate"),$repeatVLTestLastVLDate); logTableChange("vl_samples","repeatVLTestValue",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","repeatVLTestValue"),$repeatVLTestValue); logTableChange("vl_samples","repeatVLTestSampleTypeID",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","repeatVLTestSampleTypeID"),$repeatVLTestSampleTypeID); logTableChange("vl_samples","suspectedTreatmentFailureLastVLDate",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","suspectedTreatmentFailureLastVLDate"),$suspectedTreatmentFailureLastVLDate); logTableChange("vl_samples","suspectedTreatmentFailureValue",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","suspectedTreatmentFailureValue"),$suspectedTreatmentFailureValue); logTableChange("vl_samples","suspectedTreatmentFailureSampleTypeID",$modify,getDetailedTableInfo2("vl_samples","id='$modify'","suspectedTreatmentFailureSampleTypeID"),$suspectedTreatmentFailureSampleTypeID); mysqlquery("update vl_samples set lrCategory='$lrCategory', lrEnvelopeNumber='$lrEnvelopeNumber', lrNumericID='$lrNumericID', formNumber='$formNumber', districtID='$districtID', hubID='$hubID', facilityID='$facilityID', currentRegimenID='$currentRegimenID', pregnant='$pregnant', pregnantANCNumber='$pregnantANCNumber', breastfeeding='$breastfeeding', activeTBStatus='$activeTBStatus',
/** * function to generate a credit application reference */ function generateFormNumber($number,$batch) { global $datetime,$trailSessionUser; //log this entry into the db if(!getDetailedTableInfo2("vl_forms_clinicalrequest","formNumber='$number' limit 1","id")) { mysqlquery("insert into vl_forms_clinicalrequest (formNumber,refNumber,created,createdby) values ('$number','$batch','$datetime','$trailSessionUser')"); } else { //modify $id=0; $id=getDetailedTableInfo2("vl_forms_clinicalrequest","formNumber='$number'","id"); logTableChange("vl_forms_clinicalrequest","refNumber",$id,getDetailedTableInfo2("vl_forms_clinicalrequest","id='$id'","refNumber"),$batch); mysqlquery("update vl_forms_clinicalrequest set refNumber='$batch' where id='$id'"); } }