Ejemplo n.º 1
0
 public boolean isValidExchange(SerialNumber serialNumber, Exchange request) {
   // create upper bound for calculation of average
   SerialNumber validityCheckBound =
       new SerialNumber(serialNumber.getSerialNumber().add(ADD_FOR_BOUND));
   // find the set of serial #'s strictly greater than serialNumber and <= validityCheckBound
   NavigableSet<SerialNumber> temp =
       getExclusiveToInclusiveSubset(
           request.getCompatibleProducts(), serialNumber, validityCheckBound);
   // find the st of serial #'s strictly greater than serialNumber and less than average
   // if empty, no compatible product exists
   return !(getExclusiveSubset(request, serialNumber, average(temp)).isEmpty());
 }
  @Override
  public void process(Exchange exchange) throws Exception {

    // determine attributes of the message
    String message = exchange.getIn().getBody(String.class);
    String[] fields = PreParser.getFields(message, "MSH-9-1", "MSH-9-2", "MSH-9-3", "MSH-12");
    String messageType = fields[0];
    String triggerEvent = fields[1];
    String messageStructure = fields[2];
    String version = fields[3];

    // check who can accept the message
    boolean found = false;
    for (String routeId : routeIds) {
      Hl7v2Interceptor interceptor = map.get(routeId);
      Hl7v2TransactionConfiguration config =
          interceptor.getConfigurationHolder().getHl7v2TransactionConfiguration();
      try {
        config.checkMessageAcceptance(messageType, triggerEvent, messageStructure, version, true);

        LOG.debug(
            "Dispatch message with MSH-9-1='{}', MSH-9-2='{}', MSH-9-3='{}', MSH-12='{}' to route '{}'",
            messageType,
            triggerEvent,
            messageStructure,
            version,
            routeId);
        found = true;
        interceptor.process(exchange);
        break;
      } catch (Hl7v2AcceptanceException e) {
        // no problem
      }
    }

    if (!found) {
      LOG.debug(
          "Nobody can process message with MSH-9-1='{}', MSH-9-2='{}', MSH-9-3='{}', MSH-12='{}'",
          messageType,
          triggerEvent,
          messageStructure,
          version);
      HL7Exception exception =
          new HL7Exception(
              "Unsupported message type and/or version", ErrorCode.APPLICATION_INTERNAL_ERROR);
      resultMessage(exchange).setBody(getNakFactory().createDefaultNak(exception).encode());
    }
  }
Ejemplo n.º 3
0
 @Override
 public SerialNumber getExchangeResult(Exchange request) {
   return getExclusiveSubset(request, getSerialNumber(), average(request.getCompatibleProducts()))
       .last();
 }