Support multiple species rows in glass report
This commit is contained in:
@@ -764,9 +764,7 @@ class ReportController extends Controller
|
|||||||
$komponenRows = $lookups['komponen'][$row->nofoto] ?? collect([]);
|
$komponenRows = $lookups['komponen'][$row->nofoto] ?? collect([]);
|
||||||
$antibioticRows = $lookups['antibiotik'][$row->id] ?? collect([]);
|
$antibioticRows = $lookups['antibiotik'][$row->id] ?? collect([]);
|
||||||
|
|
||||||
$bacterialName = '';
|
$speciesNames = [];
|
||||||
$fungalName = '';
|
|
||||||
$foundMorphology = false;
|
|
||||||
|
|
||||||
foreach ($komponenRows as $komponenRow) {
|
foreach ($komponenRows as $komponenRow) {
|
||||||
$value = trim(strip_tags((string) $komponenRow->isidata));
|
$value = trim(strip_tags((string) $komponenRow->isidata));
|
||||||
@@ -774,19 +772,15 @@ class ReportController extends Controller
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stripos($value, 'Ditemukan morfologi') !== false) {
|
if (in_array($komponenRow->komponen, ['bakteri', 'id_bakteri01', 'id_bakteri02'], true) && stripos($value, 'Ditemukan morfologi') === false) {
|
||||||
$foundMorphology = true;
|
$speciesNames[] = $value;
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array($komponenRow->komponen, ['bakteri', 'id_bakteri01', 'id_bakteri02'], true) && $bacterialName === '' && stripos($value, 'Ditemukan morfologi') === false) {
|
|
||||||
$bacterialName = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($komponenRow->komponen === 'id_mikroorganisme' && $fungalName === '') {
|
|
||||||
$fungalName = $value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$speciesNames = array_values(array_filter($speciesNames, function ($value) {
|
||||||
|
return trim((string) $value) !== '';
|
||||||
|
}));
|
||||||
|
|
||||||
$antibioticValues = [];
|
$antibioticValues = [];
|
||||||
foreach ($antibioticRows as $antibioticRow) {
|
foreach ($antibioticRows as $antibioticRow) {
|
||||||
$matchedHeader = null;
|
$matchedHeader = null;
|
||||||
@@ -808,31 +802,39 @@ class ReportController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$hasJenisSpesimen = trim((string) ($baseRow[10] ?? '')) !== '';
|
$hasJenisSpesimen = trim((string) ($baseRow[10] ?? '')) !== '';
|
||||||
if ($bacterialName !== '' && $hasJenisSpesimen) {
|
$hasFungalAntibiotic = collect($headers['B_antibiotics'])->contains(function ($antibioticHeader) use ($antibioticValues) {
|
||||||
$tableRow = array_merge($baseRow, [
|
return array_key_exists($antibioticHeader, $antibioticValues);
|
||||||
$bacterialName,
|
});
|
||||||
$row->id_esbl ?? '',
|
|
||||||
$row->id_mrsa ?? '',
|
|
||||||
]);
|
|
||||||
|
|
||||||
foreach ($headers['A_antibiotics'] as $antibioticHeader) {
|
if (!empty($speciesNames) && $hasJenisSpesimen && !$hasFungalAntibiotic) {
|
||||||
$tableRow[] = $antibioticValues[$antibioticHeader] ?? '';
|
foreach ($speciesNames as $speciesName) {
|
||||||
|
$tableRow = array_merge($baseRow, [
|
||||||
|
$speciesName,
|
||||||
|
$row->id_esbl ?? '',
|
||||||
|
$row->id_mrsa ?? '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($headers['A_antibiotics'] as $antibioticHeader) {
|
||||||
|
$tableRow[] = $antibioticValues[$antibioticHeader] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$tables['A'][] = $tableRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tables['A'][] = $tableRow;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($foundMorphology || $fungalName !== '') {
|
if (!empty($speciesNames) && $hasJenisSpesimen && $hasFungalAntibiotic) {
|
||||||
$tableRow = array_merge($baseRow, [
|
foreach ($speciesNames as $speciesName) {
|
||||||
$fungalName !== '' ? $fungalName : 'Ditemukan morfologi',
|
$tableRow = array_merge($baseRow, [
|
||||||
]);
|
$speciesName,
|
||||||
|
]);
|
||||||
|
|
||||||
foreach ($headers['B_antibiotics'] as $antibioticHeader) {
|
foreach ($headers['B_antibiotics'] as $antibioticHeader) {
|
||||||
$tableRow[] = $antibioticValues[$antibioticHeader] ?? '';
|
$tableRow[] = $antibioticValues[$antibioticHeader] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$tables['B'][] = $tableRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tables['B'][] = $tableRow;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user