update flow pasien, store & preview screen, source klinik, api dokter
This commit is contained in:
+47
-15
@@ -1,8 +1,10 @@
|
||||
// stores/queueStore.js
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useClinicStore } from './clinicStore';
|
||||
|
||||
export const useQueueStore = defineStore('queue', () => {
|
||||
const clinicStore = useClinicStore();
|
||||
// Seed data for easy reset during dev
|
||||
const seedPatients = [
|
||||
{
|
||||
@@ -175,17 +177,21 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
penunjang: null,
|
||||
});
|
||||
|
||||
const kliniks = ref([
|
||||
{ id: 1, name: "KANDUNGAN" },
|
||||
{ id: 2, name: "IPD" },
|
||||
{ id: 3, name: "THT" },
|
||||
{ id: 4, name: "SARAF" },
|
||||
{ id: 5, name: "JIWA" },
|
||||
{ id: 6, name: "BEDAH" },
|
||||
{ id: 7, name: "MATA" },
|
||||
{ id: 8, name: "ANAK" },
|
||||
{ id: 9, name: "KULIT" },
|
||||
]);
|
||||
// Daftar klinik untuk dropdown diambil 1 pintu dari clinicStore
|
||||
const kliniks = computed(() => {
|
||||
const baseList = typeof clinicStore.getClinicsForDropdown === 'function'
|
||||
? clinicStore.getClinicsForDropdown()
|
||||
: [];
|
||||
|
||||
// Bentuk objek disesuaikan dengan yang dipakai di useQueue (id, name, kode)
|
||||
return baseList.map((c) => ({
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
kode: c.kode,
|
||||
icon: c.icon,
|
||||
available: c.available,
|
||||
}));
|
||||
});
|
||||
|
||||
const penunjangs = ref([
|
||||
{ id: 1, name: "LABORATORIUM" },
|
||||
@@ -261,7 +267,6 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
const index = allPatients.value.findIndex(p => p.no === nextPatient.no);
|
||||
if (index !== -1) {
|
||||
allPatients.value[index] = { ...allPatients.value[index], status: "di-loket" };
|
||||
currentProcessingPatient.value[adminType] = allPatients.value[index];
|
||||
}
|
||||
|
||||
quotaUsed.value++;
|
||||
@@ -401,10 +406,35 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
return { success: true, message };
|
||||
};
|
||||
|
||||
const createAntreanKlinik = (klinik, adminType = 'loket') => {
|
||||
const processNextQueue = (adminType = 'loket') => {
|
||||
const stageMap = {
|
||||
'loket': 'loket',
|
||||
'klinik': 'klinik',
|
||||
'penunjang': 'penunjang'
|
||||
};
|
||||
|
||||
const targetStage = stageMap[adminType];
|
||||
const nextPatient = allPatients.value.find(p =>
|
||||
p.status === 'di-loket' && p.processStage === targetStage
|
||||
);
|
||||
|
||||
if (!nextPatient) {
|
||||
return { success: false, message: "Tidak ada pasien di loket yang dapat diproses" };
|
||||
}
|
||||
|
||||
// Set sebagai current processing patient
|
||||
currentProcessingPatient.value[adminType] = nextPatient;
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `Memproses pasien ${nextPatient.noAntrian.split(" |")[0]}`,
|
||||
};
|
||||
};
|
||||
|
||||
const createAntreanKlinik = (klinik, patient = null, adminType = 'loket') => {
|
||||
const newNo = allPatients.value.length + 1;
|
||||
const timestamp = new Date();
|
||||
const barcode = `250811${String(timestamp.getTime()).slice(-6)}`;
|
||||
const barcode = patient ? patient.barcode : `250811${String(timestamp.getTime()).slice(-6)}`;
|
||||
|
||||
const newPatient = {
|
||||
no: newNo,
|
||||
@@ -416,10 +446,11 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
shift: "Shift 1",
|
||||
klinik: klinik.name,
|
||||
fastTrack: "TIDAK",
|
||||
pembayaran: "UMUM",
|
||||
pembayaran: patient ? patient.pembayaran : "UMUM",
|
||||
status: "di-loket",
|
||||
processStage: "klinik",
|
||||
createdAt: timestamp.toISOString(),
|
||||
referencePatient: patient ? patient.noAntrian : null,
|
||||
};
|
||||
|
||||
allPatients.value.push(newPatient);
|
||||
@@ -515,6 +546,7 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
createAntreanKlinik,
|
||||
createAntreanPenunjang,
|
||||
changeKlinik,
|
||||
processNextQueue,
|
||||
getPatientsByStage,
|
||||
getTotalPasienByStage,
|
||||
getCurrentProcessing,
|
||||
|
||||
Reference in New Issue
Block a user