› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › If statement in an xlate
I am trying to use an If statement in my xlate that will do the following:
If OBX-3 eq STUDYDATE than copy OBX-5 to OBR-7.
I created a variable named @date and this is my If statement:
1(0).1(0).1(0).OBX.#3 eq @date
Then I added a copy:
OBX-5 ~ OBR-7
Can someone point me in the right direction.
Marcus,
Welcome to Cloverleaf and clovertech.
The OBX is usually part of a repeating Group so the IF needs to be inside an ITERATE and the addrss path to the field (the 1(0).1(0).1(0).OBX.#3 ) needs to have the iteration/repetition counter specified in te ITERATE placed appropriately in the address path. Somehting like 1(0).1(0).1(%g2).OBX.#3 .
It is also possible the OBX group is subordinate to a ORC group (if this is a result for example) and thus there will be nested ITERATES (one for the ORC and then another inside of that one for the OBX group).
The address pathing would then look something like this:
1(0).1(%g1).1(%g2).OBX.#3 where %g1 is the repetition counter for the ORC Group ITERATE and %g2 is the rpetition counter for the OBX group.
In the above scenario, when building the OBX group ITERATE rememer to include the ORC repetition counter (%g1) in the basis for the OBX group ITERATE.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
Hmmm. So what is the inbound message structure?
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
The inbound message structure is flat text. We have a TCL scripts that converted the text to HL7 and all data elements reside in OBX segments. I’m trying to build an OBR segment and pull the Study date from one of the OBX segments to OBR-7. In the OBX segment OBX-3 contains StudyDate and OBX-5 contains the date.
Hope this makes sense.
VERSION 13
BEGIN OB_DATA
INTERNAL_COMMENT “SKey=110 | PKey=51 | SIUID=1.2.276.0.26.1.1.1.2.2003.138.32588.3700652.1”
STUDYDATE 03.04.2003
STUDYTIME 13:50:00
Post TCL to HL7:
OBX|1|NM|VERSION||13
OBX|2|NM|BEGIN||OB_DATA
OBX|3|NM|INTERNAL_COMMENT|SKey|110
OBX|4|NM|INTERNAL_COMMENT|PKey|51
OBX|5|NM|INTERNAL_COMMENT|SIUID|1.2.276.0.26.1.1.1.2.2003.138.32588.3700652.1
OBX|6|NM|STUDYDATE||20030403
OBX|7|NM|STUDYTIME||135000
Marcus,
OK – you need to make sure the inbound variant you are using in the Xlate matches your message structure.
If the example you gave is the full generated HL/7 message then you are missing an MSH and I am pretty sure the Xlate will not work properly without that.
From your first post I am going to guess you are using the default HL/7 structure (possibly for an ORU or an ORM). I suspect that structure will not get you what you want as ther address pathing might not match the actual message.
So you need to get a structure defined that matches the message received.
On another tack did you investigate bypassing the pre-processing Tcl and defining the inbound messag as a FRL or as a VRL then taking that directly into an Xlate that converts the FRL or HRL to HL/7?
You still need to create the missing segments, etc. but at least you will have a matching message definition and eliminate a potentially unnecessary process.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
Jim this was only a portion of what parsed to HL7. I do have the MSH and PID segments. I was unable to use a VRL because some of the fields contain pipes and there is no delimiter.
Here is a portion of the raw file:
VERSION 13
BEGIN OB_DATA
INTERNAL_COMMENT “SKey=110 | PKey=51 | SIUID=1.2.276.0.26.1.1.1.2.2003.138.32588.3700652.1”
STUDYDATE 03.04.2003
STUDYTIME 13:50:00
HOSPITAL “”
SONOGRAPHER “Sonogr.”
REFERRING_MD “Ref. Phys.”
DIAGNOSTIC_PH “Diag. Phys.”
READING_PH “”
PATNAME “Demo”
PATID “Test ID”
BIRTHDATE 03.03.1980
GENDER 1
AGE 8425
PATHEIGHT 180.0 cm
PATWEIGHT 80.0 kg
GESTATIONS 1
GRAVIDA 1
PARA 2
AB 3
BSA 2.0 m2
PAT_HR 76.0
INDICATION “Indication”
CUSTOMFIELD1 “Custom 1”
CUSTOMFIELD2 “Custom 2”
STUDYDESCRIPTION “Exam Type.”
CLINICAL_LMP 03.03.2003
CLINICAL_GA 4w 3d
CLINICAL_EDC 08.12.2003
BEGIN FETUS_DATA 1
AVG_US_GA 14w 2d
AVG_US_EDC 30.09.2003
HR 130
BEGIN FETALBIO
AC_HADLOCK 1=78.4 mm|2=80.0 mm|3=80.0 mm|AVG=79.5 mm|GA=14w 2d -11+12d|EDC=30.09.2003|
AFI 1=41.9 mm|2=41.3 mm|3=50.6 mm|4=42.1 mm|SUM=175.9 mm|
APAD 1=42.1 mm|2=40.0 mm|3=40.0 mm|AVG=40.7 mm|
APTD_HANSMANN 1=23.9 mm|2=20.0 mm|3=20.0 mm|AVG=21.3 mm|
BOD_JEANTY 1=25.8 mm|2=20.0 mm|3=20.0 mm|AVG=21.9 mm|GA=14w 4d +-23d|EDC=28.09.2003|
BPD_MERZ 1=53.3 mm|2=50.0 mm|3=50.0 mm|AVG=51.1 mm|GA=20w 5d +-13d|EDC=16.08.2003|
BPD_HADLOCK 1=41.9 mm|2=40.0 mm|3=40.0 mm|AVG=40.6 mm|GA=18w 2d +-12d|EDC=02.09.2003|
Here is the same sample size in HL7:
MSH|^~&|Voluson|Voluson|GEHCIT|GEHCIT|20100509234629.463||ORU^R01|20100509234629.463.0|P|2.3
PID|1|Test ID|Test ID|Test ID|Smith^Mary^Q.||19800303|F
OBR|1|||1.2.276.0.26.1.1.1.2.2003.138.32588.3700652.1
OBX|1|NM|VERSION||13
OBX|2|NM|BEGIN||OB_DATA
OBX|3|NM|INTERNAL_COMMENT|SKey|110
OBX|4|NM|INTERNAL_COMMENT|PKey|51
OBX|5|NM|INTERNAL_COMMENT|SIUID|1.2.276.0.26.1.1.1.2.2003.138.32588.3700652.1
OBX|6|NM|STUDYDATE||20030403
OBX|7|NM|STUDYTIME||135000
OBX|8|NM|SONOGRAPHER||Sonogr.
OBX|9|NM|REFERRING_MD||Ref. Phys.
OBX|10|NM|DIAGNOSTIC_PH||Diag. Phys.
OBX|11|NM|PATNAME||Smith^Mary^Q.
OBX|12|NM|PATID||Test ID
OBX|13|NM|BIRTHDATE||19800303
OBX|14|NM|GENDER||F
OBX|15|NM|AGE||8425
OBX|16|NM|PATHEIGHT||180.0 cm
OBX|17|NM|PATWEIGHT||80.0 kg
OBX|18|NM|GESTATIONS||1
OBX|19|NM|GRAVIDA||1
OBX|20|NM|PARA||2
OBX|21|NM|AB||3
OBX|22|NM|BSA||2.0 m2
OBX|23|NM|PAT_HR||76.0
OBX|24|NM|INDICATION||Indication
OBX|25|NM|CUSTOMFIELD1||Custom 1
OBX|26|NM|CUSTOMFIELD2||Custom 2
OBX|27|NM|STUDYDESCRIPTION||Exam Type.
OBX|28|NM|CLINICAL_LMP||20030303
OBX|29|NM|CLINICAL_GA||4w 3d
OBX|30|NM|CLINICAL_EDC||20031208
OBX|31|NM|BEGIN||FETUS_DATA 1
OBX|32|NM|AVG_US_GA||14w 2d
OBX|33|NM|AVG_US_EDC||20030930
OBX|34|NM|HR||130
OBX|35|NM|BEGIN||FETALBIO
OBX|36|NM|AC_HADLOCK|1|78.4|mm
OBX|37|NM|AC_HADLOCK|2|80.0|mm
OBX|38|NM|AC_HADLOCK|3|80.0|mm
OBX|39|NM|AC_HADLOCK|AVG|79.5|mm
OBX|40|NM|AC_HADLOCK|GA|14w|2d -11+12d
OBX|41|NM|AC_HADLOCK|EDC|20030930
OBX|42|NM|AFI|1|41.9|mm
OBX|43|NM|AFI|2|41.3|mm
OBX|44|NM|AFI|3|50.6|mm
OBX|45|NM|AFI|4|42.1|mm
OBX|46|NM|AFI|SUM|175.9|mm
OBX|47|NM|APAD|1|42.1|mm
OBX|48|NM|APAD|2|40.0|mm
OBX|49|NM|APAD|3|40.0|mm
OBX|50|NM|APAD|AVG|40.7|mm
OBX|51|NM|APTD_HANSMANN|1|23.9|mm
OBX|52|NM|APTD_HANSMANN|2|20.0|mm
OBX|53|NM|APTD_HANSMANN|3|20.0|mm
OBX|54|NM|APTD_HANSMANN|AVG|21.3|mm
OBX|55|NM|BOD_JEANTY|1|25.8|mm
OBX|56|NM|BOD_JEANTY|2|20.0|mm
OBX|57|NM|BOD_JEANTY|3|20.0|mm
OBX|58|NM|BOD_JEANTY|AVG|21.9|mm
OBX|59|NM|BOD_JEANTY|GA|14w|4d +-23d
OBX|60|NM|BOD_JEANTY|EDC|20030928
OBX|61|NM|BPD_MERZ|1|53.3|mm
OBX|62|NM|BPD_MERZ|2|50.0|mm
OBX|63|NM|BPD_MERZ|3|50.0|mm
OBX|64|NM|BPD_MERZ|AVG|51.1|mm
OBX|65|NM|BPD_MERZ|GA|20w|5d +-13d
OBX|66|NM|BPD_MERZ|EDC|20030816
OBX|67|NM|BPD_HADLOCK|1|41.9|mm
Ok it looks like you have a usable HL/7 message and I think the normal ORU^R01 for HL/7 2.3 should work.
So now you need to ITERATE over the OBX group and use the counter specified in the ITERATE inside the OBX address pathing for your IF.
Even though you havre an OBR in the inbound, there is only one so I don’t think it is necessary to ITERATE over the OBR and then the OBX inside that (you could do tboth iterations and that would still work).
So just an OBX Group ITERATE and then inside that iteration the IF with the iteration/repetition counter assigned in the ITERATE used in the OBX field address path.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
Greetings Marcus,
See if you can capture the HL7 message and run a test against your HL7 variant using the IDE. Look for IR tag mismatch and Segment out of order messages to see if your HL7 template matches the message. Look for how the segments repeat, that is, check the path to see which group increases from 0. This gives you the clue to the iterate (loop) basis to specify in the xlate. Once you have tuned your variant then reconfigure your xlate and test using the IDE. Reconfigure is an option in the Xlate tool. This drags in the current definition of your HL7 variant into your xlate. Save then test. A ground up approach that I find works for me.
Good luck and welcome to Cloverleaf!
BobR
Marcus,
Check that you have specified the iter variable in the repeating path of the source OBX field that is being tested. You have a repeating group and the value that you want may be in a member of the group:
Drawing from Jim’s example and yours:
1(0).1(%g1).1(%g2).OBX.#3 eq @date
Then I added a copy:
OBX-5 ~ OBR-7
Also: consider using a different temp var name as @date is a default supplied temporary variable that you can select from a list such as @null.
There may be some collision with Cloverleaf here too.
See if that fixes your problem.
Good hunting!
BobR
In your specific case I do not think 2 iterations are warranted so I would modify what Bob suggested with:
IF 1(0).1(0).1(%g1).OBX.#3 eq @xxx
Good catch Bob regarding the @date!!
I second not to use that and instead define your own temp variable (in the IF Action above I used xxx only as an example).
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
Makes sense. Now my easiest question is exactly how do I declare a variable in an xlate? I know @variable, but what do I put in the source and what do I put in the destination?