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 UCEnPatient UploadCode = "encounter-patient" UCEnSupport UploadCode = "encounter-support" UcEnOther UploadCode = "encounter-other" 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, UCEnPatient, UCEnSupport, UcEnOther, }, 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) }