fix: reload doctor fetch
This commit is contained in:
@@ -9,10 +9,8 @@ import AppViewHistory from '~/components/app/sep/view-history.vue'
|
||||
import { refDebounced } from '@vueuse/core'
|
||||
|
||||
// Handlers
|
||||
import { getDetail as getDoctorDetail } from '~/services/doctor.service'
|
||||
import { useEncounterEntry } from '~/handlers/encounter-entry.handler'
|
||||
import { useIntegrationSepEntry } from '~/handlers/integration-sep-entry.handler'
|
||||
import { genDoctor, type Doctor } from '~/models/doctor'
|
||||
|
||||
// Props
|
||||
const props = defineProps<{
|
||||
@@ -42,6 +40,7 @@ const {
|
||||
isSaveDisabled,
|
||||
isLoading,
|
||||
patients,
|
||||
selectedDoctor,
|
||||
selectedPatient,
|
||||
selectedPatientObject,
|
||||
paginationMeta,
|
||||
@@ -53,7 +52,8 @@ const {
|
||||
getPatientsList,
|
||||
getPatientCurrent,
|
||||
getPatientByIdentifierSearch,
|
||||
getIsSubspecialist,
|
||||
// getIsSubspecialist,
|
||||
getDoctorInfo,
|
||||
getValidateMember,
|
||||
getValidateSepNumber,
|
||||
handleFetchDoctors,
|
||||
@@ -61,16 +61,8 @@ const {
|
||||
const { recSepId, openHistory, histories, getMonitoringHistoryMappers } = useIntegrationSepEntry()
|
||||
|
||||
const debouncedSepNumber = refDebounced(sepNumber, 500)
|
||||
const selectedDoctor = ref<Doctor>(genDoctor())
|
||||
|
||||
///// Functions
|
||||
async function getDoctorInfo(value: string) {
|
||||
const resp = await getDoctorDetail(value, { includes: 'unit,specialist,subspecialist'})
|
||||
if (resp.success) {
|
||||
selectedDoctor.value = resp.body.data
|
||||
}
|
||||
}
|
||||
|
||||
function handleSavePatient() {
|
||||
selectedPatientObject.value = null
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { toast } from '~/components/pub/ui/toast'
|
||||
import type { TreeItem } from '~/components/pub/my-ui/select-tree/type'
|
||||
import type { DataTableLoader } from '~/components/pub/my-ui/data-table/type'
|
||||
import { paymentTypes, sepRefTypeCodes, participantGroups } from '~/lib/constants.vclaim'
|
||||
import { genDoctor, type Doctor } from '~/models/doctor'
|
||||
|
||||
// Stores
|
||||
import { useUserStore } from '~/stores/user'
|
||||
@@ -17,7 +18,7 @@ import {
|
||||
getList as getSpecialistList,
|
||||
getValueTreeItems as getSpecialistTreeItems,
|
||||
} from '~/services/specialist.service'
|
||||
import { getValueLabelList as getDoctorValueLabelList } from '~/services/doctor.service'
|
||||
import { getDetail as getDoctorDetail, getValueLabelList as getDoctorValueLabelList } from '~/services/doctor.service'
|
||||
import {
|
||||
create as createEncounter,
|
||||
getDetail as getEncounterDetail,
|
||||
@@ -67,9 +68,8 @@ export function useEncounterEntry(props: {
|
||||
const vclaimReference = ref<any>(null)
|
||||
const sepFile = ref<File | null>(null)
|
||||
const sippFile = ref<File | null>(null)
|
||||
|
||||
const selectedDoctor = ref<Doctor>(genDoctor())
|
||||
const isEditMode = computed(() => props.id > 0)
|
||||
|
||||
const isSaveDisabled = computed(() => {
|
||||
return !selectedPatient.value || !selectedPatientObject.value || isSaving.value || isLoadingDetail.value
|
||||
})
|
||||
@@ -78,15 +78,12 @@ export function useEncounterEntry(props: {
|
||||
if (props.classCode === 'ambulatory') {
|
||||
return '/ambulatory/encounter'
|
||||
}
|
||||
// if (props.classCode === 'ambulatory' && props.subClassCode === 'reg') {
|
||||
// return '/outpatient/encounter'
|
||||
// }
|
||||
// if (props.classCode === 'emergency') {
|
||||
// return '/emergency/encounter'
|
||||
// }
|
||||
// if (props.classCode === 'inpatient') {
|
||||
// return '/inpatient/encounter'
|
||||
// }
|
||||
if (props.classCode === 'emergency') {
|
||||
return '/emergency/encounter'
|
||||
}
|
||||
if (props.classCode === 'inpatient') {
|
||||
return '/inpatient/encounter'
|
||||
}
|
||||
return '/encounter'
|
||||
}
|
||||
|
||||
@@ -206,11 +203,22 @@ export function useEncounterEntry(props: {
|
||||
return { specialist_id: null, subspecialist_id: null }
|
||||
}
|
||||
|
||||
async function getDoctorInfo(value: string) {
|
||||
const resp = await getDoctorDetail(value, { includes: 'unit,specialist,subspecialist' })
|
||||
if (resp.success) {
|
||||
selectedDoctor.value = resp.body.data
|
||||
}
|
||||
}
|
||||
|
||||
async function getValidateMember(member: string) {
|
||||
if (isCheckingSep.value) return
|
||||
isMemberValid.value = false
|
||||
try {
|
||||
const result = await getMemberList({ mode: 'by-card', number: member, date: new Date().toISOString().split('T')[0] })
|
||||
const result = await getMemberList({
|
||||
mode: 'by-card',
|
||||
number: member,
|
||||
date: new Date().toISOString().split('T')[0],
|
||||
})
|
||||
if (result.success && result.body?.response !== null) {
|
||||
const response = result.body?.response || {}
|
||||
if (Object.keys(response).length > 0) {
|
||||
@@ -341,9 +349,9 @@ export function useEncounterEntry(props: {
|
||||
try {
|
||||
isLoadingDetail.value = true
|
||||
const result = await getEncounterDetail(props.id, {
|
||||
includes: 'patient,patient-person,specialist,subspecialist,EncounterDocuments'
|
||||
includes: 'patient,patient-person,specialist,subspecialist,Appointment_Doctor,EncounterDocuments',
|
||||
})
|
||||
|
||||
|
||||
if (result.success && result.body?.data) {
|
||||
encounterData.value = result.body.data
|
||||
await mapEncounterToForm(encounterData.value)
|
||||
@@ -391,9 +399,10 @@ export function useEncounterEntry(props: {
|
||||
formData.medicalRecordNumber = selectedPatientObject.value.number || ''
|
||||
}
|
||||
|
||||
const doctorId = encounter.appointment_doctor_code || encounter.responsible_doctor_code
|
||||
if (doctorId) {
|
||||
formData.doctorId = String(doctorId)
|
||||
const doctorCode = encounter.appointment_doctor_code || encounter.responsible_doctor_code
|
||||
if (doctorCode) {
|
||||
formData.doctorCode = String(doctorCode)
|
||||
await getDoctorInfo(doctorCode)
|
||||
}
|
||||
|
||||
if (encounter.subspecialist_id) {
|
||||
@@ -419,7 +428,7 @@ export function useEncounterEntry(props: {
|
||||
if (encounter.registeredAt) {
|
||||
const date = new Date(encounter.registeredAt)
|
||||
formData.registerDate = date.toISOString().split('T')[0]
|
||||
}
|
||||
}
|
||||
if (encounter.visitDate) {
|
||||
const date = new Date(encounter.visitDate)
|
||||
formData.registerDate = date.toISOString().split('T')[0]
|
||||
@@ -445,7 +454,7 @@ export function useEncounterEntry(props: {
|
||||
formData.sepNumber = encounter.ref_number || ''
|
||||
formData.sepType = encounter.sep_type || ''
|
||||
formData.patientCategory = encounter.participant_group_code || ''
|
||||
|
||||
|
||||
// Map BPJS reference data if available
|
||||
if (encounter.vclaimReference) {
|
||||
formData.sepReference = encounter.vclaimReference?.noSep || ''
|
||||
@@ -628,6 +637,7 @@ export function useEncounterEntry(props: {
|
||||
isEditMode,
|
||||
isSaveDisabled,
|
||||
isLoading,
|
||||
selectedDoctor,
|
||||
selectedPatient,
|
||||
selectedPatientObject,
|
||||
paginationMeta,
|
||||
@@ -643,6 +653,7 @@ export function useEncounterEntry(props: {
|
||||
getPatientsList,
|
||||
getPatientCurrent,
|
||||
getPatientByIdentifierSearch,
|
||||
getDoctorInfo,
|
||||
getValidateMember,
|
||||
getValidateSepNumber,
|
||||
handleFetchSpecialists,
|
||||
|
||||
Reference in New Issue
Block a user