Skip to content

Commit f85e143

Browse files
authored
fix: DTOSS-11714 Updating rule 60 Superseded Numbers and adding a new rule 61 (#1779)
* fix: Added condition to rule 60 supersedes transformation and added rule 61 no transformation * fix: Small formatting change * fix: Added correct category to rule 61 so it can be viewed on the superseded report * Updated rule 61
1 parent 0bfee35 commit f85e143

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

application/CohortManager/src/Functions/CohortDistributionServices/TransformDataService/transformRules.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
{
33
"WorkflowName": "Common",
44
"Rules": [
5+
{
6+
"RuleName": "61.Other.SupersededNhsNumber.NoTransformation",
7+
"Expression": "participant.RecordType == Actions.Amended && !string.IsNullOrEmpty(participant.SupersededByNhsNumber) && !string.IsNullOrEmpty(participant.ReasonForRemoval)"
8+
},
59
{
610
"RuleName": "60.Other.SupersededNhsNumber",
7-
"Expression": "participant.RecordType == Actions.Amended && !string.IsNullOrEmpty(participant.SupersededByNhsNumber)",
11+
"Expression": "participant.RecordType == Actions.Amended && !string.IsNullOrEmpty(participant.SupersededByNhsNumber) && string.IsNullOrEmpty(participant.ReasonForRemoval)",
812
"Actions": {
913
"OnSuccess": {
1014
"Name": "TransformAction",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ public async Task CreateTransformExecutedExceptions(CohortDistributionParticipan
386386
{
387387
35 => ExceptionCategory.Confusion,
388388
60 => ExceptionCategory.Superseded,
389+
61 => ExceptionCategory.Superseded,
389390
_ => ExceptionCategory.TransformExecuted
390391
};
391392
}

tests/UnitTests/TransformDataServiceTests/TransformDataServiceTests/TransformDataServiceTests.cs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ public async Task Run_DateOfDeathSuppliedAndReasonForRemovalIsDea_ShouldNotChang
630630
}
631631

632632
[TestMethod]
633-
public async Task Run_SupersededNhsNumberNotNull_TransformAndRaiseException()
633+
public async Task Run_SupersededNhsNumberNotNullAndRfRIsNull_TransformAndRaiseException()
634634
{
635635
// Arrange
636636
_requestBody.Participant.SupersededByNhsNumber = "1234567890";
@@ -664,6 +664,48 @@ public async Task Run_SupersededNhsNumberNotNull_TransformAndRaiseException()
664664
times: Times.Once);
665665
}
666666

667+
[TestMethod]
668+
public async Task Run_SupersededNhsNumberNotNullAndRfRNotNull_NoTransformAndRaiseException()
669+
{
670+
// Arrange
671+
_requestBody.Participant.SupersededByNhsNumber = "1234567890";
672+
_requestBody.Participant.RecordType = Actions.Amended;
673+
_requestBody.Participant.ReasonForRemoval = "SCT";
674+
_requestBody.Participant.ReasonForRemovalEffectiveFromDate = DateTime.UtcNow.Date.ToString("yyyyMMdd");
675+
676+
var json = JsonSerializer.Serialize(_requestBody);
677+
SetUpRequestBody(json);
678+
var expectedResponse = new CohortDistributionParticipant
679+
{
680+
RecordType = Actions.Amended,
681+
NhsNumber = "1",
682+
SupersededByNhsNumber = "1234567890",
683+
FirstName = "John",
684+
FamilyName = "Smith",
685+
NamePrefix = "MR",
686+
Gender = Gender.Male,
687+
ReferralFlag = false,
688+
PrimaryCareProvider = null,
689+
ReasonForRemoval = "SCT",
690+
ReasonForRemovalEffectiveFromDate = DateTime.UtcNow.Date.ToString("yyyyMMdd")
691+
};
692+
693+
// Act
694+
var result = await _function.RunAsync(_request.Object);
695+
696+
// Assert
697+
string responseBody = await AssertionHelper.ReadResponseBodyAsync(result);
698+
699+
Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
700+
Assert.AreEqual(JsonSerializer.Serialize(expectedResponse), responseBody);
701+
_handleException
702+
.Verify(i => i.CreateTransformExecutedExceptions(It.IsAny<CohortDistributionParticipant>(), "OtherSupersededNhsNumberNoTransformation", 61, null),
703+
times: Times.Once);
704+
_handleException
705+
.Verify(i => i.CreateTransformExecutedExceptions(It.IsAny<CohortDistributionParticipant>(), "OtherSupersededNhsNumber", 60, null),
706+
times: Times.Never);
707+
}
708+
667709
[TestMethod]
668710
public async Task Run_DelRecord_TransformRfrAndRaiseException()
669711
{

0 commit comments

Comments
 (0)