Conditional GraphQL query return unexpected interviews

SS Team,
I’ve been using GraphQL API to get some information on the interviews on our Survey Solutions Server (22.06.7 build 32810) and I found some issues on a specific query.
Query filters interviews based on the value of a exposed variable. This variable is a string. The query goes as follows:

The issue is that the response comes not only with the interviews that match the condition but also the ones in which the variable is NA (Because in some interviews this variable is blocked by a conditioned subsection). I tried adding more exclusive conditions like:

neq: null

The results are the same. would you guide me if I’m doing something wrong with the query?

Thanks in advance

To test for unanswered questions (NA), include a condition like this:

     identifyingData: {  
   none : {
     entity : { variable: {eq: "..."}}
   }
 }

instead of neq: null

Greetings @pcarrd ,
I tried to reproduced the issue you had described, but my query returned interviews that matched it. Could you please create some similar example on the Designer and reproduce the defect on the Demo server.
Also, current version of Survey Solutions is 22.12.1 and you use 22.06.7, perhaps the issue is not reproduced anymore.

@pcarrd, one more assumption:
If the sub-section with the variable was enabled/unenabled it could affect the result. In this case, please, use isEnabled flag, like in the example below

          identifyingData: {
            some: {
              entity: {
                variable: {
                  eq: "..."
                }
              },
              isEnabled: {
                eq: true
              },
              value: {
                contains: "..."
              }
            }
          }

Hi,
I’ve been able to reproduce the issue to know the cause. I’ll explain what I did:

  1. I created a questionnaire with 1 question on the cover page and 1 section with 1 question and 1 variable in it. The section enabling condition is to answer the question on the cover Page. The variable calculates a value based on the question in the same section.
  2. The imported questionnaire is configured to have both question and variable as exposed variables. Then, I created three interviews:
    2.1 The first interview I answer only the question on the cover page.
    2.2 The second interview I answer both the question on the cover page and the question on the section.
    2.3 The third interview I answer both questions, but I delete the answer to the question on the cover page, blocking the section.

Now, If I use graphQL to get the interviews with certain value on the section question (Specifically, the value registered on the 2.3), I’m able to get that interview even when the section is blocked.

So, when I’m searching for interviews where an exposed variable has a certain value, the response is going to give me the interviews in which that question has a registered answer, without considering the status of the section that contains it.

src:
Questionnaire: https://demo.mysurvey.solutions/jan23/Questionnaires/Details/4f727707-2116-44a0-bb15-5805ad9e0e4d$1

Assignment: https://demo.mysurvey.solutions/jan23/Assignments/249

@pcarrd thank you for this scenario. Using isEnabled flag will help to remove the third interview from the result. Please take a look at my previous comment.

I followed your advice and it didn’t change the outcome. This is the query I’ve used.
image

PS: The enabling condition is in the section, not in the question or the variable itself. Does this affect on the column ‘isEnabled’?

Dear @pcarrd,

I was able to reproduce the issue. Thank you for the example on the Demo. You can track the fixing progress here.

As for you current situation, I could suggest a workaround. Just simulate the enabled condition (IsAnswered(today)) of the section in the your query. It removes extra interview from the result. Something like this:

		where: {
			questionnaireId: {eq: "4f727707-2116-44a0-bb15-5805ad9e0e4d"}
			questionnaireVersion: {eq: 1}
			and: [ 
						{
							identifyingData: {
							some: {
								entity: {
									variable: {eq: "month_spa"}
								}
								value: {
									contains: "RO"
								}
								isEnabled: {
            		    	eq: true
          			}
							}
						}
					},
					{
						identifyingData: {
						some: {
							entity: {
								variable: {eq: "today"}
							}
							valueDate: {
								neq: null
							}
						}
					}					
				}
			]			
		}
1 Like