Strip units in OBX-5

Clovertech Forums Cloverleaf Strip units in OBX-5

  • Creator
    Topic
  • #122384
    ohrhull
    Participant

      Hello, I’m attempting to strip out units of measurement in OBX-5 fields when I receive them from a vendor.  In many OBXs they are going to send a value such as “14.8 cm” or “147.0 grams” etc.  I would also like to move that unit of measurement into the OBX-6 field.

      I am planning to use a translation I already have built.  I know this can be done via xlateStr commands or tcl code within the COPY action.  I have tried both and keep getting tripped up with the syntax/formatting of it.  Does anyone have experience doing this in a simple manner lately?

    Viewing 3 reply threads
    • Author
      Replies
      • #122385
        Jim Kosloskey
        Participant

          I am assuming you want to strip out some text from the OBX-5 field and place that in OBX-6. I will assume by your example, the text can vary in length and content. If that is true, then you need some sort of ‘anchor’ I think.

          For example, if the text always began or ended with something you can count on, or the following text always began a certain way, or there are a predictable number of spaces, or it starts the text for a specific length. That knowledge will help construct a reliable solution.

          BTW – shameful plug – I have a package that goes into a lot of detail regarding the STRING Action Functions and includes some additional functions I have written. You can have a copy if you email me (email in signature).

          email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.

        • #122386
          Paul Bishop
          Participant

            Will the value in OBX-5 always be in “<measurement> <unit>” with space between the two?  Will there ever be a measurement with an embedded space?  What about a unit with an embedded space?  This is easily done if there are no spaces in the measurement.  use the lindex command to pull parts out.  TCL snippet:

            lassign xlateInVals in_obx_5
            set out_obx_5 [lindex $in_obx_5 0]
            set out_obx_6 [lindex $in_obx_5 1]
            set xlateOutVals

              Your source would be the OBX-5.0 field and your destination would be both the OBX-5.0 field and OBX-6.0 field (or variables if you’d like) – just make sure both are listed since you’re outputting two values.

              If there are spaces in the units value, the second lindex would be changed to a lrange: “lrange $in_obx_5 1 end”

              This is just one way to do it – I’m sure others will come up with different solutions.

              Paul Bishop
              Carle Foundation Hospital
              Urbana, IL

            1. #122387
              ohrhull
              Participant

                Yes the value is consistently coming over as this kind of example: “<measurement> <unit>”

                To my knowledge we are not going to be getting any embedded spaces in the measurement or unit, just the space between.

                I also just noticed the first OBX will have all text in it “OB-GYN Ultrasound Report” which I don’t want to do anything with.  I am also getting some OBX-5 for gestational age formatted as example: “14 weeks 3 days”   … I would just intend to leave those as those have been filing okay because they are not Fetus measurements.

                So currently I have this in one COPY command.  When I add “set xlateOutVals $out_obx_6 it just puts the units in OBX-5 so I still have some work to do.  Along with figuring out the gestational age examples.

                =================================================================

                Source: 0(0).OBX(%s1).#5(0).[0]

                Pre Proc:

                lassign $xlateInVals in_obx_5
                set out_obx_5 [lindex $in_obx_5 0]
                set out_obx_6 [lrange $in_obx_5 1 end]
                set xlateOutVals $out_obx_5

                 

                Destination:

                1(0).1(0).1(%s1).OBX(0).#5(0).[0]
                1(0).1(0).1(%s1).OBX(0).#6(0).[0]

                 

                • #122394
                  Paul Bishop
                  Participant

                    xlateOutVals should always be treated as a list even if it is just one variable/value.   Since you want two separate output fields populated, it should be

                    set xlateOutVals

                      Paul Bishop
                      Carle Foundation Hospital
                      Urbana, IL

                  • #122399
                    Jason Russell
                    Participant

                      The xlateInVals is going to be a list of the inputs. Each line is a separate list item. Since it’s one line, you’ll need to split it. If you’re confident it will always be two sets of strings with no additional spaces you can make that assumption, however, if they don’t do that (for whatever reason) it could cause problems. The simplest pre-proc is the following:

                      set xlateOutVals [split [lindex $xlateInVals 0] { }]

                      Then set your destination as you have above. lindex will remove the {}’s around your input. Split will split it into a list,  on spaces. setting it to xlateOutVals will send it out.

                      This is because it is putting the input in a set of braces {} as there is a space to show it’s together. This creates a lot of potential issues, and this is not assuming any characters (braces, quotes, protected items \$, etc). There are ways to get around this, but if you trust your data that one line will do what you need. Adding additional spaces will throw this off.

                      For the other data, you should really have a descriptor in OBX-3 you can use to only do this to the specific data you want. OBX-3 should have something like GESTATIONAL_AGE, BIRTH_WEIGHT or some other moniker that you can use to make sure you’re only doing this to the birth weight. If they don’t that really complicates things and makes it a lot harder to do what you need to do (but it can be done).

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