Next / Previous / Contents / Shipman's homepage

74.14. BaseEncounter.scanTail(): Scan tail fields

This method scans the tail of an encounter record. For the format of this part, see the specification.

Fields in the tail are free-form and optional, so if the scan object is at end of line, we're done.

baseclasses.py
# - - -   B a s e E n c o u n t e r . s c a n T a i l   - - -

    def scanTail(self, scan):
        '''Scan free-form tail fields at the end of an encounter line.

          [ if the line in scan starts with a valid tail section ->
              scan  :=  scan advanced to end of line
              self  :=  self with values from the tail stored using
                        attribute names from self.OUT_FIELD_LIST
            else ->
              scan   :=   scan advanced no further than end of line
              Log()  +:=  error message(s)
              raise SyntaxError ]
        '''

Parsing is straightforward. If we're not at the end of the line, a tail field must be next. The class variable .tailDispatch is a dictionary that relates (uppercased) tail type codes to the methods that process each one. See Section 74.15, “BaseEncounter.scanTailField(): Scan one free-form tail field”.

baseclasses.py
        #-- 1 --
        while not scan.atEndLine():
            #-- 1 body --
            # [ if scan starts with TAIL_CUE_CHAR followed by
            #   a valid tail field ->
            #     scan  :=  scan advanced past that field
            #     self  :=  self with data from that field stored
            #               using field names in self.OUT_FIELD_NAMES
            #   else ->
            #     scan   :=   scan advanced no further than end of line
            #     Log()  +:=  error message(s)
            #     raise SyntaxError ]
            self.scanTailField(scan)