Search in sources :

Example 6 with Context

use of gov.cms.qpp.conversion.Context in project qpp-conversion-tool by CMSgov.

the class AciSectionRoundTripTest method parseGarbageAciSectionAsNode.

@Test
void parseGarbageAciSectionAsNode() throws XmlException {
    // set-up
    String xmlFragment = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<component xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:hl7-org:v3\">\n" + "	<section>\n" + "		<!-- Measure Section -->\n" + "		<templateId root=\"2.16.840.1.113883.10.20.24.2.2\"/>\n" + "		<!-- Advancing Care Information Section templateId -->\n" + "		<templateId root=\"2.16.840.1.113883.10.20.27.2.5\" extension=\"2017-06-01\"/>\n" + "		<code code=\"55186-1\" codeSystem=\"2.16.840.1.113883.6.1\" displayName=\"Measure Section\"/>\n" + "        <statusCode code=\"Death and Destruction!\" />\n" + "        Utter garbage!  Buahahahahaha!\n" + "		<title>Measure Section</title>\n" + "		<text>\n" + "		</text>\n" + "		<entry>\n" + "			<qed resultName=\"measure\" resultValue=\"measure1\">\n" + "				<templateId root=\"Q.E.D\"/>\n" + "			</qed>" + "		</entry>\n" + "		<entry typeCode=\"DRIV\">" + "			<act classCode=\"ACT\" moodCode=\"EVN\">" + "				<templateId root=\"2.16.840.1.113883.10.20.17.3.8\"/>" + "				<id root=\"00b669fd-fa4d-4f5c-b109-65c6bbbf73ae\"/>" + "				<code code=\"252116004\" codeSystem=\"2.16.840.1.113883.6.96\"" + "					displayName=\"Observation Parameters\"/>" + "				<effectiveTime>" + "					<low value=\"20170101\"/>" + "					<high value=\"20170430\"/>" + "				</effectiveTime>" + "			</act>" + "		</entry>" + "	</section>\n" + "</component>";
    // execute
    Node parentNode = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xmlFragment));
    DefaultDecoder.removeDefaultNode(parentNode.getChildNodes());
    // assert
    Node aciSectionNode = parentNode.findFirstNode(TemplateId.ACI_SECTION);
    assertAciSectionHasSingleQedNode(aciSectionNode);
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) Test(org.junit.jupiter.api.Test)

Example 7 with Context

use of gov.cms.qpp.conversion.Context in project qpp-conversion-tool by CMSgov.

the class AciSectionRoundTripTest method parseSparseAciSectionAsNode.

@Test
void parseSparseAciSectionAsNode() throws XmlException {
    // set-up
    String xmlFragment = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<component xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:hl7-org:v3\">\n" + "	<section>\n" + "		<!-- Measure Section -->\n" + "		<templateId root=\"2.16.840.1.113883.10.20.24.2.2\"/>\n" + "		<!-- Advancing Care Information Section templateId -->\n" + "		<templateId root=\"2.16.840.1.113883.10.20.27.2.5\" extension=\"2017-06-01\"/>\n" + "		<code code=\"55186-1\" codeSystem=\"2.16.840.1.113883.6.1\" displayName=\"Measure Section\"/>\n" + "		<title>Measure Section</title>\n" + "		<text>\n" + "		</text>\n" + "		<entry>\n" + "			<qed resultName=\"measure\" resultValue=\"measure1\">\n" + "				<templateId root=\"Q.E.D\"/>\n" + "			</qed>" + "		</entry>\n" + "		<entry typeCode=\"DRIV\">" + "			<act classCode=\"ACT\" moodCode=\"EVN\">" + "				<templateId root=\"2.16.840.1.113883.10.20.17.3.8\"/>" + "				<id root=\"00b669fd-fa4d-4f5c-b109-65c6bbbf73ae\"/>" + "				<code code=\"252116004\" codeSystem=\"2.16.840.1.113883.6.96\"" + "					displayName=\"Observation Parameters\"/>" + "				<effectiveTime>" + "					<low value=\"20170101\"/>" + "					<high value=\"20170430\"/>" + "				</effectiveTime>" + "			</act>" + "		</entry>" + "	</section>\n" + "</component>";
    // execute
    Node parentNode = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xmlFragment));
    DefaultDecoder.removeDefaultNode(parentNode.getChildNodes());
    // assert
    Node aciSectionNode = parentNode.findFirstNode(TemplateId.ACI_SECTION);
    assertAciSectionHasSingleQedNode(aciSectionNode);
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) Test(org.junit.jupiter.api.Test)

