Files
simrsx-fe/app/components/content/specialist/entry.ts
Khafid Prayoga 06caccf3cd feat(subspecialist): add subspecialist management components and pages
- Implement list view with pagination and search functionality
- Create form for adding subspecialist entries
- Add configuration for subspecialist data validation and dropdown options
2025-09-15 14:21:15 +07:00

96 lines
3.1 KiB
TypeScript

import * as z from 'zod'
export const schemaConf = z.object({
name: z
.string({
required_error: 'Nama spesialisasi harus diisi',
})
.min(3, 'Nama spesialisasi minimal 3 karakter'),
code: z
.string({
required_error: 'Kode spesialisasi harus diisi',
})
.min(3, 'Kode spesialisasi minimal 3 karakter'),
installationId: z
.string({
required_error: 'Instalasi harus dipilih',
})
.min(1, 'Instalasi harus dipilih'),
unitId: z
.string({
required_error: 'Unit harus dipilih',
})
.min(1, 'Unit harus dipilih'),
})
// Unit mapping berdasarkan installation
export const installationUnitMapping: Record<string, string[]> = {
'1': ['1', '3', '5'],
'2': ['2', '4', '6'],
'3': ['7', '8', '9', '10', '11'],
}
export const unitConf = {
msg: {
placeholder: '---pilih unit',
search: 'kode, nama unit',
empty: 'unit tidak ditemukan',
},
items: [
{ value: '1', label: 'Instalasi Medis', code: 'MED' },
{ value: '2', label: 'Instalasi Keperawatan', code: 'NUR' },
{ value: '3', label: 'Instalasi Administrasi', code: 'ADM' },
{ value: '4', label: 'Instalasi Penunjang Non-Medis', code: 'SUP' },
{ value: '5', label: 'Instalasi Pendidikan & Pelatihan', code: 'EDU' },
{ value: '6', label: 'Instalasi Farmasi', code: 'PHA' },
{ value: '7', label: 'Instalasi Radiologi', code: 'RAD' },
{ value: '8', label: 'Instalasi Laboratorium', code: 'LAB' },
{ value: '9', label: 'Instalasi Keuangan', code: 'FIN' },
{ value: '10', label: 'Instalasi SDM', code: 'HR' },
{ value: '11', label: 'Instalasi Teknologi Informasi', code: 'ITS' },
{ value: '12', label: 'Instalasi Pemeliharaan & Sarana', code: 'MNT' },
{ value: '13', label: 'Instalasi Gizi / Catering', code: 'CAT' },
{ value: '14', label: 'Instalasi Keamanan', code: 'SEC' },
{ value: '15', label: 'Instalasi Gawat Darurat', code: 'EMR' },
{ value: '16', label: 'Instalasi Bedah Sentral', code: 'SUR' },
{ value: '17', label: 'Instalasi Rawat Jalan', code: 'OUT' },
{ value: '18', label: 'Instalasi Rawat Inap', code: 'INP' },
{ value: '19', label: 'Instalasi Rehabilitasi Medik', code: 'REB' },
{ value: '20', label: 'Instalasi Penelitian & Pengembangan', code: 'RSH' },
],
}
export const installationConf = {
msg: {
placeholder: '---pilih instalasi',
search: 'kode, nama instalasi',
empty: 'instalasi tidak ditemukan',
},
items: [
{ value: '1', label: 'Ambulatory', code: 'AMB' },
{ value: '2', label: 'Inpatient', code: 'IMP' },
{ value: '3', label: 'Emergency', code: 'EMER' },
],
}
// Helper function untuk filter unit berdasarkan installation
export function getFilteredUnits(installationId: string) {
if (!installationId || !installationUnitMapping[installationId]) {
return []
}
const allowedUnitIds = installationUnitMapping[installationId]
return unitConf.items.filter((unit) => allowedUnitIds.includes(unit.value))
}
// Helper function untuk membuat unit config yang ter-filter
export function createFilteredUnitConf(installationId: string) {
return {
...unitConf,
items: getFilteredUnits(installationId),
}
}