Skip to content

Commit 7b50360

Browse files
authored
feat: Add new rule to check for blocked participants (#948)
* feat: Add new rule to check for blocked participants * chore: Fix tests and renumber rule
1 parent 9461212 commit 7b50360

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
}
99
],
1010
"Rules": [
11+
{
12+
"RuleName": "12.BlockedParticipant.BSSelect.Fatal",
13+
"Expression": "newParticipant.BlockedFlag != \"1\"",
14+
"Actions": {
15+
"OnFailure": {
16+
"Name": "OutputExpression",
17+
"Context": {
18+
"Expression":"\"Participant is blocked\""
19+
}
20+
}
21+
}
22+
},
1123
{
1224
"RuleName": "36.ValidatePrimaryCareProvider.NonFatal",
1325
"Expression": "string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) || dbLookup.CheckIfPrimaryCareProviderExists(newParticipant.primaryCareProvider)",

tests/UnitTests/ScreeningValidationServiceTests/LookupValidation/LookupValidationTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,26 @@ public async Task Run_ParticipantLocationRemainingOutsideOfCohort_ShouldThrowExc
680680
It.IsAny<ParticipantCsvRecord>()),
681681
Times.Once());
682682
}
683+
684+
[TestMethod]
685+
public async Task Run_BlockedParticipant_CreatesException()
686+
{
687+
// Arrange
688+
SetupRules("LookupRules");
689+
_requestBody.NewParticipant.BlockedFlag = "1";
690+
var json = JsonSerializer.Serialize(_requestBody);
691+
SetUpRequestBody(json);
692+
693+
// Act
694+
await _sut.RunAsync(_request.Object);
695+
696+
// Assert
697+
_exceptionHandler.Verify(handleException => handleException.CreateValidationExceptionLog(
698+
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "12.BlockedParticipant.BSSelect.Fatal")),
699+
It.IsAny<ParticipantCsvRecord>()),
700+
Times.Once());
701+
}
702+
683703
private void SetUpRequestBody(string json)
684704
{
685705
var byteArray = Encoding.ASCII.GetBytes(json);

0 commit comments

Comments
 (0)