Example #1
0
	def _get_as_amts_latex(self, strict=True):
		# Freitextzeile: 200 Zeichen, @...
		cells = ['\\multicolumn{1}{>{\\RaggedRight}p{4cm}}{%s}' % gmTools.tex_escape_string(self['descriptor'])]
		txt = '%s%s' % (
			self['l10n_type'],
			gmTools.coalesce(self['reaction'], '', ': %s')
		)
		if strict:
			txt = txt[:(200-len(self['descriptor']))]
		cells.append('\\multicolumn{10}{>{\\RaggedRight}p{23.9cm}}{%s}' % gmTools.tex_escape_string(txt))
		table_row = ' & '.join(cells)
		table_row += '\\tabularnewline'
		return table_row
Example #2
0
	def _get_as_amts_latex(self, strict=True):
		# Freitextzeile: 200 Zeichen, @...
		cells = [u'\\multicolumn{1}{>{\\RaggedRight}p{4cm}}{%s}' % gmTools.tex_escape_string(self['descriptor'])]
		txt = u'%s%s' % (
			self['l10n_type'],
			gmTools.coalesce(self['reaction'], u'', u': %s')
		)
		if strict:
			txt = txt[:(200-len(self['descriptor']))]
		cells.append(u'\\multicolumn{10}{>{\\RaggedRight}p{23.9cm}}{%s}' % gmTools.tex_escape_string(txt))
		table_row = u' & '.join(cells)
		table_row += u'\\tabularnewline'
		return table_row
Example #3
0
    def fields_as_dict(self,
                       date_format='%Y %b %d  %H:%M',
                       none_string='',
                       escape_style=None,
                       bool_strings=None):
        if bool_strings is None:
            bools = {True: 'True', False: 'False'}
        else:
            bools = {True: bool_strings[0], False: bool_strings[1]}
        data = {}
        for field in self._idx.keys():
            # FIXME: harden against BYTEA fields
            #if type(self._payload[self._idx[field]]) == ...
            #	data[field] = _('<%s bytes of binary data>') % len(self._payload[self._idx[field]])
            #	continue
            val = self._payload[self._idx[field]]
            if val is None:
                data[field] = none_string
                continue
            if isinstance(val, bool):
                data[field] = bools[val]
                continue

            if isinstance(val, datetime.datetime):
                if date_format is None:
                    data[field] = val
                    continue
                data[field] = pydt_strftime(val, format=date_format)
                if escape_style in ['latex', 'tex']:
                    data[field] = tex_escape_string(data[field])
                elif escape_style in ['xetex', 'xelatex']:
                    data[field] = xetex_escape_string(data[field])
                continue

            try:
                data[field] = str(val, encoding='utf8', errors='replace')
            except TypeError:
                try:
                    data[field] = str(val)
                except (UnicodeDecodeError, TypeError):
                    val = '%s' % str(val)
                    data[field] = val.decode('utf8', 'replace')
            if escape_style in ['latex', 'tex']:
                data[field] = tex_escape_string(data[field])
            elif escape_style in ['xetex', 'xelatex']:
                data[field] = xetex_escape_string(data[field])

        return data
Example #4
0
	def fields_as_dict(self, date_format='%Y %b %d  %H:%M', none_string='', escape_style=None, bool_strings=None):
		if bool_strings is None:
			bools = {True: 'True', False: 'False'}
		else:
			bools = {True: bool_strings[0], False: bool_strings[1]}
		data = {}
		for field in self._idx.keys():
			# FIXME: harden against BYTEA fields
			#if type(self._payload[self._idx[field]]) == ...
			#	data[field] = _('<%s bytes of binary data>') % len(self._payload[self._idx[field]])
			#	continue
			val = self._payload[self._idx[field]]
			if val is None:
				data[field] = none_string
				continue
			if isinstance(val, bool):
				data[field] = bools[val]
				continue

			if isinstance(val, datetime.datetime):
				if date_format is None:
					data[field] = val
					continue
				data[field] = pydt_strftime(val, format = date_format)
				if escape_style in ['latex', 'tex']:
					data[field] = tex_escape_string(data[field])
				elif escape_style in ['xetex', 'xelatex']:
					data[field] = xetex_escape_string(data[field])
				continue

			try:
				data[field] = str(val, encoding = 'utf8', errors = 'replace')
			except TypeError:
				try:
					data[field] = str(val)
				except (UnicodeDecodeError, TypeError):
					val = '%s' % str(val)
					data[field] = val.decode('utf8', 'replace')
			if escape_style in ['latex', 'tex']:
				data[field] = tex_escape_string(data[field])
			elif escape_style in ['xetex', 'xelatex']:
				data[field] = xetex_escape_string(data[field])

		return data
