32 lines
948 B
TypeScript
32 lines
948 B
TypeScript
// Services
|
|
import { getDetail } from '~/services/encounter.service'
|
|
|
|
// Handlers
|
|
import { mapResponseToEncounter } from '~/handlers/encounter-init.handler'
|
|
|
|
export async function getEncounterData(id: string | number) {
|
|
let data = null
|
|
try {
|
|
const dataRes = await getDetail(id, {
|
|
includes:
|
|
'patient,patient-person,patient-person-addresses,unit,Appointment_Doctor,Appointment_Doctor-employee,Appointment_Doctor-employee-person,Responsible_Doctor,Responsible_Doctor-employee,Responsible_Doctor-employee-person',
|
|
})
|
|
const dataResBody = dataRes.body ?? null
|
|
const result = dataResBody?.data ?? null
|
|
|
|
if (result) {
|
|
const mappedData = mapResponseToEncounter(result)
|
|
if (mappedData) {
|
|
data = mappedData
|
|
} else {
|
|
data = null
|
|
}
|
|
} else {
|
|
data = null
|
|
}
|
|
} catch (error) {
|
|
console.error('Error fetching encounter data:', error)
|
|
data = null
|
|
}
|
|
return data
|
|
} |