feat(cpone): support company lab registrations
This commit is contained in:
@@ -115,13 +115,11 @@ func validateLabRegistration(payload map[string]any) (validatedLabRegistration,
|
||||
return validatedLabRegistration{}, "Dokter pengirim atau perujuk wajib diisi"
|
||||
}
|
||||
|
||||
patientType, patientTypePresent, message := optionalString(payload, "jenis_pasien_id", 0)
|
||||
patientType, message := requiredString(payload, "jenis_pasien_id", 20, "Jenis pasien wajib diisi")
|
||||
if message != "" {
|
||||
return validatedLabRegistration{}, message
|
||||
}
|
||||
if patientTypePresent && patientType != "0" {
|
||||
return validatedLabRegistration{}, "Registrasi laboratorium API saat ini hanya mendukung pasien umum"
|
||||
}
|
||||
patientType = strings.TrimSpace(patientType)
|
||||
|
||||
tariffPeriodID, message := requiredInteger(payload, "periode_tarif_id", "Periode tarif wajib diisi")
|
||||
if message != "" {
|
||||
@@ -131,6 +129,60 @@ func validateLabRegistration(payload map[string]any) (validatedLabRegistration,
|
||||
return validatedLabRegistration{}, "The periode tarif id must be at least 1."
|
||||
}
|
||||
|
||||
companyID, companyPresent, message := optionalString(payload, "perusahaan_id", 50)
|
||||
if message != "" {
|
||||
return validatedLabRegistration{}, message
|
||||
}
|
||||
insuranceID, insurancePresent, message := optionalString(payload, "asuransi_id", 50)
|
||||
if message != "" {
|
||||
return validatedLabRegistration{}, message
|
||||
}
|
||||
providerID, _, message := optionalString(payload, "provider_id", 50)
|
||||
if message != "" {
|
||||
return validatedLabRegistration{}, message
|
||||
}
|
||||
policyNumber, _, message := optionalString(payload, "nomer_polis", 100)
|
||||
if message != "" {
|
||||
return validatedLabRegistration{}, message
|
||||
}
|
||||
employeeID, _, message := optionalString(payload, "nik_karyawan", 100)
|
||||
if message != "" {
|
||||
return validatedLabRegistration{}, message
|
||||
}
|
||||
employeeName, _, message := optionalString(payload, "nama_karyawan", 255)
|
||||
if message != "" {
|
||||
return validatedLabRegistration{}, message
|
||||
}
|
||||
|
||||
var groupTariffID int64
|
||||
if value, present := nullableValue(payload, "group_tarif_id"); present {
|
||||
parsed, ok := parseInteger(value)
|
||||
if !ok {
|
||||
return validatedLabRegistration{}, "The group tarif id must be an integer."
|
||||
}
|
||||
if parsed < 1 && patientType != "0" {
|
||||
return validatedLabRegistration{}, "The group tarif id must be at least 1."
|
||||
}
|
||||
groupTariffID = parsed
|
||||
}
|
||||
|
||||
if patientType != "0" {
|
||||
if !companyPresent || strings.TrimSpace(companyID) == "" {
|
||||
return validatedLabRegistration{}, "Perusahaan wajib diisi untuk pasien penjamin"
|
||||
}
|
||||
if !insurancePresent || strings.TrimSpace(insuranceID) == "" {
|
||||
return validatedLabRegistration{}, "Asuransi/penanggung wajib diisi untuk pasien penjamin"
|
||||
}
|
||||
if groupTariffID < 1 {
|
||||
return validatedLabRegistration{}, "Group tarif wajib diisi untuk pasien penjamin"
|
||||
}
|
||||
} else {
|
||||
companyID = ""
|
||||
insuranceID = ""
|
||||
providerID = ""
|
||||
groupTariffID = 0
|
||||
}
|
||||
|
||||
classID, classPresent, message := optionalString(payload, "kelas_id", 50)
|
||||
if message != "" {
|
||||
return validatedLabRegistration{}, message
|
||||
@@ -184,7 +236,15 @@ func validateLabRegistration(payload map[string]any) (validatedLabRegistration,
|
||||
DoctorID: doctorID,
|
||||
SenderDoctorID: senderDoctorID,
|
||||
Referrer: referrer,
|
||||
PatientType: patientType,
|
||||
TariffPeriodID: tariffPeriodID,
|
||||
CompanyID: strings.TrimSpace(companyID),
|
||||
InsuranceID: strings.TrimSpace(insuranceID),
|
||||
ProviderID: strings.TrimSpace(providerID),
|
||||
GroupTariffID: groupTariffID,
|
||||
PolicyNumber: strings.TrimSpace(policyNumber),
|
||||
EmployeeID: strings.TrimSpace(employeeID),
|
||||
EmployeeName: strings.TrimSpace(employeeName),
|
||||
ClassID: classID,
|
||||
DailyShiftID: dailyShiftID,
|
||||
WorkingDiagnosis: workingDiagnosis,
|
||||
|
||||
Reference in New Issue
Block a user