Example #5
0
def __format_latest_vaccinations_latex(vaccinations=None):

    if len(vaccinations) == 0:
        return u'\\noindent %s' % _('No vaccinations to format.')

    tex = u'\\noindent %s {\\tiny (%s)\\par}\n' % (_('Latest vaccinations'),
                                                   _('per target condition'))
    tex += u'\n'
    tex += u'\\noindent \\begin{tabular}{|l|l|l|l|l|l|}\n'
    tex += u'\\hline\n'
    tex += u'%s & %s & {\\footnotesize %s} & {\\footnotesize %s} & {\\footnotesize %s\\footnotemark} & {\\footnotesize %s\\footnotemark} \\\\ \n' % (
        _('Target'), _('Last given'), _('Vaccine'), _('Lot \#'), _('SoaP'),
        gmTools.u_sum)
    tex += u'\\hline\n'
    tex += u'\n'
    tex += u'\\hline\n'
    tex += u'%s'
    tex += u'\n'
    tex += u'\\end{tabular}\n'
    tex += u'\n'
    tex += u'\\addtocounter{footnote}{-1} \n'
    tex += u'\\footnotetext{%s} \n' % _(
        'SoaP -- "S"ubjective: vaccination was remembered by patient. "P"lan: vaccination was administered in the practice or copied from trustworthy records.'
    )
    tex += u'\\addtocounter{footnote}{1} \n'
    tex += u'\\footnotetext{%s -- %s} \n' % (
        gmTools.u_sum,
        _('Total number of vaccinations recorded for the corresponding target condition.'
          ))
    tex += u'\n'

    row_template = u'%s & %s & {\\scriptsize %s} & {\\scriptsize %s} & {\\scriptsize %s} & {\\scriptsize %s} \\\\ \n'
    lines = u''
    targets = sorted(vaccinations.keys())
    for target in targets:
        target_count, vacc = vaccinations[target]
        lines += row_template % (
            target, gmDateTime.pydt_strftime(vacc['date_given'],
                                             '%Y %b %d'), vacc['vaccine'],
            gmTools.tex_escape_string(vacc['batch_no'].strip()),
            vacc['soap_cat'].upper(), target_count)
        if vacc['site'] is not None:
            lines += u' & \\multicolumn{5}{l|}{\\scriptsize %s: %s\\par} \\\\ \n' % (
                _('Injection site'), vacc['site'].strip())
        if vacc['reaction'] is not None:
            lines += u' & \\multicolumn{5}{l|}{\\scriptsize %s: %s\\par} \\\\ \n' % (
                _('Reaction'), vacc['reaction'].strip())
        if vacc['comment'] is not None:
            lines += u' & \\multicolumn{5}{l|}{\\scriptsize %s: %s\\par} \\\\ \n' % (
                _('Comment'), vacc['comment'].strip())
        lines += u'\\hline \n'

    return tex % lines
