Use CPONE user name for HIS LoginBuat

This commit is contained in:
2026-09-25 22:09:05 +07:00
parent 20ec75fbcf
commit 0d2044926e
22 changed files with 127 additions and 47 deletions

View File

@@ -42,7 +42,8 @@ func TestRegisterPatientUsesConfiguredDepartmentAndNormalizesPayload(t *testing.
"group_tarif_id":18,
"kode_paket":"PN2600036",
"kelas_id":"Default",
"channel":"cpone"
"channel":"cpone",
"login_buat":"Joko Hudoro"
}`))
recorder := httptest.NewRecorder()
handler.RegisterPatient(recorder, request)
@@ -53,7 +54,7 @@ func TestRegisterPatientUsesConfiguredDepartmentAndNormalizesPayload(t *testing.
if repo.params.DepartmentID != "08_01" || repo.params.NIK != "3174011501900001" || repo.params.RegistrationType != 2 {
t.Fatalf("unexpected normalized params: %+v", repo.params)
}
if repo.params.PatientTypeID != 1 || repo.params.TariffPeriodID != 10 || repo.params.GroupTariffID != 18 || repo.params.Channel != "CPONE" {
if repo.params.PatientTypeID != 1 || repo.params.TariffPeriodID != 10 || repo.params.GroupTariffID != 18 || repo.params.Channel != "CPONE" || repo.params.LoginBuat != "Joko Hudoro" {
t.Fatalf("unexpected numeric/text params: %+v", repo.params)
}
if repo.params.PackageID != "PN2600036" {
@@ -72,9 +73,20 @@ func TestRegisterPatientRequiresIdentityWhenMedrecIsMissing(t *testing.T) {
}
}
func TestRegisterPatientRequiresLoggedInName(t *testing.T) {
handler := Handler{registrationRepo: &fakeRegistrationRepository{}, departmentID: "08_01"}
request := httptest.NewRequest(http.MethodPost, "/api/cpone/patients/registration", strings.NewReader(`{"medrec_id":"00001234","channel":"CPONE"}`))
recorder := httptest.NewRecorder()
handler.RegisterPatient(recorder, request)
if recorder.Code != http.StatusUnprocessableEntity || !strings.Contains(recorder.Body.String(), "login_buat wajib diisi") {
t.Fatalf("unexpected validation response: status=%d body=%s", recorder.Code, recorder.Body.String())
}
}
func TestRegisterPatientForwardsRepositoryError(t *testing.T) {
handler := Handler{registrationRepo: &fakeRegistrationRepository{err: errors.New("database unavailable")}, departmentID: "08_01"}
request := httptest.NewRequest(http.MethodPost, "/api/cpone/patients/registration", strings.NewReader(`{"medrec_id":"00001234"}`))
request := httptest.NewRequest(http.MethodPost, "/api/cpone/patients/registration", strings.NewReader(`{"medrec_id":"00001234","login_buat":"Joko Hudoro"}`))
recorder := httptest.NewRecorder()
handler.RegisterPatient(recorder, request)