Monday, April 13, 2009

GNUmed plugin development - part 8

Remember I left off with a problem rather than a solution ? Well I had a little chat face to face with Karsten who happens to be the author of the SOAP plugin I borrowed so much code from.

Turns out he added some special code to the file wxgSoapPluginPnl.py which normally gets autogenerated from the wxg file. Looking at the file I found I had to add

class wxgCardiacDevicePluginPnl(wx.ScrolledWindow):
    def __init__(self, *args, **kwds):

        from Gnumed.wxpython.gmNarrativeWidgets import cSoapNoteInputNotebook
        from Gnumed.wxpython.gmDateTimeInput import cFuzzyTimestampInput
        from Gnumed.wxpython.gmEMRStructWidgets import cEncounterTypePhraseWheel
        from Gnumed.wxpython import gmListWidgets

        # begin wxGlade: wxgCardiacDevicePluginPnl.__init__

The import statements to my wxgCardiacDevicePluginPnl.py. It now actually shows up in GNUmed. Horray. But it crashes when trying to load data. this should be easy to fix.

Here is the error:

gm.gui (/home/basti/sources/gnumed/gnumed/Gnumed/wxpython/gmExceptionHandlingWidgets.py::handle_uncaught_exception_wx() #49): unhandled exception caught:
Traceback (most recent call last):
  File "/home/basti/sources/gnumed/gnumed/Gnumed/wxpython/gmHorstSpace.py", line 231, in _on_notebook_page_changed
    new_page.receive_focus()
  File "/home/basti/sources/gnumed/gnumed/Gnumed/wxpython/gmPlugin.py", line 183, in receive_focus
    self._widget.repopulate_ui()
  File "/home/basti/sources/gnumed/gnumed/Gnumed/wxpython/gmRegetMixin.py", line 128, in repopulate_ui
    self.__repopulate_ui()
  File "/home/basti/sources/gnumed/gnumed/Gnumed/wxpython/gmRegetMixin.py", line 66, in __repopulate_ui
    self._data_stale = not self._populate_with_data()
  File "/home/basti/sources/gnumed/gnumed/Gnumed/wxpython/gmRegetMixin.py", line 79, in _populate_with_data
    raise NotImplementedError, "[%s] _populate_with_data() not implemented" % self.__class__.__name__
NotImplementedError: [cCardiacDeviceMeasurementsPnl] _populate_with_data() not implemented

That is no surprise since I decided to put the class cCardiacDeviceMeasurementsPnl into gmMeasurementWidgets.py and did not copy all stuff from gmSoapWidgets. What I effectively missed is to copy all the needed functions like _populate_with_data().

What this effectively shows is that I need to get a better idea on what to put where. Up till now it has mainly been a process of duplicating content of other files.

One issue is if it makes sense to put more stuff into gmMeasurementWidgets or rather a seperate file along the lines of gmDeviceAssessmentWidgets.

From the feedback received on the mailing list it is recommended to leave it in gmMeasurementWidgets and import the relevant stuff from gmNarrativeWidgets in order to avoid code duplication.

It was further recommended to rename cCardiacDeviceMeasurementsPnl into cCardiacDevicePluginPnl to avoid namespace confusion for the day I really want a class representing the measurement specific bits.

No comments: