Search in sources :

Example 66 with Context

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

the class QedDecoderTest method decodeQEDAsNode.

@Test
void decodeQEDAsNode() throws Exception {
    String xmlFragment = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<root xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:hl7-org:v3\">\n" + "	<qed resultName=\"result\" resultValue=\"mytestvalue\">\n" + "		<templateId root=\"Q.E.D\"/>\n" + "	</qed>" + "</root>";
    // Get the root wrapper node
    Node root = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xmlFragment));
    assertThat(root.getChildNodes()).hasSize(1);
    Node target = root.getChildNodes().get(0);
    assertThat(target.getValue("result")).isEqualTo("mytestvalue");
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Example 67 with Context

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

the class AciSectionEncoderTest method aboutMetadataHolder.

@Test
void aboutMetadataHolder() {
    JsonWrapper jsonWrapper = new JsonWrapper();
    AciSectionEncoder aciSectionEncoder = new AciSectionEncoder(new Context());
    aciSectionEncoder.internalEncode(jsonWrapper, aciSectionNode);
    Map<?, ?> testMapObject = (Map<?, ?>) jsonWrapper.getObject();
    Stream failed = ((Set) testMapObject.get("metadata_holder")).stream().filter(entry -> ((Map) entry).get("template").equals(TemplateId.REPORTING_PARAMETERS_ACT.name())).filter(entry -> ((Map) entry).get("encodeLabel").equals(""));
    assertThat(failed.count()).isEqualTo(0);
}
Also used : Context(gov.cms.qpp.conversion.Context) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Context(gov.cms.qpp.conversion.Context) BeforeEach(org.junit.jupiter.api.BeforeEach) ReportingParametersActDecoder(gov.cms.qpp.conversion.decode.ReportingParametersActDecoder) Node(gov.cms.qpp.conversion.model.Node) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) Set(java.util.Set) Truth.assertThat(com.google.common.truth.Truth.assertThat) Mockito.spy(org.mockito.Mockito.spy) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) Mockito.never(org.mockito.Mockito.never) Stream(java.util.stream.Stream) Map(java.util.Map) TemplateId(gov.cms.qpp.conversion.model.TemplateId) ErrorCode(gov.cms.qpp.conversion.model.error.ErrorCode) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Set(java.util.Set) Stream(java.util.stream.Stream) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 68 with Context

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

the class AggregateCountEncoderTest method testEncoder.

/**
 * Test Function for the AggregateCountEncode
 */
@Test
void testEncoder() {
    AggregateCountEncoder encoder = new AggregateCountEncoder(new Context());
    encoder.setNodes(nodes);
    JsonWrapper json = new JsonWrapper();
    try {
        encoder.internalEncode(json, numeratorDenominatorNode);
    } catch (EncodeException e) {
        Assertions.fail("Failure to encode: " + e.getMessage());
    }
    assertThat(json.getInteger("value")).isEqualTo(600);
}
Also used : Context(gov.cms.qpp.conversion.Context) Test(org.junit.jupiter.api.Test)

Example 69 with Context

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

the class AggregateCountEncoderTest method testEncoderWithFramework.

/**
 * Test Function for the QppOutputEncoder
 */
@Test
void testEncoderWithFramework() {
    QppOutputEncoder encoder = new QppOutputEncoder(new Context());
    encoder.setNodes(nodes);
    StringWriter sw = new StringWriter();
    try {
        encoder.encode(new BufferedWriter(sw));
    } catch (EncodeException e) {
        Assertions.fail("Failure to encode: " + e.getMessage());
    }
    // NOTE: This test is only relevant in that it finds the deep value but it is not actually a result
    String expected = "{\n  \"value\" : 600\n}";
    assertThat(sw.toString()).isEqualTo(expected);
}
Also used : Context(gov.cms.qpp.conversion.Context) StringWriter(java.io.StringWriter) BufferedWriter(java.io.BufferedWriter) Test(org.junit.jupiter.api.Test)

Example 70 with Context

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

the class ClinicalDocumentEncoderTest method testClinicalDocumentEncoderIgnoresInvalidMeasurementSection.

@Test
void testClinicalDocumentEncoderIgnoresInvalidMeasurementSection() {
    Node reportingParamNode = new Node(TemplateId.REPORTING_PARAMETERS_ACT, clinicalDocumentNode);
    reportingParamNode.putValue(ReportingParametersActEncoder.PERFORMANCE_START, "20170101");
    reportingParamNode.putValue(ReportingParametersActEncoder.PERFORMANCE_END, "20171231");
    JsonWrapper testJsonWrapper = new JsonWrapper();
    String expectedSection = "aci";
    ClinicalDocumentEncoder clinicalDocumentEncoder = new ClinicalDocumentEncoder(new Context());
    clinicalDocumentEncoder.internalEncode(testJsonWrapper, clinicalDocumentNode);
    Map<?, ?> clinicalDocMap = ((Map<?, ?>) testJsonWrapper.getObject());
    List<LinkedHashMap<String, Object>> measurementSets = getMeasurementSets(clinicalDocMap);
    String value = (String) measurementSets.get(0).get("category");
    assertThat(measurementSets).hasSize(1);
    assertThat(value).isEqualTo(expectedSection);
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) LinkedHashMap(java.util.LinkedHashMap) 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