This commit is contained in:
Dwi Swandhana
2026-01-30 10:00:28 +07:00
parent 8bb448229c
commit 06ea1415cc
+22 -16
View File
@@ -724,15 +724,15 @@ class AstmMessageService
foreach ($lines as $line) {
if (str_starts_with($line, 'H|')) {
$f = explode('|', $line);
$f = explode('|', $line);
$resultDateTime = $this->astmToDateTime($f[13] ?? null);
$parsed['header'] = [
'sender_name' => $data->alat ?? ($f[4] ?? 'BD Instrument'),
'version_number' => $f[12] ?? 'V1.0',
'message_datetime' => $this->astmToDateTime($f[13] ?? null)
];
}
elseif (str_starts_with($line, 'P|')) {
} elseif (str_starts_with($line, 'P|')) {
$f = explode('|', $line);
$name = explode(' ', $f[5] ?? '');
@@ -746,9 +746,7 @@ class AstmMessageService
'address_street' => $f[11] ?? null,
'hospital_client' => $f[29] ?? null,
];
}
elseif (str_starts_with($line, 'O|')) {
} elseif (str_starts_with($line, 'O|')) {
$f = explode('|', $line);
$test = explode('^', $f[4] ?? '');
$accnumber = $f[2] ?? null;
@@ -759,28 +757,36 @@ class AstmMessageService
'body_site' => $f[16] ?? null,
'test_start_datetime'=> $this->astmToDateTime($f[7] ?? null),
];
}
elseif (str_starts_with($line, 'R|')) {
} elseif (str_starts_with($line, 'R|')) {
$f = explode('|', $line);
$test = explode('^', $f[2] ?? '');
$resultDateTime = $this->astmToDateTime($f[9] ?? null);
$updated_date = $this->astmToDateTime($f[10] ?? null);
// Instrument detail di akhir baris
preg_match('/(MGIT960|BACTECFX)[^|]*/', $line, $inst);
$parsed['result'] = [
'organism' => $test[2] ?? null,
'test_status' => explode('^', $f[3] ?? '')[0],
'result_status_datetime' => $resultDateTime,
'test_complete_datetime' => $updated_date
'organism' => $test[2] ?? null,
'test_status' => explode('^', $f[3] ?? '')[0],
'result_status_datetime' => $this->astmToDateTime($f[13] ?? $resultDateTime),
];
$parsed['instrument'] = [
'instrument_type' => str_contains($line, 'MGIT960') ? 'MGIT960' : 'BACTECFX',
'instrument_number' => $inst[0] ?? null,
];
} else {
$cekline = explode('|F|', $line);
if (isset($cekline[1])){
$f = explode('|', $cekline[1]);
$resultDateTime2 = $this->astmToDateTime($f[4] ?? null);
if ($resultDateTime2){
$parsed['result'] = array_merge($parsed['result'], [
'result_status_datetime' => $resultDateTime2,
'test_complete_datetime' => $this->astmToDateTime($f[5] ?? null),
]);
}
}
}
}