Example #6
0
def __format_latest_vaccinations_latex(vaccinations=None):

	if len(vaccinations) == 0:
		return '\\noindent %s' % _('No vaccinations recorded.')

	tex =  '\\noindent %s {\\tiny (%s)\\par}\n' % (_('Latest vaccinations'), _('per target condition'))
	tex += '\n'
	tex += '\\noindent \\begin{tabular}{|l|l|l|l|l|l|}\n'
	tex += '\\hline\n'
	tex += '%s & %s & {\\footnotesize %s} & {\\footnotesize %s} & {\\footnotesize %s\\footnotemark} & {\\footnotesize $\\Sigma$\\footnotemark}\\\\\n' % (
		_('Target'),
		_('Last given'),
		_('Vaccine'),
		_('Lot \#'),
		_('SoaP')
	)
	tex += '\\hline\n'
	tex += '\n'
	tex += '\\hline\n'
	tex += '%s'			# this is where the actual vaccination rows end up
	tex += '\n'
	tex += '\\end{tabular}\n'
	tex += '\n'
	tex += '\\addtocounter{footnote}{-1}\n'
	tex += '\\footnotetext{%s}\n' % _('SoaP -- "S"ubjective: vaccination was remembered by patient. "P"lan: vaccination was administered in the practice or copied from trustworthy records.')
	tex += '\\addtocounter{footnote}{1}\n'
	tex += '\\footnotetext{$\\Sigma$ -- %s}\n' % _('Total number of vaccinations recorded for the corresponding target condition.')
	tex += '\n'

	row_template = '%s & %s & {\\scriptsize %s} & {\\scriptsize %s} & {\\scriptsize %s} & {\\scriptsize %s}\\\\\n'
	lines = ''
	targets = sorted(vaccinations.keys())
	for target in targets:
		target_count, vacc = vaccinations[target]
		lines += row_template % (
			target,
			gmDateTime.pydt_strftime(vacc['date_given'], '%Y %b %d'),
			vacc['vaccine'],
			gmTools.tex_escape_string(vacc['batch_no'].strip()),
			vacc['soap_cat'].upper(),
			target_count
		)
		if vacc['site'] is not None:
			lines += ' & \\multicolumn{5}{l|}{\\scriptsize %s: %s\\par}\\\\\n' % (_('Injection site'), vacc['site'].strip())
		if vacc['reaction'] is not None:
			lines += ' & \\multicolumn{5}{l|}{\\scriptsize %s: %s\\par}\\\\\n' % (_('Reaction'), vacc['reaction'].strip())
		if vacc['comment'] is not None:
			lines += ' & \\multicolumn{5}{l|}{\\scriptsize %s: %s\\par}\\\\\n' % (_('Comment'), vacc['comment'].strip())
		lines += '\\hline\n'

	return tex % lines
Example #7
0
	def _get_as_amts_latex(self, strict=True):
		table_rows = []
		# Trennzeile als leere Zeile für bessere Lesbarkeit
		table_rows.append(u'\\multicolumn{11}{l}{}\\tabularnewline')
		# Zwischenüberschrift: 31 Zeichen, $..., 14pt, no frame, \textwidth
		state = u'%s (%s)' % (
			self.state_string,
			gmDateTime.pydt_strftime(self['last_confirmed'], '%b %Y', none_str = u'?')
		)
		if strict:
			state = state[:31]
		table_rows.append(u'\\multicolumn{11}{>{\\RaggedRight}p{27.9cm}}{\\rule{0pt}{4.5mm} \\fontsize{14pt}{16pt}\selectfont %s\label{AnchorAllergieDetails}}\\tabularnewline' % gmTools.tex_escape_string(state))
		# Freitextzeile: 200 Zeichen, @..., \textwidth
		if self['comment'] is not None:
			if strict:
				cmt = self['comment'].strip()[:200]
			else:
				cmt = self['comment'].strip()
			table_rows.append(u'\\multicolumn{11}{>{\\RaggedRight}p{27.9cm}}{%s}\\tabularnewline') % gmTools.tex_escape_string(cmt)
		return table_rows
Example #8
0
	def _get_as_amts_latex(self, strict=True):
		table_rows = []
		# Trennzeile als leere Zeile für bessere Lesbarkeit
		table_rows.append('\\multicolumn{11}{l}{}\\tabularnewline')
		# Zwischenüberschrift: 31 Zeichen, $..., 14pt, no frame, \textwidth
		state = '%s (%s)' % (
			self.state_string,
			gmDateTime.pydt_strftime(self['last_confirmed'], '%b %Y', none_str = '?')
		)
		if strict:
			state = state[:31]
		table_rows.append('\\multicolumn{11}{>{\\RaggedRight}p{27.9cm}}{\\rule{0pt}{4.5mm} \\fontsize{14pt}{16pt}\selectfont %s\label{AnchorAllergieDetails}}\\tabularnewline' % gmTools.tex_escape_string(state))
		# Freitextzeile: 200 Zeichen, @..., \textwidth
		if self['comment'] is not None:
			if strict:
				cmt = self['comment'].strip()[:200]
			else:
				cmt = self['comment'].strip()
			table_rows.append('\\multicolumn{11}{>{\\RaggedRight}p{27.9cm}}{%s}\\tabularnewline') % gmTools.tex_escape_string(cmt)
		return table_rows