Editing Second level Case

Discussions about CSEntry
Post Reply
Jadee

Editing Second level Case

Post by Jadee »

I have two level dictionary, FirstLevel and Secondlevel. I am finding it difficult to edit cases in the secondlevel.
I have 6 cases for the secondlevel but when i try to modify let say secondlevel case with ID 3 it sents me to section 5 of the Firstlevel.
Please how can i resolve this case.

Secondly i have a field TQ (Total Questinnaires for Secondlevel) in the First level, i want a situation that LN (Incremental ID) of the secondlevel if it equal to the TQ, that case endlevel (A new Firstlevel Start). TQ=LN.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Editing Second level Case

Post by josh »

Could you post you application and a sample data file along with the exact steps to reproduce the problem?
Jadee
Posts: 2
Joined: January 29th, 2015, 12:00 pm

Re: Editing Second level Case

Post by Jadee »

Dear Josh,
I have attached the application and the following are my challenges:
1. From the data attached if i want to edit case 032032032032 secondlevel (ExitQ) 2. the application send me A05 instead of EXIT LN 2.
If i try edit manuelly the LN do not appear.

2. Also want a situation that if A14 is equal to LN then a case (Firstlevel) starts.
I hope you can review the application for me with the necessary corrections.

Thanks
Attachments
RHCSTRY.rar
two level dict
(43.66 KiB) Downloaded 388 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Editing Second level Case

Post by josh »

When I try your application and open 032032032032 in modify and try to go to the ExitQ I end up getting an out of range error on the interviewer ID field (A02) because the interviewer code is not in the value set for this item. When you try to advance to the second level case, CSEntry will stop you if it finds any errors in the first level items. You either need to add the missing code to the value set or modify the value that was entered to be a valid code.

I'm not sure how to do number 2. Maybe someone with more experience with 2 level applications will respond.
Jadees

Re: Editing Second level Case

Post by Jadees »

Hi Josh
Issue one is still not resolved, I want to be able to edit ExtQ level case. For example 032032032 i want to modify ExtQ 4 ( Which is the secondlevel)
but if i try it does not send me to the ExQ rather a field in the First level.
Thanks for the assisting me.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Editing Second level Case

Post by josh »

It is going to stop at any field in the first level that has an invalid value - i.e. any field whose value is not in the value set. This includes any field that is blank unless blank (NOTAPPL) is in your value set. There are a lot of blank entries in the first level of that case so you would need to enter non-blank values or add NOTAPPL to the value sets for those fields.

Looking at your application I don't see why you need two levels. All your records in both the first and second levels are singly occurring so you could combine the second level (ExitQ) records into a one record with multiple occurrences. Then you won't have this problem anymore and it would be easier to solve your second question too. The only problem is that you will have to convert any existing data into the new format which will require a batch application to read the old format and write out the new one.
Jadee
Posts: 2
Joined: January 29th, 2015, 12:00 pm

Re: Editing Second level Case

Post by Jadee »

Hi Josh
Pls can you help me with the Batch edit app as you suggested
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Editing Second level Case

Post by josh »

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.
Post Reply