Need to get a part of a field

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Need to get a part of a field

  • Creator
    Topic
  • #50936
    Yamil Velez
    Participant

    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

Viewing 27 reply threads
  • Author
    Replies
    • #68075

      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)

    • #68076
      Yamil Velez
      Participant

      Yes it would always be separate by a semicolon

    • #68077
      Yamil Velez
      Participant

      I am getting just medicine

    • #68078
      Tom Rioux
      Participant

      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

      1. #68079

        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)

      2. #68080

        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)

      3. #68081

        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)

      4. #68082
        Tom Rioux
        Participant

        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

      5. #68083
        Jim Kosloskey
        Participant

        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.

      6. #68084
        Tom Rioux
        Participant

        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????

      7. #68085
        Jim Kosloskey
        Participant

        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.

      8. #68086
        Tom Rioux
        Participant

        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.

      9. #68087
        Yamil Velez
        Participant

        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

      10. #68088
        Tom Rioux
        Participant

        Yamil,

        Try attaching the screen shot again

        Tom

      11. #68089
        Yamil Velez
        Participant

        Here it is again

      12. #68090

        Can you paste the entire hl7 message, please?

        -- Max Drown (Infor)

      13. #68091
        Tom Rioux
        Participant

        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

      14. #68092

        Good eye, Tom.

        -- Max Drown (Infor)

      15. #68093
        Yamil Velez
        Participant

        Hi Tom and Max

          When you do not put  a space between you get nothing.

        See examples

      16. #68094
        Tom Rioux
        Participant

        Copy and paste the original PV2 segment into a message for us to see

        Thanks…Tom

      17. #68095
        Yamil Velez
        Participant

        Message with original PV2 segment

      18. #68096
        Jim Kosloskey
        Participant

        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.

      19. #68097
        Yamil Velez
        Participant

        No the component separate is :

      20. #68098
        Yamil Velez
        Participant

        I meant that the separator is “:”  a colon

        Thanks

      21. #68099

        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)

      22. #68100
        Jim Kosloskey
        Participant

        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.

      23. #68101
        Yamil Velez
        Participant

        That brings up nothing  see illustration

      24. #68102

        Remove the tcl fragment. You don’t need it.

        -- Max Drown (Infor)

    Viewing 27 reply threads
    • The forum ‘Cloverleaf’ is closed to new topics and replies.

    Forum Statistics

    Registered Users
    5,125
    Forums
    28
    Topics
    9,294
    Replies
    34,439
    Topic Tags
    287
    Empty Topic Tags
    10