Build the map of the various segments.
        Each segment has a qualified name according to the number
        of equivalent segment.
        If there is only one segment, the segment name is MSH[1] or PID[1].
        If there are 3 segments with the same name, the qualified names are
        SPM[1], SPM[2], SPM[3] for instance.
        SPM[2] is the second SPM segment.

def buildSegmentMap(self, lines):
        """ Build the map of the various segments.
        Each segment has a qualified name according to the number
        of equivalent segment.
        If there is only one segment, the segment name is MSH[1] or PID[1].
        If there are 3 segments with the same name, the qualified names are
        SPM[1], SPM[2], SPM[3] for instance.
        SPM[2] is the second SPM segment.

        """
        lineMap = ['']
        segmentNameCount = {}

        # walk the lines
        for line in lines:
            # get the segment name
            name = line[:self.segment_len]
            # inc the segment count
            if name not in segmentNameCount:
                segmentNameCount[name] = 1
            else:
                segmentNameCount[name] += 1

            qualifiedSegmentName = "%s[%d]" % (name, segmentNameCount[name])
            lineMap.append(qualifiedSegmentName)

        # return the list of qualified segment name
        # ['', 'MSH[1]', 'PID[1]', 'PV1[1]', 'ORC[1]', 'OBR[1]', 'TQ1[1]', 'OBX[1]', 'SPM[1]', ...
        return segmentNameCount, lineMap