fix(sep): fixing pagination and schema

This commit is contained in:
riefive
2025-10-15 16:01:19 +07:00
parent a4ea6665af
commit 9a0a9f68bf
3 changed files with 23 additions and 9 deletions
@@ -24,6 +24,7 @@ import type { PaginationMeta } from '~/components/pub/my-ui/pagination/paginatio
const props = defineProps<{
open: boolean
patients: Array<{
id: string
identity: string
number: string
bpjs: string
@@ -54,7 +55,7 @@ function saveSelection() {
}
function handlePageChange(page: number) {
emit('fetch', { page })
emit('fetch', { 'page-number': page })
}
watch(debouncedSearch, (newValue) => {
@@ -108,8 +109,8 @@ watch(debouncedSearch, (newValue) => {
@update:model-value="emit('update:selected', $event)"
>
<RadioGroupItem
:id="p.identity"
:value="p.identity"
:id="p.id"
:value="p.id"
/>
</RadioGroup>
</td>
+18 -5
View File
@@ -1,11 +1,12 @@
<script setup lang="ts">
import { id } from "date-fns/locale"
import { ref } from 'vue'
// Types
import type { PaginationMeta } from '~/components/pub/my-ui/pagination/pagination.type'
// Services
import { getPatients } from '~/services/patient.service'
import { getPatientDetail, getPatients } from '~/services/patient.service'
const openPatient = ref(false)
const openLetter = ref(false)
@@ -14,7 +15,7 @@ const selectedPatient = ref('')
const selectedLetter = ref('SK22334442')
// patients used by AppSepTableSearchPatient (will be filled from API)
const patients = ref<Array<{ identity: string; number: string; bpjs: string; name: string }>>([
const patients = ref<Array<{ id: string; identity: string; number: string; bpjs: string; name: string }>>([
// fallback empty list until fetched
])
const isPatientsLoading = ref(false)
@@ -33,7 +34,7 @@ function mapPatientToRow(patient: any) {
const number = patient?.number || patient?.medicalRecordNo || '-'
const bpjs = patient?.person?.refNumber || '-'
const name = patient.name || patient?.person?.name || '-'
return { identity, number, bpjs, name }
return { id: patient.id ? String(patient.id) : '-', identity, number, bpjs, name }
}
function mapPaginationMetaToRow(meta: any) {
@@ -53,7 +54,7 @@ function mapPaginationMetaToRow(meta: any) {
}
}
async function fetchPatients(params: any = { 'page-size': 100 }) {
async function fetchPatients(params: any = { 'page-size': 10 }) {
try {
isPatientsLoading.value = true
patients.value = []
@@ -117,6 +118,18 @@ const histories = [
function handleSavePatient() {
console.log('Pasien dipilih:', selectedPatient.value)
const getPatient = async () => {
try {
const result = await getPatientDetail(Number(selectedPatient.value))
if (result && result.success && result.body && result.body.data) {
const patient = result.body.data
console.log('Patient:', patient)
}
} catch (err) {
console.error('Failed to fetch patient:', err)
}
}
getPatient()
}
function handleSaveLetter() {
@@ -160,7 +173,7 @@ function handleEvent(value: string) {
v-model:selected="selectedPatient"
:patients="patients"
:pagination-meta="paginationMeta"
@fetch="(value) => fetchPatients(value)"
@fetch="(value) => fetchPatients({ ...value, 'page-size': 10, includes: 'person' })"
@save="handleSavePatient"
/>
<AppSepTableSearchLetter
+1 -1
View File
@@ -3,7 +3,7 @@ import { z } from 'zod'
const IntegrationBpjsSchema = z.object({
tanggalSep: z.string().min(1, 'Tanggal SEP wajib diisi'),
jalur: z.string().min(1, 'Pilih jalur'),
noBpjs: z.string().min(1, 'No. Kartu BPJS wajib diisi'),
noBpjs: z.string({ required_error: 'No. Kartu BPJS wajib diisi' }).min(1, 'No. Kartu BPJS wajib diisi'),
noKtp: z.string().min(1, 'No. KTP wajib diisi'),
noRm: z.string().min(1, 'No. RM wajib diisi'),
namaPasien: z.string().min(1, 'Nama pasien wajib diisi'),