public function specimenCountPerStatus() { $this->withoutMiddleware(); $this->call('POST', '/specimentype', $this->specimenData); $specimenTypeStored = SpecimenType::orderBy('id', 'desc')->first(); $specimenTypeSaved = SpecimenType::find($specimenTypeStored->id); $count = $specimenTypeSaved->countPerStatus([Specimen::ACCEPTED, Specimen::REJECTED, Specimen::NOT_COLLECTED]); $this->assertEquals($specimenTypeSaved->specimen->count(), $count); }
/** * Remove the specified resource from storage (soft delete). * * @param int $id * @return Response */ public function delete($id) { //Soft delete the specimentype $specimentype = SpecimenType::find($id); $inUseByTesttype = $specimentype->testTypes->toArray(); $inUseBySpecimen = $specimentype->specimen->toArray(); // dd($inUseBySpecimen); if (empty($inUseByTesttype) && empty($inUseBySpecimen)) { // The specimen type is not in use $specimentype->delete(); } else { // The specimen type is in use return view('specimentype.index')->with('message', trans('terms.failure-delete-record')); } // redirect $url = session('SOURCE_URL'); return redirect()->to($url)->with('message', trans('terms.record-successfully-deleted')); }
/** * MOH 706 * */ public function moh706() { // Variables definition $date = date('Y-m-d'); $from = Input::get('start'); if (!$from) { $from = date('Y-m-01'); } $end = Input::get('end'); if (!$end) { $end = $date; } $toPlusOne = date_add(new DateTime($end), date_interval_create_from_date_string('1 day')); $to = date_add(new DateTime($end), date_interval_create_from_date_string('1 day'))->format('Y-m-d'); $ageRanges = array('0-5', '5-14', '14-120'); $sex = array(Patient::MALE, Patient::FEMALE); $ranges = array('Low', 'Normal', 'High'); $specimen_types = array('Urine', 'Pus', 'HVS', 'Throat', 'Stool', 'Blood', 'CSF', 'Water', 'Food', 'Other fluids'); $isolates = array('Naisseria', 'Klebsiella', 'Staphylococci', 'Streptoccoci' . 'Proteus', 'Shigella', 'Salmonella', 'V. cholera', 'E. coli', 'C. neoformans', 'Cardinella vaginalis', 'Haemophilus', 'Bordotella pertusis', 'Pseudomonas', 'Coliforms', 'Faecal coliforms', 'Enterococcus faecalis', 'Total viable counts-22C', 'Total viable counts-37C', 'Clostridium', 'Others'); // Get specimen_types for microbiology $labSecId = TestCategory::getTestCatIdByName('microbiology'); $specTypeIds = DB::select(DB::raw("select distinct(specimen_types.id) as spec_id from testtype_specimentypes" . " join test_types on test_types.id=testtype_specimentypes.test_type_id" . " join specimen_types on testtype_specimentypes.specimen_type_id=specimen_types.id" . " where test_types.test_category_id=?"), array($labSecId)); // Referred out specimen $referredSpecimens = DB::select(DB::raw("SELECT specimen_type_id, specimen_types.name as spec, count(specimens.id) as tot," . " facility_id, facilities.name as facility FROM specimens" . " join referrals on specimens.referral_id=referrals.id" . " join specimen_types on specimen_type_id=specimen_types.id" . " join facilities on referrals.facility_id=facilities.id" . " where referral_id is not null and status=1" . " and time_accepted between ? and ?" . " group by facility_id;"), array($from, $toPlusOne)); $table = '<!-- URINALYSIS --> <div class="col-sm-12"> <strong>URINE ANALYSIS</strong> <table class="table table-condensed report-table-border"> <thead> <tr> <th rowspan="2">Urine Chemistry</th> <th colspan="2">No. Exam</th> <th colspan="4"> Number positive</th> </tr> <tr> <th>M</th> <th>F</th> <th>Total</th> <th><5yrs</th> <th>5-14yrs</th> <th>>14yrs</th> </tr> </thead>'; $urinaId = TestType::getTestTypeIdByTestName('Urinalysis'); $urinalysis = TestType::find($urinaId); $urineChem = TestType::getTestTypeIdByTestName('Urine Chemistry'); $urineChemistry = TestType::find($urineChem); $measures = TestTypeMeasure::where('test_type_id', $urinaId)->orderBy('measure_id', 'DESC')->get(); $table .= '<tbody> <tr> <td>Totals</td>'; foreach ($sex as $gender) { $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [$gender], null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineChemistry, [$gender], null, $from, $toPlusOne)) . '</td>'; } $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, null, null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineChemistry, null, null, $from, $toPlusOne)) . '</td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) + $this->getGroupedTestCounts($urineChemistry, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne)) . '</td>'; } $table .= '</tr>'; foreach ($measures as $measure) { $tMeasure = Measure::find($measure->measure_id); if (in_array($tMeasure->name, ['ph', 'Epithelial cells', 'Pus cells', 'S. haematobium', 'T. vaginalis', 'Yeast cells', 'Red blood cells', 'Bacteria', 'Spermatozoa'])) { continue; } $table .= '<tr> <td>' . $tMeasure->name . '</td>'; foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, null, 1) . '</td>'; } $table .= '</tr>'; } $table .= '<tr> <td>Others</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> <table class="table table-condensed report-table-border"> <thead> <tr> <th rowspan="2">Urine Microscopy</th> <th colspan="2">No. Exam</th> <th colspan="4"> Number positive</th> </tr> <tr> <th>M</th> <th>F</th> <th>Total</th> <th><5yrs</th> <th>5-14yrs</th> <th>>14yrs</th> </tr> </thead> <tbody> <tr> <td>Totals</td>'; $urineMic = TestType::getTestTypeIdByTestName('Urine Microscopy'); $urineMicroscopy = TestType::find($urineMic); $measures = TestTypeMeasure::where('test_type_id', $urinaId)->orderBy('measure_id', 'DESC')->get(); foreach ($sex as $gender) { $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [$gender], null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineMicroscopy, [$gender], null, $from, $toPlusOne)) . '</td>'; } $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, null, null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineMicroscopy, null, null, $from, $toPlusOne)) . '</td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) + $this->getGroupedTestCounts($urineMicroscopy, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne)) . '</td>'; } $table .= '</tr>'; foreach ($measures as $measure) { $tMeasure = Measure::find($measure->measure_id); if (in_array($tMeasure->name, ['Leucocytes', 'Nitrites', 'Glucose', 'pH', 'Bilirubin', 'Ketones', 'Proteins', 'Blood', 'Urobilinogen Phenlpyruvic acid'])) { continue; } $table .= '<tr> <td>' . $tMeasure->name . '</td>'; foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, null, 1) . '</td>'; } $table .= '</tr>'; } $table .= '<tr> <td>Others</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> <table class="table table-condensed report-table-border"> <thead> <tr> <th rowspan="2">Blood Chemistry</th> <th colspan="2">No. Exam</th> <th colspan="4"> Number positive</th> </tr> <tr> <th>M</th> <th>F</th> <th>Total</th> <th>Low</th> <th>Normal</th> <th>High</th> </tr> </thead> <tbody>'; $bloodChem = TestType::getTestTypeIdByTestName('Blood Sugar'); $bloodChemistry = TestType::find($bloodChem); $measures = TestTypeMeasure::where('test_type_id', $bloodChem)->orderBy('measure_id', 'DESC')->get(); $table .= '<tr> <td>Totals</td>'; foreach ($sex as $gender) { $table .= '<td>' . $this->getGroupedTestCounts($bloodChemistry, [$gender], null, $from, $toPlusOne) . '</td>'; } $table .= '<td>' . $this->getGroupedTestCounts($bloodChemistry, null, null, $from, $toPlusOne) . '</td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . $this->getGroupedTestCounts($bloodChemistry, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>'; } foreach ($measures as $measure) { $tMeasure = Measure::find($measure->measure_id); $table .= '<tr> <td>' . $tMeasure->name . '</td>'; foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, ['Low', 'Normal', 'High'], null) . '</td>'; foreach ($ranges as $range) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>'; } $table .= '</tr>'; } $table .= '<tr> <td>OGTT</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> <table class="table table-condensed report-table-border"> <thead> <tr> <th rowspan="2">Renal function tests</th> <th colspan="2">No. Exam</th> <th colspan="4"> Number positive</th> </tr> <tr> <th>M</th> <th>F</th> <th>Total</th> <th>Low</th> <th>Normal</th> <th>High</th> </tr> </thead> <tbody>'; $rfts = TestType::getTestTypeIdByTestName('RFTS'); $rft = TestType::find($rfts); $measures = TestTypeMeasure::where('test_type_id', $rfts)->orderBy('measure_id', 'DESC')->get(); $table .= '<tr> <td>Totals</td>'; foreach ($sex as $gender) { $table .= '<td>' . $this->getGroupedTestCounts($rft, [$gender], null, $from, $toPlusOne) . '</td>'; } $table .= '<td>' . $this->getGroupedTestCounts($rft, null, null, $from, $toPlusOne) . '</td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . $this->getGroupedTestCounts($rft, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>'; } $table .= '</tr>'; foreach ($measures as $measure) { $name = Measure::find($measure->measure_id)->name; if ($name == 'Electrolytes') { continue; } $tMeasure = Measure::find($measure->measure_id); $table .= '<tr> <td>' . $tMeasure->name . '</td>'; foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>'; foreach ($ranges as $range) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>'; } $table .= '</tr>'; } $table .= '</tbody> </table> <table class="table table-condensed report-table-border"> <thead> <tr> <th rowspan="2">Liver Function Tests</th> <th colspan="2">No. Exam</th> <th colspan="4"> Number positive</th> </tr> <tr> <th>M</th> <th>F</th> <th>Total</th> <th>Low</th> <th>Normal</th> <th>High</th> </tr> </thead> <tbody>'; $lfts = TestType::getTestTypeIdByTestName('LFTS'); $lft = TestType::find($lfts); $measures = TestTypeMeasure::where('test_type_id', $lfts)->orderBy('measure_id', 'DESC')->get(); $table .= '<tr> <td>Totals</td>'; foreach ($sex as $gender) { $table .= '<td>' . $this->getGroupedTestCounts($lft, [$gender], null, $from, $toPlusOne) . '</td>'; } $table .= '<td>' . $this->getGroupedTestCounts($lft, null, null, $from, $toPlusOne) . '</td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . $this->getGroupedTestCounts($lft, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>'; } $table .= '</tr>'; foreach ($measures as $measure) { $name = Measure::find($measure->measure_id)->name; if ($name == 'SGOT') { $name = 'ASAT (SGOT)'; } if ($name == 'ALAT') { $name = 'ASAT (SGPT)'; } if ($name == 'Total Proteins') { $name = 'Serum Protein'; } $tMeasure = Measure::find($measure->measure_id); $table .= '<tr> <td>' . $tMeasure->name . '</td>'; foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>'; foreach ($ranges as $range) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>'; } $table .= '</tr>'; } $table .= '<tr> <td>Gamma GT</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> <table class="table table-condensed report-table-border"> <thead> <tr> <th rowspan="2">Lipid Profile</th> <th colspan="2">No. Exam</th> <th colspan="4"> Number positive</th> </tr> <tr> <th>M</th> <th>F</th> <th>Total</th> <th>Low</th> <th>Normal</th> <th>High</th> </tr> </thead> <tbody> <tr> <td>Totals</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr><tr> <td>Amylase</td>'; $tMeasure = Measure::find(Measure::getMeasureIdByName('Serum Amylase')); foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>'; foreach ($ranges as $range) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, [$range], 1) . '</td>'; } $table .= '</tr><tr> <td>Total cholestrol</td>'; $tMeasure = Measure::find(Measure::getMeasureIdByName('cholestrol')); foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>'; foreach ($ranges as $range) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>'; } $table .= '</tr><tr> <td>Tryglycerides</td>'; $tMeasure = Measure::find(Measure::getMeasureIdByName('Tryglycerides')); foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>'; foreach ($ranges as $range) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>'; } $table .= '</tr><tr> <td>HDL</td>'; $tMeasure = Measure::find(Measure::getMeasureIdByName('HDL')); foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>'; foreach ($ranges as $range) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>'; } $table .= '</tr><tr> <td>LDL</td>'; $tMeasure = Measure::find(Measure::getMeasureIdByName('LDL')); foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>'; foreach ($ranges as $range) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>'; } $table .= '</tr> <tr> <td>PSA</td>'; $tMeasure = Measure::find(Measure::getMeasureIdByName('PSA')); foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>'; foreach ($ranges as $range) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>'; } $table .= '</tr> </tbody> </table> <table class="table table-condensed report-table-border"> <thead> <tr> <th rowspan="2">CSF Chemistry</th> <th colspan="2">No. Exam</th> <th colspan="4"> Number positive</th> </tr> <tr> <th>M</th> <th>F</th> <th>Total</th> <th>Low</th> <th>Normal</th> <th>High</th> </tr> </thead> <tbody>'; $csf = TestType::getTestTypeIdByTestName('CSF for biochemistry'); $bioCsf = TestType::find($csf); $table .= '<tr> <td>Totals</td>'; foreach ($sex as $gender) { $table .= '<td>' . $this->getGroupedTestCounts($bioCsf, [$gender], null, $from, $toPlusOne) . '</td>'; } $table .= '<td>' . $this->getGroupedTestCounts($bioCsf, null, null, $from, $toPlusOne) . '</td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . $this->getGroupedTestCounts($bioCsf, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>'; } $table .= '</tr>'; $measures = TestTypeMeasure::where('test_type_id', $csf)->orderBy('measure_id', 'DESC')->get(); foreach ($measures as $measure) { $name = Measure::find($measure->measure_id)->name; $table .= '<tr> <td>' . $name . '</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr>'; } $table .= '</tbody> </table> <table class="table table-condensed report-table-border"> <thead> <tr> <th rowspan="2">Body Fluids</th> <th colspan="2">No. Exam</th> <th colspan="4"> Number positive</th> </tr> <tr> <th>M</th> <th>F</th> <th>Total</th> <th>Low</th> <th>Normal</th> <th>High</th> </tr> </thead> <tbody> <tr> <td>Totals</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>Proteins</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Glucose</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Acid phosphatase</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Bence jones protein</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> <table class="table table-condensed report-table-border"> <thead> <tr> <th rowspan="2">Thyroid Function Tests</th> <th colspan="2">No. Exam</th> <th colspan="4"> Number positive</th> </tr> <tr> <th>M</th> <th>F</th> <th>Total</th> <th>Low</th> <th>Normal</th> <th>High</th> </tr> </thead> <tbody>'; $tfts = TestType::getTestTypeIdByTestName('TFT'); $tft = TestType::find($tfts); $table .= '<tr> <td>Totals</td>'; foreach ($sex as $gender) { $table .= '<td>' . $this->getGroupedTestCounts($tft, [$gender], null, $from, $toPlusOne) . '</td>'; } $table .= '<td>' . $this->getGroupedTestCounts($tft, null, null, $from, $toPlusOne) . '</td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . $this->getGroupedTestCounts($tft, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>'; } $table .= '</tr>'; $measures = TestTypeMeasure::where('test_type_id', $tfts)->orderBy('measure_id', 'ASC')->get(); foreach ($measures as $measure) { $tMeasure = Measure::find($measure->measure_id); $table .= '<tr> <td>' . $tMeasure->name . '</td>'; foreach ($sex as $gender) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>'; } $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>'; foreach ($ranges as $range) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range]) . '</td>'; } $table .= '</tr>'; } $table .= '<tr> <td>Others</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> </div> <!-- URINALYSIS --> <!-- PARASITOLOGY --> <div class="col-sm-12"> <strong>PARASITOLOGY</strong> <table class="table table-condensed report-table-border"> <thead> <tr> <th colspan="5">Blood Smears</th> </tr> <tr> <th rowspan="2">Malaria</th> <th colspan="4">Positive</th> </tr> <tr> <th>Total Done</th> <th><5yrs</th> <th>5-14yrs</th> <th>>14yrs</th> </tr> </thead>'; $bs = TestType::getTestTypeIdByTestName('Bs for mps'); $bs4mps = TestType::find($bs); $table .= '<tbody> <tr> <td></td> <td>' . $this->getGroupedTestCounts($bs4mps, null, null, $from, $toPlusOne) . '</td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . $this->getGroupedTestCounts($bs4mps, null, $ageRange, $from, $toPlusOne) . '</td>'; } $table .= '</tr> <tr style="text-align:right;"> <td>Falciparum</td> <td style="background-color: #CCCCCC;"></td> <td></td> <td></td> <td></td> </tr> <tr style="text-align:right;"> <td>Ovale</td> <td style="background-color: #CCCCCC;"></td> <td></td> <td></td> <td></td> </tr> <tr style="text-align:right;"> <td>Malariae</td> <td style="background-color: #CCCCCC;"></td> <td></td> <td></td> <td></td> </tr> <tr style="text-align:right;"> <td>Vivax</td> <td style="background-color: #CCCCCC;"></td> <td></td> <td></td> <td></td> </tr> <tr> <td><strong>Borrelia</strong></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><strong>Microfilariae</strong></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><strong>Trypanosomes</strong></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td colspan="5"><strong>Genital Smears</strong></td> </tr> <tr> <td>Total</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>T. vaginalis</td> <td style="background-color: #CCCCCC;"></td> <td></td> <td></td> <td></td> </tr> <tr> <td>S. haematobium</td> <td style="background-color: #CCCCCC;"></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Yeast cells</td> <td style="background-color: #CCCCCC;"></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Others</td> <td style="background-color: #CCCCCC;"></td> <td></td> <td></td> <td></td> </tr> <tr> <td colspan="5"><strong>Spleen/bone marrow</strong></td> </tr> <tr> <td>Total</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>L. donovani</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr>'; $stool = TestType::getTestTypeIdByTestName('Stool for O/C'); $stoolForOc = TestType::find($stool); $measures = TestTypeMeasure::where('test_type_id', $stool)->orderBy('measure_id', 'DESC')->get(); $table .= '<td colspan="5"><strong>Stool</strong></td> </tr> <tr> <td>Total</td> <td>' . $this->getGroupedTestCounts($stoolForOc, null, null, $from, $toPlusOne) . '</td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . $this->getGroupedTestCounts($stoolForOc, null, $ageRange, $from, $toPlusOne) . '</td>'; } $table .= '</tr>'; foreach ($measures as $measure) { $tMeasure = Measure::find($measure->measure_id); foreach ($tMeasure->measureRanges as $range) { if ($range->alphanumeric == 'O#C not seen') { continue; } $table .= '<tr> <td>' . $range->alphanumeric . '</td>'; $table .= '<td style="background-color: #CCCCCC;"></td>'; foreach ($ageRanges as $ageRange) { $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, [$range->alphanumeric]) . '</td>'; } $table .= '</tr>'; } } $table .= '<tr> <td colspan="5"><strong>Lavages</strong></td> </tr> <tr> <td>Total</td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> </div> <!-- PARASITOLOGY --> <!-- BACTERIOLOGY --> <div class="col-sm-12"> <strong>BACTERIOLOGY</strong> <div class="row"> <div class="col-sm-4"> <table class="table table-condensed report-table-border" style="padding-right:5px;"> <tbody style="text-align:right;"> <tr> <td>Total examinations done</td> <td></td> </tr>'; foreach ($specTypeIds as $key) { if (in_array(SpecimenType::find($key->spec_id)->name, ['Aspirate', 'Pleural Tap', 'Synovial Fluid', 'Sputum', 'Ascitic Tap', 'S***n', 'Skin'])) { continue; } $totalCount = DB::select(DB::raw("select count(specimen_id) as per_spec_count from tests" . " join specimens on tests.specimen_id=specimens.id" . " join test_types on tests.test_type_id=test_types.id" . " where specimens.specimen_type_id=?" . " and test_types.test_category_id=?" . " and test_status_id in(?,?)" . " and tests.time_created BETWEEN ? and ?;"), [$key->spec_id, $labSecId, Test::COMPLETED, Test::VERIFIED, $from, $toPlusOne]); $table .= '<tr> <td>' . SpecimenType::find($key->spec_id)->name . '</td> <td>' . $totalCount[0]->per_spec_count . '</td> </tr>'; } $table .= '</tr> <td>Rectal swab</td> <td>0</td> </tr> </tr> <td>Water</td> <td>0</td> </tr> </tr> <td>Food</td> <td>0</td> </tr> </tr> <td>Other (specify)....</td> <td></td> </tr> </tbody> </table> </div> <div class="col-sm-8"> <table class="table table-condensed report-table-border"> <tbody> <tr> <td colspan="3">Drugs</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td colspan="3">Sensitivity (Total done)</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td colspan="3">Resistance per drug</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td rowspan="3">KOH Preparations</td> <td>Fungi</td> <td></td> <td></td> <td></td> <td></td> <td colspan="2">Others (specify)</td> </tr> <tr> <td>Others</td> <td></td> <td></td> <td></td> <td></td> <td>...</td> <td></td> </tr> <tr> <td>Total</td> <td></td> <td></td> <td></td> <td></td> <td>...</td> <td></td> </tr> </tbody> </table> <p>SPUTUM</p> <table class="table table-condensed report-table-border"> <tbody> <tr> <td></td> <td>Total</td> <td>Positive</td> </tr> <tr> <td>TB new suspects</td> <td></td> <td></td> </tr> <tr> <td>Followup</td> <td></td> <td></td> </tr> <tr> <td>TB smears</td> <td></td> <td></td> </tr> <tr> <td>MDR</td> <td></td> <td></td> </tr> </tbody> </table> </div> </div> <table class="table table-condensed report-table-border"> <tbody> <tr><td></td>'; foreach ($specimen_types as $spec) { $table .= '<td>' . $spec . '</td>'; } $table .= '</tr>'; foreach ($isolates as $isolate) { $table .= '<tr> <td>' . $isolate . '</td>'; foreach ($specimen_types as $spec) { $table .= '<td>' . TestResult::microCounts($isolate, $spec, $from, $toPlusOne)[0]->total . '</td>'; } $table .= '</tr>'; } $table .= '<tr> <td colspan="11">Specify species of each isolate</td> </tr> </tbody> </table> <div class="row"> <div class="col-sm-12"> <strong>HEMATOLOGY REPORT</strong> <table class="table table-condensed report-table-border"> <thead> <tr> <th colspan="2">Type of examination</th> <th>No. of Tests</th> <th>Controls</th> </tr> </thead> <tbody> <tr> <td colspan="2">Full blood count</td> <td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Full haemogram')), null, null, $from, $toPlusOne) . '</td> <td></td> </tr> <tr> <td colspan="2">Manual WBC counts</td> <td></td> <td></td> </tr> <tr> <td colspan="2">Peripheral blood films</td> <td></td> <td></td> </tr> <tr> <td colspan="2">Erythrocyte Sedimentation rate</td> <td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('ESR')), null, null, $from, $toPlusOne) . '</td> <td></td> </tr> <tr> <td colspan="2">Sickling test</td> <td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Sickling test')), null, null, $from, $toPlusOne) . '</td> <td></td> </tr> <tr> <td colspan="2">HB electrophoresis</td> <td></td> <td></td> </tr> <tr> <td colspan="2">G6PD screening</td> <td></td> <td></td> </tr> <tr> <td colspan="2">Bleeding time</td> <td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Bleeding time test')), null, null, $from, $toPlusOne) . '</td> <td></td> </tr> <tr> <td colspan="2">Clotting time</td> <td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Clotting time test')), null, null, $from, $toPlusOne) . '</td> <td></td> </tr> <tr> <td colspan="2">Prothrombin test</td> <td></td> <td></td> </tr> <tr> <td colspan="2">Partial prothrombin time</td> <td></td> <td></td> </tr> <tr> <td colspan="2">Bone Marrow Aspirates</td> <td></td> <td style="background-color: #CCCCCC;"></td> </tr> <tr> <td colspan="2">Reticulocyte counts</td> <td></td> <td style="background-color: #CCCCCC;"></td> </tr> <tr> <td colspan="2">Others</td> <td></td> <td style="background-color: #CCCCCC;"></td> </tr> <tr> <td rowspan="2">Haemoglobin</td> <td>No. Tests</td> <td><5</td> <td>5<Hb<10</td> </tr> <tr> <td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('HB')), null, null, $from, $toPlusOne) . '</td> <td></td> <td></td> </tr> <tr> <td rowspan="2">CD4/CD8</td> <td>No. Tests</td> <td><200</td> <td>200-350</td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td rowspan="2">CD4%</td> <td>No. Tests</td> <td><25%</td> <td>>25%</td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td rowspan="2">Peripheral Blood Films</td> <td>Parasites</td> <td colspan="2">No. smears with inclusions</td> </tr> <tr> <td></td> <td></td> <td colspan="2"></td> </tr> </tbody> </table> </div> <div class="col-sm-12"> <strong>BLOOD GROUPING AND CROSSMATCH REPORT</strong> <div class="row"> <div class="col-sm-6"> <table class="table table-condensed report-table-border"> <tbody> <tr> <td>Total groupings done</td> <td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('GXM')), null, null, $from, $toPlusOne) . '</td> </tr> <tr> <td>Blood units grouped</td> <td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Blood Grouping')), null, null, $from, $toPlusOne) . '</td> </tr> <tr> <td>Total transfusion reactions</td> <td></td> </tr> <tr> <td>Blood cross matches</td> <td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Cross Match')), null, null, $from, $toPlusOne) . '</td> </tr> </tbody> </table> </div> <div class="col-sm-6"> <strong>Blood safety</strong> <table class="table table-condensed report-table-border"> <tbody> <tr> <td>Measure</td> <td>Number</td> </tr> <tr> <td>A. Blood units collected from regional blood transfusion centres</td> <td></td> </tr> <tr> <td>Blood units collected from other centres and screened at health facility</td> <td></td> </tr> <tr> <td>Blood units screened at health facility that are HIV positive</td> <td></td> </tr> <tr> <td>Blood units screened at health facility that are Hepatitis positive</td> <td></td> </tr> <tr> <td>Blood units positive for other infections</td> <td></td> </tr> <tr> <td>Blood units transfered</td> <td></td> </tr> <tr> <td rowspan="2">General remarks .............................</td> <td rowspan="2"></td> </tr> </tbody> </table> </div> </div> </div> </div> </div> <!-- BACTERIOLOGY --> <!-- HISTOLOGY AND CYTOLOGY --> <div class="col-sm-12"> <strong>HISTOLOGY AND CYTOLOGY REPORT</strong> <table class="table table-condensed report-table-border"> <thead> <tr> <th rowspan="2"></th> <th rowspan="2">Total</th> <th rowspan="2">Normal</th> <th rowspan="2">Infective</th> <th colspan="2">Non-infective</th> <th colspan="3">Positive findings</th> </tr> <tr> <th>Benign</th> <th>Malignant</th> <th><5 yrs</th> <th>5-14 yrs</th> <th>>14 yrs</th> </tr> </thead> <tbody> <tr> <td colspan="9">SMEARS</td> </tr> <tr> <td>Pap Smear</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>Tissue Impressions</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td colspan="9">TISSUE ASPIRATES (FNA)</td> </tr> <tr> <td></td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td colspan="9">FLUID CYTOLOGY</td> </tr> <tr> <td>Ascitic fluid</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>CSF</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>Pleural fluid</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>Others</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td colspan="9">TISSUE HISTOLOGY</td> </tr> <tr> <td>Cervix</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>Prostrate</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>Breast</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>Ovarian cyst</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>Fibroids</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>Lymph nodes</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>Others</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> <strong>SEROLOGY REPORT</strong> <table class="table table-condensed report-table-border"> <thead> <tr> <th rowspan="2">Serological test</th> <th colspan="2">Total</th> <th colspan="2"><5 yrs</th> <th colspan="2">5-14 yrs</th> <th colspan="2">>14 yrs</th> </tr> <tr> <th>Tested</th> <th>No. +ve</th> <th>Tested</th> <th>No. +ve</th> <th>Tested</th> <th>No. +ve</th> <th>Tested</th> <th>No. +ve</th> </tr> </thead> <tbody> <tr> <td>Rapid Plasma Region</td>'; if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL'))) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL')) as $count) { if (count($count) == 0) { $count->total = 0; $count->positive = 0; } $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } foreach ($ageRanges as $ageRange) { if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL'), $ageRange)) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL'), $ageRange) as $count) { $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } } $table .= '</tr> <tr> <td>TPHA</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>ASO Test</td>'; if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Asot'))) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Asot')) as $count) { if (count($count) == 0) { $count->total = 0; $count->positive = 0; } $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } foreach ($ageRanges as $ageRange) { $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Asot'), $ageRange); if (count($data) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach ($data as $count) { $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } } $table .= '</tr> <tr> <td>HIV Test</td>'; if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Rapid HIV test'))) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Rapid HIV test')) as $count) { if (count($count) == 0) { $count->total = 0; $count->positive = 0; } $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } foreach ($ageRanges as $ageRange) { $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Rapid HIV test'), $ageRange); if (count($data) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach ($data as $count) { $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } } $table .= '</tr> <tr> <td>Widal Test</td>'; if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Widal'))) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Widal')) as $count) { if (count($count) == 0) { $count->total = 0; $count->positive = 0; } $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } foreach ($ageRanges as $ageRange) { $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Widal'), $ageRange); if (count($data) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach ($data as $count) { $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } } $table .= '</tr> <tr> <td>Brucella Test</td>'; if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Brucella'))) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Brucella')) as $count) { if (count($count) == 0) { $count->total = 0; $count->positive = 0; } $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } foreach ($ageRanges as $ageRange) { $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Brucella'), $ageRange); if (count($data) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach ($data as $count) { $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } } $table .= '</tr> <tr> <td>Rheumatoid Factor Tests</td>'; if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('RF'))) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('RF')) as $count) { if (count($count) == 0) { $count->total = 0; $count->positive = 0; } $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } foreach ($ageRanges as $ageRange) { $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('RF'), $ageRange); if (count($data) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach ($data as $count) { $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } } $table .= '</tr> <tr> <td>Cryptococcal Antigen</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Helicobacter pylori test</td>'; if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('H pylori'))) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('H pylori')) as $count) { if (count($count) == 0) { $count->total = 0; $count->positive = 0; } $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } foreach ($ageRanges as $ageRange) { $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('H pylori'), $ageRange); if (count($data) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach ($data as $count) { $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } } $table .= '</tr> <tr> <td>Hepatitis A test</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td>'; $table .= '</tr> <tr> <td>Hepatitis B test</td>'; if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis B'))) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis B')) as $count) { if (count($count) == 0) { $count->total = 0; $count->positive = 0; } $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } foreach ($ageRanges as $ageRange) { $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis B'), $ageRange); if (count($data) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach ($data as $count) { $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } } $table .= '</tr> <tr> <td>Hepatitis C test</td>'; if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis C'))) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis C')) as $count) { if (count($count) == 0) { $count->total = 0; $count->positive = 0; } $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } foreach ($ageRanges as $ageRange) { $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis C'), $ageRange); if (count($data) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach ($data as $count) { $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } } $table .= '</tr> <tr> <td>Viral Load</td>'; if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Viral load'))) == 0) { $table .= '<td>0</td> <td style="background-color: #CCCCCC;"></td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Viral load')) as $count) { if (count($count) == 0) { $count->total = 0; $count->positive = 0; } $table .= '<td>' . $count->total . '</td> <td style="background-color: #CCCCCC;"></td>'; } } foreach ($ageRanges as $ageRange) { $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Viral load'), $ageRange); if (count($data) == 0) { $table .= '<td>0</td> <td style="background-color: #CCCCCC;"></td>'; } else { foreach ($data as $count) { $table .= '<td>' . $count->total . '</td> <td style="background-color: #CCCCCC;"></td>'; } } } $table .= '</tr> <tr> <td>Formal Gel Test</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> <td>N/S</td> </tr> <tr> <td>Other Tests</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> <br /> <table class="table table-condensed report-table-border"> <thead> <tr> <th>Dried Blood Spots</th> <th>Tested</th> <th># +ve</th> <th>Discrepant</th> </tr> </thead> <tbody> <tr> <td>Early Infant Diagnosis of HIV</td>'; if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('eid of hiv'))) == 0) { $table .= '<td>0</td> <td>0</td>'; } else { foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('eid of hiv')) as $count) { if (count($count) == 0) { $count->total = 0; $count->positive = 0; } $table .= '<td>' . $count->total . '</td> <td>' . $count->positive . '</td>'; } } $table .= '<td></td> </tr> <tr> <td>Quality Assurance</td> <td></td> <td></td> <td></td> </tr> <tr> <td>Discordant couples</td> <td></td> <td></td> <td></td> </tr> <tr> <td>Others</td> <td></td> <td></td> <td></td> </tr> </tbody> </table> <p><strong>Specimen referral to higher levels</strong></p> <table class="table table-condensed report-table-border"> <thead> <tr> <th>Specimen</th> <th>No</th> <th>Sent to</th> <th>No. of Reports/results received</th> </tr> </thead> <tbody>'; if ($referredSpecimens) { foreach ($referredSpecimens as $referredSpecimen) { $table .= '<tr> <td>' . $referredSpecimen->spec . '</td> <td>' . $referredSpecimen->tot . '</td> <td>' . $referredSpecimen->facility . '</td> <td></td> </tr>'; } } else { $table .= '<tr> <td colspan="4">' . trans('messages.no-records-found') . '</td> </tr>'; } $table .= '</tbody> </table> </div> <!-- HISTOLOGY AND CYTOLOGY -->'; if (Input::has('excel')) { $date = date("Ymdhi"); $fileName = "MOH706_" . $date . ".xls"; $headers = array("Content-type" => "text/html", "Content-Disposition" => "attachment;Filename=" . $fileName); $content = $table; return Response::make($content, 200, $headers); } else { //return view('reports.moh.706'); return view('reports.moh.index')->with('table', $table)->with('from', $from)->with('end', $end); } }