Skip to content

Commit 384e4e6

Browse files
fix: fixing history
1 parent 2fa0f10 commit 384e4e6

3 files changed

Lines changed: 18 additions & 24 deletions

File tree

application/CohortManager/src/Functions/Shared/Common/FhirPatientDemographicMapper.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace Common;
1010
using Model.Enums;
1111
using System;
1212
using System.Linq;
13-
using NHS.CohortManager.Shared.Utilities;
1413

1514
public class FhirPatientDemographicMapper : IFhirPatientDemographicMapper
1615
{
@@ -121,7 +120,7 @@ public PdsDemographic MapPatientToPDSDemographic(Patient patient)
121120
demographic.ParticipantId = null; // We do not know the Participant ID from PDS
122121
demographic.RecordUpdateDateTime = null; // We do not know the RecordUpdateDateTime from PDS
123122
demographic.RecordInsertDateTime = null; // We do not know the RecordInsertDateTime from PDS
124-
demographic.DateOfBirth = FormatDates(patient.BirthDate);
123+
demographic.DateOfBirth = patient.BirthDate;
125124

126125
// CurrentPosting & CurrentPostingEffectiveFromDate
127126
// these are not set as not available in PDS
@@ -151,7 +150,7 @@ private static void MapPrimaryCareProvider(Patient patient, Demographic demograp
151150
demographic.PrimaryCareProvider = gp.Identifier.Value;
152151

153152
if (gp.Identifier.Period?.Start != null)
154-
demographic.PrimaryCareProviderEffectiveFromDate = FormatDates(gp.Identifier.Period.Start);
153+
demographic.PrimaryCareProviderEffectiveFromDate = gp.Identifier.Period.Start.ToString();
155154
}
156155

157156
private static void MapNames(Patient patient, Demographic demographic)
@@ -247,7 +246,7 @@ private static void MapAddressComponents(Address address, Demographic demographi
247246
// Map effective date
248247
if (address.Period?.Start != null)
249248
{
250-
demographic.UsualAddressEffectiveFromDate = FormatDates(address.Period.Start);
249+
demographic.UsualAddressEffectiveFromDate = address.Period.Start.ToString();
251250
}
252251
}
253252

@@ -359,7 +358,7 @@ private static void MapContactPoint(
359358

360359
if (contactPoint.Period?.Start != null)
361360
{
362-
setDateAction(FormatDates(contactPoint.Period.Start));
361+
setDateAction(contactPoint.Period.Start.ToString());
363362
}
364363
}
365364

@@ -452,11 +451,4 @@ private static void MapSecurityMetadata(Patient patient, PdsDemographic demograp
452451

453452
demographic.ConfidentialityCode = confidentialityCoding.Code;
454453
}
455-
456-
private static string FormatDates(string dateToConvert)
457-
{
458-
var parsedDateTime = MappingUtilities.ParseDates(dateToConvert);
459-
return parsedDateTime?.ToString("yyyyMMdd")!;
460-
}
461-
462454
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
namespace Model;
22

3+
using System.Data;
34
using System.Text.Json.Serialization;
45
using Model.Enums;
6+
using NHS.CohortManager.Shared.Utilities;
57

68
public class PdsDemographic : Demographic
79
{
@@ -27,7 +29,7 @@ public ParticipantDemographic ToParticipantDemographic()
2729
OtherGivenName = OtherGivenNames,
2830
FamilyName = FamilyName,
2931
PreviousFamilyName = PreviousFamilyName,
30-
DateOfBirth = DateOfBirth,
32+
DateOfBirth = MappingUtilities.ParseDates(DateOfBirth!)?.ToString("yyyyMMdd"),
3133
Gender = (short?)(Gender.HasValue ? (Gender?)Gender.Value : null),
3234
AddressLine1 = AddressLine1,
3335
AddressLine2 = AddressLine2,
@@ -36,15 +38,15 @@ public ParticipantDemographic ToParticipantDemographic()
3638
AddressLine5 = AddressLine5,
3739
PostCode = Postcode,
3840
PafKey = PafKey,
39-
UsualAddressFromDate = UsualAddressEffectiveFromDate,
41+
UsualAddressFromDate = MappingUtilities.ParseDates(UsualAddressEffectiveFromDate!)?.ToString("yyyyMMdd"),
4042
DateOfDeath = DateOfDeath,
4143
DeathStatus = (short?)(DeathStatus.HasValue ? (Status?)DeathStatus.Value : null),
4244
TelephoneNumberHome = TelephoneNumber,
43-
TelephoneNumberHomeFromDate = TelephoneNumberEffectiveFromDate,
45+
TelephoneNumberHomeFromDate = MappingUtilities.ParseDates(TelephoneNumberEffectiveFromDate!)?.ToString("yyyy-MM-dd"),
4446
TelephoneNumberMob = MobileNumber,
45-
TelephoneNumberMobFromDate = MobileNumberEffectiveFromDate,
47+
TelephoneNumberMobFromDate = MappingUtilities.ParseDates(MobileNumberEffectiveFromDate!)?.ToString("yyyyMMdd"),
4648
EmailAddressHome = EmailAddress,
47-
EmailAddressHomeFromDate = EmailAddressEffectiveFromDate,
49+
EmailAddressHomeFromDate = MappingUtilities.ParseDates(EmailAddressEffectiveFromDate!)?.ToString("yyyyMMdd"),
4850
PreferredLanguage = PreferredLanguage,
4951
InterpreterRequired = IsInterpreterRequired?.ToLower() switch
5052
{

tests/UnitTests/SharedTests/FhirPatientDemographicMapperTests/FhirPatientDemographicMapperTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ public void FhirParser_ValidJson_ReturnsDemographic()
9090
ParticipantId = null,
9191
RecordUpdateDateTime = null,
9292
RecordInsertDateTime = null,
93-
DateOfBirth = "20101022",
93+
DateOfBirth = "2010-10-22",
9494

9595
// Primary Care Provider
9696
PrimaryCareProvider = "Y12345",
97-
PrimaryCareProviderEffectiveFromDate = "20200101",
97+
PrimaryCareProviderEffectiveFromDate = "2020-01-01",
9898

9999
// Name Information
100100
NamePrefix = "Mrs",
@@ -114,19 +114,19 @@ public void FhirParser_ValidJson_ReturnsDemographic()
114114
AddressLine5 = "West Yorkshire",
115115
Postcode = "LS1 6AE",
116116
PafKey = "12345678",
117-
UsualAddressEffectiveFromDate = "20200101",
117+
UsualAddressEffectiveFromDate = "2020-01-01",
118118

119119
// Death Information
120120
DateOfDeath = "2010-10-22T00:00:00+00:00",
121121
DeathStatus = Status.Formal, // "Formal - death notice received from Registrar of Deaths"
122122

123123
// Contact Information
124124
TelephoneNumber = "01632960587", // Home phone
125-
TelephoneNumberEffectiveFromDate = "20200101",
125+
TelephoneNumberEffectiveFromDate = "2020-01-01",
126126
MobileNumber = null, // No mobile phone in the sample
127127
MobileNumberEffectiveFromDate = null,
128128
EmailAddress = "jane.smith@example.com",
129-
EmailAddressEffectiveFromDate = "20190101",
129+
EmailAddressEffectiveFromDate = "2019-01-01",
130130

131131
// Language Preferences
132132
PreferredLanguage = "fr",
@@ -215,7 +215,7 @@ public void FhirParser_SensitivePatient_MapsCorrectly()
215215

216216
// Basic Information
217217
Assert.AreEqual("9000000025", result.NhsNumber);
218-
Assert.AreEqual("20101022", result.DateOfBirth);
218+
Assert.AreEqual("2010-10-22", result.DateOfBirth);
219219
Assert.AreEqual(Gender.Female, result.Gender);
220220

221221
// Name Information
@@ -340,7 +340,7 @@ public void FhirParser_PatientWithMobileNumber_MapsCorrectly()
340340

341341
// Assert
342342
Assert.AreEqual("07700900123", result.MobileNumber);
343-
Assert.AreEqual("20200101", result.MobileNumberEffectiveFromDate);
343+
Assert.AreEqual("2020-01-01", result.MobileNumberEffectiveFromDate);
344344
}
345345

346346
[TestMethod]

0 commit comments

Comments
 (0)