home *** CD-ROM | disk | FTP | other *** search
- **
- ** PROGRAM TITLE : FORM
- **
- ** WRITTEN BY : Paul Long
- **
- ** WRITTEN FOR : Copyright (C) 1992 All rights reserved. XL Systems, Inc.
- **
- ** PROGRAM INTENT: Class for converting DSHS forms data to GHOST data
- ** and adds it to a DBF.
- **
- #include "oclip.ch"
- #include "inkey.ch"
-
-
- // Form abstract superclass definition
- CLASS Form
- VAR oFile // File. Contains form data
- VAR oFound // Boolean. Whether search succeeded
- VAR nEntries // Service entries on current form
-
- // Fields transfered from form to DBF
- VAR cLastName
- VAR cFirstName
- VAR cMiddleInitial
- VAR dDOB
- VAR cAcctNo
- VAR cExamNo
- VAR adDOS
- VAR cPIC
- VAR cSSN
-
- METHOD New = FormNew // Constructor
- METHOD Destruct = FormDestruct // Destructor
- METHOD Add2DBF = FormAdd2DBF // Convert and add form data to .DBF
- METHOD Entries = FormEntries // Return number of service entries
- METHOD Skip // Skip to next form
- METHOD Read
- // Read() reads the current form data from the input file, saving
- // pertinent data for latter output by Write(). Data
- // is stored in the following instance variables: cLastName,
- // cFirstName, cMiddleInitial, dDOB, cAcctNo, cExamNo, adDOS,
- // cPIC, and cSSN. Read() and Skip() must be provided by the subclass.
- // Because of this, Form is an abstract class.
- METHOD Found = FormFound // Return whether search succeeded
- METHOD Write = FormWrite // Write form data out to .DBF
- ENDCLASS
-
-
- *******************************************************
- *
- * FormNew
- *
- *******************************************************
- * Construct Form object mainly by constructing DOSFile object.
- *
- METHOD FUNCTION FormNew(cFileName)
-
- // Initialize all instance variables to a known state
- ::nEntries := 0
- ::cLastName := ::cFirstName := ::cMiddleInitial := ""
- ::cAcctNo := ::cExamNo := ::cPIC := ::cSSN := ""
- ::dDOB := ctod(" / / ")
- ::adDOS := {}
- ::oFile := DOSFile():New(cFileName)
- ::oFound := Boolean():New(.t.)
-
- return if(::oFile == nil, nil, Self)
-
-
- *******************************************************
- *
- * FormDestruct
- *
- *******************************************************
- * Destruct form object by destructing input file
- *
- METHOD FUNCTION FormDestruct
-
- ::oFile:Destruct()
-
- return nil
-
-
- *******************************************************
- *
- * FormAdd2DBF
- *
- *******************************************************
- * Convert forms data to GHOST data and add to DBF
- *
- METHOD FUNCTION FormAdd2DBF(cDBF)
-
- if file(cDBF + ".dbf") // Make sure output .DBF exists
- use (cDBF) exclusive new
- if neterr()
- ?? "*** ERROR *** " + cDBF + ".dbf cannot be opened"
- else
- do while ::Skip():Found() // Read each form
- ::Write(cDBF) // Write data for this form
- ?? ++::nEntries, ::cLastName, chr(K_RETURN) // Tell user progess
- enddo
- (cDBF)->(dbclosearea())
- endif
- else
- ?? "*** ERROR *** " + cDBF + ".dbf file is missing"
- endif
-
- return Self
-
-
- *******************************************************
- *
- * FormEntries
- *
- *******************************************************
- * Return number of entries in last-converted form
- *
- METHOD FUNCTION FormEntries
-
- return ::nEntries
-
-
- *******************************************************
- *
- * FormWrite
- *
- *******************************************************
- * Write service information from the current form.
- *
- METHOD FUNCTION FormWrite(cDBF)
-
- // Add n records to DBF
- aeval(::adDOS, { | dDOS | ;
- (cDBF)->(dbappend()), ;
- (cDBF)->acctno := ::cAcctNo, ;
- (cDBF)->examno := ::cExamNo, ;
- (cDBF)->svcdate := dDOS, ;
- (cDBF)->ssn := ::cSSN, ;
- (cDBF)->pic := ::cPIC, ;
- (cDBF)->firstname := ::cFirstName, ;
- (cDBF)->midinitial := ::cMiddleInitial, ;
- (cDBF)->lastname := ::cLastName, ;
- (cDBF)->birthdate := ::dDOB ;
- })
-
- return Self
-
-
- *******************************************************
- *
- * FormFound
- *
- *******************************************************
- * Return whether last search succeeded.
- *
- METHOD FUNCTION FormFound(lWhetherFound)
-
- return ::oFound:Value(lWhetherFound)
-