push
This commit is contained in:
@@ -724,15 +724,15 @@ class AstmMessageService
|
|||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
|
|
||||||
if (str_starts_with($line, 'H|')) {
|
if (str_starts_with($line, 'H|')) {
|
||||||
$f = explode('|', $line);
|
$f = explode('|', $line);
|
||||||
|
$resultDateTime = $this->astmToDateTime($f[13] ?? null);
|
||||||
|
|
||||||
$parsed['header'] = [
|
$parsed['header'] = [
|
||||||
'sender_name' => $data->alat ?? ($f[4] ?? 'BD Instrument'),
|
'sender_name' => $data->alat ?? ($f[4] ?? 'BD Instrument'),
|
||||||
'version_number' => $f[12] ?? 'V1.0',
|
'version_number' => $f[12] ?? 'V1.0',
|
||||||
'message_datetime' => $this->astmToDateTime($f[13] ?? null)
|
'message_datetime' => $this->astmToDateTime($f[13] ?? null)
|
||||||
];
|
];
|
||||||
}
|
} elseif (str_starts_with($line, 'P|')) {
|
||||||
|
|
||||||
elseif (str_starts_with($line, 'P|')) {
|
|
||||||
$f = explode('|', $line);
|
$f = explode('|', $line);
|
||||||
$name = explode(' ', $f[5] ?? '');
|
$name = explode(' ', $f[5] ?? '');
|
||||||
|
|
||||||
@@ -746,9 +746,7 @@ class AstmMessageService
|
|||||||
'address_street' => $f[11] ?? null,
|
'address_street' => $f[11] ?? null,
|
||||||
'hospital_client' => $f[29] ?? null,
|
'hospital_client' => $f[29] ?? null,
|
||||||
];
|
];
|
||||||
}
|
} elseif (str_starts_with($line, 'O|')) {
|
||||||
|
|
||||||
elseif (str_starts_with($line, 'O|')) {
|
|
||||||
$f = explode('|', $line);
|
$f = explode('|', $line);
|
||||||
$test = explode('^', $f[4] ?? '');
|
$test = explode('^', $f[4] ?? '');
|
||||||
$accnumber = $f[2] ?? null;
|
$accnumber = $f[2] ?? null;
|
||||||
@@ -759,28 +757,36 @@ class AstmMessageService
|
|||||||
'body_site' => $f[16] ?? null,
|
'body_site' => $f[16] ?? null,
|
||||||
'test_start_datetime'=> $this->astmToDateTime($f[7] ?? null),
|
'test_start_datetime'=> $this->astmToDateTime($f[7] ?? null),
|
||||||
];
|
];
|
||||||
}
|
} elseif (str_starts_with($line, 'R|')) {
|
||||||
|
|
||||||
elseif (str_starts_with($line, 'R|')) {
|
|
||||||
$f = explode('|', $line);
|
$f = explode('|', $line);
|
||||||
$test = explode('^', $f[2] ?? '');
|
$test = explode('^', $f[2] ?? '');
|
||||||
$resultDateTime = $this->astmToDateTime($f[9] ?? null);
|
|
||||||
$updated_date = $this->astmToDateTime($f[10] ?? null);
|
|
||||||
|
|
||||||
// Instrument detail di akhir baris
|
// Instrument detail di akhir baris
|
||||||
preg_match('/(MGIT960|BACTECFX)[^|]*/', $line, $inst);
|
preg_match('/(MGIT960|BACTECFX)[^|]*/', $line, $inst);
|
||||||
|
|
||||||
$parsed['result'] = [
|
$parsed['result'] = [
|
||||||
'organism' => $test[2] ?? null,
|
'organism' => $test[2] ?? null,
|
||||||
'test_status' => explode('^', $f[3] ?? '')[0],
|
'test_status' => explode('^', $f[3] ?? '')[0],
|
||||||
'result_status_datetime' => $resultDateTime,
|
'result_status_datetime' => $this->astmToDateTime($f[13] ?? $resultDateTime),
|
||||||
'test_complete_datetime' => $updated_date
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$parsed['instrument'] = [
|
$parsed['instrument'] = [
|
||||||
'instrument_type' => str_contains($line, 'MGIT960') ? 'MGIT960' : 'BACTECFX',
|
'instrument_type' => str_contains($line, 'MGIT960') ? 'MGIT960' : 'BACTECFX',
|
||||||
'instrument_number' => $inst[0] ?? null,
|
'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),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user