update flow pasien, store & preview screen, source klinik, api dokter

This commit is contained in:
bagus-arie05
2025-12-18 14:22:15 +07:00
parent d2a51f3aee
commit dfcd59481c
18 changed files with 984 additions and 183 deletions

No files matched your search

+32 -8
View File
@@ -1,8 +1,12 @@
// stores/masterStore.js - Integrated dengan Penunjang
import { defineStore } from 'pinia';
import { ref, computed } from 'vue';
import { useClinicStore } from './clinicStore';
export const useMasterStore = defineStore('master', () => {
// Store referensi utama daftar klinik (single source of truth)
const clinicStore = useClinicStore();
// ============================================
// MASTER KLINIK
// ============================================
@@ -74,13 +78,24 @@ export const useMasterStore = defineStore('master', () => {
]);
// Computed - Get klinik list for dropdowns
const klinikList = computed(() =>
klinikData.value.map(k => ({
id: k.id,
kode: k.kode,
nama: k.nama
}))
);
// Sumber data kode & nama klinik diambil dari clinicStore (1 pintu),
// lalu difilter hanya untuk kode yang terdaftar di master klinik ini.
const klinikList = computed(() => {
const availableCodes = new Set(klinikData.value.map((k) => k.kode));
// getClinicsForDropdown() sudah mengembalikan { id, name, kode, icon, available }
const baseList = typeof clinicStore.getClinicsForDropdown === 'function'
? clinicStore.getClinicsForDropdown()
: [];
return baseList
.filter((c) => availableCodes.has(c.kode))
.map((c) => ({
id: c.id,
kode: c.kode,
nama: c.name,
}));
});
// Actions - Klinik
const addKlinik = (klinikPayload) => {
@@ -611,7 +626,16 @@ export const useMasterStore = defineStore('master', () => {
// UTILITY FUNCTIONS
// ============================================
const getKlinikNameByKode = (kode) => {
const klinik = klinikData.value.find(k => k.kode === kode);
// Utamakan nama dari clinicStore agar konsisten di seluruh aplikasi
if (typeof clinicStore.getClinicByKode === 'function') {
const clinic = clinicStore.getClinicByKode(kode);
if (clinic) {
return clinic.name;
}
}
// Fallback ke data lokal master jika belum terdaftar di clinicStore
const klinik = klinikData.value.find((k) => k.kode === kode);
return klinik ? klinik.nama : kode;
};