Dev cleaning (#106)

This commit is contained in:
Munawwirul Jamal
2025-10-08 00:03:36 +07:00
committed by GitHub
parent 7fdd5c61f0
commit 3eb9dde21d
892 changed files with 51326 additions and 1 deletions
+265
View File
@@ -0,0 +1,265 @@
export const activeStatusCodes: Record<string, string> = {
active: 'Aktif',
inactive: 'Tidak Aktif',
}
export const dataStatusCodes: Record<string, string> = {
new: 'Baru',
review: 'Review',
process: 'Proses',
done: 'Selesai',
canceled: 'Dibatalkan',
rejected: 'Ditolak',
skiped: 'Dilewati',
}
export const userStatusCodes: Record<string, string> = {
new: 'Baru',
active: 'Aktif',
inactive: 'Tidak Aktif',
blocked: 'Diblokir',
suspended: 'Dibekukan',
}
export const itemGroupCodes: Record<string, string> = {
infra: 'Infrastruktur',
medicine: 'Obat',
device: 'Peralatan',
material: 'Perlengkapan',
}
export const unitTypeCodes: Record<string, string> = {
reg: 'Registrasi',
exa: 'Pemeriksaan',
pay: 'Pembayaran',
pha: 'Farmasai',
lab: 'Laboratorium',
rad: 'Radiologi',
}
export const queueStatusCodes: Record<string, string> = {
wait: 'Tunggu',
proc: 'Proses',
done: 'Selesai',
cancel: 'Batal',
skip: 'Dilewati',
}
export const encounterClassCodes: Record<string, string> = {
outpatient: 'Rawat Jalan',
ambulatory: 'Rawat Jalan',
emergency: 'Gawat Darurat',
inpatient: 'Rawat Inap',
draft: 'Draft',
done: 'Selesai',
cancel: 'Batal',
skip: 'Dilewati',
}
export const timeUnitCodes: Record<string, string> = {
sec: 'Detik',
min: 'Menit',
hour: 'Jam',
day: 'Hari',
week: 'Minggu',
month: 'Bulan',
year: 'Tahun',
}
export const dischargeMethodCodes: Record<string, string> = {
home: 'Home',
'home-request': 'Home Request',
}
export const genderCodes: Record<string, string> = {
male: 'Laki',
female: 'Perempuan',
'not-stated': 'Tidak Disebutkan',
unknown: 'Tidak Diketahui',
}
export const religionCodes: Record<string, string> = {
islam: 'Islam',
protestan: 'Protestan',
katolik: 'Katolik',
hindu: 'Hindu',
buda: 'Buda',
konghucu: 'Konghucu',
}
export const educationCodes: Record<string, string> = {
TS: 'TS',
TK: 'TK',
SD: 'SD',
SMP: 'SMP',
SMA: 'SMA',
D1: 'D1',
D2: 'D2',
D3: 'D3',
S1: 'S1',
S2: 'S2',
S3: 'S3',
}
export const occupationCodes: Record<string, string> = {
'tidak-bekerja': 'Tidak Bekerja',
pns: 'Pegawai Negeri Sipil',
polisi: 'Polisi',
tni: 'TNI',
guru: 'Guru',
wiraswasta: 'Wiraswasta',
'kary-swasta': 'Karyawan Swasta',
lainnya: 'Lainnya',
}
export const personContactTypes: Record<string, string> = {
phone: 'Telepon',
'm-phone': 'HP / Ponsel',
email: 'Email',
fax: 'Fax',
}
// Mapping dari UI values ke contact type constants
export const contactTypeMapping: Record<string, string> = {
phoneNumber: 'm-phone',
officePhoneNumber: 'phone',
homePhoneNumber: 'phone',
email: 'email',
fax: 'fax',
}
export const dayCodes: Record<string, string> = {
'0': 'Minggu',
'1': '',
'2': '',
'3': '',
'4': '',
'5': '',
'6': 'Sabtu',
}
export const paymentMethodCodes: Record<string, string> = {
cash: 'Cash',
debit: 'Debit',
credit: 'Kredit',
insurance: 'Asuransi',
membership: 'Membership',
}
export const transportationCodes: Record<string, string> = {
ambulance: 'Ambulans',
car: 'Mobil',
'motor-cycle': 'Motor',
other: 'Lainnya',
}
export const personConditionCodes: Record<string, string> = {
res: 'Resutiasi',
emg: 'Darurat',
urg: 'Mendesak',
lurg: 'Kurang Mendesak',
nurg: 'Mendesak',
doa: 'Meninggal Saat Tiba',
}
export const emergencyClassCodes: Record<string, string> = {
emg: 'Darurat',
eon: 'Ponek',
}
export const outpatientClassCodes: Record<string, string> = {
op: 'Rawat Inap',
icu: 'ICU',
hcu: 'HCU',
vk: 'Kamar Bersalin',
}
export const checkupScopeCodes: Record<string, string> = {
lab: 'Laboratorium',
'mic-lab': 'Microbacterial Laboratorium',
'pa-lab': 'Patology Anatomy Laboratorium',
rad: 'Radiology',
}
export const employeePositionCodes: Record<string, string> = {
doctor: 'Dokter',
nurse: 'Perawat',
nutritionist: 'Ahli Gisi',
laborant: 'Laboran',
pharmacy: 'Farmasi',
payment: 'Pembayaran',
'payment-verificator': 'Konfirmasi Pembayaran',
management: 'Management',
}
export const subjectCodes: Record<string, string> = {
'pri-compl': 'Primary Complaint',
'sec-compl': 'Secondary Complaint',
'cur-disea-hist': 'Current Disease History',
'pas-disea-hist': 'Past Disease History',
'fam-disea-hist': 'Family Disease History',
'alg-hist': 'Allergic Hist',
'alg-react': 'Allergic Reaction',
'med-hist': 'Medication Hist',
}
export const objectCodes: Record<string, string> = {
'consc-level': 'Tingkat Kesadaran',
'consc-level-det': 'Detail Tingkat Kesadaran',
'syst-bp': 'Tekanan Darah Systolic',
'diast-bp': 'Tekanan Darah Diastolic',
'hear-rt': 'Detak Jantung',
temp: 'Suhu',
spo2: 'SpO2',
weight: 'Berat Badan',
height: 'Tinggi Badan',
}
export const assessmentCodes: Record<string, string> = {
'early-diag': 'Diagnosis Awal',
'late-diag': 'Diagnosis Akhir',
'sec-diag': 'Diagnosis Sekunder',
}
export const instructionCodes: Record<string, string> = {
detail: 'Detail Instruksi',
'med-act': 'Tindakan medis',
medication: 'Obat',
material: 'BMHP',
}
export const relationshipCodes: Record<string, string> = {
mother: 'Ibu',
father: 'Ayah',
uncle: 'Paman',
aunt: 'Bibi',
sibling: 'Saudara',
'gd-mother': 'Nenek',
'gd-father': 'Kakek',
child: 'Anak',
nephew: 'Keponakan',
'gd-child': 'Cucu',
other: 'Lainnya',
}
export const uploadCode: Record<string, string> = {
ktp: 'person-resident-number',
sim: 'person-driving-license',
kk: 'person-family-card',
paspor: 'person-passport',
'mcu-report': 'mcu-item-result',
}
export const infraGroupCodes: Record<string, string> = {
building: 'Bangunan',
floor: 'Lantai',
warehouse: 'Gudang / Depo',
room: 'Ruang',
chamber: 'Kamar',
bed: 'Ranjang'
}
export const infraGroupCodesKeys: Record<string, string> = Object.keys(infraGroupCodes).reduce((acc, key) => {
acc[key] = key
return acc
}, {} as Record<string, string>)
+44
View File
@@ -0,0 +1,44 @@
import type { RoleAccess } from '~/models/role'
export const PAGE_PERMISSIONS = {
'/patient': {
doctor: ['R'],
nurse: ['R'],
admisi: ['C', 'R', 'U', 'D'],
pharmacy: ['R'],
billing: ['R'],
management: ['R'],
},
'/doctor': {
doctor: ['C', 'R', 'U', 'D'],
nurse: ['R'],
admisi: ['R'],
pharmacy: ['R'],
billing: ['R'],
management: ['R'],
},
'/satusehat': {
doctor: ['R'],
nurse: ['R'],
admisi: ['C', 'R', 'U', 'D'],
pharmacy: ['R'],
billing: ['R'],
management: ['R'],
},
'/rehab/encounter': {
doctor: ['C', 'R', 'U', 'D'],
nurse: ['R'],
admisi: ['R'],
pharmacy: ['R'],
billing: ['R'],
management: ['R'],
},
'/rehab/registration': {
doctor: ['C', 'R', 'U', 'D'],
nurse: ['R'],
admisi: ['R'],
pharmacy: ['R'],
billing: ['R'],
management: ['R'],
},
} as const satisfies Record<string, RoleAccess>
+96
View File
@@ -0,0 +1,96 @@
import type { ClassValue } from 'clsx'
import { clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'
export interface SelectOptionType<_T = string> {
value: string
label: string
code?: string
}
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export function mapToComboboxOptList(items: Record<string, string>): SelectOptionType<string>[] {
if (!items) {
return []
}
const result: SelectOptionType<string>[] = []
Object.keys(items).forEach((item) => {
result.push({
label: items[item] as string,
value: item,
code: item,
})
})
return result
}
/**
* Menghitung umur berdasarkan tanggal lahir
* @param birthDate - Tanggal lahir dalam format Date atau string
* @returns String umur dalam format "X tahun Y bulan" atau "X bulan" untuk bayi
*/
export function calculateAge(birthDate: Date | string | null | undefined): string {
if (!birthDate) {
return '-'
}
let birth: Date
// Konversi ke Date object
if (typeof birthDate === 'string') {
birth = new Date(birthDate)
} else {
birth = birthDate
}
// Validasi tanggal
if (isNaN(birth.getTime())) {
return '-'
}
const today = new Date()
const birthYear = birth.getFullYear()
const birthMonth = birth.getMonth()
const birthDay = birth.getDate()
const currentYear = today.getFullYear()
const currentMonth = today.getMonth()
const currentDay = today.getDate()
// Hitung tahun
let years = currentYear - birthYear
let months = currentMonth - birthMonth
// Adjust jika bulan atau hari belum lewat
if (months < 0 || (months === 0 && currentDay < birthDay)) {
years--
months += 12
}
if (currentDay < birthDay) {
months--
}
// Pastikan months tidak negatif
if (months < 0) {
months += 12
}
// Format output
if (years === 0) {
if (months === 0) {
// Hitung hari untuk bayi baru lahir
const diffTime = today.getTime() - birth.getTime()
const days = Math.floor(diffTime / (1000 * 60 * 60 * 24))
return days <= 30 ? `${days} hari` : '1 bulan'
}
return `${months} bulan`
} else if (months === 0) {
return `${years} tahun`
} else {
return `${years} tahun ${months} bulan`
}
}