Search in sources :

Example 11 with Context

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

the class CpcMeasureDataValidatorTest method validateSuccessfulSupplementalDataFieldsTest.

@Test
void validateSuccessfulSupplementalDataFieldsTest() throws Exception {
    String successfulFile = TestHelper.getFixture("successfulSupplementalDataFile.xml");
    Node placeholder = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(successfulFile));
    CpcMeasureDataValidator validator = new CpcMeasureDataValidator();
    Node underTest = placeholder.findFirstNode(TemplateId.MEASURE_DATA_CMS_V2);
    validator.internalValidateSingleNode(underTest);
    Set<Detail> errors = validator.getDetails();
    assertThat(errors).isEmpty();
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) 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)

Example 12 with Context

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

the class AciNumeratorDenominatorDecoderTest method decodeAggregateCountAsNode.

@Test
void decodeAggregateCountAsNode() throws Exception {
    String xmlFragment = XmlUtils.buildString("<root xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:hl7-org:v3\">", "  <observation classCode=\"OBS\" moodCode=\"EVN\">", "    <templateId root=\"2.16.840.1.113883.10.20.27.3.3\"/>", "    <code code=\"MSRAGG\" codeSystem=\"2.16.840.1.113883.5.4\" codeSystemName=\"ActCode\" displayName=\"rate aggregation\"/>", "    <statusCode code=\"completed\"/>", "    <value xsi:type=\"INT\" value=\"600\"/>", "    <methodCode code=\"COUNT\" codeSystem=\"2.16.840.1.113883.5.84\" codeSystemName=\"ObservationMethod\" displayName=\"Count\"/>", "  </observation>", "</root>");
    Node aggregateCountNode = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xmlFragment));
    assertThat(aggregateCountNode.getChildNodes().get(0).getValue("aggregateCount")).isEqualTo("600");
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Example 13 with Context

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

the class AciProportionDenominatorDecoderTest method decodeACIProportionDenominatorAsNode.

/**
 * decodeACIProportionDenominatorAsNode given a well formed xml fragment
 * parses out the appropriate aggregateCount This test calls
 * QrdaDecoderEngine.()decode() which in turn calls the only method in this
 * class. AciProportionDenominatorDecoder().decode()
 *
 * @throws Exception
 */
@Test
void decodeACIProportionDenominatorAsNode() throws Exception {
    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" + " <observation classCode=\"OBS\" moodCode=\"EVN\">\n" + "     <!-- ACI Numerator Denominator Type Measure Denominator Data templateId -->\n" + "     <templateId root=\"2.16.840.1.113883.10.20.27.3.32\" extension=\"2016-09-01\" />\n" + "     <!-- Denominator Count -->\n" + "     <entryRelationship typeCode=\"SUBJ\" inversionInd=\"true\">\n" + "         <qed resultName=\"aggregateCount\" resultValue=\"800\">\n" + "             <templateId root=\"Q.E.D\"/>\n" + "         </qed>" + "     </entryRelationship>\n" + " </observation>\n" + "</component>";
    Node root = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xmlFragment));
    // For all decoders this should be either a value or child node
    assertThat(root.getChildNodes()).hasSize(1);
    // This is the child node that is produced by the intended decoder
    Node aciProportionDenominatorNode = root.getChildNodes().get(0);
    // Should have a aggregate count node
    assertThat(aciProportionDenominatorNode.getChildNodes()).hasSize(1);
    // This is stubbed node with the test value
    Node target = aciProportionDenominatorNode.getChildNodes().get(0);
    // Get the test value
    assertThat(target.getValue("aggregateCount")).isEqualTo("800");
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Example 14 with Context

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

the class AggregateCountDecoderTest method testAggregateCountDecoderIgnoresInvalidElements.

@Test
void testAggregateCountDecoderIgnoresInvalidElements() throws XmlException {
    Node root = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(XML_FRAGMENT));
    Node node = root.getChildNodes().get(0);
    assertThat(node.getChildNodes()).hasSize(1);
    assertThat(node.getChildNodes().get(0).getValue("aggregateCount")).isEqualTo("400");
    assertWithMessage("Should have template id").that(node.getChildNodes().get(0).getType()).isEqualTo(TemplateId.ACI_AGGREGATE_COUNT);
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Example 15 with Context

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

the class AggregateCountDecoderTest method testDuplicateAggregateCountDecodesToDuplicateAggregateCount.

@Test
void testDuplicateAggregateCountDecodesToDuplicateAggregateCount() throws XmlException {
    Node root = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(DUPLICATE_AGGREGATE_COUNT));
    assertThat(root.getChildNodes().get(0).getChildNodes(TemplateId.ACI_AGGREGATE_COUNT).count()).isEqualTo(2);
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

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