Example 8 with Context

use of gov.cms.qpp.conversion.Context in project qpp-conversion-tool by CMSgov.

the class AutoDetectQrdaTest method testNoClinicalDocumentElement.

@Test
void testNoClinicalDocumentElement() throws IOException, XmlException {
    // set-up
    String xmlFragment = IOUtils.toString(getStream("bogus-QDRA-III-root"), StandardCharsets.UTF_8);
    // execute
    clearLogs();
    XmlDecoderEngine.decodeXml(new Context(), XmlUtils.stringToDom(xmlFragment));
    // assert
    assertThat(getLogs()).contains("The XML file is an unknown document");
}
Also used : Context(gov.cms.qpp.conversion.Context) Test(org.junit.jupiter.api.Test)

Example 9 with Context

use of gov.cms.qpp.conversion.Context in project qpp-conversion-tool by CMSgov.

the class ClinicalDocumentValidatorTest method testClinicalDocumentValidationParsesMultipleErrors.

@Test
void testClinicalDocumentValidationParsesMultipleErrors() {
    // setup
    Path path = Paths.get("src/test/resources/negative/angerClinicalDocumentValidations.xml");
    // execute
    Context context = new Context();
    context.setDoDefaults(true);
    Converter converter = new Converter(new PathSource(path), context);
    AllErrors allErrors = new AllErrors();
    try {
        converter.transform();
    } catch (TransformException exception) {
        allErrors = exception.getDetails();
    }
    List<Detail> errors = getErrors(allErrors);
    assertWithMessage("Must have 4 errors").that(errors).hasSize(4);
    assertWithMessage("Must contain the correct errors").that(errors).comparingElementsUsing(DetailsErrorEquals.INSTANCE).containsAllOf(ErrorCode.CLINICAL_DOCUMENT_MISSING_PROGRAM_NAME, ErrorCode.REPORTING_PARAMETERS_MUST_CONTAIN_SINGLE_PERFORMANCE_START);
}
Also used : Path(java.nio.file.Path) Context(gov.cms.qpp.conversion.Context) AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) PathSource(gov.cms.qpp.conversion.PathSource) TransformException(gov.cms.qpp.conversion.model.error.TransformException) Converter(gov.cms.qpp.conversion.Converter) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Example 10 with Context

use of gov.cms.qpp.conversion.Context in project qpp-conversion-tool by CMSgov.

the class CpcMeasureDataValidatorTest method validateFailureSupplementalDataMissingCountTest.

@Test
void validateFailureSupplementalDataMissingCountTest() throws Exception {
    String failurePayerFile = TestHelper.getFixture("failureSupplementalDataCountFile.xml");
    Node placeholder = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(failurePayerFile));
    CpcMeasureDataValidator validator = new CpcMeasureDataValidator();
    Node underTest = placeholder.findFirstNode(TemplateId.MEASURE_DATA_CMS_V2);
    validator.internalValidateSingleNode(underTest);
    LocalizedError expectedError = ErrorCode.CPC_PLUS_SUPPLEMENTAL_DATA_MISSING_COUNT.format(SupplementalData.MALE.getCode(), SubPopulationLabel.IPOP.name(), MEASURE_ID);
    Set<Detail> errors = validator.getDetails();
    assertThat(errors).comparingElementsUsing(DetailsErrorEquals.INSTANCE).contains(expectedError);
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) LocalizedError(gov.cms.qpp.conversion.model.error.LocalizedError) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Context (gov.cms.qpp.conversion.Context)114 Test (org.junit.jupiter.api.Test)92 Node (gov.cms.qpp.conversion.model.Node)63 BufferedWriter (java.io.BufferedWriter)17 StringWriter (java.io.StringWriter)17 QrdaDecoderEngine (gov.cms.qpp.conversion.decode.QrdaDecoderEngine)14 Element (org.jdom2.Element)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 QppOutputEncoder (gov.cms.qpp.conversion.encode.QppOutputEncoder)8 ArrayList (java.util.ArrayList)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 TemplateId (gov.cms.qpp.conversion.model.TemplateId)4 Detail (gov.cms.qpp.conversion.model.error.Detail)4 InputStream (java.io.InputStream)4 Namespace (org.jdom2.Namespace)4 Map (java.util.Map)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 Converter (gov.cms.qpp.conversion.Converter)2 PathSource (gov.cms.qpp.conversion.PathSource)2 ComponentKey (gov.cms.qpp.conversion.model.ComponentKey)2