Search in sources :

Example 1 with Context

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

the class AciMeasurePerformedRnRDecoderTest method internalDecodeReturnsTreeContinue.

@Test
void internalDecodeReturnsTreeContinue() {
    // set-up
    AciMeasurePerformedRnRDecoder objectUnderTest = new AciMeasurePerformedRnRDecoder(new Context());
    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 aciMeasurePerformedNode = new Node();
    objectUnderTest.setNamespace(element.getNamespace());
    // execute
    DecodeResult decodeResult = objectUnderTest.decode(element, aciMeasurePerformedNode);
    // assert
    assertThat(decodeResult).isEqualTo(DecodeResult.TREE_CONTINUE);
    String actualMeasureId = aciMeasurePerformedNode.getValue("measureId");
    assertThat(actualMeasureId).isEqualTo(MEASURE_ID);
}
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 2 with Context

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

the class AciMeasurePerformedRnRDecoderTest method testUpperLevel.

@Test
void testUpperLevel() throws XmlException, IOException {
    String needsFormattingXml = TestHelper.getFixture("AciMeasurePerformedIsolated.xml");
    String xml = String.format(needsFormattingXml, MEASURE_ID);
    Node wrapperNode = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(xml));
    Node aciMeasurePerformedNode = wrapperNode.getChildNodes().get(0);
    String actualMeasureId = aciMeasurePerformedNode.getValue("measureId");
    assertThat(actualMeasureId).isEqualTo(MEASURE_ID);
    long measurePerformedCount = aciMeasurePerformedNode.getChildNodes(node -> node.getType() == TemplateId.MEASURE_PERFORMED).count();
    assertThat(measurePerformedCount).isEqualTo(1L);
}
Also used : Context(gov.cms.qpp.conversion.Context) Test(org.junit.jupiter.api.Test) Context(gov.cms.qpp.conversion.Context) TestHelper(gov.cms.qpp.TestHelper) Node(gov.cms.qpp.conversion.model.Node) XmlUtils(gov.cms.qpp.conversion.xml.XmlUtils) Namespace(org.jdom2.Namespace) TemplateId(gov.cms.qpp.conversion.model.TemplateId) IOException(java.io.IOException) XmlException(gov.cms.qpp.conversion.xml.XmlException) Truth.assertThat(com.google.common.truth.Truth.assertThat) Element(org.jdom2.Element) Node(gov.cms.qpp.conversion.model.Node) Test(org.junit.jupiter.api.Test)

Example 3 with Context

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

the class AciNumeratorDenominatorRoundTripTest method parseAciNumeratorDenominatorAsNode.

@Test
void parseAciNumeratorDenominatorAsNode() throws Exception {
    String xmlFragment = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<entry xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:hl7-org:v3\">\n" + "	<organizer classCode=\"CLUSTER\" moodCode=\"EVN\">\n" + "		<!-- Implied template Measure Reference templateId -->\n" + "		<!-- ACI Numerator Denominator Type Measure Reference and Results templateId -->\n" + "		<templateId root=\"2.16.840.1.113883.10.20.27.3.28\" extension=\"2017-06-01\"/>\n" + "		<id root=\"ac575aef-7062-4ea2-b723-df517cfa470a\"/>\n" + "		<statusCode code=\"completed\"/>\n" + "		<reference typeCode=\"REFR\">\n" + "			<!-- Reference to a particular ACI measure's unique identifier. -->\n" + "			<externalDocument classCode=\"DOC\" moodCode=\"EVN\">\n" + "				<!-- This is a temporary root OID that indicates this is an ACI measure identifier -->\n" + "				<!-- extension is the unique identifier for an ACI measure. \"ACI-PEA-1\" is for illustration only. -->\n" + "				<id root=\"2.16.840.1.113883.3.7031\" extension=\"ACI-PEA-1\"/>\n" + "				<!-- ACI measure title -->\n" + "				<text>Patient Access</text>\n" + "			</externalDocument>\n" + "		</reference>\n" + "		<component>\n" + "			<observation classCode=\"OBS\" moodCode=\"EVN\">\n" + "				<!-- Performance Rate templateId -->\n" + "				<templateId root=\"2.16.840.1.113883.10.20.27.3.30\"\n" + "					extension=\"2016-09-01\"/>\n" + "				<code code=\"72510-1\" codeSystem=\"2.16.840.1.113883.6.1\" codeSystemName=\"LOINC\" displayName=\"Performance Rate\"/>\n" + "				<statusCode code=\"completed\"/>\n" + "				<value xsi:type=\"REAL\" value=\"0.750000\"/>\n" + "			</observation>\n" + "		</component>\n" + "		<component>\n" + "			<observation classCode=\"OBS\" moodCode=\"EVN\">\n" + "				<!-- ACI Numerator Denominator Type Measure Numerator Data templateId -->\n" + "				<templateId root=\"2.16.840.1.113883.10.20.27.3.31\"\n" + "					extension=\"2016-09-01\"/>\n" + "				<code code=\"ASSERTION\" codeSystem=\"2.16.840.1.113883.5.4\"\n" + "					codeSystemName=\"ActCode\" displayName=\"Assertion\"/>\n" + "				<statusCode code=\"completed\"/>\n" + "				<value xsi:type=\"CD\" code=\"NUMER\"\n" + "					codeSystem=\"2.16.840.1.113883.5.4\" codeSystemName=\"ActCode\"/>\n" + "				<!-- Numerator 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\"\n" + "							codeSystemName=\"ActCode\"\n" + "							displayName=\"rate aggregation\"/>\n" + "						<statusCode code=\"completed\"/>\n" + "						<value xsi:type=\"INT\" value=\"600\"/>\n" + "						<methodCode code=\"COUNT\"\n" + "							codeSystem=\"2.16.840.1.113883.5.84\"\n" + "							codeSystemName=\"ObservationMethod\"\n" + "							displayName=\"Count\"/>\n" + "					</observation>\n" + "				</entryRelationship>\n" + "			</observation>\n" + "		</component>\n" + "		<component>\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\"\n" + "					extension=\"2016-09-01\"/>\n" + "				<code code=\"ASSERTION\" codeSystem=\"2.16.840.1.113883.5.4\"\n" + "					codeSystemName=\"ActCode\" displayName=\"Assertion\"/>\n" + "				<statusCode code=\"completed\"/>\n" + "				<value xsi:type=\"CD\" code=\"DENOM\"\n" + "					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\"\n" + "							codeSystemName=\"ActCode\"\n" + "							displayName=\"rate aggregation\"/>\n" + "						<statusCode code=\"completed\"/>\n" + "						<value xsi:type=\"INT\" value=\"800\"/>\n" + "						<methodCode code=\"COUNT\"\n" + "							codeSystem=\"2.16.840.1.113883.5.84\"\n" + "							codeSystemName=\"ObservationMethod\"\n" + "							displayName=\"Count\"/>\n" + "					</observation>\n" + "				</entryRelationship>\n" + "			</observation>\n" + "		</component>\n" + "	</organizer>\n" + "</entry>";
    Context context = new Context();
    Node numeratorDenominatorNode = new QrdaDecoderEngine(context).decode(XmlUtils.stringToDom(xmlFragment));
    // remove default nodes (will fail if defaults change)
    DefaultDecoder.removeDefaultNode(numeratorDenominatorNode.getChildNodes());
    String xPathExpected = "/*[local-name() = 'entry' and namespace-uri() = 'urn:hl7-org:v3']/*[local-name() = 'organizer' " + "and namespace-uri() = 'urn:hl7-org:v3']";
    QppOutputEncoder encoder = new QppOutputEncoder(context);
    List<Node> nodes = new ArrayList<>();
    nodes.add(numeratorDenominatorNode);
    encoder.setNodes(nodes);
    StringWriter sw = new StringWriter();
    encoder.encode(new BufferedWriter(sw));
    String jsonExpected = "{\n  \"measureId\" : \"ACI-PEA-1\",\n  \"value\" : {\n    \"numerator\" : 600,\n    \"denominator\" : 800\n  }\n}";
    assertWithMessage("The XPath of the numerator denominator node is incorrect").that(numeratorDenominatorNode.getChildNodes().get(0).getPath()).isEqualTo(xPathExpected);
    assertWithMessage("expected encoder to return a representation of a measure").that(sw.toString()).isEqualTo(jsonExpected);
}
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 4 with Context

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

