feat/consultation-82: wip
This commit is contained in:
No files matched your search
@@ -27,16 +27,19 @@ const emit = defineEmits<{
|
|||||||
cancel: [resetForm: () => void]
|
cancel: [resetForm: () => void]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const today = new Date()
|
||||||
const { defineField, errors, meta } = useForm({
|
const { defineField, errors, meta } = useForm({
|
||||||
validationSchema: toTypedSchema(props.schema),
|
validationSchema: toTypedSchema(props.schema),
|
||||||
initialValues: {
|
initialValues: {
|
||||||
id: 0,
|
id: 0,
|
||||||
encounter_id: 0,
|
encounter_id: 0,
|
||||||
|
date: props.values.date || today.toISOString().slice(0, 10),
|
||||||
problem: '',
|
problem: '',
|
||||||
unit_id: 0,
|
unit_id: 0,
|
||||||
} as Partial<ConsultationFormData>,
|
} as Partial<ConsultationFormData>,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const [date, dateAttrs] = defineField('date')
|
||||||
const [unit_id, unitAttrs] = defineField('unit_id')
|
const [unit_id, unitAttrs] = defineField('unit_id')
|
||||||
const [problem, problemAttrs] = defineField('problem')
|
const [problem, problemAttrs] = defineField('problem')
|
||||||
|
|
||||||
@@ -47,6 +50,7 @@ if (props.values) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
|
date.value = date.value ?? today.toISOString().slice(0, 10)
|
||||||
unit_id.value = 0
|
unit_id.value = 0
|
||||||
problem.value = ''
|
problem.value = ''
|
||||||
}
|
}
|
||||||
@@ -56,6 +60,7 @@ function onSubmitForm(values: any) {
|
|||||||
const formData: ConsultationFormData = {
|
const formData: ConsultationFormData = {
|
||||||
id: 0,
|
id: 0,
|
||||||
encounter_id: 0,
|
encounter_id: 0,
|
||||||
|
date: date.value || '',
|
||||||
problem: problem.value || '',
|
problem: problem.value || '',
|
||||||
unit_id: unit_id.value || 0,
|
unit_id: unit_id.value || 0,
|
||||||
}
|
}
|
||||||
@@ -71,16 +76,15 @@ function onCancelForm() {
|
|||||||
<template>
|
<template>
|
||||||
<form id="form-division" @submit.prevent>
|
<form id="form-division" @submit.prevent>
|
||||||
<DE.Block labelSize="thin" class="!mb-2.5 !pt-0 xl:!mb-3" :colCount="3" :cellFlex="false">
|
<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.Cell>
|
||||||
<DE.Label>Tanggal</DE.Label>
|
<DE.Label>Tanggal</DE.Label>
|
||||||
<DE.Field :errMessage="errors.code">
|
<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.Field>
|
||||||
</DE.Cell>
|
</DE.Cell>
|
||||||
<DE.Cell>
|
<DE.Cell>
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { toast } from '~/components/pub/ui/toast'
|
|||||||
// Types
|
// Types
|
||||||
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
|
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
|
||||||
import { ConsultationSchema, type ConsultationFormData } from '~/schemas/consultation.schema'
|
import { ConsultationSchema, type ConsultationFormData } from '~/schemas/consultation.schema'
|
||||||
import type { Unit } from '~/models/unit'
|
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
import {
|
import {
|
||||||
@@ -32,9 +31,18 @@ import {
|
|||||||
|
|
||||||
// Services
|
// Services
|
||||||
import { getList, getDetail } from '~/services/consultation.service'
|
import { getList, getDetail } from '~/services/consultation.service'
|
||||||
// import { getList as getUnitList } from '~/services/unit.service' // previously uses getList
|
|
||||||
import { getValueLabelList } from '~/services/unit.service'
|
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 }[]>([])
|
let units = ref<{ value: string; label: string }[]>([])
|
||||||
const title = ref('')
|
const title = ref('')
|
||||||
|
|
||||||
@@ -72,7 +80,12 @@ const headerPrep: HeaderPrep = {
|
|||||||
label: 'Tambah',
|
label: 'Tambah',
|
||||||
icon: 'i-lucide-plus',
|
icon: 'i-lucide-plus',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
recItem.value = null
|
recItem.value = {
|
||||||
|
encounter_id: props.encounter.id,
|
||||||
|
date: today.toISOString().slice(0, 10),
|
||||||
|
unit_id: 0,
|
||||||
|
problem: '',
|
||||||
|
}
|
||||||
recId.value = 0
|
recId.value = 0
|
||||||
isFormEntryDialogOpen.value = true
|
isFormEntryDialogOpen.value = true
|
||||||
isReadonly.value = false
|
isReadonly.value = false
|
||||||
@@ -80,6 +93,8 @@ const headerPrep: HeaderPrep = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const today = new Date()
|
||||||
|
|
||||||
provide('rec_id', recId)
|
provide('rec_id', recId)
|
||||||
provide('rec_action', recAction)
|
provide('rec_action', recAction)
|
||||||
provide('rec_item', recItem)
|
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 for row actions when recId or recAction changes
|
||||||
watch([recId, recAction], () => {
|
watch([recId, recAction], () => {
|
||||||
switch (recAction.value) {
|
switch (recAction.value) {
|
||||||
@@ -140,7 +144,7 @@ onMounted(async () => {
|
|||||||
/>
|
/>
|
||||||
<List :data="data" :pagination-meta="paginationMeta" @page-change="handlePageChange" />
|
<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
|
<Entry
|
||||||
:schema="ConsultationSchema"
|
:schema="ConsultationSchema"
|
||||||
:values="recItem"
|
:values="recItem"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import type { Encounter } from '~/models/encounter'
|
|||||||
import Status from '~/components/app/encounter/status.vue'
|
import Status from '~/components/app/encounter/status.vue'
|
||||||
// import AssesmentFunctionList from '~/components/content/assesment-function/list.vue'
|
// import AssesmentFunctionList from '~/components/content/assesment-function/list.vue'
|
||||||
import EarlyMedicalRehabList from '~/components/content/soapi/entry.vue'
|
import EarlyMedicalRehabList from '~/components/content/soapi/entry.vue'
|
||||||
|
import Consultation from '~/components/content/consultation/list.vue'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -65,7 +66,7 @@ const tabs: TabItem[] = [
|
|||||||
{ value: 'mcu-lab-pa', label: 'Order Lab PA' },
|
{ value: 'mcu-lab-pa', label: 'Order Lab PA' },
|
||||||
{ value: 'medical-action', label: 'Order Ruang Tindakan' },
|
{ value: 'medical-action', label: 'Order Ruang Tindakan' },
|
||||||
{ value: 'mcu-result', label: 'Hasil Penunjang' },
|
{ value: 'mcu-result', label: 'Hasil Penunjang' },
|
||||||
{ value: 'consultation', label: 'Konsultasi' },
|
{ value: 'consultation', label: 'Konsultasi', component: Consultation, props: { encounter } },
|
||||||
{ value: 'resume', label: 'Resume' },
|
{ value: 'resume', label: 'Resume' },
|
||||||
{ value: 'control', label: 'Surat Kontrol' },
|
{ value: 'control', label: 'Surat Kontrol' },
|
||||||
{ value: 'screening', label: 'Skrinning MPP' },
|
{ value: 'screening', label: 'Skrinning MPP' },
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export interface Consultation {
|
export interface Consultation {
|
||||||
id: number
|
id: number
|
||||||
encounter_id: number
|
encounter_id: number
|
||||||
|
date?: string
|
||||||
unit_id: number
|
unit_id: number
|
||||||
doctor_id?: number
|
doctor_id?: number
|
||||||
problem: string
|
problem: string
|
||||||
@@ -10,6 +11,7 @@ export interface Consultation {
|
|||||||
|
|
||||||
export interface CreateDto {
|
export interface CreateDto {
|
||||||
encounter_id: number
|
encounter_id: number
|
||||||
|
date: string
|
||||||
problem: string
|
problem: string
|
||||||
unit_id: number
|
unit_id: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import { z } from 'zod'
|
|||||||
import type { Consultation } from '~/models/consultation'
|
import type { Consultation } from '~/models/consultation'
|
||||||
|
|
||||||
const ConsultationSchema = z.object({
|
const ConsultationSchema = z.object({
|
||||||
|
date: z.string({ required_error: 'Tanggal harus diisi' }),
|
||||||
unit_id: z.number({ required_error: 'Unit 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)
|
type ConsultationFormData = z.infer<typeof ConsultationSchema> & (Consultation)
|
||||||
|
|||||||
Reference in New Issue
Block a user