Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
{
"WorkflowName": "Common",
"Rules": [
{
"RuleName": "61.Other.SupersededNhsNumber.NoTransformation",
"Expression": "participant.RecordType == Actions.Amended && !string.IsNullOrEmpty(participant.SupersededByNhsNumber) && !string.IsNullOrEmpty(participant.ReasonForRemoval)"
},
{
"RuleName": "60.Other.SupersededNhsNumber",
"Expression": "participant.RecordType == Actions.Amended && !string.IsNullOrEmpty(participant.SupersededByNhsNumber)",
"Expression": "participant.RecordType == Actions.Amended && !string.IsNullOrEmpty(participant.SupersededByNhsNumber) && string.IsNullOrEmpty(participant.ReasonForRemoval)",
"Actions": {
"OnSuccess": {
"Name": "TransformAction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ public async Task CreateTransformExecutedExceptions(CohortDistributionParticipan
{
35 => ExceptionCategory.Confusion,
60 => ExceptionCategory.Superseded,
61 => ExceptionCategory.Superseded,
_ => ExceptionCategory.TransformExecuted
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ public async Task Run_DateOfDeathSuppliedAndReasonForRemovalIsDea_ShouldNotChang
}

[TestMethod]
public async Task Run_SupersededNhsNumberNotNull_TransformAndRaiseException()
public async Task Run_SupersededNhsNumberNotNullAndRfRIsNull_TransformAndRaiseException()
{
// Arrange
_requestBody.Participant.SupersededByNhsNumber = "1234567890";
Expand Down Expand Up @@ -664,6 +664,48 @@ public async Task Run_SupersededNhsNumberNotNull_TransformAndRaiseException()
times: Times.Once);
}

[TestMethod]
public async Task Run_SupersededNhsNumberNotNullAndRfRNotNull_NoTransformAndRaiseException()
{
// Arrange
_requestBody.Participant.SupersededByNhsNumber = "1234567890";
_requestBody.Participant.RecordType = Actions.Amended;
_requestBody.Participant.ReasonForRemoval = "SCT";
_requestBody.Participant.ReasonForRemovalEffectiveFromDate = DateTime.UtcNow.Date.ToString("yyyyMMdd");

var json = JsonSerializer.Serialize(_requestBody);
SetUpRequestBody(json);
var expectedResponse = new CohortDistributionParticipant
{
RecordType = Actions.Amended,
NhsNumber = "1",
SupersededByNhsNumber = "1234567890",
FirstName = "John",
FamilyName = "Smith",
NamePrefix = "MR",
Gender = Gender.Male,
ReferralFlag = false,
PrimaryCareProvider = null,
ReasonForRemoval = "SCT",
ReasonForRemovalEffectiveFromDate = DateTime.UtcNow.Date.ToString("yyyyMMdd")
};

// Act
var result = await _function.RunAsync(_request.Object);

// Assert
string responseBody = await AssertionHelper.ReadResponseBodyAsync(result);

Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
Assert.AreEqual(JsonSerializer.Serialize(expectedResponse), responseBody);
_handleException
.Verify(i => i.CreateTransformExecutedExceptions(It.IsAny<CohortDistributionParticipant>(), "OtherSupersededNhsNumberNoTransformation", 61, null),
times: Times.Once);
_handleException
.Verify(i => i.CreateTransformExecutedExceptions(It.IsAny<CohortDistributionParticipant>(), "OtherSupersededNhsNumber", 60, null),
times: Times.Never);
}

[TestMethod]
public async Task Run_DelRecord_TransformRfrAndRaiseException()
{
Expand Down
Loading