Use CPONE user name for HIS LoginBuat
This commit is contained in:
@@ -77,8 +77,12 @@ func validateAddLabPackage(payload map[string]any) (repository.AddLabPackagePara
|
||||
if !present {
|
||||
channel = "CPONE"
|
||||
}
|
||||
loginBuat, message := requiredLoginBuat(payload)
|
||||
if message != "" {
|
||||
return repository.AddLabPackageParams{}, message
|
||||
}
|
||||
return repository.AddLabPackageParams{
|
||||
PackageID: packageID, Cito: cito, MarkupCito: markup,
|
||||
Notes: strings.TrimSpace(notes), Channel: strings.ToUpper(strings.TrimSpace(channel)),
|
||||
Notes: strings.TrimSpace(notes), Channel: strings.ToUpper(strings.TrimSpace(channel)), LoginBuat: loginBuat,
|
||||
}, ""
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func TestAddLabPackageValidPayload(t *testing.T) {
|
||||
Message: "Paket dispenser berhasil ditambahkan ke registrasi laboratorium",
|
||||
}}
|
||||
handler := Handler{labRepo: repo}
|
||||
request := httptest.NewRequest(http.MethodPost, "/packages", strings.NewReader(`{"paket_id":"disp-260800011","cito":true,"markup_cito":"10","catatan":" test ","channel":"cpone"}`))
|
||||
request := httptest.NewRequest(http.MethodPost, "/packages", strings.NewReader(`{"paket_id":"disp-260800011","cito":true,"markup_cito":"10","catatan":" test ","channel":"cpone","login_buat":"Joko Hudoro"}`))
|
||||
request.SetPathValue("regId", "lab-2608210003")
|
||||
recorder := httptest.NewRecorder()
|
||||
handler.AddLabPackage(recorder, request)
|
||||
|
||||
@@ -233,6 +233,10 @@ func validateLabRegistration(payload map[string]any) (validatedLabRegistration,
|
||||
channel = "CPONE"
|
||||
}
|
||||
channel = strings.ToUpper(strings.TrimSpace(channel))
|
||||
loginBuat, message := requiredLoginBuat(payload)
|
||||
if message != "" {
|
||||
return validatedLabRegistration{}, message
|
||||
}
|
||||
|
||||
return validatedLabRegistration{Params: repository.LabRegistrationParams{
|
||||
MedrecID: medrecID,
|
||||
@@ -255,6 +259,7 @@ func validateLabRegistration(payload map[string]any) (validatedLabRegistration,
|
||||
WorkingDiagnosis: workingDiagnosis,
|
||||
Notes: notes,
|
||||
Channel: channel,
|
||||
LoginBuat: loginBuat,
|
||||
}}, ""
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,8 @@ func TestRegisterLabValidPayloadAndResponseParity(t *testing.T) {
|
||||
"kelas_id":"",
|
||||
"diagnosa_kerja":"Pemeriksaan laboratorium",
|
||||
"catatan":" catatan ",
|
||||
"channel":" cpone-api "
|
||||
"channel":" cpone-api ",
|
||||
"login_buat":"Joko Hudoro"
|
||||
}`
|
||||
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/cpone/patients/lab-registration", strings.NewReader(body))
|
||||
@@ -95,7 +96,7 @@ func TestRegisterLabValidPayloadAndResponseParity(t *testing.T) {
|
||||
if repo.params.MedrecID != "00001234" || repo.params.DepartmentID != "LAB" || repo.params.DoctorID != "DR01" {
|
||||
t.Fatalf("unexpected repository params: %+v", repo.params)
|
||||
}
|
||||
if repo.params.TariffPeriodID != 10 || repo.params.ClassID != "Default" || repo.params.Channel != "CPONE-API" {
|
||||
if repo.params.TariffPeriodID != 10 || repo.params.ClassID != "Default" || repo.params.Channel != "CPONE-API" || repo.params.LoginBuat != "Joko Hudoro" {
|
||||
t.Fatalf("normalization mismatch: %+v", repo.params)
|
||||
}
|
||||
if repo.params.Referrer != " Klinik A " || repo.params.Notes != " catatan " {
|
||||
@@ -118,7 +119,8 @@ func TestRegisterLabUsesConfiguredDepartmentID(t *testing.T) {
|
||||
"dokter_pengirim_id":"DR02",
|
||||
"jenis_pasien_id":"0",
|
||||
"periode_tarif_id":10,
|
||||
"diagnosa_kerja":"Pemeriksaan laboratorium"
|
||||
"diagnosa_kerja":"Pemeriksaan laboratorium",
|
||||
"login_buat":"Joko Hudoro"
|
||||
}`
|
||||
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/cpone/patients/lab-registration", strings.NewReader(body))
|
||||
@@ -158,7 +160,8 @@ func TestRegisterLabCompanyPayload(t *testing.T) {
|
||||
"nama_karyawan":"INTAN SEPTIANI",
|
||||
"kelas_id":"Default",
|
||||
"shift_harian_id":48049,
|
||||
"diagnosa_kerja":"Test diagnosa"
|
||||
"diagnosa_kerja":"Test diagnosa",
|
||||
"login_buat":"Joko Hudoro"
|
||||
}`
|
||||
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/cpone/patients/lab-registration", strings.NewReader(body))
|
||||
@@ -186,6 +189,7 @@ func TestRegisterLabValidationParity(t *testing.T) {
|
||||
"jenis_pasien_id": "0",
|
||||
"periode_tarif_id": 10,
|
||||
"diagnosa_kerja": "Pemeriksaan laboratorium",
|
||||
"login_buat": "Joko Hudoro",
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@@ -290,7 +294,7 @@ func TestRegisterLabRepositoryErrorsMatchLaravelEnvelope(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
const validBody = `{"medrec_id":"00001234","departemen_id":"LAB","dokter_id":"DR01","dokter_pengirim_id":"DR02","jenis_pasien_id":"0","periode_tarif_id":10,"diagnosa_kerja":"Pemeriksaan laboratorium"}`
|
||||
const validBody = `{"medrec_id":"00001234","departemen_id":"LAB","dokter_id":"DR01","dokter_pengirim_id":"DR02","jenis_pasien_id":"0","periode_tarif_id":10,"diagnosa_kerja":"Pemeriksaan laboratorium","login_buat":"Joko Hudoro"}`
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
handler := Handler{labRepo: &fakeLabRegistrationRepository{err: test.err}}
|
||||
|
||||
@@ -128,8 +128,12 @@ func validateAddLabServices(payload map[string]any) (repository.AddLabServicesPa
|
||||
channel = "CPONE"
|
||||
}
|
||||
channel = strings.ToUpper(strings.TrimSpace(channel))
|
||||
loginBuat, message := requiredLoginBuat(payload)
|
||||
if message != "" {
|
||||
return repository.AddLabServicesParams{}, message
|
||||
}
|
||||
|
||||
return repository.AddLabServicesParams{Layanan: services, Channel: channel}, ""
|
||||
return repository.AddLabServicesParams{Layanan: services, Channel: channel, LoginBuat: loginBuat}, ""
|
||||
}
|
||||
|
||||
func requiredNestedString(item map[string]any, key string, index int, maxLength int, requiredMessage string) (string, string) {
|
||||
|
||||
@@ -47,7 +47,8 @@ func TestAddLabServicesValidPayloadAndResponseParity(t *testing.T) {
|
||||
{"layanan_id":"6413","jumlah":"2","cito":true,"markup_cito":"10.5","catatan":" urgent "},
|
||||
{"layanan_id":"6414","cito":"0"}
|
||||
],
|
||||
"channel":" cpone-api "
|
||||
"channel":" cpone-api ",
|
||||
"login_buat":"Joko Hudoro"
|
||||
}`
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/cpone/patients/lab-registration/CPLAB2608180001/services", strings.NewReader(body))
|
||||
request.SetPathValue("regId", "CPLAB2608180001")
|
||||
|
||||
16
internal/http/login_buat.go
Normal file
16
internal/http/login_buat.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package http
|
||||
|
||||
import "strings"
|
||||
|
||||
// HIS package tables limit LoginBuat to 30 characters.
|
||||
func requiredLoginBuat(payload map[string]any) (string, string) {
|
||||
name, message := requiredString(payload, "login_buat", 30, "login_buat wajib diisi dengan nama pengguna CPONE")
|
||||
if message != "" {
|
||||
return "", message
|
||||
}
|
||||
name = strings.TrimSpace(name)
|
||||
if name == "" {
|
||||
return "", "login_buat wajib diisi dengan nama pengguna CPONE"
|
||||
}
|
||||
return name, ""
|
||||
}
|
||||
@@ -171,6 +171,10 @@ func validateMedrec(payload map[string]any) (repository.MedrecParams, string) {
|
||||
if !channelPresent || channel == "" {
|
||||
channel = "CPONE"
|
||||
}
|
||||
loginBuat, message := requiredLoginBuat(payload)
|
||||
if message != "" {
|
||||
return repository.MedrecParams{}, message
|
||||
}
|
||||
|
||||
identityType = normalizeText(identityType)
|
||||
identityNumber = normalizeIdentity(identityNumber)
|
||||
@@ -208,6 +212,7 @@ func validateMedrec(payload map[string]any) (repository.MedrecParams, string) {
|
||||
DependantID: strings.TrimSpace(dependantID),
|
||||
EmployeeName: strings.TrimSpace(employeeName),
|
||||
Channel: normalizeText(channel),
|
||||
LoginBuat: loginBuat,
|
||||
}, ""
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,8 @@ func TestStoreMedrecValidPayloadAndCreatedResponseParity(t *testing.T) {
|
||||
"nik_karyawan":" TSB2026002 ",
|
||||
"dependant_id":"D001",
|
||||
"nama_karyawan":" Budi Santos ",
|
||||
"channel":" cpone "
|
||||
"channel":" cpone ",
|
||||
"login_buat":" Joko Hudoro "
|
||||
}`
|
||||
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/cpone/patients/medrec", strings.NewReader(body))
|
||||
@@ -93,7 +94,7 @@ func TestStoreMedrecValidPayloadAndCreatedResponseParity(t *testing.T) {
|
||||
if repo.params.Phone != "081234567890" || repo.params.Mobile != "081234567890" {
|
||||
t.Fatalf("phone normalization mismatch: %+v", repo.params)
|
||||
}
|
||||
if repo.params.Email != "budi@example.com" || repo.params.PlaceOfBirth != "JAKARTA" || repo.params.Channel != "CPONE" {
|
||||
if repo.params.Email != "budi@example.com" || repo.params.PlaceOfBirth != "JAKARTA" || repo.params.Channel != "CPONE" || repo.params.LoginBuat != "Joko Hudoro" {
|
||||
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" {
|
||||
@@ -112,6 +113,7 @@ func TestStoreMedrecValidationParity(t *testing.T) {
|
||||
"jenis_nomer_sosial": "KTP",
|
||||
"nomer_sosial": "3174011501900001",
|
||||
"telepon": "081234567890",
|
||||
"login_buat": "Joko Hudoro",
|
||||
}
|
||||
|
||||
tomorrow := time.Now().AddDate(0, 0, 1).Format("2006-01-02")
|
||||
@@ -168,7 +170,7 @@ func TestStoreMedrecNikFallbackAndOutcomeForwarding(t *testing.T) {
|
||||
Data: data,
|
||||
}}
|
||||
handler := Handler{patientRepo: repo}
|
||||
body := `{"nama":"BUDI","jenis_kelamin":"P","tgl_lahir":"1990-01-15","nik":"3174011501900001","ponsel":"08123"}`
|
||||
body := `{"nama":"BUDI","jenis_kelamin":"P","tgl_lahir":"1990-01-15","nik":"3174011501900001","ponsel":"08123","login_buat":"Joko Hudoro"}`
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/cpone/patients/medrec", strings.NewReader(body))
|
||||
recorder := httptest.NewRecorder()
|
||||
handler.StoreMedrec(recorder, request)
|
||||
@@ -180,7 +182,7 @@ func TestStoreMedrecNikFallbackAndOutcomeForwarding(t *testing.T) {
|
||||
|
||||
func TestStoreMedrecRepositoryErrorParity(t *testing.T) {
|
||||
handler := Handler{patientRepo: &fakePatientRepository{err: errors.New("database unavailable")}}
|
||||
body := `{"nama":"BUDI","jenis_kelamin":"L","tgl_lahir":"1990-01-15","nomer_sosial":"3174011501900001","telepon":"08123"}`
|
||||
body := `{"nama":"BUDI","jenis_kelamin":"L","tgl_lahir":"1990-01-15","nomer_sosial":"3174011501900001","telepon":"08123","login_buat":"Joko Hudoro"}`
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/cpone/patients/medrec", strings.NewReader(body))
|
||||
recorder := httptest.NewRecorder()
|
||||
handler.StoreMedrec(recorder, request)
|
||||
|
||||
@@ -123,6 +123,10 @@ func validateCreatePaket(payload map[string]any) (repository.CreatePaketParams,
|
||||
if !present || strings.TrimSpace(channel) == "" {
|
||||
channel = "CPONE"
|
||||
}
|
||||
loginBuat, message := requiredLoginBuat(payload)
|
||||
if message != "" {
|
||||
return repository.CreatePaketParams{}, message
|
||||
}
|
||||
|
||||
days := int64(1)
|
||||
if value, present := nullableValue(payload, "jumlah_hari"); present {
|
||||
@@ -251,7 +255,7 @@ func validateCreatePaket(payload map[string]any) (repository.CreatePaketParams,
|
||||
RawatInap: rawatInap, RawatJalan: rawatJalan, MultiVisit: multiVisit,
|
||||
TanggalMulai: startDate, TanggalSelesai: endDate, KelasID: strings.TrimSpace(classID),
|
||||
HeaderPaketID: strings.TrimSpace(headerID), Keterangan: strings.TrimSpace(notes), JumlahHari: days,
|
||||
Channel: strings.ToUpper(strings.TrimSpace(channel)), Layanan: result,
|
||||
Channel: strings.ToUpper(strings.TrimSpace(channel)), LoginBuat: loginBuat, Layanan: result,
|
||||
}, ""
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ const validCreatePaketJSON = `{
|
||||
"tanggal_mulai":"2026-09-01",
|
||||
"tanggal_selesai":"2026-09-30",
|
||||
"kelas_id":"Default",
|
||||
"login_buat":"Joko Hudoro",
|
||||
"layanan":[{
|
||||
"layanan_id":"1200",
|
||||
"departemen_id":"MED-PNJ-LAB",
|
||||
|
||||
@@ -149,6 +149,10 @@ func validateRegistration(payload map[string]any, configuredDepartment string) (
|
||||
if !present || strings.TrimSpace(channel) == "" {
|
||||
channel = "CPONE"
|
||||
}
|
||||
loginBuat, message := requiredLoginBuat(payload)
|
||||
if message != "" {
|
||||
return repository.RegistrationParams{}, message
|
||||
}
|
||||
referrer, _, message := optionalString(payload, "perujuk", 150)
|
||||
if message != "" {
|
||||
return repository.RegistrationParams{}, message
|
||||
@@ -183,7 +187,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), Referrer: strings.TrimSpace(referrer), EmployeeID: strings.TrimSpace(employeeID), EmployeeName: strings.TrimSpace(employeeName), Channel: normalizeText(channel), PackageID: packageID,
|
||||
Notes: strings.TrimSpace(notes), Referrer: strings.TrimSpace(referrer), EmployeeID: strings.TrimSpace(employeeID), EmployeeName: strings.TrimSpace(employeeName), Channel: normalizeText(channel), LoginBuat: loginBuat, PackageID: packageID,
|
||||
}, ""
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user