Convert DBF to PostgreSQL

A friend of mine just released a converter of .dbf files to PostgreSQL, under the GPL license. He writes:

This document provides a step by step instruction how to convert DBase II, DBase III+, DBase IV and (to some extent) FoxProV2 files to PostgreSQL. This solution is based on the excellent Simple DBase SQL by Michael Lecuyer.

UPDATE 2013-05-18: The link above is still valid.

Given, treatment, result

The data structure refactoring will never end. At least it feels like it never will.

While normalizing the factors, I decided to add a new class, a factor type. I hate word “type” but I don’t have any better word now. The types will be:

  • Given: not influenced by the hospital, mostly diseases and their properties.
  • Treatment: the elements of the treatment. The hospital’s choice.
  • Result: influenced by both given and treatment factors. They’ll be the dependent variables.

Having the factor types, it’ll be possible to compare the hospitals against the way of treating the patients. For example, what percent of patients will have palliative operations?

Four age groups in the EACTS Database reports

I just changed the EACTS Congenital Database reports to show four age groups instead of three. Old age groups were:

  • Neonate (0-30 days)
  • Infant (31-365 days)
  • Other (366 days and more)

New age groups are:

  • Neonate (0-30 days)
  • Infant (31-365 days)
  • Child (1-18 years)
  • Adult (18 years and more)

I’ve changed six reports:

The linked reports are publicly available, so if you’re interested in congenital heart surgery, you can check the reports yourself.

Vim, UTF-8 and ISO-8859-2

How to edit with Vim an ISO-8859-2 file when my system uses UTF-8?

About four years ago I had to fiddle with Vim to make it edit an UTF-8 encoded file, while my terminal (and system) used ISO-8859-2.

I use UTF-8 as the default encoding today. How to edit with Vim an ISO-8859-2 file when my system uses UTF-8?

The first thought was to make it the same way as before, just swapping the parameter values: set encoding to ISO-8859-2 and termencoding to UTF-8. Unfortunately, it doesn’t work!

After some RTFM’ing, I learned about the fileencoding parameter, but setting it to ISO-8859-2 didn’t fix the problem. This was to be solved in a different way.

Vim will automatically guess the file encoding, as long as the encoding is listed in the fileencodings parameter. I use only UTF-8 AND ISO-8859-2 (alias LATIN2) encodings, so adding following line to the ~/.vimrc file fixed the problem:

set fileencodings=utf-8,latin2

Database browsing with Django

After few days of building a database browsing tool with Django, I must say: Django is brilliant!

Example patient information
I have set up browsing for all the major database entities: hospitals, surgeons, patients, operations and factors (a factor is a disease, procedure, etc). The database browsing website is intensively interlinked. Every hospital, surgeon, factor, etc is linked, so you can click it and follow to information about it.

Almost everything was done using the generic views, which means that I didn’t have to write the views myself. I decided to migrate the data instead of using the legacy tables directly. It required a bit of work with migrating the data, but I wanted to have pure Django-generated tables. Besides reading the Django documentation, what I have done was:

  • Write models for my data: Hospital, Surgeon, Patient, Operation, Factor
  • Move the data from the old tables to Django tables
  • Generate slugs for nice URLs (slug-is-this-king-of-string)
  • Design URLs (/hospitals/, /hospital/CODE/, etc)
  • Write templates (hospital_list.html, hospital_detail.html, etc)

The next major task will be creating the “related factors” view. It seems like I’ll have to write a custom SQL query for that. The question is: having a given factor (tag), what else factors are associated with patients with my given factor?


I wrote about the kdissert some time ago. After some research I found a similar project, Freemind. Here’s an example screenshot:
Freemind tree example
I like Freemind more than Kdissert for three reasons:

  • Allows keyboard-only data entry. You can use arrow keys to navigate, ENTER to create new nodes on the same level and INSERT to create leaf nodes, F2 to edit note text. This is a great advantage, because mouse usage slows down the process.
  • Does automatic on-screen layout, so you don’t have to waste your time on manual node positioning.
  • Has convenient (press SPACE) branch-collapsing, which allows you to temporarily hide some parts of the tree. Useful especially if you have large and flat tree structure. Please look at the leaves that have little circles on the ends. They are collapsed branches.

Freemind is written in Java and available for Linux, Mac and Windows™.

What’s a diagnosis?

The EACTS Congenital Database website states:

The resulting the International Nomenclature for Congenital Heart Surgery including the Minimum Data Set of 21 items and the lists of 150 Diagnoses, 200 Procedures, 32 Complications, as well as 28 extra cardiac anomalies and 17 preoperative risk factors.

What’s a diagnosis, anyway? Is VSD a diagnosis? No, it’s a disease. So are Tetralogy of Fallot and Hypoplastic Left Heart Syndrome. We can talk about a diagnosis, when certain disease is identified within a patient.

Diagnosis can be also referred to as a set of identified diseases. This is unfortunate, because the nomenclature contains now sets of diseases, for example TGA+VSD. The dictionary of disases should contain single diseases only, and the diagnosis should be defined as a set of previously defined diseases, identified within a patient.