Search in sources :

Example 6 with Detail

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

the class AciSectionEncoder method encodeChildren.

/**
 * Encodes the children of the given section
 *
 * @param children child nodes of the given section
 * @param measurementsWrapper wrapper that holds the measurements of a section
 */
private void encodeChildren(List<Node> children, JsonWrapper measurementsWrapper) {
    JsonWrapper childWrapper;
    for (Node currentChild : children) {
        childWrapper = new JsonWrapper();
        TemplateId templateId = currentChild.getType();
        if (TemplateId.REPORTING_PARAMETERS_ACT != templateId) {
            JsonOutputEncoder childEncoder = encoders.get(templateId);
            if (childEncoder != null) {
                childEncoder.encode(childWrapper, currentChild);
                measurementsWrapper.putObject(childWrapper);
            } else {
                Detail detail = Detail.forErrorCode(ErrorCode.ENCODER_MISSING);
                detail.setPath(currentChild.getPath());
                addValidationError(detail);
            }
        }
    }
}
Also used : Node(gov.cms.qpp.conversion.model.Node) TemplateId(gov.cms.qpp.conversion.model.TemplateId) Detail(gov.cms.qpp.conversion.model.error.Detail)

Example 7 with Detail

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

the class Converter method transform.

/**
 * Transform the content in a given input stream
 *
 * @param inStream source content
 * @return a transformed representation of the source content
 * @throws XmlException during transform
 */
private JsonWrapper transform(InputStream inStream) {
    Element doc = XmlUtils.parseXmlStream(inStream);
    decoded = XmlDecoderEngine.decodeXml(context, doc);
    JsonWrapper qpp = null;
    if (null != decoded) {
        DEV_LOG.info("Decoded template ID {}", decoded.getType());
        if (!context.isDoDefaults()) {
            DefaultDecoder.removeDefaultNode(decoded.getChildNodes());
        }
        if (context.isDoValidation()) {
            QrdaValidator validator = new QrdaValidator(context);
            details.addAll(validator.validate(decoded));
        }
        if (details.isEmpty()) {
            qpp = encode();
        }
    } else {
        Detail detail = Detail.forErrorCode(ErrorCode.NOT_VALID_QRDA_DOCUMENT.format(Context.REPORTING_YEAR, Context.IG_URL));
        details.add(detail);
    }
    return qpp;
}
Also used : JsonWrapper(gov.cms.qpp.conversion.encode.JsonWrapper) QrdaValidator(gov.cms.qpp.conversion.validate.QrdaValidator) Element(org.jdom2.Element) Detail(gov.cms.qpp.conversion.model.error.Detail)

Example 8 with Detail

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

the class ReportingParametersActValidatorTest method testPerformanceStartAndEndWithDashesAndTimezone.

@Test
void testPerformanceStartAndEndWithDashesAndTimezone() {
    Node reportingParametersActNode = createReportingParametersAct("2017-01-01T01:45:23.123", "2017-12-01T01:45:23.123", PERFORMANCE_YEAR);
    reportingParametersActValidator.internalValidateSingleNode(reportingParametersActNode);
    Set<Detail> error = reportingParametersActValidator.getDetails();
    assertThat(error).isEmpty();
}
Also used : Node(gov.cms.qpp.conversion.model.Node) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Example 9 with Detail

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

the class ReportingParametersActValidatorTest method testInvalidPerformanceStartFormat.

@Test
void testInvalidPerformanceStartFormat() {
    Node reportingParametersActNode = createReportingParametersAct(TIMESTAMPED_DATE, PERFORMANCE_END, PERFORMANCE_YEAR);
    reportingParametersActValidator.internalValidateSingleNode(reportingParametersActNode);
    Set<Detail> error = reportingParametersActValidator.getDetails();
    assertThat(error).comparingElementsUsing(DetailsErrorEquals.INSTANCE).contains(ErrorCode.INVALID_PERFORMANCE_PERIOD_FORMAT.format(TIMESTAMPED_DATE));
}
Also used : Node(gov.cms.qpp.conversion.model.Node) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Example 10 with Detail

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

the class CpcQualityMeasureScopedValidatonTest method validateCms137V5FailMissingMeasure.

@Test
void validateCms137V5FailMissingMeasure() {
    Node result = scopedConversion(QrdaScope.MEASURE_REFERENCE_RESULTS_CMS_V2, "cms137v5_MissingMeasure.xml");
    Set<Detail> details = validateNode(result);
    LocalizedError message = ErrorCode.QUALITY_MEASURE_ID_INCORRECT_UUID.format("CMS137v5", "IPP,IPOP", "EC2C5F63-AF76-4D3C-85F0-5423F8C28541");
    assertWithMessage("Missing CMS137v5 IPOP strata should result in errors").that(details).comparingElementsUsing(DetailsErrorEquals.INSTANCE).containsExactly(message);
}
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) Test(org.junit.jupiter.api.Test)

Aggregations

Detail (gov.cms.qpp.conversion.model.error.Detail)123 Test (org.junit.jupiter.api.Test)108 Node (gov.cms.qpp.conversion.model.Node)105 LocalizedError (gov.cms.qpp.conversion.model.error.LocalizedError)16 Converter (gov.cms.qpp.conversion.Converter)9 AllErrors (gov.cms.qpp.conversion.model.error.AllErrors)9 TransformException (gov.cms.qpp.conversion.model.error.TransformException)9 PathSource (gov.cms.qpp.conversion.PathSource)8 ArrayList (java.util.ArrayList)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Context (gov.cms.qpp.conversion.Context)4 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 QrdaDecoderEngine (gov.cms.qpp.conversion.decode.QrdaDecoderEngine)3 FormattedErrorCode (gov.cms.qpp.conversion.model.error.FormattedErrorCode)3 Path (java.nio.file.Path)2 LinkedHashSet (java.util.LinkedHashSet)2 InputStreamSupplierSource (gov.cms.qpp.conversion.InputStreamSupplierSource)1 JsonWrapper (gov.cms.qpp.conversion.encode.JsonWrapper)1 TemplateId (gov.cms.qpp.conversion.model.TemplateId)1