Announcement

Collapse
No announcement yet.

HL7 Response from RESTful endpoint

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HL7 Response from RESTful endpoint

    Hi All,
    I hope everyone is staying safe and healthy out there. I am looking for some help with the following. I have an HL7 source where I convert to a JSON message for a restful endpoint. I need the response to come from the destination so nothing "queues" in mirth(treating it as sort of a black box). I have read some other threads about this but am not sure where to begin. I assume the easiest way to accomplish this is to build my HL7 response in the response transformer of the destination based on what I get back from the endpoint. I am starting first with the error handling which I have attached. Ideally I would like to send back a standard "AE","AA", or "AR" ack based on the endpoint response for example with the attached I would send something like...

    MSA|AE|Unsupported Media Type|"Ctrl ID"

    any help would be greatly appreciated. Thanks!
    Attached Files

  • #2
    Can you maybe explain this differently?

    I don't understand your flow.

    Are you asking:

    Inbound HL7 (source tab) -> http sender (destination tab) -> if http sender response OK, build ACK and reply back (in destination tab response transformer) to the thing that sent the hl7 message?
    Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
    Diridium Technologies, Inc.
    https://diridium.com

    Comment


    • #3
      Yes so for example..

      LIS sends an HL7 to the inbound source(Mirth)^Mirth Transforms to JSON^JSON sent to Destination(REST)

      I want the RESTful destination to tell the LIS who is sending the HL7 message if they got it or not. If not give the error otherwise send back an HL7 AA

      Comment


      • #4
        In that case you build the ACK in the response transformer of the destination (you can use a stubbed message template in there).

        And on the source tab, under "Source Settings" you select the drop down called response and set it to the appropriate destination or the post processor.
        Last edited by pacmano; 03-30-2020, 01:27 PM.
        Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
        Diridium Technologies, Inc.
        https://diridium.com

        Comment


        • #5
          I thought the destination transformer was for altering the message before the destination. I can just build an Ack message in there to send back to the connection sending to the source?

          Do you have any working examples of this?
          Last edited by mrando; 03-30-2020, 01:28 PM.

          Comment


          • #6
            Oops.. fixed that, I mean "response transformer of the destination"
            Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
            Diridium Technologies, Inc.
            https://diridium.com

            Comment


            • #7
              Ahhh That is what I thought! hahaha I was confused for a second there. I figured I had to do that with some javascript with an IF statement looking at the "responsestatus" variable. Do you have any working examples of that?

              Comment


              • #8
                Just me mindful your API post may fail and your response transformer will not fire every time UNLESS it is set to RAW.
                Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
                Diridium Technologies, Inc.
                https://diridium.com

                Comment


                • #9
                  Remember my last note please.

                  A simple example to look at the actual response code. Note that " OK" is not required so check your Mappings tab to see the variable values.

                  Code:
                  if ($('responseStatusLine') == 'HTTP/1.1 200 OK') {
                  	$c('API_Post_OK',true)
                  } else {
                  	$c('API_Post_OK',false)
                  }
                  Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
                  Diridium Technologies, Inc.
                  https://diridium.com

                  Comment


                  • #10
                    I am still getting an error. I can now see the prompt in the logs for "response transformation" but it is empty. I set your example suggestion as one step which is disabled and I tried copying one which I saw elsewhere but cant seem to get either to give me something in the response transformation. I have attached my channel to this message to give a better understanding of what I am trying to accomplish and to see where I may be having issues. Thanks!
                    Attached Files

                    Comment


                    • #11
                      Look in the User API for ACKGenerator. Since you are responding to an HL7 message, you can call those methods to create your response without having to create one from scratch.

                      This returns a string, so set your outbound type on the response transformer to Raw as well as the inbound type.

                      Comment


                      • #12
                        Wow! You're quick. I'll have a look. Thanks for the advice.

                        Comment


                        • #13
                          I may be worse off than I was before. I did find...

                          https://www.mirthcorp.com/community/...ght=custom+ack

                          where I tried adding that code to the response transformer. I tried using the generateAckResponse but it looks like there is an issue with the .getStatus() call. Can I use that in the response transformer? Attached my latest channel. Both templates are set to "RAW" now.
                          Attached Files

                          Comment


                          • #14
                            It may be beneficial to read the Response Transformers section in the user guide. It starts on page 255 in the 3.8 guide.

                            In the response transformer you can get the current status in the "responseStatus" variable. You can also modify it if you need to since the response isn't finalized until your transformer ends.

                            Comment


                            • #15
                              So there is a lot here, here are few things to get you started:
                              1. I suspect wherever you want to post the hl7 message has sample JSON that is expected. That JSON that would normally go in the source tab in the outbound messages template (or of course could go in the destination transformer). Once you have that JSON you can drag drop assignment from the inbound message template and the outbound message template (from the "Message Tree" tab).
                              2. In general you don't need iterators on PID and PV1 segments. In fact - just start with NO iterators until you get the hang of things.
                              3. Your drag / drop substitutions on iterator steps don't need to be there, but note #2
                              4. Your "Send Raw HL7 to JSON" transformer step doesn't make sense to me, are you trying to include the original HL7 message in a JSON field? You can do that by assigning the JSON field to the appropriate template field, e.g. "tmp['hl7'] = connectorMessage.getRawData()"
                              5. Your destination in "content" needs to have something (e.g. "${message.encodedData}") and the content type should match the content (e.g. "application/json").
                              6. Your outbound data type on the first destination response transformer needs to be of type HL7, then insert a sample ACK in the outbound message template and then assign values to that template via drag drop again. For example you need to store the inbound message id on the source side to then put it in the outbound ACK. Use channel map variables for that for example this line stores MSH.10.1 to a variable called this_message_id:
                                Code:
                                $c('this_message_id',msg['MSH']['MSH.10']['MSH.10.1'].toString())
                                on the source side, then on the destination response transformer assign that value back to the outbound message template:
                                Code:
                                  tmp['MSA']['MSA.2']['MSA.2.1'] = $c('this_message_id')


                              A sample ACK you would put in the outbound message template in the response transformer for your first destination:

                              Code:
                              MSH|^~\&|||||19220509202239||ACK^ACK|MSG0000000004|P|2.5
                              MSA|CR|MSG0000000004
                              And what agermano said and he will correct me if I goofed somewhere in there.
                              Last edited by pacmano; 03-31-2020, 02:35 PM.
                              Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
                              Diridium Technologies, Inc.
                              https://diridium.com

                              Comment

                              Working...
                              X