feat(cpone): support company patient fields
This commit is contained in:
@@ -51,6 +51,10 @@ Contoh payload pembuatan pasien HIS:
|
||||
"kecamatan": "KECAMATAN CONTOH",
|
||||
"kelurahan": "KELURAHAN CONTOH",
|
||||
"kode_pos": "12345",
|
||||
"perusahaan_id": "PE260700001",
|
||||
"nik_karyawan": "TSB2026002",
|
||||
"dependant_id": "D001",
|
||||
"nama_karyawan": "BUDI SANTOS",
|
||||
"channel": "CPONE"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -155,6 +155,18 @@ func validateMedrec(payload map[string]any) (repository.MedrecParams, string) {
|
||||
if message != "" {
|
||||
return repository.MedrecParams{}, message
|
||||
}
|
||||
employeeID, message := optionalMedrecString(payload, "nik_karyawan", 50)
|
||||
if message != "" {
|
||||
return repository.MedrecParams{}, message
|
||||
}
|
||||
dependantID, message := optionalMedrecString(payload, "dependant_id", 4)
|
||||
if message != "" {
|
||||
return repository.MedrecParams{}, message
|
||||
}
|
||||
employeeName, message := optionalMedrecString(payload, "nama_karyawan", 100)
|
||||
if message != "" {
|
||||
return repository.MedrecParams{}, message
|
||||
}
|
||||
channel, channelPresent, message := optionalString(payload, "channel", 50)
|
||||
if message != "" {
|
||||
return repository.MedrecParams{}, message
|
||||
@@ -196,6 +208,9 @@ func validateMedrec(payload map[string]any) (repository.MedrecParams, string) {
|
||||
Village: strings.TrimSpace(village),
|
||||
PostalCode: strings.TrimSpace(postalCode),
|
||||
CompanyID: strings.TrimSpace(companyID),
|
||||
EmployeeID: strings.TrimSpace(employeeID),
|
||||
DependantID: strings.TrimSpace(dependantID),
|
||||
EmployeeName: strings.TrimSpace(employeeName),
|
||||
Channel: normalizeText(channel),
|
||||
}, ""
|
||||
}
|
||||
|
||||
@@ -66,6 +66,10 @@ func TestStoreMedrecValidPayloadAndCreatedResponseParity(t *testing.T) {
|
||||
"kecamatan":" KECAMATAN CONTOH ",
|
||||
"kelurahan":" KELURAHAN CONTOH ",
|
||||
"kode_pos":" 12345 ",
|
||||
"perusahaan_id":" PE260700001 ",
|
||||
"nik_karyawan":" TSB2026002 ",
|
||||
"dependant_id":"D001",
|
||||
"nama_karyawan":" Budi Santos ",
|
||||
"channel":" cpone "
|
||||
}`
|
||||
|
||||
@@ -93,6 +97,9 @@ func TestStoreMedrecValidPayloadAndCreatedResponseParity(t *testing.T) {
|
||||
if repo.params.Email != "budi@example.com" || repo.params.PlaceOfBirth != "JAKARTA" || repo.params.Channel != "CPONE" {
|
||||
t.Fatalf("text normalization mismatch: %+v", repo.params)
|
||||
}
|
||||
if repo.params.CompanyID != "PE260700001" || repo.params.EmployeeID != "TSB2026002" || repo.params.DependantID != "D001" || repo.params.EmployeeName != "Budi Santos" {
|
||||
t.Fatalf("company patient fields mismatch: %+v", repo.params)
|
||||
}
|
||||
if repo.params.DateOfBirth.Format("2006-01-02") != "1990-01-15" {
|
||||
t.Fatalf("birth date mismatch: %s", repo.params.DateOfBirth)
|
||||
}
|
||||
@@ -125,6 +132,7 @@ func TestStoreMedrecValidationParity(t *testing.T) {
|
||||
{name: "missing phone", mutate: func(p map[string]any) { delete(p, "telepon") }, message: "Telepon atau ponsel wajib diisi"},
|
||||
{name: "invalid email", mutate: func(p map[string]any) { p["email"] = "invalid" }, message: "The email must be a valid email address."},
|
||||
{name: "long hospital code", mutate: func(p map[string]any) { p["rs"] = strings.Repeat("X", 21) }, message: "The rs must not be greater than 20 characters."},
|
||||
{name: "long dependant id", mutate: func(p map[string]any) { p["dependant_id"] = "D0001" }, message: "The dependant id must not be greater than 4 characters."},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
@@ -26,6 +26,9 @@ type MedrecParams struct {
|
||||
Village string
|
||||
PostalCode string
|
||||
CompanyID string
|
||||
EmployeeID string
|
||||
DependantID string
|
||||
EmployeeName string
|
||||
Channel string
|
||||
}
|
||||
|
||||
@@ -235,10 +238,6 @@ func insertMedrec(ctx context.Context, tx *sql.Tx, medrecID string, params Medre
|
||||
if mobile == "" {
|
||||
mobile = params.Phone
|
||||
}
|
||||
var nik any
|
||||
if params.IdentityType == "KTP" {
|
||||
nik = params.IdentityNumber
|
||||
}
|
||||
firstName := params.Name
|
||||
if index := strings.IndexByte(params.Name, ' '); index >= 0 {
|
||||
firstName = params.Name[:index]
|
||||
@@ -252,14 +251,16 @@ func insertMedrec(ctx context.Context, tx *sql.Tx, medrecID string, params Medre
|
||||
_, err = tx.ExecContext(ctx, `
|
||||
INSERT INTO medrec (
|
||||
MEDRECID, KodeRS, Nama, Panggilan, Kelamin, TanggalLahir, TempatLahir,
|
||||
JenisNomerSosial, NomerSosial, NIK, Telepon, Ponsel, Email, Alamat,
|
||||
Propinsi, Kota, Kecamatan, Kelurahan, KodePos, PerusahaanID,
|
||||
JenisNomerSosial, NomerSosial, NIK, DependantID, NamaKaryawan,
|
||||
Telepon, Ponsel, Email, Alamat, Propinsi, Kota, Kecamatan, Kelurahan,
|
||||
KodePos, PerusahaanID,
|
||||
Mati, NA, LoginBuat, TanggalBuat, TanggalEdit
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'N', 'N', ?, ?, ?)`,
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'N', 'N', ?, ?, ?)`,
|
||||
medrecID, params.HospitalCode, params.Name, firstName, params.Gender,
|
||||
params.DateOfBirth.Format("2006-01-02"), params.PlaceOfBirth,
|
||||
params.IdentityType, params.IdentityNumber, nik, phone, mobile, params.Email,
|
||||
params.Address, params.Province, params.City, params.District, params.Village,
|
||||
params.IdentityType, params.IdentityNumber, params.EmployeeID, params.DependantID,
|
||||
params.EmployeeName, phone, mobile, params.Email, params.Address, params.Province,
|
||||
params.City, params.District, params.Village,
|
||||
params.PostalCode, params.CompanyID, params.Channel, now, now)
|
||||
if err != nil {
|
||||
return MedrecPatient{}, err
|
||||
|
||||
Reference in New Issue
Block a user