update
This commit is contained in:
@@ -845,10 +845,12 @@ class GudangController extends Controller
|
||||
|
||||
$rows = $query->get();
|
||||
$grouped = [];
|
||||
$jenisNames = [];
|
||||
foreach ($rows as $row) {
|
||||
$jenis = $row->jenis ?: 'Tidak Diketahui';
|
||||
if (!isset($grouped[$jenis])) {
|
||||
$grouped[$jenis] = ['jenis' => $jenis, 'masuk' => 0, 'keluar' => 0];
|
||||
$grouped[$jenis] = ['jenis' => $jenis, 'masuk' => 0, 'keluar' => 0, 'sisa' => 0];
|
||||
$jenisNames[] = $jenis;
|
||||
}
|
||||
if (!is_null($row->pemasukan) && (int)$row->pemasukan > 0) {
|
||||
$grouped[$jenis]['masuk'] += $this->extractBaseQty($row, 'pemasukan');
|
||||
@@ -858,6 +860,14 @@ class GudangController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($jenisNames)) {
|
||||
$stockMap = app(SimbhpStockService::class)->getStockBaseByJenisMany($jenisNames);
|
||||
foreach ($grouped as $jenis => &$item) {
|
||||
$item['sisa'] = (int) ($stockMap[$jenis] ?? 0);
|
||||
}
|
||||
unset($item);
|
||||
}
|
||||
|
||||
return array_values($grouped);
|
||||
}
|
||||
|
||||
|
||||
@@ -868,14 +868,10 @@ class ReportController extends Controller
|
||||
$bulan = str_replace('bulan=', '', $bulan);
|
||||
$tahun = str_replace('tahun=', '', $tahun);
|
||||
}
|
||||
|
||||
// Query Periksa
|
||||
$query = Periksa::query()->where('dlp', 'Kultur')->whereNotNull('dokter_id')->whereYear('daftar', $tahun);
|
||||
if ($bulan != 'ALL' && $bulan != 'Pick Month') {
|
||||
$query->whereMonth('daftar', $bulan);
|
||||
}
|
||||
|
||||
// Preview dibuat paginated agar aman saat filter setahun.
|
||||
$orderbydate = $query->orderBy('daftar', 'ASC')->orderBy('id', 'ASC')->paginate(50);
|
||||
$orderbydate->appends(['bulan' => $bulan, 'tahun' => $tahun]);
|
||||
|
||||
|
||||
@@ -329,10 +329,30 @@ class GudangPos extends Component
|
||||
|
||||
$jenisNames = $products->getCollection()->pluck('jenis')->filter()->values()->all();
|
||||
$stockMap = $service->getStockBaseByJenisMany($jenisNames);
|
||||
$latestExpiredMap = [];
|
||||
if (count($jenisNames) > 0) {
|
||||
$expiredRows = SIMBHPReport::query()
|
||||
->select('jenis', DB::raw('MAX(masa_expired) as latest_expired'))
|
||||
->whereIn('jenis', $jenisNames)
|
||||
->whereNotNull('masa_expired')
|
||||
->whereNotNull('pemasukan')
|
||||
->where('pemasukan', '>', 0)
|
||||
->groupBy('jenis')
|
||||
->get();
|
||||
|
||||
foreach ($expiredRows as $row) {
|
||||
$jenisNama = (string) ($row->jenis ?? '');
|
||||
$expired = (string) ($row->latest_expired ?? '');
|
||||
if ($jenisNama !== '' && $expired !== '') {
|
||||
$latestExpiredMap[$jenisNama] = Carbon::parse($expired)->format('d-m-Y');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$selectedJenis = null;
|
||||
$selectedStockDisplay = null;
|
||||
$selectedSetting = null;
|
||||
$selectedLatestExpired = null;
|
||||
$kode = $service->sanitizeKode($this->selectedKode);
|
||||
if ($kode !== '') {
|
||||
$selectedJenis = $service->getJenisByKode($kode);
|
||||
@@ -345,6 +365,7 @@ class GudangPos extends Component
|
||||
(string) ($selectedJenis->satuan_kecil ?? ''),
|
||||
(int) ($selectedJenis->konversi_kecil ?? 1),
|
||||
);
|
||||
$selectedLatestExpired = $latestExpiredMap[(string) $selectedJenis->jenis] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,9 +373,11 @@ class GudangPos extends Component
|
||||
'users' => $users,
|
||||
'products' => $products,
|
||||
'stockMap' => $stockMap,
|
||||
'latestExpiredMap' => $latestExpiredMap,
|
||||
'selectedJenis' => $selectedJenis,
|
||||
'selectedStockDisplay' => $selectedStockDisplay,
|
||||
'selectedSetting' => $selectedSetting,
|
||||
'selectedLatestExpired' => $selectedLatestExpired,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,9 +124,6 @@
|
||||
<div class="form-group">
|
||||
<button type="button" class="btn btn-success btn-block" id="btn_op_in_addline">Tambah ke Daftar</button>
|
||||
</div>
|
||||
<div class="form-group m-b-0">
|
||||
<button type="button" class="btn btn-custom btn-block" id="btn_op_in_commit">Simpan Semua Barang Masuk</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-8">
|
||||
@@ -150,6 +147,9 @@
|
||||
</table>
|
||||
</div>
|
||||
<small class="text-muted d-block m-t-10">Catatan: sistem akan menyimpan per-item menjadi baris transaksi (mirip stok opname).</small>
|
||||
<div class="text-right m-t-15">
|
||||
<button type="button" class="btn btn-custom" id="btn_op_in_commit">Simpan Semua Barang Masuk</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -207,12 +207,12 @@
|
||||
<hr>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-bordered m-b-0">
|
||||
<thead><tr><th>Jenis</th><th>Masuk</th><th>Keluar</th></tr></thead>
|
||||
<thead><tr><th>Jenis</th><th>Masuk</th><th>Keluar</th><th>Sisa Stok</th></tr></thead>
|
||||
<tbody id="stat_perjenis_harian_body">
|
||||
@forelse($stat_perjenis_harian ?? [] as $row)
|
||||
<tr><td>{{ $row['jenis'] }}</td><td class="text-right">{{ number_format($row['masuk'],0,'.',',') }}</td><td class="text-right">{{ number_format($row['keluar'],0,'.',',') }}</td></tr>
|
||||
<tr><td>{{ $row['jenis'] }}</td><td class="text-right">{{ number_format($row['masuk'],0,'.',',') }}</td><td class="text-right">{{ number_format($row['keluar'],0,'.',',') }}</td><td class="text-right">{{ number_format($row['sisa'] ?? 0,0,'.',',') }}</td></tr>
|
||||
@empty
|
||||
<tr><td colspan="3" class="text-center">Belum ada transaksi</td></tr>
|
||||
<tr><td colspan="4" class="text-center">Belum ada transaksi</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -227,12 +227,12 @@
|
||||
<hr>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-bordered m-b-0">
|
||||
<thead><tr><th>Jenis</th><th>Masuk</th><th>Keluar</th></tr></thead>
|
||||
<thead><tr><th>Jenis</th><th>Masuk</th><th>Keluar</th><th>Sisa Stok</th></tr></thead>
|
||||
<tbody id="stat_perjenis_bulanan_body">
|
||||
@forelse($stat_perjenis_bulanan ?? [] as $row)
|
||||
<tr><td>{{ $row['jenis'] }}</td><td class="text-right">{{ number_format($row['masuk'],0,'.',',') }}</td><td class="text-right">{{ number_format($row['keluar'],0,'.',',') }}</td></tr>
|
||||
<tr><td>{{ $row['jenis'] }}</td><td class="text-right">{{ number_format($row['masuk'],0,'.',',') }}</td><td class="text-right">{{ number_format($row['keluar'],0,'.',',') }}</td><td class="text-right">{{ number_format($row['sisa'] ?? 0,0,'.',',') }}</td></tr>
|
||||
@empty
|
||||
<tr><td colspan="3" class="text-center">Belum ada transaksi</td></tr>
|
||||
<tr><td colspan="4" class="text-center">Belum ada transaksi</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -247,12 +247,12 @@
|
||||
<hr>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-bordered m-b-0">
|
||||
<thead><tr><th>Jenis</th><th>Masuk</th><th>Keluar</th></tr></thead>
|
||||
<thead><tr><th>Jenis</th><th>Masuk</th><th>Keluar</th><th>Sisa Stok</th></tr></thead>
|
||||
<tbody id="stat_perjenis_tahunan_body">
|
||||
@forelse($stat_perjenis_tahunan ?? [] as $row)
|
||||
<tr><td>{{ $row['jenis'] }}</td><td class="text-right">{{ number_format($row['masuk'],0,'.',',') }}</td><td class="text-right">{{ number_format($row['keluar'],0,'.',',') }}</td></tr>
|
||||
<tr><td>{{ $row['jenis'] }}</td><td class="text-right">{{ number_format($row['masuk'],0,'.',',') }}</td><td class="text-right">{{ number_format($row['keluar'],0,'.',',') }}</td><td class="text-right">{{ number_format($row['sisa'] ?? 0,0,'.',',') }}</td></tr>
|
||||
@empty
|
||||
<tr><td colspan="3" class="text-center">Belum ada transaksi</td></tr>
|
||||
<tr><td colspan="4" class="text-center">Belum ada transaksi</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -869,10 +869,11 @@
|
||||
'<td>' + escapeHtml(r.jenis || '-') + '</td>' +
|
||||
'<td class="text-right">' + formatInt(r.masuk || 0) + '</td>' +
|
||||
'<td class="text-right">' + formatInt(r.keluar || 0) + '</td>' +
|
||||
'<td class="text-right">' + formatInt(r.sisa || 0) + '</td>' +
|
||||
'</tr>';
|
||||
});
|
||||
if(!html){
|
||||
html = '<tr><td colspan="3" class="text-center">Belum ada transaksi</td></tr>';
|
||||
html = '<tr><td colspan="4" class="text-center">Belum ada transaksi</td></tr>';
|
||||
}
|
||||
$(tbodyId).html(html);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
@php
|
||||
$saldoBase = (int) ($stockMap[$p->jenis] ?? 0);
|
||||
$warning = $saldoBase <= (int) ($p->stok_minimum ?? 0);
|
||||
$latestExpired = $latestExpiredMap[$p->jenis] ?? null;
|
||||
@endphp
|
||||
<div class="col-lg-4 col-md-6">
|
||||
<div class="card-box" style="border:1px solid #eee; cursor:pointer;" wire:click="selectProduct('{{ $p->kodejenis }}')">
|
||||
@@ -46,6 +47,9 @@
|
||||
<div class="m-t-5">
|
||||
<small class="text-muted">Satuan: {{ $p->satuan }} @if(($p->satuan_kecil ?? '') !== '') / {{ $p->satuan_kecil }} @endif</small>
|
||||
</div>
|
||||
<div class="m-t-5">
|
||||
<small class="text-muted">Expired terakhir: {{ $latestExpired ?: '-' }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
@@ -139,6 +143,7 @@
|
||||
<div class="alert alert-info">
|
||||
<div><b>{{ $selectedJenis->jenis }}</b></div>
|
||||
<div>Stok: <b>{{ $selectedStockDisplay }}</b></div>
|
||||
<div>Expired terakhir: <b>{{ $selectedLatestExpired ?: '-' }}</b></div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="form-group">
|
||||
|
||||
+21
-5
@@ -474,9 +474,9 @@ def create_genexpert_rsp_z02_response(orders, incoming_hl7, ip_addr=None):
|
||||
|
||||
segments.append(f"PID|{patient_idx}||{patient_id}||{patient_name}||{dob}|{sex}|||{address}")
|
||||
segments.append(f"ORC|NW|1|||||||{order_ts}")
|
||||
segments.append(f"OBR|1|||{assay_code}^{requested_test_name}^L|||||||A")
|
||||
segments.append(f"OBR|1|||{assay_code}|||||||A")
|
||||
segments.append("TQ1|||||||||R")
|
||||
segments.append(f"SPM|1|{sample_id}^{sample_id}||{specimen_type}|||||||P")
|
||||
segments.append(f"SPM|1|{sample_id}^||ORH|||||||P")
|
||||
|
||||
return "\r".join(segments) + "\r"
|
||||
|
||||
@@ -595,6 +595,15 @@ def send_genexpert_response(conn, ip_addr, hl7_message, framing, label=""):
|
||||
)
|
||||
conn.sendall(payload)
|
||||
|
||||
def send_genexpert_transport_ack(conn, ip_addr, framing, reason="frame-received"):
|
||||
if framing != "astm":
|
||||
return
|
||||
try:
|
||||
conn.sendall(b"\x06")
|
||||
print(f"[GENEXPERT-DEBUG] Transport ACK sent ip={ip_addr}, framing={framing}, reason={reason}")
|
||||
except Exception as exc:
|
||||
print(f"[GENEXPERT-DEBUG] Transport ACK gagal ip={ip_addr}, framing={framing}, reason={reason}, error={exc}")
|
||||
|
||||
def debug_genexpert_order_message(hl7_message, ip_addr=None):
|
||||
segments = parse_hl7_segments(hl7_message)
|
||||
current_pid = ""
|
||||
@@ -2109,10 +2118,10 @@ def handle_genexpert_client(conn, addr):
|
||||
msg_complete = True
|
||||
elif b'\x03' in buffer: # Pola ASTM (Ada Checksum setelahnya)
|
||||
# ASTM: <STX>...<ETX>CS<CR><LF>
|
||||
# Kita cari \x03, lalu tambah 4 byte (CS + CRLF) untuk aman
|
||||
# Kita cari \x03, lalu ambil ETX + 2 checksum + CRLF secara penuh.
|
||||
pos = buffer.find(b'\x03')
|
||||
if len(buffer) >= pos + 4:
|
||||
end_marker_pos = pos + 4
|
||||
if len(buffer) >= pos + 5:
|
||||
end_marker_pos = pos + 5
|
||||
msg_complete = True
|
||||
elif b'\x04' in buffer: # Pola EOT (Putus Koneksi/Selesai)
|
||||
end_marker_pos = buffer.find(b'\x04')
|
||||
@@ -2126,6 +2135,13 @@ def handle_genexpert_client(conn, addr):
|
||||
|
||||
full_message_bytes = buffer[:end_marker_pos]
|
||||
response_framing = detect_genexpert_message_framing(full_message_bytes)
|
||||
|
||||
send_genexpert_transport_ack(
|
||||
conn,
|
||||
addr[0],
|
||||
response_framing,
|
||||
reason="incoming-frame-complete"
|
||||
)
|
||||
|
||||
# Sisa buffer (jika ada paket nempel di belakangnya) disimpan untuk loop berikutnya
|
||||
buffer = buffer[end_marker_pos:]
|
||||
|
||||
Reference in New Issue
Block a user