Skip to content

Commit 6f686c4

Browse files
Merge branch 'main' into DTOSS-7817-SonarCloud-Coverage-Refinements
2 parents 90d5280 + a14a3b9 commit 6f686c4

File tree

4 files changed

+113
-19
lines changed

4 files changed

+113
-19
lines changed

application/CohortManager/src/Functions/ScreeningValidationService/LookupValidation/Breast_Screening_lookupRules.json

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
{
66
"Name": "ValidCurrentPosting",
77
"Expression": "string.IsNullOrEmpty(newParticipant.CurrentPosting) OR dbLookup.CheckIfCurrentPostingExists(newParticipant.CurrentPosting)"
8+
},
9+
{
10+
"Name": "ValidPrimaryCareProvider",
11+
"Expression": "string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) || dbLookup.CheckIfPrimaryCareProviderExists(newParticipant.PrimaryCareProvider)"
812
}
913
],
1014
"Rules": [
@@ -21,8 +25,8 @@
2125
}
2226
},
2327
{
24-
"RuleName": "36.ValidatePrimaryCareProvider.BSSelect.NonFatal",
25-
"Expression": "string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) || dbLookup.CheckIfPrimaryCareProviderExists(newParticipant.primaryCareProvider)",
28+
"RuleName": "3601.ValidatePrimaryCareProvider.BSSelect.NonFatal",
29+
"Expression": "ValidPrimaryCareProvider",
2630
"Actions": {
2731
"OnFailure": {
2832
"Name": "OutputExpression",
@@ -33,18 +37,22 @@
3337
}
3438
},
3539
{
36-
"RuleName": "3645.CurrentPostingAndPrimaryProvider.BSSelect.NonFatal",
40+
"RuleName": "3602.CurrentPostingAndPrimaryProvider.BSSelect.NonFatal",
3741
"LocalParams": [
3842
{
39-
"Name": "ValidPostingCategory",
40-
"Expression": "dbLookup.ValidatePostingCategories(newParticipant.CurrentPosting)"
41-
},
42-
{
43-
"Name": "InvalidPrimaryCareProvider",
44-
"Expression": "!string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) AND !dbLookup.CheckIfPrimaryCareProviderExists(newParticipant.PrimaryCareProvider)"
43+
"Name": "EnglishPostingCategory",
44+
"Expression": "dbLookup.RetrievePostingCategory(newParticipant.CurrentPosting) == \"ENGLAND\""
4545
}
4646
],
47-
"Expression": "!(ValidPostingCategory AND InvalidPrimaryCareProvider)"
47+
"Expression": "!((EnglishPostingCategory || new[] {\"ENG\", \"DMS\", \"IM\"}.Contains(newParticipant.CurrentPosting)) && !string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) && !dbLookup.CheckIfPrimaryCareProviderExists(newParticipant.PrimaryCareProvider))",
48+
"Actions": {
49+
"OnFailure": {
50+
"Name": "OutputExpression",
51+
"Context": {
52+
"Expression": "\"Invalid primary care provider GP practice code\""
53+
}
54+
}
55+
}
4856
},
4957
{
5058
"RuleName": "58.CurrentPosting.NBO.NonFatal",

tests/UnitTests/ScreeningValidationServiceTests/LookupValidation/LookupValidationTests.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ public async Task Run_CurrentPosting_DoesNotCreateException(string currentPostin
456456
}
457457

458458
[TestMethod]
459-
[DataRow("ValidCurrentPosting", "InvalidPCP")]
459+
[DataRow("ENG", "InvalidPCP")]
460460
public async Task Run_CurrentPostingAndPrimaryProvider_CreatesException(string currentPosting, string primaryCareProvider)
461461
{
462462
// Arrange
@@ -466,15 +466,14 @@ public async Task Run_CurrentPostingAndPrimaryProvider_CreatesException(string c
466466
var json = JsonSerializer.Serialize(_requestBody);
467467
SetUpRequestBody(json);
468468

469-
_lookupValidation.Setup(x => x.ValidatePostingCategories(It.IsAny<string>())).Returns(currentPosting == "ValidCurrentPosting");
470-
_lookupValidation.Setup(x => x.CheckIfPrimaryCareProviderExists(It.IsAny<string>())).Returns(primaryCareProvider == "ValidPCP");
469+
_lookupValidation.Setup(x => x.CheckIfPrimaryCareProviderExists(It.IsAny<string>())).Returns(false);
471470

472471
// Act
473472
await _sut.RunAsync(_request.Object);
474473

475474
// Assert
476475
_exceptionHandler.Verify(handleException => handleException.CreateValidationExceptionLog(
477-
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "3645.CurrentPostingAndPrimaryProvider.BSSelect.NonFatal")),
476+
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "3602.CurrentPostingAndPrimaryProvider.BSSelect.NonFatal")),
478477
It.IsAny<ParticipantCsvRecord>()),
479478
Times.Once());
480479
}
@@ -502,7 +501,7 @@ public async Task Run_CurrentPostingAndPrimaryProvider_DoesNotCreateException(st
502501

503502
// Assert
504503
_exceptionHandler.Verify(handleException => handleException.CreateValidationExceptionLog(
505-
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "3645.CurrentPostingAndPrimaryProvider.NonFatal")),
504+
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "3602.CurrentPostingAndPrimaryProvider.NonFatal")),
506505
It.IsAny<ParticipantCsvRecord>()),
507506
Times.Never());
508507
}
@@ -525,7 +524,7 @@ public async Task Run_ValidatePrimaryCareProvider_CreatesException(string primar
525524
// Assert
526525
Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);
527526
_exceptionHandler.Verify(handleException => handleException.CreateValidationExceptionLog(
528-
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "36.ValidatePrimaryCareProvider.BSSelect.NonFatal")),
527+
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "3601.ValidatePrimaryCareProvider.BSSelect.NonFatal")),
529528
It.IsAny<ParticipantCsvRecord>()),
530529
Times.Once());
531530
}
@@ -549,7 +548,7 @@ public async Task Run_ValidatePrimaryCareProvider_DoesNotCreateException(string
549548
// Assert
550549
Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
551550
_exceptionHandler.Verify(handleException => handleException.CreateValidationExceptionLog(
552-
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "36.ValidatePrimaryCareProvider.NonFatal")),
551+
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "3601.ValidatePrimaryCareProvider.BSSelect.NonFatal")),
553552
It.IsAny<ParticipantCsvRecord>()),
554553
Times.Never());
555554
}

