diff --git a/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/HealthCertificate.swift b/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/HealthCertificate.swift index 506ccca3faa..e57377f7c8f 100644 --- a/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/HealthCertificate.swift +++ b/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/HealthCertificate.swift @@ -378,7 +378,16 @@ final class HealthCertificate: Codable, Equatable, Comparable, RecycleBinIdentif // This covers scenarios where familyName and givenName were swapped. let hasCrossIntersection_FamilyName_GivenName = familyNameComponents.intersection(other.givenNameComponents).isNotEmpty let hasCrossIntersection_GivenName_FamilyName = givenNameComponents.intersection(other.familyNameComponents).isNotEmpty - let hasCrossNameIntersections = hasCrossIntersection_FamilyName_GivenName && hasCrossIntersection_GivenName_FamilyName + + let hasCrossNameIntersectionWithOneEmptyName: Bool + if givenNameComponents.isEmpty && other.familyNameComponents.isEmpty { + hasCrossNameIntersectionWithOneEmptyName = familyNameComponents.intersection(other.givenNameComponents).isNotEmpty + } else if familyNameComponents.isEmpty && other.givenNameComponents.isEmpty { + hasCrossNameIntersectionWithOneEmptyName = givenNameComponents.intersection(other.familyNameComponents).isNotEmpty + } else { + hasCrossNameIntersectionWithOneEmptyName = false + } + let hasCrossNameIntersections = hasCrossNameIntersectionWithOneEmptyName || (hasCrossIntersection_FamilyName_GivenName && hasCrossIntersection_GivenName_FamilyName) return hasNameIntersections || hasCrossNameIntersections } diff --git a/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/__tests__/HealthCertificate+BelongsToSamePersonTests.swift b/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/__tests__/HealthCertificate+BelongsToSamePersonTests.swift index 2d92f71f5c4..b2a25903627 100644 --- a/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/__tests__/HealthCertificate+BelongsToSamePersonTests.swift +++ b/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/__tests__/HealthCertificate+BelongsToSamePersonTests.swift @@ -66,7 +66,7 @@ class HealthCertificate_BelongsToSamePersonTests: XCTestCase { } private struct TesCaseName: Decodable { - let gnt: String - let fnt: String + let gnt: String? + let fnt: String? } } diff --git a/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/__tests__/Resources/dcc-holder-comparison.json b/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/__tests__/Resources/dcc-holder-comparison.json index f2d43e1022f..65e936e46b9 100644 --- a/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/__tests__/Resources/dcc-holder-comparison.json +++ b/src/xcode/ENA/ENA/Source/Services/HealthCertificate/Models/__tests__/Resources/dcc-holder-comparison.json @@ -1,600 +1,686 @@ { - "$comment": "Generated at Fri Feb 11 2022 10:55:36 GMT+0100 (Central European Standard Time)", - "$sourceHash": "daa5b26f10af1adcf1cc78a9b6d8a1298c31548c3f28d396ebbb938ab22b9f43", - "data": [ - { - "description": "happy path - match", - "actHolderA": { - "nam": { - "gnt": "ERIKA", - "fnt": "MUSTERMANN" - }, - "dob": "1980-02-03" - }, - "actHolderB": { - "nam": { - "gnt": "ERIKA", - "fnt": "MUSTERMANN" - }, - "dob": "1980-02-03" - }, - "expIsSameHolder": true - }, - { - "description": "happy path - no match - different dob", - "actHolderA": { - "nam": { - "gnt": "ERIKA", - "fnt": "MUSTERMANN" - }, - "dob": "1980-02-03" - }, - "actHolderB": { - "nam": { - "gnt": "ERIKA", - "fnt": "MUSTERMANN" - }, - "dob": "1970-01-01" - }, - "expIsSameHolder": false - }, - { - "description": "happy path - no match - no matches in gnt", - "actHolderA": { - "nam": { - "gnt": "ERIKA", - "fnt": "MUSTERMANN" - }, - "dob": "1980-02-03" - }, - "actHolderB": { - "nam": { - "gnt": "ANGELIKA", - "fnt": "MUSTERMANN" - }, - "dob": "1980-02-03" - }, - "expIsSameHolder": false - }, - { - "description": "happy path - no match - no matches in fnt", - "actHolderA": { - "nam": { - "gnt": "ERIKA", - "fnt": "MUSTERMANN" - }, - "dob": "1980-02-03" - }, - "actHolderB": { - "nam": { - "gnt": "ERIKA", - "fnt": "BEISPIELFRAU" - }, - "dob": "1980-02-03" - }, - "expIsSameHolder": false - }, - { - "description": "match despite optional middle name", - "actHolderA": { - "nam": { - "gnt": "ERIKA", - "fnt": "MUSTERMANN" - }, - "dob": "1980-02-03" - }, - "actHolderB": { - "nam": { - "gnt": "ERIKA