Search in sources :

Example 1 with ACK

use of ca.uhn.hl7v2.model.v24.message.ACK in project camel by apache.

the class AckExpressionTest method testAckExpression.

@Test
public void testAckExpression() throws Exception {
    ADT_A01 a01 = createADT01Message();
    ACK ack = template.requestBody("direct:test1", a01, ACK.class);
    assertEquals("AA", ack.getMSA().getAcknowledgementCode().getValue());
    assertEquals(a01.getMSH().getMessageControlID().getValue(), ack.getMSA().getMessageControlID().getValue());
}
Also used : ACK(ca.uhn.hl7v2.model.v24.message.ACK) ADT_A01(ca.uhn.hl7v2.model.v24.message.ADT_A01) Test(org.junit.Test)

Example 2 with ACK

use of ca.uhn.hl7v2.model.v24.message.ACK in project camel by apache.

the class AckExpressionTest method testNakExpressionWithParameters.

@Test
public void testNakExpressionWithParameters() throws Exception {
    ADT_A01 a01 = createADT01Message();
    ACK ack = template.requestBody("direct:test4", a01, ACK.class);
    assertEquals("AR", ack.getMSA().getAcknowledgementCode().getValue());
    assertEquals(a01.getMSH().getMessageControlID().getValue(), ack.getMSA().getMessageControlID().getValue());
    assertEquals(String.valueOf(ErrorCode.APPLICATION_INTERNAL_ERROR.getCode()), ack.getERR().getErrorCodeAndLocation(0).getCodeIdentifyingError().getIdentifier().getValue());
    assertEquals("Problem!", ack.getERR().getErrorCodeAndLocation(0).getCodeIdentifyingError().getAlternateText().getValue());
}
Also used : ACK(ca.uhn.hl7v2.model.v24.message.ACK) ADT_A01(ca.uhn.hl7v2.model.v24.message.ADT_A01) Test(org.junit.Test)

Example 3 with ACK

use of ca.uhn.hl7v2.model.v24.message.ACK in project pentaho-kettle by pentaho.

the class HL7MLLPAcknowledge method execute.

public Result execute(Result previousResult, int nr) {
    Result result = previousResult;
    try {
        String serverName = environmentSubstitute(server);
        int portNumber = Integer.parseInt(environmentSubstitute(port));
        String variable = environmentSubstitute(variableName);
        MLLPSocketCacheEntry entry = MLLPSocketCache.getInstance().getServerSocketStreamSource(serverName, portNumber);
        MLLPTransport transport = entry.getTransport();
        // 
        synchronized (transport) {
            String message = getVariable(variable);
            // Parse the message and extract the acknowledge message.
            // 
            Parser parser = new GenericParser();
            ValidationContext validationContext = new NoValidation();
            parser.setValidationContext(validationContext);
            Message msg = parser.parse(message);
            Message ack = msg.generateACK();
            String ackMessage = ack.encode();
            String APPNAME = "PDI4";
            if (ack instanceof ca.uhn.hl7v2.model.v21.message.ACK) {
                ca.uhn.hl7v2.model.v21.message.ACK mod = (ca.uhn.hl7v2.model.v21.message.ACK) ack;
                mod.getMSH().getSENDINGAPPLICATION().setValue(APPNAME);
                mod.getMSH().getSENDINGFACILITY().setValue(APPNAME);
                ackMessage = mod.encode();
            } else if (ack instanceof ca.uhn.hl7v2.model.v22.message.ACK) {
                ca.uhn.hl7v2.model.v22.message.ACK mod = (ca.uhn.hl7v2.model.v22.message.ACK) ack;
                mod.getMSH().getSendingApplication().setValue(APPNAME);
                mod.getMSH().getSendingFacility().setValue(APPNAME);
                ackMessage = mod.encode();
            } else if (ack instanceof ca.uhn.hl7v2.model.v23.message.ACK) {
                ca.uhn.hl7v2.model.v23.message.ACK mod = (ca.uhn.hl7v2.model.v23.message.ACK) ack;
                mod.getMSH().getSendingApplication().getNamespaceID().setValue(APPNAME);
                mod.getMSH().getSendingFacility().getNamespaceID().setValue(APPNAME);
                ackMessage = mod.encode();
            } else if (ack instanceof ca.uhn.hl7v2.model.v231.message.ACK) {
                ca.uhn.hl7v2.model.v231.message.ACK mod = (ca.uhn.hl7v2.model.v231.message.ACK) ack;
                mod.getMSH().getSendingApplication().getNamespaceID().setValue(APPNAME);
                mod.getMSH().getSendingFacility().getNamespaceID().setValue(APPNAME);
                ackMessage = mod.encode();
            } else if (ack instanceof ca.uhn.hl7v2.model.v24.message.ACK) {
                ca.uhn.hl7v2.model.v24.message.ACK mod = (ca.uhn.hl7v2.model.v24.message.ACK) ack;
                mod.getMSH().getSendingApplication().getNamespaceID().setValue(APPNAME);
                mod.getMSH().getSendingFacility().getNamespaceID().setValue(APPNAME);
                ackMessage = mod.encode();
            } else if (ack instanceof ca.uhn.hl7v2.model.v25.message.ACK) {
                ca.uhn.hl7v2.model.v25.message.ACK mod = (ca.uhn.hl7v2.model.v25.message.ACK) ack;
                mod.getMSH().getSendingApplication().getNamespaceID().setValue(APPNAME);
                mod.getMSH().getSendingFacility().getNamespaceID().setValue(APPNAME);
                ackMessage = mod.encode();
            } else if (ack instanceof ca.uhn.hl7v2.model.v251.message.ACK) {
                ca.uhn.hl7v2.model.v251.message.ACK mod = (ca.uhn.hl7v2.model.v251.message.ACK) ack;
                mod.getMSH().getSendingApplication().getNamespaceID().setValue(APPNAME);
                mod.getMSH().getSendingFacility().getNamespaceID().setValue(APPNAME);
                ackMessage = mod.encode();
            } else if (ack instanceof ca.uhn.hl7v2.model.v26.message.ACK) {
                ca.uhn.hl7v2.model.v26.message.ACK mod = (ca.uhn.hl7v2.model.v26.message.ACK) ack;
                mod.getMSH().getSendingApplication().getNamespaceID().setValue(APPNAME);
                mod.getMSH().getSendingFacility().getNamespaceID().setValue(APPNAME);
                ackMessage = mod.encode();
            } else {
                logError("This job entry does not support the HL7 dialect used. Found ACK class: " + ack.getClass().getName());
            }
            Transportable transportable = new TransportableImpl(ackMessage);
            transport.doSend(transportable);
        }
        // All went well..
        // 
        result.setNrErrors(0);
        result.setResult(true);
    } catch (Exception e) {
        log.logError(BaseMessages.getString(PKG, "HL7MLLPInput.Exception.UnexpectedError"), e);
        result.setNrErrors(1);
        result.setResult(false);
    }
    return result;
}
Also used : Message(ca.uhn.hl7v2.model.Message) Result(org.pentaho.di.core.Result) MLLPSocketCacheEntry(org.pentaho.di.trans.steps.hl7input.common.MLLPSocketCacheEntry) Transportable(ca.uhn.hl7v2.protocol.Transportable) TransportableImpl(ca.uhn.hl7v2.protocol.impl.TransportableImpl) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) Parser(ca.uhn.hl7v2.parser.Parser) GenericParser(ca.uhn.hl7v2.parser.GenericParser) GenericParser(ca.uhn.hl7v2.parser.GenericParser) ValidationContext(ca.uhn.hl7v2.validation.ValidationContext) MLLPTransport(ca.uhn.hl7v2.protocol.impl.MLLPTransport) NoValidation(ca.uhn.hl7v2.validation.impl.NoValidation)

