- This topic has 7 replies, 4 voices, and was last updated 14 years, 9 months ago by .
-
Topic
-
v5.5 on Windows…. I have an interesting problem – an inbound which sends in results (imaging reports) in an ORU format where the text “lines” of the report are listed as repeating elements in OBX-5, eg:
Code:OBX||FT|^|000852171AMI|PATIENT HISTORY~Patient is postmenopausal, has history of breast cancer at age 57, has history~of high-risk lesion on a previous biopsy at age 56, and had first child at ~age 32.~No known family history of cancer.|
Each “repeat” (~) gets treated as a soft return so that the above text would look like so in the destination system:
PATIENT HISTORY
Patient is postmenopausal, has history of breast cancer at age 57, has history
of high-risk lesion on a previous biopsy at age 56, and had first child at
age 32.
No known family history of cancer.
All of a sudden, the receiving system has decided that any incoming reports of this nature have to have lines that are 68 characters or less (in other words, each occurrence of OBX-5 needs to be less than 68). This basically means I have to take the full text inside of OBX-5, remove the existing “~” characters, and then put them back in at intervals of 68.
Now, using an xlate proc I can get pretty far with this but can’t seem to get over the last hump. Here’s the tcl I cobbled together so far:
Code:set myIn0 [lindex $xlateInVals end]
set myIn2Len [string length $myIn0]
set myIn0 [string map {~~ @@ ~ ” “} $myIn0]
set myIn0 [string map {@@ ~~} $myIn0]set LoopLimit [expr [string length $myIn0]/68]
set myOut “”
for {set LoopNum 0} {$LoopNum < [expr $LoopLimit + 1]} {incr LoopNum} { lappend myOut [concat [string range $myIn0 [expr $LoopNum * 68] [expr [expr $LoopNum * 68] + 67]] ~] } set xlateOutVals $myOut
The problem is, if I echo out the result of this code I get:
Code:{~~PATIENT HISTORY Patient is postmenopausal, has history of breast c ~} {ancer at age 57, has history of high-risk lesion on a previous biops ~} {y at age 56, and had first child at age 32. No known family history ~} {of cancer. ~}
So that I know that it is “working”, insofar as it is breaking the line up where I want it to (also notice that I am keeping “~~” characters where they are since they split the thing up into “paragraphs” and I wanted to keep that formatting intact). But, sumptin’ ain’t right because the outbound transaction only yields:
Code:OBX|1|TX|AWIDM.77056^GDT||~~PATIENT HISTORY Patient is postmenopausal, has history of breast c ~
This obviously has something to do with lists and lappends and instances of the component and so forth…but I’m not familiar enough with tcl to know how to deal with this.
What would an expert do?
Also, I know I probably ultimately clean it up even more so that it is not breaking in the middle of words…but I figured I’d save that for last after I figure out the bigger problem of why I’m not getting the whole string back.
Thanks for any help/ideas. Anything will increase my knowledge at this point since I’m already at the edge of my envelope on this one.
- The forum ‘Cloverleaf’ is closed to new topics and replies.