diff --git a/app/components/app/outpatient/encounter/_common/select-dpjp.vue b/app/components/app/outpatient/encounter/_common/select-dpjp.vue index 393fe988..0b9ef8e3 100644 --- a/app/components/app/outpatient/encounter/_common/select-dpjp.vue +++ b/app/components/app/outpatient/encounter/_common/select-dpjp.vue @@ -32,25 +32,30 @@ const { const doctors = ref>([]) -async function fetchDpjp() { +async function fetchDpjp(specialistId: string, subspecialistId: string) { doctors.value = await getDoctorLabelList({ serviceType: 1, serviceDate: new Date().toISOString().substring(0, 10), specialistCode: 0, includes: 'employee-person', + // "unit-id": parseInt(unitId), + "specialist-id": parseInt(specialistId), + "subspecialist-id": parseInt(subspecialistId), }) } -const selectedDpjpId = inject>("selectedDpjpId")! -function handleDpjpChange(selected: string) { - console.log(`change dphp`) - selectedDpjpId.value = selected ?? null - const dpjp = doctors.value.find(s => s.value === selectedDpjpId.value) - console.log(dpjp) -} +// const selectedUnitId = inject>("selectedUnitId")! +const selectedSpecialistId = inject>("selectedSpecialistId")! +const selectedSubSpecialistId = inject>("selectedSubSpecialistId")! -onMounted(() => { - fetchDpjp() +// function handleDpjpChange(selected: string) { +// selectedDpjpId.value = selected ?? null +// } + +watch([ selectedSpecialistId, selectedSubSpecialistId], () => { + if ( selectedSpecialistId.value && selectedSubSpecialistId.value) { + fetchDpjp( selectedSpecialistId.value, selectedSubSpecialistId.value) + } }) @@ -82,7 +87,7 @@ onMounted(() => { :placeholder="placeholder" search-placeholder="Cari..." empty-message="Data tidak ditemukan" - @update:model-value="handleDpjpChange" + :is-disabled="selectedSubSpecialistId === null" /> diff --git a/app/components/app/outpatient/encounter/_common/select-speciality.vue b/app/components/app/outpatient/encounter/_common/select-specialist.vue similarity index 57% rename from app/components/app/outpatient/encounter/_common/select-speciality.vue rename to app/components/app/outpatient/encounter/_common/select-specialist.vue index 126884d2..9f507014 100644 --- a/app/components/app/outpatient/encounter/_common/select-speciality.vue +++ b/app/components/app/outpatient/encounter/_common/select-specialist.vue @@ -10,8 +10,7 @@ import { getValueLabelList as getSubspecialistLabelList } from '~/services/subsp import * as DE from '~/components/pub/my-ui/doc-entry' const props = defineProps<{ - specialistFieldName?: string - subSpecialistFieldName?: string + fieldName?: string label?: string placeholder?: string errors?: FormErrors @@ -23,8 +22,7 @@ const props = defineProps<{ }>() const { - specialistFieldName = 'job', - subSpecialistFieldName = 'job', + fieldName = 'job', label = 'Pekerjaan', placeholder = 'Pilih pekerjaan', errors, @@ -34,96 +32,62 @@ const { } = props const specialists = ref>([]) -const subspecialists = ref>([]) -async function fetchSpecialists() { +async function fetchSpecialists(unitId: string) { specialists.value = await getSpecialistLabelList({ serviceType: 1, serviceDate: new Date().toISOString().substring(0, 10), specialistCode: 0, - }) - subspecialists.value = await getSubspecialistLabelList({ - serviceType: 1, - serviceDate: new Date().toISOString().substring(0, 10), - specialistCode: 0, + "unit-id": parseInt(unitId), }) } +const selectedUnitId = inject>("selectedUnitId")! const selectedSpecialistId = inject>("selectedSpecialistId")! + function handleSpecialistChange(selected: string) { selectedSpecialistId.value = selected ?? null } -onMounted(() => { - fetchSpecialists() +watch([selectedUnitId], () => { + if (selectedUnitId.value) { + fetchSpecialists(selectedUnitId.value) + } }) + console.log(selectedUnitId.value) diff --git a/app/components/app/outpatient/encounter/preview.vue b/app/components/app/outpatient/encounter/preview.vue index 5ee6e2bd..e10a2b91 100644 --- a/app/components/app/outpatient/encounter/preview.vue +++ b/app/components/app/outpatient/encounter/preview.vue @@ -1,23 +1,11 @@ + + diff --git a/app/pages/(features)/rehab/encounter/[id]/control-letter/[control_letter_id]/index.vue b/app/pages/(features)/rehab/encounter/[id]/control-letter/[control_letter_id]/index.vue new file mode 100644 index 00000000..1864cf2c --- /dev/null +++ b/app/pages/(features)/rehab/encounter/[id]/control-letter/[control_letter_id]/index.vue @@ -0,0 +1,41 @@ + + + diff --git a/app/schemas/control-letter.schema.ts b/app/schemas/control-letter.schema.ts index 7292e306..93e10149 100644 --- a/app/schemas/control-letter.schema.ts +++ b/app/schemas/control-letter.schema.ts @@ -4,17 +4,19 @@ const ControlLetterSchema = z.object({ sepStatus: z.string({ required_error: 'Mohon isi status SEP', }).default('SEP Internal'), - spesialist_id: z.number({ - required_error: 'Mohon isi Spesialis/Sub Spesialis', + unit_id: z.number({ + required_error: 'Mohon isi Unit', }), - subspesialist_id: z.number({ - required_error: 'Mohon isi Spesialis/Sub Spesialis', + specialist_id: z.number({ + required_error: 'Mohon isi Spesialis', + }), + subspecialist_id: z.number({ + required_error: 'Mohon isi Sub Spesialis', }), doctor_id: z.number({ required_error: 'Mohon isi DPJP', }), encounter_id: z.number().optional(), - unit_id: z.number().optional(), date: z.string({ required_error: 'Mohon lengkapi Tanggal Kontrol', })