gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] GNUmed plugin development - part 11


From: Karsten Hilbert
Subject: Re: [Gnumed-devel] GNUmed plugin development - part 11
Date: Tue, 12 May 2009 23:44:32 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

On Fri, May 08, 2009 at 09:00:17AM +0200, Hilbert, Sebastian wrote:

> I had to tidy up my pyhon skills a lot and started with a standalone python 
> script that reads in an XML file and parses it for a number of known tags 
> such 
> as 'vendor', 'model' and much more. The next step is to format this into the 
> string I would like to display on the screen. The benefit of seperating the 
> data extraction from the data formating part is that many different display 
> options can be catered for.

...

> Having said that I am going to check in the XML file and standalone 
> XML-parser 

...

> to try it run:
> 
>     python GNUmedDeviceParserElementTree.py
> 
> Reading the XML file GNUmed6.xml it will output this:
> 
>     The file has the following devices: <Element CardicacDevice at b7bfb20c>:
>     The device has the following parts: <Element DevicePart at b7bfb18c>
>     hey we are dealing with a generator here:-)
>     ('St. Jude Medical', 'Atlas DR', 'active')
> 
> Seems like we are getting there. Next up is to finish the parsing. While this 
> is getting done Karsten needs to write the routine to store and retrieve and 
> xml object in the database.

This can happen like so:

We decided that those XML snippets will be stored as
documents of a certain type. So, you need to decide on the
document type (a name for the type). Let's assume "cardiac
device status".

Now, you need to run the following code when the user clicks
[save] in your GUI:

        # save your XML to some temporary file
        fname = gmTools.get_unique_filename()
        xml_file = codecs.open(fname, 'w', encoding = 'utf8')
        xml_file.write(the_xml_data)
        xml_file.close()

        # import as a document
        new_doc = gmMedDocWidgets.save_file_as_new_document (
                filename = fname,
                document_type = 'cardiac device status',
                unlock_patient = False
        )

        # set some additional metadata
        new_doc['comment'] = ..
        new_doc['...'] = ...
        new_doc.save()

        # delete the temp file
        try: os.remove(fname)
        except: pass            # can raise exception on Windows

The document type will be created if it does not exist yet.
The new document will auto-appear in any listings containing
documents (EMR tree, EMR journal, document tree) across all
clients connected to the same database and showing the same
patient.

Karsten
-- 
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346




reply via email to

[Prev in Thread] Current Thread [Next in Thread]