QRcode update
This commit is contained in:
@@ -91,14 +91,23 @@ export default defineEventHandler(async (event: H3Event) => {
|
||||
})
|
||||
}
|
||||
|
||||
// Helper function untuk generate barcode dengan format: YYMMDD + 5 digit random
|
||||
// Helper function untuk generate barcode dengan format: YYMMDD + 5 digit sequential
|
||||
// Format: YY (tahun 2 digit terakhir) + MM (bulan 2 digit) + DD (tanggal 2 digit) + XXXXX (5 digit sequential)
|
||||
// Contoh: 26011400001, 26011400002, dst
|
||||
// Counter akan reset setiap ganti tanggal (mulai dari 00001 lagi)
|
||||
const generateBarcode = () => {
|
||||
const now = new Date();
|
||||
const year = String(now.getFullYear()).slice(-2); // 2 digit tahun terakhir
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0'); // 2 digit bulan
|
||||
const day = String(now.getDate()).padStart(2, '0'); // 2 digit tanggal
|
||||
const randomCode = String(Math.floor(Math.random() * 100000)).padStart(5, '0'); // 5 digit random
|
||||
return `${year}${month}${day}${randomCode}`;
|
||||
const datePrefix = `${year}${month}${day}`; // YYMMDD
|
||||
|
||||
// Gunakan counter berdasarkan existing patients untuk sequential
|
||||
// NOTE: Di production, gunakan database counter atau shared counter service
|
||||
const existingCount = mockDB.filter(p => p.barcode && p.barcode.startsWith(datePrefix)).length;
|
||||
const counter = existingCount + 1;
|
||||
const counterCode = String(counter).padStart(5, '0'); // 5 digit sequential
|
||||
return `${datePrefix}${counterCode}`;
|
||||
};
|
||||
|
||||
// Generate patient data
|
||||
|
||||
Reference in New Issue
Block a user