feat(sep): add error message
This commit is contained in:
@@ -4,6 +4,7 @@ import { useRoute } from 'vue-router'
|
||||
|
||||
// Components
|
||||
import AppViewHistory from '~/components/app/sep/view-history.vue'
|
||||
import { toast } from '~/components/pub/ui/toast'
|
||||
|
||||
// Types
|
||||
import type { PaginationMeta } from '~/components/pub/my-ui/pagination/pagination.type'
|
||||
@@ -67,6 +68,8 @@ const classLevelsList = ref<Array<{ value: string; label: string }>>([])
|
||||
const classLevelUpgradesList = ref<Array<{ value: string; label: string }>>([])
|
||||
const classPaySourcesList = ref<Array<{ value: string; label: string }>>([])
|
||||
const isPatientsLoading = ref(false)
|
||||
const isServiceHidden = ref(false)
|
||||
const isSaveLoading = ref(false)
|
||||
const paginationMeta = ref<PaginationMeta>({
|
||||
recordCount: 0,
|
||||
page: 1,
|
||||
@@ -77,7 +80,6 @@ const paginationMeta = ref<PaginationMeta>({
|
||||
})
|
||||
|
||||
function mapPatientToRow(patient: PatientEntity) {
|
||||
// Defensive mapping: try common field names that might be returned by the API
|
||||
const identity = patient?.person?.residentIdentityNumber || '-'
|
||||
const number = patient?.number || '-'
|
||||
const bpjs = '-'
|
||||
@@ -175,7 +177,6 @@ async function getMonitoringVisitMappers() {
|
||||
if (result && result.success && result.body) {
|
||||
const visitsRaw = result.body?.response?.sep || []
|
||||
|
||||
// "diagnosa": "K65.0",
|
||||
// "jnsPelayanan": "R.Inap",
|
||||
// "kelasRawat": "2",
|
||||
// "nama": "HANIF ABDURRAHMAN",
|
||||
@@ -269,10 +270,24 @@ async function handleEvent(menu: string, value: any) {
|
||||
navigateTo('/integration/bpjs/sep')
|
||||
}
|
||||
if (menu === 'save-sep') {
|
||||
createSep(makeSepData(value)).then((value) => {
|
||||
console.log('value:', value)
|
||||
// navigateTo('/integration/bpjs/sep')
|
||||
})
|
||||
isSaveLoading.value = true
|
||||
createSep(makeSepData(value))
|
||||
.then((res) => {
|
||||
const code = res?.metaData?.code
|
||||
const message = res?.metaData?.message
|
||||
if (code && code !== '200') {
|
||||
toast({ title: 'Gagal', description: message || 'Gagal membuat SEP', variant: 'destructive' })
|
||||
} else {
|
||||
toast({ title: 'Berhasil', description: 'SEP berhasil dibuat', variant: 'default' })
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Failed to save SEP:', err)
|
||||
toast({ title: 'Gagal', description: err?.message || 'Gagal membuat SEP', variant: 'destructive' })
|
||||
})
|
||||
.finally(() => {
|
||||
isSaveLoading.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +337,7 @@ async function handleInit() {
|
||||
label: serviceTypes[item],
|
||||
})) as any
|
||||
registerMethodsList.value = Object.keys(registerMethods)
|
||||
.filter((item) => !['2', '4'].includes(item))
|
||||
.filter((item) => !['4'].includes(item))
|
||||
.map((item) => ({
|
||||
value: item.toString(),
|
||||
label: registerMethods[item],
|
||||
@@ -364,9 +379,11 @@ async function handleInit() {
|
||||
onMounted(async () => {
|
||||
await handleInit()
|
||||
if (route.query) {
|
||||
selectedObjects.value = { ...route.query }
|
||||
const queries = route.query as any
|
||||
selectedObjects.value = { ...queries }
|
||||
isServiceHidden.value = queries['is-service'] === 'true'
|
||||
delete selectedObjects.value['is-service']
|
||||
}
|
||||
console.log('selectedObjects:', selectedObjects.value)
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -379,6 +396,7 @@ onMounted(async () => {
|
||||
<span class="font-semibold">Tambah</span>
|
||||
SEP
|
||||
</div>
|
||||
Hallo {{ isServiceHidden }}
|
||||
<AppSepEntryForm
|
||||
:doctors="doctors"
|
||||
:diagnoses="diagnoses"
|
||||
@@ -398,6 +416,8 @@ onMounted(async () => {
|
||||
:class-level-upgrades="classLevelUpgradesList"
|
||||
:class-pay-sources="classPaySourcesList"
|
||||
:patient="selectedPatientObject"
|
||||
:is-save-loading="isSaveLoading"
|
||||
:is-service="isServiceHidden"
|
||||
@fetch="handleFetch"
|
||||
@event="handleEvent"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user