Sunday, June 17, 2007

A Tale of Four Fonts

This post is a rant.

This is driving me nuts. I'm struggling to find a font in OpenOffice that is consistent size across Windows, Linux, and OS X. Not only do they not all have the same selection of fonts (they don't even all have Helvetica or Georgia!), but the same font appears differently on all of them. Here are some screenshots using Times New Roman, bold, 11 point.

1. Windows

2. Linux

3. OS X using the X11 OpenOffice

4. OS X using NeoOffice

Saturday, June 16, 2007

OpenOffice XForms and Bindings

Good news! In my last post, I complained about OpenOffice's lack of control when dragging elements from the data navigator to your document window to create bindings automatically. It seemed that you were limited to a LabelField and TextBox, and you could only replace the TextBox with a limited number of controls.

Further research has shown me that these two controls are actually grouped together - hence the lack of control over them. I found that you can ungroup them and you have two separate controls, and can then replace the TextBox with whatever you want.

Here's an example of how to do this in OpenOffice. I'll use the "patient.birthday" which we'll need to change to a date field. (Note that the following screenshots are from an awesome program called NeoOffice, an OS X port of OpenOffice that currently uses version 2.1. I've been trying it out, and so far it seems really really cool.)
1. Drag an element from the data navigator to your document. It will look like this:

2. Ungroup the controls. This can be done via Format | Group | Ungroup, or by adding the Ungroup button to your toolbar:

3. You can then click on the individual controls and edit them. Here we'll replace the TextBox with a date field:

4. You can make a pretty calendar-like date select field by setting the "Dropdown" property to "Yes" (thanks to omarc55 for this tip!):

5. All of your XML data from the schema should be there:

6. You can now also change the LabelField to read something more user-friendly like "Date of Birth:".

I'm pleased as punch to have found this. It should make creating this forms MUCH easier. It also opens up form creation to the less technically-inclined people out there.

Friday, June 15, 2007

Form design in OpenOffice

(Note: After you've read this, see my follow-up post.)

This past week I've been working with InfoPath and side-by-side to compare what InfoPath can do vs. what OpenOffice can do. I've started creating the Adult Initial Encounter form in OpenOffice, and so far I've been quite pleased with the results (as have the rest of the OpenMRS gang). Here's a screenshot of part of the form:

I'm noticing that while InfoPath has a lot of drag-and-drop functionality, OpenOffice leaves much of it for the user to do. For example, in order to create a binding in InfoPath, you simply drag an element from the schema over to the document. You can then change what type of control it is (text field, radio button, date field, etc) and it will be nice and bound to your schema:

In OpenOffice, this isn't quite as easy. While you can drag an element from the data navigator directly to the document, you don't seem to have much control over what type of form control gets added. As you can see from the picture, it defaults to a simple text field with a label that I can't seem to change. While it allows you to replace the control with other controls, your choices are very limited. Hopefully this will be further developed in future versions:

In order to bind everything in OpenOffice, I've been selecting the binding from a drop-down list in the data tab of the control properties window. While this is perfectly doable, it's a bit tedious. I've posed a question to the OpenOffice Users mailing list about this, so hopefully I'll have an answer soon.

If there's no better way to do this in the GUI, it's possible that I may be able to write a script that edits the XML files in the .odt file that OpenOffice generates that fills in all of the bindings and default values. Both the InfoPath .xsn files and OpenOffice .odt files are zip files that contain XML and style sheets defining how the forms look and behave.

When the forms are submitted, they send an XML file to a remote server which then has some XSLT which translates the data to HL7. Here's an example of what this looks like, taken from the first screenshot, question 11a, "Is the patient or their partner currently using any form of family planning?":

If the user of the form checks the "Oral Contraceptive Pills" box, the <oral_contraception/> element is set to true, and 780^ORAL CONTRACEPTION^99DCT is the HL7 that is submitted.

I'm currently working on the rest of this form, and I'll start work on the others once it's finished. While the Adult Initial Visit form is rather large and tedious, I figure it's a good place to start because it will have a lot of reusable elements that I can copy and paste into other forms.

I'm pretty pleased with progress so far - I think things are going along quite nicely. Comments?

Monday, June 4, 2007

Week One - Getting Started

After meeting with my mentor and organization admin, my task for the first week has been laid out for me. I'm going to walk through the process of creating and using a form in InfoPath, and document how it works with OpenMRS. This serves three purposes: first it will allow me to understand this process and learn how everything works together. Second, it will show me what needs to be done in OpenOffice, and I'll find out what OOo can already do vs. what I need to make it do. Third, it will allow me to write documentation for this on the wiki for the benefit of other developers and the implementors. Keep an eye here for the documentation as I write it.

Note: I'll write more on this post when I return home to where the stuff I already have done is.