We are converting an enormous number of records from three source systems for delivery to an HL7 system. The issue is that these source systems (one sending VRL, one FRL, one XML) all contain multiple instances of ampersand, pipes, etc, in free text fields. The vendor on the destination system wants these mapped to the HL7 escape sequences, for instance & to T.
This should be easy to do via a tps or xltp using regsub or string map, but there are several issues that arise. When the tcl proc hands back the converted value, the slashes seem to cause a ton of problems. Sometimes the slashes just vanish, sometimes they don’t. Sometimes two characters back to back (i.e. &&) results in the escaped sequence (T\T\ in this case) to drop all but one of the slashes (T). If the final character in the field is a special character, the proc will fail as it tries to wrap the field in braces, and it freaks out when it finds } at the end of the value.
There are estimated to be 200,000 records with these special characters in them so manual correction is not an option. It seems to be an issue with either the engine or TCL not liking the use of the HL7 escape sequences.
Has anyone had any success with something like this? How did you get it working?!
We are on 5.4.1 SP2 on AIX.
Thanks!