From f4dadd67f872a76c8f6c0a3729b91b7c9d7dca4d Mon Sep 17 00:00:00 2001 From: Khafid Prayoga Date: Fri, 17 Oct 2025 16:23:51 +0700 Subject: [PATCH] feat(medical-action-src): add type code selection with strict typing - Add medicalActionTypeCode constants and type definition - Update MedicalActionSrc interface to use strict type for type_code - Implement select dropdown for type code in entry form - Enable type code validation in schema --- .../app/medical-action-src/entry-form.vue | 25 +++++++++++++++++++ app/lib/constants.ts | 10 ++++++++ app/models/medical-action-src.ts | 3 ++- app/schemas/medical-action-src.schema.ts | 9 +++---- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/app/components/app/medical-action-src/entry-form.vue b/app/components/app/medical-action-src/entry-form.vue index 0a02ea85..f8bf87e4 100644 --- a/app/components/app/medical-action-src/entry-form.vue +++ b/app/components/app/medical-action-src/entry-form.vue @@ -5,14 +5,17 @@ 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' import Button from '~/components/pub/ui/button/Button.vue' +import Select from '~/components/pub/my-ui/form/select.vue' // Types import type { MedicalActionSrcFormData } from '~/schemas/medical-action-src.schema' +import { medicalActionTypeCode } from '~/lib/constants' // Helpers import type z from 'zod' import { useForm } from 'vee-validate' import { toTypedSchema } from '@vee-validate/zod' +import { mapToComboboxOptList } from '~/lib/utils' interface Props { schema: z.ZodSchema @@ -24,6 +27,8 @@ interface Props { const props = defineProps() const isLoading = props.isLoading !== undefined ? props.isLoading : false const isReadonly = props.isReadonly !== undefined ? props.isReadonly : false +const medicalActionTypeOptions = mapToComboboxOptList(medicalActionTypeCode) + const emit = defineEmits<{ submit: [values: MedicalActionSrcFormData, resetForm: () => void] cancel: [resetForm: () => void] @@ -34,26 +39,31 @@ const { defineField, errors, meta } = useForm({ initialValues: { code: '', name: '', + type_code: '', } as Partial, }) const [code, codeAttrs] = defineField('code') const [name, nameAttrs] = defineField('name') +const [typeCode, typeCodeAttrs] = defineField('type_code') if (props.values) { if (props.values.code !== undefined) code.value = props.values.code if (props.values.name !== undefined) name.value = props.values.name + if (props.values.type_code !== undefined) typeCode.value = props.values.type_code } const resetForm = () => { code.value = '' name.value = '' + typeCode.value = '' } function onSubmitForm() { const formData: MedicalActionSrcFormData = { code: code.value || '', name: name.value || '', + type_code: typeCode.value || '', } emit('submit', formData, resetForm) } @@ -95,6 +105,21 @@ function onCancelForm() { /> + + + +