def parse(self, msg):
        """ Parse an HL7 message and return an HL7 dictionary.

        :param msg: HL7 message to parse
        :return: An HL7 dictionary
        """
        #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
def parse ( self , msg ) : dictValues = HL7Dict ( self . tersersep ) msg_ = msg . strip ( '\r\n ' ) self . extractSeparators ( dictValues , msg_ ) msg_ = msg_ . replace ( '\r' , '\n' ) lines = msg_ . split ( '\n' ) lineNumber = 1 segmentNameCount , lineMap = self . buildSegmentMap ( lines ) dictValues . setSegmentsMap ( segmentNameCount , lineMap ) for line in lines : dictValues . currentLineNumber = lineNumber self . extractValues ( dictValues , line ) lineNumber += 1 return dictValues
Parse an HL7 message and return an HL7 dictionary.

        :param msg: HL7 message to parse
        :return: An HL7 dictionary