MLP to Batch

  • Creator
    Topic
  • #47943
    Gene Salay
    Participant

    I would like to convert a charge file in MLP format to a regular batch file to improve processing speed on the destination system (right now my thread sends the messages in the file out individually).    Is there a simple way to do that, or if not, what is syntax for hex chars in tcl so I can split the messages out from the mlp coding?

    Thanks!   I’m on QDX 5.3, AIX

Viewing 6 reply threads
  • Author
    Replies
    • #57121
      Anonymous
      Participant

      Gene,

      I’m going to simplify to see if I’m on the right track with what you wan to do.  Would this be true?

      You want to replace all the occurances of /x0b with “” and you want to replace all occurances of /x1c followed by /x0d with /x0a.

      You could do that in a TCL proc using ‘regsub’.  But there’s probably a lot more to designing what you want.  Do you want to do it in the engine or would a little script that you run by hand outside the engine be fine?

    • #57122
      Gene Salay
      Participant

      Hi Greg,

      Thanks for your response.   Sounds good so far, but there’s

      x0d x1c x0d x0b before each MSH (except for the first)

      So I need to replace that whole string with one xa I’m thinking.

      Would this work?:

      set text “x0d x1c x0d x0b”

      regsub -all {$text} $file {x0a} newfile

      … and then I can build the FHS,BHS,BTS,FTS and sandwich it.

      BTW, you used /… is that what I should use instead of here?

      Thanks!

    • #57123
      Charlie Bursell
      Participant

      Won’t work Gene.  First of all Tcl will not evaluate the variable inside the curly braces so {$text} becomes literally $text.

      Out of the string “x0d x1c x0d x0b “, you only wnat to get rid of “x1c x0d x0b “.  The first x0d is the termination character for the last segment of the previous message.  You need to keep it.

      Also there will be “x1cx0d” at the end of the last message but no “x0b” and there is a “x0b” before the first message without the other stuff.

      I would do it in two steps

      Try this:

      # Get rid of all x1c and x0b

      regsub -all — {[x1cx0b]} $msg {} msg

      # Replace two carriage returns with carriage return line feed

      regsub -all — {rr} $msg “rn” msg

      Note the rn replacement string is *NOT* inside curly braces since it must be evaluated as a carriage return and newline by Tcl

      Good luck with it

    • #57124
      Gene Salay
      Participant

      Thanks  Charlie, that was a great help!!

      I wrote the script to make those changes, and to add the headers and trailers.

      Now I’m wondering about the leading MSH… Our existing batcch interfaces use a ‘tps_pre_HL7_batch’ script in TPS Inbound Data to add an MSH on the front of the message for its trip through the engine.

      Since my message is already in the engine when I’m putting FHS BHS on the front, do I need to worry about that?

      Thanks!

    • #57125
      Charlie Bursell
      Participant

      I wouldn’t think so, not if the MSH is already there

    • #57126
      Gene Salay
      Participant

      Here’s what I have (and let me say Thanks in adv up here since the bottom is way down!!):

      My inbound thread is running the upoc protocol with a read TPS of get_FTP.

      My TSP Inbound Data field has three procs:

      tps_batch_envelope_ORMIS_chgs

      tps_pre_HL7_batch

      raw_hl7_ack  (probably don’t need this, I’m thinking)

      The first one, tps_batch_envelope_ORMIS_chgs (listed below) should be replacing the characters we discussed, and putting on the batch and file headers and footers.  It does appear to be replacing the characters and putting on the footers, but the FHS and BHS from this proc aren’t there, and neither is the MSH from tps_pre_HL7_batch.

      Also curious:

      1. other batches I’ve reviewed have x0a between every segment and message – no x0ds.

      2. in tps_pre_HL7_batch, why the “^” in these lines:

                 set fhs [lsearch -regexp $msgs “^FHS”]

                 set msh_loc [lsearch -regexp $msgs “^MSH”]

      Here’s the batch envelope proc:

      run {

                 # ‘run’ mode always has a MSGID; fetch and process it

                      keylget args MSGID mh

                      set msg [msgget $mh]

                 # Get rid of all x1c and x0b

            regsub -all — {[x1cx0b]} $msg {} msg

                 # Build envelope

            set fhs “FHS|^~\&|||||||||r”

            set bhs “BHS|^~\&|||||||||r”

            set bts “BTS|||r”

            set fts “FTS|1rn”

                 # Build batch

            append newmsg1 $fhs $bhs $msg $bts $fts

                 #Replace two carriage returns with carriage return line feed

                 #Doing now because adding BHSr on front may result in rr again.

            regsub -all — {rr} $newmsg1 “rn” newmsg2

                 # Pile it back on the train

            msgset $mh $newmsg2

                 # Wash hands

                  lappend dispList “CONTINUE $mh”

           

                 }

    • #57127
      Charlie Bursell
      Participant

      Gene:

      You are getting *WAY* too deep into this.  You need more help than I can provide on Clovertech.

      To answer some of your questions:

      No, you do not need the raw_hl7_ack  .  Pretty hard to send ACK via FTP.

      The “^” in an lsearch  -regexe command i part of the regular expression we are searching for.  It constrains the search to the beginning of the string.  For eaxample ^MSH says I only want string that *START* with MSH.

      You don’t need to escape all of those pipes when building the FTS, etc.  You could simply do something like:

              set fhs “FHS|^~\&|||||||||r”

      Note that only the backslash itself is escaped

      I hope this helps

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

Forum Statistics

Registered Users
5,127
Forums
28
Topics
9,299
Replies
34,443
Topic Tags
288
Empty Topic Tags
10