After looking a bit more closely at it the batch application will be a bit tricky. If you aren't very comfortable with CSPro you may want to stick with the two level application and just fix the issues with the invalid entries and blanks.
If you are comfortable in CSPro then here is how I would convert the dictionary and data file:
1) First create an intermediate dictionary that has both the 2nd level and a new multiply occuring record in the first level to copy the second level into.
a) Make a copy of your dictionary and rename the file to something like intermediate.dcf.
b) Open this dictionary in CSPro and add a new record in the first level called ExitQ. Make it not required and allow multiple occurrences (set max to some number big enough to hold the maximum number of exit questionnaires).
c) Add new Questionnaire number field (in addition the Questionnaire number id item) to this record. It should be length 2 just like the existing one.
d) Copy the all items from the MODWM record in the second level to the new ExitQ record. Select all the fields that you just pasted into the ExitQ record and convert them to an alpha subitem named NEW_MODWM. You may need to remove any existing subitems first.
e) In the original MODWM record in the second level, remove the subitems and convert all the fields to a single alpha subitem named OLD_MODWM.
f) Repeat steps d and e for the other two second level records. Your ExitQ should now have four items: Questionaire number, NEW_MODWM, NEW_MODRB, NEW_MODCA.
2) Create a batch application using the intermediate dictionary to copy from the 2nd level to the first level.
a) Add code to copy from the second level records to the new first level multiply occuring recurring record. It should go in the PROC for the second level (EXT). Something like this (warning not tested):
Code: Select all
PROC EXT
// This gets called once for each second level occurrence
// so each time it is called we want to create a new
// occurence of ExitQ and copy the from the second level
// records into ExitQ
// Compute index of next ExitQ record.
numeric nextExitQNum = totocc(EXITQ_EDT) + 1;
// Add the new ExitQ record occurence
insert(EXITQ_EDT(nextExitQNum));
errmsg("Inserted exitQ %d", nextExitQNum);
// Copy from 2nd level to new ExitQ occurrence
LN2(nextExitQNum) = LN; // LN2 is new variable for questionnaire number
NEW_MODWM(nextExitQNum) = OLD_MODWM;
NEW_MODRB(nextExitQNum) = OLD_MODRB;
NEW_MODCA(nextExitQNum) = OLD_MODCA;
// Delete the 2nd level records that we don't need anymore
delete(MODWM_EDT);
delete(MODRB_EDT);
delete(MODCA_EDT);
b) Run this batch application with your existing data file as the input and a new data file (intermediate.dat) as the output.
3) Create a final one-level dictionary that doesn't have the second level.
a) Make a copy of the original dictionary with the same name as the original dictionary but put in a different folder.
b) Create the ExitQ record, giving it the same name and record type as you did in the intermediate dictionary.
c) Copy the items from the second level records as you did before but this don't delete the subitems or convert them to subitems.
d) Delete the second level
4) Reformat from the intermediate dictionary to the final one-level dictionary.
Use the CSPro Reformat data tool with the intermediate dictionary and intermediate data file as input and with the final dictionary and a new data file as output.
Now you have a one-level data file and dictionary with your original data transformed to fit. You can now create a copy of your original data entry application and replace the dictionary with your final dictionary from step 3. Unfortunately once you open the copy of the data entry application that uses the new dictionary, CSPro will delete the forms corresponding to the 2nd level records since those records no longer exist. You will have to recreate them.
As I said, this is not an easy thing to do. If you didn't have existing data to deal with I would certainly recommend it, but converting the data makes it challenging enough that I might not bother if I was you.