Skip to content

Commit 16d7b3c

Browse files
fix: now returns to TransformReasonForRemoval so transform rules are not effected and can run properly
1 parent 7569e06 commit 16d7b3c

5 files changed

Lines changed: 9 additions & 36 deletions

File tree

application/CohortManager/src/Functions/CohortDistributionServices/TransformDataService/TransformDataLookupFacade.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,10 @@ public async Task<HashSet<string>> GetCachedExcludedSMUValues()
6464
public bool ValidateOutcode(string postcode)
6565
{
6666
var parsedOutCode = ValidationHelper.ParseOutcode(postcode);
67-
_ = parsedOutCode.outcode
67+
_ = parsedOutCode
6868
?? throw new TransformationException("Postcode format invalid");
6969

70-
// we can bypass checking the database if it's a dummy postcode
71-
if (parsedOutCode.isDummyPostCode)
72-
{
73-
return true;
74-
}
75-
76-
var result = _outcodeClient.GetSingle(parsedOutCode.outcode).Result;
70+
var result = _outcodeClient.GetSingle(parsedOutCode).Result;
7771
return result != null;
7872

7973
}
@@ -91,7 +85,7 @@ public bool ValidateLanguageCode(string languageCode)
9185

9286
public string GetBsoCode(string postcode)
9387
{
94-
string outcode = ValidationHelper.ParseOutcode(postcode).outcode
88+
string outcode = ValidationHelper.ParseOutcode(postcode)
9589
?? throw new TransformationException("Postcode format invalid");
9690

9791
var result = _outcodeClient.GetSingle(outcode).Result;

application/CohortManager/src/Functions/CohortDistributionServices/TransformDataService/TransformReasonForRemoval.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ namespace NHS.CohortManager.CohortDistributionService;
22

33
using Model;
44
using Common;
5-
using Data.Database;
65
using System.Text.Json;
7-
using Apache.Arrow.Types;
6+
87

98
public class TransformReasonForRemoval : ITransformReasonForRemoval
109
{

application/CohortManager/src/Functions/ScreeningValidationService/LookupValidation/DataLookupFacadeBreastScreening.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public bool ValidateOutcode(string postcode)
5353
{
5454
var outcode = ValidationHelper.ParseOutcode(postcode);
5555
_logger.LogInformation("Validating Outcode: {Outcode}", outcode);
56-
var result = _outcodeClient.GetSingle(outcode.outcode!).Result;
56+
var result = _outcodeClient.GetSingle(outcode!).Result;
5757

5858
return result != null;
5959
}

application/CohortManager/src/Functions/Shared/Common/ValidationHelper.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static bool ValidatePostcode(string postcode)
110110
/// Works for valid UK postcodes and dummy postcodes.
111111
/// Works with or without a space separator between outcode and incode.
112112
/// </remarks>
113-
public static (string? outcode, bool isDummyPostCode) ParseOutcode(string postcode)
113+
public static string? ParseOutcode(string postcode)
114114
{
115115
string pattern = @"^([A-Za-z][A-Za-z]?[0-9][A-Za-z0-9]?) ?[0-9][A-Za-z]{2}$";
116116
string specialDummyOutCodePattern = "^ZZ99|^ZZZSECUR$";
@@ -120,19 +120,16 @@ public static (string? outcode, bool isDummyPostCode) ParseOutcode(string postco
120120

121121
if (dummyOutCodePattern.Success)
122122
{
123-
return (postcode, true);
123+
return dummyOutCodePattern.Groups[1].Value;
124124
}
125125

126126
if (!match.Success)
127127
{
128-
return (null, false);
128+
return null;
129129
}
130130

131-
132-
133131
string outcode = match.Groups[1].Value;
134-
135-
return (outcode, false);
132+
return outcode;
136133
}
137134

138135
private static bool ParseInt32(char value, out int integerValue)

tests/UnitTests/TransformDataServiceTests/TransformDataServiceTests/TransformDataLookupFacadeTests.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,6 @@ public void ValidateOutcode_OutcodeNotFound_ReturnFalse()
9595
Assert.IsFalse(result);
9696
}
9797

98-
[TestMethod]
99-
public void ValidateOutcode_OutCodeIsSpecial_ReturnTrue()
100-
{
101-
// Arrange
102-
_outcodeClientMock
103-
.Setup(x => x.GetSingle(It.IsAny<string>()))
104-
.ReturnsAsync((BsSelectOutCode)null);
105-
106-
string postcode = "ZZZSECUR";
107-
108-
// Act
109-
bool result = _sut.ValidateOutcode(postcode);
110-
111-
// Assert
112-
Assert.IsTrue(result);
113-
}
114-
11598
[TestMethod]
11699
[DataRow("")]
117100
[DataRow("ABC123")]

0 commit comments

Comments
 (0)