Files
simrsx-fe/app/components/content/soapi/form-function.vue
2025-10-20 20:26:01 +07:00

124 lines
2.6 KiB
Vue

<script setup lang="ts">
import { z } from 'zod'
import Entry from '~/components/app/soapi/entry.vue'
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su.vue'
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import { FunctionSoapiSchema } from '~/schemas/soapi.schema'
import { toast } from '~/components/pub/ui/toast'
import { handleActionSave, handleActionEdit } from '~/handlers/soapi-early.handler'
const route = useRoute()
const isOpen = ref(false)
const data = ref([])
const schema = FunctionSoapiSchema
const payload = ref({
encounter_id: 0,
time: '',
typeCode: 'function',
value: '',
})
const model = ref({
'prim-compl': '',
'past-disease': '',
'current-disease': '',
gcs: '',
'respiratory-rate': '',
'respiratory-rate-type': '',
pulse: '',
'pulse-type': '',
'right-arm-bp': '',
'left-arm-bp': '',
'axillary-temp': '',
'rektal-temp': '',
skin: '',
head: '',
ear: '',
nose: '',
'oral-cavity': '',
eye: '',
'other-body-part': '',
neck: '',
thyroid: '',
thorax: '',
heart: '',
lung: '',
abdomen: '',
heart2: '',
lien: '',
back: '',
extremity: '',
gender: '',
rectum: '',
'system-syaraf': '',
'nervous-system': '',
'cardio-respiratory': '',
imaging: '',
laboratory: '',
})
const isLoading = reactive<DataTableLoader>({
isTableLoading: false,
})
async function getPatientList() {
isLoading.isTableLoading = true
const resp = await xfetch('/api/v1/patient')
if (resp.success) {
data.value = (resp.body as Record<string, any>).data
}
isLoading.isTableLoading = false
}
onMounted(() => {
getPatientList()
})
function handleOpen(type: string) {
console.log(type)
isOpen.value = true
}
const entryRehabRef = ref()
async function actionHandler(type: string) {
console.log(type)
const result = await entryRehabRef.value?.validate()
if (result?.valid) {
console.log('data', result.data)
handleActionSave(
{
...payload.value,
value: JSON.stringify(result.data),
encounter_id: +route.params.id,
time: new Date().toISOString(),
},
{},
toast,
)
} else {
console.log('Ada error di form', result)
}
}
provide('table_data_loader', isLoading)
</script>
<template>
<Entry
ref="entryRehabRef"
v-model="model"
:schema="schema"
type="function"
@modal="handleOpen"
/>
<div class="my-2 flex justify-end py-2">
<Action @click="actionHandler" />
</div>
<Dialog
v-model:open="isOpen"
title="Pilih Prosedur"
size="xl"
prevent-outside
>
<AppIcdMultiselectPicker :data="data" />
</Dialog>
</template>