Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: changes to validation rule 36 #620

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
{
"Name": "ValidCurrentPosting",
"Expression": "string.IsNullOrEmpty(newParticipant.CurrentPosting) OR dbLookup.CheckIfCurrentPostingExists(newParticipant.CurrentPosting)"
},
{
"Name": "ValidPrimaryCareProvider",
"Expression": "string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) || dbLookup.CheckIfPrimaryCareProviderExists(newParticipant.primaryCareProvider)"
}
],
"Rules": [
{
"RuleName": "36.ValidatePrimaryCareProvider.NonFatal",
"Expression": "string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) || dbLookup.CheckIfPrimaryCareProviderExists(newParticipant.primaryCareProvider)",
"RuleName": "3601.ValidatePrimaryCareProvider.NonFatal",
"Expression": "ValidPrimaryCareProvider",
"Actions": {
"OnFailure": {
"Name": "OutputExpression",
Expand All @@ -21,18 +25,22 @@
}
},
{
"RuleName": "3645.CurrentPostingAndPrimaryProvider.NonFatal",
"RuleName": "3602.CurrentPostingAndPrimaryProvider.NonFatal",
"LocalParams": [
{
"Name": "ValidPostingCategory",
"Expression": "dbLookup.ValidatePostingCategories(newParticipant.CurrentPosting)"
},
{
"Name": "InvalidPrimaryCareProvider",
"Expression": "!string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) AND !dbLookup.CheckIfPrimaryCareProviderExists(newParticipant.PrimaryCareProvider)"
"Name": "EnglishCurrentPosting",
"Expression": "new[] {\"ENG\", \"DMS\", \"IM\"}.Contains(newParticipant.CurrentPosting)"
}
],
"Expression": "!(ValidPostingCategory AND InvalidPrimaryCareProvider)"
"Expression": "!(EnglishCurrentPosting && (string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) || !dbLookup.CheckIfPrimaryCareProviderExists(newParticipant.primaryCareProvider)))",
will-larkin-nhs marked this conversation as resolved.
Show resolved Hide resolved
"Actions": {
"OnFailure": {
"Name": "OutputExpression",
"Context": {
"Expression": "\"Invalid primary care provider GP practice code\""
}
}
}
},
{
"RuleName": "58.CurrentPosting.NonFatal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public async Task Run_CurrentPosting_DoesNotCreateException(string currentPostin
}

[TestMethod]
[DataRow("ValidCurrentPosting", "InvalidPCP")]
[DataRow("ENG", null)]
public async Task Run_CurrentPostingAndPrimaryProvider_CreatesException(string currentPosting, string primaryCareProvider)
{
// Arrange
Expand All @@ -411,15 +411,14 @@ public async Task Run_CurrentPostingAndPrimaryProvider_CreatesException(string c
var json = JsonSerializer.Serialize(_requestBody);
SetUpRequestBody(json);

_lookupValidation.Setup(x => x.ValidatePostingCategories(It.IsAny<string>())).Returns(currentPosting == "ValidCurrentPosting");
_lookupValidation.Setup(x => x.CheckIfPrimaryCareProviderExists(It.IsAny<string>())).Returns(primaryCareProvider == "ValidPCP");

// Act
await _sut.RunAsync(_request.Object);

// Assert
_exceptionHandler.Verify(handleException => handleException.CreateValidationExceptionLog(
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "3645.CurrentPostingAndPrimaryProvider.NonFatal")),
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "3602.CurrentPostingAndPrimaryProvider.NonFatal")),
It.IsAny<ParticipantCsvRecord>()),
Times.Once());
}
Expand Down Expand Up @@ -447,7 +446,7 @@ public async Task Run_CurrentPostingAndPrimaryProvider_DoesNotCreateException(st

// Assert
_exceptionHandler.Verify(handleException => handleException.CreateValidationExceptionLog(
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "3645.CurrentPostingAndPrimaryProvider.NonFatal")),
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "3602.CurrentPostingAndPrimaryProvider.NonFatal")),
It.IsAny<ParticipantCsvRecord>()),
Times.Never());
}
Expand All @@ -470,7 +469,7 @@ public async Task Run_ValidatePrimaryCareProvider_CreatesException(string primar
// Assert
Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);
_exceptionHandler.Verify(handleException => handleException.CreateValidationExceptionLog(
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "36.ValidatePrimaryCareProvider.NonFatal")),
It.Is<IEnumerable<RuleResultTree>>(r => r.Any(x => x.Rule.RuleName == "3601.ValidatePrimaryCareProvider.NonFatal")),
It.IsAny<ParticipantCsvRecord>()),
Times.Once());
}
Expand Down