/** AD = ST, ST,... */
  @Test
  public void testObx5WithExpectedComponentExpectedComponent() throws HL7Exception {

    // Message is stripped down
    String msgString =
        "MSH|^~\\&\r" // -
            + "OBR|\r" // -
            + "OBX||AD|||F1C1^F2C1\r";

    ORU_R01 msg = new ORU_R01();
    msg.parse(msgString);

    String encode = msg.encode();
    ourLog.debug("\n\n" + encode);

    Varies observationValue =
        msg.getPATIENT_RESULT(0)
            .getORDER_OBSERVATION(0)
            .getOBSERVATION()
            .getOBX()
            .getObx5_ObservationValue(0);
    AD obx5 = (AD) observationValue.getData();
    assertEquals("F1C1", obx5.getAd1_StreetAddress().getValue());
    assertEquals("F2C1", obx5.getAd2_OtherDesignation().getValue());

    assertEquals(msgString.trim(), encode.trim());
  }
  /**
   * CD = WVI, WVS,...<br>
   * WVI = NM, ST
   */
  @Test
  public void testObx5WithExpectedComponentExpectedSubcomponent() throws HL7Exception {

    // Message is stripped down
    String msgString =
        "MSH|^~\\&\r" // -
            + "OBR|\r" // -
            + "OBX||CD|||F1C1&F1C2\r";

    ORU_R01 msg = new ORU_R01();
    msg.setParser(new PipeParser(new DefaultHapiContext(ValidationContextFactory.noValidation())));
    msg.parse(msgString);

    String encode = msg.encode();
    ourLog.debug("\n\n" + encode);

    Varies observationValue =
        msg.getPATIENT_RESULT(0)
            .getORDER_OBSERVATION(0)
            .getOBSERVATION()
            .getOBX()
            .getObx5_ObservationValue(0);
    CD obx5 = (CD) observationValue.getData();
    assertEquals("F1C1", obx5.getCd1_ChannelIdentifier().getWvi1_ChannelNumber().getValue());
    assertEquals("F1C2", obx5.getCd1_ChannelIdentifier().getWvi2_ChannelName().getValue());

    assertEquals(msgString.trim(), encode.trim());
  }
  @Test
  public void testObx5WithExpectedComponentUnpexpectedSubcomponentWithinPrimitive2()
      throws HL7Exception {

    // Message is stripped down
    String msgString =
        "MSH|^~\\&\r" // -
            + "OBR|\r" // -
            + "OBX||ST|||F1C1&F1C2\r";

    ORU_R01 msg = new ORU_R01();
    msg.getParser().getParserConfiguration().setEscapeSubcomponentDelimiterInPrimitive(true);
    msg.parse(msgString);

    String encode = msg.encode();
    ourLog.debug("\n\n" + encode);

    Varies observationValue =
        msg.getPATIENT_RESULT(0)
            .getORDER_OBSERVATION(0)
            .getOBSERVATION()
            .getOBX()
            .getObx5_ObservationValue(0);
    ST obx5 = (ST) observationValue.getData();
    assertEquals("F1C1&F1C2", obx5.getValue());

    String expected =
        "MSH|^~\\&\r" // -
            + "OBR|\r" // -
            + "OBX||ST|||F1C1\\T\\F1C2\r";

    assertEquals(expected.trim(), encode.trim());
  }
  /** AD = ST, ST,... */
  @Test
  public void testObx5WithExpectedComponentUnpexpectedSubcomponentWithinPrimitive()
      throws HL7Exception {

    // Message is stripped down
    String msgString =
        "MSH|^~\\&\r" // -
            + "OBR|\r" // -
            + "OBX||ST|||F1C1&F1C2\r";

    System.setProperty(Varies.ESCAPE_SUBCOMPONENT_DELIM_IN_PRIMITIVE, "TRUE");

    ORU_R01 msg = new ORU_R01();
    msg.parse(msgString);

    String encode = msg.encode();
    ourLog.debug("\n\n" + encode);

    Varies observationValue =
        msg.getPATIENT_RESULT(0)
            .getORDER_OBSERVATION(0)
            .getOBSERVATION()
            .getOBX()
            .getObx5_ObservationValue(0);
    ST obx5 = (ST) observationValue.getData();
    assertEquals("F1C1&F1C2", obx5.getValue());

    String expected =
        "MSH|^~\\&\r" // -
            + "OBR|\r" // -
            + "OBX||ST|||F1C1\\T\\F1C2\r";

    assertEquals(expected.trim(), encode.trim());
  }
  /** Checking a problem that was reported by email */
  @Test
  public void testMultipleValuesInObx5() throws HL7Exception, IOException {

    ORU_R01 msg = new ORU_R01();
    msg.initQuickstart("ORU", "R01", "T");

    String input =
        "OBX|10|FT|2239^Opm."
            + "fundus^L^OPFU^FUFOFA||TEKST\\\\E\\\\.br\\\\E\\\\Unclear; niet te"
            + "beoordelen.&line 2&line 3|\\\"\\\"|\\\"\\\"|\\\"\\\"|||F";
    OBX obx = msg.getPATIENT_RESULT().getORDER_OBSERVATION().getOBSERVATION().getOBX();
    obx.parse(input);

    String encoded = obx.encode();
    ourLog.debug("Encoded: \n{}", encoded);
  }
  /**
   * This is from a reported message that was kind of malformed to begin with, but became more
   * malformed in processing.
   *
   * <p>Parse method should clear all existing data including extra components.
   */
  @Test
  public void testVariesParseMethodClearsExistingExtraComponents() throws HL7Exception {

    // Message is stripped down
    String msgString =
        "MSH|^~\\&\r" // -
            + "OBR|\r" // -
            + "OBX||FN|||OF1C1^OF2C1&OF2C2\r";

    ORU_R01 msg = new ORU_R01();
    msg.parse(msgString);

    OBX obx = msg.getPATIENT_RESULT().getORDER_OBSERVATION().getOBSERVATION().getOBX();
    Varies varies = obx.getObx5_ObservationValue(0);
    varies.parse("NF1^NF2");

    String encode = msg.encode();
    ourLog.debug("\n\n" + encode);

    assertEquals("NF1^NF2", varies.encode());
  }
