- Implement list view with pagination and search functionality - Create form for adding subspecialist entries - Add configuration for subspecialist data validation and dropdown options
99 lines
2.6 KiB
TypeScript
99 lines
2.6 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'),
|
|
specialistId: z
|
|
.string({
|
|
required_error: 'Specialist harus dipilih',
|
|
})
|
|
.min(1, 'Specialist harus dipilih'),
|
|
})
|
|
|
|
// Unit mapping berdasarkan installation
|
|
export const installationUnitMapping: Record<string, string[]> = {
|
|
'1': ['1', '3'],
|
|
'2': ['2', '3'],
|
|
'3': ['1', '2', '3'],
|
|
}
|
|
|
|
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' },
|
|
],
|
|
}
|
|
|
|
export const specialistConf = {
|
|
msg: {
|
|
placeholder: '---pilih specialist',
|
|
search: 'kode, nama specialist',
|
|
empty: 'specialist tidak ditemukan',
|
|
},
|
|
items: [
|
|
{ value: '1', label: 'Spesialis Jantung', code: 'CARD' },
|
|
{ value: '2', label: 'Spesialis Mata', code: 'OPHT' },
|
|
{ value: '3', label: 'Spesialis Bedah', code: 'SURG' },
|
|
{ value: '4', label: 'Spesialis Anak', code: 'PEDI' },
|
|
{ value: '5', label: 'Spesialis Kandungan', code: 'OBGY' },
|
|
],
|
|
}
|
|
|
|
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),
|
|
}
|
|
}
|