feat(cpone): support company lab registrations
This commit is contained in:
@@ -80,7 +80,7 @@ func TestRegisterLabValidPayloadAndResponseParity(t *testing.T) {
|
||||
if recorder.Code != http.StatusCreated {
|
||||
t.Fatalf("status = %d, want %d; body=%s", recorder.Code, http.StatusCreated, recorder.Body.String())
|
||||
}
|
||||
const expected = `{"success":true,"status":"registered","message":"Registrasi laboratorium berhasil disimpan","data":{"registration":{"RegID":"CPLAB2608180001","MEDRECID":"00001234","Tanggal":"2026-08-18 10:11:12","DepartemenID":"LAB","DokterID":"DR01","JenisPasienID":0,"JenisRegID":3,"PeriodeTarifID":10},"transaction":{"TrxDepartemenID":99,"TrxID":"CPLAB2608180001","GrandTotal":0},"layanan":[]}}` + "\n"
|
||||
const expected = `{"success":true,"status":"registered","message":"Registrasi laboratorium berhasil disimpan","data":{"registration":{"RegID":"CPLAB2608180001","MEDRECID":"00001234","Tanggal":"2026-08-18 10:11:12","DepartemenID":"LAB","DokterID":"DR01","JenisPasienID":0,"JenisRegID":3,"PeriodeTarifID":10,"PerusahaanID":null,"AsuransiID":null,"ProviderID":null,"GroupTarifID":null,"NomerPolis":null},"transaction":{"TrxDepartemenID":99,"TrxID":"CPLAB2608180001","GrandTotal":0},"layanan":[]}}` + "\n"
|
||||
if recorder.Body.String() != expected {
|
||||
t.Fatalf("body mismatch\n got: %s\nwant: %s", recorder.Body.String(), expected)
|
||||
}
|
||||
@@ -96,12 +96,57 @@ func TestRegisterLabValidPayloadAndResponseParity(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterLabCompanyPayload(t *testing.T) {
|
||||
repo := &fakeLabRegistrationRepository{outcome: repository.LabRegistrationOutcome{
|
||||
HTTPStatus: http.StatusCreated,
|
||||
Success: true,
|
||||
Status: "registered",
|
||||
Message: "Registrasi laboratorium berhasil disimpan",
|
||||
}}
|
||||
handler := Handler{labRepo: repo}
|
||||
body := `{
|
||||
"medrec_id":"00409575",
|
||||
"departemen_id":"MED-PNJ-LAB",
|
||||
"dokter_id":"SPP01_003",
|
||||
"dokter_pengirim_id":"Luar",
|
||||
"perujuk":"DOKTER PERUJUK LUAR",
|
||||
"jenis_pasien_id":"1",
|
||||
"periode_tarif_id":7,
|
||||
"perusahaan_id":"PE260700001",
|
||||
"asuransi_id":"PE260700001",
|
||||
"provider_id":"",
|
||||
"group_tarif_id":1980,
|
||||
"nomer_polis":"POLIS-001",
|
||||
"nik_karyawan":"TSB2026002",
|
||||
"nama_karyawan":"INTAN SEPTIANI",
|
||||
"kelas_id":"Default",
|
||||
"shift_harian_id":48049,
|
||||
"diagnosa_kerja":"Test diagnosa"
|
||||
}`
|
||||
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/cpone/patients/lab-registration", strings.NewReader(body))
|
||||
recorder := httptest.NewRecorder()
|
||||
handler.RegisterLab(recorder, request)
|
||||
|
||||
if recorder.Code != http.StatusCreated {
|
||||
t.Fatalf("status = %d, want %d; body=%s", recorder.Code, http.StatusCreated, recorder.Body.String())
|
||||
}
|
||||
params := repo.params
|
||||
if params.PatientType != "1" || params.CompanyID != "PE260700001" || params.InsuranceID != "PE260700001" || params.GroupTariffID != 1980 {
|
||||
t.Fatalf("company guarantor params mismatch: %+v", params)
|
||||
}
|
||||
if params.PolicyNumber != "POLIS-001" || params.EmployeeID != "TSB2026002" || params.EmployeeName != "INTAN SEPTIANI" {
|
||||
t.Fatalf("company employee params mismatch: %+v", params)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterLabValidationParity(t *testing.T) {
|
||||
baseline := map[string]any{
|
||||
"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",
|
||||
}
|
||||
@@ -130,9 +175,14 @@ func TestRegisterLabValidationParity(t *testing.T) {
|
||||
message: "Dokter pengirim atau perujuk wajib diisi",
|
||||
},
|
||||
{
|
||||
name: "non-general patient",
|
||||
name: "missing company for guarantor",
|
||||
mutate: func(payload map[string]any) { payload["jenis_pasien_id"] = "1" },
|
||||
message: "Registrasi laboratorium API saat ini hanya mendukung pasien umum",
|
||||
message: "Perusahaan wajib diisi untuk pasien penjamin",
|
||||
},
|
||||
{
|
||||
name: "missing patient type",
|
||||
mutate: func(payload map[string]any) { delete(payload, "jenis_pasien_id") },
|
||||
message: "Jenis pasien wajib diisi",
|
||||
},
|
||||
{
|
||||
name: "invalid tariff period type",
|
||||
@@ -203,7 +253,7 @@ func TestRegisterLabRepositoryErrorsMatchLaravelEnvelope(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
const validBody = `{"medrec_id":"00001234","departemen_id":"LAB","dokter_id":"DR01","dokter_pengirim_id":"DR02","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"}`
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
handler := Handler{labRepo: &fakeLabRegistrationRepository{err: test.err}}
|
||||
|
||||
Reference in New Issue
Block a user