Wednesday, April 29, 2009

GNUmed plugin development - part 10

It has taken some time to tackle part 10 of my way to a GNUmed plugin. A new GNUmed version has been released. Release dude duties have taken up most of my freetime.

Anyway I am back. The widget user interface loads in GNUmed but does not do anything useful yet. The time for clicking UI elements is over. The hard labor to code in python is about to begin. Here is where most idealists have left off and left GNUmed.

I was fortunate enough to have a face to face meeting with Karsten to ask all my newbie questions.

1.) How to proceed ?
2.) How to extend the database tables to house my data ?

His answer wasn't straight forward. First he wanted to know exactly what I intended to do. I told him my vision but visions don't amount to code. I had to break the vision down into manageable pieces.

Turns out there are many ways to store the input gathered via the the plugin user interface. There is the option to extend the database structure which is more work for him and involves a lot of new code (potentially buggy that is) or store the input as a XML document like any other document.

I did not understand the concept of storing the input as a document at first so he had to explain the concept to me. It comes down to this. Instead of storing any value gotten from the user interface in a table/field in the database one stores the values in an xml file and stores the xml file in the database. The xml file is a datbase more or less which gets stored in the the PostgreSQL database.

This means I can reuse the document plugin's classes and functions and do the content storage via python's XML routines.

I first constructed an XML file to work with. The editor used was EditiX - a cross-platform and multi-purpose XML editor, XSLT debugger and Visual Schema Editor. It provides editing support for XML, DTD, XHTML, XSLT, XSD, XML RelaxNG, ...

Here is the manually crafted XML file.

<?xml version="1.0" encoding="UTF-8"?>

<!-- New document created with EditiX at Wed Apr 29 15:37:23 CEST 2009 -->

<CardicacDevices>
        <DevicePart type="generator">
                <class>AID</class>
                <type>generator</type>
                <isactive>yes</isactive>
                <dateofimplant></dateofimplant>
                <dateofexplant></dateofexplant>
                <isexplanted>no</isexplanted>
                <comment></comment>
                <implantsite>subpectoral</implantsite>
                <implantregion>right subclavian</implantregion>
                        <GeneratorPart type="CPU" >
                                <manufacturer>SJM</manufacturer>
                                <model></model>
                                <serial></serial>
                        </GeneratorPart>
                        <GeneratorPart type="Battery">
                        <manufacturer></manufacturer>
                        <serial></serial>
                </GeneratorPart>
        </DevicePart>

        <DevicePart type="lead">
                <manufacturer>          </manufacturer>
                <model></model>
                <polarity></polarity>
                <serial></serial>
                <isactive>yes</isactive>
                <hasYconnector>yes</hasYconnector>
                <dateofimplant></dateofimplant>
                <dateofexplant></dateofexplant>
                <isexplanted>   no</isexplanted>
                <leadposition>RV</leadposition>
                <leadslot>RA</leadslot>
                <comment></comment>
                        <connectedtodevice>aid</connectedtodevice>
                        <connectedtodevice>RVlead</connectedtodevice>
        </DevicePart>

</CardicacDevices>
This is a simplified version. It lacks the actual measurements. Next step is to learn how to transfer that XML to a human readable form so I can display it in the left upper section of the plugin.

No comments: