reportgen

class reportgen.PrintedReport.PrintedReport[source]

The class defining a PrintedReport.

Whenever you make a new printed report you will have to define a new class that inherits from this report.

classname[source]

Name of the file where this report is defined (e.g., Operational if the file is Operational.py)

filename

Filename alphanumeric, underscore, and hyphen are ok

formats

A list of file formats to use, e.g., [‘pdf’,’html’,’xls’]

generate(time_period, rformat, title, filepath, data)[source]

You should implement the generate method in a report subclass. This method creates the report and saves it to the right place (probably static/reports/filename.format). The return value is ignored.

set_progress(progress)[source]

Call this to update the progress of the report in the database.

Parameters:progress (float) – A number from 0 to 100 giving the percentage completion.
test(time_period, rformat)[source]

Use this method to test your reports from the shell.

Parameters:
  • time_period – An object with start and end methods that return datetime objects.
  • rformat – A string giving the report format to generate (e.g., “pdf”)
title

Human-readable title of report

variants

A list of report variants in the form:

(title_suffix, fn_suffix, variant_data)

For example, you might have a patient register for Bugongi and Ruhiira health centers:

variants = [
    (' Bugongi HC', '_BG', {'clinic_id': 13}),
    (' Ruhiira HC', '_RH', {'clinic_id': 15}),
]

Neither the title nor filename suffixes can be the empty string “”

Previous topic

mgvmrs

Next topic

lib

This Page