Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Generating NTE segments based on the value of OBX|3
- This topic has 21 replies, 3 voices, and was last updated 18 years, 11 months ago by Arslan Khan.
-
CreatorTopic
-
November 7, 2005 at 6:56 pm #48129Arslan KhanParticipant
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
-
CreatorTopic
-
AuthorReplies
-
-
November 7, 2005 at 8:01 pm #57737Rentian HuangParticipant
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 }
-
November 9, 2005 at 9:09 pm #57738Arslan KhanParticipant
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
-
November 9, 2005 at 10:12 pm #57739Rentian HuangParticipant
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 } -
November 9, 2005 at 10:40 pm #57740Arslan KhanParticipant
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
-
November 9, 2005 at 10:52 pm #57741Rentian HuangParticipant
Are you using the Xlate testing tool? Try toss a few echoes and see what you got, I have never tried that thou.. Sam
-
November 10, 2005 at 8:40 pm #57742Arslan KhanParticipant
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?
-
November 10, 2005 at 9:48 pm #57743Rentian HuangParticipant
Arslan, Can you post the code you used inside the CALL?
Sam
-
November 10, 2005 at 9:56 pm #57744Arslan KhanParticipant
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 }
-
November 15, 2005 at 4:07 pm #57745Rentian HuangParticipant
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 addrif {[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
}
-
November 15, 2005 at 5:04 pm #57746Rentian HuangParticipant
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
-
November 15, 2005 at 5:15 pm #57747Arslan KhanParticipant
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
-
November 15, 2005 at 5:37 pm #57748Jim KosloskeyParticipant
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.
-
November 15, 2005 at 5:50 pm #57749Arslan KhanParticipant
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
-
November 15, 2005 at 6:39 pm #57750Rentian HuangParticipant
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
-
November 15, 2005 at 8:49 pm #57751Arslan KhanParticipant
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
-
November 15, 2005 at 9:28 pm #57752Jim KosloskeyParticipant
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.
-
November 16, 2005 at 10:49 pm #57753Arslan KhanParticipant
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
-
November 17, 2005 at 3:05 am #57754Jim KosloskeyParticipant
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.
-
November 17, 2005 at 3:01 pm #57755Arslan KhanParticipant
Yes. -
November 17, 2005 at 3:27 pm #57756Jim KosloskeyParticipant
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.
-
November 17, 2005 at 3:28 pm #57757Arslan KhanParticipant
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.
-
-
AuthorReplies
- The forum ‘Cloverleaf’ is closed to new topics and replies.