Need assitance adding an extra segment to message

Clovertech Forums Cloverleaf Need assitance adding an extra segment to message

Tagged: 

  • Creator
    Topic
  • #113132
    b murphy
    Participant

      I have a xlate that is taking the field segments from ODS 4 and creating a new ODS segment for each, and writing the appropriate field data to ODS 3 in each segment.

       

      Pre xlate:

      0000000657MSH|^~\&||OGH|||201909181457||ORM^O01|728986|D|2.4|||AL|NE|
      PID|1||H000000906^^^^MR~156-23-4569^^^^SS~H902^^^^PI||CBORD^TEST8^^^^^L||19201025|F||CA||||||||E00002224|
      PV1|1|I|^^^MD|IN||MEDICARE|||||||||||||||||||OGH||ADM|||201909111436|
      AL1|1|FA|MUSHROON^Mushroom|SV||20190918|
      AL1|2|FA|WALNUT^Walnut|SV||20190918|
      ORC|CA|DIET20190918-0001OGH|||X|N|||201909181457|JHARRIS|
      OBR|1|DIET20190918-0001OGH||DIET^REG||||||||||||^^^MD|||||||||||^^^20190918D|
      ODS|D||57^REG^Regular  Diet|OEDIETFD^20190918~OEDIETFT^1457~U.DTMOD02^CCD1800~U.DTMOD02^HH/Cardiac|

       

      Post xlate

      0000000698MSH|^~\&||OGH|||201909181457||ORM^O01|728986|D|2.4|||AL|NE
      PID|1||H000000906^^^^MR~156-23-4569^^^^SS~H902^^^^PI||CBORD^TEST8^^^^^L||19201025|F||CA||||||||E00002224
      PV1|1|I|^^^MD|IN||MEDICARE|||||||||||||||||||OG||AD|||201909111436
      AL1|1|FA|MUSHROON^Mushroom|SV||20190918
      AL1|2|FA|WALNUT^Walnut|SV||20190918
      ORC|CA|DIET20190918-0001OGH|||X|N|||201909181457|JHARRIS
      OBR|1|DIET20190918-0001OGH||DIET^REG||||||||||||^^^MD|||||||||||^^^20190918D
      ODS|D||20190918^REG^Regular  Diet|OEDIETFD^20190918~OEDIETFT^1457~U.DTMOD02^CCD1800~U.DTMOD02^HH/Cardiac
      ODS|D||1457
      ODS|D||CCD1800
      ODS|D||HH/Cardiac

       

      I need to add another ODS segment and place OBR 4 into the additional ODS segment. I am unable to reference my %f1 field variable outside of the ODS 4 iteration. I have tried a few different ideas using tcl in the xlate to no avail. I am unable to reference the variables in the xlate when using tcl.

       

      Any suggestions?

      Thank you

      Attachments:
      You must be logged in to view attached files.
    Viewing 4 reply threads
    • Author
      Replies
      • #113134
        Jim Kosloskey
        Participant

          You will need your own %g variable (like %g99) for adding that ODS (I am assuming at the end of the ODS set).

          You can reference ITERATE Variables directly by prepending a $ like this $%g99 (that will allow you to see the value in Tcl as well).

          Feel free to email me if you would like to work through this together.

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

        • #113149
          b murphy
          Participant

            The issue I seem to be running into is that once i leave the iterate I am unable to reference the iterate variable – the value seems to start back at 0 our side of the iteration.

             

            If I could somehow assign it to a variable that I can reference outside of the iterate…

          • #113150
            Jim Kosloskey
            Participant

              OK do this:

              At the beginning of your Xlate –

              COPY =0 to $%g99   <– that initializes your ITERATE Variable (%g99).

              Inside your ITERATE (the last thing you do) –

              COPY $%f1 to $%g99 <– this will make %g99 match the value of %f1 so when all of the iterations have been exhausted %g99 will equal the last value of %f1.

              After the ITERATE is done –

              MATH ADD =1 and $%g99 to $%g99  <– now your variable will be one greater than the last normal repetition of the ODS.

              Then –

              COPY …OBR.#4 to …ODS whatever field you want using %g99 (no $) in the proper address position for the ODS repetition (where you used %f1 inside the ITERATE.

              If you are still struggling, email me.

               

              • This reply was modified 5 years, 2 months ago by Jim Kosloskey.

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

            • #113152
              Robert Kersemakers
              Participant

                I agree with Jim’s solution, especially if you need to add several segments.

                 

                However: if you only need to add 1 segment and it always needs to be the last segment, there is a quick and dirty method. Just use a large number as the segmentnumber, say ‘999’, assuming you will not have more than 999 ODS segments in your message. You will get  something like this:

                COPY 2(0.).1(0).0(0).OBR.#4 ->2(0.).1(0).0(0).ODS(999).#1

                This should work as well.

                Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

                • #113158
                  Jim Kosloskey
                  Participant

                    One caveat Robert,

                    I believe if any field in the ODS segment is required one will get empty intervening segments between the last real ODS segment and the high-water added segment.

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

                • #113153
                  b murphy
                  Participant

                    Both solutions work. I went with the non-dirty method. Thank you much for the assistance on getting the iteration counter outside the iteration.

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