getvaluelabel

Discussions about CSEntry
Post Reply
VirtuesArios
Posts: 35
Joined: June 2nd, 2022, 5:55 am

getvaluelabel

Post by VirtuesArios »

Hello CSPro users,

I've just wanna ask on how to get value label its on the attached images, what I want to get is the name of the illness but it seems the value came out is AB..so on. Any suggestion would be highly appreciated, Thanks in advance.

Images:
1. Dictionary
2. CAPI Questions
3. Above Image (Choices)
4. Below Image (Results)
You do not have the required permissions to view the files attached to this post.
Gregory Martin
Posts: 1947
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: getvaluelabel

Post by Gregory Martin »

The getvaluelabel function isn't looking at the capture type (checkbox), so it's not formatting your checked options appropriately. You can do something like this in your question text: ~~GetCheckboxLabel()~~

And then add a user-defined function:
function string GetCheckboxLabel()
   
    string labels;
   
    do numeric ctr = 1 while ctr <= I1MULTI_VS1.codes.length()

        if ischecked(I1MULTI_VS1.codes(ctr), I1MULTI) then

           
// add a comma between each entry
           
if labels <> "" then
               
labels = labels + ", ";
            endif;
           
            labels = labels + I1MULTI_VS1.labels(ctr);

        endif;
       
    enddo;

    exit labels;

end;
Last edited by Gregory Martin on November 6th, 2023, 1:17 pm, edited 1 time in total.
VirtuesArios
Posts: 35
Joined: June 2nd, 2022, 5:55 am

Re: getvaluelabel

Post by VirtuesArios »

Gregory Martin wrote: September 26th, 2023, 9:28 am The getvaluelabel function isn't looking at the capture type (checkbox), so it's not formatting your checked options appropriately. You can do something like this in your question text: ~~GetCheckboxLabel()~~

And then add a user-defined function:
function string GetCheckboxLabel()
   
    string labels;
   
    do numeric ctr = 1 while ctr <= I1MULTI_VS1.codes.length()

        if ischecked(I1MULTI, I1MULTI_VS1.codes(ctr)) then

           
// add a comma between each entry
           
if labels <> "" then
               
labels = labels + ", ";
            endif;
           
            labels = labels + I1MULTI_VS1.labels(ctr);

        endif;
       
    enddo;

    exit labels;

end;
Thank you Gregory Martin for replying to my problem and I am sorry it takes me long to reply, but it seems when I try to apply the code that you give me it return blank.
sherrell
Posts: 407
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: getvaluelabel

Post by sherrell »

Greg is out this week so let me respond. I haven't used the codes and labels feature, but it should be working. In the interim, you can do this, which is working for me:
function string GetCheckboxLabel()
  
    string labels;
   
    do numeric ctr = 1 while ctr <= length(strip(I1MULTI)) // I1MULTI_VS1.codes.length()
   
       
alpha(1) letter = I1MULTI[ctr:1];
       
        if ischecked(letter, I1MULTI) then
       
           
// add a comma between each entry
           
if labels <> "" then
               
labels = labels + ", ";
            endif;
          
            labels = labels + getlabel (I1MULTI, letter);
        endif;
       
    enddo;
   
    exit labels;
end;
VirtuesArios
Posts: 35
Joined: June 2nd, 2022, 5:55 am

Re: getvaluelabel

Post by VirtuesArios »

Thanks sherrell for the response.
sherrell wrote: October 9th, 2023, 9:14 pm Greg is out this week so let me respond. I haven't used the codes and labels feature, but it should be working. In the interim, you can do this, which is working for me:
function string GetCheckboxLabel()
  
    string labels;
   
    do numeric ctr = 1 while ctr <= length(strip(I1MULTI)) // I1MULTI_VS1.codes.length()
   
       
alpha(1) letter = I1MULTI[ctr:1];
       
        if ischecked(letter, I1MULTI) then
       
           
// add a comma between each entry
           
if labels <> "" then
               
labels = labels + ", ";
            endif;
          
            labels = labels + getlabel (I1MULTI, letter);
        endif;
       
    enddo;
   
    exit labels;
end;
VirtuesArios
Posts: 35
Joined: June 2nd, 2022, 5:55 am

Re: getvaluelabel

Post by VirtuesArios »

Hi sherrell, I was just wondering it works on the first and second checkbox(e.g. Diabetes and Heart disease) but when I change the answer to another illness it would only display one illness or it would not display at all, what would I change for this to work on all checkbox.
sherrell wrote: October 9th, 2023, 9:14 pm Greg is out this week so let me respond. I haven't used the codes and labels feature, but it should be working. In the interim, you can do this, which is working for me:
function string GetCheckboxLabel()
  
    string labels;
   
    do numeric ctr = 1 while ctr <= length(strip(I1MULTI)) // I1MULTI_VS1.codes.length()
   
       
alpha(1) letter = I1MULTI[ctr:1];
       
        if ischecked(letter, I1MULTI) then
       
           
// add a comma between each entry
           
if labels <> "" then
               
labels = labels + ", ";
            endif;
          
            labels = labels + getlabel (I1MULTI, letter);
        endif;
       
    enddo;
   
    exit labels;
end;
sherrell
Posts: 407
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: getvaluelabel

Post by sherrell »

I've made two passes.

In the first app, you can pass a pointer to a function that makes the evaluation, but you'll just need to create a function for each variable you want to analyze.

In the second app (v2, after consult with Greg :) ), you can pass a valueset in as a function argument. However since the variable is a string, we have to identify the valueset as being for a string, not numeric (as it expects by default).

Sherrell
You do not have the required permissions to view the files attached to this post.
Post Reply