Skip to content

Commit c0c6bff

Browse files
fix: [DTOSS-12058] updated delete function to remove record from demographic table (#1880)
* updated delete function to remove record from demographic table * updated tests
1 parent 90eaa28 commit c0c6bff

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

application/CohortManager/src/Functions/ParticipantManagementServices/DeleteParticipant/DeleteParticipant.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ public class DeleteParticipant
1616
private readonly ILogger<DeleteParticipant> _logger;
1717
private readonly IExceptionHandler _exceptionHandler;
1818
private readonly IDataServiceClient<CohortDistribution> _cohortDistributionClient;
19+
private readonly IDataServiceClient<ParticipantDemographic> _participantDemographic;
1920

2021
public DeleteParticipant(ICreateResponse createResponse, ILogger<DeleteParticipant> logger,
2122
IDataServiceClient<CohortDistribution> cohortDistributionClient,
23+
IDataServiceClient<ParticipantDemographic> participantDemographic,
2224
IExceptionHandler exceptionHandler)
2325
{
2426
_createResponse = createResponse;
2527
_logger = logger;
2628
_exceptionHandler = exceptionHandler;
2729
_cohortDistributionClient = cohortDistributionClient;
30+
_participantDemographic = participantDemographic;
2831
}
2932

3033
/// <summary>
@@ -95,6 +98,7 @@ public async Task<HttpResponseData> RunAsync([HttpTrigger(AuthorizationLevel.Ano
9598
foreach (var participant in participantsToDelete)
9699
{
97100
await _cohortDistributionClient.Delete(participant.CohortDistributionId.ToString());
101+
await _participantDemographic.Delete(participant.ParticipantId.ToString());
98102
}
99103

100104
_logger.LogInformation("Deleted participants");

application/CohortManager/src/Functions/ParticipantManagementServices/DeleteParticipant/DeleteParticipantConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ namespace NHS.Screening.DeleteParticipant;
44

55
public class DeleteParticipantConfig
66
{
7+
8+
[Required]
9+
public required string ParticipantDemographicDataServiceUrl { get; set; }
710
[Required]
811
public required string CohortDistributionDataServiceUrl {get; set;}
912
}

tests/UnitTests/ParticipantManagementServicesTests/DeleteParticipantTests/DeleteParticipantTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class DeleteParticipantTests
2727
private readonly DeleteParticipantRequestBody _requestBody;
2828
private readonly Mock<IExceptionHandler> _exceptionHandler = new();
2929
private Mock<IDataServiceClient<CohortDistribution>> _cohortDistributionClientMock = new();
30+
private Mock<IDataServiceClient<ParticipantDemographic>> _mockParticipantDemographicClient = new();
3031

3132
public DeleteParticipantTests()
3233
{
@@ -40,7 +41,7 @@ public DeleteParticipantTests()
4041

4142
_request = _setupRequest.Setup(JsonSerializer.Serialize(_requestBody));
4243

43-
_sut = new DeleteParticipant(_createResponse.Object, _logger.Object, _cohortDistributionClientMock.Object,
44+
_sut = new DeleteParticipant(_createResponse.Object, _logger.Object, _cohortDistributionClientMock.Object, _mockParticipantDemographicClient.Object,
4445
_exceptionHandler.Object);
4546

4647
_createResponse.Setup(x => x.CreateHttpResponse(It.IsAny<HttpStatusCode>(), It.IsAny<HttpRequestData>(), It.IsAny<string>()))

0 commit comments

Comments
 (0)