Single Field multiple components to create new segments.

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Single Field multiple components to create new segments.

  • Creator
    Topic
  • #49518
    John Hamilton
    Participant

    I have a source order message that has OBR 13 set to a string of codes separated by comas.  What I need to do is for each of the codes is create a new DG1 segment

    Example

    MSH

    ..

    OBR ||||||||789.00,790,11,791.22|||||

    NTE

    NTE

    I need to convert this too.

    MSH

    .

    .

    OBR ||||||||||||||||

    DG1|1||789.00

    DG1|2||790.11

    DG1|3||791.22

    I know I can do this in a tcl procedure. But I would like to do this within the translation.

    Can it be done?  I have tried several different things with the iteration. Each  time I have met with no success.

Viewing 11 reply threads
  • Author
    Replies
    • #62282
      Jim Kosloskey
      Participant

      John,

      I am assuming the repetition separator is not a comma.

      In that case, you will need some Tcl to at least split the field into it’s components.

      Shame on the sending system for not delineating repeating fields properly.

      If they had – i.e OBR ||||||||789.00~790,11~791.22||||| then you would simply iterate on the field.

      You could also have a pre Xlate (in the route) Tcl proc to replace the commas in that field with the appropriate repetition separator.

      But it might be worth a try to gt the source system to build the field correctly and then use field iteration.

      Jim Kosloskey

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

    • #62283
      John Hamilton
      Participant

      After trying all kinds of different things. The only way I could solve this is with a pre-xlate tcl proc to replace all the , with ~ in the source message then iterate over that field.

      It is just a shame there is no way in a xlate to acomplish such a thing with out using TCL.  Or at least iterate over some destination field.

    • #62284
      Jim Kosloskey
      Participant

      John,

      I repectfully disagree.

      The toolset is following the standard the sending system is not.

      That is why we have standards.

      The sending system authors need to be shamed into complying with the standard.

      Well that’s my .02 anyway.

      Jim Kosloskey

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

    • #62285
      John Hamilton
      Participant

      😀  Can we agree to disagree.

      I know and understand that vendors should always follow the standards.

      But I look at cloverleaf as a tool to integrate system.

      The more complete the tool is to allow me to get to the end result the better.

      I really wish I could force all vendors to comply. But I can

    • #62286
      Robert Kersemakers
      Participant

      Hi John,

      This can be done within the Xlate without a pre-tcl proc. I’ll try to explain:

      * Split the field into its separate values and put these values in a list (@values). Also put the number of values into @number_values.

      * Initialize $%s9 to zero. This acts as a counter and will be used to fill the correct DG1 segment.

      * Iterate over list %l9 with basis {0 1}

         * IF $%s9 < @number_values        * Make a new DG1 segment where %s9 is the segmentnumber; use $%s9 as index to get the correct value from @values.        * increase $%s9        * set $%l9 to zero, so that the iterate continues    * ELSE        * set $%l9 to one, so that the iterate stops I hope you get my drift. I use this kind of DO-WHILE a lot when I have to iterate over a dynamic list.

      Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

    • #62287
      John Hamilton
      Participant

      This is awesome.

      I really like new thoughts and approaches.

      In case anyone else looks at this and decide they want the same thing.

      Here is an example of the code I have that did this with.

      So Jim it can be done, with minimal tcl.  This just proves with this engine your imagination is the only boundary.

    • #62288
      Jim Kosloskey
      Participant

      John,

      I found Robert’s solution very intriguing as well.

      I never fail to learn something new via Clovertech each day it seems. That is what makes this service so great.

      I knew some Tcl would be required, the unusual use of the list iteration is something I will definitely add to my knowledge base and is the missing piece in this challenge. Thanks Robert.

      I will also try to remember to refer to this during the BOF (Birds Of Feather) meeting I hope to have at the upcoming User Conference wherein we can discuss our collective knowledge of the ins and outs of Xlates.

      Jim Kosloskey

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

    • #62289
      Robert Kersemakers
      Participant

      I’m glad you all like my little solution!

      I still hope it will once be possible to iterate directly over a dynamic list, in this case that would be:

       ITERATE OVER %l9 BASIS @values

      But this DO-WHILE will do the trick for now…

      Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

    • #62290
      Jim Kosloskey
      Participant

      Robert,

      Yes that has been on the request list for some time.

      It will be most welcome when it finally occurs.

      Thanks again,

      Jim Kosloskey

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

    • #62291
      Daniel Lee
      Participant

      We’re on 5.8.4.  Do you know if Cloverleaf made a change somewhere along the way to make this solution no longer work?  I attempted to do this and the Xlate will not allow me to change a list variable.  I iterate over %l9 with a basis {0 1}, then later try to set $%l9 to 0 and then try to echo it right away from the Xlate and it’s still {0 1}.  I’ve tried every way I can think to change %l9 and can not affect it.  It allows me to change %s9 just fine, but not %l9.

      I did find another solution to my problem but am just currious in case I need to use this later.

    • #62292
      John Hamilton
      Participant

      I am on 5.8.4 now as well. I am still using this for several things. So no I don’t think anything has changed to stop this from working. God help me if they every do.

    • #62293
      James Cobane
      Participant

      I know some people have identified some anomalies with the list iteration variable and processing it.  See this post:

      http://clovertech.infor.com/viewtopic.php?t=5835&start=0&postdays=0&postorder=asc&highlight=list+iteration

      Jim Cobane

      Henry Ford Health

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

Forum Statistics

Registered Users
5,126
Forums
28
Topics
9,296
Replies
34,439
Topic Tags
287
Empty Topic Tags
10