From 9f8cc5a92f261c7080ad3d1fdcdffae51b0d5871 Mon Sep 17 00:00:00 2001 From: HarmeetRandhawa-NHS <264994822+HarmeetRandhawa-NHS@users.noreply.github.com> Date: Wed, 11 Mar 2026 11:26:41 +0000 Subject: [PATCH 1/4] fix: added logic to get data from PDS and update Demographic table --- .../UpdateBlockedFlag/BlockParticipantHandler.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/application/CohortManager/src/Functions/ParticipantManagementServices/UpdateBlockedFlag/BlockParticipantHandler.cs b/application/CohortManager/src/Functions/ParticipantManagementServices/UpdateBlockedFlag/BlockParticipantHandler.cs index 0c7646d8eb..05464039bb 100644 --- a/application/CohortManager/src/Functions/ParticipantManagementServices/UpdateBlockedFlag/BlockParticipantHandler.cs +++ b/application/CohortManager/src/Functions/ParticipantManagementServices/UpdateBlockedFlag/BlockParticipantHandler.cs @@ -53,8 +53,20 @@ public async Task BlockParticipant(BlockParticipantDto b return new BlockParticipantResult(false, "Participant Already Blocked"); } + var pdsParticipant = await GetPDSParticipant(blockParticipantRequest.NhsNumber); + + if (pdsParticipant == null ) + { + return new BlockParticipantResult(false, "Participant details do not match a record in PDS"); + } + var participantDemographic = await _participantDemographicDataService.GetSingleByFilter(x => x.NhsNumber == blockParticipantRequest.NhsNumber); + if (participantDemographic == null) + { + return new BlockParticipantResult(false, "Can not retrieve record from demographic"); + } + if (!ValidateRecordsMatch(participantDemographic, blockParticipantRequest)) { _logger.LogWarning("Participant didn't pass three point check and cannot be blocked"); From c68ed66195ea92b3b264a6c15bd30bb73d606e95 Mon Sep 17 00:00:00 2001 From: HarmeetRandhawa-NHS <264994822+HarmeetRandhawa-NHS@users.noreply.github.com> Date: Thu, 12 Mar 2026 11:29:35 +0000 Subject: [PATCH 2/4] updated test class --- .../UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs b/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs index 209b8bead4..eeeb943f0a 100644 --- a/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs +++ b/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs @@ -95,13 +95,24 @@ public async Task BlockParticipant_ExistingParticipant_ReturnsSuccess() }); + _mockParticipantDemographicClient.Setup(x => x.Update(It.IsAny())) + .ReturnsAsync(true); + _mockHttpClient.Setup(x => x.SendPost("RetrievePdsDemographicUrl", It.IsAny>())) + .ReturnsAsync(new HttpResponseMessage + { + StatusCode = HttpStatusCode.OK + }); + + //act var result = await _sut.BlockParticipant(_request.Object); //asset Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); _mockHttpClient.Verify(x => x.SendPost("NemsUnsubscribeUrl", It.IsAny>()), Times.Once); + _mockHttpClient.Verify(x => x.SendPost("RetrievePdsDemographicUrl", It.IsAny>()), Times.Once); _mockParticipantManagementClient.Verify(x => x.Update(It.IsAny()), Times.Once); + _mockParticipantManagementClient.Verify(x => x.Update(It.IsAny()), Times.Once); _mockHttpClient.VerifyNoOtherCalls(); } [TestMethod] From e6678968025b3895747a917bb584b25b2fcc7285 Mon Sep 17 00:00:00 2001 From: HarmeetRandhawa-NHS <264994822+HarmeetRandhawa-NHS@users.noreply.github.com> Date: Thu, 12 Mar 2026 12:12:58 +0000 Subject: [PATCH 3/4] updated test class --- .../UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs b/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs index eeeb943f0a..7b4de6b24b 100644 --- a/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs +++ b/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs @@ -97,7 +97,7 @@ public async Task BlockParticipant_ExistingParticipant_ReturnsSuccess() _mockParticipantDemographicClient.Setup(x => x.Update(It.IsAny())) .ReturnsAsync(true); - _mockHttpClient.Setup(x => x.SendPost("RetrievePdsDemographicUrl", It.IsAny>())) + _mockHttpClient.Setup(x => x.SendGet("RetrievePdsDemographicUrl", It.IsAny>())) .ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK @@ -110,9 +110,10 @@ public async Task BlockParticipant_ExistingParticipant_ReturnsSuccess() //asset Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); _mockHttpClient.Verify(x => x.SendPost("NemsUnsubscribeUrl", It.IsAny>()), Times.Once); - _mockHttpClient.Verify(x => x.SendPost("RetrievePdsDemographicUrl", It.IsAny>()), Times.Once); + _mockHttpClient.Verify(x => x.SendGet("RetrievePdsDemographicUrl", It.IsAny>()), Times.Once); _mockParticipantManagementClient.Verify(x => x.Update(It.IsAny()), Times.Once); - _mockParticipantManagementClient.Verify(x => x.Update(It.IsAny()), Times.Once); + _mockParticipantDemographicClient.Verify(x => x.Update(It.IsAny()), Times.Once); + _mockHttpClient.VerifyNoOtherCalls(); } [TestMethod] @@ -243,10 +244,11 @@ public async Task BlockParticipant_ExistingParticipantFailsThreePointCheck_Retur //asset Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode); _mockHttpClient.Verify(x => x.SendPost("NemsUnsubscribeUrl", It.IsAny>()), Times.Never); + _mockHttpClient.Verify(x => x.SendGet("RetrievePdsDemographicUrl", It.IsAny>()), Times.Once); _mockHttpClient.VerifyNoOtherCalls(); _mockParticipantManagementClient.Verify(x => x.GetSingleByFilter(It.IsAny>>()), Times.Once); _mockParticipantManagementClient.VerifyNoOtherCalls(); - _mockParticipantDemographicClient.Verify(x => x.GetSingleByFilter(It.IsAny>>()), Times.Once); + _mockParticipantDemographicClient.Verify(x => x.GetSingleByFilter(It.IsAny>>()), Times.Never); _mockParticipantDemographicClient.VerifyNoOtherCalls(); } [TestMethod] From a3cd7f72c5e3b7ba8422fbacc3b90341ef7f3ae5 Mon Sep 17 00:00:00 2001 From: HarmeetRandhawa-NHS <264994822+HarmeetRandhawa-NHS@users.noreply.github.com> Date: Thu, 12 Mar 2026 16:22:03 +0000 Subject: [PATCH 4/4] test class update --- .../UpdateBlockedFlagTests.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs b/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs index 7b4de6b24b..4da5f0348d 100644 --- a/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs +++ b/tests/UnitTests/ParticipantManagementServicesTests/UpdateBlockedFlagTests/UpdateBlockedFlagTests.cs @@ -86,24 +86,26 @@ public async Task BlockParticipant_ExistingParticipant_ReturnsSuccess() DateOfBirth = "19231012" }); - _mockParticipantManagementClient.Setup(x => x.Update(It.IsAny())) - .ReturnsAsync(true); - _mockHttpClient.Setup(x => x.SendPost("NemsUnsubscribeUrl", It.IsAny>())) - .ReturnsAsync(new HttpResponseMessage + var pdsDemoResponse = JsonSerializer.Serialize( + new PdsDemographic { - StatusCode = HttpStatusCode.OK + NhsNumber = "6427635034", + FamilyName = "Jones", + DateOfBirth = "1923-10-12" }); + _mockHttpClient.Setup(x => x.SendGet("RetrievePdsDemographicUrl", It.IsAny>())) + .ReturnsAsync(pdsDemoResponse); - _mockParticipantDemographicClient.Setup(x => x.Update(It.IsAny())) + + _mockParticipantManagementClient.Setup(x => x.Update(It.IsAny())) .ReturnsAsync(true); - _mockHttpClient.Setup(x => x.SendGet("RetrievePdsDemographicUrl", It.IsAny>())) + _mockHttpClient.Setup(x => x.SendPost("NemsUnsubscribeUrl", It.IsAny>())) .ReturnsAsync(new HttpResponseMessage { StatusCode = HttpStatusCode.OK }); - //act var result = await _sut.BlockParticipant(_request.Object); @@ -112,8 +114,6 @@ public async Task BlockParticipant_ExistingParticipant_ReturnsSuccess() _mockHttpClient.Verify(x => x.SendPost("NemsUnsubscribeUrl", It.IsAny>()), Times.Once); _mockHttpClient.Verify(x => x.SendGet("RetrievePdsDemographicUrl", It.IsAny>()), Times.Once); _mockParticipantManagementClient.Verify(x => x.Update(It.IsAny()), Times.Once); - _mockParticipantDemographicClient.Verify(x => x.Update(It.IsAny()), Times.Once); - _mockHttpClient.VerifyNoOtherCalls(); } [TestMethod]