package upload import "fmt" type ( DocTypeCode string EntityTypeCode string ) const ( DTCPRN DocTypeCode = "person-resident-number" // Person Resident Number DTCPDL DocTypeCode = "person-driver-license" // Person Driver License DTCPP DocTypeCode = "person-passport" // Person Passport DTCPFC DocTypeCode = "person-family-card" // Person Family Card DTCMIR DocTypeCode = "mcu-item-result" // Mcu Item Result DTCEnPatient DocTypeCode = "encounter-patient" DTCEnSupport DocTypeCode = "encounter-support" DTCEnOther DocTypeCode = "encounter-other" DTCSEP DocTypeCode = "vclaim-sep" // SEP DTCSIPP DocTypeCode = "vclaim-sipp" // SIPP DTCGC DocTypeCode = "general-consent" ETCPerson EntityTypeCode = "person" ETCEncounter EntityTypeCode = "encounter" ETCMCU EntityTypeCode = "mcu" ) var validUploadCodesByEntity = map[EntityTypeCode][]DocTypeCode{ ETCPerson: { DTCPRN, DTCPDL, DTCPP, DTCPFC, }, ETCEncounter: { DTCSEP, DTCSIPP, DTCEnPatient, DTCEnSupport, DTCEnOther, }, ETCMCU: { DTCMIR, }, } func IsValidUploadCode(entity EntityTypeCode, code DocTypeCode) (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 doctype_code '%s' for entityType_code '%s'", code, entity) }