TCL help – to print including space characters

Clovertech Forums Read Only Archives Cloverleaf Tcl Library TCL help – to print including space characters

  • Creator
    Topic
  • #55303

    I need some help with TCL code below. I am trying to get the value from PV1-3 Location in the HL7 message and display it. For example, the PV1-3 value is “Family Care Center” in the HL7 message, and it displays only “Family” when I echo the variable. It seems the code doesn’t recognize anything from the first space and after in any HL7 fields. I tried with two cases, and the results are given below. Is there any other method / syntax to get and display all words including spaces from any HL7 field using TCL? Thanks for your help.

    set mh [keylget args MSGID]

    set msg [msgget $mh]

    set msh [lindex [split $msg r] 0]

Viewing 6 reply threads
  • Author
    Replies
    • #84891
      Charlie Bursell
      Participant

        Did you really execute the proc with this command:  

           set locLength : [string length $patientLoc]

        You should have got an error because of the “:”

        You must split your message into segments and then extract the PV1

        set segs [split $msg r]   ;# List of segments

        set msh [lindex [split $segs r] 0]    ;# MSH segment

        set pv1idx [lsearch -regexp $segs ^PV1]

        set pv1flds [split [lindex $segs $pv1idx] $fldsep]

      • #84892

        Hi Charlie,

        Thanks for pointing out the typo. The “:” was a typo when I posted it. Yes, I executed the code on a different PC where I have access to Cloverleaf GUI. For some reason, it does not display the total content from the HL7 field PV1-3.  I tried to display the value from a different field OBR-4.2 Universal Service ID Description, and it also displays only “DRUG” with the string length as 4. Thanks

        OBR-4 = 12345^DRUG SCREEN 10^12345

      • #84893
        Charlie Bursell
        Participant

          So, does it work now?

        • #84894

          No, it is not working. It displayed DRUG instead of DRUG SCREEN 10 for OBR-4.2. and just “Family” instead of “Family Care Center”. It displays properly if I remove the space between words. Thanks Charlie.

          HL7 field   Field content            Displayed as

          PV1-3       Family Care Center   Family

          PV1-3       FamilyCareCenter     FamilyCareCenter     <– This one works because there is no space

          OBR-4.2   DRUG SCREEN 10     DRUG

        • #84895

          It is working now. Thanks Charlie.

        • #84896
          Charlie Bursell
          Participant

            Works for me..  Send a snippet of how it is coded now

          • #84897

            Here is the working code to display PV1-3 and OBR-4.2. As you suggested, it worked after I split the message into list of segments. Thank you so much for your help Charlie.

            set mh [keylget args MSGID]        ;#Message header

            set msg [msgget $mh]

            set segs [split $msg r]           ;# List of segments

            set msh [lindex $segs 0]           ;# MSH segment

            set fldsep [string index $msh 3]   ;# Field sep (|)

            set subsep [string index $msh 4]   ;# Subfield sep (^)

            #get PV1-3 Location

            set pv1idx [lsearch -regexp $segs ^PV1]

            set pv1flds [split [lindex $segs $pv1idx] $fldsep

            set patientLoc [lindex $pv1flds 3]

            echo PV1-3 Location : $patientLoc

            #get OBR-4.2 Test Description

            set obridx [lsearch -regexp $segs ^OBR]

            set obrflds [split [lindex $segs $obridx] $fldsep]

            set testDesc [lindex [split [lindex $obrflds 4] $subsep 1]

            echo OBR-4.2 Test Description : $testDesc

            HL7 field   Field content            Displayed as

            PV1-3       Family Care Center   Family Care Center

            OBR-4.2   DRUG SCREEN 10     DRUG SCREEN 10

            [/b]

        Viewing 6 reply threads
        • The forum ‘Tcl Library’ is closed to new topics and replies.