go_import_excel_pg/internal/excel.go
2024-03-06 09:15:08 +07:00

84 lines
3.4 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"},
}
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]
}