Example 4 with ACK

use of ca.uhn.hl7v2.model.v24.message.ACK in project streamsx.health by IBMStreams.

the class HapiMessageHandler method processMessage.

@Override
public Message processMessage(Message theMessage, Map<String, Object> arg1) throws ReceivingApplicationException, HL7Exception {
    server.messageArrived(theMessage);
    Message ack;
    try {
        // Always use the default parser to generate an ack
        // HAPI seems to get into trouble if the ADT_AXX superstructure
        // is used.  
        // Internally, when it tries to generate an ack message
        // the super structure setting in the model class factory causes the ADT_AXX message
        // to get created instead of the ACK getting created.  This is to override the model
        // class factory so that the proper class can be generated.
        theMessage.setParser(ackParser);
        ack = theMessage.generateACK();
        return ack;
    } catch (IOException e) {
        TRACE.log(TraceLevel.ERROR, "Unable to generate ack message", e);
    }
    return theMessage;
}
Also used : Message(ca.uhn.hl7v2.model.Message) IOException(java.io.IOException)

Example 5 with ACK

use of ca.uhn.hl7v2.model.v24.message.ACK in project camel by apache.

the class AckExpressionTest method testNakExpressionWithoutException.

@Test
public void testNakExpressionWithoutException() throws Exception {
    ADT_A01 a01 = createADT01Message();
    ACK ack = template.requestBody("direct:test5", a01, ACK.class);
    assertEquals("AR", ack.getMSA().getAcknowledgementCode().getValue());
    assertEquals(a01.getMSH().getMessageControlID().getValue(), ack.getMSA().getMessageControlID().getValue());
    assertEquals(String.valueOf(ErrorCode.DATA_TYPE_ERROR.getCode()), ack.getERR().getErrorCodeAndLocation(0).getCodeIdentifyingError().getIdentifier().getValue());
    assertEquals("Problem!", ack.getERR().getErrorCodeAndLocation(0).getCodeIdentifyingError().getAlternateText().getValue());
}
Also used : ACK(ca.uhn.hl7v2.model.v24.message.ACK) ADT_A01(ca.uhn.hl7v2.model.v24.message.ADT_A01) Test(org.junit.Test)

Aggregations

ACK (ca.uhn.hl7v2.model.v24.message.ACK)5 ADT_A01 (ca.uhn.hl7v2.model.v24.message.ADT_A01)5 Test (org.junit.Test)5 Message (ca.uhn.hl7v2.model.Message)2 GenericParser (ca.uhn.hl7v2.parser.GenericParser)1 Parser (ca.uhn.hl7v2.parser.Parser)1 Transportable (ca.uhn.hl7v2.protocol.Transportable)1 MLLPTransport (ca.uhn.hl7v2.protocol.impl.MLLPTransport)1 TransportableImpl (ca.uhn.hl7v2.protocol.impl.TransportableImpl)1 ValidationContext (ca.uhn.hl7v2.validation.ValidationContext)1 NoValidation (ca.uhn.hl7v2.validation.impl.NoValidation)1 IOException (java.io.IOException)1 Result (org.pentaho.di.core.Result)1 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)1 MLLPSocketCacheEntry (org.pentaho.di.trans.steps.hl7input.common.MLLPSocketCacheEntry)1