fix: refactor view letter

This commit is contained in:
riefive
2025-10-29 13:22:06 +07:00
parent 2d2e14ede0
commit 02e33c4f61
6 changed files with 78 additions and 17 deletions
+4 -2
View File
@@ -131,8 +131,10 @@ watch(props, (value) => {
nationalId.value = objects?.nationalIdentity || '-'
medicalRecordNumber.value = objects?.medicalRecordNumber || '-'
patientName.value = objects?.patientName || '-'
// Set admission type to 1 (rujukan) if sepType exists in query params
if (objects?.sepType) {
if (objects?.sepType === 'internal') {
admissionType.value = '4'
}
if (objects?.sepType === 'external') {
admissionType.value = '1'
}
isDateReload.value = true
@@ -0,0 +1,51 @@
import type { Config } from '~/components/pub/my-ui/data-table'
import { defineAsyncComponent } from 'vue'
const SelectedRadio = defineAsyncComponent(() => import('~/components/pub/my-ui/data/select-radio.vue'))
export const config: Config = {
cols: [
{ width: 50 },
{ width: 150 },
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 120 },
{ width: 150 },
],
headers: [
[
{ label: '' },
{ label: 'NO. SURAT KONTROL' },
{ label: 'TANGGAL SURAT KONTROL' },
{ label: 'NO. SEP' },
{ label: 'NAMA PASIEN' },
{ label: 'NO. KARTU BPJS' },
{ label: 'KLINIK TUJUAN' },
{ label: 'DOKTER' },
],
],
keys: ['check', 'letterNumber', 'plannedDate', 'sepNumber', 'patientName', 'bpjsCardNo', 'clinic', 'doctor'],
delKeyNames: [
{ key: 'code', label: 'Code' },
{ key: 'name', label: 'Name' },
],
parses: {},
components: {
check(rec, idx) {
return {
idx,
rec: { ...(rec as object), menu: 'letter' },
component: SelectedRadio,
}
},
},
htmls: {},
}
+6 -8
View File
@@ -10,26 +10,25 @@ export interface LetterData {
patientName: string
bpjsCardNo: string
clinic: string
doctor: string
doctor?: string
}
export const config: Config = {
cols: [{ width: 50 }, { width: 150 }, { width: 120 }, { width: 120 }, { width: 120 }, { width: 120 }, { width: 150 }, { width: 200 }],
cols: [{ width: 50 }, { width: 150 }, { width: 120 }, { width: 120 }, { width: 120 }, { width: 120 }, { width: 120 }],
headers: [
[
{ label: '' },
{ label: 'NO. SURAT' },
{ label: 'TANGGAL SURAT' },
{ label: 'NO. SURAT RUJUKAN' },
{ label: 'TANGGAL SURAT RUJUKAN' },
{ label: 'NO. SEP' },
{ label: 'NAMA PASIEN' },
{ label: 'NO. KARTU BPJS' },
{ label: 'KLINIK TUJUAN' },
{ label: 'DOKTER' },
],
],
keys: ['check', 'letterNumber', 'plannedDate', 'sepNumber', 'patientName', 'bpjsCardNo', 'clinic', 'doctor'],
keys: ['check', 'letterNumber', 'plannedDate', 'sepNumber', 'patientName', 'bpjsCardNo', 'clinic'],
delKeyNames: [
{ key: 'code', label: 'Code' },
@@ -42,7 +41,7 @@ export const config: Config = {
check(rec, idx) {
return {
idx,
rec: { ...rec as object, menu: 'letter' },
rec: { ...(rec as object), menu: 'letter' },
component: SelectedRadio,
}
},
@@ -50,4 +49,3 @@ export const config: Config = {
htmls: {},
}
+6 -2
View File
@@ -7,14 +7,18 @@ import type { LetterData } from './list-cfg.letter'
import type { PaginationMeta } from '~/components/pub/my-ui/pagination/pagination.type'
// Configs
import { config } from './list-cfg.letter'
import { config as configControl } from './list-cfg.control'
import { config as configLetter } from './list-cfg.letter'
const props = defineProps<{
data: LetterData[]
menu?: string
selected?: string
paginationMeta?: PaginationMeta
}>()
const menu = props.menu || 'control'
const emit = defineEmits<{
pageChange: [page: number]
}>()
@@ -26,7 +30,7 @@ function handlePageChange(page: number) {
<template>
<PubMyUiDataTable
v-bind="config"
v-bind="menu === 'control' ? configControl : configLetter"
:rows="props.data"
:selected="props.selected"
/>
+2
View File
@@ -23,6 +23,7 @@ import { refDebounced } from '@vueuse/core'
const props = defineProps<{
open: boolean
menu?: string
letters: Array<LetterData>
selected: string
paginationMeta?: PaginationMeta
@@ -101,6 +102,7 @@ watch(debouncedSearch, (newValue) => {
<div class="overflow-x-auto rounded-lg border">
<ListLetter
:data="letters"
:menu="props.menu"
:selected="props.selected"
:pagination-meta="paginationMeta"
@page-change="handlePageChange"
+9 -5
View File
@@ -55,9 +55,10 @@ const route = useRoute()
const openPatient = ref(false)
const openLetter = ref(false)
const openHistory = ref(false)
const selectedLetter = ref('SK22334442')
const selectedLetter = ref('')
const selectedObjects = ref<any>({})
const selectedServiceType = ref<string>('')
const selectedAdmissionType = ref<string>('')
const histories = ref<Array<SepHistoryData>>([])
const visits = ref<Array<SepVisitData>>([])
const letters = ref<Array<any>>([])
@@ -87,8 +88,10 @@ async function getMonitoringHistoryMappers() {
const dateFirst = new Date()
const dateLast = new Date()
dateLast.setMonth(dateFirst.getMonth() - 3)
const cardNumber =
selectedPatientObject.value?.person?.residentIdentityNumber || selectedPatientObject.value?.number || ''
const result = await getMonitoringHistoryList({
cardNumber: '0002078925513',
cardNumber: cardNumber,
startDate: dateFirst.toISOString().substring(0, 10),
endDate: dateLast.toISOString().substring(0, 10),
})
@@ -203,7 +206,7 @@ async function getLetterMappers(admissionType: string, search: string) {
patientName: lettersRaw.rujukan.peserta.nama || '',
bpjsCardNo: lettersRaw.rujukan.peserta.noKartu || '',
clinic: lettersRaw.rujukan.poliRujukan.nama || '',
doctor: lettersRaw.rujukan.namaDokter || '-',
doctor: '',
},
]
}
@@ -227,7 +230,7 @@ function handleSaveLetter() {
async function handleEvent(menu: string, value: any) {
if (menu === 'admission-type') {
console.log('service-type:', value)
selectedAdmissionType.value = value
return
}
if (menu === 'service-type') {
@@ -345,7 +348,7 @@ async function handleInit() {
label: serviceTypes[item],
})) as any
registerMethodsList.value = Object.keys(registerMethods)
.filter((item) => !['4'].includes(item))
.filter((item) => ![''].includes(item))
.map((item) => ({
value: item.toString(),
label: registerMethods[item],
@@ -481,6 +484,7 @@ onMounted(async () => {
<AppViewLetter
v-model:open="openLetter"
:letters="letters"
:menu="selectedAdmissionType !== '3' ? 'control' : 'reference'"
:selected="selectedLetter"
:pagination-meta="{ recordCount: 0, page: 1, pageSize: 10, totalPage: 0 } as any"
@fetch="(value) => getLetterMappers(value.admissionType, value.search)"