PROGRAM ASSIGNMENT #8

DUE: 1:00 p.m., May 17, 2001 - NO EXCEPTIONS
VALUE: 100 pts.

Program 8 will be an interactive patient billing system program which will emphasize modularization, especially in the use of user-defined functions and procedures using variable parameters. You will also use a binary search algorithm to process two input text files. All I/O in this program will be via text files whose names are to appear in the constant section of the main program.

The input to the program will come from three text files.

The first input file (referred to as the "services file") contains on each line a 20-character service name, followed by one or more spaces and then an integer service code. This file is not sorted. A typical record in the services file could be:

Laryngoscopy           5

The second input file (referred to as the "new charges file") contains on each line of the file a 5-character patient identification number (ID) in columns 1-5, followed by one or more spaces and then an integer identifying the type of service received by the patient, followed by one or more spaces and then a real number giving the fee to be charged to that patient. This file is not sorted. The new charges file represents the data input at the console as each patient finishes their visit. A bill is generated from this information on the spot. A typical record in the new charges file could be:

12230  5  40.0

The third input file (referred to as the "patient master file") has on each line a patient ID in columns 1-5, the patient's name in columns 7-21 and then separated by one or more spaces, values for the following numerical quantities:

Insurer code (integer)
Year to date total fees charged (real)
Year to date total fees billed to insurance (real)
Year to date total fees billed to the patient (real)
Insurance coverage percentage (real, between 0 and 1 inclusive)
Total account balance (real, positive for an amount owed)

Thus a typical record in the patient master file could be:

12230 Edwin Burdek    8 300.00 210.00 90.00 0.70 45.00

The patient master file is sorted by patient ID in ascending order.

There may be patient records in one file whose patient ID is not matched by any patient ID in the other file. When run against these data files, your program will produce:

  1. an updated master file in which the fields of the patient records will be appropriately updated (you should call this file NEWMAST.OUT);

  2. a patient statement file (also called the statement file) with a section for each patient that received a bill today (see detailed explanation to follow); you should call this file BILLS.OUT);

  3. an error log file (you should call this file ERRORLOG.OUT) which will have the entry "No errors found" when every record in the new charges file has a record in the patient master file with a matching ID, and the service code is valid. However, when a record in the new charges file is encountered for which there is no record in the patient master file with matching patient ID, or if a record has a service code which is not found in the services file, an appropriate message is written to the error log file together with an echo print of the mismatching record from the charges file. The errant record is NOT PROCESSED further, and is not counted in the totals given at the end of the statement file.

The Error Log file will have a header banner at the beginning of the file very much like the following:

   =======================================
   Error Log File
   Date: <date Error Log file created; use TIMER07.PAS>
   Time: <time Error Log file created; use TIMER07.PAS>
   Input files:
     <name of patient master file>
     <name of new charges file>
     <name of services file>
   Programmed by: <your name here>
   CS 171 - <your section here>
   =======================================
   Due Date: 5/17/2001
   Value: 150 pts.
   =======================================
The Statement File will have a very similar header banner at the beginning of the file:
   =======================================
   Patient Statement File
   Date: <date Statement file created; use TIMER07.PAS>
   Time: <time Statement file created; use TIMER07.PAS>
   Input files:
     <name of patient master file>
     <name of new charges file>
     <name of services file>
   Programmed by: <your name here>
   CS 171 - <your section here>
   =======================================
   Due Date: 5/17/2001
   Value: 100 pts.
   =======================================
You are to create and use a procedure called Create_Banner to print these banners in the output files. The lines of === should be created by a nested procedure within Create_Banner called Print_line; pass the character to print ( = ) and the number of them to print as values to the procedure. Pass the different messages "Error Log File" and "Patient Statement File" to the procedure Create_Banner as appropriate.

An entry (section) in the patient statement file will look like the following; compare to the entries given from the input files listed earlier (computations may not be exact):

============================================================
PATIENT INVOICE

Patient identification number: 12230
Patient name:                  Edwin Burdek
Insurer code: 8       Service: Laryngoscopy

                       Current        Year to Date
