diff --git a/app/components/app/employee/entry-form.vue b/app/components/app/employee/entry-form.vue index 8ccf0916..006f8eff 100644 --- a/app/components/app/employee/entry-form.vue +++ b/app/components/app/employee/entry-form.vue @@ -27,19 +27,31 @@ const data = computed({ - - - diff --git a/app/components/app/soapi/early-entry.vue b/app/components/app/soapi/early-entry.vue index c5697a7a..146a25d4 100644 --- a/app/components/app/soapi/early-entry.vue +++ b/app/components/app/soapi/early-entry.vue @@ -4,29 +4,72 @@ import Cell from '~/components/pub/my-ui/doc-entry/cell.vue' import Field from '~/components/pub/my-ui/doc-entry/field.vue' import Label from '~/components/pub/my-ui/doc-entry/label.vue' +// Helpers +import type z from 'zod' +import { toTypedSchema } from '@vee-validate/zod' +import { useForm } from 'vee-validate' +import { genBase } from '~/models/_base' + const props = defineProps<{ + modelValue: any + schema: z.ZodSchema excludeFields?: string[] + isReadonly?: boolean }>() -const emits = defineEmits(['click']) +const emit = defineEmits<{ + (e: 'update:modelValue', val: any): void + (e: 'submit', val: any): void +}>() -const subject = ref({ - 'prim-compl': '', - 'sec-compl': '', - 'cur-disea-hist': '', - 'pas-disea-hist': '', - 'fam-disea-hist': '', - 'alg-hist': '', - 'alg-react': '', - 'med-hist': '', - 'blood-type': '', +// Setup form +const { + validate: _validate, + defineField, + handleSubmit, + errors, + values, +} = useForm({ + validationSchema: toTypedSchema(props.schema), + initialValues: props.modelValue, }) +watch(values, (val) => emit('update:modelValue', val), { deep: true }) + +const [primaryComplaint, primaryComplaintAttrs] = defineField('prim-compl') +const [curDiseaseHistory, curDiseaseHistoryAttrs] = defineField('cur-disea-hist') +const [systolic, systolicAttrs] = defineField('syst-bp') +const [diastolic, diastolicAttrs] = defineField('diast-bp') +const [pulse, pulseAttrs] = defineField('pulse') +const [respiratoryRate, respiratoryRateAttrs] = defineField('resp-rate') +const [temperature, temperatureAttrs] = defineField('temp') +const [weight, weightAttrs] = defineField('weight') +const [height, heightAttrs] = defineField('height') +const [bloodGroup, bloodGroupAttrs] = defineField('reflect-fisio') +const [physicalExamination, physicalExaminationAttrs] = defineField('reflect-pato') +const [diagnosisMedical, diagnosisMedicalAttrs] = defineField('autonom-neuron') +const [medicalPlan, medicalPlanAttrs] = defineField('medical-act') +const [therapy, therapyAttrs] = defineField('therapy') + +const validate = async () => { + const result = await _validate() + console.log('Component validate() result:', result) + + return { + valid: true, + data: result.values, + errors: result.errors, + } +} + +defineExpose({ validate }) + const isExcluded = (key: string) => props.excludeFields?.includes(key)