Go to the first, previous, next, last section, table of contents.

Generating Prolog predicates from tables

From the interim tables we can finally build Prolog predicates. Since Prolog predicates are essentially relations, and relations can be regarded as tables, this conversion is rather straightforward.

It is funny, that any formal information, identifiers as well as descriptive strings are printed in all uppercase in the HL7 document. However we turn everything to lower case, because of following reasons:

The functor symbol is derived from the name of the table, by deleting any special character and replacing consecutive white spaces by one single underscore (`_') character. Even though we could as well surround the whole title of the table by `'' characters, thus marking the sequence as a symbol, we make the conversion for convenience of the working on it to come. Note that we have to refer to these symbols and we don't want to bother with the special characters and number of consecutive spaces, we rather convert the names in a canonical form.

It happens quite often, that one or more attributes of a tuple stay undefined, i.e. when nothing is found between two colons. In this case, we set the value to undefined, which we can do in Prolog by using the anonymous variable `_'. We could as well use a specific symbol which will assume the meaning of nil, like `null', `nil', `"' or even `[]'. However, the anonymous variable will be bound to anything during a unification, thus anything will be allowed at this attribute to cause the predicate to suceed.

Finally we begin each group of predicates with a few command lines of descriptive information about functor name and arity, column types and column headings.

This job is done by the `bin/tb2pl' shell script, which calls `bin/tb2pl.awk', and collects temporary output of `bin/tb2pl.awk'. These temporary files are created during the procession of subtables.


Go to the first, previous, next, last section, table of contents.