update fixing status dan pasien selesai ruang
This commit is contained in:
@@ -985,7 +985,8 @@ const getAllPatientsForRoom = (ruang) => {
|
||||
const matches =
|
||||
p.kodeKlinik === klinikData.value?.kodeKlinik &&
|
||||
p.nomorRuang === ruang.nomorRuang &&
|
||||
p.processStage === 'klinik-ruang';
|
||||
p.processStage === 'klinik-ruang' &&
|
||||
p.status !== 'processed'; // Exclude finished patients
|
||||
|
||||
return matches;
|
||||
});
|
||||
@@ -1718,11 +1719,11 @@ const handleCallPatientByTipe = async (ruang, tipeLayanan) => {
|
||||
showSnackbar(`Memanggil pasien ${patientCode} untuk ${tipeLayanan}`, 'success');
|
||||
};
|
||||
|
||||
const handlePatientAction = (ruang, action) => {
|
||||
const handlePatientAction = async (ruang, action) => {
|
||||
const current = getCurrentProcessingForRoom(ruang);
|
||||
if (!current) return;
|
||||
|
||||
const result = queueStore.processPatientKlinikRuang(
|
||||
const result = await queueStore.processPatientKlinikRuang(
|
||||
current,
|
||||
action,
|
||||
klinikData.value.kodeKlinik,
|
||||
|
||||
+32
-1
@@ -2559,7 +2559,7 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
};
|
||||
|
||||
// Process patient in klinik ruang (set as current processing)
|
||||
const processPatientKlinikRuang = (patient, action, kodeKlinik, nomorRuang) => {
|
||||
const processPatientKlinikRuang = async (patient, action, kodeKlinik, nomorRuang) => {
|
||||
const patientIndex = allPatients.value.findIndex(p => p.no === patient.no);
|
||||
if (patientIndex === -1) return { success: false, message: "Pasien tidak ditemukan" };
|
||||
|
||||
@@ -2574,6 +2574,37 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
message = `Memproses ${pCode}`;
|
||||
break;
|
||||
case "selesai":
|
||||
// Send API call to finish endpoint
|
||||
try {
|
||||
const apiUrl = 'http://10.10.150.100:8084/api/v1/visit/status/finish';
|
||||
const requestBody = {
|
||||
patient_visit_healthcare_service_id: patient.klinikId || patient.idKlinik,
|
||||
visit_code: patient.barcode || patient.visitCode,
|
||||
visit_status_id: [19]
|
||||
};
|
||||
|
||||
console.log('📤 [queueStore] Sending finish request to API:', requestBody);
|
||||
|
||||
const response = await fetch(apiUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestBody)
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error('❌ [queueStore] Failed to finish patient via API:', response.status, response.statusText);
|
||||
// Continue with local status update even if API fails
|
||||
} else {
|
||||
console.log('✅ [queueStore] Successfully finished patient via API');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ [queueStore] Error calling finish API:', error);
|
||||
// Continue with local status update even if API fails
|
||||
}
|
||||
|
||||
// Update local status
|
||||
allPatients.value[patientIndex] = { ...allPatients.value[patientIndex], status: "processed" };
|
||||
currentProcessingPatient.value[storageKey] = null;
|
||||
message = `Pasien ${pCode} selesai diproses`;
|
||||
|
||||
Reference in New Issue
Block a user