Search in sources :

Example 16 with Context

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

the class AggregateCountDecoderTest method testAggregateCountDecoderIgnoresInvalidElementsPartTwo.

@Test
void testAggregateCountDecoderIgnoresInvalidElementsPartTwo() throws XmlException {
    Node root = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(ANOTHER_XML_FRAGMENT));
    assertWithMessage("Node has aggregate count").that(root.getValue("aggregateCount")).isEqualTo("400");
    assertWithMessage("Should have template id").that(root.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 17 with Context

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

the class AggregateCountDecoderTest method testInternalDecode.

@Test
void testInternalDecode() {
    Namespace rootNs = Namespace.getNamespace("urn:hl7-org:v3");
    Namespace ns = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    Context context = new Context();
    Element element = new Element("observation", rootNs);
    element.addContent(new Element("templateId", rootNs).setAttribute("root", TemplateId.ACI_AGGREGATE_COUNT.getTemplateId(context)));
    element.addContent(new Element("value", rootNs).setAttribute("value", "450").setAttribute("type", "INT", ns));
    element.addNamespaceDeclaration(ns);
    Node thisNode = new Node();
    AggregateCountDecoder instance = new AggregateCountDecoder(context);
    instance.setNamespace(element.getNamespace());
    instance.decode(element, thisNode);
    assertThat(thisNode.getValue("aggregateCount")).isEqualTo("450");
}
Also used : Context(gov.cms.qpp.conversion.Context) Element(org.jdom2.Element) Node(gov.cms.qpp.conversion.model.Node) Namespace(org.jdom2.Namespace) Test(org.junit.jupiter.api.Test)

Example 18 with Context

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

the class ClinicalDocumentDecoderTest method decodeClinicalDocumentInternalDecodeUnknown.

@Test
void decodeClinicalDocumentInternalDecodeUnknown() {
    Element clinicalDocument = makeClinicalDocument("Unknown");
    Node testParentNode = new Node();
    ClinicalDocumentDecoder objectUnderTest = new ClinicalDocumentDecoder(new Context());
    objectUnderTest.setNamespace(clinicalDocument.getNamespace());
    objectUnderTest.decode(clinicalDocument, testParentNode);
    assertWithMessage("Clinical Document doesn't contain program name").that(testParentNode.getValue(ClinicalDocumentDecoder.PROGRAM_NAME)).isEqualTo("unknown");
    assertWithMessage("Clinical Document doesn't contain entity type").that(testParentNode.getValue(ClinicalDocumentDecoder.ENTITY_TYPE)).isEqualTo("individual");
    assertWithMessage("Clinical Document doesn't contain national provider").that(testParentNode.getValue(ClinicalDocumentDecoder.NATIONAL_PROVIDER_IDENTIFIER)).isEqualTo("2567891421");
    assertWithMessage("Clinical Document doesn't contain taxpayer id number").that(testParentNode.getValue(ClinicalDocumentDecoder.TAX_PAYER_IDENTIFICATION_NUMBER)).isEqualTo("123456789");
}
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 19 with Context

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

the class ClinicalDocumentDecoderTest method decodeClinicalDocumentInternalDecode.

@Test
void decodeClinicalDocumentInternalDecode() {
    Element clinicalDocument = makeClinicalDocument("MIPS");
    Node testParentNode = new Node();
    ClinicalDocumentDecoder objectUnderTest = new ClinicalDocumentDecoder(new Context());
    objectUnderTest.setNamespace(clinicalDocument.getNamespace());
    objectUnderTest.decode(clinicalDocument, testParentNode);
    assertWithMessage("Clinical Document doesn't contain program name").that(testParentNode.getValue(ClinicalDocumentDecoder.PROGRAM_NAME)).isEqualTo(ClinicalDocumentDecoder.MIPS_PROGRAM_NAME);
    assertWithMessage("Clinical Document doesn't contain entity type").that(testParentNode.getValue(ClinicalDocumentDecoder.ENTITY_TYPE)).isEqualTo(ClinicalDocumentDecoder.ENTITY_INDIVIDUAL);
    assertWithMessage("Clinical Document doesn't contain national provider").that(testParentNode.getValue(ClinicalDocumentDecoder.NATIONAL_PROVIDER_IDENTIFIER)).isEqualTo("2567891421");
    assertWithMessage("Clinical Document doesn't contain taxpayer id number").that(testParentNode.getValue(ClinicalDocumentDecoder.TAX_PAYER_IDENTIFICATION_NUMBER)).isEqualTo("123456789");
}
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 20 with Context

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

the class ClinicalDocumentDecoderTest method testClinicalDocumentIgnoresGarbage.

@Test
void testClinicalDocumentIgnoresGarbage() throws IOException, XmlException {
    InputStream stream = ClasspathHelper.contextClassLoader().getResourceAsStream("QRDA-III-with-extra-elements.xml");
    String xmlWithGarbage = IOUtils.toString(stream, StandardCharsets.UTF_8);
    Node root = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xmlWithGarbage));
    clinicalDocument = root.findFirstNode(TemplateId.CLINICAL_DOCUMENT);
    assertThat(clinicalDocument.getValue(ClinicalDocumentDecoder.PROGRAM_NAME)).isEqualTo(ClinicalDocumentDecoder.MIPS_PROGRAM_NAME);
    assertThat(clinicalDocument.getValue(ClinicalDocumentDecoder.TAX_PAYER_IDENTIFICATION_NUMBER)).isEqualTo("123456789");
}
Also used : Context(gov.cms.qpp.conversion.Context) InputStream(java.io.InputStream) 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