Search in sources :

Example 26 with LocalizedError

use of gov.cms.qpp.conversion.model.error.LocalizedError in project qpp-conversion-tool by CMSgov.

the class CpcQualityMeasureIdValidator method followUpHook.

/**
 * Validate measure strata
 *
 * @param node measure node
 * @param sub sub population constituent ids
 */
@Override
protected void followUpHook(Node node, SubPopulation sub) {
    List<Node> strataNodes = node.getChildNodes(TemplateId.REPORTING_STRATUM_CMS).collect(Collectors.toList());
    if (strataNodes.size() != sub.getStrata().size()) {
        LocalizedError error = ErrorCode.CPC_QUALITY_MEASURE_ID_STRATA_MISMATCH.format(strataNodes.size(), sub.getStrata().size(), node.getValue(MeasureDataDecoder.MEASURE_TYPE), node.getValue(MEASURE_POPULATION), sub.getStrata());
        addValidationError(Detail.forErrorAndNode(error, node));
    }
    sub.getStrata().forEach(stratum -> {
        Predicate<Node> seek = child -> child.getValue(StratifierDecoder.STRATIFIER_ID).equalsIgnoreCase(stratum);
        if (strataNodes.stream().noneMatch(seek)) {
            LocalizedError error = ErrorCode.CPC_QUALITY_MEASURE_ID_MISSING_STRATA.format(stratum, node.getValue(MeasureDataDecoder.MEASURE_TYPE), node.getValue(MEASURE_POPULATION));
            addValidationError(Detail.forErrorAndNode(error, node));
        }
    });
}
Also used : MeasureConfig(gov.cms.qpp.conversion.model.validation.MeasureConfig) Arrays(java.util.Arrays) Node(gov.cms.qpp.conversion.model.Node) SubPopulationLabel(gov.cms.qpp.conversion.model.validation.SubPopulationLabel) Predicate(java.util.function.Predicate) MEASURE_POPULATION(gov.cms.qpp.conversion.decode.MeasureDataDecoder.MEASURE_POPULATION) Validator(gov.cms.qpp.conversion.model.Validator) Program(gov.cms.qpp.conversion.model.Program) StratifierDecoder(gov.cms.qpp.conversion.decode.StratifierDecoder) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) MeasureConfigHelper(gov.cms.qpp.conversion.util.MeasureConfigHelper) Consumer(java.util.function.Consumer) Detail(gov.cms.qpp.conversion.model.error.Detail) List(java.util.List) LocalizedError(gov.cms.qpp.conversion.model.error.LocalizedError) SubPopulation(gov.cms.qpp.conversion.model.validation.SubPopulation) PERFORMANCE_RATE_ID(gov.cms.qpp.conversion.decode.PerformanceRateProportionMeasureDecoder.PERFORMANCE_RATE_ID) TemplateId(gov.cms.qpp.conversion.model.TemplateId) ErrorCode(gov.cms.qpp.conversion.model.error.ErrorCode) MeasureDataDecoder(gov.cms.qpp.conversion.decode.MeasureDataDecoder) Node(gov.cms.qpp.conversion.model.Node) LocalizedError(gov.cms.qpp.conversion.model.error.LocalizedError)

Example 27 with LocalizedError

use of gov.cms.qpp.conversion.model.error.LocalizedError in project qpp-conversion-tool by CMSgov.

the class MipsQualityMeasureIdValidator method addPerformanceRateValidationMessage.

/**
 * Adds a validation error message for a specified Performance Rate
 *
 * @param node The current parent node of performance rate
 * @param performanceUuid The current performance rate uuid
 */
private void addPerformanceRateValidationMessage(Node node, String electronicMeasureId, String performanceUuid) {
    LocalizedError error = ErrorCode.QUALITY_MEASURE_ID_INCORRECT_UUID.format(electronicMeasureId, PERFORMANCE_RATE_ID, performanceUuid);
    addValidationError(Detail.forErrorAndNode(error, node));
}
Also used : LocalizedError(gov.cms.qpp.conversion.model.error.LocalizedError)

Example 28 with LocalizedError

use of gov.cms.qpp.conversion.model.error.LocalizedError in project qpp-conversion-tool by CMSgov.

the class QualityMeasureIdValidator method validateChildTypeCount.

/**
 * Validates that given subpopulations have the correct number of a given type
 *
 * @param subPopulations The subpopulations to test against
 * @param key The type to check
 * @param node The node in which the child nodes live
 */
private void validateChildTypeCount(List<SubPopulation> subPopulations, SubPopulationLabel key, Node node) {
    long expectedChildTypeCount = subPopulations.stream().map(subPopulation -> SubPopulations.getUniqueIdForKey(key.name(), subPopulation)).filter(Objects::nonNull).count();
    Predicate<Node> childTypeFinder = makeTypeChildFinder(key.getAliases());
    long actualChildTypeCount = node.getChildNodes(TemplateId.MEASURE_DATA_CMS_V2).filter(childTypeFinder).count();
    if (expectedChildTypeCount != actualChildTypeCount) {
        LocalizedError error = ErrorCode.POPULATION_CRITERIA_COUNT_INCORRECT.format(MeasureConfigHelper.getMeasureConfig(node).getElectronicMeasureId(), expectedChildTypeCount, StringHelper.join(key.getAliases(), ",", "or"), actualChildTypeCount);
        Detail detail = Detail.forErrorAndNode(error, node);
        addValidationError(detail);
    }
}
Also used : Node(gov.cms.qpp.conversion.model.Node) LocalizedError(gov.cms.qpp.conversion.model.error.LocalizedError) Detail(gov.cms.qpp.conversion.model.error.Detail)

Aggregations

LocalizedError (gov.cms.qpp.conversion.model.error.LocalizedError)28 Test (org.junit.jupiter.api.Test)21 Node (gov.cms.qpp.conversion.model.Node)20 Detail (gov.cms.qpp.conversion.model.error.Detail)17 AllErrors (gov.cms.qpp.conversion.model.error.AllErrors)3 Converter (gov.cms.qpp.conversion.Converter)2 PathSource (gov.cms.qpp.conversion.PathSource)2 TransformException (gov.cms.qpp.conversion.model.error.TransformException)2 MeasureConfig (gov.cms.qpp.conversion.model.validation.MeasureConfig)2 ArrayList (java.util.ArrayList)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 EqualsTester (com.google.common.testing.EqualsTester)1 Context (gov.cms.qpp.conversion.Context)1 MeasureDataDecoder (gov.cms.qpp.conversion.decode.MeasureDataDecoder)1 MEASURE_POPULATION (gov.cms.qpp.conversion.decode.MeasureDataDecoder.MEASURE_POPULATION)1 PERFORMANCE_RATE_ID (gov.cms.qpp.conversion.decode.PerformanceRateProportionMeasureDecoder.PERFORMANCE_RATE_ID)1 QrdaDecoderEngine (gov.cms.qpp.conversion.decode.QrdaDecoderEngine)1 StratifierDecoder (gov.cms.qpp.conversion.decode.StratifierDecoder)1 Program (gov.cms.qpp.conversion.model.Program)1 TemplateId (gov.cms.qpp.conversion.model.TemplateId)1