Iteration issue.

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Iteration issue.

  • Creator
    Topic
  • #52174
    Roy Osumi
    Participant

      Hey Folks –

      I am on RedHat Linux 4.0 running CL 5.5.

      I have a repeating field that has 1 field with 3 components. Each doctor can have numerous different doctor numbers with a unique ID.  The problem is that there is no unique delimiter between each set of doctor numbers.

      ex) 10^name1^IDa~11^name1^IDb~12^name1^IDc~20^name2^IDa~22^name2^IDc~23^name2^IDd~30^name3^IDa~31^name3^IDb~32^name3^IDc~33^name3^IDd~34^name3^IDe

      name1, name2 and name3 are three different doctors.  Name1 has 3 doctor numbers, Name2 has 3 doctor numbers and Name3 has 5 doctor numbers.

      I want to pull out one doctor number per doctor based on this logic:

      copy the number ,name and ID if ID = IDe

      if no IDe then not copy number, name and ID if ID = IDc

      if no IDc then copy number , name and ID = IDa  

      So output for the above example should look like this:

      OBR#28(0).[0] = 10

      OBR#28(0).[1] = name1

      OBR#28(0).[2] = IDa

      OBR#28(1).[0] = 22

      OBR#28(1).[1] = name2

      OBR#28(1).[2] = IDc

      OBR#28(2).[0] = 34

      OBR#28(2).[1] = name3

      OBR#28(2).[2] = IDe

      Any and all help is greatly appreciated.

    Viewing 1 reply thread
    • Author
      Replies
      • #73302
        Robert Kersemakers
        Participant

          Hi Roy,

          This can be a bit complicated, as it uses different ‘techniques’. It also assumes that the name of these doctors is unique, or else you will have weird results.

          I would do something like this:

          * Initialize a list (like COPY @null -> @doctorlist)

          * Use field-iteration to iterate over all the occurrences of the field. You will need to use %fnn (so %f1) as a variable and the basis will be the field with the repetitions.

          * Inside the iteration, loop through (or better: search) @doctorlist for the name of the ‘current’ doctor. If it’s not in the @doctorlist, then append name, number and ID as a list into @doctorlist. If the name is already in the list, check the corresponding ID and, if necessary, replace the found list with this (new) name, number and ID.

          (So @doctorlist will be a list of lists; sounds complicated, but just put in a few echoes and you will see what you are doing)

          * At the end of the loop, you have a list with all the correct names+number+ID. Now you will need to put these values into OBR-28. Follow this link <a href="https://usspvlclovertch2.infor.com/viewtopic.php?t=2213&#8243; class=”bbcode_url”>https://usspvlclovertch2.infor.com/viewtopic.php?t=2213 for an explanation on how to iterate over a dynamic list (in this case your @doctorlist).

          Hope this helps. If not: just ask where you need some more directions.

          Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

        • #73303
          Roy Osumi
          Participant

            Thanks for your help.  I will try and work this on this fix.  Is there a way  use the ID called IDa this is always the first ID and all doctors have one?

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