code: def parse(self, msg):
          
          #init
          dictValues = HL7Dict(self.tersersep)
          msg_ = msg.strip('\r\n ')
  
          # extracts separator defined in the message itself
          self.extractSeparators(dictValues, msg_)
          msg_ = msg_.replace('\r', '\n')
          lines = msg_.split('\n')
          lineNumber = 1
  
          # build the map of segments
          segmentNameCount, lineMap = self.buildSegmentMap(lines)
          dictValues.setSegmentsMap(segmentNameCount, lineMap)
  
          # Parse each line of the message : 1 line = 1 segment
          for line in lines:
              dictValues.currentLineNumber = lineNumber
              self.extractValues(dictValues, line)
              lineNumber += 1
  
          return dictValues
docs: Parse an HL7 message and return an HL7 dictionary.
  
          :param msg: HL7 message to parse
          :return: An HL7 dictionary