feat/consultation-82: wip

This commit is contained in:
2025-10-16 04:46:06 +07:00
parent c8ec0410e6
commit 72f2e86601
5 changed files with 36 additions and 24 deletions
+11 -7
View File
@@ -27,16 +27,19 @@ const emit = defineEmits<{
cancel: [resetForm: () => void]
}>()
const today = new Date()
const { defineField, errors, meta } = useForm({
validationSchema: toTypedSchema(props.schema),
initialValues: {
id: 0,
encounter_id: 0,
date: props.values.date || today.toISOString().slice(0, 10),
problem: '',
unit_id: 0,
} as Partial<ConsultationFormData>,
})
const [date, dateAttrs] = defineField('date')
const [unit_id, unitAttrs] = defineField('unit_id')
const [problem, problemAttrs] = defineField('problem')
@@ -47,6 +50,7 @@ if (props.values) {
}
const resetForm = () => {
date.value = date.value ?? today.toISOString().slice(0, 10)
unit_id.value = 0
problem.value = ''
}
@@ -56,6 +60,7 @@ function onSubmitForm(values: any) {
const formData: ConsultationFormData = {
id: 0,
encounter_id: 0,
date: date.value || '',
problem: problem.value || '',
unit_id: unit_id.value || 0,
}
@@ -71,16 +76,15 @@ function onCancelForm() {
<template>
<form id="form-division" @submit.prevent>
<DE.Block labelSize="thin" class="!mb-2.5 !pt-0 xl:!mb-3" :colCount="3" :cellFlex="false">
<DE.Cell>
<DE.Label>Dokter Asal</DE.Label>
<DE.Field :errMessage="errors.code">
<Input readonly />
</DE.Field>
</DE.Cell>
<DE.Cell>
<DE.Label>Tanggal</DE.Label>
<DE.Field :errMessage="errors.code">
<Input readonly />
<Input
v-model.number="date"
icon-name="i-lucide-chevron-down"
v-bind="dateAttrs"
readonly
/>
</DE.Field>
</DE.Cell>
<DE.Cell>
+19 -15
View File
@@ -13,7 +13,6 @@ import { toast } from '~/components/pub/ui/toast'
// Types
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
import { ConsultationSchema, type ConsultationFormData } from '~/schemas/consultation.schema'
import type { Unit } from '~/models/unit'
// Handlers
import {
@@ -32,9 +31,18 @@ import {
// Services
import { getList, getDetail } from '~/services/consultation.service'
// import { getList as getUnitList } from '~/services/unit.service' // previously uses getList
import { getValueLabelList } from '~/services/unit.service'
// Models
import type { Encounter } from '~/models/encounter'
// Props
interface Props {
encounter: Encounter
}
const props = defineProps<Props>()
console.log(props.encounter);
let units = ref<{ value: string; label: string }[]>([])
const title = ref('')
@@ -72,7 +80,12 @@ const headerPrep: HeaderPrep = {
label: 'Tambah',
icon: 'i-lucide-plus',
onClick: () => {
recItem.value = null
recItem.value = {
encounter_id: props.encounter.id,
date: today.toISOString().slice(0, 10),
unit_id: 0,
problem: '',
}
recId.value = 0
isFormEntryDialogOpen.value = true
isReadonly.value = false
@@ -80,6 +93,8 @@ const headerPrep: HeaderPrep = {
},
}
const today = new Date()
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
@@ -94,17 +109,6 @@ const getMyDetail = async (id: number | string) => {
}
}
// const getUnits = async () => {
// const result = await getUnitList()
// if (result.success) {
// const currentMedicineGroups = result.body?.data || []
// units.value = currentMedicineGroups.map((item: Unit) => ({
// value: item.code,
// label: item.name,
// }))
// }
// }
// Watch for row actions when recId or recAction changes
watch([recId, recAction], () => {
switch (recAction.value) {
@@ -140,7 +144,7 @@ onMounted(async () => {
/>
<List :data="data" :pagination-meta="paginationMeta" @page-change="handlePageChange" />
<Dialog v-model:open="isFormEntryDialogOpen" :title="!!recItem ? title : 'Tambah Divisi'" size="xl" prevent-outside>
<Dialog v-model:open="isFormEntryDialogOpen" :title="recItem?.id ? 'Edit Konsultasi' : 'Tambah Konsultasi'" size="xl" prevent-outside>
<Entry
:schema="ConsultationSchema"
:values="recItem"
+2 -1
View File
@@ -16,6 +16,7 @@ import type { Encounter } from '~/models/encounter'
import Status from '~/components/app/encounter/status.vue'
// import AssesmentFunctionList from '~/components/content/assesment-function/list.vue'
import EarlyMedicalRehabList from '~/components/content/soapi/entry.vue'
import Consultation from '~/components/content/consultation/list.vue'
const route = useRoute()
const router = useRouter()
@@ -65,7 +66,7 @@ const tabs: TabItem[] = [
{ value: 'mcu-lab-pa', label: 'Order Lab PA' },
{ value: 'medical-action', label: 'Order Ruang Tindakan' },
{ value: 'mcu-result', label: 'Hasil Penunjang' },
{ value: 'consultation', label: 'Konsultasi' },
{ value: 'consultation', label: 'Konsultasi', component: Consultation, props: { encounter } },
{ value: 'resume', label: 'Resume' },
{ value: 'control', label: 'Surat Kontrol' },
{ value: 'screening', label: 'Skrinning MPP' },
+2
View File
@@ -1,6 +1,7 @@
export interface Consultation {
id: number
encounter_id: number
date?: string
unit_id: number
doctor_id?: number
problem: string
@@ -10,6 +11,7 @@ export interface Consultation {
export interface CreateDto {
encounter_id: number
date: string
problem: string
unit_id: number
}
+2 -1
View File
@@ -2,8 +2,9 @@ import { z } from 'zod'
import type { Consultation } from '~/models/consultation'
const ConsultationSchema = z.object({
date: z.string({ required_error: 'Tanggal harus diisi' }),
unit_id: z.number({ required_error: 'Unit harus diisi' }),
problem: z.string({ required_error: 'Uraian harus diisi' }).min(20, 'Kode minimum 20 karakter'),
problem: z.string({ required_error: 'Uraian harus diisi' }).min(20, 'Uraian minimum 20 karakter'),
})
type ConsultationFormData = z.infer<typeof ConsultationSchema> & (Consultation)