Пример #1
0
  @Test
  public void generate() {
    logger.info("     INIT generate()");

    try {
      ACK ack = new ACK();
      ack.initQuickstart("ACK", null, "P");

      // MSH
      MSH msh = ack.getMSH();
      msh.getSendingApplication().getNamespaceID().setValue("sistemaExterno"); // MSH.3.1
      msh.getSendingFacility().getNamespaceID().setValue("FARMATOOLS"); // MSH.4.1
      msh.getReceivingFacility().getNamespaceID().setValue("HOSPITAL"); // MSH.6.1
      msh.getDateTimeOfMessage()
          .getTime()
          .setValue(
              DateUtil.format(
                  DateUtil.parse("03/04/2015 12:09:51", DateUtil.FECHA_HORA_SEPARADOR_BARRA),
                  DateUtil.FECHA_HORA_SIN_SEPARADOR_INVERTIDA)); // MSH.7
      msh.getSecurity().setValue("calidad2:calidad2"); // MSH.8
      msh.getMessageControlID().setValue("14966c1c9a394b79ad65b341fdaff"); // MSH.10
      msh.getProcessingID().getProcessingID().setValue("E"); // MSH.12
      msh.getAcceptAcknowledgmentType().setValue("AL"); // MSH.15
      msh.getApplicationAcknowledgmentType().setValue("AL"); // MSH.16
      msh.getCountryCode().setValue("ESP"); // MSH.17
      msh.getCharacterSet(0).setValue("ASCII"); // MSH.18

      // MSA
      MSA msa = ack.getMSA();
      msa.getAcknowledgmentCode().setValue("AE"); // MSA.1
      msa.getMessageControlID().setValue("16d24ee0105d410ac724d616a5cc5"); // MSA.2

      // ERR
      ERR err = ack.getERR(0);
      err.getHL7ErrorCode().getIdentifier().setValue("207"); // ERR.3.1
      err.getHL7ErrorCode().getText().setValue("ERROR AL PROCESAR EL MENSAJE"); // ERR.3.2
      err.getSeverity().setValue("E"); // ERR.3.4
      err.getDiagnosticInformation().setValue("error pq no viene NHC"); // ERR.3.7

      logger.debug(ack.encode());
      Assert.assertTrue(true);
    } catch (DateUtilException due) {
      logger.error(due);
      Assert.fail(due.toString());
    } catch (IOException ioe) {
      logger.error(ioe);
      Assert.fail(ioe.toString());
    } catch (HL7Exception hl7e) {
      logger.error(hl7e);
      Assert.fail(hl7e.toString());
    }

    logger.info("     END generate()");
  }
Пример #2
0
  @BeforeClass
  public static void before() {
    logger.info("INIT ACKTest");

    try {
      ACK = IOUtils.toString(ACKTest.class.getResource(ACK_ER7_V25));
      context = new DefaultHapiContext();
      logger.debug(context.getPipeParser().parse(ACK).printStructure());
      Assert.assertTrue(true);
    } catch (IOException ioe) {
      logger.error(ioe);
      Assert.fail(ioe.toString());
    } catch (HL7Exception hl7e) {
      logger.error(hl7e);
      Assert.fail(hl7e.toString());
    }
  }
Пример #3
0
  @Test
  public void parse() {
    logger.info("     INIT parse()");

    try {
      ACK ack = (ACK) context.getPipeParser().parse(ACK);

      // ACK
      logger.debug("          [" + ack.getName() + "] (start)");

      // MSH
      logger.debug("               [" + ack.getMSH().getName() + "]: " + ack.getMSH().encode());

      // SFT
      List<SFT> listaSFT = ack.getSFTAll();
      if (listaSFT != null && !listaSFT.isEmpty()) {
        Iterator<SFT> iteratorSFT = listaSFT.iterator();
        while (iteratorSFT.hasNext()) {
          SFT sft = iteratorSFT.next();
          logger.debug("          [" + sft.getName() + "]: " + sft.encode());
        }
      }

      // MSA
      logger.debug("               [" + ack.getMSA().getName() + "]: " + ack.getMSA().encode());

      // ERR
      List<ERR> listaERR = ack.getERRAll();
      if (listaERR != null && !listaERR.isEmpty()) {
        Iterator<ERR> iteratorERR = listaERR.iterator();
        while (iteratorERR.hasNext()) {
          ERR err = iteratorERR.next();
          logger.debug("               [" + err.getName() + "]: " + err.encode());
        }
      }

      logger.debug("          [" + ack.getName() + "] (end)");

    } catch (HL7Exception hl7e) {
      logger.error(hl7e);
      Assert.fail(hl7e.toString());
    }

    logger.info("     END parse()");
  }