update logika pemanggilan admin loket by payment
This commit is contained in:
+35
-12
@@ -1000,7 +1000,7 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
idtiket: nextPatient.barcode || "",
|
||||
barcode: nextPatient.barcode || "",
|
||||
statuspasien: "3",
|
||||
statuspasien2: "4",
|
||||
idklinikstatus: "1",
|
||||
@@ -1096,7 +1096,7 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
idtiket: patient.barcode || "",
|
||||
barcode: patient.barcode || "",
|
||||
statuspasien: "3",
|
||||
statuspasien2: "4",
|
||||
idklinikstatus: "1",
|
||||
@@ -1938,18 +1938,41 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
const registerRegulerPatientViaApi = async (clinic, paymentType, visitType = 'SEKARANG', isFastTrack = false, fastTrackData = null) => {
|
||||
try {
|
||||
console.log('🔄 [queueStore] Generating ticket via API for REGULER patient...');
|
||||
console.log('📋 [queueStore] Payment Type:', paymentType, '| Clinic:', clinic.name, '| Clinic Code:', clinic.kode);
|
||||
|
||||
// 1. Find appropriate idloket based on BOTH clinic code AND payment type
|
||||
const allLokets = loketStore.lokets || [];
|
||||
|
||||
// Determine payment type for matching (normalize BPJS to JKN for API compatibility)
|
||||
const paymentTypeForMatching = paymentType === "BPJS" ? "JKN" : paymentType;
|
||||
|
||||
// Find loket that handles BOTH the clinic AND the payment type
|
||||
const targetLoket = allLokets.find(l => {
|
||||
// Check if loket handles the clinic
|
||||
const handlesClinic = l.pelayanan && Array.isArray(l.pelayanan) && l.pelayanan.includes(clinic.kode);
|
||||
if (!handlesClinic) return false;
|
||||
|
||||
// 1. Find appropriate idloket
|
||||
const allLokets = loketStore.lokets || [];
|
||||
const targetLoket = allLokets.find(l =>
|
||||
l.pelayanan && Array.isArray(l.pelayanan) && l.pelayanan.includes(clinic.kode)
|
||||
);
|
||||
// Check if loket accepts the payment type
|
||||
const acceptsPayment = l.pembayaran && Array.isArray(l.pembayaran) &&
|
||||
l.pembayaran.some(p => {
|
||||
// Handle case-insensitive matching and common variations
|
||||
const normalizedP = String(p).toUpperCase().trim();
|
||||
const normalizedPayment = String(paymentTypeForMatching).toUpperCase().trim();
|
||||
return normalizedP === normalizedPayment ||
|
||||
(normalizedPayment === "JKN" && normalizedP === "BPJS") ||
|
||||
(normalizedPayment === "BPJS" && normalizedP === "JKN");
|
||||
});
|
||||
|
||||
const idloket = targetLoket ? String(targetLoket.id) : "2"; // Default fallback to "2" if not found
|
||||
|
||||
// 2. Determine idpembayaran based on paymentType
|
||||
// BPJS (JKN) = "2", UMUM and others = "1"
|
||||
const idpembayaran = paymentType === "BPJS" ? "2" : "1";
|
||||
return handlesClinic && acceptsPayment;
|
||||
});
|
||||
|
||||
const idloket = targetLoket ? String(targetLoket.id) : "2"; // Default fallback to "2" if not found
|
||||
|
||||
console.log('🎯 [queueStore] Target Loket:', targetLoket ? `${targetLoket.namaLoket} (ID: ${targetLoket.id})` : 'Not found (using fallback)', '| Accepts Payment:', targetLoket?.pembayaran);
|
||||
|
||||
// 2. Determine idpembayaran based on paymentType
|
||||
// BPJS (JKN) = "2", UMUM and others = "1"
|
||||
const idpembayaran = paymentType === "BPJS" ? "2" : "1";
|
||||
|
||||
// 3. Prepare API Body
|
||||
const body = {
|
||||
|
||||
Reference in New Issue
Block a user