feat (summary-medic): implement summary medic entry form

This commit is contained in:
Abizrh
2025-12-03 22:26:32 +07:00
parent 409e8fd1ed
commit 15db237f30
4 changed files with 64 additions and 69 deletions

No files matched your search

+19 -41
View File
@@ -1,13 +1,12 @@
<script setup lang="ts">
import { z } from 'zod'
import Entry from '~/components/app/summary-medic/entry.vue'
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su-pr.vue'
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su.vue'
import ActionDialog from '~/components/pub/my-ui/nav-footer/ba-su.vue'
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import { GeneralConsentSchema } from '~/schemas/general-consent.schema'
import { SummaryMedicSchema } from '~/schemas/soapi.schema'
import { toast } from '~/components/pub/ui/toast'
import { handleActionSave, handleActionEdit } from '~/handlers/general-consent.handler'
import { create } from '~/services/generate-file.service'
import { handleActionSave, handleActionEdit } from '~/handlers/soapi-early.handler'
// Services
import { getDetail } from '~/services/summary-medic.service'
const { backToList } = useQueryCRUDMode('mode')
@@ -23,18 +22,20 @@ const fungsional = ref([])
const selectedProcedure = ref<any>(null)
const selectedDiagnose = ref<any>(null)
const selectedFungsional = ref<any>(null)
const schema = GeneralConsentSchema
const schema = SummaryMedicSchema
const payload = ref({
typeCode: 'amb-resume',
encounter_id: 0,
time: '',
value: '',
})
const model = ref({
relatives: [],
responsibleName: '',
responsiblePhone: '',
informant: '',
witness1: '',
witness2: '',
date: '',
doctor: '',
diagnosis: '',
essay: '',
plan: '',
note: '',
})
const fileUrl = ref('')
@@ -63,9 +64,7 @@ async function getProcedures() {
onMounted(() => {
const mode = route.query.mode
const recordId = route.query['record-id']
if (mode === 'entry' && recordId) {
loadEntryForEdit(+recordId)
}
})
@@ -74,15 +73,6 @@ const loadEntryForEdit = async (id: number) => {
const result = await getDetail(id)
if (result?.success) {
const data = result.body?.data || {}
const value = JSON.parse(data.value || '{}')
model.value.witness1 = value?.witness1 || ''
model.value.witness2 = value?.witness2 || ''
model.value.informant = value?.informant || ''
model.value.responsibleName = value?.responsible || ''
model.value.responsiblePhone = value?.responsiblePhone || ''
model.value.relatives = value?.relatives || []
console.log('model', model.value)
}
}
@@ -103,19 +93,15 @@ async function actionHandler(type: string) {
return
}
if (type === 'print') {
const data = await getDetail(recordId.value)
const detail = data.body?.data
fileUrl.value = detail?.fileUrl
isOpenDiagnose.value = true
return
}
const result = await entryGeneralConsent.value?.validate()
if (result?.valid) {
if (result.data.relatives.length > 0) {
result.data.relatives = result.data.relatives.map((item: any) => {
return item.name
})
}
// 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(
@@ -123,21 +109,13 @@ async function actionHandler(type: string) {
...payload.value,
value: JSON.stringify(result.data),
encounter_id: +route.params.id,
time: new Date().toISOString(),
},
() => {},
() => {},
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)
backToList()
}
backToList()
} else {
console.log('Ada error di form', result)
}
@@ -3,7 +3,7 @@
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
import List from '~/components/app/summary-medic/list.vue'
import List from '~/components/app/soapi/list.vue'
import Entry from '~/components/app/summary-medic/entry.vue'
// Helpers
@@ -31,7 +31,7 @@ import {
} from '~/handlers/summary-medic.handler'
// Services
import { getList, getDetail } from '~/services/summary-medic.service'
import { getList, getDetail } from '~/services/soapi-early.service'
// Models
import type { Encounter } from '~/models/encounter'
@@ -61,7 +61,13 @@ const {
fetchData: getMyList,
} = usePaginatedList({
fetchFn: async ({ page, search }) => {
const result = await getList({ 'encounter-id': props.encounter.id, includes: '', search, page })
const result = await getList({
'encounter-id': route.params.id,
includes: 'encounter,employee',
'type-code': 'amb-resume',
search,
page,
})
if (result.success) {
data.value = result.body.data
}