✨ feat (generate-file): add generate file schema
This commit is contained in:
@@ -4,9 +4,10 @@ import Entry from '~/components/app/general-consent/entry.vue'
|
||||
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su-pr.vue'
|
||||
import ActionDialog from '~/components/pub/my-ui/nav-footer/ba-su.vue'
|
||||
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
|
||||
import { FunctionSoapiSchema } from '~/schemas/soapi.schema'
|
||||
import { GeneralConsentSchema } from '~/schemas/general-consent.schema'
|
||||
import { toast } from '~/components/pub/ui/toast'
|
||||
import { handleActionSave, handleActionEdit } from '~/handlers/soapi-early.handler'
|
||||
import { handleActionSave, handleActionEdit } from '~/handlers/general-consent.handler'
|
||||
import { create } from '~/services/generate-file.service'
|
||||
const { backToList } = useQueryMode('mode')
|
||||
|
||||
const route = useRoute()
|
||||
@@ -19,14 +20,15 @@ const fungsional = ref([])
|
||||
const selectedProcedure = ref<any>(null)
|
||||
const selectedDiagnose = ref<any>(null)
|
||||
const selectedFungsional = ref<any>(null)
|
||||
const schema = FunctionSoapiSchema
|
||||
const schema = GeneralConsentSchema
|
||||
const payload = ref({
|
||||
encounter_id: 0,
|
||||
value: '',
|
||||
})
|
||||
const model = ref({
|
||||
relatives: [],
|
||||
responsible: '',
|
||||
responsibleName: '',
|
||||
responsiblePhone: '',
|
||||
informant: '',
|
||||
witness1: '',
|
||||
witness2: '',
|
||||
@@ -81,16 +83,32 @@ async function actionHandler(type: string) {
|
||||
}
|
||||
const result = await entryGeneralConsent.value?.validate()
|
||||
if (result?.valid) {
|
||||
console.log('data', result.data)
|
||||
handleActionSave(
|
||||
if (result.data.relatives.length > 0) {
|
||||
result.data.relatives = result.data.relatives.map((item: any) => {
|
||||
return item.name
|
||||
})
|
||||
}
|
||||
|
||||
console.log('data', result)
|
||||
const resp = await handleActionSave(
|
||||
{
|
||||
...payload.value,
|
||||
value: JSON.stringify(result.data),
|
||||
encounter_id: +route.params.id,
|
||||
},
|
||||
{},
|
||||
() => {},
|
||||
() => {},
|
||||
toast,
|
||||
)
|
||||
const data = resp.body?.data
|
||||
if (data) {
|
||||
const resp2 = await create({
|
||||
entityType_code: 'encounter',
|
||||
ref_id: +data?.id,
|
||||
type_code: 'general-consent',
|
||||
})
|
||||
console.log('resp2', resp2.body?.data)
|
||||
}
|
||||
} else {
|
||||
console.log('Ada error di form', result)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Handlers
|
||||
import { genCrudHandler } from '~/handlers/_handler'
|
||||
|
||||
// Services
|
||||
import { create, update, remove } from '~/services/general-consent.service'
|
||||
|
||||
export const {
|
||||
recId,
|
||||
recAction,
|
||||
recItem,
|
||||
isReadonly,
|
||||
isProcessing,
|
||||
isFormEntryDialogOpen,
|
||||
isRecordConfirmationOpen,
|
||||
onResetState,
|
||||
handleActionSave,
|
||||
handleActionEdit,
|
||||
handleActionRemove,
|
||||
handleCancelForm,
|
||||
} = genCrudHandler({
|
||||
create,
|
||||
update,
|
||||
remove,
|
||||
})
|
||||
@@ -6,7 +6,8 @@ export interface GeneralConsent {
|
||||
|
||||
export interface ValueCreateDto {
|
||||
relatives: string[]
|
||||
responsible: string
|
||||
responsibleName: string
|
||||
responsiblePhone: string
|
||||
informant: string
|
||||
witness1: string
|
||||
witness2: string
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface GenerateFile {
|
||||
entityType_code: string
|
||||
ref_id: number
|
||||
type_code: string
|
||||
}
|
||||
@@ -2,8 +2,9 @@ import { z } from 'zod'
|
||||
import type { CreateDto } from '~/models/general-consent'
|
||||
|
||||
const GeneralConsentSchema = z.object({
|
||||
relatives: z.string().optional(),
|
||||
responsible_doctor: z.string().optional(),
|
||||
relatives: z.array(z.object({ name: z.string(), phone: z.string() })),
|
||||
responsibleName: z.string().optional(),
|
||||
responsiblePhone: z.string().optional(),
|
||||
informant: z.string().optional(),
|
||||
witness1: z.string().optional(),
|
||||
witness2: z.string().optional(),
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import * as base from './_crud-base'
|
||||
|
||||
const path = '/api/v1/generate-file'
|
||||
|
||||
export function create(data: any) {
|
||||
return base.create(path, data)
|
||||
}
|
||||
|
||||
export function getList(params: any = null) {
|
||||
return base.getList(path, params)
|
||||
}
|
||||
|
||||
export function getDetail(id: number | string) {
|
||||
return base.getDetail(path, id)
|
||||
}
|
||||
Reference in New Issue
Block a user