› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Generating NTE segments based on the value of OBX|3
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
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 }
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
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
}
Is there a way to echo out xpmstore values inside the while loop?
Arslan
Sam
Any ideas?
Can you post the code you used inside the CALL?
Sam
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 }
Hope this works on yours.
Sam
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
}
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
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
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.
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
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
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
Jim Kosloskey
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
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
It should be.
Jim Kosloskey
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
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.
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.