Update
This commit is contained in:
@@ -1272,7 +1272,7 @@ class DokterController extends Controller
|
||||
foreach($gentabel as $rtabel){
|
||||
$isidata .= '<tr>
|
||||
<td style="text-align:center;">'.$nomor.'</td>
|
||||
<td>'.$rtabel->resistance.'</td>
|
||||
<td>'.$rtabel->antibiotic.'</td>
|
||||
<td style="text-align:center;">'.$rtabel->value.'</td>
|
||||
<td style="text-align:center;">'.$rtabel->interpretation.'</td>
|
||||
</tr>';
|
||||
|
||||
@@ -30,11 +30,11 @@ function processIsolateResult($rawData){
|
||||
$resultData = explode('|', $rawData);
|
||||
return [
|
||||
'test_type' => 'Isolate',
|
||||
'isolate_result' => $resultData[3],
|
||||
'antibiotic' => $resultData[4],
|
||||
'value' => $resultData[5],
|
||||
'status' => $resultData[6],
|
||||
'completion_time' => $resultData[10]
|
||||
'isolate_result' => $resultData[3] ?? null,
|
||||
'antibiotic' => $resultData[4] ?? null,
|
||||
'value' => $resultData[5] ?? null,
|
||||
'status' => $resultData[6] ?? null,
|
||||
'completion_time' => $resultData[10] ?? null
|
||||
];
|
||||
}
|
||||
// Proses untuk Other Test Result
|
||||
@@ -58,7 +58,7 @@ class AstmMessageService
|
||||
*/
|
||||
private function cleanString($string)
|
||||
{
|
||||
return preg_replace('/[^\P{C}\n]+/u', '', $string);
|
||||
return preg_replace('/[^\x20-\x7E|]+/', '', $string);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,113 +289,110 @@ class AstmMessageService
|
||||
|
||||
} else {
|
||||
if (!empty($mltrData)){
|
||||
Log::info("Trying parser MTRSL :", $mltrData);
|
||||
$parsedData = [];
|
||||
$parsedData['antibiotics'] = [];
|
||||
$antibiotic = '';
|
||||
$resistance = '';
|
||||
$value = '';
|
||||
$interpretation = '';
|
||||
$mulaikirim = 0;
|
||||
$tanggalmasuk = '';
|
||||
$tanggalkeluar = '';
|
||||
|
||||
$parsedData = [
|
||||
'patient_info' => [],
|
||||
'antibiotics' => []
|
||||
];
|
||||
$resultSample = new ResultSample();
|
||||
foreach ($mltrData as $index => $field) {
|
||||
$cekbersih = trim($field, '"');
|
||||
if (strpos($cekbersih, 'a1') === 0) {
|
||||
// Kode dari alat
|
||||
}
|
||||
if (strpos($cekbersih, 'a2') === 0) {
|
||||
$antibiotic = substr($field, 2); // Nama antibiotik
|
||||
$mulaikirim++;
|
||||
}
|
||||
if (strpos($cekbersih, 'a3') === 0) {
|
||||
$value = substr($field, 2); // Nilai MIC
|
||||
$mulaikirim++;
|
||||
}
|
||||
if (strpos($cekbersih, 'a4') === 0) {
|
||||
$interpretation = substr($field, 2); // S, I, atau R
|
||||
$mulaikirim++;
|
||||
}
|
||||
if (strpos($cekbersih, 'an') === 0) {
|
||||
$resistance = substr($field, 2); // Catatan resistansi
|
||||
$mulaikirim++;
|
||||
}
|
||||
if (strpos($cekbersih, 'mt') === 0) {
|
||||
$resultSample->sender_name = substr($cekbersih, 2);
|
||||
}
|
||||
if (strpos($cekbersih, 'ii') === 0) {
|
||||
$resultSample->version_number = substr($cekbersih, 2);
|
||||
}
|
||||
if (strpos($cekbersih, 'rr') === 0) {
|
||||
$resultSample->isolate_number = substr($cekbersih, 2);
|
||||
}
|
||||
if (strpos($cekbersih, 'ci') === 0) {
|
||||
$accession_number = substr($cekbersih, 2);
|
||||
$resultSample->accession_number = $accession_number;
|
||||
}
|
||||
if (strpos($cekbersih, 'pi') === 0) {
|
||||
$resultSample->patient_id = substr($cekbersih, 2);
|
||||
}
|
||||
if (strpos($cekbersih, 'pn') === 0) {
|
||||
$patientNames = substr($cekbersih, 2);
|
||||
$patientNames = explode(',', $patientNames ?? null);
|
||||
if (count($patientNames) > 0) {
|
||||
$resultSample->patient_name_first = trim($patientNames[0]);
|
||||
for ($i = 0; $i < count($mltrData); $i++) {
|
||||
$field = $mltrData[$i];
|
||||
$kodeduadigit = substr($field, 0, 2);
|
||||
|
||||
if ($field == 'ra') {
|
||||
$current_antibiotic = [];
|
||||
for ($j = 1; $j <= 5; $j++) {
|
||||
if (isset($mltrData[$i + $j])) {
|
||||
$subField = $mltrData[$i + $j];
|
||||
$code = substr($subField, 0, 2);
|
||||
$value = substr($subField, 2);
|
||||
|
||||
switch ($code) {
|
||||
case 'a1':
|
||||
$current_antibiotic['instrument_code'] = $value; // Kode dari alat
|
||||
break;
|
||||
case 'a2':
|
||||
$current_antibiotic['antibiotic_name'] = $value; // Nama antibiotik
|
||||
break;
|
||||
case 'a3':
|
||||
$current_antibiotic['value'] = $value; // Nilai MIC
|
||||
break;
|
||||
case 'a4':
|
||||
$current_antibiotic['interpretation'] = $value; // S, I, atau R
|
||||
break;
|
||||
case 'an':
|
||||
$current_antibiotic['resistance_note'] = $value; // Catatan resistansi
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($patientNames) > 1) {
|
||||
$resultSample->patient_name_last = trim($patientNames[1]);
|
||||
$antibioticName = $current_antibiotic['antibiotic_name'] ?? null;
|
||||
if ($antibioticName && isset($kodevitek[$antibioticName])) {
|
||||
$current_antibiotic['lis_code'] = $kodevitek[$antibioticName];
|
||||
} else {
|
||||
$current_antibiotic['lis_code'] = $current_antibiotic['instrument_code'] ?? 'NOT_FOUND';
|
||||
}
|
||||
if (count($patientNames) > 2) {
|
||||
$resultSample->patient_name_middle = trim($patientNames[2]);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($cekbersih, 'pl') === 0) {
|
||||
$resultSample->hospital_service = substr($cekbersih, 2);
|
||||
}
|
||||
if (strpos($cekbersih, 'p2') === 0) {
|
||||
$resultSample->hospital_client = substr($cekbersih, 2);
|
||||
}
|
||||
if (strpos($cekbersih, 'ss') === 0) {
|
||||
$resultSample->specimen_type = substr($cekbersih, 2);
|
||||
}
|
||||
if (strpos($cekbersih, 'o2') === 0) {
|
||||
$resultSample->organism = substr($cekbersih, 2);
|
||||
}
|
||||
if (strpos($cekbersih, 's1') === 0) {
|
||||
$tanggalmasuk = substr($cekbersih, 2);
|
||||
}
|
||||
if (strpos($cekbersih, 's2') === 0) {
|
||||
$tanggalmasuk = $tanggalmasuk.' '.substr($cekbersih, 2);
|
||||
}
|
||||
if (strpos($cekbersih, 's3') === 0) {
|
||||
$tanggalkeluar = substr($cekbersih, 2);
|
||||
}
|
||||
if (strpos($cekbersih, 's4') === 0) {
|
||||
$tanggalkeluar = $tanggalkeluar.' '.substr($cekbersih, 2);
|
||||
}
|
||||
if ($antibiotic != '' AND $resistance != '' AND $value != '' AND $interpretation != '') {
|
||||
$parsedData['antibiotics'][] = [
|
||||
'antibiotic' => $antibiotic, // Antibiotik
|
||||
'resistance' => $resistance, // Hasil Resistansi
|
||||
'value' => $value, // Nilai
|
||||
'interpretation'=> $interpretation // Interpretasi
|
||||
];
|
||||
$antibiotic = '';
|
||||
$resistance = '';
|
||||
$value = '';
|
||||
$interpretation = '';
|
||||
$parsedData['antibiotics'][] = $current_antibiotic;
|
||||
$i += 5;
|
||||
} else {
|
||||
$mulaikirim = 1;
|
||||
if ($kodeduadigit == 'mt'){
|
||||
$resultSample->sender_name = substr($field, 2);
|
||||
}
|
||||
if ($kodeduadigit == 'ii'){
|
||||
$resultSample->version_number = substr($field, 2);
|
||||
}
|
||||
if ($kodeduadigit == 'rr'){
|
||||
$resultSample->isolate_number = substr($field, 2);
|
||||
}
|
||||
if ($kodeduadigit == 'ci'){
|
||||
$accession_number = substr($field, 2);
|
||||
$resultSample->accession_number = $accession_number;
|
||||
}
|
||||
if ($kodeduadigit == 'pi'){
|
||||
$resultSample->patient_id = substr($field, 2);
|
||||
}
|
||||
if ($kodeduadigit == 'pn'){
|
||||
$patientNames = substr($field, 2);
|
||||
$patientNames = explode(',', $patientNames ?? null);
|
||||
if (count($patientNames) > 0) {
|
||||
$resultSample->patient_name_first = trim($patientNames[0]);
|
||||
}
|
||||
if (count($patientNames) > 1) {
|
||||
$resultSample->patient_name_last = trim($patientNames[1]);
|
||||
}
|
||||
if (count($patientNames) > 2) {
|
||||
$resultSample->patient_name_middle = trim($patientNames[2]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($kodeduadigit == 'pl'){
|
||||
$resultSample->hospital_service = substr($field, 2);
|
||||
}
|
||||
if ($kodeduadigit == 'p2'){
|
||||
$resultSample->hospital_client = substr($field, 2);
|
||||
}
|
||||
if ($kodeduadigit == 'ss'){
|
||||
$resultSample->specimen_type = substr($field, 2);
|
||||
}
|
||||
if ($kodeduadigit == 'o2'){
|
||||
$resultSample->organism = substr($field, 2);
|
||||
}
|
||||
if ($kodeduadigit == 's1'){
|
||||
$tanggalmasuk = substr($field, 2);
|
||||
}
|
||||
if ($kodeduadigit == 's2'){
|
||||
$tanggalmasuk = $tanggalmasuk.' '.substr($field, 2);
|
||||
}
|
||||
if ($kodeduadigit == 's3'){
|
||||
$tanggalkeluar = substr($field, 2);
|
||||
}
|
||||
if ($kodeduadigit == 's4'){
|
||||
$tanggalkeluar = $tanggalkeluar.' '.substr($field, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//$resultSample->specimen_type = $parsedData['specimen_type'] ?? null; // Could be inferred
|
||||
//$resultSample->test_id = $parsedData['test_id'] ?? null;
|
||||
|
||||
// Result Record
|
||||
$resultSample->additional_result = json_encode($parsedData['antibiotics']);
|
||||
if ($tanggalmasuk != ''){
|
||||
try {
|
||||
@@ -416,18 +413,18 @@ class AstmMessageService
|
||||
$getorderid = Periksa::where('nofoto', $accession_number)->first();
|
||||
$orderid = $getorderid->id ?? null;
|
||||
if ($orderid){
|
||||
|
||||
if(is_array($parsedData['antibiotics']) && count($parsedData['antibiotics']) > 0){
|
||||
Log::info("Processing", $parsedData['antibiotics']);
|
||||
RekapAntibiotik::where('orderid', $orderid)->delete();
|
||||
foreach ($parsedData['antibiotics'] as $item){
|
||||
$glassreportname = in_array($item['antibiotic'], $jsonantibiotik);
|
||||
RekapAntibiotik::updateOrCreate(
|
||||
[
|
||||
$glassreportname = in_array($item['antibiotic_name'], $jsonantibiotik);
|
||||
RekapAntibiotik::create([
|
||||
'orderid' => $orderid,
|
||||
'antibiotic' => $item['antibiotic'],
|
||||
],
|
||||
[
|
||||
'resistance' => $item['resistance'],
|
||||
'value' => $item['value'],
|
||||
'interpretation' => $item['interpretation'],
|
||||
'antibiotic' => $item['antibiotic_name'] ?? null,
|
||||
'resistance' => $item['resistance_note'] ?? null,
|
||||
'value' => $item['value'] ?? null,
|
||||
'interpretation' => $item['interpretation'] ?? null,
|
||||
'glassreportname' => $glassreportname,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
@@ -445,7 +442,7 @@ class AstmMessageService
|
||||
Log::info("Data MTRL Berhasil di Parse dan di simpan ", $resultSample->toArray());
|
||||
return response()->json(['message' => 'Data berhasil diproses dan disimpan.']);
|
||||
} else {
|
||||
$headerData = explode("|", $response);
|
||||
$headerData = explode("|", $astmData);
|
||||
if (isset($headerData[3])){
|
||||
$accnumber = $headerData[47] ?? null;
|
||||
$noregister = $headerData[16] ?? null;
|
||||
@@ -608,7 +605,7 @@ class AstmMessageService
|
||||
}
|
||||
} else {
|
||||
Log::debug("Abaikan Data Berikut ". json_encode($headerData));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user