Issue with Parsing and Lists

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Issue with Parsing and Lists

  • Creator
    Topic
  • #55446
    Jon Melin
    Participant

      Hello,

      I am working on an issue that requires me to pull some CPT codes out of a comment field. I know it’s not ideal, but it’s our only option for some sort of solution based on the limitations of the source system messages.

      Here is an example of what I receive in the NTE comments:

      NTE|1|PM_TRANSACTION|6/23/2017 10:23:00

    Viewing 4 reply threads
    • Author
      Replies
      • #85365
        Terry Kellum
        Participant

          Have you tried

          Code:


          set xlateOutVals [split $final ” “]

          Sometimes it’s difficult to determine “list” contexts.

          If cloverleaf interprets it as a scalar, you will see this.

        • #85366
          Keith McLeod
          Participant

            Try removing the list command.

            from:

            set xlateOutVals

              to:

              set xlateOutVals $final

              I believe $final is already a list.

              The list iterate can be trickier if you want a dynamic length list each time.

          • #85367
            James Cobane
            Participant

              Depending on what fields you have listed on the output side of your COPY statement, this will impact your output as well.  When you set xlateOutVals to

                ,  you are putting all the values into one field, so all the values will be put as a single result into whatever field you have specified on the output side of your COPY statement.  If you set xlateOutVals to [split $final] , then you will have multiple values and would need to list multiple fields on the output side of your COPY statement to capture all the values.

                Hope that makes sense.

                Jim Cobane

                Henry Ford Health

            • #85368
              Jon Melin
              Participant

                Perfect. This all helps me see the things I’ve missed. All have been useful for me to figure this out. I appreciate the help thus far from everyone.  

                I do have it now storing into a list and if I add multiple outputs to the xlate like James recommended, I can then grab each one individually by calling the variable I’ve saved them into.

                I’m still not able to retrieve them by list index, so if I enter something like this, with the next index:

                set item [lindex $xlateInVals 1]

                set xlateOutVals $item

                I get a blank. So it’s clearly still thinking it’s in one field it appears. Which reflects what James said. Right now if I know how many to expect inbound it wouldn’t be an issue because I can just create that many variables in my output on my COPY statement and build it from there. So it still seems like even when I’m placing the list into one output variable, I’m not able to grab them by index, but maybe that’s not even the correct way to approach this.

                Essentially my initial thought was to put the whole list into one variable. Check it’s length, knowing how many values there are, and then grab them individually out of the list as I build the PR1 segment. It seems I can do this if I assign a output variable in my COPY to each, but how could I dynamically build the variables in the output COPY field for a varying number? Or rather, should I use hardcoded values in the output COPY, up to a max number (i.e. 5) and just check if they are empty afterward?

                Thank you again.

              • #85369
                Ron Pinter
                Participant

                  Jon

                      Attached is an example Xlate to iterate thru the Temporary variable and create the PR1 segments.

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