gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] B complex


From: Karsten Hilbert
Subject: Re: [Gnumed-devel] B complex
Date: Sat, 12 May 2012 11:53:18 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Sat, May 12, 2012 at 01:22:02AM +0000, Jim Busser wrote:

> > This seems better regarding multi-component drugs. I am
> > currently trying to find out how to tell LaTeX not to
> > stretch wrapped text across the whole column.
> 
> What lines of (latex) code are currently wrapping these placeholders in your 
> template?

None.

The placeholder code itself - inside GNUmed - produces LaTeX
code. The python code producing same is as follows  :-)

def format_substance_intake(emr=None, output_format=u'latex', 
table_type=u'by-brand'):

        tex =  u'\\noindent %s {\\tiny (%s)\\par}\n' % (_('Medication list'), 
_('ordered by brand'))
        tex += u'\n'
        tex += u'\\noindent \\begin{tabularx}{\\textwidth}{|X|X|}\n'
        tex += u'\\hline\n'
        tex += u'%s & %s \\\\ \n' % (_('Drug'), _('Regimen / Advice'))
        tex += u'\\hline\n'
        tex += u'\n'
        tex += u'\\hline\n'
        tex += u'%s\n'
        tex += u'\n'
        tex += u'\\end{tabularx}\n'

        current_meds = emr.get_current_substance_intake (
                include_inactive = False,
                include_unapproved = False,
                order_by = u'brand, substance'
        )

        # aggregate data
        line_data = {}
        for med in current_meds:
                identifier = gmTools.coalesce(med['brand'], med['substance'])

                try:
                        line_data[identifier]
                except KeyError:
                        line_data[identifier] = {'brand': u'', 'preparation': 
u'', 'schedule': u'', 'notes': [], 'strengths': []}

                line_data[identifier]['brand'] = identifier
                line_data[identifier]['strengths'].append(u'%s %s%s' % 
(med['substance'][:20], med['amount'], med['unit'].strip()))
                line_data[identifier]['preparation'] = med['preparation']
                line_data[identifier]['schedule'] = 
gmTools.coalesce(med['schedule'], u'')
                if med['notes'] is not None:
                        if med['notes'] not in line_data[identifier]['notes']:
                                
line_data[identifier]['notes'].append(med['notes'])

        # create lines
        already_seen = []
        lines = []
        line1_template = u'%s %s             & %s \\\\'
        line2_template = u' {\\tiny %s\\par} & {\\scriptsize %s\\par} \\\\'
        line3_template = u'                  & {\\scriptsize %s\\par} \\\\'

        for med in current_meds:
                identifier = gmTools.coalesce(med['brand'], med['substance'])

                if identifier in already_seen:
                        continue

                already_seen.append(identifier)

                lines.append (line1_template % (
                        
gmTools.tex_escape_string(line_data[identifier]['brand']),
                        
gmTools.tex_escape_string(line_data[identifier]['preparation']),
                        
gmTools.tex_escape_string(line_data[identifier]['schedule'])
                ))

                strengths = 
gmTools.tex_escape_string(u'/'.join(line_data[identifier]['strengths']))
                if len(line_data[identifier]['notes']) == 0:
                        first_note = u''
                else:
                        first_note = 
gmTools.tex_escape_string(line_data[identifier]['notes'][0])
                lines.append(line2_template % (strengths, first_note))
                if len(line_data[identifier]['notes']) > 1:
                        for note in line_data[identifier]['notes'][1:]:
                                lines.append(line3_template % 
gmTools.tex_escape_string(note))

                lines.append(u'\\hline')

        return tex % u' \n'.join(lines)


Karsten
-- 
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



reply via email to

[Prev in Thread] Current Thread [Next in Thread]