fix import patient
This commit is contained in:
parent
1db9d43b64
commit
3e6f91f0ab
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
don't look at the patient repository
|
||||||
|
it's only psycho who does that,
|
||||||
|
should've just update everything from the payload
|
@ -2,6 +2,7 @@ package repository
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.nochill.in/nochill/excel_import_playground/model"
|
"git.nochill.in/nochill/excel_import_playground/model"
|
||||||
"github.com/jackc/pgx/v5"
|
"github.com/jackc/pgx/v5"
|
||||||
@ -22,11 +23,10 @@ func (q *Queries) CreateAlamat(ctx context.Context, arg model.Alamat) (model.Ala
|
|||||||
rw,
|
rw,
|
||||||
no_hp,
|
no_hp,
|
||||||
no_telpon,
|
no_telpon,
|
||||||
pasen_id,
|
pasien_id,
|
||||||
status,
|
status,
|
||||||
created_at,
|
updated_at
|
||||||
updated_at,
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
|
||||||
) VALUES ($1,, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
|
||||||
RETURNING *
|
RETURNING *
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -45,6 +45,7 @@ func (q *Queries) CreateAlamat(ctx context.Context, arg model.Alamat) (model.Ala
|
|||||||
arg.No_telpon,
|
arg.No_telpon,
|
||||||
arg.Pasien_id,
|
arg.Pasien_id,
|
||||||
arg.Status,
|
arg.Status,
|
||||||
|
time.Now().UTC(),
|
||||||
)
|
)
|
||||||
|
|
||||||
result, err := pgx.CollectExactlyOneRow[model.Alamat](row, pgx.RowToStructByName[model.Alamat])
|
result, err := pgx.CollectExactlyOneRow[model.Alamat](row, pgx.RowToStructByName[model.Alamat])
|
||||||
|
@ -21,7 +21,7 @@ func (q *Queries) CreateKeluarga(ctx context.Context, arg model.Keluarga) (model
|
|||||||
jenis_kelamin,
|
jenis_kelamin,
|
||||||
pendidikan,
|
pendidikan,
|
||||||
pekerjaan,
|
pekerjaan,
|
||||||
email,
|
email
|
||||||
) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
|
) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package repository
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ func (q *Queries) FindLastPatientInCertainFasyankes(ctx context.Context, fasyank
|
|||||||
LIMIT(1)
|
LIMIT(1)
|
||||||
`
|
`
|
||||||
row, _ := q.db.Query(ctx, findLastPasienQuery, fasyankes_id)
|
row, _ := q.db.Query(ctx, findLastPasienQuery, fasyankes_id)
|
||||||
result, err := pgx.CollectExactlyOneRow[model.Patient](row, pgx.RowToStructByName[model.Patient])
|
result, err := pgx.CollectOneRow[model.Patient](row, pgx.RowToStructByName[model.Patient])
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +180,36 @@ func (q *Queries) UpdatePatientNik(ctx context.Context, nik *string, patientId i
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) CreatePatient(ctx context.Context, arg model.Patient) (model.Patient, error) {
|
type createPatientParams struct {
|
||||||
|
NoRm string `json:"no_rm" db:"no_rm"`
|
||||||
|
NamaPasien string `json:"nama_pasien" db:"nama_pasien"`
|
||||||
|
JenisIdentitas pgtype.Int4 `json:"jenis_identitas" db:"jenis_identitas"`
|
||||||
|
NoIdentitas pgtype.Text `json:"no_identitas" db:"no_identitas"`
|
||||||
|
FotoProfil pgtype.Text `json:"foto_profil" db:"foto_profil"`
|
||||||
|
FotoKtp pgtype.Text `json:"foto_ktp" db:"foto_ktp"`
|
||||||
|
KotaLahir pgtype.Int4 `json:"kota_lahir" db:"kota_lahir"`
|
||||||
|
TanggalLahir time.Time `json:"tanggal_lahir" db:"tanggal_lahir"`
|
||||||
|
JenisKelamin int8 `json:"jenis_kelamin" db:"jenis_kelamin"`
|
||||||
|
Suku pgtype.Int4 `json:"suku" db:"suku"`
|
||||||
|
Agama pgtype.Int4 `json:"agama" db:"agama"`
|
||||||
|
Kebangsaan pgtype.Int4 `json:"kebangsaan" db:"kebangsaan"`
|
||||||
|
Bahasa pgtype.Int4 `json:"bahasa" db:"bahasa"`
|
||||||
|
Pendidikan pgtype.Int4 `json:"pendidikan" db:"pendidikan"`
|
||||||
|
StatusPerkawinan pgtype.Int4 `json:"status_perkawinan" db:"status_perkawinan"`
|
||||||
|
Email pgtype.Text `json:"email" db:"email"`
|
||||||
|
Pekerjaan pgtype.Int4 `json:"pekerjaan" db:"pekerjaan"`
|
||||||
|
NoHp pgtype.Text `json:"no_hp" db:"no_hp"`
|
||||||
|
IsDeleted bool `json:"is_deleted" db:"is_deleted"`
|
||||||
|
FasyankesID int `json:"fasyankes_id" db:"fasyankes_id"`
|
||||||
|
Nik pgtype.Text `json:"nik" db:"nik"`
|
||||||
|
NoKk pgtype.Text `json:"no_kk" db:"no_kk"`
|
||||||
|
NoKartuPesertaBPJS pgtype.Text `json:"no_kartu_peserta_bpjs" db:"no_kartu_peserta_bpjs"`
|
||||||
|
CreateBy int `json:"create_by" db:"create_by"`
|
||||||
|
UpdateBy int `json:"update_by" db:"update_by"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) CreatePatient(ctx context.Context, arg createPatientParams) (model.Patient, error) {
|
||||||
createPasienQuery := `
|
createPasienQuery := `
|
||||||
INSERT INTO "Pasien"(
|
INSERT INTO "Pasien"(
|
||||||
no_rm,
|
no_rm,
|
||||||
@ -206,8 +236,9 @@ func (q *Queries) CreatePatient(ctx context.Context, arg model.Patient) (model.P
|
|||||||
no_kk,
|
no_kk,
|
||||||
no_kartu_peserta_bpjs,
|
no_kartu_peserta_bpjs,
|
||||||
create_by,
|
create_by,
|
||||||
update_by
|
update_by,
|
||||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
|
updated_at
|
||||||
|
) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -237,7 +268,6 @@ func (q *Queries) CreatePatient(ctx context.Context, arg model.Patient) (model.P
|
|||||||
arg.NoKartuPesertaBPJS,
|
arg.NoKartuPesertaBPJS,
|
||||||
arg.CreateBy,
|
arg.CreateBy,
|
||||||
arg.UpdateBy,
|
arg.UpdateBy,
|
||||||
arg.CreatedAt,
|
|
||||||
arg.UpdatedAt,
|
arg.UpdatedAt,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -276,7 +306,7 @@ type ImportDataPasienParams struct {
|
|||||||
AlamatPenjamin pgtype.Text
|
AlamatPenjamin pgtype.Text
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *SQLStore) ImportPatientTx(ctx context.Context, params ImportDataPasienParams) 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
|
||||||
|
|
||||||
@ -298,7 +328,7 @@ func (store *SQLStore) ImportPatientTx(ctx context.Context, params ImportDataPas
|
|||||||
params.StatusNikah = &tempNilInt
|
params.StatusNikah = &tempNilInt
|
||||||
}
|
}
|
||||||
|
|
||||||
patient, err := q.CreatePatient(ctx, model.Patient{
|
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)},
|
Pendidikan: pgtype.Int4{Valid: params.Pendidikan != nil, Int32: int32(*params.Pendidikan)},
|
||||||
@ -312,6 +342,19 @@ func (store *SQLStore) ImportPatientTx(ctx context.Context, params ImportDataPas
|
|||||||
JenisKelamin: params.Kelamin,
|
JenisKelamin: params.Kelamin,
|
||||||
StatusPerkawinan: pgtype.Int4{Valid: params.StatusNikah != nil, Int32: int32(*params.StatusNikah)},
|
StatusPerkawinan: pgtype.Int4{Valid: params.StatusNikah != nil, Int32: int32(*params.StatusNikah)},
|
||||||
IsDeleted: false,
|
IsDeleted: false,
|
||||||
|
JenisIdentitas: pgtype.Int4{Valid: false, Int32: 0},
|
||||||
|
NoIdentitas: pgtype.Text{Valid: false, String: ""},
|
||||||
|
FotoProfil: pgtype.Text{Valid: false, String: ""},
|
||||||
|
FotoKtp: pgtype.Text{Valid: false, String: ""},
|
||||||
|
KotaLahir: pgtype.Int4{Valid: false, Int32: 0},
|
||||||
|
Suku: pgtype.Int4{Valid: false, Int32: 0},
|
||||||
|
Kebangsaan: pgtype.Int4{Valid: false, Int32: 0},
|
||||||
|
Bahasa: pgtype.Int4{Valid: false, Int32: 0},
|
||||||
|
FasyankesID: int(fasyankesId),
|
||||||
|
CreateBy: int(createdBy),
|
||||||
|
UpdateBy: int(createdBy),
|
||||||
|
NoKk: pgtype.Text{Valid: false, String: ""},
|
||||||
|
UpdatedAt: time.Now().UTC(),
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -323,7 +366,9 @@ func (store *SQLStore) ImportPatientTx(ctx context.Context, params ImportDataPas
|
|||||||
provinsi, err := q.FindWilayahByName(ctx, *params.Provinsi)
|
provinsi, err := q.FindWilayahByName(ctx, *params.Provinsi)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
if err != pgx.ErrNoRows {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if provinsi.Id == 0 {
|
if provinsi.Id == 0 {
|
||||||
@ -336,6 +381,17 @@ func (store *SQLStore) ImportPatientTx(ctx context.Context, params ImportDataPas
|
|||||||
Provinsi: provinsi_id,
|
Provinsi: provinsi_id,
|
||||||
Nama_jalan: ¶ms.NamaJalan.String,
|
Nama_jalan: ¶ms.NamaJalan.String,
|
||||||
Pasien_id: int32(patient.ID),
|
Pasien_id: int32(patient.ID),
|
||||||
|
Kategori: nil,
|
||||||
|
Negara: nil,
|
||||||
|
Kabupaten: nil,
|
||||||
|
Kecamatan: nil,
|
||||||
|
Kelurahan: nil,
|
||||||
|
Kode_pos: nil,
|
||||||
|
Rt: nil,
|
||||||
|
Rw: nil,
|
||||||
|
No_hp: nil,
|
||||||
|
No_telpon: nil,
|
||||||
|
Status: nil,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -378,14 +434,18 @@ func genNoRm(lastNoRm *string) string {
|
|||||||
if lastNoRm != nil {
|
if lastNoRm != nil {
|
||||||
tempNoRm = *lastNoRm
|
tempNoRm = *lastNoRm
|
||||||
} else {
|
} else {
|
||||||
tempNoRm = "1"
|
tempNoRm = "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
length := strings.IndexFunc(tempNoRm, func(r rune) bool {
|
length := strings.IndexFunc(tempNoRm, func(r rune) bool {
|
||||||
return r != '0'
|
return r != '0'
|
||||||
})
|
})
|
||||||
|
|
||||||
return util.Pad(tempNoRm, int32(length))
|
if lastNoRm == nil {
|
||||||
}
|
length = 6
|
||||||
|
}
|
||||||
|
|
||||||
// func FindPatientBy
|
tempNoRmNum, _ := strconv.ParseInt(tempNoRm, 10, 32)
|
||||||
|
|
||||||
|
return util.PadWithZeros(int(tempNoRmNum)+1, int(length))
|
||||||
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
type Store interface {
|
type Store interface {
|
||||||
Querier
|
Querier
|
||||||
ImportPatientTx(ctx context.Context, params ImportDataPasienParams) error
|
ImportPatientTx(ctx context.Context, params ImportDataPasienParams, createdBy int32, fasyankesId int32) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type SQLStore struct {
|
type SQLStore struct {
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
func (q *Queries) FindWilayahByName(ctx context.Context, name string) (model.Wilayah, error) {
|
func (q *Queries) FindWilayahByName(ctx context.Context, name string) (model.Wilayah, error) {
|
||||||
findWilayaByNameQuery := `
|
findWilayaByNameQuery := `
|
||||||
SELECT * FROM "Wilayah"
|
SELECT * FROM "Wilayah"
|
||||||
WHERE NamaWilayah = $1
|
WHERE nama_wilayah = $1
|
||||||
`
|
`
|
||||||
|
|
||||||
row, _ := q.db.Query(ctx, findWilayaByNameQuery, name)
|
row, _ := q.db.Query(ctx, findWilayaByNameQuery, name)
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"git.nochill.in/nochill/excel_import_playground/internal/repository"
|
"git.nochill.in/nochill/excel_import_playground/internal/repository"
|
||||||
"git.nochill.in/nochill/excel_import_playground/util"
|
"git.nochill.in/nochill/excel_import_playground/util"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
"github.com/xuri/excelize/v2"
|
"github.com/xuri/excelize/v2"
|
||||||
)
|
)
|
||||||
@ -139,12 +140,14 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
patientExist, err := repository.Store.FindPatientByNoRm(s.Store, r.Context(), value.NoRekamMedis)
|
patientExist, err := repository.Store.FindPatientByNoRm(s.Store, r.Context(), value.NoRekamMedis)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorMsg = append(errorMsg, map[string]any{
|
if err != pgx.ErrNoRows {
|
||||||
"no_rm": value.NoRekamMedis,
|
errorMsg = append(errorMsg, map[string]any{
|
||||||
"status": "CRITICAL",
|
"no_rm": value.NoRekamMedis,
|
||||||
"message": fmt.Sprintf("Terjadi kesalahan sistem, mencari data pasien %v", err),
|
"status": "CRITICAL",
|
||||||
})
|
"message": fmt.Sprintf("Terjadi kesalahan sistem, mencari data pasien %v", err),
|
||||||
continue
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if patientExist.NoRm != "" {
|
if patientExist.NoRm != "" {
|
||||||
@ -173,11 +176,13 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
patient, err := repository.Store.FindPatientByNik(s.Store, r.Context(), value.Nik.String)
|
patient, err := repository.Store.FindPatientByNik(s.Store, r.Context(), value.Nik.String)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorMsg = append(errorMsg, map[string]any{
|
if err != pgx.ErrNoRows {
|
||||||
"no_rm": value.NoRekamMedis,
|
errorMsg = append(errorMsg, map[string]any{
|
||||||
"status": "CRITICAL",
|
"no_rm": value.NoRekamMedis,
|
||||||
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal mendapatakan data pasien %v", err),
|
"status": "CRITICAL",
|
||||||
})
|
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal mendapatakan data pasien %v", err),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if value.Nik.String == patient.Nik.String {
|
if value.Nik.String == patient.Nik.String {
|
||||||
@ -200,7 +205,7 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
errorMsg = append(errorMsg, map[string]any{
|
errorMsg = append(errorMsg, map[string]any{
|
||||||
"no_rm": value.NoRekamMedis,
|
"no_rm": value.NoRekamMedis,
|
||||||
"status": "WARNING",
|
"status": "WARNING",
|
||||||
"message": fmt.Sprintf("NIK kembar dengan pasien: %s, mohon dicek kembali current user: %v", patient.NoRm, value),
|
"message": fmt.Sprintf("NIK kembar dengan pasien yang ada di sistem noRm: %s %s, mohon dicek kembali current user: %v"),
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -212,11 +217,13 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
patient, err := repository.Store.FindPatientByBPJSCode(s.Store, r.Context(), value.NoBPJS.String)
|
patient, err := repository.Store.FindPatientByBPJSCode(s.Store, r.Context(), value.NoBPJS.String)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorMsg = append(errorMsg, map[string]any{
|
if err != pgx.ErrNoRows {
|
||||||
"no_rm": value.NoRekamMedis,
|
errorMsg = append(errorMsg, map[string]any{
|
||||||
"status": "CRITICAL",
|
"no_rm": value.NoRekamMedis,
|
||||||
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal mendapatakan data pasien dengan BPJS %v", err),
|
"status": "CRITICAL",
|
||||||
})
|
"message": fmt.Sprintf("Terjadi kesalahan sistem, gagal mendapatakan data pasien dengan BPJS %v", err),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if patient.ID != 0 {
|
if patient.ID != 0 {
|
||||||
@ -243,14 +250,16 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
errorMsg = append(errorMsg, map[string]any{
|
errorMsg = append(errorMsg, map[string]any{
|
||||||
"no_rm": value.NoRekamMedis,
|
"no_rm": value.NoRekamMedis,
|
||||||
"status": "WARNING",
|
"status": "WARNING",
|
||||||
"message": fmt.Sprintf("No KartuBPJS ada yang sama dengan pasien: %s, mohon dicek kembali. current user: %v", patient.NoRm, value),
|
"message": fmt.Sprintf("No KartuBPJS ada yang sama dengan pasien dengan no rm yang ada di sistem: noRm: %s noBpjs: %s, mohon dicek kembali, NO BPJS pasien import: %s",
|
||||||
|
patient.NoRm, patient.NoKartuPesertaBPJS.String, value.NoBPJS.String,
|
||||||
|
),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repository.Store.ImportPatientTx(s.Store, r.Context(), value)
|
err = repository.Store.ImportPatientTx(s.Store, r.Context(), value, int32(currentUser.UserId), int32(currentUser.FasyankesId))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorMsg = append(errorMsg, map[string]any{
|
errorMsg = append(errorMsg, map[string]any{
|
||||||
@ -274,12 +283,15 @@ func (s *Server) ImportPatientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
a := map[string]any{
|
a := map[string]any{
|
||||||
"halo": "halo",
|
"halo": "halo",
|
||||||
|
"file": "foo.txt",
|
||||||
|
|
||||||
// "contentType": contentType,
|
// "contentType": contentType,
|
||||||
// "patient": tempArr,
|
// "patient": tempArr,
|
||||||
"errorData": errorMsg,
|
// "errorData": errorMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.WriteHeader(200)
|
||||||
|
|
||||||
json.NewEncoder(w).Encode(a)
|
json.NewEncoder(w).Encode(a)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ type Alamat struct {
|
|||||||
Rw *string `json:"rw,omitempty"`
|
Rw *string `json:"rw,omitempty"`
|
||||||
No_hp *string `json:"no_hp,omitempty"`
|
No_hp *string `json:"no_hp,omitempty"`
|
||||||
No_telpon *string `json:"no_telpon,omitempty"`
|
No_telpon *string `json:"no_telpon,omitempty"`
|
||||||
Pasien_id int32 `json:"pasen_id"`
|
Pasien_id int32 `json:"pasien_id"`
|
||||||
Status *bool `json:"status,omitempty"`
|
Status *bool `json:"status,omitempty"`
|
||||||
Created_at time.Time `json:"created_at"`
|
Created_at time.Time `json:"created_at"`
|
||||||
Updated_at time.Time `json:"updated_at"`
|
Updated_at time.Time `json:"updated_at"`
|
||||||
|
@ -44,10 +44,13 @@ func StringToStringPtr(s string) *string {
|
|||||||
return &s
|
return &s
|
||||||
}
|
}
|
||||||
|
|
||||||
func Pad(numStr string, size int32) string {
|
func PadWithZeros(number int, zerosCount int) string {
|
||||||
for int32(len(numStr)) < size {
|
numStr := strconv.Itoa(number)
|
||||||
numStr = "0" + numStr
|
|
||||||
|
padding := ""
|
||||||
|
for i := 0; i < zerosCount; i++ {
|
||||||
|
padding += "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
return numStr
|
return padding + numStr
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user