rename and adjust upload code into doctypecode

This commit is contained in:
dpurbosakti
2025-11-17 14:49:34 +07:00
parent b211ae3f24
commit 13ddfaab5f
8 changed files with 59 additions and 57 deletions
+18 -17
View File
@@ -3,40 +3,41 @@ package upload
import "fmt"
type (
UploadCode string
DocTypeCode 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
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][]UploadCode{
var validUploadCodesByEntity = map[EntityTypeCode][]DocTypeCode{
ETCPerson: {
UCPRN, UCPDL, UCPP, UCPFC,
DTCPRN, DTCPDL, DTCPP, DTCPFC,
},
ETCEncounter: {
UCSEP, UCSIPP, UCEnPatient, UCEnSupport, UcEnOther,
DTCSEP, DTCSIPP, DTCEnPatient, DTCEnSupport, DTCEnOther,
},
ETCMCU: {
UCMIR,
DTCMIR,
},
}
func IsValidUploadCode(entity EntityTypeCode, code UploadCode) (bool, string) {
func IsValidUploadCode(entity EntityTypeCode, code DocTypeCode) (bool, string) {
allowedCodes, ok := validUploadCodesByEntity[entity]
if !ok {
return false, fmt.Sprintf("unknown entityType_code: %s", entity)
@@ -48,5 +49,5 @@ func IsValidUploadCode(entity EntityTypeCode, code UploadCode) (bool, string) {
}
}
return false, fmt.Sprintf("invalid upload_code '%s' for entityType_code '%s'", code, entity)
return false, fmt.Sprintf("invalid doctype_code '%s' for entityType_code '%s'", code, entity)
}