Skip to content

Commit

Permalink
Merge pull request #766 from MeasureAuthoringTool/feature/MAT-7992/ma…
Browse files Browse the repository at this point in the history
…ke-improvement-notation-required-for-qi-core

MAT-7992: make improvement notation required for QI-Core
  • Loading branch information
etan-sb authored Dec 20, 2024
2 parents 585c97d + 669086b commit b676baa
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,17 @@ public void validateGroups(Measure measure) {
measure.getId(),
"since there is at least one Population Criteria with no type.");
}

if (measure.getMeasureMetaData() != null && measure.getMeasureMetaData().isDraft()) {
measure.getGroups().forEach(
group -> {
if (StringUtils.isBlank(group.getImprovementNotation())) {
throw new InvalidResourceStateException(
"Measure", measure.getId(), "since there is at least one Population Criteria " +
"with no improvement notation.");
}
}
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

import cms.gov.madie.measure.exceptions.InvalidResourceStateException;
import cms.gov.madie.measure.factories.ModelValidatorFactory;
import gov.cms.madie.models.measure.Measure;
import gov.cms.madie.models.measure.MeasureErrorType;
import gov.cms.madie.models.measure.MeasureGroupTypes;
import gov.cms.madie.models.measure.*;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -21,11 +19,6 @@

import cms.gov.madie.measure.exceptions.InvalidGroupException;
import gov.cms.madie.models.common.ModelType;
import gov.cms.madie.models.measure.BaseConfigurationTypes;
import gov.cms.madie.models.measure.Group;
import gov.cms.madie.models.measure.PopulationType;
import gov.cms.madie.models.measure.QdmMeasure;
import gov.cms.madie.models.measure.Stratification;

@ExtendWith(MockitoExtension.class)
@SpringBootTest
Expand Down Expand Up @@ -281,4 +274,47 @@ void testQdmModelValidatorTestMeasureDoesHaveMeasuretypes() {
assertTrue(validator instanceof QdmModelValidator);
assertDoesNotThrow(() -> validator.validateGroups(measure));
}

@Test
void useQicoreModelValidatorTestDraftMeasureHasNoImprovementNotationInAtLeastOnePopulationCriteria() {
assertNotNull(modelValidatorFactory);
Group group1 = Group.builder().measureGroupTypes(List.of(MeasureGroupTypes.OUTCOME)).improvementNotation("Decreased score indicates improvement").build();
Group group2 = Group.builder().measureGroupTypes(List.of(MeasureGroupTypes.OUTCOME)).build();

Measure measure =
Measure.builder()
.id("1")
.groups(List.of(group1, group2))
.measureMetaData(MeasureMetaData.builder().draft(true).build())
.build();

ModelValidator validator = modelValidatorFactory.getModelValidator(ModelType.QI_CORE);
assertTrue(validator instanceof QiCoreModelValidator);
try {
validator.validateGroups(measure);
fail("Should fail because, since there is at least one Population Criteria with no improvement notation");
} catch (InvalidResourceStateException e) {
assertEquals(
"Response could not be completed for Measure with ID 1, since there is at least one Population Criteria with no improvement notation.",
e.getMessage());
}
}

@Test
void useQicoreModelValidatorTestVersionedMeasureHasNoImprovementNotationInAtLeastOnePopulationCriteria() {
assertNotNull(modelValidatorFactory);
Group group1 = Group.builder().measureGroupTypes(List.of(MeasureGroupTypes.OUTCOME)).improvementNotation("Decreased score indicates improvement").build();
Group group2 = Group.builder().measureGroupTypes(List.of(MeasureGroupTypes.OUTCOME)).build();

Measure measure =
Measure.builder()
.id("1")
.groups(List.of(group1, group2))
.measureMetaData(MeasureMetaData.builder().draft(false).build())
.build();

ModelValidator validator = modelValidatorFactory.getModelValidator(ModelType.QI_CORE);
assertTrue(validator instanceof QiCoreModelValidator);
assertDoesNotThrow(() -> validator.validateGroups(measure));
}
}

0 comments on commit b676baa

Please sign in to comment.