Description            Amount         Amount
--------------------------------------------------
Amount charged           40.00            340.00
Billed to insurer        28.00            238.00
Billed to patient        12.00            102.00

Current charges          12.00
Previous balance         45.00
-------------------------------
Total Due (please pay)   57.00
============================================================
EXTRA CREDIT NOTICE: You may elect to add the following feature to your program 8 code for 50 pts extra credit (and you must so note in the banners written at the top of the Error and Statement log files, see above): the order of the patients written in the Statement Log must be alphabetized by patient last name. Do not underestimate the demands of this additional feature! If you elect to add it to Program 8, it is a good idea to plan for it from the very beginning. You may NOT accomplish this by first sorting the new charges file by last name!

The following paragraphs explain how these amounts are computed on the basis of values read from the input files for the patient record being processed. Note: any dollar value computed as a product or quotient should be immediately rounded to the nearest cent by calling a function which returns its real argument rounded to two decimal places (use the reference sheet from Program 6).

The amount charged current amount is used directly as read from the charges file. The year to date amount charged is the sum of the current amount charged with the previous year to date total from the patient's record in the master file. The amount billed to the insurer is the product of the current amount charged and the insurance coverage percentage from the patient's record. The amount billed to the patient is the difference between the total charge and the amount billed to insurance. The corresponding year to date amounts are updated in the patient's record in the obvious way.

The charges shown on the invoice are merely a repeat of the current amount charged to the patient, thr prvious total balance, and the new total balance.

Statements are generated for all patients with valid new charges, even if the amount billed to the patient is zero. In this case the current amounts charged would simply be zero.

At the end of the Statement Log File is to appear a summary report in the following format (the data values shown are for illustration purposes only; the date following "Report Created on:" is supplied by TIMER07.PAS. Note also how the money amounts are formatted in the proper US style, but this is not required in the body of the Statement log; see the reference section of Program 6):

===============================================================
   Report Created on:                             5/17/2001
   Total number of patients in this report:           21
   Total of all current charges in this report:  $4,947.95
   Total of all totals due in this report:       $5,843.85
===============================================================
   End of Report
