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;
}
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);
}
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);
}
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);
}
Aggregations