Help Removing a sub_field

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Help Removing a sub_field

  • Creator
    Topic
  • #54929
    Sebastien Bazile
    Participant

      I need help removing a sub_field in a ORM_001 Message. The client can’t handle this: “^^^Home” in the message. It’s failing. Please help.

      PID|||I100000000^^^Home||MMMMM^TTTTTT^O||19421222|M||||||||||V00000000000||||||||||||

      thanks[/u][/b]

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

          If in an Xlate just copy the components (sub-field in your parlance) you want using component notation in your COPY –

          COPY …PID()0.#5(0).[0] –> …PID()0.#5(0).[0]

          The [0] points to the first component if you wanted the second component then [1].

          I think you can also do multiples inside the [] like [0,1,2] and maybe even [0-3] but you will eed to test that.

          So you aren’t geetting rid you are onlly COPYing what you want.

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

        • #83487
          Sebastien Bazile
          Participant

            I tried that but only getting the MSH header.

          • #83488
            Charlie Bursell
            Participant

              No reason you should get just MSH if you follow Jim’s instructions

              Perhaps it was:

              COPY …PID()0.#5(0).[0] –> …PID()0.#5(0).[0]

              Which I am sure, Jim being dyslectic like me; he meant:

              COPY …PID(0).#5(0).[0] –> …PID(0).#5(0).[0]

              If you are doing a BULKCOPY first then do it like this:

              PATHCOPY @null -> PID.#5

              COPY PID.#5.[0] –>  PID.#5

              Note you can leave off the (0) since that is the default

              The PATHCOPY will clear the entire PID.5 field in case of more subfields and the COPY will just put what you want back in

            • #83489
              Sebastien Bazile
              Participant

                I am still getting just the MSH SEGMENT. There might be something wrong with the late tool itself. I don’t know. Is there a way I can do this in TCL?

              • #83490
                Charlie Bursell
                Participant

                  My bet is you have a test file that either has LF at the end of each segment or you are on Windows and Microsoft is trying to be your friend.

                  Certainly you can do this in Tcl but, as Jim said, if you are using an Xlate for this route why do it in Tcl?

                  Tcl

                  run {

                             # Message handle

                             keylget args MSGID mh

                             # Get msg and split into a list of segs

                             set msg [msgget $mh]

                             set segList [split $msg r]

                             # Get field and subfield separator characters

                              set fldSep [string index $msg 3]

                              set subSep [string index $msg 4]

                              # Location of PID

                              set pidLoc [lsearch -regexp $segList {^PID}]

                             

                              # get and split PID into fields

                              set PID [split [lindex $segList $pidLoc] $fldSep]

                              # Get and split field 5

                              set fld5 [split [lindex $PID 5] $subSep]

                              # Get just first subfield

                              set first [lindex $fld5 0]

                              # Replace field 5 with just first subfield

                              set PID [lreplace $PID 5 5 $first]

                              # Join PID and put back in segment list

                              set segList [lreplace $segList $pidLoc $pidLoc [join $PID $fldSep]]

                               

                              # New message

                              msgset $mh [join $segList r]

                              # send it on

                              return “{CONTINUE $mh}”

                  }

                • #83491
                  Sebastien Bazile
                  Participant

                    Thank you Jim and Charlie. Charlie, you were right, it was the file I was using. It now works perfectly. Thank you so much gentlemen.

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