Yvonne,
Based on what is presented, I think you have at least 3 options:
1. build an HRL with 3 VRL definitions.
The first VRL definition will be these:
charge type
pt_name
MRN
FIN
Billing_doc
doc_id
cost_ctr
DOS
The above would have a pipe (|) terminator and have one occurrence in the HRL.
The second VRL would be your CPT codes. It would be space terminated with a single field and defined in the HRL to repeat based on the repetition characteristics.
The third VRL would be these:
diag 1
diag 2
diag 3
diag 4
The above would be pipe terminated fields.
2. One VRL with the field being pipe delimited and the CPT field treated inside the Xlate as a list. You will need some Tcl here to pull each one of the list elements (CPT Codes) out of the field into a Temp Variable. Then using a list iteration and the trick of resetting the counter to 0 (zero) as long as there is a CPT list element to retrieve you can ITERATE through the List (%l1 could be your counter). With each of these iterations then you can build your HL/7 messages.
3. Using all Tcl and parse the messag and build an HL/7 message doing everything in Tcl.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.