Build this program in stages (see detailed time chart at the end of this handout):
  1. Design your own input data files (SERVICES.DAT, the services file; CHARGES.DAT, the new charges file and MASTER.DAT, the patient master file). At first, have no more than 4-5 records in each. Make sure that the ID fields for each patient record match and that the records in the master file are sorted by patient ID. Initially, make sure the services in the service file are sorted by service code. Do not use complicated data for the remaining fields; use easy, reasonable data values for these fields (some fields should be zero).

  2. Design the main code which will read the input master file and dump the new master file. Your code should do no computation whatever, but copy records in the old file (from their array) into a new master file. In this way you will know that your array input and output routines are working properly.

  3. Using the binary search algorithm, add the procedure which will search for a matching patient record. Add to the main program code to open all input files and match charges to patients. Your code should still do no computation whatever, but should print something trivial (like the patient's name) in the statement file when a successful match occurs. In this way you will know that your input data files are being opened and that the search algorithm is working properly. Also check that the contents of the error log file are correct (that is, that no errors are reported).

  4. Add the code necessary to write records from the charges file without a matching ID field in the master file into the Error log file. Add new records to each input file which do not have corresponding matching records in the other file. Check that these "unmatched" records are processed properly and appropriate entries are made in the Error log file.

  5. Once the binary search code in the main program is working properly and is thoroughly tested, add the necessary procedure(s) and/or function(s) to process patient records whose ID matches a record in the new charges file. Add procedures one at a time and test them thoroughly on your test data files until you are certain that they work correctly. This is the time to write a procedure to search for the charge service code in the services array - because the amount of data is small, use a quit-early linear search.

  6. Finally, after your code works perfectly for an already sorted services file, add the necessary procedure(s) to read the records of this input file, sort them from lowest to highest key, and rewrite the sorted records back to the input file.

You will be given two sets of input data files (PATIENT1.DAT together with CHARGES1.DAT and SERVS1.DAT, plus PATIENT2.DAT together with CHARGES2.DAT and SERVS2.DAT). They will be available sometime on or before Wednesday, May 9. One pair of files will contain no errant records, so should produce a "clean" Error Log file. The other pair of files will contain charge errors of both types and so your Error Log file will contain entries pointing out the problem records.

The only output to the user's screen in this program will be appropriate informational messages only as processing progresses.

Excellent documentation of all procedures, functions and the main code is expected in this program. Significant point deductions will be incurred by programs without appropriate documentation. Include in your main code prologue a table listing by name all procedures and functions used in your program along with a short phrase describing their purpose. Also, be sure each procedure and function has a (mini) prologue of its own.

TURN IN TO THE MCS OFFICE paper copies of the following (using your folder; include a disk with your program source code and copies of all input and output files):

  1. Your documented source code, properly signed on each page.
  2. Copies of the new patient master files obtained from running your program against each pair of input files; label the header pages carefully with an appropriate title (e.g., "New Master File produced using input files PATIENT1.DAT, SERVS1.DAT and CHARGES1.DAT"), your name, section, date, etc.
  3. Copies of the Statement Log file using each pair of input data files, again clearly labeled; each file begins with the banner explained on page 2.
  4. Copies of the Error Log file obtained from running your program against each pair of input files, clearly labeled; each file also begins with a banner as explained on page 2.

There will be no "redos" on this program -- significant point deductions will accrue in lieu of a redo (i.e., an error causing a "redo" = 20% deduction).

Here is a possible work schedule for completing Program 8 correctly and on time (using a two week time line):

TASK/COMPLETION DATE

  1. Design input data files
    April 26
  2. Code main program with array input and dump procedures for master data.
    April 27
  3. Code binary search procedure to match charges with patient records.
    April 28
  4. Test search algorithm against all possible conditions in input files. Check that all output files are being correctly written and/or updated. Be sure bills will be generated for every matching record (but don't calculate them yet). Don't rush this step!!
    Construct banners for Statement and Error Log files.
    April 29,30
  5. Add appropriate messages to user's screen during processing; recheck output one more time
    May 1
  6. Add procedure to find the amounts due for patients with matching records in both PATIENT.DAT and CHARGES.DAT files; thoroughly check that the Statement log is being correctly written and records in Master File are being updated properly (the YTD totals must change!). Add the rounding function to properly control round-off errors to cents. This is one of the hardest sections of the program; once past here, the other parts go much more quickly.
    May 2-4
  7. Add procedure to find the service description; make sure to test for all possible conditions, and check that log files are being properly written. The timing of when you use this procedure is important - an invalid service code means an invalid charge. Double check all computations by hand!!!
    May 5
  8. Take a break - you've earned it!
    May 6
  9. Add code necessary to create the summary report at the end of the Statement Log. Check carefully by hand!
    May 7
  10. Add code to sort the records in the SERVICES.DAT file.
    May 8
  11. Update documentation in your code.
    May 9-10
  12. Download data; create required output reports and program listings.
    May 11

FAQs:

  1. Are there informational banners at the top of the updated Master File?
    NO. The updated Master File is to contain nothing but the records for each patient as processed by the program. That is, the new master file produced today should be accetible as input for the program tomorrow.

  2. What should the body of the Error Log file look like?
    Here are some typical entries in an Error Log file generated from a program run:
       55555  5  40.0
       Error in new charges file.
       No matching record in Patient Master File
    
       11111  23  40.0
       Error in new charges file.
       No matching service in Services File
    
  3. Should the Error Log file contain a summary report?
    No, but you may include one similar to the summary report in the Statement Log for extra credit (5 points).

  4. How should we sort the services file records?
    Choose any sort algorithm you would like to use (bubble sort is NOT permitted, of course), write a procedure to perform the sort, open the file you wish to sort, read the file into an appropriate structure, close the file, and perform the sort.


Return to
CS-171
Home Page
    Return to
UW-W
Home Page
   
This page last updated
26 April 2001