Ejemplo n.º 1
0
  /**
   * 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());
  }
Ejemplo n.º 2
0
  /** 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());
  }
Ejemplo n.º 3
0
  @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());
  }
Ejemplo n.º 4
0
  /** 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());
  }
Ejemplo n.º 5
0
  /** 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);
  }
Ejemplo n.º 6
0
  /**
   * 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());
  }