From 0d61efadd54fee11578513c3f5785f4851bbc0c2 Mon Sep 17 00:00:00 2001 From: Joseph Kotanchik Date: Tue, 22 Oct 2024 13:11:17 -0400 Subject: [PATCH 1/2] MAT-7437: Allow for empty Improvement Notation since it is optional. --- pom.xml | 2 +- .../models/validators/ImprovementNotationValidator.java | 3 +++ .../models/validators/ImprovementNotationValidatorTest.java | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ea60fb4..e2c0fae 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ gov.cms.madie madie-java-models - 0.6.67-SNAPSHOT + 0.6.68-SNAPSHOT madie-java-models Java based models for MADiE microservices diff --git a/src/main/java/gov/cms/madie/models/validators/ImprovementNotationValidator.java b/src/main/java/gov/cms/madie/models/validators/ImprovementNotationValidator.java index e3d3541..5220a5c 100644 --- a/src/main/java/gov/cms/madie/models/validators/ImprovementNotationValidator.java +++ b/src/main/java/gov/cms/madie/models/validators/ImprovementNotationValidator.java @@ -12,6 +12,9 @@ public class ImprovementNotationValidator @Override public boolean isValid(QdmMeasure measure, ConstraintValidatorContext context) { + if (StringUtils.isEmpty(measure.getImprovementNotation())) { + return true; + } if (StringUtils.equalsIgnoreCase( measure.getImprovementNotation(), "Increased score indicates improvement") || StringUtils.equalsIgnoreCase( diff --git a/src/test/java/gov/cms/madie/models/validators/ImprovementNotationValidatorTest.java b/src/test/java/gov/cms/madie/models/validators/ImprovementNotationValidatorTest.java index a213c31..addf0bc 100644 --- a/src/test/java/gov/cms/madie/models/validators/ImprovementNotationValidatorTest.java +++ b/src/test/java/gov/cms/madie/models/validators/ImprovementNotationValidatorTest.java @@ -59,4 +59,9 @@ void testInvalidImprovementNotation() { measure.setImprovementNotation("Invalid"); assertFalse(validator.isValid(measure, validatorContext)); } + + @Test + void testEmptyImprovementNotation() { + assertTrue(validator.isValid(measure, validatorContext)); + } } From 4eb082ec0be5a4b0083a09b0c15c5168bb9f77ba Mon Sep 17 00:00:00 2001 From: Joseph Kotanchik Date: Tue, 22 Oct 2024 14:08:52 -0400 Subject: [PATCH 2/2] MAT-7437: Prevent description on empty notation. --- .../validators/ImprovementNotationValidator.java | 2 +- .../ImprovementNotationValidatorTest.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/gov/cms/madie/models/validators/ImprovementNotationValidator.java b/src/main/java/gov/cms/madie/models/validators/ImprovementNotationValidator.java index 5220a5c..7b5d978 100644 --- a/src/main/java/gov/cms/madie/models/validators/ImprovementNotationValidator.java +++ b/src/main/java/gov/cms/madie/models/validators/ImprovementNotationValidator.java @@ -13,7 +13,7 @@ public class ImprovementNotationValidator @Override public boolean isValid(QdmMeasure measure, ConstraintValidatorContext context) { if (StringUtils.isEmpty(measure.getImprovementNotation())) { - return true; + return StringUtils.isEmpty(measure.getImprovementNotationDescription()); } if (StringUtils.equalsIgnoreCase( measure.getImprovementNotation(), "Increased score indicates improvement") diff --git a/src/test/java/gov/cms/madie/models/validators/ImprovementNotationValidatorTest.java b/src/test/java/gov/cms/madie/models/validators/ImprovementNotationValidatorTest.java index addf0bc..db7de38 100644 --- a/src/test/java/gov/cms/madie/models/validators/ImprovementNotationValidatorTest.java +++ b/src/test/java/gov/cms/madie/models/validators/ImprovementNotationValidatorTest.java @@ -40,6 +40,13 @@ void testImprovementNotationDecrease() { assertTrue(validator.isValid(measure, validatorContext)); } + @Test + void testImprovementNotationWithDescription() { + measure.setImprovementNotation("Decreased score indicates improvement"); + measure.setImprovementNotationDescription("Something useful"); + assertTrue(validator.isValid(measure, validatorContext)); + } + @Test void testImprovementNotationOtherHasDescription() { measure.setImprovementNotation("Other"); @@ -60,6 +67,12 @@ void testInvalidImprovementNotation() { assertFalse(validator.isValid(measure, validatorContext)); } + @Test + void testImprovementNotationDescriptionOnly() { + measure.setImprovementNotationDescription("Nonsense description"); + assertFalse(validator.isValid(measure, validatorContext)); + } + @Test void testEmptyImprovementNotation() { assertTrue(validator.isValid(measure, validatorContext));