refactor(person-relative): update schema and form components for family data
- Change value format in radio-parents-input from '1'/'0' to 'yes'/'no' - Remove default labels from select-education and select-job components - Update schema to make fields optional and add new fields - Modify family-parents-form to use new schema and improve UI - Update patient form and models to align with schema changes
This commit is contained in:
@@ -18,7 +18,7 @@ import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su.vue'
|
||||
import AppPatientEntryForm from '~/components/app/patient/entry-form.vue'
|
||||
import AppPersonAddressEntryForm from '~/components/app/person-address/entry-form.vue'
|
||||
import AppPersonAddressEntryFormRelative from '~/components/app/person-address/entry-form-relative.vue'
|
||||
import AppPersonFamilyParentsForm from '~/components/app/person/family-parents-form.vue'
|
||||
import AppPersonFamilyParentsForm from '~/components/app/person/family-parents-form-bak.vue'
|
||||
import AppPersonContactEntryForm from '~/components/app/person-contact/entry-form.vue'
|
||||
import AppPersonRelativeEntryForm from '~/components/app/person-relative/entry-form.vue'
|
||||
|
||||
|
||||
@@ -25,16 +25,7 @@ import { id as localeID } from 'date-fns/locale'
|
||||
// services
|
||||
import { getPatientDetail, uploadAttachment } from '~/services/patient.service'
|
||||
|
||||
import {
|
||||
isReadonly,
|
||||
isProcessing,
|
||||
isFormEntryDialogOpen,
|
||||
isRecordConfirmationOpen,
|
||||
onResetState,
|
||||
handleActionSave,
|
||||
handleActionEdit,
|
||||
handleCancelForm,
|
||||
} from '~/handlers/patient.handler'
|
||||
import { isReadonly, isProcessing, handleActionSave, handleActionEdit } from '~/handlers/patient.handler'
|
||||
|
||||
import { toast } from '~/components/pub/ui/toast'
|
||||
|
||||
@@ -180,19 +171,19 @@ const familyFormInitialValues = computed(() => {
|
||||
|
||||
if (parents.length === 0) {
|
||||
return {
|
||||
shareFamilyData: '0',
|
||||
_shareFamilyData: 'no' as const,
|
||||
families: [],
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
shareFamilyData: '1',
|
||||
_shareFamilyData: 'yes' as const,
|
||||
families: parents.map((parent: PersonRelative) => ({
|
||||
id: parent.id || 0,
|
||||
relation: parent.relationship_code || '',
|
||||
name: parent.name || '',
|
||||
education: parent.education_code || '',
|
||||
occupation: parent.occupation_name || parent.occupation_code || '',
|
||||
occupation_code: parent.occupation_code || '',
|
||||
education_code: parent.education_code || '',
|
||||
})),
|
||||
}
|
||||
})
|
||||
@@ -253,6 +244,7 @@ async function composeFormData(): Promise<PatientEntity> {
|
||||
const results = [patient, address, addressRelative, families, contacts, emergencyContact]
|
||||
const allValid = results.every((r) => r?.valid)
|
||||
|
||||
console.log(results)
|
||||
// exit, if form errors happend during validation
|
||||
// for example: dropdown not selected
|
||||
if (!allValid) return Promise.reject('Form validation failed')
|
||||
|
||||
@@ -11,7 +11,7 @@ import { PersonAddressRelativeSchema } from '~/schemas/person-address-relative.s
|
||||
import { PersonAddressSchema } from '~/schemas/person-address.schema'
|
||||
import { PersonContactListSchema } from '~/schemas/person-contact.schema'
|
||||
import { PersonFamiliesSchema } from '~/schemas/person-family.schema'
|
||||
import { ResponsiblePersonSchema } from '~/schemas/person-relative.schema'
|
||||
import { ResponsiblePersonRelativeSchema } from '~/schemas/person-relative.schema'
|
||||
import { uploadAttachment } from '~/services/patient.service'
|
||||
import { getDetail, update } from '~/services/surgery-report.service'
|
||||
import type { SurgeryReport } from '~/models/surgery-report'
|
||||
@@ -28,17 +28,18 @@ import { handleActionEdit } from '~/handlers/surgery-report.handler'
|
||||
import type { HeaderPrep, RefSearchNav } from '~/components/pub/my-ui/data/types'
|
||||
|
||||
// #region Props & Emits
|
||||
const props = withDefaults(defineProps<{
|
||||
encounter_id: number
|
||||
callbackUrl?: string
|
||||
record_id: number
|
||||
}>(), {
|
||||
|
||||
})
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
encounter_id: number
|
||||
callbackUrl?: string
|
||||
record_id: number
|
||||
}>(),
|
||||
{},
|
||||
)
|
||||
|
||||
// form related state
|
||||
const { data, isLoading, paginationMeta, searchInput, handlePageChange, handleSearch, fetchData } = usePaginatedList({
|
||||
fetchFn: (params) => getList({ ...params, includes: 'specialist,subspecialist,doctor-employee-person', }),
|
||||
fetchFn: (params) => getList({ ...params, includes: 'specialist,subspecialist,doctor-employee-person' }),
|
||||
entityName: 'surgery-report',
|
||||
})
|
||||
// #endregion
|
||||
@@ -56,7 +57,7 @@ const selectedOperativeAction = ref<any>(null)
|
||||
onMounted(async () => {
|
||||
const result = await getDetail(props.record_id)
|
||||
if (result.success) {
|
||||
const responseData = {...result.body.data, date: formatDateYyyyMmDd(result.body.data.date)}
|
||||
const responseData = { ...result.body.data, date: formatDateYyyyMmDd(result.body.data.date) }
|
||||
surgeryReport.value = responseData
|
||||
inputForm.value?.setValues(responseData)
|
||||
}
|
||||
@@ -72,17 +73,15 @@ async function handleConfirmAdd() {
|
||||
const response = await handleActionEdit(
|
||||
props.record_id,
|
||||
await composeFormData(),
|
||||
() => { },
|
||||
() => { },
|
||||
() => {},
|
||||
() => {},
|
||||
toast,
|
||||
)
|
||||
goBack()
|
||||
}
|
||||
|
||||
async function composeFormData(): Promise<SurgeryReport> {
|
||||
const [input,] = await Promise.all([
|
||||
inputForm.value?.validate(),
|
||||
])
|
||||
const [input] = await Promise.all([inputForm.value?.validate()])
|
||||
|
||||
const results = [input]
|
||||
const allValid = results.every((r) => r?.valid)
|
||||
@@ -129,9 +128,12 @@ function handleCancelAdd() {
|
||||
:schema="SurgeryReportSchema"
|
||||
:operative-action-list="[]"
|
||||
/>
|
||||
|
||||
|
||||
<div class="my-2 flex justify-end py-2">
|
||||
<Action :enable-draft="false" @click="handleActionClick" />
|
||||
<Action
|
||||
:enable-draft="false"
|
||||
@click="handleActionClick"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Confirmation
|
||||
|
||||
Reference in New Issue
Block a user