TCL or XLATE Complex situation?

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCL or XLATE Complex situation?

  • Creator
    Topic
  • #53908
    Femina Jaffer
    Participant

      Hello Folks,

      I do not have it easy here lately….LOL!  I could use some help or tips with the following inbound message and situation: –Is this even doable?

      ORC|RE|13-1433-A|DPP-13-000029||||||201308291420|PK||18302C^Purcell^Carol^^^^PAC

      OBR|1|13-1433-A|DPP-13-000029|DERMP^Surgical Procedure|||201308260000|||||||201308261328|LEFT RING FINGER~LEFT LEG~RIGHT TEMPLE|18302C^Purcell^Carol^^^^PAC||||||201308291420|||F|||||||^PATHOLOGIST^TEST^^^^

      OBX|1|FT|REPORT|1|CASE: DPP-13-000029||||||F|||201308291404

      OBX|2|FT|REPORT|2|PATIENT: DAFFY DUCK||||||F|||201308291404

      OBX|3|FT|REPORT|3|||||||F|||201308291404

      OBX|4|FT|REPORT|4|SPECIMENS SUBMITTED:||||||F|||201308291404

      OBX|5|FT|REPORT|5|A. LEFT RING FINGER||||||F|||201308291404

      OBX|6|FT|REPORT|6|B. LEFT LEG||||||F|||201308291404

      OBX|7|FT|REPORT|7|C. RIGHT TEMPLE||||||F|||201308291404

      OBX|8|FT|REPORT|8|||||||F|||201308291404

      OBX|9|FT|REPORT|9|||||||F|||201308291404

      OBX|10|FT|REPORT|10|DIAGNOSIS:   TEST CASE.  DO NOT DISTRIBUTE.||||||F|||201308291404

      OBX|11|FT|REPORT|11|A.   SKIN, LEFT RING FINGER; PUNCH BIOPSY:||||||F|||201308291404

      OBX|12|FT|REPORT|12|     –    COMPOUND MELANOCYTIC NEVUS||||||F|||201308291404

      OBX|13|FT|REPORT|13|B.   SKIN, LEFT LEG; SHAVE BIOPSY:||||||F|||201308291404

      WHEN you see SPECIMENS SUBMITTED in an OBX segment, I need to count the subsequent OBX segments where OBX 5 has values such as A.LEFT, B.LEFT etc.   For each of these I need to create an OBR segment followed by the entire message as it is, after the OBR.

      The OBR would look like this

    Viewing 11 reply threads
    • Author
      Replies
      • #79483

        That seems very doable, but I would do it in a tcl proc probably where you have more flexibility.

        -- Max Drown (Infor)

      • #79484
        Femina Jaffer
        Participant

          Thanks Max.  Can you give me an idea on how I can approach this?

        • #79485
          Jim Kosloskey
          Participant

            Femina,

            I believe this is accomplishable in an Xlate.

            You would need to use your own counters. Probably one for the outbound ORC/OBR group and one for the outbound OBX group/

            There might be some Tcl involved inside the Xlate using an Xlate solution but I don’t see that based on your description.

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

          • #79486
            Brandon Grudt
            Participant

              Are you familiar enough with tcl to translate from plain text?

              Use a variable set to 0 as a counter, then run a foreach on the segments.  Split the segment into fields, find the field you want, set a variable with the data from that field, then run a search in an if statement to see if it contains that sequence of characters.  If true, increase your variable.  You can do this independently for each string, if needed.

              It looks like you’ll also need to grab the patient name from in the message, as well as a couple of other pieces of data.  That shouldn’t be too tricky.

              I don’t quite see where you are looking to put those values in the OBR segment, but you would simply free write out the entire segment to a variable, using your variables in the string of text.  A basic example:

              set topOBR “OBR|RE|13-433|DPP-$aleft|$procedure|||$date||||” (and so on)

              Then you just need to add that topOBR variable to your list of segments at position 0.  It could take some time but Google is your friend.  Just start your search with “tcl”

              “tcl get value of list item”

              “tcl insert variable into list”

              “tcl counter variable”

              I hope this helps.  The testing tool and the echo command are your best friends in something like this.

            • #79487
              Femina Jaffer
              Participant

                Thank you.  I will give this some thought.  Brandon,  thanks for the tcl approach too, I am somewhat  familiar tcl.

                thank again, all. This is a tough one.

              • #79488
                Femina Jaffer
                Participant

                  Still having no luck with either tcl or xlate.  Not sure how to find segments between other segments.  For example, if OBX 5 has “specimen —” and next segment obx 5 is not blank then I need to pull that value and put it in a variable.  I do this until I come to an obx segment that has OBX 5 as blank.  ?

                  Thanks..

                  fj

                • #79489
                  Jim Kosloskey
                  Participant

                    Femina,

                    In an Xlate I would think you would ITERATE through the OBX Group then with an IF once you detect OBX-5 with the value ‘SPECIMENS SUBMITTED’ set a switch (use a temp variable) also set something to the value of the repetition counter of which OBX repetition this was located.

                    That switch indicates that this set of OBX repetitions has the value. The counter value saved off tells you after which you need to start building OBR group, etc.

                    After that ITERATE add an IF to check to see if the switch from the first ITERATE was thrown. Inside the IF add another OBX Group ITERATE. This one will be used to build the OBR, etc.

                    Inside the second ITERATE you will check its Iteration counter value against the value stored off in the first ITERATE which indicates where the ‘SPECIMENS SUBMITTED’ was found. IF the current counter is greater than the saved off value then check OBX-5 for eq @null. If it is not eq @null build your OBR then ITERATE again over the OBX group adding all of those OBX etc. to the new outbound.

                    Of course you will need some of your own counters for the outbound OBR and OBX groups.

                    Rememember in tha Xlate you can ITERATE over anything as many times as you need. Just try to use different Iteration Counters for each ITERATE – I would not recommend re-using counters.

                    That should give you an outline of how to do this but there is still some detail to be worked out.

                    For example if you can also have OBX sets which do NOT have this requirement then you will need to add logic to determine which set you are working with.

                    In the past when I have had Result messages with mixed content and the sending system is essentially sending reports I usually create an Xlate for each set (let’s say there are 2). Then either using a TrxID proc or filtering, I separate the messages at routing into the 2 camps and associate the appropriate Xlate with the message.

                    Although that means maintaining 2 Xlates it does mean neither is as complicated as trying to do both sets of logic in one Xlate.

                    I have done it in the combined Xlate as well.

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

                  • #79490
                    Gene Salay
                    Participant

                      Femina,

                      I think Jim has an interesting idea.     Try to find out if it would be ok to send a complete separate message for each of those OBRs you would build.

                      If yes, build a separate route for each possibility (A., B., C., D….), and have the translate in that route just make the needed adjustments specific to that route to the original OBR.

                    • #79491
                      Femina Jaffer
                      Participant

                        That is not a bad idea.  I will bring this up in one of our meetings.  My only concern is that the OBX 4 or NTE can have many possibilities…for ecample., A. leg, B. ARM, Q.Wrist.  HOw can you have a trx id set for the different possiblilites and then create a separate OBR for each?

                        Thanks,

                        Femina

                      • #79492
                        Steve Stepp
                        Participant

                          Jim,

                          I am trying to use the technique to add an OBX segment (as the first OBX) when certain conditions are met. But I’m having issues with the variables I think. I’ve always used a percent sign for iteration variables (i.e. %group1 ) and an @ symbol for regular variables (i.e. @obxcntr). I appear to be getting errors when trying to use the @ var in a path.

                          I also tried to make my variables using the percent instead but that didn’t work either.

                          I’ve included an image with a screenshot from the Xlate.

                        • #79493
                          Jim Kosloskey
                          Participant

                            Steve,

                            You cannot use anything but a % variable or a number in the address path.

                            when you use a temp variable (@whatever) it is converteed to zero (0).

                            But you can have your own % variable (like %g99) which you have to manage (increment/decrement, etc.).

                            Feel free to email me if you need more assistance.

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

                          • #79494
                            Steve Stepp
                            Participant

                              I both emailed and spoke to Jim on the phone and he gave some additional tips that I though I’d share, just in case someone else finds this thread interesting.

                              I didn’t read the documentation close enough on ITERATE.

                              Excerpt: “All variables must start with % and be either f (field), g (group), l (list), or s (segment). If there is more than one variable, use, for example %f1, %f2, and so on.” I wasn’t using one of those four single letters and a number. That was one issues (of several).

                              Another tip, unless the % variable is used in an actual address path (such as “1(0).1(%g1).1(%g99).OBX(0).#5(0)” ) you likely need to preface it with a dollar sign ($) so that TCL will interpret it correctly as a variable. This got me in an IF statement, MATH statement, and COPY statement.

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