use of gov.cms.qpp.conversion.Context in project qpp-conversion-tool by CMSgov.
the class MeasureDataRoundTripTest method test.
private void test(SubPopulationLabel type) throws Exception {
// setup
String typeLabel = type.name();
Node placeholder = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(happy));
Node measure = placeholder.findChildNode(n -> n.getValue(MEASURE_TYPE).equals(typeLabel));
// when
StringWriter sw = encode(placeholder);
// then
assertThat(measure).isNotNull();
assertThat(measure.getChildNodes().get(0).getType()).isEquivalentAccordingToCompareTo(TemplateId.ACI_AGGREGATE_COUNT);
assertThat(sw.toString()).isEqualTo(expected);
}
use of gov.cms.qpp.conversion.Context 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.Context in project qpp-conversion-tool by CMSgov.
the class AciNumeratorDenominatorDecoderTest method decodeAciNumeratorDenominatorNullValueAsNode.
@Test
void decodeAciNumeratorDenominatorNullValueAsNode() 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\"/>", " <value xsi:type=\"INT\"/>", " </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();
}
use of gov.cms.qpp.conversion.Context in project qpp-conversion-tool by CMSgov.
the class AciNumeratorDenominatorDecoderTest method testInternalDecode.
@Test
void testInternalDecode() {
// set-up
Namespace rootns = Namespace.getNamespace("urn:hl7-org:v3");
Namespace ns = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Element element = new Element("organizer", rootns);
Element templateIdElement = new Element("templateId", rootns).setAttribute("root", "2.16.840.1.113883.10.20.27.3.28");
Element referenceElement = new Element("reference", rootns);
Element externalDocumentElement = new Element("externalDocument", rootns);
Element idElement = new Element("id", rootns).setAttribute("extension", MEASURE_ID);
externalDocumentElement.addContent(idElement);
referenceElement.addContent(externalDocumentElement);
element.addContent(templateIdElement);
element.addContent(referenceElement);
element.addNamespaceDeclaration(ns);
Node thisNode = new Node();
AciNumeratorDenominatorDecoder objectUnderTest = new AciNumeratorDenominatorDecoder(new Context());
objectUnderTest.setNamespace(element.getNamespace());
// execute
objectUnderTest.decode(element, thisNode);
// assert
assertThat(thisNode.getValue("measureId")).isEqualTo(MEASURE_ID);
}
use of gov.cms.qpp.conversion.Context in project qpp-conversion-tool by CMSgov.
the class AciNumeratorDenominatorDecoderTest method decodeValidAciNumeratorDenominatorTest.
@Test
void decodeValidAciNumeratorDenominatorTest() throws XmlException {
Node aciMeasureNode = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(getValidXmlFragment()));
Node numeratorDenominatorNode = aciMeasureNode.getChildNodes().get(0);
int numberNodes = countNodes(aciMeasureNode);
List<Node> nodeList = aciMeasureNode.findNode(TemplateId.ACI_NUMERATOR);
assertThat(numeratorDenominatorNode.getValue("measureId")).isEqualTo(MEASURE_ID);
assertThat(numeratorDenominatorNode.getChildNodes().get(0).getType()).isEqualTo(TemplateId.ACI_NUMERATOR);
assertThat(numeratorDenominatorNode.getChildNodes().get(1).getType()).isEqualTo(TemplateId.ACI_DENOMINATOR);
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);
assertWithMessage("Decoded xml fragment %s should contain 6 nodes", aciMeasureNode.getType().name()).that(numberNodes).isEqualTo(6);
assertWithMessage("measureId should be %s", MEASURE_ID).that(numeratorDenominatorNode.getValue("measureId")).isEqualTo(MEASURE_ID);
}
Aggregations