Next / Previous / Contents / Shipman's homepage

39. class SexCodeField: Sex code

An object of this class represents the sex code. It is very similar to Section 36, “class AgeCodeField: Age code”, except for the list of valid codes; see the specification.
class SexCodeField(SingleField):
    '''Represents a sex code.

      Exports: as inherited.

Next we define the class attributes required by the SingleField interface. These define the set of valid sex codes, and a translation table that maps the older sex codes onto the newer set. Note that VALID_CODES does not contain a space character, because the sex code is required.
    OLD_TRANSLATOR = string.maketrans (

39.1. SexCodeField.scanField()

Scans a sex code field.
# - - -   S e x C o d e F i e l d . s c a n F i e l d   - - -

    def scanField(encounter, scan, fieldName):
        '''Scan a sex code field.
        SingleField.scanField(encounter, scan, fieldName,
                               SexCodeField, "sex code")