From a14c4a5d3c334d3ea7b9875feb5620991511d4f0 Mon Sep 17 00:00:00 2001 From: hasyim_kai Date: Tue, 11 Nov 2025 14:21:58 +0700 Subject: [PATCH] Fix: Refactor Surat Kontrol CRUD {id} to {code} --- .../outpatient/encounter/_common/select-dpjp.vue | 6 +++--- .../encounter/_common/select-specialist.vue | 4 ++-- .../encounter/_common/select-subspecialist.vue | 4 ++-- .../outpatient/encounter/_common/select-unit.vue | 2 +- .../app/outpatient/encounter/entry-form.vue | 8 ++++---- app/components/pub/my-ui/nav-footer/ba-dr-su.vue | 8 -------- app/models/doctor.ts | 13 +++++++------ app/schemas/control-letter.schema.ts | 10 +++++----- app/services/doctor.service.ts | 6 ++++-- app/services/specialist.service.ts | 6 ++++-- app/services/subspecialist.service.ts | 6 ++++-- app/services/unit.service.ts | 6 ++++-- 12 files changed, 40 insertions(+), 39 deletions(-) diff --git a/app/components/app/outpatient/encounter/_common/select-dpjp.vue b/app/components/app/outpatient/encounter/_common/select-dpjp.vue index 0b9ef8e3..2f5a9c6e 100644 --- a/app/components/app/outpatient/encounter/_common/select-dpjp.vue +++ b/app/components/app/outpatient/encounter/_common/select-dpjp.vue @@ -39,9 +39,9 @@ async function fetchDpjp(specialistId: string, subspecialistId: string) { specialistCode: 0, includes: 'employee-person', // "unit-id": parseInt(unitId), - "specialist-id": parseInt(specialistId), - "subspecialist-id": parseInt(subspecialistId), - }) + "specialist-id": String(specialistId), + "subspecialist-id": String(subspecialistId), + }, true) } // const selectedUnitId = inject>("selectedUnitId")! diff --git a/app/components/app/outpatient/encounter/_common/select-specialist.vue b/app/components/app/outpatient/encounter/_common/select-specialist.vue index 9f507014..f4de1373 100644 --- a/app/components/app/outpatient/encounter/_common/select-specialist.vue +++ b/app/components/app/outpatient/encounter/_common/select-specialist.vue @@ -38,8 +38,8 @@ async function fetchSpecialists(unitId: string) { serviceType: 1, serviceDate: new Date().toISOString().substring(0, 10), specialistCode: 0, - "unit-id": parseInt(unitId), - }) + "unit-id": String(unitId), + }, true) } const selectedUnitId = inject>("selectedUnitId")! diff --git a/app/components/app/outpatient/encounter/_common/select-subspecialist.vue b/app/components/app/outpatient/encounter/_common/select-subspecialist.vue index 3636c8e0..e9a597d2 100644 --- a/app/components/app/outpatient/encounter/_common/select-subspecialist.vue +++ b/app/components/app/outpatient/encounter/_common/select-subspecialist.vue @@ -37,8 +37,8 @@ async function fetchSubSpecialists(specialistId: string) { serviceType: 1, serviceDate: new Date().toISOString().substring(0, 10), specialistCode: 0, - "specialist-id": parseInt(specialistId), - }) + "specialist-id": String(specialistId), + }, true) } const selectedSpecialistId = inject>("selectedSpecialistId")! diff --git a/app/components/app/outpatient/encounter/_common/select-unit.vue b/app/components/app/outpatient/encounter/_common/select-unit.vue index 0087aaf1..afe0ca0a 100644 --- a/app/components/app/outpatient/encounter/_common/select-unit.vue +++ b/app/components/app/outpatient/encounter/_common/select-unit.vue @@ -33,7 +33,7 @@ const { const units = ref>([]) async function fetchData() { - units.value = await getUnitLabelList() + units.value = await getUnitLabelList({}, true) } const selectedUnitId = inject>("selectedUnitId")! diff --git a/app/components/app/outpatient/encounter/entry-form.vue b/app/components/app/outpatient/encounter/entry-form.vue index fc20d824..2517e8b1 100644 --- a/app/components/app/outpatient/encounter/entry-form.vue +++ b/app/components/app/outpatient/encounter/entry-form.vue @@ -60,28 +60,28 @@ defineExpose({ () diff --git a/app/models/doctor.ts b/app/models/doctor.ts index 3f517476..1b631907 100644 --- a/app/models/doctor.ts +++ b/app/models/doctor.ts @@ -8,10 +8,11 @@ export interface Doctor extends Base { employee: Employee ihs_number: string sip_number: string - unit_id?: number - specialist_id?: number + code?: string + unit_icode?: number + specialist_icode?: number specialist?: Specialist - subspecialist_id?: number + subspecialist_icode?: number subspecialist?: Subspecialist bpjs_code?: string } @@ -21,9 +22,9 @@ export interface CreateDto { employee_id: number ihs_number: string sip_number: string - unit_id?: number - specialist_id?: number - subspecialist_id?: number + unit_code?: number + specialist_code?: number + subspecialist_code?: number bpjs_code: string } diff --git a/app/schemas/control-letter.schema.ts b/app/schemas/control-letter.schema.ts index 93e10149..c82ffaac 100644 --- a/app/schemas/control-letter.schema.ts +++ b/app/schemas/control-letter.schema.ts @@ -4,19 +4,19 @@ const ControlLetterSchema = z.object({ sepStatus: z.string({ required_error: 'Mohon isi status SEP', }).default('SEP Internal'), - unit_id: z.number({ + unit_code: z.string({ required_error: 'Mohon isi Unit', }), - specialist_id: z.number({ + specialist_code: z.string({ required_error: 'Mohon isi Spesialis', }), - subspecialist_id: z.number({ + subspecialist_code: z.string({ required_error: 'Mohon isi Sub Spesialis', }), - doctor_id: z.number({ + doctor_code: z.string({ required_error: 'Mohon isi DPJP', }), - encounter_id: z.number().optional(), + encounter_code: z.string().optional(), date: z.string({ required_error: 'Mohon lengkapi Tanggal Kontrol', }) diff --git a/app/services/doctor.service.ts b/app/services/doctor.service.ts index d3d830cb..3bf2c6d0 100644 --- a/app/services/doctor.service.ts +++ b/app/services/doctor.service.ts @@ -27,13 +27,15 @@ export function remove(id: number | string) { return base.remove(path, id, name) } -export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> { +export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> { let data: { value: string; label: string }[] = [] const result = await getList(params) if (result.success) { const resultData = result.body?.data || [] data = resultData.map((item: Doctor) => ({ - value: item.id ? Number(item.id) : item.id, + value: useCodeAsValue ? item.code + : item.id ? Number(item.id) + : item.id, label: item.employee.person.name, parent: item.unit_id ? Number(item.unit_id) : null, })) diff --git a/app/services/specialist.service.ts b/app/services/specialist.service.ts index c2c34e3f..65687c24 100644 --- a/app/services/specialist.service.ts +++ b/app/services/specialist.service.ts @@ -27,13 +27,15 @@ export function remove(id: number | string) { return base.remove(path, id, name) } -export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> { +export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> { let data: { value: string; label: string }[] = [] const result = await getList(params) if (result.success) { const resultData = result.body?.data || [] data = resultData.map((item: Specialist) => ({ - value: item.id ? Number(item.id) : item.code, + value: useCodeAsValue ? item.code + : item.id ? Number(item.id) + : item.id, label: item.name, parent: item.unit_id ? Number(item.unit_id) : null, })) diff --git a/app/services/subspecialist.service.ts b/app/services/subspecialist.service.ts index 94e70a09..3b61d8ec 100644 --- a/app/services/subspecialist.service.ts +++ b/app/services/subspecialist.service.ts @@ -27,13 +27,15 @@ export function remove(id: number | string) { return base.remove(path, id, name) } -export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> { +export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> { let data: { value: string; label: string }[] = [] const result = await getList(params) if (result.success) { const resultData = result.body?.data || [] data = resultData.map((item: Subspecialist) => ({ - value: item.id ? Number(item.id) : item.code, + value: useCodeAsValue ? item.code + : item.id ? Number(item.id) + : item.id, label: item.name, parent: item.specialist_id ? Number(item.specialist_id) : null, })) diff --git a/app/services/unit.service.ts b/app/services/unit.service.ts index 438625f1..0d934c95 100644 --- a/app/services/unit.service.ts +++ b/app/services/unit.service.ts @@ -27,13 +27,15 @@ export function remove(id: number | string) { return base.remove(path, id, name) } -export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> { +export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> { let data: { value: string; label: string }[] = [] const result = await getList(params) if (result.success) { const resultData = result.body?.data || [] data = resultData.map((item: Unit) => ({ - value: item.id, + value: useCodeAsValue ? item.code + : item.id ? Number(item.id) + : item.id, label: item.name, })) }