diff --git a/app/components/app/encounter/entry-form.vue b/app/components/app/encounter/entry-form.vue index 22acbbb8..66d2e4e3 100644 --- a/app/components/app/encounter/entry-form.vue +++ b/app/components/app/encounter/entry-form.vue @@ -1,43 +1,57 @@ + + + + + + + Data Pasien + + sudah pernah terdaftar sebagai pasien? + + + Cari Pasien + + belum pernah terdaftar sebagai pasien? + + + Tambah Pasien Baru + + + + + + + Nama Pasien + + + + + + + NIK + + + + + + + No. RM + + + + + + + + + + Data Kunjungan + + + + + Dokter + * + + + + + + + + + Spesialis / Subspesialis + * + + + + + + + + + + + Tanggal Daftar + * + + + + + + + + + Jenis Pembayaran + * + + + + + + + + + + + + + Kelompok Peserta + * + + + + + + + + + No. Kartu BPJS + * + + + + + + + + + Jenis SEP + * + + + + + + + + + + + No. SEP + * + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/components/content/encounter/entry.vue b/app/components/content/encounter/entry.vue index 228d165e..203d781a 100644 --- a/app/components/content/encounter/entry.vue +++ b/app/components/content/encounter/entry.vue @@ -8,8 +8,11 @@ import AppViewPatient from '~/components/app/patient/view-patient.vue' import { refDebounced } from '@vueuse/core' // Handlers +import { getDetail as getDoctorDetail } from '~/services/doctor.service' import { useEncounterEntry } from '~/handlers/encounter-entry.handler' +import { genDoctor, type Doctor } from '~/models/doctor' +// Props const props = defineProps<{ id: number classCode?: 'ambulatory' | 'emergency' | 'inpatient' | 'outpatient' @@ -54,7 +57,33 @@ const { } = useEncounterEntry(props) const debouncedSepNumber = refDebounced(sepNumber, 500) +const selectedDoctor = ref(genDoctor()) +provide('rec_select_id', recSelectId) +provide('table_data_loader', isLoading) + +watch(debouncedSepNumber, async (newValue) => { + await getValidateSepNumber(newValue) +}) + +watch( + () => formObjects.value?.paymentType, + (newValue) => { + isSepValid.value = false + if (newValue !== 'jkn') { + sepNumber.value = '' + } + }, +) + +onMounted(async () => { + await handleInit() + if (props.id > 0) { + await loadEncounterDetail() + } +}) + +///// Functions function handleSavePatient() { selectedPatientObject.value = null setTimeout(() => { @@ -100,29 +129,13 @@ async function handleEvent(menu: string, value?: any) { } } -provide('rec_select_id', recSelectId) -provide('table_data_loader', isLoading) - -watch(debouncedSepNumber, async (newValue) => { - await getValidateSepNumber(newValue) -}) - -watch( - () => formObjects.value?.paymentType, - (newValue) => { - isSepValid.value = false - if (newValue !== 'jkn') { - sepNumber.value = '' - } - }, -) - -onMounted(async () => { - await handleInit() - if (props.id > 0) { - await loadEncounterDetail() +async function getDoctorInfo(value: string) { + const resp = await getDoctorDetail(value, { includes: 'unit,specialist,subspecialist'}) + if (resp.success) { + selectedDoctor.value = resp.body.data + // console.log(selectedDoctor.value) } -}) +} @@ -144,9 +157,11 @@ onMounted(async () => { :seps="sepsList" :participant-groups="participantGroupsList" :specialists="specialistsTree" - :doctor="doctorsList" + :doctorItems="doctorsList" + :selectedDoctor="selectedDoctor" :patient="selectedPatientObject" :objects="formObjects" + @on-select-doctor="getDoctorInfo" @event="handleEvent" @fetch="handleFetch" /> diff --git a/app/handlers/encounter-entry.handler.ts b/app/handlers/encounter-entry.handler.ts index 71594ebf..4d29defb 100644 --- a/app/handlers/encounter-entry.handler.ts +++ b/app/handlers/encounter-entry.handler.ts @@ -70,18 +70,18 @@ export function useEncounterEntry(props: { }) function getListPath(): string { - if (props.classCode === 'ambulatory' && props.subClassCode === 'rehab') { - return '/rehab/encounter' - } - if (props.classCode === 'ambulatory' && props.subClassCode === 'reg') { - return '/outpatient/encounter' - } - if (props.classCode === 'emergency') { - return '/emergency/encounter' - } - if (props.classCode === 'inpatient') { - return '/inpatient/encounter' + if (props.classCode === 'ambulatory') { + return '/ambulatory/encounter' } + // if (props.classCode === 'ambulatory' && props.subClassCode === 'reg') { + // return '/outpatient/encounter' + // } + // if (props.classCode === 'emergency') { + // return '/emergency/encounter' + // } + // if (props.classCode === 'inpatient') { + // return '/inpatient/encounter' + // } return '/encounter' } @@ -257,11 +257,10 @@ export function useEncounterEntry(props: { async function handleFetchDoctors(subSpecialistId: string | null = null) { try { - const filterParams: any = { 'page-size': 100, includes: 'employee-Person' } + const filterParams: any = { 'page-size': 100, includes: 'employee-Person,unit,specialist,subspecialist' } if (!subSpecialistId) { - const doctors = await getDoctorValueLabelList(filterParams, true) - doctorsList.value = doctors + doctorsList.value = await getDoctorValueLabelList(filterParams, true) return } @@ -273,8 +272,7 @@ export function useEncounterEntry(props: { filterParams['specialist-id'] = subSpecialistId } - const doctors = await getDoctorValueLabelList(filterParams, true) - doctorsList.value = doctors + doctorsList.value = await getDoctorValueLabelList(filterParams, true) } catch (error) { console.error('Error fetching doctors:', error) doctorsList.value = [] @@ -497,7 +495,7 @@ export function useEncounterEntry(props: { if (paymentMethodCode) { payload.paymentMethod_code = paymentMethodCode } - + if (paymentMethodCode === 'insurance') { payload.insuranceCompany_id = formValues.insuranceCompany_id ?? null if (memberNumber) payload.member_number = memberNumber diff --git a/app/models/doctor.ts b/app/models/doctor.ts index 1b631907..297f9372 100644 --- a/app/models/doctor.ts +++ b/app/models/doctor.ts @@ -1,5 +1,6 @@ import { type Base, genBase } from "./_base" import { type Employee, genEmployee } from "./employee" +import type { Unit } from "./unit" import type { Specialist } from "./specialist" import type { Subspecialist } from "./subspecialist" @@ -9,10 +10,11 @@ export interface Doctor extends Base { ihs_number: string sip_number: string code?: string - unit_icode?: number - specialist_icode?: number + unit_code?: string + unit?: Unit + specialist_code?: string specialist?: Specialist - subspecialist_icode?: number + subspecialist_code?: string subspecialist?: Subspecialist bpjs_code?: string } diff --git a/app/models/encounter.ts b/app/models/encounter.ts index 85a0012d..95bccff0 100644 --- a/app/models/encounter.ts +++ b/app/models/encounter.ts @@ -3,6 +3,7 @@ import { type Doctor, genDoctor } from "./doctor" import { genEmployee, type Employee } from "./employee" import type { EncounterDocument } from "./encounter-document" import type { InternalReference } from "./internal-reference" +import type { Nurse } from "./nurse" import { type Patient, genPatient } from "./patient" import type { Specialist } from "./specialist" import type { Subspecialist } from "./subspecialist" @@ -14,18 +15,20 @@ export interface Encounter { patient: Patient registeredAt: string class_code: string - unit_id: number + unit_code: string unit: Unit - specialist_id?: number + specialist_code?: string specilist?: Specialist - subspecialist_id?: number + subspecialist_code?: string subspecialist?: Subspecialist visitDate: string adm_employee_id: number adm_employee: Employee - appointment_doctor_id: number + responsible_nurse_code?: string + responsible_nurse?: Nurse + appointment_doctor_code: string appointment_doctor: Doctor - responsible_doctor_id?: number + responsible_doctor_code?: string responsible_doctor?: Doctor refSource_name?: string appointment_id?: number @@ -49,12 +52,12 @@ export function genEncounter(): Encounter { patient: genPatient(), registeredAt: '', class_code: '', - unit_id: 0, + unit_code: 0, unit: genUnit(), visitDate: '', adm_employee_id: 0, adm_employee: genEmployee(), - appointment_doctor_id: 0, + appointment_doctor_code: '', appointment_doctor: genDoctor(), medicalDischargeEducation: '', status_code: '', diff --git a/app/schemas/integration-encounter.schema.ts b/app/schemas/integration-encounter.schema.ts index 32327328..b141f912 100644 --- a/app/schemas/integration-encounter.schema.ts +++ b/app/schemas/integration-encounter.schema.ts @@ -2,10 +2,12 @@ import { z } from 'zod' const ERROR_MESSAGES = { required: { - doctorId: 'Dokter wajib diisi', + doctor_code: 'Dokter wajib diisi', registerDate: 'Tanggal Daftar wajib diisi', - paymentType: 'Jenis Pembayaran wajib diisi', - subSpecialistId: 'Subspesialis wajib diisi', + paymentMethod_code: 'Jenis Pembayaran wajib diisi', + unit_code: 'Spesialis wajib diisi', + // specialist_code: 'Spesialis wajib diisi', + // subSpecialist_code: 'Subspesialis wajib diisi', patientCategory: 'Kelompok Peserta wajib diisi', cardNumber: 'No. Kartu BPJS wajib diisi', sepType: 'Jenis SEP wajib diisi', @@ -21,22 +23,22 @@ const IntegrationEncounterSchema = z patientName: z.string().optional(), nationalIdentity: z.string().optional(), medicalRecordNumber: z.string().optional(), - + // Visit data - doctorId: z - .string({ required_error: ERROR_MESSAGES.required.doctorId }) - .min(1, ERROR_MESSAGES.required.doctorId), - subSpecialistId: z - .string({ required_error: ERROR_MESSAGES.required.subSpecialistId }) - .min(1, ERROR_MESSAGES.required.subSpecialistId) + doctor_code: z + .string({ required_error: ERROR_MESSAGES.required.doctor_code }) + .min(1, ERROR_MESSAGES.required.doctor_code), + unit_code: z + .string({ required_error: ERROR_MESSAGES.required.unit_code }) + .min(1, ERROR_MESSAGES.required.unit_code) .optional(), registerDate: z .string({ required_error: ERROR_MESSAGES.required.registerDate }) .min(1, ERROR_MESSAGES.required.registerDate), - paymentType: z - .string({ required_error: ERROR_MESSAGES.required.paymentType }) - .min(1, ERROR_MESSAGES.required.paymentType), - + paymentMethod_code: z + .string({ required_error: ERROR_MESSAGES.required.paymentMethod_code }) + .min(1, ERROR_MESSAGES.required.paymentMethod_code), + // BPJS related fields patientCategory: z .string() @@ -54,7 +56,7 @@ const IntegrationEncounterSchema = z .string() .min(1, ERROR_MESSAGES.required.sepNumber) .optional(), - + // File uploads sepFile: z .any() @@ -76,7 +78,7 @@ const IntegrationEncounterSchema = z .refine( (data) => { // If payment type is jkn, then patient category is required - if (data.paymentType === 'jkn') { + if (data.paymentMethod_code === 'jkn') { return data.patientCategory && data.patientCategory.trim() !== '' } return true @@ -89,7 +91,7 @@ const IntegrationEncounterSchema = z .refine( (data) => { // If payment type is jkn, then card number is required - if (data.paymentType === 'jkn') { + if (data.paymentMethod_code === 'jkn') { return data.cardNumber && data.cardNumber.trim() !== '' } return true @@ -102,7 +104,7 @@ const IntegrationEncounterSchema = z .refine( (data) => { // If payment type is jkn, then SEP type is required - if (data.paymentType === 'jkn') { + if (data.paymentMethod_code === 'jkn') { return data.sepType && data.sepType.trim() !== '' } return true @@ -115,7 +117,7 @@ const IntegrationEncounterSchema = z .refine( (data) => { // If payment type is jkn and SEP type is selected, then SEP number is required - if (data.paymentType === 'jkn' && data.sepType && data.sepType.trim() !== '') { + if (data.paymentMethod_code === 'jkn' && data.sepType && data.sepType.trim() !== '') { return data.sepNumber && data.sepNumber.trim() !== '' } return true diff --git a/app/services/_crud-base.ts b/app/services/_crud-base.ts index bf3a89c5..c9a0f013 100644 --- a/app/services/_crud-base.ts +++ b/app/services/_crud-base.ts @@ -111,4 +111,4 @@ export async function removeCustom(path: string, data: any, name: string = 'item console.error(`Error deleting ${name}:`, error) throw new Error(`Failed to delete ${name}`) } -} \ No newline at end of file +} diff --git a/app/services/doctor.service.ts b/app/services/doctor.service.ts index e6ae0051..5b855715 100644 --- a/app/services/doctor.service.ts +++ b/app/services/doctor.service.ts @@ -13,8 +13,8 @@ export function getList(params: any = null) { return base.getList(path, params, name) } -export function getDetail(id: number | string) { - return base.getDetail(path, id, name) +export function getDetail(id: number | string, params?: any) { + return base.getDetail(path, id, name, params) } export function update(id: number | string, data: any) { @@ -32,7 +32,7 @@ export async function getValueLabelList(params: any = null, useCodeAsValue = fal const resultData = result.body?.data || [] data = resultData.map((item: Doctor) => ({ value: useCodeAsValue ? item.code - : item.id ? Number(item.id) + : item.id ? Number(item.id) : item.id, label: item.employee?.person?.name || '', }))