Skip to content

Commit 6e12730

Browse files
chore: addressing comments on pr
1 parent dbe57dc commit 6e12730

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

application/CohortManager/src/Functions/DemographicServices/RetrievePDSDemographic/PdsProcessor.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public PdsProcessor(
3232
_config = retrievePDSDemographicConfig.Value;
3333
}
3434

35+
/// <summary>
36+
/// processes pds error responses. Sends a record to distribute participant via service bus
37+
/// </summary>
38+
/// <param name="pdsResponse"></param>
39+
/// <param name="nhsNumber"></param>
40+
/// <returns></returns>
3541
public async Task ProcessPdsNotFoundResponse(HttpResponseMessage pdsResponse, string nhsNumber)
3642
{
3743
var errorResponse = await pdsResponse!.Content.ReadFromJsonAsync<PdsErrorResponse>();
@@ -54,11 +60,15 @@ public async Task ProcessPdsNotFoundResponse(HttpResponseMessage pdsResponse, st
5460
_logger.LogError("the PDS function has returned a 404 error. function now stopping processing");
5561
}
5662

57-
63+
/// <summary>
64+
/// sends a participant record to the distribute service bus topic
65+
/// </summary>
66+
/// <param name="participant"></param>
67+
/// <returns></returns>
5868
public async Task ProcessRecord(Participant participant)
5969
{
6070
var updateRecord = new ConcurrentQueue<BasicParticipantCsvRecord>();
61-
participant.RecordType = participant.RecordType = Actions.Removed;
71+
participant.RecordType = Actions.Removed;
6272

6373
var basicParticipantCsvRecord = new BasicParticipantCsvRecord
6474
{
@@ -73,7 +83,11 @@ public async Task ProcessRecord(Participant participant)
7383
await _addBatchToQueue.ProcessBatch(updateRecord, _config.ParticipantManagementTopic);
7484
}
7585

76-
86+
/// <summary>
87+
/// adds or updates a demographic record depending on if an record already exists in the database
88+
/// </summary>
89+
/// <param name="participantDemographic"></param>
90+
/// <returns></returns>
7791
public async Task<bool> UpsertDemographicRecordFromPDS(ParticipantDemographic participantDemographic)
7892
{
7993
ParticipantDemographic oldParticipantDemographic = await _participantDemographicClient.GetSingleByFilter(i => i.NhsNumber == participantDemographic.NhsNumber);

tests/PdsProcessorTests/PdsProcessorTests.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
namespace NHS.CohortManager.Tests.PdsProcessorTests;
22

3-
using System.Collections.Concurrent;
4-
using System.Data.Services.Client;
5-
using System.Runtime.CompilerServices;
63
using System.Text.Json;
74
using Common;
85
using DataServices.Client;
9-
using Hl7.Fhir.ElementModel.Types;
10-
using Hl7.Fhir.Model;
116
using Microsoft.Extensions.Logging;
127
using Microsoft.Extensions.Options;
138
using Model;
@@ -52,7 +47,7 @@ public PdsProcessorTests()
5247
}
5348

5449
[TestMethod]
55-
public async System.Threading.Tasks.Task ProcessPdsNotFoundResponse_ProcessesResponse_SendsForDistribution()
50+
public async Task ProcessPdsNotFoundResponse_ProcessesResponse_SendsForDistribution()
5651
{
5752
var errorResponse = new PdsErrorResponse()
5853
{
@@ -96,7 +91,7 @@ public async System.Threading.Tasks.Task ProcessPdsNotFoundResponse_ProcessesRes
9691
}
9792

9893
[TestMethod]
99-
public async System.Threading.Tasks.Task ProcessPdsNotFoundResponse_ProcessesResponse_Logs404Happened()
94+
public async Task ProcessPdsNotFoundResponse_WithNonInvalidatedResource_LogsError()
10095
{
10196
var errorResponse = new PdsErrorResponse()
10297
{
@@ -141,7 +136,7 @@ public async System.Threading.Tasks.Task ProcessPdsNotFoundResponse_ProcessesRes
141136

142137

143138
[TestMethod]
144-
public async System.Threading.Tasks.Task UpsertDemographicRecordFromPDS_Updatesrecord_true()
139+
public async Task UpsertDemographicRecordFromPDS_WithExistingRecord_ReturnsTrue()
145140
{
146141
_dataServiceClient.Setup(x => x.GetSingleByFilter(It.IsAny<System.Linq.Expressions.Expression<Func<ParticipantDemographic, bool>>>())).ReturnsAsync(new ParticipantDemographic()
147142
{
@@ -169,7 +164,7 @@ public async System.Threading.Tasks.Task UpsertDemographicRecordFromPDS_Updatesr
169164

170165

171166
[TestMethod]
172-
public async System.Threading.Tasks.Task UpsertDemographicRecordFromPDS_AddsNewrecord_true()
167+
public async Task UpsertDemographicRecordFromPDS_WithNewRecord_ReturnsTrue()
173168
{
174169
var res = await _pdsProcessor.UpsertDemographicRecordFromPDS(new ParticipantDemographic());
175170

@@ -199,7 +194,7 @@ public async System.Threading.Tasks.Task UpsertDemographicRecordFromPDS_AddsNewr
199194
}
200195

201196
[TestMethod]
202-
public async System.Threading.Tasks.Task UpsertDemographicRecordFromPDS_FailsToAddNewRecord_False()
197+
public async Task UpsertDemographicRecordFromPDS_FailsToAddNewRecord_ReturnsFalse()
203198
{
204199
_dataServiceClient.Setup(x => x.Add(It.IsAny<ParticipantDemographic>())).ReturnsAsync(false);
205200
var res = await _pdsProcessor.UpsertDemographicRecordFromPDS(new ParticipantDemographic());
@@ -229,7 +224,7 @@ public async System.Threading.Tasks.Task UpsertDemographicRecordFromPDS_FailsToA
229224
}
230225

231226
[TestMethod]
232-
public async System.Threading.Tasks.Task UpsertDemographicRecordFromPDS_UpdateRecordFails_False()
227+
public async Task UpsertDemographicRecordFromPDS_UpdateRecordFails_ReturnsFalse()
233228
{
234229
_dataServiceClient.Setup(x => x.GetSingleByFilter(It.IsAny<System.Linq.Expressions.Expression<Func<ParticipantDemographic, bool>>>())).ReturnsAsync(new ParticipantDemographic()
235230
{

0 commit comments

Comments
 (0)