Code Clinic - HL7 Lab - Book 6: Loops for Repetition
A message has many segments and you cannot hand-write each one. The for loop is the answer, and this book builds it from the simplest case, walking a list of parsed fields and printing each in turn, then walking a string one character at a time. enumerate() gives you the position alongside the value, so you can report that field number five is empty rather than just that something is empty. range() covers the counting loops where you need a number rather than an item. Then the loop starts to think. An if inside the body lets you act on some items and skip others, which turns a plain walk into a filter, and the count pattern gives you a running total, so you can say how many values in a message met your condition. The book finishes on routing, the pattern at the heart of every parser: loop through the segments of a message, look at the three-letter name at the front of each one, and send a header, a patient segment and a result segment down three different paths.
Seventeen A4 pages, in full color. Written in short sentences and plain English, for readers whose first language is not English and clearer for everyone else because of it.
Every code example in this book was run before the page was printed, so the output you read is the output you get. Instant PDF download. By M.R. Sterling.