Files
simrsx-fe/app/components/app/encounter/list.cfg.ts
T

234 lines
6.0 KiB
TypeScript

import type { Config, RecComponent } from '~/components/pub/my-ui/data-table'
import { defineAsyncComponent } from 'vue'
import type { Encounter } from '~/models/encounter'
import { formatAddress } from '~/models/person-address'
import { educationCodes, encounterClassCodes, genderCodes } from '~/lib/constants'
import { getAge } from '~/lib/date'
type SmallDetailDto = Encounter
const action = defineAsyncComponent(() => import('./dropdown-action.vue'))
const statusBadge = defineAsyncComponent(() => import('./status-badge.vue'))
const vclaimSepInfo = defineAsyncComponent(() => import('./vclaim-sep-info.vue'))
const vclaimSepNone = defineAsyncComponent(() => import('./vclaim-sep-none.vue'))
export const defaultConfig: Config = {
cols: [{}, {}, {}, { width: 160 }, {}, { width: 70 }, {}, { width: 50 }],
headers: [
[
{ label: 'Nama' },
{ label: 'Rekam Medis' },
{ label: 'KTP' },
{ label: 'Tgl Lahir / Umur' },
{ label: 'JK' },
{ label: 'Pendidikan' },
{ label: 'Status', classVal: '!text-center' },
{ label: '' },
],
],
keys: [
'patient.person.name',
'patient.number',
'patient.person.residentIdentityNumber',
'birth_date',
'gender',
'education',
'status',
'action',
],
delKeyNames: [
{ key: 'code', label: 'Kode' },
{ key: 'name', label: 'Nama' },
],
parses: {
gender: (rec: unknown): unknown => {
const recX = rec as Encounter
if (recX.patient?.person?.gender_code) {
return genderCodes[recX.patient.person.gender_code]
}
return '-'
},
education: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
if (recX.patient?.person?.education_code) {
return educationCodes[recX.patient.person.education_code]
}
return '-'
},
},
components: {
action(rec, idx) {
const res: RecComponent = {
idx,
rec: rec as object,
component: action,
}
return res
},
status(rec, idx) {
const recX = rec as Encounter
if (!recX.status_code) {
recX.status_code = 'new'
}
const res: RecComponent = {
idx,
rec: recX,
component: statusBadge,
}
return res
},
},
htmls: {
birth_date: (rec: unknown): unknown => {
const recX = rec as Encounter
if (recX.patient?.person?.birthDate) {
return (
'' +
'<div>' +
(recX.patient.person.birthDate as string).substring(0, 10) +
' / </div>' +
getAge(recX.patient.person.birthDate as string).extFormat
)
}
return '-'
},
},
}
export const ambulatoryConfig: Config = {
cols: [{}, {}, {}, { width: 160 }, {}, { width: 70 }, {}, {}, {}, {}, {}, {}, { width: 50 }],
headers: [
[
{ label: 'TANGGAL' },
{ label: 'NO. RM' },
{ label: 'NO. BILL' },
{ label: 'NAMA PASIEN' },
{ label: 'L/P' },
{ label: 'ALAMAT' },
{ label: 'KLINIK' },
{ label: 'CARA BAYAR' },
{ label: 'RUJUKAN' },
{ label: 'KET. RUJUKAN' },
{ label: 'ASAL' },
{ label: 'SEP' },
{ label: 'STATUS', classVal: '!text-center' },
{ label: '' },
],
],
keys: [
'registeredAt',
'patientNumber',
'trxNumber',
'patient.person.name',
'gender',
'address',
'clinic',
'paymentMethod_code',
'referral',
'note',
'class_code',
'sep',
'status',
'action',
],
delKeyNames: [
{ key: 'code', label: 'Kode' },
{ key: 'name', label: 'Nama' },
],
parses: {
registeredAt: (rec: unknown): unknown => {
const recX = rec as Encounter
const currentDate = recX.registeredAt ? (recX.registeredAt as string) : (recX as any).createdAt
return currentDate ? currentDate.substring(0, 10) : '-'
},
patientNumber: (rec: unknown): unknown => {
const recX = rec as any
return recX.patient?.number || '-'
},
trxNumber: (rec: unknown): unknown => {
const recX = rec as any
return recX.trx_number || '-'
},
gender: (rec: unknown): unknown => {
const recX = rec as Encounter
if (recX.patient?.person?.gender_code) {
return genderCodes[recX.patient.person.gender_code]
}
return '-'
},
address: (rec: unknown): unknown => {
const recX = rec as Encounter
const addresses = recX.patient?.person?.addresses || []
const resident = addresses?.find((addr) => addr.locationType_code === 'domicile')
const text = resident ? formatAddress(resident) : '-'
return text.length > 20 ? text.substring(0, 17) + '...' : text
},
clinic: (rec: unknown): unknown => {
const recX = rec as Encounter
return recX.unit?.name || recX.refSource_name || '-'
},
paymentMethod_code: (rec: unknown): unknown => {
const recX = rec as Encounter
return (recX.paymentMethod_code || '-').toUpperCase()
},
referral: (rec: unknown): unknown => {
const recX = rec as any
return recX?.vclaimReference?.poliRujukan || '-'
},
note: (rec: unknown): unknown => {
const recX = rec as any
return recX?.vclaimReference?.ppkDirujuk || '-'
},
class_code: (rec: unknown): unknown => {
const recX = rec as Encounter
return recX.class_code ? encounterClassCodes[recX.class_code] : '-'
},
},
components: {
sep(rec: any) {
if (rec?.paymentMethod_code !== 'jkn') {
return {
rec: rec as object,
component: vclaimSepNone,
} as RecComponent
}
const res: RecComponent = {
rec: rec as object,
component: vclaimSepInfo,
}
return res
},
status(rec, idx) {
const recX = rec as Encounter
if (!recX.status_code) {
recX.status_code = 'new'
}
const res: RecComponent = {
idx,
rec: recX,
component: statusBadge,
}
return res
},
action(rec, idx) {
const res: RecComponent = {
idx,
rec: rec as object,
component: action,
}
return res
},
},
}