Template Guidelines

Read tryton reports document

GNU Health HIS is based on tryton service, so should read it first.

Libreoffice setup

  1. Remove user data

    • Open: (File → Properties)

    • Uncheck: Apply user data

    • Uncheck: Save preview image with this document

    • Click on: Reset Properties

  2. Set some parameters

    • Check (View > Field Names) and let field only show Placeholder label, which will be more conducive to observing the layout effect.

    • Use English (USA) UI, so the name of table or figure in document will be English.

      (Options → Language Settings → Languages → User Interface)

    • Disable table number recognition

      (Options → Libreoffice Write → Table → Number recognition)

Edit report template file

  1. Do not use direct (or manual) formatting.

  2. Do not use character style unless absolutely necessary.

  3. Prefer use paragraph styles, but suggest style number < 20.

  4. Use GNU FreeFont as English font, for example: FreeSerif, FreeSans and FreeMono.

  5. Hide all unused styles.

  6. User custom styles suggest prefix with GH-, which means GNU Health.

  7. Be careful of spaces of label strings.

    Suggest PUID or PUID:, instead of PUID<SPC>:.

  8. Do not add extra spaces between two words.

    Using hello<SPC>world instead of hello<SPC><SPC>world.

  9. The name of table, figure and other things suggest use ascii.

  10. Reconfigure table properties after table layout is changed.

  11. Should we use and/or/not or if directive ?

    1. In most situation, we prefer and/or/not, for it is not disrupt report layout and make grep work well.

      appointment.patient and and or ''

      Using Python Conditional Expressions is a good idea too:

      <value_if_true> if <expression> else <value_if_false>
    2. if string will be translated by other languages, and if directive do not disrupt report layout too much, we suggest use if directive.

      if test='appointment.patient'
    3. if if directive seriously affects the report structure, we suggest to add a method to model and use this method in template, for example, we use get_report_pain_and_level() in report template of health_nursing modules.

      # Use by round_report template
      def get_report_pain_and_level(self):
           if self.pain and self.pain_level:
               return gettext('health_nursing.msg_report_pain_level',
           elif self.pain:
               return gettext('health_nursing.msg_report_pain_yes')
               return gettext('health_nursing.msg_report_pain_no')

Save and check report template file

  • Clean Direct Formatting.

    1. (Edit → Select All)

    2. (Format → Clean Direct Formatting)

    NOTE: This step is very useful, which can solve most Abnormal string fragmentation issues describe below.

  • Check ‘Abnormal string fragmentation’ issue.

    Save file to fodt format, then open fodt file with a text editor to check “PU” + “ID” style issues (Abnormal string fragmentation), if found, edit template file again.

    <text:span text:style-name="T4">PU</text:span><text:span text:style-name="T3">ID</text:span>
    <text:p text:style-name="P11">Hello <text:s/>world</text:p>
  • Check po or pot files.

    Finally, user can run below command to update po files, then check diff with hg command, make sure no PU + ID style issues.

    bash tryton/script/po-export/ <YOUR-LANGUAGE>