Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Need to get a part of a field
- This topic has 28 replies, 4 voices, and was last updated 15 years, 4 months ago by Max Drown (Infor).
-
CreatorTopic
-
June 4, 2009 at 2:30 pm #50936Yamil VelezParticipant
Hi I am trying to to get from the pv2_23_0 just the following ADED
eg. :ADULT EMERGENCY MEDICINE;D;ADED;;;;XX:
and I would like to do this in a xlate.
Thanks in advance
Yamil
-
CreatorTopic
-
AuthorReplies
-
-
June 4, 2009 at 2:56 pm #68075Max Drown (Infor)Keymaster
Can you explain your data in a little more details? For example, will the field always be delimited by semicolons and will the piece of the data that you want to extract always be in the same place?
If so, here is one way that might work for you.
Code:set xlateOutVals [list [lindex [split [lindex $xlateInVals 0] ;] 2]]
-- Max Drown (Infor)
-
June 4, 2009 at 3:01 pm #68076Yamil VelezParticipant
Yes it would always be separate by a semicolon -
June 4, 2009 at 3:05 pm #68077Yamil VelezParticipant
I am getting just medicine -
June 4, 2009 at 3:18 pm #68078Tom RiouxParticipant
Try changing it to just this:
set xlateOutVals
2]]
or if you have more than one input source, set the xlateInVals to a variable first
set clinic [lindex $xlateInVals 0]
set xlateOutVals list [lindex [split [lindex $clinic ;] 2]]
Hope this helps….
Tom
-
June 4, 2009 at 4:12 pm #68079Max Drown (Infor)Keymaster
Odd. It works for me from a test script.
Code:set xlateInVals [list “:ADULT EMERGENCY MEDICINE;D;ADED;;;;XX:”]
set xlateOutVals [list [lindex [split [lindex $xlateInVals 0] ;] 2]]
puts [lindex $xlateOutVals 0]Put that code into a file called test.tcl and then run “tcl test.tcl” from the command line.
-- Max Drown (Infor)
-
June 4, 2009 at 4:20 pm #68080Max Drown (Infor)Keymaster
I do not recommend using “[split $xlateInVals ;]” because xlateInVals is a list variable. You never know when you’ll get data in that will bite you right on the tail. Always treat xlateInVals and xlateOutVals as list variable. The semicolons may be screwing up the data. I’ll try it out in an xlate asap.
-- Max Drown (Infor)
-
June 4, 2009 at 4:41 pm #68081Max Drown (Infor)Keymaster
I created a test xlate. The code I provided with the data you provided works perfect for me. I used PV1.03 as a -- Max Drown (Infor)
-
June 4, 2009 at 4:57 pm #68082Tom RiouxParticipant
I would agree with you in most cases, but since we are specifying a particular subfield PV2.23.[0], unless there are multiple source fields listed, then “[lindex $xlateInVals 0]” or $xlateInVals will return the same value. I totally agree, I would be careful of using just the InVals designation if specifying only something like PV2.23. That will bite you on the tail. Incidentally, I have tried both Max’s code and my code in an xlate with the data provided and it should work for you Yamil. If you are still having difficulty, maybe copy/paste some details showing us how you have it set up.
Thanks….Tom
-
June 4, 2009 at 5:04 pm #68083Jim KosloskeyParticipant
Actually if the field has white space, then not specifying via a list reference may return only a part of the field/component. It is always best to treat the xlate variables as lists.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
June 4, 2009 at 5:17 pm #68084Tom RiouxParticipant
The field in question did in fact have white space and by specifying the subfield designation (i.e. PV2.23.[0]) with $xlateInVals only, it still returned the whole subfield. Is this something that should be concerning???? -
June 4, 2009 at 5:28 pm #68085Jim KosloskeyParticipant
Interesting. Since I always use the list reference, I can’tsay I have ever kicked the tires on inbound fields. Perhaps Xlate is not so sensitive with those.
However, I feel I would rather be safe than have to remember when to use list notation and when not to.
Using list notaitn has never caused me an issue – forgetting to use has caused me grief.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
June 4, 2009 at 5:41 pm #68086Tom RiouxParticipant
I’ve always been sure to use it on an OutVal. As I’ve mentioned before, I never had a concern about using InVal alone so long as I was referencing a subfield and not an entire field. That is curious. I do have another question but I will start a new topic for it.
-
June 4, 2009 at 5:55 pm #68087Yamil VelezParticipant
Hi Thomas and Jim
I have attach a screen shot of my translation configurator.
This my message when I run the routes testing
omnicell_Adt_Out MSH|^~&|STAR|S|CERNER|S|20090604084354||ADT^A08|92064|P|2.2|92064||AL
EVN|A08|20090604084354|||RT
PID|1||^^^^PI|||||F||O|262 SUYDAM ST APT 1^^NEW ||||||||N|||N|||N
PV1|1|E||1||||||XED||||7||||ER||MM|||||||||||||||||||S||0|||200906040750
I must be doing some wrong but do not know why
Thanks for all your answer and help
Yamil
-
June 4, 2009 at 5:57 pm #68088Tom RiouxParticipant
Yamil, Try attaching the screen shot again
Tom
-
June 4, 2009 at 6:04 pm #68089Yamil VelezParticipant
Here it is again -
June 4, 2009 at 6:20 pm #68090Max Drown (Infor)Keymaster
Can you paste the entire hl7 message, please? -- Max Drown (Infor)
-
June 4, 2009 at 6:23 pm #68091Tom RiouxParticipant
It appears you have a space between the backslash (“”) and the semicolon. Push them together like “;” and you should get your desired results. Just a note, when I put a space between them using the code, the first word I got in the destination field was “MEDICINE”.
Hope this helps…
Tom
-
June 4, 2009 at 6:25 pm #68092Max Drown (Infor)Keymaster
Good eye, Tom. -- Max Drown (Infor)
-
June 4, 2009 at 6:34 pm #68093Yamil VelezParticipant
Hi Tom and Max When you do not put a space between you get nothing.
See examples
-
June 4, 2009 at 6:42 pm #68094Tom RiouxParticipant
Copy and paste the original PV2 segment into a message for us to see Thanks…Tom
-
June 4, 2009 at 6:56 pm #68095Yamil VelezParticipant
Message with original PV2 segment -
June 4, 2009 at 7:06 pm #68096Jim KosloskeyParticipant
Yamil, Is the Component Separator in MSH-2 a semi-colon ‘;’? Maybe all you need to do is select the correct field component.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
June 4, 2009 at 7:09 pm #68097Yamil VelezParticipant
No the component separate is : -
June 4, 2009 at 7:25 pm #68098Yamil VelezParticipant
I meant that the separator is “:” a colon Thanks
-
June 4, 2009 at 7:29 pm #68099Max Drown (Infor)Keymaster
Oh. You are using “:” and “;” as the HL7 field delimiters instead of the default “^” and “&”. So, you should be able to pull the field out without using any tcl code. Data” :ADULT EMERGENCY MEDICINE;D;ADED;;;;XX:
Use “0(0).PV2(0).#23(0).[2]” as your inbound field.
Notice the “[2]”.
-- Max Drown (Infor)
-
June 4, 2009 at 7:53 pm #68100Jim KosloskeyParticipant
It looks like the ; semi-colon is the sub-component separator. So you notation should be somehting like 0(0).PV2(0).#23(0).[0].[2].
The first [0] points to the component, the second [2] points to the sub-component.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
June 4, 2009 at 8:06 pm #68101Yamil VelezParticipant
That brings up nothing see illustration -
June 4, 2009 at 8:37 pm #68102Max Drown (Infor)Keymaster
Remove the tcl fragment. You don’t need it. -- Max Drown (Infor)
-
-
AuthorReplies
- The forum ‘Cloverleaf’ is closed to new topics and replies.