Update Cara Baca
This commit is contained in:
@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\DB;
|
||||
use Exception;
|
||||
use App\DataListiner;
|
||||
use App\Periksa;
|
||||
|
||||
use App\RekapAntibiotik;
|
||||
// Proses untuk Growth and Detection Result
|
||||
function processGrowthDetectionResult($rawData){
|
||||
// Format: R|1| ^ ^ ^GND_MGIT^430100001234|INST_POSITIVE ^87| ...
|
||||
@@ -148,6 +148,55 @@ class AstmMessageService
|
||||
if (empty($astmData)) {
|
||||
Log::error("ASTM data kosong atau tidak valid.");
|
||||
}
|
||||
$jsonantibiotik = array(
|
||||
'Oxacillin-OX',
|
||||
'Cefoxitin-FOX',
|
||||
'Benzylpenicillin-P',
|
||||
'Ampicillin-AM',
|
||||
'Azithromycin-AZM',
|
||||
'Erythromycin-ERY',
|
||||
'Cefazolin-CZO',
|
||||
'Cefepime-FEP',
|
||||
'Cefixime-CFM',
|
||||
'Cefotaxime-CTX',
|
||||
'Cefuroxime-CXM',
|
||||
'Ceftazidime-CAZ',
|
||||
'Ceftriaxone-CRO',
|
||||
'Ceftazidime/Avibactam-CZA',
|
||||
'Piperacilin/Tazobactam-TZP',
|
||||
'Ampicillin/Sulbactam-SAM',
|
||||
'Amoxicillin/Clavulanate-AMC',
|
||||
'Cefoperazon/Sulbactam-SCF',
|
||||
'Aztreonam-ATM',
|
||||
'Ceftaroline-CPT',
|
||||
'Ciprofloxacin-CIP',
|
||||
'Levofloxacin-LEV',
|
||||
'Moxifloxacin-MFX',
|
||||
'Clindamycin-CLI',
|
||||
'Colistin-CS',
|
||||
'Tetracyclin-TCY',
|
||||
'Tigecycline-TGC',
|
||||
'Gentamicin-GM',
|
||||
'Amikacin-AN',
|
||||
'Meropenem-MEM',
|
||||
'Imipenem-IPM',
|
||||
'Doripenem-DOR',
|
||||
'Ertapenem-ETP',
|
||||
'Minocycline-MNO',
|
||||
'Doxycycline-DOX',
|
||||
'Spectinomycin-SPT',
|
||||
'Tigecycline-TGC',
|
||||
'Trimethoprim/Sulfamethoxazole-SXT',
|
||||
'Fosfomycin-FOS',
|
||||
'Vancomycin-VAN',
|
||||
'Linezolid-LNZ',
|
||||
'Fluconazole',
|
||||
'Voriconazole',
|
||||
'Caspofungin',
|
||||
'Micafungin',
|
||||
'Amphotericin B',
|
||||
'Flucytosine'
|
||||
);
|
||||
$headerData = [];
|
||||
$patientData = [];
|
||||
$orderData = [];
|
||||
@@ -246,6 +295,9 @@ class AstmMessageService
|
||||
$value = '';
|
||||
$interpretation = '';
|
||||
$mulaikirim = 0;
|
||||
$tanggalmasuk = '';
|
||||
$tanggalkeluar = '';
|
||||
|
||||
$resultSample = new ResultSample();
|
||||
foreach ($mltrData as $index => $field) {
|
||||
if ($field == 'ra'){
|
||||
@@ -277,60 +329,60 @@ class AstmMessageService
|
||||
$interpretation = substr($field, 2);
|
||||
$mulaikirim++;
|
||||
} else {
|
||||
$cekbersih = trim($field, '"');
|
||||
|
||||
if (strpos($cekbersih, 'ci') === 0) {
|
||||
$accession_number = substr($cekbersih, 2);
|
||||
$cekbersih = trim($field, '"');
|
||||
if (strpos($cekbersih, 'mt') === 0) {
|
||||
$resultSample->sender_name = substr($cekbersih, 2);
|
||||
}
|
||||
$field = substr($field, 2);
|
||||
switch ($index) {
|
||||
case 0:
|
||||
$resultSample->sender_name = $alat;
|
||||
break;
|
||||
case 1:
|
||||
$resultSample->version_number = $field; // iiV2
|
||||
break;
|
||||
case 2:
|
||||
$resultSample->isolate_number = $field; // is000015F278BD
|
||||
break;
|
||||
case 4:
|
||||
$resultSample->patient_id = $field; // pi12009427
|
||||
break;
|
||||
case 5:
|
||||
$patientNames = explode(',', $field ?? null);
|
||||
if (count($patientNames) > 0) {
|
||||
$resultSample->patient_name_last = trim($patientNames[0]); // Last name
|
||||
}
|
||||
if (count($patientNames) > 1) {
|
||||
$resultSample->patient_name_first = trim($patientNames[1]); // First name
|
||||
}
|
||||
if (count($patientNames) > 2) {
|
||||
$resultSample->patient_name_middle = trim($patientNames[2]); // Middle name
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
$resultSample->address_street = $field; // plMANINJAU
|
||||
break;
|
||||
case 12:
|
||||
try {
|
||||
$resultSample->message_datetime = Carbon::parse($field)->format('Y-m-d') ?? null;
|
||||
}catch (Exception $e) {
|
||||
$resultSample->message_datetime = date('Y-m-d');
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
try {
|
||||
$resultSample->test_complete_datetime = Carbon::parse($field)->format('Y-m-d') ?? null;
|
||||
}catch (Exception $e) {
|
||||
$resultSample->test_complete_datetime = date('Y-m-d');
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
//$resultSample->accession_number = substr($field, 6); // ci30112024.26859
|
||||
break;
|
||||
case 23:
|
||||
$resultSample->organism = $field; // o2Staphylococcus haemolyticus
|
||||
break;
|
||||
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]);
|
||||
}
|
||||
if (count($patientNames) > 1) {
|
||||
$resultSample->patient_name_last = trim($patientNames[1]);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -341,15 +393,50 @@ class AstmMessageService
|
||||
|
||||
// Result Record
|
||||
$resultSample->additional_result = json_encode($parsedData['antibiotics']);
|
||||
|
||||
// Menyimpan data yang sudah diparse
|
||||
if ($tanggalmasuk != ''){
|
||||
try {
|
||||
$resultSample->message_datetime = Carbon::parse($tanggalmasuk)->format('Y-m-d H:i:s') ?? null;
|
||||
}catch (Exception $e) {
|
||||
$resultSample->message_datetime = date('Y-m-d H:i:s');
|
||||
}
|
||||
}
|
||||
if ($tanggalkeluar != ''){
|
||||
try {
|
||||
$resultSample->test_complete_datetime = Carbon::parse($tanggalkeluar)->format('Y-m-d H:i:s') ?? null;
|
||||
}catch (Exception $e) {
|
||||
$resultSample->test_complete_datetime = date('Y-m-d H:i:s');
|
||||
}
|
||||
}
|
||||
$resultSample->save();
|
||||
if ($accession_number){
|
||||
$resultSample->accession_number = $accession_number; // '12345'
|
||||
$getorderid = Periksa::where('nofoto', $accession_number)->first();
|
||||
$orderid = $getorderid->id ?? null;
|
||||
if ($orderid){
|
||||
if(is_array($parsedData['antibiotics']) && count($parsedData['antibiotics']) > 0){
|
||||
foreach ($parsedData['antibiotics'] as $item){
|
||||
$glassreportname = in_array($item['antibiotic'], $jsonantibiotik);
|
||||
RekapAntibiotik::updateOrCreate(
|
||||
[
|
||||
'orderid' => $orderid,
|
||||
'antibiotic' => $item['antibiotic'],
|
||||
],
|
||||
[
|
||||
'resistance' => $item['resistance'],
|
||||
'value' => $item['value'],
|
||||
'interpretation' => $item['interpretation'],
|
||||
'glassreportname' => $glassreportname,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Periksa::where('nofoto', $accession_number)->update([
|
||||
'status' => 'Data Vitek di Terima',
|
||||
]);
|
||||
}
|
||||
$resultSample->save();
|
||||
|
||||
|
||||
Log::info("Data MTRL Berhasil di Parse dan di simpan ", $resultSample->toArray());
|
||||
return response()->json(['message' => 'Data berhasil diproses dan disimpan.']);
|
||||
|
||||
Reference in New Issue
Block a user