Skip to content

Commit 05923c6

Browse files
fix: DTOSS-11715 BSS rule fixes (#1784)
* Enhance Rule 45: Current Posting * unit tests * e2e tests * adressing Comments * Update unit tests to HJ * add test case * update category * fixed unit test
1 parent 44a095e commit 05923c6

File tree

4 files changed

+137
-50
lines changed

4 files changed

+137
-50
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,25 @@
22
{
33
"WorkflowName": "Common",
44
"GlobalParams": [
5-
{
6-
"Name": "ValidCurrentPosting",
7-
"Expression": "string.IsNullOrEmpty(newParticipant.CurrentPosting) OR dbLookup.CheckIfCurrentPostingExists(newParticipant.CurrentPosting)"
8-
},
95
{
106
"Name": "ValidPrimaryCareProvider",
117
"Expression": "string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) || dbLookup.CheckIfPrimaryCareProviderExists(newParticipant.PrimaryCareProvider)"
128
}
139
],
1410
"Rules": [
1511
{
16-
"RuleName": "45.GPPracticeCodeDoesNotExist.BSSelect.NonFatal",
12+
"RuleName": "45.GPPracticeCodeDoesNotExist.NBO.NonFatal",
1713
"LocalParams": [
1814
{
19-
"Name": "EnglishPostingCategory",
20-
"Expression": "string.Equals(dbLookup.RetrievePostingCategory(newParticipant.CurrentPosting), \"ENGLAND\", StringComparison.OrdinalIgnoreCase)"
21-
},
22-
{
23-
"Name": "InvalidPostingCategory",
24-
"Expression": "!(EnglishPostingCategory || string.Equals(newParticipant.CurrentPosting, \"ENG\", StringComparison.OrdinalIgnoreCase) || string.Equals(newParticipant.CurrentPosting, \"IM\", StringComparison.OrdinalIgnoreCase) || string.Equals(newParticipant.CurrentPosting, \"DMS\", StringComparison.OrdinalIgnoreCase))"
15+
"Name": "WelshPostingCategory",
16+
"Expression": "string.Equals(dbLookup.RetrievePostingCategory(newParticipant.CurrentPosting), \"WALES\", StringComparison.OrdinalIgnoreCase)"
2517
},
2618
{
2719
"Name": "IsExcluded",
2820
"Expression": "dbLookup.CheckIfPrimaryCareProviderInExcludedSmuList(newParticipant.PrimaryCareProvider)"
2921
}
3022
],
31-
"Expression": "(InvalidPostingCategory || ValidPrimaryCareProvider || IsExcluded)",
23+
"Expression": "(WelshPostingCategory || ValidPrimaryCareProvider || IsExcluded)",
3224
"Actions": {
3325
"OnFailure": {
3426
"Name": "OutputExpression",

tests/UnitTests/ScreeningValidationServiceTests/LookupValidation/LookupValidationTests.cs

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class LookupValidationTests
2828
private readonly Mock<ILogger<LookupValidation>> _mockLogger = new();
2929
private readonly Mock<IDataLookupFacadeBreastScreening> _lookupValidation = new();
3030

31+
private readonly List<string> welshPostingCategories = new List<string>{"CLD","CYM","DYF","GWE","SGA","WGA"};
32+
3133
[TestInitialize]
3234
public void IntialiseTests()
3335
{
@@ -189,29 +191,64 @@ public async Task Run_CurrentPosting_ReturnNoContent(string currentPosting)
189191
}
190192

191193
[TestMethod]
192-
[DataRow("InvalidCurrentPosting", "InvalidPCP")]
193-
[DataRow("ValidCurrentPosting", "ValidPCP")]
194-
[DataRow("InvalidCurrentPosting", "ValidPCP")]
195-
[DataRow("ValidCurrentPosting", null)]
196-
[DataRow("InvalidCurrentPosting", null)]
197-
public async Task Run_CurrentPostingAndPrimaryProvider_ReturnNoContent(string currentPosting, string primaryCareProvider)
194+
[DataRow("BAA", "InvalidPCP", true)]
195+
[DataRow(null, "InvalidPCP", true)]
196+
[DataRow("BAA", "ValidPCP", true)]
197+
[DataRow(null, "ValidPCP", true)]
198+
[DataRow("BAA", "ValidPCP", false)]
199+
[DataRow(null, "ValidPCP", false)]
200+
[DataRow("BAA", null, false)]
201+
[DataRow("BAA", null, true)]
202+
[DataRow(null, null, false)]
203+
[DataRow("CYM", "InvalidPCP", false)]
204+
[DataRow("CYM", "ValidPCP", false)]
205+
[DataRow("CYM", "InvalidPCP", true)]
206+
[DataRow("CYM", "ValidPCP", true)]
207+
public async Task Run_CurrentPostingAndPrimaryProvider_ReturnNoContent(string currentPosting, string primaryCareProvider, bool PCPIsExcluded)
198208
{
199209
// Arrange
200210
_requestBody.NewParticipant.CurrentPosting = currentPosting;
201211
_requestBody.NewParticipant.PrimaryCareProvider = primaryCareProvider;
212+
202213
var json = JsonSerializer.Serialize(_requestBody);
203214
SetUpRequestBody(json);
204215

205-
_lookupValidation.Setup(x => x.ValidatePostingCategories(It.IsAny<string>())).Returns(currentPosting == "ValidCurrentPosting");
206216
_lookupValidation.Setup(x => x.CheckIfPrimaryCareProviderExists(It.IsAny<string>())).Returns(primaryCareProvider == "ValidPCP");
217+
_lookupValidation.Setup(x => x.CheckIfPrimaryCareProviderInExcludedSmuList(It.IsAny<string>())).Returns(PCPIsExcluded);
218+
_lookupValidation.Setup(x => x.RetrievePostingCategory(It.IsIn<string>(welshPostingCategories))).Returns("WALES");
219+
_lookupValidation.Setup(x => x.RetrievePostingCategory(It.IsNotIn<string>(welshPostingCategories))).Returns("ENGLAND");
207220

208221
// Act
209222
var response = await _sut.RunAsync(_request.Object);
210223
string body = await AssertionHelper.ReadResponseBodyAsync(response);
211224

212225
// Assert
213-
Assert.IsFalse(body.Contains("45.GPPracticeCodeDoesNotExist.BSSelect.NonFatal"));
226+
Assert.IsFalse(body.Contains("45.GPPracticeCodeDoesNotExist.BSSelect.NonFatal")); // Rule Not Triggered
214227
}
228+
[TestMethod]
229+
[DataRow("BAA", "InvalidPCP",false)]
230+
[DataRow("HJ", "InvalidPCP",false)]
231+
[DataRow("DMS", "InvalidPCP",false)]
232+
public async Task Run_CurrentPostingAndPrimaryProvider_ReturnsException(string currentPosting, string primaryCareProvider, bool PCPIsExcluded)
233+
{
234+
// Arrange
235+
_requestBody.NewParticipant.CurrentPosting = currentPosting;
236+
_requestBody.NewParticipant.PrimaryCareProvider = primaryCareProvider;
237+
var json = JsonSerializer.Serialize(_requestBody);
238+
SetUpRequestBody(json);
239+
240+
_lookupValidation.Setup(x => x.CheckIfPrimaryCareProviderExists(It.IsAny<string>())).Returns(primaryCareProvider == "ValidPCP");
241+
_lookupValidation.Setup(x => x.CheckIfPrimaryCareProviderInExcludedSmuList(It.IsAny<string>())).Returns(PCPIsExcluded);
242+
_lookupValidation.Setup(x => x.RetrievePostingCategory(It.IsIn<string>(welshPostingCategories))).Returns("WALES");
243+
_lookupValidation.Setup(x => x.RetrievePostingCategory(It.IsNotIn<string>(welshPostingCategories))).Returns("ENGLAND");
244+
// Act
245+
var response = await _sut.RunAsync(_request.Object);
246+
string body = await AssertionHelper.ReadResponseBodyAsync(response);
247+
248+
// Assert
249+
Assert.IsTrue(body.Contains("45.GPPracticeCodeDoesNotExist.NBO.NonFatal"));
250+
}
251+
215252

216253
#region Validate BSO Code (Rule 54)
217254
[TestMethod]
@@ -267,35 +304,6 @@ public async Task Run_AmendedParticipantHasValidBSO_ReturnNoContent(string reaso
267304
#endregion
268305

269306
[TestMethod]
270-
[DataRow("DMS", "Z00000")]
271-
[DataRow("ENG", "Z00000")]
272-
[DataRow("IM", "Z00000")]
273-
274-
public async Task Run_ParticipantLocationRemainingOutsideOfCohortAndNotInExcludedSMU_ReturnValidationException(string newCurrentPosting, string newPrimaryCareProvider)
275-
{
276-
// Arrange
277-
_requestBody.NewParticipant.RecordType = Actions.New;
278-
_requestBody.NewParticipant.CurrentPosting = newCurrentPosting;
279-
_requestBody.NewParticipant.PrimaryCareProvider = newPrimaryCareProvider;
280-
281-
var json = JsonSerializer.Serialize(_requestBody);
282-
SetUpRequestBody(json);
283-
_lookupValidation.Setup(x => x.RetrievePostingCategory(newCurrentPosting)).Returns(newCurrentPosting);
284-
_lookupValidation.Setup(x => x.CheckIfCurrentPostingExists(newCurrentPosting)).Returns(true);
285-
_lookupValidation.Setup(x => x.CheckIfPrimaryCareProviderInExcludedSmuList(newPrimaryCareProvider)).Returns(false);
286-
_lookupValidation.Setup(x => x.CheckIfPrimaryCareProviderExists(newPrimaryCareProvider)).Returns(false);
287-
288-
// Act
289-
var response = await _sut.RunAsync(_request.Object);
290-
string body = await AssertionHelper.ReadResponseBodyAsync(response);
291-
292-
// Assert
293-
StringAssert.Contains(body, "45.GPPracticeCodeDoesNotExist.BSSelect.NonFatal");
294-
}
295-
296-
297-
[TestMethod]
298-
299307
[DataRow(null, null, null, null, null, null, "Existing Address 1", "Existing Address 2", "Existing Address 3", "Existing Address 4", "Existing Address 5", "RG2 5TX")] // All New Address Fields null, New Postcode null, Existing Address fields full.
300308
[DataRow("", "", "", "", "", "", "Existing Address 1", "Existing Address 2", "Existing Address 3", "Existing Address 4", "Existing Address 5", "RG2 5TX")] // All New Address Fields empty, New Postcode empty, Existing Address fields full.
301309
[DataRow(null, null, null, null, null, "RG2 5TX", "Existing Address 1", "Existing Address 2", "Existing Address 3", "Existing Address 4", "Existing Address 5", "ZZ99 6TF")] // All New Address Fields null, All existing address field full, Postcode does not match.

tests/playwright-tests/src/tests/e2e/epic4d-validation-tests/epic4d-6045-validation-testsuite-migrated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
// This equates to "@epic4d-" tags, configured in the package.json at the playwright-tests root location.
2525

2626

27-
export const runnerBasedEpic4dTestScenariosAdd = "@DTOSS-9496-01|@DTOSS-9498-01|@DTOSS-A456-01|@DTOSS-A457-01|@DTOSS-A459-01";
27+
export const runnerBasedEpic4dTestScenariosAdd = "@DTOSS-11715-01|@DTOSS-9496-01|@DTOSS-9498-01|@DTOSS-A456-01|@DTOSS-A457-01|@DTOSS-A459-01";
2828
export const runnerBasedEpic4dTestScenariosAmend = "@DTOSS-9497-01|@DTOSS-9499-01|@DTOSS-A451-01|@DTOSS-A452-01|@DTOSS-A453-01|@DTOSS-A454-01|@DTOSS-A455-01|@DTOSS-A458-01";
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"validations": [
3+
{
4+
"validations": {
5+
"apiEndpoint": "api/ExceptionManagementDataService",
6+
"NhsNumber": "9995272172",
7+
"RuleId": 45,
8+
"RuleDescription": "GP practice code does not exist"
9+
},
10+
"meta": {
11+
"testJiraId": "@DTOSS-11715-01",
12+
"requirementJiraId": "DTOSS-11715",
13+
"additionalTags": "@regression @e2e @epic4d-rule8 Verify ADD records with 'HMP' Current Posting is processed a rule 45 Exception for NHS Number 9995272172"
14+
}
15+
},
16+
{
17+
"validations": {
18+
"apiEndpoint": "api/ParticipantManagementDataService",
19+
"RecordType": "ADD",
20+
"NHSNumber": 9995272172,
21+
"expectedCount": 1
22+
},
23+
"meta": {
24+
"testJiraId": "@DTOSS-11715-01",
25+
"requirementJiraId": "DTOSS-11715",
26+
"additionalTags": "@regression @e2e @epic4d-rule8 Verify ADD records is processed without any Exception and participant is stored on Participant_Management table for NHS Number 9995272172"
27+
}
28+
},
29+
{
30+
"validations": {
31+
"apiEndpoint": "api/ParticipantDemographicDataService",
32+
"NhsNumber": 9995272172,
33+
"expectedCount": 1
34+
},
35+
"meta": {
36+
"testJiraId": "@DTOSS-11715-01",
37+
"requirementJiraId": "DTOSS-11715",
38+
"additionalTags": "@regression @e2e @epic4d-rule8 Verify ADD records is processed without any Exception and participant is stored on Participant_Demographic table for NHS Number 9995272172"
39+
}
40+
}
41+
],
42+
"inputParticipantRecord": [
43+
{
44+
"record_type": "ADD",
45+
"change_time_stamp": null,
46+
"serial_change_number": 1,
47+
"nhs_number": 9995272172,
48+
"superseded_by_nhs_number": null,
49+
"primary_care_provider": "X99999",
50+
"primary_care_effective_from_date": null,
51+
"current_posting": "HMP",
52+
"current_posting_effective_from_date": "20130319",
53+
"name_prefix": "Mrs",
54+
"given_name": "Dalby",
55+
"other_given_name": "Conners",
56+
"family_name": "Reg",
57+
"previous_family_name": "gibbins",
58+
"date_of_birth": "19720112",
59+
"gender": 1,
60+
"address_line_1": "AddressLine1",
61+
"address_line_2": "AddressLine2",
62+
"address_line_3": "AddressLine3",
63+
"address_line_4": "AddressLine4",
64+
"address_line_5": "AddressLine5",
65+
"postcode": "AB23 1AF",
66+
"paf_key": "Z3S4Q5X8",
67+
"address_effective_from_date": "20250101",
68+
"reason_for_removal": null,
69+
"reason_for_removal_effective_from_date": null,
70+
"date_of_death": null,
71+
"death_status": null,
72+
"home_telephone_number": "161999999",
73+
"home_telephone_effective_from_date": "20240908",
74+
"mobile_telephone_number": "788888888",
75+
"mobile_telephone_effective_from_date": "20010101",
76+
"email_address": "[email protected]",
77+
"email_address_effective_from_date": "20240101",
78+
"preferred_language": "en",
79+
"is_interpreter_required": false,
80+
"invalid_flag": false,
81+
"eligibility": true
82+
}
83+
],
84+
"nhsNumbers": [
85+
"9995272172"
86+
]
87+
}

0 commit comments

Comments
 (0)