feat(cpone): support company patient fields

This commit is contained in:
2026-08-23 19:38:46 +07:00
parent 30ddf25012
commit 4d02fc4dc9
4 changed files with 37 additions and 9 deletions

View File

@@ -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),
}, ""
}

View File

@@ -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 {