adjust with new field
This commit is contained in:
parent
3e6f91f0ab
commit
d8da93fdb4
@ -48,59 +48,6 @@ var Pekerjaan = []EnumObject{
|
|||||||
{ID: 6, Label: "Lain-lain"},
|
{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 {
|
type Patient struct {
|
||||||
NoRekamMedis string `json:"no_rekammedis"`
|
NoRekamMedis string `json:"no_rekammedis"`
|
||||||
NamaPasien string `json:"nama_pasien"`
|
NamaPasien string `json:"nama_pasien"`
|
||||||
|
@ -279,81 +279,48 @@ func (q *Queries) CreatePatient(ctx context.Context, arg createPatientParams) (m
|
|||||||
type ImportDataPasienParams struct {
|
type ImportDataPasienParams struct {
|
||||||
NoRekamMedis string
|
NoRekamMedis string
|
||||||
NamaPasien string
|
NamaPasien string
|
||||||
Nik pgtype.Text
|
NoKTP pgtype.Text
|
||||||
NoBPJS pgtype.Text
|
NoBPJS pgtype.Text
|
||||||
TpLahir pgtype.Text
|
TempatLahir pgtype.Int4
|
||||||
TglLahir time.Time
|
TglLahir time.Time
|
||||||
Kelamin int8
|
Kelamin int8
|
||||||
Kebangsaan *int8
|
Kebangsaan pgtype.Int4
|
||||||
Agama *int8
|
Agama pgtype.Int4
|
||||||
Suku *int32
|
Suku pgtype.Int4
|
||||||
Pendidikan *int8
|
Pendidikan pgtype.Int4
|
||||||
Pekerjaan *int8
|
Pekerjaan pgtype.Int4
|
||||||
Hp pgtype.Text
|
Hp pgtype.Text
|
||||||
Email pgtype.Text
|
Email pgtype.Text
|
||||||
StatusNikah *int8
|
StatusKawin pgtype.Int4
|
||||||
Provinsi *string
|
Provinsi pgtype.Text
|
||||||
Kabupaten *int32
|
|
||||||
Kecamatan *int32
|
|
||||||
Kelurahan *int32
|
|
||||||
Kodepos *int32
|
|
||||||
NamaJalan pgtype.Text
|
NamaJalan pgtype.Text
|
||||||
HpPenjamin pgtype.Text
|
|
||||||
NamaPenjamin pgtype.Text
|
NamaPenjamin pgtype.Text
|
||||||
KtpPenjamin pgtype.Text
|
NikPenjamin pgtype.Text
|
||||||
HubunganPenjamin *int8
|
HubunganPenjamin pgtype.Int2
|
||||||
PendidikanPenjamin *int8
|
HpPenjamin pgtype.Text
|
||||||
AlamatPenjamin pgtype.Text
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *SQLStore) ImportPatientTx(ctx context.Context, params ImportDataPasienParams, createdBy int32, fasyankesId int32) error {
|
func (store *SQLStore) ImportPatientTx(ctx context.Context, params ImportDataPasienParams, createdBy int32, fasyankesId int32) error {
|
||||||
err := store.execTx(ctx, func(q *Queries) error {
|
err := store.execTx(ctx, func(q *Queries) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
tempNilInt := int8(util.NilIntVal)
|
|
||||||
|
|
||||||
if params.Pendidikan == nil {
|
|
||||||
params.Pendidikan = &tempNilInt
|
|
||||||
}
|
|
||||||
|
|
||||||
if params.Agama == nil {
|
|
||||||
params.Agama = &tempNilInt
|
|
||||||
}
|
|
||||||
|
|
||||||
if params.Pekerjaan == nil {
|
|
||||||
params.Pekerjaan = &tempNilInt
|
|
||||||
}
|
|
||||||
|
|
||||||
if params.StatusNikah == nil {
|
|
||||||
params.StatusNikah = &tempNilInt
|
|
||||||
}
|
|
||||||
|
|
||||||
patient, err := q.CreatePatient(ctx, createPatientParams{
|
patient, err := q.CreatePatient(ctx, createPatientParams{
|
||||||
NoRm: params.NoRekamMedis,
|
NoRm: params.NoRekamMedis,
|
||||||
NamaPasien: params.NamaPasien,
|
NamaPasien: params.NamaPasien,
|
||||||
Pendidikan: pgtype.Int4{Valid: params.Pendidikan != nil, Int32: int32(*params.Pendidikan)},
|
Nik: params.NoKTP,
|
||||||
TanggalLahir: params.TglLahir,
|
|
||||||
Nik: params.Nik,
|
|
||||||
Agama: pgtype.Int4{Valid: params.Agama != nil, Int32: int32(*params.Agama)},
|
|
||||||
NoHp: params.Hp,
|
|
||||||
Pekerjaan: pgtype.Int4{Valid: params.Pekerjaan != nil, Int32: int32(*params.Agama)},
|
|
||||||
Email: params.Email,
|
|
||||||
NoKartuPesertaBPJS: params.NoBPJS,
|
NoKartuPesertaBPJS: params.NoBPJS,
|
||||||
|
KotaLahir: params.TempatLahir,
|
||||||
|
TanggalLahir: params.TglLahir,
|
||||||
JenisKelamin: params.Kelamin,
|
JenisKelamin: params.Kelamin,
|
||||||
StatusPerkawinan: pgtype.Int4{Valid: params.StatusNikah != nil, Int32: int32(*params.StatusNikah)},
|
Kebangsaan: params.Kebangsaan,
|
||||||
IsDeleted: false,
|
Agama: params.Agama,
|
||||||
JenisIdentitas: pgtype.Int4{Valid: false, Int32: 0},
|
Suku: params.Suku,
|
||||||
NoIdentitas: pgtype.Text{Valid: false, String: ""},
|
Pendidikan: params.Pendidikan,
|
||||||
FotoProfil: pgtype.Text{Valid: false, String: ""},
|
Pekerjaan: params.Pekerjaan,
|
||||||
FotoKtp: pgtype.Text{Valid: false, String: ""},
|
NoHp: params.Hp,
|
||||||
KotaLahir: pgtype.Int4{Valid: false, Int32: 0},
|
Email: params.Email,
|
||||||
Suku: pgtype.Int4{Valid: false, Int32: 0},
|
StatusPerkawinan: params.StatusKawin,
|
||||||
Kebangsaan: pgtype.Int4{Valid: false, Int32: 0},
|
|
||||||
Bahasa: pgtype.Int4{Valid: false, Int32: 0},
|
|
||||||
FasyankesID: int(fasyankesId),
|
FasyankesID: int(fasyankesId),
|
||||||
CreateBy: int(createdBy),
|
|
||||||
UpdateBy: int(createdBy),
|
|
||||||
NoKk: pgtype.Text{Valid: false, String: ""},
|
|
||||||
UpdatedAt: time.Now().UTC(),
|
UpdatedAt: time.Now().UTC(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -363,7 +330,7 @@ func (store *SQLStore) ImportPatientTx(ctx context.Context, params ImportDataPas
|
|||||||
|
|
||||||
if params.NamaJalan.Valid {
|
if params.NamaJalan.Valid {
|
||||||
var provinsi_id *int32
|
var provinsi_id *int32
|
||||||
provinsi, err := q.FindWilayahByName(ctx, *params.Provinsi)
|
provinsi, err := q.FindWilayahByName(ctx, params.Provinsi.String)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != pgx.ErrNoRows {
|
if err != pgx.ErrNoRows {
|
||||||
@ -400,10 +367,10 @@ func (store *SQLStore) ImportPatientTx(ctx context.Context, params ImportDataPas
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if params.HubunganPenjamin != nil && params.NamaPenjamin.Valid {
|
if params.HubunganPenjamin.Valid && params.NamaPenjamin.Valid {
|
||||||
_, err = q.CreateKeluarga(ctx, model.Keluarga{
|
_, err = q.CreateKeluarga(ctx, model.Keluarga{
|
||||||
Id: int32(patient.ID),
|
Id: int32(patient.ID),
|
||||||
Nama: ¶ms.NamaPenjamin.String,
|
Nama: params.NamaPenjamin,
|
||||||
Hubungan: params.HubunganPenjamin,
|
Hubungan: params.HubunganPenjamin,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
rows, err := f.GetRows("import data pasien")
|
rows, err := f.GetRows("PRODUCTION Pasien Setio")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
json.NewEncoder(w).Encode(err)
|
json.NewEncoder(w).Encode(err)
|
||||||
@ -78,17 +78,19 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// tempArr := make([]repository.ImportDataPasienParams, len(rows)-1)
|
// tempArr := make([]repository.ImportDataPasienParams, len(rows)-1)
|
||||||
var errorMsg []interface{}
|
var errorMsg []interface{}
|
||||||
|
// var wg = &sync.WaitGroup{}
|
||||||
|
|
||||||
for idx, row := range rows {
|
for idx, row := range rows {
|
||||||
|
// wg.Add(1)
|
||||||
|
// go func(idx int, row []string) {
|
||||||
if idx >= 1 {
|
if idx >= 1 {
|
||||||
|
|
||||||
if row[0] == "" || row[1] == "" {
|
if row[0] == "" || row[1] == "" {
|
||||||
errorMsg = append(errorMsg, map[string]any{
|
errorMsg = append(errorMsg, map[string]any{
|
||||||
"baris": idx + 1,
|
"baris": idx + 1,
|
||||||
"status": "CRITICAL",
|
"status": "CRITICAL",
|
||||||
"error_message": "kolom A 'no_rekam medis' dan kolom B 'nama_pasien' wajib diisi",
|
"error_message": "kolom A 'no_rekam medis' dan kolom B 'nama_pasien' wajib diisi",
|
||||||
})
|
})
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tanggalLahir, err := time.Parse(util.TIME_PARSE_LAYOUT, row[5])
|
tanggalLahir, err := time.Parse(util.TIME_PARSE_LAYOUT, row[5])
|
||||||
@ -98,43 +100,37 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
"status": "CRITICAL",
|
"status": "CRITICAL",
|
||||||
"error_message": "tanggal lahir wajib diisi",
|
"error_message": "tanggal lahir wajib diisi",
|
||||||
})
|
})
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
kelamin, err := strconv.Atoi(row[6])
|
kelamin, err := strconv.Atoi(row[6])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("row 6: %s, err: %v", row[6], err)
|
log.Printf("row 6: %s, err: %v", row[6], err)
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
value := repository.ImportDataPasienParams{
|
value := repository.ImportDataPasienParams{
|
||||||
NoRekamMedis: row[0],
|
NoRekamMedis: row[0],
|
||||||
NamaPasien: row[1],
|
NamaPasien: row[1],
|
||||||
Nik: pgtype.Text{String: row[2], Valid: len(row[2]) > 0},
|
NoKTP: pgtype.Text{String: row[2], Valid: len(row[2]) > 0},
|
||||||
NoBPJS: pgtype.Text{String: row[3], Valid: len(row[3]) > 0},
|
NoBPJS: pgtype.Text{String: row[3], Valid: len(row[3]) > 0},
|
||||||
TpLahir: pgtype.Text{String: row[4], Valid: len(row[4]) > 0},
|
TempatLahir: pgtype.Int4{Int32: 0, Valid: false},
|
||||||
TglLahir: tanggalLahir,
|
TglLahir: tanggalLahir,
|
||||||
Kelamin: int8(kelamin),
|
Kelamin: int8(kelamin),
|
||||||
Kebangsaan: util.StringToIntPtr[int8](row[6]),
|
Kebangsaan: pgtype.Int4{Int32: util.StringToInt[int32](row[7]), Valid: util.StringToInt[int32](row[7]) > 0},
|
||||||
Agama: util.StringToIntPtr[int8](row[7]),
|
Agama: pgtype.Int4{Int32: util.StringToInt[int32](row[8]), Valid: util.StringToInt[int32](row[8]) > 0},
|
||||||
Suku: util.StringToIntPtr[int32](row[8]),
|
Suku: pgtype.Int4{Int32: util.StringToInt[int32](row[9]), Valid: util.StringToInt[int32](row[9]) > 0},
|
||||||
Pendidikan: util.StringToIntPtr[int8](row[9]),
|
Pendidikan: pgtype.Int4{Int32: util.StringToInt[int32](row[10]), Valid: util.StringToInt[int32](row[10]) > 0},
|
||||||
Pekerjaan: util.StringToIntPtr[int8](row[10]),
|
Pekerjaan: pgtype.Int4{Int32: util.StringToInt[int32](row[11]), Valid: util.StringToInt[int32](row[11]) > 0},
|
||||||
Hp: pgtype.Text{String: row[11], Valid: len(row[11]) > 0},
|
Hp: pgtype.Text{String: row[12], Valid: len(row[12]) > 0},
|
||||||
Email: pgtype.Text{String: row[12], Valid: len(row[12]) > 0},
|
Email: pgtype.Text{String: row[13], Valid: len(row[13]) > 0},
|
||||||
StatusNikah: util.StringToIntPtr[int8](row[13]),
|
StatusKawin: pgtype.Int4{Int32: util.StringToInt[int32](row[14]), Valid: util.StringToInt[int32](row[14]) > 0},
|
||||||
Provinsi: util.StringToStringPtr(row[14]),
|
Provinsi: pgtype.Text{String: row[15], Valid: len(row[15]) > 0},
|
||||||
Kabupaten: util.StringToIntPtr[int32](row[15]),
|
NamaJalan: pgtype.Text{String: row[16], Valid: len(row[16]) > 0},
|
||||||
Kecamatan: util.StringToIntPtr[int32](row[16]),
|
NamaPenjamin: pgtype.Text{String: row[17], Valid: len(row[17]) > 0},
|
||||||
Kelurahan: util.StringToIntPtr[int32](row[17]),
|
NikPenjamin: pgtype.Text{String: row[18], Valid: len(row[18]) > 0},
|
||||||
Kodepos: util.StringToIntPtr[int32](row[18]),
|
HubunganPenjamin: pgtype.Int2{Int16: util.StringToInt[int16](row[8]), Valid: util.StringToInt[int16](row[8]) > 0},
|
||||||
NamaJalan: pgtype.Text{String: row[19], Valid: len(row[19]) > 0},
|
|
||||||
HpPenjamin: pgtype.Text{String: row[20], Valid: len(row[20]) > 0},
|
HpPenjamin: pgtype.Text{String: row[20], Valid: len(row[20]) > 0},
|
||||||
NamaPenjamin: pgtype.Text{String: row[21], Valid: len(row[21]) > 0},
|
|
||||||
KtpPenjamin: pgtype.Text{String: row[22], Valid: len(row[22]) > 0},
|
|
||||||
HubunganPenjamin: util.StringToIntPtr[int8](row[23]),
|
|
||||||
PendidikanPenjamin: util.StringToIntPtr[int8](row[24]),
|
|
||||||
AlamatPenjamin: pgtype.Text{String: row[25], Valid: len(row[25]) > 0},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
patientExist, err := repository.Store.FindPatientByNoRm(s.Store, r.Context(), value.NoRekamMedis)
|
patientExist, err := repository.Store.FindPatientByNoRm(s.Store, r.Context(), value.NoRekamMedis)
|
||||||
@ -146,7 +142,7 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
"status": "CRITICAL",
|
"status": "CRITICAL",
|
||||||
"message": fmt.Sprintf("Terjadi kesalahan sistem, mencari data pasien %v", err),
|
"message": fmt.Sprintf("Terjadi kesalahan sistem, mencari data pasien %v", err),
|
||||||
})
|
})
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +155,7 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
"status": "CRITICAL",
|
"status": "CRITICAL",
|
||||||
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal generate NoRM %v", err),
|
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal generate NoRM %v", err),
|
||||||
})
|
})
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
errorMsg = append(errorMsg, map[string]any{
|
errorMsg = append(errorMsg, map[string]any{
|
||||||
@ -172,8 +168,8 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if value.Nik.Valid {
|
if value.NoKTP.Valid {
|
||||||
patient, err := repository.Store.FindPatientByNik(s.Store, r.Context(), value.Nik.String)
|
patient, err := repository.Store.FindPatientByNik(s.Store, r.Context(), value.NoKTP.String)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != pgx.ErrNoRows {
|
if err != pgx.ErrNoRows {
|
||||||
@ -185,9 +181,9 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if value.Nik.String == patient.Nik.String {
|
if value.NoKTP.String == patient.Nik.String {
|
||||||
if patient.TanggalLahir.Before(value.TglLahir) {
|
if patient.TanggalLahir.Before(value.TglLahir) {
|
||||||
value.Nik.Valid = false
|
value.NoKTP.Valid = false
|
||||||
} else {
|
} else {
|
||||||
_, err := repository.Store.UpdatePatient(s.Store, r.Context(), repository.UpdatePatientParams{
|
_, err := repository.Store.UpdatePatient(s.Store, r.Context(), repository.UpdatePatientParams{
|
||||||
Nik: repository.UpdateableField[pgtype.Text]{IsFilled: true, Value: pgtype.Text{Valid: false, String: ""}},
|
Nik: repository.UpdateableField[pgtype.Text]{IsFilled: true, Value: pgtype.Text{Valid: false, String: ""}},
|
||||||
@ -199,7 +195,7 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal mendapatakan update pasien lama karena NIK sama %v", err),
|
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal mendapatakan update pasien lama karena NIK sama %v", err),
|
||||||
})
|
})
|
||||||
|
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
errorMsg = append(errorMsg, map[string]any{
|
errorMsg = append(errorMsg, map[string]any{
|
||||||
@ -246,7 +242,7 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal mendapatakan update pasien dengan BPJS %v", err),
|
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal mendapatakan update pasien dengan BPJS %v", err),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
errorMsg = append(errorMsg, map[string]any{
|
errorMsg = append(errorMsg, map[string]any{
|
||||||
@ -268,12 +264,16 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal saat import pasien dengan %v", err),
|
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal saat import pasien dengan %v", err),
|
||||||
})
|
})
|
||||||
|
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// wg.Done()
|
||||||
|
// }(idx, row)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wg.Wait()
|
||||||
|
|
||||||
if len(errorMsg) > 0 {
|
if len(errorMsg) > 0 {
|
||||||
jsonMarshal, _ := json.MarshalIndent(errorMsg, "", " ")
|
jsonMarshal, _ := json.MarshalIndent(errorMsg, "", " ")
|
||||||
if err := os.WriteFile("foo.txt", []byte(jsonMarshal), 0666); err != nil {
|
if err := os.WriteFile("foo.txt", []byte(jsonMarshal), 0666); err != nil {
|
||||||
|
2
main.go
2
main.go
@ -21,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
runtime.GOMAXPROCS(5)
|
runtime.GOMAXPROCS(2)
|
||||||
var wait time.Duration
|
var wait time.Duration
|
||||||
flag.DurationVar(&wait, "graceful-timeout", time.Second*15, "the duration for which the server gracefully wait for existing connections to finish - e.g. 15s or 1m")
|
flag.DurationVar(&wait, "graceful-timeout", time.Second*15, "the duration for which the server gracefully wait for existing connections to finish - e.g. 15s or 1m")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
|
)
|
||||||
|
|
||||||
type Keluarga struct {
|
type Keluarga struct {
|
||||||
Id int32 `json:"id"`
|
Id int32 `json:"id"`
|
||||||
PasienId int32 `json:"pasien_id"`
|
PasienId int32 `json:"pasien_id"`
|
||||||
Nama *string `json:"nama,omitempty"`
|
Nama pgtype.Text `json:"nama,omitempty"`
|
||||||
Hubungan *int8 `json:"hubungan,omitempty"`
|
Hubungan pgtype.Int2 `json:"hubungan,omitempty"`
|
||||||
NoIdentitas *string `json:"no_identitas,omitempty"`
|
NoIdentitas *string `json:"no_identitas,omitempty"`
|
||||||
NoHp *string `json:"no_hp,omitempty"`
|
NoHp *string `json:"no_hp,omitempty"`
|
||||||
KotaLahir *int32 `json:"kota_lahir,omitempty"`
|
KotaLahir *int32 `json:"kota_lahir,omitempty"`
|
||||||
|
@ -2,37 +2,43 @@ package util
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const TIME_PARSE_LAYOUT = "2/1/2006"
|
const TIME_PARSE_LAYOUT = "2/1/2006"
|
||||||
const NilIntVal = int8(0)
|
const NilIntVal = int8(0)
|
||||||
|
|
||||||
func StringToIntPtr[T int8 | int32 | int64](s string) *T {
|
func StringToInt[T int8 | int32 | int16 | int64](s string) T {
|
||||||
|
log.Println(s)
|
||||||
var val T
|
var val T
|
||||||
switch any(val).(type) {
|
if strings.TrimSpace(s) == "" {
|
||||||
case int8, int32, int64:
|
return 0
|
||||||
num, err := strconv.ParseInt(s, 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
switch any(val).(type) {
|
switch any(val).(type) {
|
||||||
|
case int8, int16, int32, int64:
|
||||||
|
num, _ := strconv.ParseInt(s, 10, 64)
|
||||||
|
switch any(val).(type) {
|
||||||
case int8:
|
case int8:
|
||||||
val := int8(num)
|
val := int8(num)
|
||||||
return any(&val).(*T)
|
return any(val).(T)
|
||||||
|
case int16:
|
||||||
|
val := int16(num)
|
||||||
|
return any(val).(T)
|
||||||
case int32:
|
case int32:
|
||||||
val := int32(num)
|
val := int32(num)
|
||||||
return any(&val).(*T)
|
return any(val).(T)
|
||||||
case int64:
|
case int64:
|
||||||
val := int64(num)
|
val := int64(num)
|
||||||
return any(&val).(*T)
|
return any(val).(T)
|
||||||
default:
|
default:
|
||||||
return nil
|
return 0
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
fmt.Printf("Unsupported type: %s\n", reflect.TypeOf(val).Name())
|
fmt.Printf("Unsupported type: %s\n", reflect.TypeOf(val).Name())
|
||||||
return nil
|
return 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user