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