137 lines
5.3 KiB
Go
137 lines
5.3 KiB
Go
package internal
|
|
|
|
import (
|
|
"slices"
|
|
"time"
|
|
)
|
|
|
|
type EnumObject struct {
|
|
ID int `json:"id"`
|
|
Label string `json:"label"`
|
|
}
|
|
|
|
var Agama = []EnumObject{
|
|
{ID: 1, Label: "Islam"},
|
|
{ID: 2, Label: "Kristen (Protestan)"},
|
|
{ID: 3, Label: "Katolik"},
|
|
{ID: 4, Label: "Hindu"},
|
|
{ID: 5, Label: "Buddha"},
|
|
{ID: 6, Label: "Konghucu"},
|
|
{ID: 7, Label: "Penghayat"},
|
|
{ID: 8, Label: "Lain-lain"},
|
|
}
|
|
var Pendidikan = []EnumObject{
|
|
{ID: 1, Label: "Tidak sekolah"},
|
|
{ID: 2, Label: "SD"},
|
|
{ID: 3, Label: "SLTP sederajat"},
|
|
{ID: 4, Label: "SLTA sederajat"},
|
|
{ID: 5, Label: "D1-D3 sederajat"},
|
|
{ID: 6, Label: "D4"}, // Note: There was a duplicate ID for D4 and S1
|
|
{ID: 6, Label: "S1"}, // Note: There was a duplicate ID for D4 and S1
|
|
{ID: 7, Label: "S2"},
|
|
{ID: 8, Label: "S3"},
|
|
}
|
|
|
|
var StatusKawin = []EnumObject{
|
|
{ID: 1, Label: "Belum Kawin"},
|
|
{ID: 2, Label: "Kawin"},
|
|
{ID: 3, Label: "Cerai Hidup"},
|
|
{ID: 4, Label: "Cerai Mati"},
|
|
}
|
|
|
|
var Pekerjaan = []EnumObject{
|
|
{ID: 1, Label: "Tidak bekerja"},
|
|
{ID: 2, Label: "PNS"},
|
|
{ID: 3, Label: "TNI/POLRI"},
|
|
{ID: 4, Label: "BUMN"},
|
|
{ID: 5, Label: "Pegawai Swasta/Wirausaha"},
|
|
{ID: 6, Label: "Lain-lain"},
|
|
}
|
|
|
|
// export const importDataPasienSchema = z.object({
|
|
// no_rekammedis: z.string(),
|
|
// nama_pasien: z.string(),
|
|
// no_ktp: z.string().nullish(),
|
|
// no_bpjs: z.string().nullish(),
|
|
// tgl_lahir: z.date(),
|
|
// kelamin: z.number(),
|
|
// kebangsaan: z.string().nullish(),
|
|
// agama: z.string().nullish().transform(val => Agama.find(x => x.label === val)?.id),
|
|
// suku: z.string().nullish(),
|
|
// pendidikan: z.coerce.number().nullish(),
|
|
// pekerjaan: z.string().nullish().transform(val => Pekerjaan.find(x => x.label === val)?.id),
|
|
// hp: z.coerce.string().nullish().transform(val => validatePhoneRegex(val?.replace(/\s+/g, ''))),
|
|
// email: z.string().nullish(),
|
|
// status_nikah: z.string().nullish().transform(val => StatusKawin.find(x => x.label === val)?.id),
|
|
// provinsi: z.string().nullish(),
|
|
// kabupaten: z.string().nullish(),
|
|
// kecamatan: z.string().nullish(),
|
|
// kelurahan: z.string().nullish(),
|
|
// kodepos: z.string().nullish(),
|
|
// namajalan: z.string().nullish(),
|
|
// hp_penjamin: z.coerce.string().nullish().transform(val => validatePhoneRegex(val?.replace(/\s+/g, ''))),
|
|
// namapenjamin: z.string().nullish(),
|
|
// ktp_penjamin: z.coerce.string().nullish(),
|
|
// hubungan_penjamin: z.coerce.number().nullish(),
|
|
// pendidikan_penjamin: z.string().nullish().transform(val => Pendidikan.find(x => x.label === val)?.id),
|
|
// alamat_penjamin: z.string().nullish(),
|
|
// }).transform(({
|
|
// no_rekammedis,
|
|
// nama_pasien,
|
|
// no_ktp,
|
|
// no_bpjs,
|
|
// tgl_lahir,
|
|
// kelamin,
|
|
// status_nikah,
|
|
// namajalan,
|
|
// hp,
|
|
// pendidikan_penjamin,
|
|
// ...rest
|
|
// }) => ({
|
|
// noRm: no_rekammedis,
|
|
// namaPasien: nama_pasien,
|
|
// nik: no_ktp,
|
|
// noKartuPesertaBPJS: no_bpjs,
|
|
// tanggalLahir: tgl_lahir,
|
|
// jenisKelamin: kelamin,
|
|
// statusPernikahan: status_nikah,
|
|
// pendidikanPenjamin: pendidikan_penjamin,
|
|
// noHp: hp,
|
|
// nama_jalan: namajalan,
|
|
// ...rest
|
|
// }))
|
|
|
|
type Patient struct {
|
|
NoRekamMedis string `json:"no_rekammedis"`
|
|
NamaPasien string `json:"nama_pasien"`
|
|
NoKTP *string `json:"no_ktp"` // Nullable string
|
|
NoBPJS *string `json:"no_bpjs"` // Nullable string
|
|
TglLahir time.Time `json:"tgl_lahir"`
|
|
Kelamin int `json:"kelamin"`
|
|
Kebangsaan *string `json:"kebangsaan"` // Nullable string
|
|
Agama *int `json:"agama"` // Assuming Agama is an enum, and you'll convert from string to enum ID
|
|
Suku *string `json:"suku"` // Nullable string
|
|
Pendidikan *int `json:"pendidikan"` // Nullable int
|
|
Pekerjaan *int `json:"pekerjaan"` // Assuming Pekerjaan is an enum, and you'll convert from string to enum ID
|
|
HP *string `json:"hp"` // Nullable string, assume validation happens elsewhere
|
|
Email *string `json:"email"` // Nullable string
|
|
StatusNikah *int `json:"status_nikah"` // Assuming StatusKawin is an enum, and you'll convert from string to enum ID
|
|
Provinsi *string `json:"provinsi"` // Nullable string
|
|
Kabupaten *string `json:"kabupaten"` // Nullable string
|
|
Kecamatan *string `json:"kecamatan"` // Nullable string
|
|
Kelurahan *string `json:"kelurahan"` // Nullable string
|
|
Kodepos *string `json:"kodepos"` // Nullable string
|
|
NamaJalan *string `json:"namajalan"` // Nullable string
|
|
HPPenjamin *string `json:"hp_penjamin"` // Nullable string, assume validation happens elsewhere
|
|
NamaPenjamin *string `json:"namapenjamin"` // Nullable string
|
|
KTPPenjamin *string `json:"ktp_penjamin"` // Nullable string
|
|
HubunganPenjamin *int `json:"hubungan_penjamin"` // Nullable int
|
|
PendidikanPenjamin *int `json:"pendidikan_penjamin"` // Assuming Pendidikan is an enum, and you'll convert from string to enum ID
|
|
AlamatPenjamin *string `json:"alamat_penjamin"` // Nullable string
|
|
}
|
|
|
|
func FindValueByLabel(arr []EnumObject, s string) EnumObject {
|
|
idx := slices.IndexFunc(arr, func(c EnumObject) bool { return c.Label == s })
|
|
return arr[idx]
|
|
}
|