Forms in GNUMed

This is a description of a new framework for forms in Gnumed (the old one didn't really work, and is not flexible enough)

Previously we've been defining forms in the backend. This has several problems:

Now I think forms belong in the middleware layer, as descendants of abstract 'engine' classes, such as LaTeX or HL7, which define what the templates look like.

So we would have: (FYI: Karsten's reply to this is on the developer list here)

class ScriptForm (LaTeXForm):
    def store (self):
        various SQL commands to store internal state in the backend

    def print (self):
        """
No actual code, just a big docstring containing LaTeX which we run through
the templater (this code already written in the old framework),
which can reference the objects internal variables
"""
       LaTeXForm.print (self)

   def display (self):
       """
Descendants under client/wxpython (and elsewhere for other clients)
override this to provide a GUI popup,which asks for the required information
We have to arrange on what internal variables need to be defined for
the various form types (see below)

Using multiple inheritances, form GUIs can be "grafted" onto different
middleware forms (for example, paper and electronic referrals have the same
GUI
"""


    soap = "p"
    """
Where in the soap paragim this form fits 
(most will be "p" of course, but we may want special forms
for "o" for MMSE, NUCOG, &c.)
"""
    keyword = "script"
    """
The keyword in the SOAP widget, which causes us to pop up.
"""
    menu_name = "&Prescription"
    """
A name for a "Forms" menu on the top menubar
"""

To gave some examples, a referral form might use these variables:

variable type
request string
clinical_notes string
patient_instructions multi-line text
recipient gmDemographicRecord.cIdentity

For scripts (AU-style):

variable type
drugs list of cMedication
brand_only boolean
RPBS boolean

Remember these forms should have user and patient defined automatically,

For work certificates:

variable type comment
date_start date start of certificate
date_restrict date date return to work with restrictions
date_return date date of return to full duties
restrictions string work restrictions