This chapter describes, how we actually scan the HL7 document to capture useful information. First we have to take a look on the HL7 document itself, its format and what structured information we may find therein. Then we describe the interim format, in which all information that can be expressed in tables is stored. Finally we describe the methods used to generate Prolog predicates from these tables. However as noted above, tables are not the only information style in which information is presented in the HL7 document, the message syntax is expressed in a simple formal language, that can be translated purely lexically to Prolog expressions.
To accomplish the tasks of this step, we use AWK, which is a common tool for text file processing, available on virtually any UNIX system. So is sed, which we sometimes use to post process our output in order to get rid of nasty junk characters. Where AWK or sed is not available, the C sources of the GNU version of these (strongly recommendable) tools can be freely copied from any major FTP server next to you.