示例#7
0
  @Ignore
  @Test
  @DirtiesContext
  public void validHL7IsConvertedAndAckIsSent() throws Exception {
    standardHL7XMLEndpoint.expectedMessageCount(1);
    t5XMLEndpoint.expectedMessageCount(1);

    String hl7Input =
        "MSH|^~\\&|SendingApplication|SendingFacility|ReceivingApplication|ReceivingFacility|20120530112345||ORU^R01^ORU_R01|9879790003|P|2.6|||NE|AL|USA|ASCII|EN^English^ISO639||IHE_PCD_ORU_R01^IHE PCD^1.3.6.1.4.1.19376.1.6.1.1.1^ISO\r"
            + "PID|||HO2009001^^^NIST^PI||Hon^Albert^^^^^L|Adams^^^^^^L|19610101|M|||15 N Saguaro^^Tucson^AZ^85701\r"
            + "PV1||I|ICU^2^23\r"
            + "OBR|1|||44616-1^Pulse oximetry panel ^LN|||20120512031234||||||||||||||||||F|||||||||||||||||||252465000^Pulse oximetry^SCT|7087005^Intermittent^SCT\r"
            + "NTE|1||This comment refers to all the results in the battery\r"
            + "OBX|1|NM|8889-8^Heart Rate by Oximetry^LN^149530^ MDC_PULS_OXIM_PULS_RATE^MDC|1.11.2.3|55|{beats}/min^beats per minute^UCUM|35-125||99||R|||20120530112340|||AMEAS^auto-measurement^MDC|0123456789ABCDEF^Pulse_Oximeter_Vendor_X^0123456789ABCDEF^EUI-64||49521004^left ear structure^SCT\n"
            + "NTE|1||This is a comment about pulse";

    Parser parser = new PipeParser();
    ORU_R01 originalMessage = (ORU_R01) parser.parse(hl7Input);
    String encodedHL7 = parser.encode(originalMessage);

    String response = minaTemplate.requestBody((Object) encodedHL7, String.class);

    ACK responseMessage = (ACK) parser.parse(response);

    assertEquals(
        AcknowledgmentCode.AA.name(), responseMessage.getMSA().getAcknowledgmentCode().getValue());

    standardHL7XMLEndpoint.assertIsSatisfied();
    t5XMLEndpoint.assertIsSatisfied();

    ORU_R01 outputStandardXMLMessage =
        (ORU_R01) parseXMLExchange(standardHL7XMLEndpoint.getReceivedExchanges().get(0));

    assertEquals(
        originalMessage.getMSH().getMessageType().getName(),
        outputStandardXMLMessage.getMSH().getMessageType().getName());
    assertEquals(
        originalMessage.getMSH().getMessageControlID().getValue(),
        outputStandardXMLMessage.getMSH().getMessageControlID().getValue());
  }