ID-177: Verify all required questions are answered in $next-question requests - #90
Open
abhinandan2012 wants to merge 1 commit into
Conversation
abhinandan2012
force-pushed
the
ID-177-next-question-required-questions-answered
branch
from
July 28, 2026 16:19
24add47 to
dcb2551
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Partial implementation of requirement spec-146: the DTR client must not indicate that the user is ready for the next question until the answers in the current QuestionnaireResponse pass validation rules. This adds a check that every required question in the QuestionnaireResponse sent to
$next-questionhas been answered.Changes
Factored the QuestionnaireResponse completeness logic out of the v2.2.0
$next-questionserver simulation into a new shared module,DaVinciDTRTestKit::QuestionnaireResponseCompleteness(lib/davinci_dtr_test_kit/cross_suite/v2.2.0/questionnaire_response_completeness.rb). It exposescontained_questionnaire,questionnaire_response_complete?andunanswered_required_link_ids.MockPayer::FullEHRV220NextQuestionEndpointnow includes the module rather than carrying its own copy of the logic. Behavior is unchanged, including treating a booleanfalseas a valid answer and only marking a QuestionnaireResponse ascompletedwhen no new questions were disclosed.DTRFullEHRV220NextQuestionRequestValidationTestnow uses the same module to verify each$next-questionrequest body. The QuestionnaireResponse is taken from either theParameterswrapper or a bare QuestionnaireResponse body, and the required items in its contained Questionnaire are checked against the answers present. Unanswered required questions are reported per request:A QuestionnaireResponse with no contained Questionnaire reports that the check could not be
performed. The test declares
verifies_requirements 'hl7.fhir.us.davinci-dtr_2.2.0@spec-146'.Note that
enableWhenconditions are not taken into account, so a required question is expected tobe answered even when its enabling condition is not met. This matches the existing behavior of the
server simulation and is documented in the module and in the test description.
Tests
New spec
spec/davinci_dtr_test_kit/dtr_full_ehr_v220_next_question_request_validation_test_spec.rbcovers the initial request with no questions disclosed yet, a fully answered form, an unanswered
required question, request numbering across multiple requests, a bare QuestionnaireResponse body, a
required question nested under an answered question, a missing contained Questionnaire, unanswered
optional questions, and a boolean
falseanswer.Requirements coverage is unchanged (
bundle exec inferno requirements check_coverage dtr_full_ehr_v220reports the coverage CSV is up to date). spec-146 appears in the existing warning list of requirements
not present in the suite's requirement sets, because
requirement_setsis still commented out indtr_full_ehr_suite.rbfor the v2.2.0 suite.Test IDs
dtr_full_ehr_v220_nq_request_validation, shown as 2.2.3.01 Next Question request is validdtr_full_ehr_v220-dtr_full_ehr_basic_workflows-dtr_full_ehr_v220_workflow_adaptive-Group03-dtr_full_ehr_v220_nq_request_validationdtr_full_ehr_v220_workflow_adaptive, shown as 2.2 Adaptive Questionnairebundle exec rspec spec/davinci_dtr_test_kit/dtr_full_ehr_v220_next_question_request_validation_test_spec.rbbundle exec rspec spec/davinci_dtr_test_kit/full_ehr_v220_next_question_endpoint_spec.rbWhere to verify in the UI
Da Vinci DTR Client Test Suite v2.2.0 -> 2 Basic Workflows -> 2.2 Adaptive Questionnaire ->
2.2.3 $next-question -> 2.2.3.01 Next Question request is valid -> MESSAGES tab. The new
check appears as an error message prefixed with the request number. The REQUESTS tab of the same
test shows the
$next-questionbodies the messages refer to.Note that with hand made request bodies this test also reports profile conformance errors, so the
result is red either way. The item to verify is the presence or absence of the
"All required questions must be answered" message.
UI testing steps
Start a session on the Da Vinci DTR Client Test Suite v2.2.0 with the SMART Backend Services
client type, and select the "Run Against the Client Simulation Suite" preset so the Client Id is
set to
demo.Run 1 Client Registration and complete the attestation so the Client Id is available to the
rest of the session.
Select 2.2 Adaptive Questionnaire and click RUN TESTS. The Questionnaires wait dialog appears.
Send a
$questionnaire-packagerequest followed by two$next-questionrequests, where the secondone repeats the form returned by the first without answering the questions that were disclosed:
The
session_pathquery parameter identifies the session without an access token. It also causesthe existing request URL check to report a wrong URL, which is expected with this shortcut.
Click the continuation link in the wait dialog, then the rendering attestation link.
Open 2.2.3.01 and check the MESSAGES tab. Request 2 reports
PBD.1,PBD.2andLOC.1asunanswered required questions.
To confirm there are no false positives, repeat steps 1 to 6 in a new session, but add answers for
PBD.1andPBD.2under thePBDgroup andLOC.1under theLOCgroup in the third requestbody. The message is no longer reported.
Running the client and server suites against each other
The paired presets let the Client Simulator Suite drive the Client Test Suite, which exercises the
passing path of this check without a real client, because the simulated client answers each disclosed
question before requesting the next one.
"Run Against the Client Simulation Suite". Run 1 Client Registration, then select
2.2 Adaptive Questionnaire and click RUN TESTS so Inferno waits for requests.
The preset points the Payer FHIR Server Base Url at
<base_url>/custom/dtr_full_ehr_v220/fhirand uses client iddemo. Run 1 Backend Servicesto obtain a token, then run 2 Payer serves Questionnaires, which sends the
$questionnaire-packageand$next-questionrequests to session A."All required questions must be answered" message is reported for these requests.
UI proof
Test 2.2.3.01 reporting the unanswered required questions for the second
$next-questionrequest:Location of the test in the Adaptive Questionnaire group:
The same test for a flow where the disclosed questions were answered. Only profile conformance errors
remain and the completeness message is not present: