//$worksheetID=getDetailedTableInfo2("vl_samples_worksheet","sampleID='$sampleID' order by created desc limit 1","worksheetID"); $sampleVLTestDate=0; //$sampleVLTestDate=getDetailedTableInfo2("vl_results_abbott_runtimes","worksheetID='$worksheetID' limit 1","runCompletionTime"); //if(!$sampleVLTestDate) { $sampleVLTestDate=getDetailedTableInfo2($resultsTable,"$resultsSampleType='$vlSampleID' order by created desc limit 1","created"); //} //factor $factor=0; $factor=getDetailedTableInfo2("vl_results_multiplicationfactor","worksheetID='$worksheetID' limit 1","factor"); if(!$factor) { $factor=1; } $vlResult=0; //$vlResult=getDetailedTableInfo2($resultsTable,"$resultsSampleType='$vlSampleID' order by created desc limit 1",$resultField); $vlResult=getVLResult($machineType,$worksheetID,$vlSampleID,$factor); //signatures $worksheetOwner=0; $worksheetOwner=getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$worksheetID'","createdby"); $labTechSignature=0; if(getDetailedTableInfo2("vl_users","email='$worksheetOwner'","signatureURL")) { $labTechSignature="<img src=\"".getDetailedTableInfo2("vl_users","email='$worksheetOwner'","signatureURL")."\" width=\"120\" height=\"50\" />"; } $labManagerSignature=0; if(getDetailedTableInfo2("vl_users","role='Lab Manager' order by created desc limit 1","signatureURL")) { $labManagerSignature="<img src=\"".getDetailedTableInfo2("vl_users","role='Lab Manager' order by created desc limit 1","signatureURL")."\" width=\"120\" height=\"50\" />"; }
$worksheetReferenceNumber=0; $factor=0; $result=0; $rejectionReason=0; $outcomeReasonID=0; if($worksheetID) { //worksheets $worksheetUniqueID=$worksheetID; $worksheetReferenceNumber=getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$worksheetUniqueID'","worksheetReferenceNumber"); //factor $factor=getDetailedTableInfo2("vl_results_multiplicationfactor","worksheetID='$worksheetUniqueID' limit 1","factor"); if(!$factor) { $factor=1; } //results $result=getVLResult($machineType,$worksheetID,$sampleReferenceNumber,$factor); } else { $outcomeReasonID=getDetailedTableInfo2("vl_samples_verify","sampleID='$sampleID' and outcome='Rejected' limit 1","outcomeReasonsID"); $rejectionReason=getDetailedTableInfo2("vl_appendix_samplerejectionreason","id='$outcomeReasonID' and sampleTypeID='$sampleTypeID'","appendix"); } ?> <tr onMouseover="this.bgColor='#f0e6dd'" onMouseout="this.bgColor='#FFFFFF'"> <td class="<?php echo $count < $num ? "vl_tdstandard" : "vl_tdnoborder"; ?> "><?php echo $count; ?> <input name="sampleResultHidden[]" type="hidden" id="sampleResultHidden[]" value="<?php echo $sampleID . "|" . $worksheetUniqueID; ?>
* task 9: match the districtID and hubID within vl_samples to the facility within vl_facilities * task 10: remove facilities with no samples * task 11: populate vl_results_merged */ //task 11: populate vl_results_merged, begin with abbott $query=0; $query=mysqlquery("select * from vl_results_abbott"); if(mysqlnumrows($query)) { while($q=mysqlfetcharray($query)) { //factor $factor=0; $factor=getDetailedTableInfo2("vl_results_multiplicationfactor","worksheetID='$q[worksheetID]' limit 1","factor"); if(!$factor) { $factor=1; } //alphanumeric result $resultAlphanumeric=0; $resultAlphanumeric=getVLResult("abbott",$q["worksheetID"],$q["sampleID"],$factor); //numeric result $resultNumeric=0; $resultNumeric=getVLNumericResultOnly($resultAlphanumeric); mysqlquery("insert ignore into vl_results_merged (machine,worksheetID,vlSampleID,resultAlphanumeric, resultNumeric,created,createdby) values ('abbott','$q[worksheetID]','$q[sampleID]','$resultAlphanumeric', '$resultNumeric','$q[created]','$q[createdby]')"); } } ?>
$rcount=0; $rnum=0; $rnum=mysqlnumrows($rquery); if($rnum) { while($rq=mysqlfetcharray($rquery)) { //key variables $rcount+=1; $worksheetID=0; $worksheetID=getDetailedTableInfo2("vl_results_roche","SampleID='$rq[vlSampleID]' order by created desc limit 1","worksheetID"); $factor=0; $factor=getDetailedTableInfo2("vl_results_multiplicationfactor","worksheetID='$worksheetID' limit 1","factor"); if(!$factor) { $factor=1; } //results $results.=getVLResult("roche",$worksheetID,$rq["vlSampleID"],$factor).($rcount<$rnum?", ":""); } } //xls $dataRocheResults[]=array($patientART,$patientOtherID,$facility,$numberResults,$results); } } //output to xlsx $writer = new XLSXWriter(); $writer->setAuthor($default_institutionName); $writer->writeSheet($dataAbbottResults,"abbott",$headerAbbottResults); $writer->writeSheet($dataRocheResults,"roche",$headerRocheResults); $writer->writeToStdOut(); break; case "clinicalrequestformsexcel":
*/ //task 11: populate vl_results_merged, begin with abbott $query=0; $query=mysqlquery("select * from vl_results_roche"); if(mysqlnumrows($query)) { //flush the db mysqlquery("delete from vl_results_merged where machine='roche'"); while($q=mysqlfetcharray($query)) { //factor $factor=0; $factor=getDetailedTableInfo2("vl_results_multiplicationfactor","worksheetID='$q[worksheetID]' limit 1","factor"); if(!$factor) { $factor=1; } //alphanumeric result $resultAlphanumeric=0; $resultAlphanumeric=getVLResult("roche",$q["worksheetID"],$q["SampleID"],$factor); $resultAlphanumeric=preg_replace("/'/s","\'",$resultAlphanumeric); //numeric result $resultNumeric=0; $resultNumeric=getVLNumericResultOnly($resultAlphanumeric); mysqlquery("insert ignore into vl_results_merged (machine,worksheetID,vlSampleID,resultAlphanumeric, resultNumeric,created,createdby) values ('roche','$q[worksheetID]','$q[SampleID]','$resultAlphanumeric', '$resultNumeric','$q[created]','$q[createdby]')"); } } ?>
$otherID=0; $otherID=getDetailedTableInfo2("vl_patients","id='$patientID' limit 1","otherID"); //factor $factor=0; $factor=getDetailedTableInfo2("vl_results_multiplicationfactor","worksheetID='$worksheetID' limit 1","factor"); if(!$factor) { $factor=1; } $result=0; $rawResult=0; if($type=="roche") { $rawResult=getDetailedTableInfo2("vl_results_roche","worksheetID='$worksheetID' and SampleID='$sampleNumber' order by created desc limit 1","Result"); } elseif($type=="abbott") { $rawResult=getDetailedTableInfo2("vl_results_abbott","worksheetID='$worksheetID' and sampleID='$sampleNumber' order by created desc limit 1","result"); } $result=getVLResult($type,$worksheetID,$sampleNumber,$factor); $contents[]="<div align=\"center\" class=\"vls\">$i</div> <div align=\"center\" class=\"vls\" style=\"padding:3px 0px 0px 0px\">Patient ART #: $patientART</div> <div align=\"center\" class=\"vls\" style=\"padding:3px 0px 0px 0px\">Other ID: $otherID</div> <div align=\"center\" class=\"vls\" style=\"padding:1px 0px 0px 0px\">Sample #: $sampleNumber</div> ".($locationID?"<div align=\"center\" class=\"vls\" style=\"padding:1px 0px 0px 0px\">Location ID: $locationID</div> ":"")." <div align=\"center\" class=\"vls\" style=\"padding:1px 0px 0px 0px\">Form #: $formNumber</div> <div align=\"center\" style=\"padding:5px 0px\"><img src=\"/worksheets/image/".vlEncrypt($sampleNumber)."/\" /></div> ".($rawResult?"<div align=\"center\" class=\"vls\" style=\"padding:5px 0px 0px 0px; border-top: 1px dashed #cccccc\">Result: $result</div>":""); //log printed status if(!getDetailedTableInfo2("vl_logs_worksheetsamplesviewed","sampleID='$sampleID' and worksheetID='$worksheetID' limit 1","id")) { mysqlquery("insert into vl_logs_worksheetsamplesviewed (sampleID,worksheetID,created,createdby) values
$sampleReceiptDate=0; $sampleReceiptDate=getDetailedTableInfo2("vl_samples","id='$sampleID'","receiptDate"); $sampleVLTestDate=0; //$sampleVLTestDate=getDetailedTableInfo2("vl_results_abbott_runtimes","worksheetID='$worksheetID' limit 1","runCompletionTime"); //if(!$sampleVLTestDate) { $sampleVLTestDate=getDetailedTableInfo2($resultsTable,"$resultsSampleType='$vlSampleID' order by created desc limit 1","created"); //} //factor $factor=0; $factor=getDetailedTableInfo2("vl_results_multiplicationfactor","worksheetID='$worksheetID' limit 1","factor"); if(!$factor) { $factor=1; } $vlResult=0; $vlResult=getVLResult(($worksheetMachineType?$worksheetMachineType:$machineType),$worksheetID,$vlSampleID,$factor); //signatures $worksheetOwner=0; $worksheetOwner=getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$worksheetID'","createdby"); $labTechSignature=0; if(getDetailedTableInfo2("vl_users","email='$worksheetOwner'","signaturePATH")) { $labTechSignature="<img src=\"".getDetailedTableInfo2("vl_users","email='$worksheetOwner'","signaturePATH")."\" width=\"120\" height=\"50\" />"; } $labManagerSignature=0; if(getDetailedTableInfo2("vl_users","role='Lab Manager' order by created desc limit 1","signaturePATH")) { $labManagerSignature="<img src=\"".getDetailedTableInfo2("vl_users","role='Lab Manager' order by created desc limit 1","signaturePATH")."\" width=\"120\" height=\"50\" />"; }
} } //last worksheet $lastWorksheetID=0; $lastWorksheetID=getDetailedTableInfo2("vl_samples_worksheet","sampleID='$q[id]' order by created desc limit 1","worksheetID"); $lastWorksheetName=0; $lastWorksheetName=getDetailedTableInfo2("vl_samples_worksheetcredentials","id='$lastWorksheetID' limit 1","worksheetReferenceNumber"); //factor $factor=1; $factor=getDetailedTableInfo2("vl_results_multiplicationfactor","worksheetID='$lastWorksheetID' limit 1","factor"); //results $result=0; $result=getVLResult($machineType,$lastWorksheetID,$q["vlSampleID"],$factor); //date first printed $dateFirstPrinted=0; $dateFirstPrinted=getDetailedTableInfo2("vl_logs_printedresults","sampleID='$q[id]' order by created limit 1","created"); if(!$dateFirstPrinted) { $dateFirstPrinted=getDetailedTableInfo2("vl_logs_printedrejectedresults","sampleID='$q[id]' order by created limit 1","created"); } //add rows $row=array(); $row[]=$q[formNumber]; $row[]="$q[lrCategory]$q[lrEnvelopeNumber]/$q[lrNumericID]"; $row[]=$q[vlSampleID]; $row[]=getDetailedTableInfo2("vl_facilities","id='$q[facilityID]' limit 1","facility"); $row[]=getDetailedTableInfo2("vl_districts","id='$q[districtID]' limit 1","district");
calibratorExpirationDate='$calibratorExpirationDate', calibratorLogConcentration='$calibratorLogConcentration', resultComment='$resultComment', targetMR='$targetMR', icMR='$icMR' where id='$modify'"); //automatically log whether this sample should be repeated $abbottSampleID=0; $abbottSampleID=getDetailedTableInfo2("vl_samples","vlSampleID='$sampleID' limit 1","id"); $log_repeat_values .= logRepeat("abbott",$abbottSampleID,$worksheetID,$result,$flags); //log into vl_results_merged //alphanumeric result $resultAlphanumeric=0; $resultAlphanumeric=getVLResult("abbott",$worksheetID,$sampleID,$factor); //numeric result $resultNumeric=0; $resultNumeric=getVLNumericResultOnly($resultAlphanumeric); $is_res_valid=isResultValid($resultAlphanumeric); //checks for validity of the result $spprssn_status=isSuppressed($is_res_valid,$resultNumeric); //get the suppression status //update $resultsMergedSampleID=0; $resultsMergedSampleID=getDetailedTableInfo2("vl_results_merged","vlSampleID='$sampleID' and worksheetID='$worksheetID' and machine='abbott' limit 1","id"); 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
$scheduledOn=getDetailedTableInfo2("vl_logs_samplerepeats","sampleID='$sampleID' and oldWorksheetID='$worksheetID' limit 1","created"); $repeatedOn=0; $repeatedOn=getDetailedTableInfo2("vl_logs_samplerepeats","sampleID='$sampleID' and oldWorksheetID='$worksheetID' limit 1","repeatedOn"); $withWorksheetID=0; $withWorksheetID=getDetailedTableInfo2("vl_logs_samplerepeats","sampleID='$sampleID' and oldWorksheetID='$worksheetID' limit 1","withWorksheetID"); $repeatedFactor=0; $repeatedFactor=getDetailedTableInfo2("vl_results_multiplicationfactor","worksheetID='$withWorksheetID' limit 1","factor"); if(!$repeatedFactor) { $repeatedFactor=1; } $repeatedResult=0; $repeatedResult=getVLResult($machineType,$withWorksheetID,$sampleReferenceNumber,$repeatedFactor); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" cellspacing="0" cellpadding="0" class="vl"> <tr> <td class="tab_active">FORM: <?php echo getDetailedTableInfo2("vl_samples", "id='{$sampleID}'", "formNumber"); ?> </td> </tr> </table></td> </tr> <tr> <td style="border:1px solid #CCCCFF; padding:20px"> <table width="100%" border="0" class="vl">