Skip to content

Commit 64bb1e6

Browse files
fix: 11230 add unique nhs number demograpghic table (#1716)
* fix: adding unique constraint for nhs number * fix: making sure add date time and updated date time are correct for demograpghic records * fix: removing uwanted usings
1 parent 423dccd commit 64bb1e6

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

application/CohortManager/src/Functions/CaasIntegration/receiveCaasFile/ProcessFileClasses/ProcessCaasFile.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ namespace NHS.Screening.ReceiveCaasFile;
33
using System.Text.Json;
44
using Common;
55
using Common.Interfaces;
6-
using Data.Database;
76
using DataServices.Client;
8-
using Hl7.Fhir.Rest;
97
using Microsoft.Extensions.Logging;
108
using Microsoft.Extensions.Options;
11-
using Microsoft.IdentityModel.Protocols.Configuration;
129
using Model;
1310
using Model.Enums;
11+
using NHS.CohortManager.Shared.Utilities;
1412

1513
public class ProcessCaasFile : IProcessCaasFile
1614
{
@@ -121,12 +119,12 @@ private async Task AddRecordToBatch(Participant participant, Batch currentBatch,
121119
{
122120

123121
case Actions.New:
122+
124123
currentBatch.AddRecords.Enqueue(basicParticipantCsvRecord);
125124
if (await UpdateOldDemographicRecord(basicParticipantCsvRecord, fileName))
126125
{
127126
break;
128127
}
129-
130128
currentBatch.DemographicData.Enqueue(participant.ToParticipantDemographic());
131129
break;
132130
case Actions.Amended:
@@ -185,9 +183,13 @@ private async Task<bool> UpdateOldDemographicRecord(BasicParticipantCsvRecord ba
185183
return false;
186184
}
187185

186+
basicParticipantCsvRecord.Participant.RecordInsertDateTime = participant.RecordInsertDateTime?.ToString("yyyy-MM-dd HH:mm:ss");
188187
var participantForUpdate = basicParticipantCsvRecord.Participant.ToParticipantDemographic();
188+
189+
participantForUpdate.RecordUpdateDateTime = DateTime.UtcNow;
189190
participantForUpdate.ParticipantId = participant.ParticipantId;
190191

192+
191193
var updated = await _participantDemographic.Update(participantForUpdate);
192194
if (updated)
193195
{

application/CohortManager/src/Functions/Shared/Model/Participant.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ public ParticipantDemographic ToParticipantDemographic()
154154
PreferredLanguage = PreferredLanguage,
155155
InterpreterRequired = !string.IsNullOrEmpty(IsInterpreterRequired) ? short.Parse(IsInterpreterRequired) : null,
156156
InvalidFlag = (short?)GetInvalidFlag(),
157-
RecordInsertDateTime = DateTime.UtcNow,
158-
RecordUpdateDateTime = null,
157+
RecordInsertDateTime = !string.IsNullOrEmpty(RecordInsertDateTime) ? MappingUtilities.ParseDates(RecordInsertDateTime) : DateTime.UtcNow,
158+
RecordUpdateDateTime = !string.IsNullOrEmpty(RecordUpdateDateTime) ? MappingUtilities.ParseDates(RecordUpdateDateTime) : null
159159
};
160160
}
161161

0 commit comments

Comments
 (0)