Column Headers using vrl field names

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Column Headers using vrl field names

  • Creator
    Topic
  • #55128
    Lisa Heaton
    Participant

      I have the following code:

      # build header from vrl field names

                    VrioLoadData v 837I.vrl

                    set fields [VrioGetFieldList v]

                    foreach fld $fields {

                      if {![string length $fld]} {continue}

                      xpmstore $xlateId $fld c $fld

                    }

      I have an xlate (837 to vrl flat file).  I want to create column headers out of the vrl field names.  One thing it is doing is putting the column headers in each field that is empty.  I only want the column headers in the first row.

      What am I doing wrong?

      L

      _________________

      Lisa H

    Viewing 10 reply threads
    • Author
      Replies
      • #84216
        Charlie Bursell
        Participant

          Really confused about what you are trying to do here.

          I don’t understand the statement “if {![string length $fld]} {continue}”.  How can fld ever be empty.  You would have an invalid VRL configuration file since NAME cannot be empty.

          Can we assume the output file you are writing to in the Xlate is the same VRL?

          Maybe example of what you expect?

        • #84217
          Lisa Heaton
          Participant

            I’m just trying to get column headers.  This script came from someone and Infor.  We are trying to use the vrl field names as the column headers in the flat file.

            Sadly all this does is fill in empty fields with the vrl field names and nothing in the column headers.

          • #84218
            Charlie Bursell
            Participant

              I suppose we would need to see the whole thing to answer

            • #84219
              Charlie Bursell
              Participant

                Lisa:

                I took another look at this and assume you will process multiple records and only want headers on the first.  Is this VRL defined as CSV?  If so be careful as VRL does not handle embedded commas well.

                At any rate, assume you have some HL7 messages in and you will be copying to a VRL and you want headers only in the first record.  Try something like below.  You should be able to manipulate the iea to fit your needs

                prologue

                   xlt_infile: hl7 2.3.1  DFT_P03

                   who:        Charlie Bursell

                   date:       July 2, 2016 10:19:34 AM ICT

                   xlt_outfile:        vr cbtest.vrl

                   type:       xlt

                   version:    7.0

                end_prologue

                { { OP COPY }

                   { ERR 0 }

                   { IN =1 }

                   { OUT @flag }

                }

                { { OP COPY }

                   { ERR 0 }

                   { PRE {

                       if {![info exists foobar]} {

                           set foobar 1

                           VrioLoadData v cbtest.vrl

                           foreach fld [VrioGetFieldList v] {xpmstore $xlateId $fld c $fld}

                       } else {

                           xpmstore $xlateId @flag c 0

                       }

                   }}

                   { IN @null }

                   { OUT @null }

                }

                { { OP IF }

                   { ERR 0 }

                   { COND {@flag  eq =1} }

                   { THENBODY {

                       { { OP CONTINUE } }

                   }}

                   { ELSEBODY {

                   }}

                }

                { { OP COPY }

                   { ERR 0 }

                   { IN {{0(0).PID(0).#5(0).[0]}} }

                   { OUT fld1 }

                }

                { { OP COPY }

                   { ERR 0 }

                   { IN {{0(0).PID(0).#5(0).[1]}} }

                   { OUT fld2 }

                }

                { { OP COPY }

                   { ERR 0 }

                   { IN 0(0).PID(0).#7(0) }

                   { OUT fld3 }

                }

                { { OP COPY }

                   { ERR 0 }

                   { IN 0(0).PID(0).#11(0) }

                   { OUT fld4 }

                }

              • #84220
                Lisa Heaton
                Participant

                  Thank you Charlie, I’ll take a look

                • #84221
                  Lisa Heaton
                  Participant

                    Will this work as well with an X12 edi message

                  • #84222
                    Charlie Bursell
                    Participant

                      With the proper changes it should work

                    • #84223
                      Lisa Heaton
                      Participant

                        Since I’m so new, can you give me a hint???

                      • #84224
                        Charlie Bursell
                        Participant

                          We would need a *LOT* more info.

                          Example of inbound.  Example of desired outbound.

                          Are you doing single or batch files in or out?

                          Are column headers to be applied to each message or to a batch.

                          Is the output CSV?  If so are there to be embedded commas or special characters in the data?

                          And as much other info as can be provided.  These are the sorts of things that should have been asked for by you when asked to do the interface.

                          As I have said on many occasions; Developing an interface is relatively easy but getting that interface defined is the hard part.  ðŸ˜€

                        • #84225
                          Lisa Heaton
                          Participant

                            Attached is the vrl, I am trying to use the vrl for the column headers.

                            For now, I am trying to run a single through the test module.

                            it is a ^ delimited file. There are imbeded , in the file.

                            Also attached is the xlate, test file and vrl.

                            I am having trouble attaching documents . . . .

                            I can only submit one.  Any suggestions.

                          • #84226
                            Charlie Bursell
                            Participant

                              You sent a 0 byte file.  I don’t think it should be a .txt file anyway if it contains all you say it does.

                              Send it via email: cbursell@fastem.com

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