Search in sources :

Example 96 with Context

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

the class AciNumeratorDenominatorDecoderTest method decodeAciNumeratorDenominatorExtraneousXMLTest.

@Test
void decodeAciNumeratorDenominatorExtraneousXMLTest() throws XmlException {
    String xmlFragment = getValidXmlFragment();
    xmlFragment = xmlFragment.replaceAll("<statusCode ", "\n<Stuff arbitrary=\"123\"><newnode>Some extra stuff</newnode></Stuff>Unexpected stuff appears here\n\n<statusCode ");
    Node aciMeasureNode = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xmlFragment));
    assertWithMessage("Decoded xml fragment should contain one child node").that(aciMeasureNode.getChildNodes()).hasSize(1);
    List<Node> nodeList = aciMeasureNode.findNode(TemplateId.ACI_NUMERATOR);
    assertWithMessage("Decoded xml fragment should contain %s", TemplateId.ACI_NUMERATOR.name()).that(nodeList).hasSize(1);
    nodeList = nodeList.get(0).findNode(TemplateId.ACI_AGGREGATE_COUNT);
    assertWithMessage("Decoded xml fragment %s should contain %s", TemplateId.ACI_NUMERATOR.name(), TemplateId.ACI_AGGREGATE_COUNT.name()).that(nodeList).hasSize(1);
    nodeList = aciMeasureNode.findNode(TemplateId.ACI_DENOMINATOR);
    assertWithMessage("Decoded xml fragment should contain %s", TemplateId.ACI_DENOMINATOR.name()).that(nodeList).hasSize(1);
    nodeList = nodeList.get(0).findNode(TemplateId.ACI_AGGREGATE_COUNT);
    assertWithMessage("Decoded xml fragment %s should contain %s", TemplateId.ACI_NUMERATOR.name(), TemplateId.ACI_AGGREGATE_COUNT.name()).that(nodeList).hasSize(1);
    int numberNodes = countNodes(aciMeasureNode);
    assertWithMessage("Decoded xml fragment %s should contain 6 nodes", aciMeasureNode.getType().name()).that(numberNodes).isEqualTo(6);
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Example 97 with Context

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

the class AciNumeratorDenominatorDecoderTest method decodeAciNumeratorDenominatorNullElementAsNode.

@Test
void decodeAciNumeratorDenominatorNullElementAsNode() 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\"/>", "  </observation>", "</root>");
    Node numDenomNode = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xmlFragment));
    assertWithMessage("aci numerator/denominator value should be null").that(numDenomNode.getChildNodes().get(0).getValue("aggregateCount")).isNull();
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Example 98 with Context

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

the class AciProportionDenominatorDecoderTest method decodeInvalidACIProportionDenominatorAsNode.

@Test
void decodeInvalidACIProportionDenominatorAsNode() 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" + "  <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>" + " </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(2);
    // 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 99 with Context

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

the class AciProportionNumeratorDecoderTest method testInternalDecode.

@Test
void testInternalDecode() {
    Element element = new Element("testElement");
    Node node = new Node();
    AciProportionNumeratorDecoder aciProportionNumeratorDecoder = new AciProportionNumeratorDecoder(new Context());
    DecodeResult decodeResult = aciProportionNumeratorDecoder.decode(element, node);
    assertThat(decodeResult).isEqualTo(DecodeResult.TREE_CONTINUE);
    assertThat(node.getValue("name")).isEqualTo(NUMERATOR_NODE_NAME);
}
Also used : Context(gov.cms.qpp.conversion.Context) Element(org.jdom2.Element) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Example 100 with Context

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

the class AciSectionDecoderTest method testInternalDecode.

@Test
void testInternalDecode() {
    Element element = new Element("testElement");
    Node node = new Node();
    AciSectionDecoder aciSectionDecoder = new AciSectionDecoder(new Context());
    aciSectionDecoder.decode(element, node);
    assertThat(node.getValue("category")).isEqualTo("aci");
}
Also used : Context(gov.cms.qpp.conversion.Context) Element(org.jdom2.Element) 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