Files
simrsx-be/internal/domain/references/upload/upload.go
T
vanilia 733fb481b3 tbc
2025-11-11 15:35:19 +07:00

50 lines
1.2 KiB
Go

package upload
import "fmt"
type (
UploadCode string
EntityTypeCode string
)
const (
UCPRN UploadCode = "person-resident-number" // Person Resident Number
UCPDL UploadCode = "person-driver-license" // Person Driver License
UCPP UploadCode = "person-passport" // Person Passport
UCPFC UploadCode = "person-family-card" // Person Family Card
UCMIR UploadCode = "mcu-item-result" // Mcu Item Result
UCSEP UploadCode = "vclaim-sep" // SEP
UCSIPP UploadCode = "vclaim-sipp" // SIPP
ETCPerson EntityTypeCode = "person"
ETCEncounter EntityTypeCode = "encounter"
ETCMCU EntityTypeCode = "mcu"
)
var validUploadCodesByEntity = map[EntityTypeCode][]UploadCode{
ETCPerson: {
UCPRN, UCPDL, UCPP, UCPFC,
},
ETCEncounter: {
UCSEP, UCSIPP,
},
ETCMCU: {
UCMIR,
},
}
func IsValidUploadCode(entity EntityTypeCode, code UploadCode) (bool, string) {
allowedCodes, ok := validUploadCodesByEntity[entity]
if !ok {
return false, fmt.Sprintf("unknown entityType_code: %s", entity)
}
for _, c := range allowedCodes {
if c == code {
return true, ""
}
}
return false, fmt.Sprintf("invalid upload_code '%s' for entityType_code '%s'", code, entity)
}