Search in sources :

Example 11 with QrdaDecoderEngine

use of gov.cms.qpp.conversion.decode.QrdaDecoderEngine 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);
}
Also used : Context(gov.cms.qpp.conversion.Context) StringWriter(java.io.StringWriter) Node(gov.cms.qpp.conversion.model.Node) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine)

Example 12 with QrdaDecoderEngine

use of gov.cms.qpp.conversion.decode.QrdaDecoderEngine 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 13 with QrdaDecoderEngine

use of gov.cms.qpp.conversion.decode.QrdaDecoderEngine 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 14 with QrdaDecoderEngine

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

the class ClinicalDocumentRoundTripTest method checkCorrectClinicalDocumentTemplateIdWins.

@Test
void checkCorrectClinicalDocumentTemplateIdWins() throws XmlException {
    String similarClinicalDocumentBlob = "<ClinicalDocument xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + "\t\t\t\t  xsi:schemaLocation=\"urn:hl7-org:v3 ../CDA_Schema_Files/infrastructure/cda/CDA_SDTC.xsd\"\n" + "\t\t\t\t  xmlns=\"urn:hl7-org:v3\" xmlns:voc=\"urn:hl7-org:v3/voc\">\n" + "\t<realmCode code=\"US\"/>\n" + "\t<typeId root=\"2.16.840.1.113883.1.3\" extension=\"POCD_HD000040\"/>\n" + "\t<templateId root=\"2.16.840.1.113883.10.20.27.1.2\"/>\n" + "\t<templateId root=\"2.16.840.1.113883.10.20.27.1.2\" extension=\"2017-07-01\"/>\n" + "</ClinicalDocument>";
    Node root = new QrdaDecoderEngine(new Context()).decode(XmlUtils.stringToDom(similarClinicalDocumentBlob));
    assertThat(root.getType()).isEqualTo(TemplateId.CLINICAL_DOCUMENT);
}
Also used : Context(gov.cms.qpp.conversion.Context) Node(gov.cms.qpp.conversion.model.Node) QrdaDecoderEngine(gov.cms.qpp.conversion.decode.QrdaDecoderEngine) Test(org.junit.jupiter.api.Test)

Aggregations

Context (gov.cms.qpp.conversion.Context)14 QrdaDecoderEngine (gov.cms.qpp.conversion.decode.QrdaDecoderEngine)14 Node (gov.cms.qpp.conversion.model.Node)14 Test (org.junit.jupiter.api.Test)13 QppOutputEncoder (gov.cms.qpp.conversion.encode.QppOutputEncoder)6 StringWriter (java.io.StringWriter)6 BufferedWriter (java.io.BufferedWriter)5 ArrayList (java.util.ArrayList)5 Detail (gov.cms.qpp.conversion.model.error.Detail)3 InputStream (java.io.InputStream)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 JsonWrapper (gov.cms.qpp.conversion.encode.JsonWrapper)1 LocalizedError (gov.cms.qpp.conversion.model.error.LocalizedError)1