HTTP reply Handling

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf HTTP reply Handling

  • Creator
    Topic
  • #55571
    Jason Riddick
    Participant

      Hi,

      I need suggestions on code for our team to handle scenarios with HTTP where we send HL7 messages using HTTP connections using curl(so they have a header). We need to either stop the thread or keep the messages in pending due to non acknowledgments. these may or may not be NAKS but errors/exceptions from the remote connections.  It would be also benefical if possible to Probably wait x amount of time in Minutes before we start the thread and/or try to send again those that are pending

    Viewing 5 reply threads
    • Author
      Replies
      • #85782
        Jim Kosloskey
        Participant

          By NAK are you referring to HL/7 acknowledgment messages returned by the receiving system?

          Then are the non NAKs status of the HTTP Post or another type of message?

          Are you using the HTTP Protocol or is this being done via CAA-WS?

          What release of Cloverleaf and what O/S?

          When I did my one HTTP(s) connection, the status was returned as a result of the HTTP Post. So I could check its value inside the Tcl code I was using.

          In my case all that was required was to log the error and make an entry in the Error Db for auditing purposes since the destination system did not care about resends.

          But at that point you have the opportunity to take whatever action you want.

          The one I did was an X12 integration and so the X12 response needed to be routed back to the sending system if the envelope was not an issue. If the envelope was an issue then that was handled within Cloverleaf via a generalized acknowledgment handling proc we had for any message type.

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #85783
          Jason Riddick
          Participant

            Hi Jim,

            I was being a bit generic in my post because we want the code to handle any text being sent back that is not a valid ACK. We work with multiple sites. For one site it could be NAK or 503 and other site for instance we have seen a error text returned because their side was down.

            The main issue we have assistance  on is we don’t have a method for the thread to either stop or to keep the messages pending and try perhaps to send again in x minutes time. Right now its trying every x seconds

            6.1.2 is our version. We use Unix

            We are sending an HL7 message using HTTP Client Protocol using Curl and we are get ACK messages for successful transmissions.

          • #85784
            Jason Riddick
            Participant

              Talking further we just need to stop the thread not try resending based off some timer.

            • #85785
              Jason Riddick
              Participant

                Hi all,

                Any suggestions on my previous posts. Let me know if I was not clear as this is my first post.

              • #85786
                Eric Fortenberry
                Participant

                  It may be worth trying to use an “error database” or “error count” Alert action to trigger your thread to stop on error.  I don’t have much experience doing this, but it seems like it would be possible.

                • #85787
                  Michael Hertel
                  Participant

                    Here is a script we use for our immunization interface to evaluate ACKs/NAKs.

                    We run two procs in inbound replies.

                    vx_kill_AE_nak  and tps_checkhl7_ack_argv

                    We have checked await replies and set the timeout to 60. (See attachment)

                    The first proc below checks to see if it has received a valid ack or not.

                    If it is a valid NAK, we kill the reply which makes the thread think it hasn’t received a response and retries the same message every 60 seconds until it gets an ACK.

                    Occasionally some NAKs aren’t so bad, so we change them to ACKs and let them process, otherwise if it is a real NAK like “System unavailable” reason, we alert after receiving 5 consecutive NAKs. (The alert will happen every 5 minutes until we receive the ACK or Interface Analyst intervention is taken.

                    Code:


                    ######################################################################
                    # Name: vx_kill_AE_nak
                    # Purpose:
                    # UPoC type: tps
                    # Args: tps keyedlist containing the following keys:
                    #       MODE    run mode (”start”, “run” or “time”)
                    #       MSGID   message handle
                    #       ARGS    user-supplied arguments:
                    #              
                    #
                    # Returns: tps disposition list:
                    #          
                    #

                    proc vx_kill_AE_nak { args } {
                       keylget args MODE mode
                       global HciSite HciConnName AEcnt DuplicateCount ob_save
                       set procname [lindex [info level [info level]] 0]
                       set module “$HciSite/$HciConnName/$procname: ”

                       set dispList {}

                       switch -exact — $mode {
                           start {
                    set AEcnt 0
                    set DuplicateCount 0
                           }

                           run {
                    keylget args MSGID mh

                    set vmenv TEST
                    if {[string equal [string range $HciSite 0 2] vmp]} {
                    set vmenv PROD
                    }

                    set msg [msgget $mh]
                    set outmsg [msgget $ob_save]
                    set outmsgid [vm_getHL7 $outmsg MSH 0 9]
                    set inmsgid [vm_getHL7 $msg MSH 0 9]
                    set response [vm_getHL7 $msg MSA 0 1]
                    set reason [vm_getHL7 $msg MSA 0 3]

                    if {![string equal [string first “E||||next of kin name first is invalid” $msg] -1]} {
                    set response AA
                    set msg [vm_setHL7 $msg $response MSA 0 1]
                    set notifylist “interfaceteam@myhosp.org”
                    exec echo $msgnn$outmsg | mail -s “$module $vmenv – $HciConnName NAK response overridden and skipped” $notifylist
                    msgset $mh $msg
                    }

                    if {[string equal $response AA]} {
                    set AEcnt 0
                    } else {
                    incr AEcnt
                    if {[expr $AEcnt % 5] < 1} {
                    set notifylist "interfaceteam@myhosp"
                    exec echo $msg | mail -s "$module $vmenv – VX $HciConnName NAK response(s) received $AEcnt" $notifylist
                    return "{ERROR $mh}"
                    }
                    echo $module – VX $HciConnName NAK received – NAK Message killedn$msgn
                    return "{KILL $mh}"
                    }
                    lappend dispList "CONTINUE $mh"
                           }

                           time {
                    # Timer-based processing
                    # N.B.: there may or may not be a MSGID key in args
                           }
                           
                           shutdown {
                    # Doing some clean-up work
                           }
                       }

                       return $dispList
                    }

                Viewing 5 reply threads
                • The forum ‘Cloverleaf’ is closed to new topics and replies.