From 41cd9d2715849bef0c211d41691f0d321c0d221e Mon Sep 17 00:00:00 2001 From: Yusron alamsyah Date: Mon, 27 Apr 2026 13:43:12 +0700 Subject: [PATCH] fix : add filter dokter,kategori antrean --- components/pendaftaran/BiodataPasienV2.vue | 108 +++++++++++++++++--- components/pendaftaran/CardAntrianList.vue | 6 ++ components/pendaftaran/FilterSortMenu.vue | 37 ++++++- pages/antrean/all.vue | 109 +++++++++++++++++++-- pages/antrean/kategori/[id].vue | 52 +++++++++- pages/antrean/spesialis/[kode].vue | 87 +++++++++++++++- pages/antrean/subspesialis/[kode].vue | 88 ++++++++++++++++- pages/dashboard.vue | 67 +++++++++---- services/antrean.ts | 6 +- 9 files changed, 505 insertions(+), 55 deletions(-) diff --git a/components/pendaftaran/BiodataPasienV2.vue b/components/pendaftaran/BiodataPasienV2.vue index 56b26ad..2056d7c 100644 --- a/components/pendaftaran/BiodataPasienV2.vue +++ b/components/pendaftaran/BiodataPasienV2.vue @@ -4,6 +4,8 @@ import type { Props } from '~/types/common'; import type { PatientData } from '~/types/pendaftaran'; import { Icon } from '@iconify/vue'; import { formatDate } from '~/utils/helpers'; +import { getAntrianOperasi } from '~/services/antrean'; +import { STATUS } from '~/types/antrean'; const props = withDefaults(defineProps(), { readonly: false @@ -21,15 +23,19 @@ const formData = defineModel<{ }>({ required: true }); const rules = { - required: (value: string) => !!value || 'Field ini wajib diisi' + required: (value: any) => !!value || 'Field ini wajib diisi' }; // Autocomplete state const patientItems = ref([]); const loadingPatients = ref(false); -const searchTimeout = ref(null); +const searchTimeout = ref | null>(null); const selectedPatient = ref(null); +// History antrean belum selesai +const loadingHistoryAntrean = ref(false); +const pendingAntreanOperasi = ref([]); + // Search patients by RM number or name const searchPatients = async (search: string) => { if (!search || search.length < 3) { @@ -60,8 +66,9 @@ const searchPatients = async (search: string) => { // Handle search input with debounce const handleSearchInput = (value: string) => { - if (value === formData.value.noRekamMedis) { - patientItems.value = selectedPatient.value ? [selectedPatient.value] : []; + // Avoid re-triggering search when the input reflects the selected value + if (selectedPatient.value && (value === selectedPatient.value.nomr || value === selectedPatient.value.select)) { + patientItems.value = [selectedPatient.value]; return; } if (searchTimeout.value) { @@ -84,9 +91,54 @@ const handlePatientSelect = (patient: PatientData | null) => { formData.value.tanggalLahir = patient.tgllahir; formData.value.umur = patient.dataumur.label; formData.value.alamat = patient.alamat; + + fetchHistoryAntrean(patient.nomr); + return; + } + + selectedPatient.value = null; + pendingAntreanOperasi.value = []; + formData.value.noRekamMedis = ''; + formData.value.noKtp = ''; + formData.value.namaPasien = ''; + formData.value.jenisKelamin = ''; + formData.value.tanggalLahir = ''; + formData.value.umur = ''; + formData.value.alamat = ''; +}; + +const fetchHistoryAntrean = async (rm: string) => { + if (!rm) return; + + loadingHistoryAntrean.value = true; + pendingAntreanOperasi.value = []; + + try { + const response = await getAntrianOperasi({ + type: 'all', + limit: 50, + offset: 0, + search: rm, + status : STATUS.BELUM + }); + + if (response?.success && Array.isArray(response.data)) { + pendingAntreanOperasi.value = response.data; + } + } catch (error) { + console.error('Error fetching history antrean:', error); + pendingAntreanOperasi.value = []; + } finally { + loadingHistoryAntrean.value = false; } }; +const pendingAntreanDetailUrl = computed(() => { + const rm = selectedPatient.value?.nomr || formData.value.noRekamMedis; + if (!rm) return '/antrean/all'; + return `/antrean/all?search=${encodeURIComponent(rm)}`; +}); + // Fetch patient by RM number (for edit mode) const fetchPatientByRm = async (rm: string) => { if (!rm) return; @@ -231,15 +283,27 @@ defineExpose({ No Rekam Medis * - +