HL7 parser

  • Creator
    Topic
  • #52102
    David Barr
    Participant

      Here’s a new HL7 parser I’ve been working on.  It’s not quite done yet, but I think it works pretty well.  I’m planning on adding features to delete and insert segments soon.  I’ve used TCLDOC formatted comments, so you can generate nicely formatted documentation if you’d like. Any suggestions are appreciated.

      Description:

      This library contains routines for manipulating HL7 messages.  This

      involves splitting messages into segments, fields, components and

      subcomponents.  It saves processing time by only splitting apart the

      parts of the message that are required to get or set the specified

      field.  As each part of the message is split, it is stored for future

      requests, so if you make multiple requests for fields in a single

      segment, only one segment split is required.

      Example code:

      Code:

      package require hl7
      keylget ARGS MSGID mh
      set hl7 [hl7::parse_msg [msgget $mh]]
      set msgType [hl7::get_field hl7 MSH.9.2]
      hl7::set_field hl7 MSH.10 12345
      for { set i 1 } { $i <= [hl7::count hl7 DG1] } { incr i } {  set diag_text [hl7::get_field hl7 DG1($i).4] } for { set i 1 } { $i <= [hl7::count hl7 PID.3] } { incr i } {  if { [hl7::get_field hl7 PID.3($i).5] eq "MR" } {    set mrn [hl7::get_field hl7 PID.3($i).1]  } } msgset $mh [hl7::join_msg hl7]

      A field specifier has this format:

      segment_name [ (repeating_segment_number) ] [ .field_number [

       (repeating_field_number) ] [ .component_number [ .subcomponent_number ] ] ]

      Examples:

      PID.3

         PID field 3

      MRG(2).2

         field 2 of MRG segment #2.

      PID.3.5.1

         PID segment, field 3, component 5, subcomponent 1.

      DG1

         the entire DG1 segment.

    Viewing 3 reply threads
    • Author
      Replies
      • #73082
        David Barr
        Participant

          I haven’t posted an updated copy of our library in a while. This one adds some procs for adding and removing segments, and the syntax for specifying fields is more powerful.

          Extract the TAR file in $HCIROOT to install.

        • #73083
          David Barr
          Participant

            This version fixes a bug related to specifying subfields in repeating segment/field searches.

          • #73084
            Jon Blanchard
            Participant

              <span style="color: #471A60]Add an indicator for a repeating field number as follows”>

              (segmentNumber)~…

              Migration Consultant
              Coffee Regional Medical Center
              Eastern Time Zone

            • #73085
              David Barr
              Participant

                Jon Blanchard wrote:

                <span style="color: #471A60]Add an indicator for a repeating field number as follows”>

                (segmentNumber)~…

                I don’t understand what you’re saying. Are you making a enhancement request or asking how it works?

                You can say PID.3(2).1 to access repeating fields (from PID.3, access the second field repetition then the first component of that repetition). You can also do things like PID.3(5=MR).1. This says to access the repetition of PID.3 that contains MR in the fifth component and return the value of the first component.

                You can also use [hl7::count hl7 PID.3] to count the number of repetitions of the field.

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