Skip to content

Commit

Permalink
5011: Refactored to remove hardcoded check for empty product name
Browse files Browse the repository at this point in the history
  • Loading branch information
Rool committed Dec 5, 2022
1 parent d5c350f commit 2abbac9
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,17 @@ class DCCTestDetailsGenerator {
class VaccinationDetailsGenerator {

static func getDetails(identity: EventFlow.Identity, event: EventFlow.Event, providerIdentifier: String) -> [EventDetails] {

let mappingManager: MappingManaging = Current.mappingManager

let formattedBirthDate: String = identity.birthDateString
.flatMap(Formatter.getDateFrom)
.map(DateFormatter.Format.dayMonthYear.string) ?? (identity.birthDateString ?? "")
let formattedShotDate: String = event.vaccination?.dateString
.flatMap(Formatter.getDateFrom)
.map(DateFormatter.Format.dayMonthYear.string) ?? (event.vaccination?.dateString ?? "")
let provider: String = mappingManager.getProviderIdentifierMapping(providerIdentifier) ?? providerIdentifier

var vaccinName: String?
var vaccineDisplayName: String?
var vaccineType: String?
Expand All @@ -155,7 +155,7 @@ class VaccinationDetailsGenerator {
vaccineManufacturer = mappingManager.getVaccinationManufacturer(hpkData.marketingAuthorizationHolder)
vaccineDisplayName = hpkData.displayName
}

if vaccinName == nil, let brand = event.vaccination?.brand {
vaccinName = mappingManager.getVaccinationBrand(brand)
}
Expand All @@ -166,21 +166,22 @@ class VaccinationDetailsGenerator {
vaccineManufacturer = mappingManager.getVaccinationManufacturer(event.vaccination?.manufacturer)
?? event.vaccination?.manufacturer
}

var dosage: String?
if let doseNumber = event.vaccination?.doseNumber,
let totalDose = event.vaccination?.totalDoses {
dosage = L.holderVaccinationAboutOff("\(doseNumber)", "\(totalDose)")
}

let country = mappingManager.getDisplayCountry(event.vaccination?.country ?? "")

var details = [
EventDetails(field: EventDetailsVaccination.subtitle(provider: provider), value: nil),
EventDetails(field: EventDetailsVaccination.name, value: identity.fullName),
EventDetails(field: EventDetailsVaccination.dateOfBirth, value: formattedBirthDate),
EventDetails(field: EventDetailsVaccination.pathogen, value: L.holderEventAboutVaccinationPathogenvalue()),
EventDetails(field: EventDetailsVaccination.vaccineBrand, value: vaccinName),
EventDetails(field: EventDetailsVaccination.vaccineProductname, value: vaccineDisplayName),
EventDetails(field: EventDetailsVaccination.vaccineType, value: vaccineType),
EventDetails(field: EventDetailsVaccination.vaccineManufacturer, value: vaccineManufacturer),
EventDetails(field: EventDetailsVaccination.dosage, value: dosage),
Expand All @@ -189,10 +190,12 @@ class VaccinationDetailsGenerator {
EventDetails(field: EventDetailsVaccination.country, value: country),
EventDetails(field: EventDetailsVaccination.uniqueIdentifer, value: event.unique)
]
if vaccineDisplayName != nil {
details.insert(EventDetails(field: EventDetailsVaccination.vaccineProductname, value: vaccineDisplayName), at: 5)
return details.filter { details in
if case EventDetailsVaccination.vaccineProductname = details.field {
return vaccineDisplayName != nil
}
return true
}
return details
}
}

Expand Down

0 comments on commit 2abbac9

Please sign in to comment.