Search in sources :

Example 6 with QppOutputEncoder

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

the class MeasureDataRoundTripTest method encode.

private StringWriter encode(Node placeholder) throws EncodeException {
    QppOutputEncoder encoder = new QppOutputEncoder(new Context());
    List<Node> nodes = new ArrayList<>();
    nodes.add(placeholder);
    encoder.setNodes(nodes);
    StringWriter sw = new StringWriter();
    encoder.encode(new BufferedWriter(sw));
    return sw;
}
Also used : Context(gov.cms.qpp.conversion.Context) QppOutputEncoder(gov.cms.qpp.conversion.encode.QppOutputEncoder) StringWriter(java.io.StringWriter) Node(gov.cms.qpp.conversion.model.Node) ArrayList(java.util.ArrayList) BufferedWriter(java.io.BufferedWriter)

Example 7 with QppOutputEncoder

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

the class AciNumeratorDenominatorValueRoundTripTest method decodeAggregateCountAsNode.

// we currently have a root placeholder node, so the numerator/denominator
// is indented an extra level
@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>");
    Context context = new Context();
    Node numDenomNode = new QrdaDecoderEngine(context).decode(XmlUtils.stringToDom(xmlFragment));
    String xPathExpected = "/*[local-name() = 'root' and namespace-uri() = 'urn:hl7-org:v3']/*[local-name() = 'observation'" + " and namespace-uri() = 'urn:hl7-org:v3']";
    assertWithMessage("The XPath of the aggregate count node is incorrect").that(numDenomNode.getChildNodes().get(0).getPath()).isEqualTo(xPathExpected);
    QppOutputEncoder encoder = new QppOutputEncoder(context);
    List<Node> nodes = new ArrayList<>();
    nodes.add(numDenomNode);
    encoder.setNodes(nodes);
    StringWriter sw = new StringWriter();
    encoder.encode(new BufferedWriter(sw));
    String expected = "{\n  \"value\" : 600\n}";
    assertThat(sw.toString()).isEqualTo(expected);
}
Also used : Context(gov.cms.qpp.conversion.Context) QppOutputEncoder(gov.cms.qpp.conversion.encode.QppOutputEncoder) StringWriter(java.io.StringWriter) Node(gov.cms.qpp.conversion.model.Node) ArrayList(java.util.ArrayList) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) BufferedWriter(java.io.BufferedWriter) Test(org.junit.jupiter.api.Test)

Example 8 with QppOutputEncoder

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

the class AciProportionDenominatorRoundTripTest method parseAciNumeratorDenominatorAsNode.

@Test
void parseAciNumeratorDenominatorAsNode() 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" + "		<code code=\"ASSERTION\" codeSystem=\"2.16.840.1.113883.5.4\" codeSystemName=\"ActCode\" displayName=\"Assertion\" />\n" + "		<statusCode code=\"completed\" />\n" + "		<value xsi:type=\"CD\" code=\"DENOM\" codeSystem=\"2.16.840.1.113883.5.4\" codeSystemName=\"ActCode\" />\n" + "		<!-- Denominator Count -->\n" + "		<entryRelationship typeCode=\"SUBJ\" inversionInd=\"true\">\n" + "			<observation classCode=\"OBS\" moodCode=\"EVN\">\n" + "				<templateId root=\"2.16.840.1.113883.10.20.27.3.3\" />\n" + "				<code code=\"MSRAGG\" codeSystem=\"2.16.840.1.113883.5.4\" codeSystemName=\"ActCode\" displayName=\"rate aggregation\" />\n" + "				<statusCode code=\"completed\" />\n" + "				<value xsi:type=\"INT\" value=\"600\" />\n" + "				<methodCode code=\"COUNT\" codeSystem=\"2.16.840.1.113883.5.84\" codeSystemName=\"ObservationMethod\" displayName=\"Count\" />\n" + "			</observation>" + "		</entryRelationship>\n" + "	</observation>\n" + "</component>";
    Context context = new Context();
    Node numDenomNode = new QrdaDecoderEngine(context).decode(XmlUtils.stringToDom(xmlFragment));
    QppOutputEncoder encoder = new QppOutputEncoder(context);
    List<Node> nodes = new ArrayList<>();
    nodes.add(numDenomNode);
    encoder.setNodes(nodes);
    StringWriter sw = new StringWriter();
    encoder.encode(new BufferedWriter(sw));
    String EXPECTED = "{\n  \"denominator\" : 600\n}";
    assertThat(sw.toString()).isEqualTo(EXPECTED);
}
Also used : Context(gov.cms.qpp.conversion.Context) QppOutputEncoder(gov.cms.qpp.conversion.encode.QppOutputEncoder) StringWriter(java.io.StringWriter) Node(gov.cms.qpp.conversion.model.Node) ArrayList(java.util.ArrayList) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) BufferedWriter(java.io.BufferedWriter) Test(org.junit.jupiter.api.Test)

Example 9 with QppOutputEncoder

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

the class ClinicalDocumentRoundTripTest method parseClinicalDocument.

@Test
void parseClinicalDocument() throws Exception {
    InputStream stream = ClasspathHelper.contextClassLoader().getResourceAsStream("valid-QRDA-III-abridged.xml");
    String xmlFragment = IOUtils.toString(stream, StandardCharsets.UTF_8);
    Context context = new Context();
    Node clinicalDocumentNode = XmlDecoderEngine.decodeXml(context, XmlUtils.stringToDom(xmlFragment));
    // remove default nodes (will fail if defaults change)
    DefaultDecoder.removeDefaultNode(clinicalDocumentNode.getChildNodes());
    QppOutputEncoder encoder = new QppOutputEncoder(context);
    encoder.setNodes(Collections.singletonList(clinicalDocumentNode));
    StringWriter sw = new StringWriter();
    encoder.encode(new BufferedWriter(sw));
    assertThat(sw.toString()).isEqualTo(expected);
}
Also used : Context(gov.cms.qpp.conversion.Context) QppOutputEncoder(gov.cms.qpp.conversion.encode.QppOutputEncoder) StringWriter(java.io.StringWriter) InputStream(java.io.InputStream) Node(gov.cms.qpp.conversion.model.Node) BufferedWriter(java.io.BufferedWriter) Test(org.junit.jupiter.api.Test)

Aggregations

QppOutputEncoder (gov.cms.qpp.conversion.encode.QppOutputEncoder)9 Context (gov.cms.qpp.conversion.Context)8 Node (gov.cms.qpp.conversion.model.Node)8 BufferedWriter (java.io.BufferedWriter)7 StringWriter (java.io.StringWriter)7 Test (org.junit.jupiter.api.Test)7 QrdaDecoderEngine (gov.cms.qpp.conversion.decode.QrdaDecoderEngine)6 ArrayList (java.util.ArrayList)6 InputStream (java.io.InputStream)2 EncodeException (gov.cms.qpp.conversion.encode.EncodeException)1 JsonWrapper (gov.cms.qpp.conversion.encode.JsonWrapper)1 TransformException (gov.cms.qpp.conversion.model.error.TransformException)1 Path (java.nio.file.Path)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1