Send JSON payload segment from TCL script Xlate

Homepage Clovertech Forums Cloverleaf Send JSON payload segment from TCL script Xlate

  • Creator
    Topic
  • #120470
    Syed Ahmed
    Participant

    Hello there, I’m new to Cloverlear. A payload is being transferred from the web to a process. We must apply some business logic to that payload in order to extract a payload segment. I’ve written a TCL script to handle the JSON body. Now I’d like to use Xlate to convert the extracted body to HL7. We’ve already used Xlate to perform the transformation, and I’ve set it up to run the TCL script as a pre-process. However, I am unsure how to send this extracted JSON payload from TCL to Xlate.

    Could you please suggest a method?

Viewing 6 reply threads
  • Author
    Replies
    • #120471
      Jim Kosloskey
      Participant

      I would think you would have set up a route definition. I have never done JSON but I would think that something as simple as a raw route would suffice.

      In the Route Details then you would specify your proc (Inbound TPS is an alternative UPoC to pre-Xlate) and the Xlate to be used along with destination information, etc.

      I am unsure as to your level of training in Cloverleaf but if you have had at least Level 1 you should be familiar with some of the NetConfig Routing.

       

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

      • #120472
        Syed Ahmed
        Participant

        Thank you very much, Jim. I configured the routes in NetConfig. The issue is that Xlate receives the entire payload, whereas I require a modified payload from the TCL script. Is there anything I need to do in TCL to send the extracted payload?

        I received very basic training to cover the fundamentals of NetConfig setup

    • #120473
      Jim Kosloskey
      Participant

      Oh I see – well in your proc you need to CONTINUE a message which is just the payload.

      You really should have level 2 training to do this.

      Maybe the best thing to do is to share the Tcl and see what can be suggested.

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

      • #120474
        Syed Ahmed
        Participant

        Jim, here is my TCL script.

        I extract the $signer from the original payload. Now, I want to pass the $signer to Xlate. If I understand correctly, do I need to ‘lappend dispList “CONTINUE $signer”‘ instead of ‘lappend dispList “CONTINUE $mh”‘ at the end of the script?

        proc tps_signer_patient_index { args } {
        global HciConnName HciRoot
        global signer_index
        package require base64
        package require json
        keylget args MODE mode
        set ctx “” ; keylget args CONTEXT ctx
        set module “tps_signer_patient_index/$HciConnName/$ctx”
        set uargs {} ; keylget args ARGS uargs
        set debug 0
        catch {keylget uargs DEBUG debug}
        set dispList {}

        switch -exact — $mode {
        start {}

        run {
        keylget args MSGID mh

        set msg [msgget $mh]
        set jfields [::json::json2dict $msg]
        #puts $jfields
        set data [dict get $jfields data]
        set envelopeSummary [dict get $data envelopeSummary]
        set envelopeDocuments [dict get $envelopeSummary envelopeDocuments]
        set recipients [dict get $envelopeSummary recipients]
        set signers [dict get $recipients signers]
        set signer_index 0
        set admTabFound 0
        foreach signer $signers {
        set tabs [dict get $signer tabs]
        set textTabs [dict get $tabs textTabs]
        foreach textTab $textTabs {
        if {[dict exists $textTab mergeFieldXml]} {
        set mergeFieldXml [dict get $textTab mergeFieldXml]
        if {[string match “<patient>*” $mergeFieldXml]} {
        incr admTabFound
        break
        }
        }
        }
        if {$admTabFound == 1} {
        set xlateOutVals $signer
        break;
        }
        incr signer_index
        }
        lappend dispList “CONTINUE $mh”
        }

        time {}
        shutdown {}
        default {
        error “Unknown mode ‘$mode’ in $module”
        }
        }

        return $dispList
        }

    • #120475
      Jim Kosloskey
      Participant

      Recommendations anyone?

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

    • #120476
      Paul Stein
      Participant

      Appears you modified or extracted the data you wanted in $signer variable and that is what you want to pass on to the xlate?

      If so – you still need to send the new message to the message handle($mh) to be passed on to the disposition list.

      # Replace the message in the message handle

      msgset $mh $signer

      I am not sure what you are doing with this line “set xlateOutVals $signer” however.
      xlate variables are typically used for the inline Tcl portion of the Pre/Post proc dialogue box within the xlate GUI. My guess is that is where you were attempting to send it to the xlate.

      Also – Perhaps you are confusing where to put your tcl proc given the upoc options Jim mentioned. Once you figure out what I suggested above, I would suggest placing this proc under ‘Pre-Procs’ for xlate type via route details.

      • #120477
        Syed Ahmed
        Participant

        Thanks, Paul,

        You can ignore this “set xlateOutVals $signer” line. It was one of my debugging lines.

        Quick question/clarification – “msgset $mh $signer” will send both messages to Xlate. How do I get the $signer data from Xlate?

    • #120478
      Paul Stein
      Participant

      The “msgset $mh $signer” will reset the original message handle to have the data stored in the $signer variable, not append to the original message handle.

      Assuming your have pulled only the data you want to send to your xlate in the $signer variable out of the original $msg variable, that should be the only data being sent to the xlate, not both.

    • #120479
      Syed Ahmed
      Participant

      Thank you very much, guys. It worked!

    • #120480
      Jim Kosloskey
      Participant

      Most of the thanks should go to Paul.

      Syed, you really need to take at least Level 2 Training (Level 3 would be good as well). There is so much more than you have seen.

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

Viewing 6 reply threads
  • You must be logged in to reply to this topic.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,435
Topic Tags
286
Empty Topic Tags
10