tests/playwright-tests/src/tests/e2e/epic3-highpriority-tests/epic3-high-priority-testsuite.spec.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ test.describe('@regression @e2e @epic3-high-priority Tests', () => {
128128
});
129129
});
130130

131-
132-
133131
test('@DTOSS-5560-01 - BS Select - Records are received where IsExtracted is set to 0', {
134132
annotation: {
135133
type: 'Requirement',
@@ -152,5 +150,39 @@ test.describe('@regression @e2e @epic3-high-priority Tests', () => {
152150
expect(firstRecord?.IsExtracted).toBe(1);
153151
});
154152
});
153+
154+
test('@DTOSS-5584-01 - BS Select - 204 if IsExtracted is set to 1', {
155+
annotation: {
156+
type: 'Requirement',
157+
description: 'Tests - https://nhsd-jira.digital.nhs.uk/browse/DTOSS-3714',
158+
},
159+
}, async ({ request, testData }) => {
160+
161+
await test.step('Then processed ADD participant should be received using bs select get request where IsExtracted = 0', async () => {
162+
await validateSqlDatabaseFromAPI(request, testData.checkInDatabase);
163+
164+
const response = await getRecordsFromBsSelectRetrieveCohort(request, { rowCount: 10, screeningServiceId: 1 });
165+
expect(response.data.length).toBe(1);
166+
167+
});
168+
169+
await test.step('And IsExtracted flag is set to 1', async () => {
170+
const response = await getRecordsFromCohortDistributionService(request);
171+
const firstRecord = response.data.find(() => true);
172+
expect(firstRecord?.IsExtracted).toBe(1);
173+
});
174+
175+
await test.step('When records are received again using bs select API where IsExtracted = 1, Then API should return no records with status 204', async () => {
176+
177+
const response = await getRecordsFromBsSelectRetrieveCohort(request, { rowCount: 10, screeningServiceId: 1 });
178+
const genericValidations = composeValidators(
179+
expectStatus(204),
180+
validateResponseByStatus()
181+
);
182+
await genericValidations(response);
183+
});
184+
185+
186+
});
155187
});
156188

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"validations": [
3+
{
4+
"validations": {
5+
"apiEndpoint": "api/CohortDistributionDataService",
6+
"NHSNumber": 9995518112
7+
}
8+
}
9+
],
10+
"inputParticipantRecord": [
11+
{
12+
"record_type": "ADD",
13+
"change_time_stamp": null,
14+
"serial_change_number": 1,
15+
"nhs_number": 9995518112,
16+
"superseded_by_nhs_number": null,
17+
"primary_care_provider": "F83043",
18+
"primary_care_effective_from_date": "20130319",
19+
"current_posting": "CH",
20+
"current_posting_effective_from_date": "20130319",
21+
"name_prefix": "A.ML",
22+
"given_name": "NewTest1Updated",
23+
"other_given_name": "Test",
24+
"family_name": "Adani1",
25+
"previous_family_name": "Test2",
26+
"date_of_birth": "19700101",
27+
"gender": 1,
28+
"address_line_1": "247 SpaightSpaightSpTeeeeeeest Road",
29+
"address_line_2": "Eastbourne",
30+
"address_line_3": "Test",
31+
"address_line_4": "Chelmsford",
32+
"address_line_5": "United Kingdom",
33+
"postcode": "AB43 8FJ",
34+
"paf_key": "Z3S4Q5X9",
35+
"address_effective_from_date": null,
36+
"reason_for_removal": null,
37+
"reason_for_removal_effective_from_date": null,
38+
"date_of_death": null,
39+
"death_status": null,
40+
"home_telephone_number": "01619999999",
41+
"home_telephone_effective_from_date": "20240501",
42+
"mobile_telephone_number": "07888888888",
43+
"mobile_telephone_effective_from_date": "20240501",
44+
"email_address": "[email protected]",
45+
"email_address_effective_from_date": null,
46+
"preferred_language": "en",
47+
"is_interpreter_required": false,
48+
"invalid_flag": false,
49+
"eligibility": true
50+
}
51+
],
52+
"nhsNumbers": [
53+
"9995518112"
54+
]
55+
}

0 commit comments

Comments
 (0)