the class AciProportionNumeratorRoundTripTest 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" + "		<templateId root=\"2.16.840.1.113883.10.20.27.3.31\" 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=\"NUMER\" codeSystem=\"2.16.840.1.113883.5.4\" codeSystemName=\"ActCode\" />\n" + "		<!-- Numerator 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>\n" + "		</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  \"numerator\" : 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 5 with Context

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

the class AciSectionRoundTripTest method parseAciSectionAsJson.

@Test
void parseAciSectionAsJson() throws EncodeException, XmlException {
    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" + "	<section>\n" + "		<!-- Measure Section -->\n" + "		<templateId root=\"2.16.840.1.113883.10.20.24.2.2\"/>\n" + "		<!-- Advancing Care Information Section templateId -->\n" + "		<templateId root=\"2.16.840.1.113883.10.20.27.2.5\" extension=\"2017-06-01\"/>\n" + "		<code code=\"55186-1\" codeSystem=\"2.16.840.1.113883.6.1\" displayName=\"Measure Section\"/>\n" + "		<title>Measure Section</title>\n" + "		<text>\n" + "		</text>\n" + "		<entry>\n" + "			<qed resultName=\"measure\" resultValue=\"measure1\">\n" + "				<templateId root=\"Q.E.D\"/>\n" + "			</qed>" + "		</entry>\n" + "		<entry typeCode=\"DRIV\">" + "			<act classCode=\"ACT\" moodCode=\"EVN\">" + "				<templateId root=\"2.16.840.1.113883.10.20.17.3.8\"/>" + "				<id root=\"00b669fd-fa4d-4f5c-b109-65c6bbbf73ae\"/>" + "				<code code=\"252116004\" codeSystem=\"2.16.840.1.113883.6.96\"" + "					displayName=\"Observation Parameters\"/>" + "				<effectiveTime>" + "					<low value=\"20170101\"/>" + "					<high value=\"20170430\"/>" + "				</effectiveTime>" + "			</act>" + "		</entry>" + "	</section>\n" + "</component>";
    String expected = "{\n  \"category\" : \"aci\",\n  \"submissionMethod\" : \"electronicHealthRecord\",\n  \"measurements\" : [ {\n    \"measure\" : \"measure1\"\n  } ],\n  \"performanceStart\" : \"2017-01-01\",\n  \"performanceEnd\" : \"2017-04-30\"\n}";
    Context context = new Context();
    // Decode
    Node measureNode = new QrdaDecoderEngine(context).decode(XmlUtils.stringToDom(xmlFragment));
    // remove default nodes (will fail if defaults change)
    DefaultDecoder.removeDefaultNode(measureNode.getChildNodes());
    // Encode
    QppOutputEncoder encoder = new QppOutputEncoder(context);
    List<Node> nodes = new ArrayList<>();
    nodes.add(measureNode);
    encoder.setNodes(nodes);
    StringWriter sw = new StringWriter();
    encoder.encode(new BufferedWriter(sw));
    // Test
    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)

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