Commits

Anonymous committed fe357a8

work around i2b2 webclient bug with double-quotes in tooltips

Comments (0)

Files changed (1)

              c_tablename='concept_dimension',
              c_facttablecolumn='concept_cd',
              max_tooltip_len=850, encoding='utf-8'):
+        '''
+
+        If there's a double quote in the tooltip, the web client
+        gets confused and doesn't display the tooltip.
+        KLUDGE: change them to single quotes.
+
+        >>> I2B2MetaData.term(['ROOT'], ['T'], 'T',
+        ...                   tooltip='ab "x"').c_tooltip
+        "ab 'x'"
+        '''
+
         # TODO: move pfx to caller's responsibility
         # TODO: postpone serialization?
         hlevel, path = len(parts), '\\'.join(pfx + parts + [''])
         m_path = '\\'.join(applies_to + ['%']) if applies_to else '@'
-        tooltip = (tooltip or '')[:max_tooltip_len].encode(encoding)
+
+        tooltip_enc = (tooltip or '')[:max_tooltip_len].encode(encoding)
+        tooltip_q = tooltip_enc.replace('"', "'")
+
         return Term(
             hlevel, path,
             code, name, viz,
-            m_path, tooltip,
+            m_path, tooltip_q,
             c_synonym_cd,
             update_date, sourcesystem_cd,
             c_metadataxml or '',