Page 1 of 1

Duplicate Household Head Name

Posted: January 4th, 2024, 3:37 am
by YFT_CBSD
Hi,

What function can i use to display the duplicate household head name but different case id? This is a batch editing application.

For example.

140012
HHHead Name: Joe Coe

140013
HHHead Name: Joe Coe

Thanks. In advance

Re: Duplicate Household Head Name

Posted: January 4th, 2024, 7:51 am
by Gregory Martin
How about using the HashMap object: https://www.csprousers.org/help/CSPro/HashMap.html

Something like:
HashMap string hhNames(string);

if hhNames.contains(HH_NAME) then
    errmsg
("'%s' already encountered in case '%s'", HH_NAME, hhNames(HH_NAME));

else
   
// associate the household name with the case ID
   
hhNames(HH_NAME) = key(DICT_NAME);

endif;

Re: Duplicate Household Head Name

Posted: January 18th, 2024, 2:22 am
by YFT_CBSD
Thanks, the code is working.

Additionally i want to printout the age of John in case 140013, it should appear in 140012 errror message, how can i do this?

errmsg("'%s' already encountered in case '%s'", HH_NAME, hhNames(HH_NAME));

Case [140012] has 1 messages (0 E / 0 W / 1 U)
U -'Joe Coe' already encountered in case 140013

Re: Duplicate Household Head Name

Posted: January 18th, 2024, 7:54 am
by Gregory Martin
You can use the same idea of storing the name, but also have a variable with the ages.
HashMap numeric hhAges(string);

// ...

errmsg("'%s', aged %d, already encountered in case '%s'", HH_NAME, hhAges(HH_NAME), hhNames(HH_NAME));