Page 1 of 1

Count Partially Saved Cases

Posted: August 6th, 2019, 2:02 pm
by khurshid.arshad
Dear Cspro Team

How can I track number of partially saved cases during listing exercise? In desktop application we have log file but not in the tablet.

Actually, I want to restrict enumerator to save partially not more than 3 cases. For instance, enumerator already entered 30 cases with 3 partially and now he cannot enter new cases because there are already 3 partially cases. At this point enumerator needs to complete at least 1 case out of 3 to start new case.

Best Regards.
a.

Re: Count Partially Saved Cases

Posted: August 6th, 2019, 3:52 pm
by josh
You can use the ispartial() function to determine if a case is partially saved. So if you have a menu program you could use a forcase to loop through all the cases and count the number that are partial.

Re: Count Partially Saved Cases

Posted: August 7th, 2019, 7:05 am
by khurshid.arshad
Dear Josh

I have menu program but listing is a continuous process in this application. The issue is that the application is not quitting after each entry. This is our protocol.

I am using the forcase statement without quitting the application. What I am doing, before start of every entry, I close the csdb file from the main dictionary and set it with external dictionary to count partially saved case with forcase statement in the listing application. After that, again close the csdb file from the external dictionary and set with the main dictionary. If partially save cases are <3 then it is okay, Otherwise I cannot start new entry.

However, I am worried that between the open and close function somewhere we may lose the data.

Please Advise.

Best Regards.
a.

Re: Count Partially Saved Cases

Posted: August 7th, 2019, 7:12 am
by josh
I'd be worried about using open/close on the main dictionary too. It is something I have never tried. If you test and it works though then that is certainly the easiest solution. If you are doing this at the start of a new case it seems like it should be safe since the previous case will already have been written to the data file. Just make sure the file is open again before you do any partial saves.

The alternative is to lock the case listing in your listing application and return to the menu after each case to count the partial cases. I would then implement my own version of the case list in the menu program using a dynamic value set.

Re: Count Partially Saved Cases

Posted: August 10th, 2019, 4:29 am
by khurshid.arshad
Dear Josh

Now, I am doing something else.

I am using WriteCase Function to store partially save case lflinformation in external dictionary.

I need your suggestion.
Best Regards.
a.

The syntax are as follows:

Code: Select all


function onstop()

	setfile(LFLISTING_DICT, concat("..\..\106_Ext_Data\LFL-", edit("9999999",Pro_Code),"-",Enu_Code, ".txt"));
	LFL_PROCESSING_CODE=L_PROCESSING_CODE;
	LFENU_CODE=ENU_CODE;
	LFHOUSE_NUMBER=HOUSE_NUMBER;

	if accept ("Do You Want Save Interview Partially?", "No, Exit without Save Partially","Yes, Save This Case Partially")=2 then
		if savepartial() and demode()=1 or savepartial() and demode()=2 then 
			LFL_STATUS=1;//1: this case is partially saved
			writecase(LFLISTING_DICT);
			close(LFLISTING_DICT);
		else 
			delcase(LFLISTING_DICT,LFL_PROCESSING_CODE,LFENU_CODE,LFHOUSE_NUMBER);
			close(LFLISTING_DICT);
		endif;
	else
		close(LFLISTING_DICT);
		stop(0);
	endif;

end;

This is the First Variable in this listing application.

Code: Select all


PROC PROVINCE_CODE
onfocus

	{****        LOAD EXTERNAL DICTIONARY          ******}
	{****        CHECK PARTIALLY SAVE CASES        ******}
	{****************************************************}
	{Use External dictionary to write information of partially cases}	
	

	incompleteHouseholds=0;

	FindResult = fileexist (concat("..\..\106_Ext_Data\LFL-", edit("9999999",Pro_Code),"-",Enu_Code, ".txt"));

	if FindResult=1 then
		setfile(Lookupfilelisting, concat("..\..\106_Ext_Data\LFL-", edit("9999999",Pro_Code),"-",Enu_Code, ".txt"));

		while fileread (Lookupfilelisting,PreLoad_Data) do;
			if PreLoad_Data[1:1]="~" then
			else
			inc(incompleteHouseholds);
			endif;
		enddo;

		Close (Lookupfilelisting);

	else
		{if external file does not exist}
		setfile (Lookupfilelisting, concat("..\..\106_Ext_Data\LFL-", edit("9999999",Pro_Code),"-",Enu_Code, ".txt"),create);
	endif;


	if demode()=1 and incompletehouseholds>=3  & not ispartial() then
		set errmsg (operator);
		errmsg ("First, finish partially saved cases.\n\nAfter that, you can start new interview.");
		 set errmsg(default);
		stop(0);
	else
	endif;

		Advance to House_Number;




This is the last variable.

Code: Select all

PROC L_ENU_COMM

	{On the last variable: If partially case info exist then delete the info because now this is a complete case}

	setfile(LFLISTING_DICT, concat("..\..\106_Ext_Data\LFL-", edit("9999999",Pro_Code),"-",Enu_Code, ".txt"));

	LFL_PROCESSING_CODE=L_PROCESSING_CODE;
	LFENU_CODE=ENU_CODE;
	LFHOUSE_NUMBER=HOUSE_NUMBER;

	delcase(LFLISTING_DICT,LFL_PROCESSING_CODE,LFENU_CODE,LFHOUSE_NUMBER);
	close (LFLISTING_DICT);


Re: Count Partially Saved Cases

Posted: August 10th, 2019, 5:05 pm
by josh
I'm not sure what exactly you need my help with here. Is this not working?

Just looking quickly at your logic I would recommend putting the logic you have for PROVINCE_CODE in the preproc of the level instead of the onfocus of the first field so that it won't get called twice if the interviewer moves backward. Also in that routine, since your lookup file is data file you could forcase or countcases instead of fileread. If you do that you can avoid all the opening and closing of the lookup file since you can just leave it open the whole time.

Similarly you could put the logic in L_ENU_COMM in the postproc of the level too.

Re: Count Partially Saved Cases

Posted: August 23rd, 2019, 8:41 am
by khurshid.arshad
Dear Josh


The syntax is working fine but i need your technical input in this regards, which i have got from your last post.

As you have mentioned that use "forcase or countcases instead of fileread", i have tried to use forcase or countcases but did not succeed.

My external file is in text format. I am saving very basic information in this file to count partially saved cases at run-time.

I have shared my application on the following email address: "'cspro@lists.census.gov'".

Please advise.

Best Regards.
a.

Re: Count Partially Saved Cases

Posted: August 23rd, 2019, 9:20 am
by josh
You can just do something like this:

setfile(LFLISTING_DICT, concat("..\..\106_Ext_Data\LFL-", edit("9999999",Pro_Code),"-",Enu_Code, ".txt"));
incompleteHouseholds = countcases(LFLISTING_DICT);

Then you don't need all the closing and opening of the file.

Re: Count Partially Saved Cases

Posted: August 23rd, 2019, 12:19 pm
by khurshid.arshad
Working perfectly.
Thank you.
a.