layar baru antrean klinik dan masuk
This commit is contained in:
+68
-9
@@ -124,16 +124,68 @@ export const useQueue = (adminType = "loket") => {
|
||||
showSnackbar(result.message, color);
|
||||
};
|
||||
|
||||
// Helper function untuk mendapatkan pasien yang sedang diproses dari store
|
||||
const getCurrentProcessingPatientFromStore = () => {
|
||||
try {
|
||||
const processingPatient = queueStore.currentProcessingPatient?.[adminType];
|
||||
if (!processingPatient) return null;
|
||||
|
||||
// Dapatkan data terbaru dari allPatients langsung (bukan dari getPatientsByStage yang sudah difilter)
|
||||
// allPatients adalah ref yang di-export dari Pinia store, bisa diakses langsung atau dengan .value
|
||||
// Coba akses langsung dulu, jika undefined baru coba dengan .value
|
||||
let allPatients = [];
|
||||
if (queueStore.allPatients) {
|
||||
// Jika allPatients adalah ref (punya .value)
|
||||
allPatients = Array.isArray(queueStore.allPatients)
|
||||
? queueStore.allPatients
|
||||
: (queueStore.allPatients.value || []);
|
||||
}
|
||||
|
||||
// Cari pasien berdasarkan no, barcode, atau noAntrian
|
||||
const latestPatient = allPatients.find(
|
||||
p => (p && p.no === processingPatient.no) ||
|
||||
(p && p.barcode && p.barcode === processingPatient.barcode) ||
|
||||
(p && p.noAntrian && p.noAntrian === processingPatient.noAntrian)
|
||||
);
|
||||
|
||||
// Jika ditemukan, return data terbaru, jika tidak return data dari currentProcessingPatient
|
||||
return latestPatient || processingPatient;
|
||||
} catch (error) {
|
||||
console.error('Error in getCurrentProcessingPatientFromStore:', error);
|
||||
// Fallback: return processingPatient dari store jika ada
|
||||
return queueStore.currentProcessingPatient?.[adminType] || null;
|
||||
}
|
||||
};
|
||||
|
||||
const selectKlinik = (klinik) => {
|
||||
const result = queueStore.createAntreanKlinik(klinik, currentProcessingPatient.value, adminType);
|
||||
// Pastikan currentProcessingPatient valid, jika tidak, coba dapatkan dari store
|
||||
let patient = currentProcessingPatient.value || getCurrentProcessingPatientFromStore();
|
||||
|
||||
if (!patient) {
|
||||
showSnackbar("Tidak ada pasien yang sedang diproses", "error");
|
||||
showKlinikDialog.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const result = queueStore.createAntreanKlinik(klinik, patient, adminType);
|
||||
showSnackbar(result.message, "success");
|
||||
showKlinikDialog.value = false;
|
||||
};
|
||||
|
||||
const selectPenunjang = (penunjang) => {
|
||||
// Pastikan currentProcessingPatient valid, jika tidak, coba dapatkan dari store
|
||||
let patient = currentProcessingPatient.value || getCurrentProcessingPatientFromStore();
|
||||
|
||||
if (!patient) {
|
||||
showSnackbar("Tidak ada pasien yang sedang diproses", "error");
|
||||
showPenunjangDialog.value = false;
|
||||
selectedPatientForPenunjang.value = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const result = queueStore.createAntreanPenunjang(
|
||||
penunjang,
|
||||
currentProcessingPatient.value,
|
||||
patient,
|
||||
adminType
|
||||
);
|
||||
showSnackbar(result.message, "success");
|
||||
@@ -147,15 +199,22 @@ export const useQueue = (adminType = "loket") => {
|
||||
};
|
||||
|
||||
const changeKlinik = (klinik) => {
|
||||
if (currentProcessingPatient.value) {
|
||||
const result = queueStore.changeKlinik(
|
||||
currentProcessingPatient.value,
|
||||
klinik,
|
||||
adminType
|
||||
);
|
||||
showSnackbar(result.message, result.success ? "success" : "error");
|
||||
// Pastikan currentProcessingPatient valid, jika tidak, coba dapatkan dari store
|
||||
let patient = currentProcessingPatient.value || getCurrentProcessingPatientFromStore();
|
||||
|
||||
if (!patient) {
|
||||
showSnackbar("Tidak ada pasien yang sedang diproses", "error");
|
||||
showChangeKlinikDialog.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const result = queueStore.changeKlinik(
|
||||
patient,
|
||||
klinik,
|
||||
adminType
|
||||
);
|
||||
showSnackbar(result.message, result.success ? "success" : "error");
|
||||
showChangeKlinikDialog.value = false;
|
||||
};
|
||||
|
||||
const processNextQueue = () => {
|
||||
|
||||
Reference in New Issue
Block a user