feat: enhance encounter entry forms with mode handling and default date setup

This commit is contained in:
riefive
2025-11-27 11:46:06 +07:00
parent c4ab408a09
commit b38487e41f
10 changed files with 57 additions and 50 deletions
+38 -30
View File
@@ -27,6 +27,7 @@ const props = defineProps<{
isReadonly?: boolean
isSepValid?: boolean
isCheckingSep?: boolean
mode?: string
doctor?: any[]
subSpecialist?: any[]
specialists?: TreeItem[]
@@ -63,11 +64,10 @@ const patientId = ref('')
const isLoading = props.isLoading !== undefined ? props.isLoading : false
const isReadonly = props.isReadonly !== undefined ? props.isReadonly : false
const mode = props.mode !== undefined ? props.mode : 'add'
// SEP validation state from props
const isSepValid = computed(() => props.isSepValid || false)
const isCheckingSep = computed(() => props.isCheckingSep || false)
const doctorOpts = computed(() => {
// Add default option
const defaultOption = [{ label: 'Pilih', value: '' }]
@@ -75,9 +75,17 @@ const doctorOpts = computed(() => {
const doctors = props.doctor || []
return [...defaultOption, ...doctors]
})
const isJKNPayment = computed(() => paymentType.value === 'jkn')
if (mode === 'add') {
// Set default sepDate to current date in YYYY-MM-DD format
const today = new Date()
const year = today.getFullYear()
const month = String(today.getMonth() + 1).padStart(2, '0')
const day = String(today.getDate()).padStart(2, '0')
registerDate.value = `${year}-${month}-${day}`
}
async function onFetchChildren(parentId: string): Promise<void> {
console.log('onFetchChildren', parentId)
}
@@ -141,7 +149,7 @@ function onAddSep() {
registerDate: registerDate.value,
cardNumber: cardNumber.value,
paymentType: paymentType.value,
sepType: sepType.value
sepType: sepType.value,
}
emit('event', 'add-sep', formValues)
}
@@ -165,7 +173,7 @@ function submitForm() {
})
console.log('🔵 Form errors:', errors.value)
console.log('🔵 Form meta:', meta.value)
// Trigger form submit using native form submit
// This will trigger validation and onSubmit handler
if (formRef.value) {
@@ -179,7 +187,7 @@ function submitForm() {
preventDefault: () => {},
target: formRef.value || {},
} as SubmitEvent
// Call onSubmit directly
console.log('🔵 Calling onSubmit with mock event')
onSubmit(mockEvent)
@@ -285,6 +293,22 @@ defineExpose({
:colCount="3"
:cellFlex="false"
>
<Cell>
<Label height="compact">
Spesialis / Subspesialis
<span class="text-red-500">*</span>
</Label>
<Field :errMessage="errors.subSpecialistId">
<TreeSelect
id="subSpecialistId"
v-model="subSpecialistId"
v-bind="subSpecialistIdAttrs"
:data="specialists || []"
:on-fetch-children="onFetchChildren"
/>
</Field>
</Cell>
<Cell>
<Label height="compact">
Dokter
@@ -304,29 +328,6 @@ defineExpose({
</Field>
</Cell>
<Cell>
<Label height="compact">
Spesialis / Subspesialis
<span class="text-red-500">*</span>
</Label>
<Field :errMessage="errors.subSpecialistId">
<TreeSelect
id="subSpecialistId"
v-model="subSpecialistId"
v-bind="subSpecialistIdAttrs"
:data="specialists || []"
:on-fetch-children="onFetchChildren"
/>
</Field>
</Cell>
</Block>
<Block
labelSize="thin"
class="!pt-0"
:colCount="3"
:cellFlex="false"
>
<Cell>
<Label height="compact">
Tanggal Daftar
@@ -341,7 +342,14 @@ defineExpose({
/>
</Field>
</Cell>
</Block>
<Block
labelSize="thin"
class="!pt-0"
:colCount="3"
:cellFlex="false"
>
<Cell>
<Label height="compact">
Jenis Pembayaran
@@ -454,7 +462,7 @@ defineExpose({
name="i-lucide-loader-2"
class="h-4 w-4 animate-spin"
/>
<Icon
<Icon
v-else
name="i-lucide-plus"
class="h-4 w-4"
+1 -1
View File
@@ -24,11 +24,11 @@ import { useForm } from 'vee-validate'
import { refDebounced } from '@vueuse/core'
const props = defineProps<{
mode?: string
isLoading?: boolean
isReadonly?: boolean
isService?: boolean
isShowPatient?: boolean;
mode?: string
doctors: any[]
diagnoses: any[]
facilitiesFrom: any[]
+4 -3
View File
@@ -43,7 +43,7 @@ const {
toNavigateSep,
getListPath,
handleInit,
loadEncounterDetail,
getFetchEncounterDetail,
handleSaveEncounter,
getPatientsList,
getPatientCurrent,
@@ -120,7 +120,7 @@ watch(
onMounted(async () => {
await handleInit()
if (props.id > 0) {
await loadEncounterDetail()
await getFetchEncounterDetail()
}
})
</script>
@@ -131,12 +131,13 @@ onMounted(async () => {
name="i-lucide-user"
class="me-2"
/>
<span class="font-semibold">{{ props.formType }}</span>
<span class="font-semibold">{{ props.formType === 'add' ? 'Tambah' : 'Ubah' }}</span>
Kunjungan
</div>
<AppEncounterEntryForm
ref="formRef"
:mode="props.formType"
:is-loading="isLoadingDetail"
:is-sep-valid="isSepValid"
:is-checking-sep="isCheckingSep"
+7 -9
View File
@@ -229,7 +229,7 @@ export function useEncounterEntry(props: {
diagRujukan: response.diagnosa || '',
tipeRujukan: response.tujuanKunj?.kode ?? '0',
poliRujukan: response.poli || '',
user: '',
user: userStore.user?.user_name || '',
}
}
isSepValid.value = result.body?.metaData?.code === '200'
@@ -307,7 +307,7 @@ export function useEncounterEntry(props: {
}
}
async function loadEncounterDetail() {
async function getFetchEncounterDetail() {
if (!isEditMode.value || props.id <= 0) {
return
}
@@ -436,7 +436,7 @@ export function useEncounterEntry(props: {
try {
isSaving.value = true
const isAdmin = false
const employeeId = userStore.user?.employee_id || userStore.user?.employee?.id || 0
const formatDate = (dateString: string): string => {
@@ -501,19 +501,17 @@ export function useEncounterEntry(props: {
if (paymentMethodCode === 'insurance') {
payload.insuranceCompany_id = formValues.insuranceCompany_id ?? null
if (memberNumber) payload.member_number = memberNumber
if (refNumber) payload.ref_number = refNumber
// if (refNumber) payload.ref_number = refNumber
if (formValues.refTypeCode) payload.refTypeCode = formValues.refTypeCode
if (formValues.vclaimReference) payload.vclaimReference = formValues.vclaimReference
} else {
if (paymentMethodCode === 'membership' && memberNumber) {
payload.member_number = memberNumber
}
if (refNumber) {
payload.ref_number = refNumber
}
// if (refNumber) payload.ref_number = refNumber
}
if (props.classCode === 'ambulatory') {
if (isAdmin && props.classCode === 'ambulatory') {
payload.visitMode_code = 'adm'
payload.allocatedVisitCount = 0
}
@@ -575,7 +573,7 @@ export function useEncounterEntry(props: {
selectedPatient,
selectedPatientObject,
paginationMeta,
loadEncounterDetail,
getFetchEncounterDetail,
mapEncounterToForm,
toKebabCase,
toNavigateSep,
@@ -45,7 +45,7 @@ const encounterId = computed(() => {
:id="encounterId"
class-code="emergency"
sub-class-code="emg"
form-type="Edit"
form-type="edit"
/>
</div>
<Error
@@ -40,8 +40,8 @@ const canCreate = hasCreateAccess(roleAccess)
<Content
:id="0"
class-code="emergency"
sub-class-code="reg"
form-type="Tambah"
sub-class-code="emg"
form-type="add"
/>
</div>
<Error
@@ -45,7 +45,7 @@ const encounterId = computed(() => {
:id="encounterId"
class-code="inpatient"
sub-class-code="icu"
form-type="Edit"
form-type="edit"
/>
</div>
<Error
@@ -41,7 +41,7 @@ const canCreate = hasCreateAccess(roleAccess)
:id="0"
class-code="ambulatory"
sub-class-code="reg"
form-type="Tambah"
form-type="add"
/>
</div>
<Error
@@ -45,7 +45,7 @@ const encounterId = computed(() => {
:id="encounterId"
class-code="ambulatory"
sub-class-code="reg"
form-type="Edit"
form-type="edit"
/>
</div>
<Error
@@ -41,7 +41,7 @@ const canCreate = hasCreateAccess(roleAccess)
:id="0"
class-code="ambulatory"
sub-class-code="reg"
form-type="Tambah"
form-type="add"
/>
</div>
<Error