Skip to content

Commit

Permalink
Merge pull request #2175 from minvws/feature/5011-vaccine-version
Browse files Browse the repository at this point in the history
  • Loading branch information
Rool authored Dec 6, 2022
2 parents c05e54c + 13147fa commit 3b4dd57
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 34 deletions.
24 changes: 19 additions & 5 deletions CTRTests/Infrastrucure/Services/MappingManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,14 @@ class MappingManagerTests: XCTestCase {

// Given
remoteConfigManagerSpy.stubbedStoredConfiguration.hpkCodes = [
HPKData(code: "Test", name: "Test Corona Check", vp: "vp", mp: "mp", ma: "ma")
HPKData(
code: "Test",
name: "Test Corona Check",
displayName: "DisplayName",
vaccineOrProphylaxis: "vp",
medicalProduct: "mp",
marketingAuthorizationHolder: "ma"
)
]
sut = MappingManager(remoteConfigManager: remoteConfigManagerSpy)

Expand All @@ -478,16 +485,23 @@ class MappingManagerTests: XCTestCase {
// Then
expect(mapped?.name) == "Test Corona Check"
expect(mapped?.code) == "Test"
expect(mapped?.vp) == "vp"
expect(mapped?.mp) == "mp"
expect(mapped?.ma) == "ma"
expect(mapped?.vaccineOrProphylaxis) == "vp"
expect(mapped?.medicalProduct) == "mp"
expect(mapped?.marketingAuthorizationHolder) == "ma"
}

func test_getHpkData_missingMapping() {

// Given
remoteConfigManagerSpy.stubbedStoredConfiguration.hpkCodes = [
HPKData(code: "Test", name: "Test Corona Check", vp: "vp", mp: "mp", ma: "ma")
HPKData(
code: "Test",
name: "Test Corona Check",
displayName: "DisplayName",
vaccineOrProphylaxis: "vp",
medicalProduct: "mp",
marketingAuthorizationHolder: "ma"
)
]
sut = MappingManager(remoteConfigManager: remoteConfigManagerSpy)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,44 @@ class EventDetailsGeneratorTest: XCTestCase {
expect(details[11].value) == "1234"
}

func testVaccinationDetailsGenerator_withHPKCode() {

// Given
let identity = EventFlow.Identity.fakeIdentity
let event = EventFlow.Event.vaccinationEventWithHPKCode
environmentSpies.mappingManagerSpy.stubbedGetVaccinationBrandResult = "Pfizer (Comirnaty)"
environmentSpies.mappingManagerSpy.stubbedGetVaccinationTypeResult = "SARS-CoV-2 mRNA vaccine"
environmentSpies.mappingManagerSpy.stubbedGetVaccinationManufacturerResult = "Biontech"
environmentSpies.mappingManagerSpy.stubbedGetDisplayCountryResult = "NL"
environmentSpies.mappingManagerSpy.stubbedGetHpkDataResult = HPKData(
code: "1234",
name: "Test",
displayName: "Vaccination Product Name",
vaccineOrProphylaxis: "vp",
medicalProduct: "mp",
marketingAuthorizationHolder: "ma"
)

// When
let details = VaccinationDetailsGenerator.getDetails(identity: identity, event: event, providerIdentifier: "CC")

// Then
expect(details).to(haveCount(13))
expect(details[0].value) == nil
expect(details[1].value) == "Check, Corona"
expect(details[2].value) == "16 mei 1980"
expect(details[3].value) == L.holderEventAboutVaccinationPathogenvalue()
expect(details[4].value) == "Pfizer (Comirnaty)"
expect(details[5].value) == "Vaccination Product Name"
expect(details[6].value) == "SARS-CoV-2 mRNA vaccine"
expect(details[7].value) == "Biontech"
expect(details[8].value) == "1 van 2"
expect(details[9].value) == nil
expect(details[10].value) == "16 mei 2021"
expect(details[11].value) == "NL"
expect(details[12].value) == "1234"
}

func testVaccinationAssessmentDetailsGenerator() {

// Given
Expand Down
26 changes: 26 additions & 0 deletions CTRTests/Utils/Fakes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,32 @@ extension EventFlow.Event {
)
}

static var vaccinationEventWithHPKCode: EventFlow.Event {
EventFlow.Event(
type: "vaccination",
unique: "1234",
isSpecimen: true,
vaccination: EventFlow.VaccinationEvent(
dateString: "2021-05-16",
hpkCode: "1234",
type: nil,
manufacturer: "ORG-100030215",
brand: "EU/1/20/1528",
doseNumber: 1,
totalDoses: 2,
country: "NLD",
completedByMedicalStatement: nil,
completedByPersonalStatement: nil,
completionReason: nil
),
negativeTest: nil,
positiveTest: nil,
recovery: nil,
dccEvent: nil,
vaccinationAssessment: nil
)
}

static var boosterEvent: EventFlow.Event {
EventFlow.Event(
type: "vaccination",
Expand Down
1 change: 1 addition & 0 deletions Localizations/Holder/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@
"holder_endOfLife_description" = "The app is not in use at the moment. For more information, go to CoronaCheck.nl";
"holder_endOfLife_errorMessage" = "Can't open website.";
"holder_endOfLife_title" = "App not in use";
"holder_event_aboutVaccination_productName" = "Product name:";
"holder_event_negativeTestEndstate_addVaccinationAssessment_body" = "<p>Your negative test result was successfully added. Add your vaccination approval to complete your visitor pass.</p><p>To this end, you've received an approval code from the desk that reviewed your vaccination. You’ve received this code on paper.</p>";
"holder_event_negativeTestEndstate_addVaccinationAssessment_button_complete" = "Complete certificate";
"holder_event_negativeTestEndstate_addVaccinationAssessment_title" = "Negative test result added";
Expand Down
1 change: 1 addition & 0 deletions Localizations/Holder/nl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@
"holder_endOfLife_description" = "Op dit moment is de app niet in gebruik. Ga voor meer informatie naar CoronaCheck.nl";
"holder_endOfLife_errorMessage" = "De website kan niet geopend worden.";
"holder_endOfLife_title" = "App niet in gebruik";
"holder_event_aboutVaccination_productName" = "Productnaam:";
"holder_event_negativeTestEndstate_addVaccinationAssessment_body" = "<p>Je negatieve testuitslag is succesvol toegevoegd. Maak je bezoekersbewijs compleet met je vaccinatiebeoordeling.</p><p>Hiervoor heb je een beoordelingscode gekregen van de balie waar je vaccinatie is beoordeeld. Deze code heb je geprint gekregen.</p>";
"holder_event_negativeTestEndstate_addVaccinationAssessment_button_complete" = "Maak bewijs compleet";
"holder_event_negativeTestEndstate_addVaccinationAssessment_title" = "Negatieve testuitslag toegevoegd";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,27 @@ public struct HPKData: Codable, Equatable {

public let name: String

public let displayName: String?

/// euVaccinationTypes lookup
public let vp: String
public let vaccineOrProphylaxis: String

/// euBrands lookup
public let mp: String
public let medicalProduct: String

/// euManufacturers lookup
public let ma: String
public let marketingAuthorizationHolder: String

/// Key mapping
enum CodingKeys: String, CodingKey {

case code
case name
case displayName
case vaccineOrProphylaxis = "vp"
case medicalProduct = "mp"
case marketingAuthorizationHolder = "ma"
}
}

public struct Mapping: Codable, Equatable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum EventDetailsVaccination: EventDetailable {
case dateOfBirth
case pathogen
case vaccineBrand
case vaccineProductname
case vaccineType
case vaccineManufacturer
case dosage
Expand All @@ -56,6 +57,7 @@ enum EventDetailsVaccination: EventDetailable {
case .dateOfBirth: return L.holderEventAboutVaccinationDateofbirth()
case .pathogen: return L.holderEventAboutVaccinationPathogen()
case .vaccineBrand: return L.holderEventAboutVaccinationBrand()
case .vaccineProductname: return L.holder_event_aboutVaccination_productName()
case .vaccineType: return L.holderEventAboutVaccinationType()
case .vaccineManufacturer: return L.holderEventAboutVaccinationManufacturer()
case .dosage: return L.holderEventAboutVaccinationDosage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,29 @@ 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?
var vaccineManufacturer: String?
if let hpkCode = event.vaccination?.hpkCode, !hpkCode.isEmpty {
let hpkData = mappingManager.getHpkData(hpkCode)
vaccinName = mappingManager.getVaccinationBrand(hpkData?.mp)
vaccineType = mappingManager.getVaccinationType(hpkData?.vp)
vaccineManufacturer = mappingManager.getVaccinationManufacturer(hpkData?.ma)
if let hpkCode = event.vaccination?.hpkCode,
let hpkData = mappingManager.getHpkData(hpkCode) {
vaccinName = mappingManager.getVaccinationBrand(hpkData.medicalProduct)
vaccineType = mappingManager.getVaccinationType(hpkData.vaccineOrProphylaxis)
vaccineManufacturer = mappingManager.getVaccinationManufacturer(hpkData.marketingAuthorizationHolder)
vaccineDisplayName = hpkData.displayName
}

if vaccinName == nil, let brand = event.vaccination?.brand {
vaccinName = mappingManager.getVaccinationBrand(brand)
}
Expand All @@ -164,29 +166,33 @@ 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 ?? "")

return [
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.vaccineType, value: vaccineType),
EventDetails(field: EventDetailsVaccination.vaccineManufacturer, value: vaccineManufacturer),
EventDetails(field: EventDetailsVaccination.dosage, value: dosage),
EventDetails(field: EventDetailsVaccination.completionReason, value: event.vaccination?.completionStatus),
EventDetails(field: EventDetailsVaccination.date, value: formattedShotDate),
EventDetails(field: EventDetailsVaccination.country, value: country),
EventDetails(field: EventDetailsVaccination.uniqueIdentifer, value: event.unique)
]

var details = [EventDetails]()
details += [EventDetails(field: EventDetailsVaccination.subtitle(provider: provider), value: nil)]
details += [EventDetails(field: EventDetailsVaccination.name, value: identity.fullName)]
details += [EventDetails(field: EventDetailsVaccination.dateOfBirth, value: formattedBirthDate)]
details += [EventDetails(field: EventDetailsVaccination.pathogen, value: L.holderEventAboutVaccinationPathogenvalue())]
details += [EventDetails(field: EventDetailsVaccination.vaccineBrand, value: vaccinName)]
if vaccineDisplayName != nil {
details += [EventDetails(field: EventDetailsVaccination.vaccineProductname, value: vaccineDisplayName)]
}
details += [EventDetails(field: EventDetailsVaccination.vaccineType, value: vaccineType)]
details += [EventDetails(field: EventDetailsVaccination.vaccineManufacturer, value: vaccineManufacturer)]
details += [EventDetails(field: EventDetailsVaccination.dosage, value: dosage)]
details += [EventDetails(field: EventDetailsVaccination.completionReason, value: event.vaccination?.completionStatus)]
details += [EventDetails(field: EventDetailsVaccination.date, value: formattedShotDate)]
details += [EventDetails(field: EventDetailsVaccination.country, value: country)]
details += [EventDetails(field: EventDetailsVaccination.uniqueIdentifer, value: event.unique)]

return details
}
}

Expand Down

0 comments on commit 3b4dd57

Please sign in to comment.