fix socket checkin
This commit is contained in:
@@ -1779,6 +1779,7 @@ const checkInClientId = computed(() => {
|
||||
const fetchAllData = async () => {
|
||||
console.log('🔄 CheckIn refresh: Syncing data...');
|
||||
try {
|
||||
await queueStore.fetchAllPatients();
|
||||
queueStore.ensureInitialData();
|
||||
checkAndResetDaily();
|
||||
console.log('✅ CheckIn refresh: Success');
|
||||
@@ -3354,6 +3355,13 @@ const checkInManual = async () => {
|
||||
kodeKlinik: null,
|
||||
});
|
||||
|
||||
// RESET lastCheckInResult for failure to avoid success color bleed
|
||||
lastCheckInResult.value = {
|
||||
success: false,
|
||||
patientId: searchBarcode || inputValue,
|
||||
status: "NOT_FOUND",
|
||||
};
|
||||
|
||||
const errorMsg = `❌ Tiket Tidak Ditemukan!\n\nInput: ${inputValue}\n\nTiket dengan nomor antrean atau barcode tersebut tidak ditemukan di sistem.\n\nPastikan:\n- Nomor antrean atau barcode sudah benar\n- Tiket sudah di-generate terlebih dahulu\n- Format input: RA020, F-RA001, atau 26011500001`;
|
||||
infoMessage.value = errorMsg;
|
||||
infoAction.value = "checkin";
|
||||
@@ -3414,6 +3422,13 @@ const checkInManual = async () => {
|
||||
kodeKlinik: foundPatient.kodeKlinik || null,
|
||||
});
|
||||
|
||||
// RESET lastCheckInResult for failure
|
||||
lastCheckInResult.value = {
|
||||
success: false,
|
||||
patientId: foundPatient.barcode,
|
||||
status: "REFRESH_NOT_FOUND",
|
||||
};
|
||||
|
||||
const errorMsg = `❌ Pasien tidak ditemukan di sistem setelah refresh data.`;
|
||||
infoMessage.value = errorMsg;
|
||||
infoAction.value = "checkin";
|
||||
|
||||
@@ -447,6 +447,22 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Global fetcher for all patients across all available lokets
|
||||
*/
|
||||
const fetchAllPatients = async () => {
|
||||
console.log('🔄 [queueStore] Fetching all patients for all lokets...');
|
||||
const allLokets = loketStore.lokets || [];
|
||||
if (allLokets.length === 0) {
|
||||
console.warn('⚠️ [queueStore] No lokets available for fetchAllPatients');
|
||||
return;
|
||||
}
|
||||
|
||||
// Use Promise.all for faster fetching
|
||||
await Promise.all(allLokets.map(l => fetchPatientsForLoket(l.id)));
|
||||
console.log(`✅ [queueStore] All patients fetched. Total: ${allPatients.value.length}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get patients for a specific loket (from API or seed data based on loket type)
|
||||
*/
|
||||
@@ -2549,6 +2565,7 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
|
||||
// API Patient Actions
|
||||
fetchPatientsForLoket,
|
||||
fetchAllPatients,
|
||||
getPatientsForLoket,
|
||||
mapStatusFromDeskripsi,
|
||||
mapApiPatientToStoreFormat,
|
||||
|
||||
Reference in New Issue
Block a user