feat: support registration package data
This commit is contained in:
@@ -149,6 +149,32 @@ func validateRegistration(payload map[string]any, configuredDepartment string) (
|
||||
if !present || strings.TrimSpace(channel) == "" {
|
||||
channel = "CPONE"
|
||||
}
|
||||
referrer, _, message := optionalString(payload, "perujuk", 150)
|
||||
if message != "" {
|
||||
return repository.RegistrationParams{}, message
|
||||
}
|
||||
employeeID, _, message := optionalString(payload, "nik_karyawan", 100)
|
||||
if message != "" {
|
||||
return repository.RegistrationParams{}, message
|
||||
}
|
||||
employeeName, _, message := optionalString(payload, "nama_karyawan", 150)
|
||||
if message != "" {
|
||||
return repository.RegistrationParams{}, message
|
||||
}
|
||||
packageID, packagePresent, message := optionalString(payload, "kode_paket", 50)
|
||||
if message != "" {
|
||||
return repository.RegistrationParams{}, message
|
||||
}
|
||||
if !packagePresent || strings.TrimSpace(packageID) == "" {
|
||||
packageID, _, message = optionalString(payload, "paket_id", 50)
|
||||
if message != "" {
|
||||
return repository.RegistrationParams{}, message
|
||||
}
|
||||
}
|
||||
packageID = strings.ToUpper(strings.TrimSpace(packageID))
|
||||
if packageID != "" && !labIdentifier.MatchString(packageID) {
|
||||
return repository.RegistrationParams{}, "kode_paket hanya boleh berisi huruf, angka, dan tanda hubung"
|
||||
}
|
||||
|
||||
return repository.RegistrationParams{
|
||||
MedrecID: strings.TrimSpace(medrecID), NIK: normalizeIdentity(nik), BirthDate: birthDate,
|
||||
@@ -157,7 +183,7 @@ func validateRegistration(payload map[string]any, configuredDepartment string) (
|
||||
TariffPeriodID: tariffPeriod, CompanyID: strings.TrimSpace(companyID), InsuranceID: strings.TrimSpace(insuranceID),
|
||||
GroupTariffID: groupTariff, ProviderID: strings.TrimSpace(providerID), PolicyNumber: strings.TrimSpace(policyNumber),
|
||||
GuaranteeNumber: strings.TrimSpace(guaranteeNumber), EntryCode: strings.TrimSpace(entryCode), ClassID: strings.TrimSpace(classID),
|
||||
Notes: strings.TrimSpace(notes), Channel: normalizeText(channel),
|
||||
Notes: strings.TrimSpace(notes), Referrer: strings.TrimSpace(referrer), EmployeeID: strings.TrimSpace(employeeID), EmployeeName: strings.TrimSpace(employeeName), Channel: normalizeText(channel), PackageID: packageID,
|
||||
}, ""
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ func TestRegisterPatientUsesConfiguredDepartmentAndNormalizesPayload(t *testing.
|
||||
"periode_tarif_id":"10",
|
||||
"perusahaan_id":"ADMEDIKAAA",
|
||||
"group_tarif_id":18,
|
||||
"kode_paket":"PN2600036",
|
||||
"kelas_id":"Default",
|
||||
"channel":"cpone"
|
||||
}`))
|
||||
@@ -55,6 +56,9 @@ func TestRegisterPatientUsesConfiguredDepartmentAndNormalizesPayload(t *testing.
|
||||
if repo.params.PatientTypeID != 1 || repo.params.TariffPeriodID != 10 || repo.params.GroupTariffID != 18 || repo.params.Channel != "CPONE" {
|
||||
t.Fatalf("unexpected numeric/text params: %+v", repo.params)
|
||||
}
|
||||
if repo.params.PackageID != "PN2600036" {
|
||||
t.Fatalf("unexpected package: %+v", repo.params)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterPatientRequiresIdentityWhenMedrecIsMissing(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user