Generating NTE segments based on the value of OBX|3

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Generating NTE segments based on the value of OBX|3

  • Creator
    Topic
  • #48129
    Arslan Khan
    Participant

    Hi all,

    I am in need of generating NTE segments from other vendor lab results based on the value of OBX|3. Currently, Lab system is sending data type of ‘FT’ in OBX|3 and results comments in OBX|5. What I want is to process OBX|3 and if it is data type ‘FT’, generate a new NTE segment with NTE|3 copied over from OBX|5. Also, I have to generate multilpe NTE segments if OBX|5 has a character length of > 80 (inbound system has a limit of 80 characters for NTE|3 field).

    What is the best approach to accomplish this? Should I use tcl or can it be done using an xlate? What issues might result in using this approach?

    Any ideas? Does any one has ever encounter such scenario?

    Any insight on this issue is highly appreciated.

    Thanks.

    Arslan

Viewing 20 reply threads
  • Author
    Replies
    • #57737
      Rentian Huang
      Participant

      Arslan,

      try putting a CALL under an ITERATE on the group level.

      hope this helps!

      Sam  8)


      ITERATE: OBX  %g1

      IF: IF OBX-3 eq “FT”

      CALL:

      set OBX5 [datget [xpmfetch $xlateId 1(0).1(0).1(%g1).OBX(0).00573] VALUE]

      if {[string length $OBX5] > 80} {

      set pos 0 ;# reset position

      while {$pos < [string length $OBX5]} { xpmstore $xlateId {1(0).1(0).1(%g1).NTE(0).00098} c [string range $OBX5 $pos [expr $pos + 80]] incr pos 80 } } else { xpmstore $xlateId {1(0).1(0).1(%g1).NTE(0).00098} c $OBX5 }

    • #57738
      Arslan Khan
      Participant

      Sam,

      Thanks for your guidance. I partially got it working.

      If OBX|5 has a length of <80, it is working with no problems. The problems comes when OBX|5 is more than 80 characters in length. The current CALL statement is only generating 1 NTE segment with partial result comment values.

      Do you have any idea where we have to tweak the code?

      Thanks.

      Arslan

    • #57739
      Rentian Huang
      Participant

      Try this one  – Sam

      Code:


      ITERATE: OBX  %g1
      IF: IF OBX-3 eq “FT”

      CALL:
       set OBX5 [datget [xpmfetch $xlateId 1(0).1(0).1(%g1).OBX(0).00573] VALUE]
       if {[string length $OBX5] > 80} {
         set pos 0; set cnt 0        # reset variables
         while {$pos < [string length $OBX5]} {      xpmstore $xlateId {1(0).1(0).1(%g1).NTE($cnt).00098} c [string range $OBX5 $pos [expr $pos + 80]]      incr pos 80, incr cnt    }  } else {    xpmstore $xlateId {1(0).1(0).1(%g1).NTE(0).00098} c $OBX5  }

    • #57740
      Arslan Khan
      Participant

      Still getting the same result…. only 1 NTE segment with NTE|3 populated with the remainder of (total length of OBX-5)/80.

      Is there a way to echo out xpmstore values inside the while loop?

      Arslan

    • #57741
      Rentian Huang
      Participant

      Are you using the Xlate testing tool? Try toss a few echoes and see what you got, I have never tried that thou..

      Sam

    • #57742
      Arslan Khan
      Participant

      The echo’s are displaying correct informartion but some how xpmstore is not storing that information in NTE segments (or may be overwriting it with new information on each iteration!)

      Any ideas?

    • #57743
      Rentian Huang
      Participant

      Arslan,

      Can you post the code you used inside the CALL?

      Sam

    • #57744
      Arslan Khan
      Participant

      Call Statement (as provided by you)


      OBX5 [datget [xpmfetch $xlateId 1(0).1(0).1(%g1).OBX(0).00573] VALUE]

      if {[string length $OBX5] > 80} {

      set pos 0

      set cnt 0

      while {$pos < [string length $OBX5]} { xpmstore $xlateId {1(0).1(0).1(%g1).NTE($cnt).00098} c [string range $OBX5 $pos [expr $pos + 80]] incr pos 80 incr cnt } } else { xpmstore $xlateId {1(0).1(0).1(%g1).NTE(0).00098} c $OBX5 }

    • #57745
      Rentian Huang
      Participant

      It takes a few tests for me to figure out some tricky errors. try this code, it works on my testing tool.

      Hope this works on yours.

      Sam   8)

      Code:



      ITERATE: OBX  %g1
      IF: IF OBX-3 eq “FT”

      CALL:
      Source:
      $%g1
      1(0).1(0).1(%g1).OBX.00573
      Destination:
      @null

      # Generate a new NTE segment with NTE|3 copied over from OBX|5.
      # Also, generate multilpe NTE segments if OBX|5 has a character
      # length of > 80 (inbound system has a limit of 80 characters for NTE|3 field).

      set var [lindex $xlateInVals 0]
      set OBX5 [lindex $xlateInVals 1]

      set addr {1(0).1(0).1(group).NTE(count).00098}
      regsub group $addr $var addr

      if {[string length $OBX5] > 80} {
      set pos 0; set cnt 0
      while {$pos < [string length $OBX5]} { regsub count $addr $cnt addr xpmstore $xlateId $addr c [string range $OBX5 $pos [expr $pos + 79]] regsub "NTE..." $addr {NTE(count)} addr incr pos 80; incr cnt } } elseif {[string length $OBX5] > 0} {
      regsub count $addr 0 addr
      xpmstore $xlateId $addr c $OBX5
      }

    • #57746
      Rentian Huang
      Participant

      Arslan,

      is ~ your repetition delimiter in the encoding character?

      Sam


      Coooooolllllll!!!!!! It worked!! 🙂)

      I had no idea what you did, but it is working. Amazing!

      BTW, my lab is sending “~” in OBX 5 to indicate a new line for notes/comments. Is it possible to generate NTE segments based on that “~” value?

      Like if we receive the following OBX-5:

      “POSITIVE~Due to the intermittent nature of~  gastrointestinal bleeding, it is recommended~  that fecal specimens on consecutive days be~ tested.  The patient should be placed on a meat~  free, high bulk diet beginning 72 hours prior~  to testing and continuing through the test~ period. All foods containing blood, such as meat and meat~  extracts, should be avoided, as well as turnips~  , horseradish and other foods containing~  peroxidase-like substances.”

      Your translation will generate something like:

      NTE[1] = Due to the intermittent nature of

      NTE[2] = gastrointestinal bleeding, it is recommended

      NTE[3] = that fecal specimens on consecutive days be

      NTE[4] = tested.  The patient should be placed on a meat

      NTE[5] = free, high bulk diet beginning 72 hours prior

      NTE[6] = to testing and continuing through the test

      NTE[7] = period. All foods containing blood, such as meat and meat NTE[8] = extracts, should be avoided, as well as turnips

      NTE[9] =   , horseradish and other foods containing

      NTE[10] = ~  peroxidase-like substances.

      Can it be done using the same CALL statement?

      Arslan

    • #57747
      Arslan Khan
      Participant

      Coooooolllllll!!!!!! It worked!! 🙂)

      I had no idea what you did, but it is working. Amazing!

      BTW, my lab is sending “~” in OBX 5 to indicate a new line for notes/comments. Is it possible to generate NTE segments based on that “~” value?

      Like if we receive the following OBX-5:

      “POSITIVE~Due to the intermittent nature of~  gastrointestinal bleeding, it is recommended~  that fecal specimens on consecutive days be~ tested.  The patient should be placed on a meat~  free, high bulk diet beginning 72 hours prior~  to testing and continuing through the test~ period. All foods containing blood, such as meat and meat~  extracts, should be avoided, as well as turnips~  , horseradish and other foods containing~  peroxidase-like substances.”

      Your translation will generate something like:

      NTE[1] = Due to the intermittent nature of NTE[2] = gastrointestinal bleeding, it is recommended NTE[3] = that fecal specimens on consecutive days be NTE[4] = tested.  The patient should be placed on a meat NTE[5] = free, high bulk diet beginning 72 hours prior NTE[6] = to testing and continuing through the test NTE[7] = period. All foods containing blood, such as meat and meat NTE[8] = extracts, should be avoided, as well as turnips

      NTE[9] =   , horseradish and other foods containing

      NTE[10] = ~  peroxidase-like substances.

      Can it be done using the same CALL statement?

      Arslan

    • #57748
      Jim Kosloskey
      Participant

      If the OBX-5 is a repeating field as indicated, then there is no need to use Tcl.

      Simply iterate over the repeating field and creat an NTE with each repetition.

      Jim Kosloskey

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

    • #57749
      Arslan Khan
      Participant

      Sam,

      Yes. We are using “~” in our encoding charaters.

      I am thinking of cleaning all the “~” values from OBX-5 using a regsub command. It should fix the problem then.

      What do you think?

      Arslan

    • #57750
      Rentian Huang
      Participant

      Arslan,

      I think Jim gives a great idea. If the OBX-5 is a repeating field as indicated in your HL7 favor, a simple ITERATE on the field level will do it.

      Sam

    • #57751
      Arslan Khan
      Participant

      Sam/Jim,

      I am little confused here. Each lab results with a data type of “FT” comes with a unique instance of OBX-5.

      Like,

      OBX|1|2|FT|4|Result comments and notes in this field||||

      Currently, LAB is sending notes and comments with ‘~’ to represent a new line, like:

      OBX|1|2|FT|4|POSITIVE~Due to the intermittent nature of~  gastrointestinal bleeding, it is recommended~  that fecal specimens on consecutive days be~ tested.  The patient should be placed on a meat~  free, high bulk diet beginning 72 hours prior~  to testing and continuing through the test~ period. All foods containing blood, such as meat and meat~  extracts, should be avoided, as well as turnips~  , horseradish and other foods containing~  peroxidase-like substances.||||

      My guess is if I am able to remove all the ‘~’ using a regsub command, I should be able to using “SAM’s” CALL statement to generate multiple NTE segments.

      Correct me if I am wrong in this interpretation.

      Thanks.

      Arslan

    • #57752
      Jim Kosloskey
      Participant

      That Tilde indicates repetitions of that OBX field. You do not need any Tcl. Just do an ITERATE on the field and create an NTE for each repetition.

      Jim Kosloskey

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

    • #57753
      Arslan Khan
      Participant

      Using iterate over the OBX field, I was able to generate NTE segments. My solution works for the first OBX segment and as soon as it hits the second OBX (of type FT), I receive only one NTE segment from that OBX-5 field.

      Iterate:

      Type = group

      Basis = 1(0).1(0).1(0)

      Variable = %g1

      Inside Iterate, IF 1(0).1(0).1(%g1).OBX.570 EQ FT

      After IF,

      ITERATE

      Type = field

      Basis = 1(0).1(0).1(0).OBX.573

      Variable = %f1

      — Now I copy OBX-5 to NTE-3

      COPY 1(0).1(0).1(%g1).OBX.573(%f1)

      to

      1(0).1(0).1(%g1).NTE(%f1).00098

      Do I have to do another iterate on OBX segment to generate all NTE’s from OBX-5 field?

      Any ideas?

      Thanks.

      Arslan

    • #57754
      Jim Kosloskey
      Participant

      Is your COPy to the FTE within the ITERATE on the OBX field?

      It should be.

      Jim Kosloskey

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

    • #57755
      Arslan Khan
      Participant

      Yes.

    • #57756
      Jim Kosloskey
      Participant

      Arslan,

      From our conversation the correction is to place the group counter appropriately when setting the basis for the field ITERATE.

      From:

      ITERATE

      Type = field

      Basis = 1(0).1(0).1(0).OBX.573

      Variable = %f1

      To:

      ITERATE

      Type = field

      Basis = 1(0).1(0).1(%g1).OBX.573

      Variable = %f1

      The secret is we always need to define the iteration hierarchy as we progress down the hierarchy.

      Jim Kosloskey

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

    • #57757
      Arslan Khan
      Participant

      Thanks to Jim’s timely intervention, I was able to get all the NTE segments.

      Modified solution is once again listed below for clovertech community:

      Iterate:

      Type = group

      Basis = 1(0).1(0).1(0)

      Variable = %g1

      Inside Iterate, IF 1(0).1(0).1(%g1).OBX.570 EQ FT

      After IF,

      ITERATE

      Type = field

      Basis = 1(0).1(0).1(%g1).OBX.573

      Variable = %f1

      — Now I copy OBX-5 to NTE-3

      COPY 1(0).1(0).1(%g1).OBX.573(%f1)

      to

      1(0).1(0).1(%g1).NTE(%f1).00098

      and again sincere thanks to Sam and Jim.

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

Forum Statistics

Registered Users
5,127
Forums
28
Topics
9,299
Replies
34,443
Topic Tags
288
Empty Topic Tags
10