Program MERGE1

The purpose of Program Merg1 is

To execute Program Merg1, after the >>? prompt type

>>? RUN MERG1

Program Merg1 responds THE SCI PROGRAM MERG1 ENTER 4 FILE NAMES ?

Program MERG1 asks for two input file names and two output file names. 1. input file name 1 2. input file name 2 3. output file name 1 4. output file name 2

Program MERGE1 is a file specifically intended to work in the MOMS system to read two input file names and to produce two output file names. It is presumed that we are dealing with a master file of patient data records for the purpose of making corrections or additions to it. This program is set up so that in the event of a duplicate record, the second will be discarded. The program works as follows. After the two input files and two output files are opened, the program reads a record from file number 1, it reads a record from file number 2. In the event the last name field is blank, the record is discarded and another record is read from the appropriate file and put in its place. As soon as two records are readied, the program looks into the patient ID field. In the event the ID is same for the record from file 1 and the record from file 2, then the record from file 2 is discarded and another record is read from file 2. In the event the record from file 1 is lexigraphically less than that of file 2 then the record from file 1 is written to the output file and the record is replaced by reading another record from file 1. In the event the record from file 2 is less, then it is written to the output file and this process is carried out until the contents of both files are exhausted. One problem could arise. As the program is writing the chosen record it keeps track of the contents of the patient ID that has been written. In the event that the new record to be written is less than that which has been written before (implying that one of the two input files was not sorted, it is written not to file 3 which has been the output file all along but to file 4). This program will produce two output files. The sum of the two will equal the sum of the two input files. The fourth file name, the second output file name contains only records that were found to be out of sorting order. If file 1 and file 2 were both properly sorted, then file 4 will be empty when this program goes to completion. This program is specifically intended as the merge program for taking an existing patient data file and merging it with the files PATIENTS.DC and PATIENTX.DA which have been created during the time period. In the event a record was modified in PATIENTS.DA it is written on line to both PATIENTS.DA and PATIENTS.DC. This is the reason that in the event of a tie, the record from file 2 (PATIENTS.DC) is discarded. The reason this file is even included is in the event of a certain type of massive failure, the CYYDDD for the appropriate periods can be read in and appended and nightrun can be executed to rebuild from some backup point a PATIENTS.DA.