Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to generate test/dummy questionnaire responses #15

Closed
4 tasks
Wambere opened this issue Aug 10, 2023 · 10 comments · Fixed by #71 or #259
Closed
4 tasks

Add support to generate test/dummy questionnaire responses #15

Wambere opened this issue Aug 10, 2023 · 10 comments · Fixed by #71 or #259
Assignees
Labels
efsity FCT features

Comments

@Wambere
Copy link
Contributor

Wambere commented Aug 10, 2023

Overview
Some projects have a lot of questionnaires, with this functionality it will be possible to quickly generate questionnaire responses which can be used to test the extraction of resources, validation of app configs etc

Currently this is done manually

We can use tools like java-faker or datafaker to help with the actual dummy data generation

The result needs to account for special cases like skip logic. For example if one question asks for the gender and there is a subsequent question that is only relevant to female responders, that answer should only be answered when expected.

We would also want to extract and validate the data after generation. For valiation we can ideally use the same implementation from validate fhir resources

Implementation spec.
Add a new sub command generateResponses to efcity

sample commands:

fct generateResponses -i /path/to/questionnaire 

input

  • The questionnaire resource
  • Flag is -i and --input as an alias

output

  • A valid questionnaire response resource

Acceptance Criteria

  • New sub command generateResponses added, taking in a path to a questionnaire resource
  • Documentation for the command added to the README
  • Extraction and validation of this newly generated questionnaire response
  • Unit tests (Framework and status checks to be set up*)

Resources


@ndegwamartin ndegwamartin added the efsity FCT features label Aug 10, 2023
@Wambere Wambere self-assigned this Aug 30, 2023
@Wambere
Copy link
Contributor Author

Wambere commented Oct 25, 2023

Leaving this open because I'm still looking into using Questionnaire/$populate as an alternative option

@Wambere Wambere reopened this Oct 25, 2023
@Wambere
Copy link
Contributor Author

Wambere commented Nov 3, 2023

The $populate is part of the Clinical Reasoning module on the HAPI FHIR server as mentioned here. Basically, the operation "generates a QuestionnaireResponse based on a specific Questionnaire, filling in answers to questions where possible based on information provided as part of the operation or already known by the server about the subject of the Questionnaire". The operation is also defined on the FHIR website here including a bit more detail such as a list of the required parameters when making the request.

To get more detail of how this actually works, checkout the Form Population page which talks about the 3 distinct operations under the populate umbrella, the population modes, how to design Questionnaires to support the operation etc

@Wambere
Copy link
Contributor Author

Wambere commented Nov 3, 2023

In order to test this out,

  • I enabled the CR module in the applications.yaml file (Note that this is on the hapi-fhir-jpaserver-starter master branch, not on tagged release yet). (As mentioned in the comment just above this line) This will include the evaluate measure operations, but not any of the questionnaire ones
  • When the above is enabled, from the logs we can see the Measure operation providers loaded like below
2023-11-02 10:30:36.779 [main] INFO  ca.uhn.fhir.cr.config.ProviderLoader [ProviderLoader.java:53] loading provider: class ca.uhn.fhir.cr.r4.measure.MeasureOperationsProvider
2023-11-02 10:30:36.780 [main] INFO  c.uhn.fhir.rest.server.RestfulServer [RestfulServer.java:1776] Added 1 plain provider(s). Total 8
2023-11-02 10:30:36.780 [main] INFO  ca.uhn.fhir.cr.config.ProviderLoader [ProviderLoader.java:53] loading provider: class ca.uhn.fhir.cr.r4.measure.SubmitDataProvider
2023-11-02 10:30:36.780 [main] INFO  c.uhn.fhir.rest.server.RestfulServer [RestfulServer.java:1776] Added 1 plain provider(s). Total 9
2023-11-02 10:30:36.781 [main] INFO  ca.uhn.fhir.cr.config.ProviderLoader [ProviderLoader.java:53] loading provider: class ca.uhn.fhir.cr.r4.measure.CareGapsOperationProvider
2023-11-02 10:30:36.781 [main] INFO  c.uhn.fhir.rest.server.RestfulServer [RestfulServer.java:1776] Added 1 plain provider(s). Total 10
import ca.uhn.fhir.cr.r4.questionnaire.QuestionnaireOperationsProvider;
  • Passed in the provider QuestionnaireOperationsProvider thequestionnaireOperationsProvider as a parameter to the restfulServer function
  • Then registered the provider within the same function
fhirServer.registerProvider(thequestionnaireOperationsProvider);

Blocker
With the above however I get the error

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hapiServletRegistration' defined in ca.uhn.fhir.jpa.starter.Application: Unsatisfied dependency expressed through method 'hapiServletRegistration' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'restfulServer' defined in class path resource [ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.class]: Unsatisfied dependency expressed through method 'restfulServer' parameter 10; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'ca.uhn.fhir.cr.r4.questionnaire.QuestionnaireOperationsProvider' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

So it looks like I need to define a Bean somewhere... not sure where

cc @ndegwamartin @dubdabasoduba

@pld
Copy link
Member

pld commented Nov 6, 2023

Do you want to try running from main and see what happens?

@Wambere
Copy link
Contributor Author

Wambere commented Nov 7, 2023

I had tried to build the main branch to deploy locally to test but it's broken, it doesn't even build
I tried a couple other branches and tags but none that included these changes seemed to work
Only available option that I have not yet tried, I think is to actually add needed changes to the latest tag and then deploy a snapshot of that locally

@Wambere
Copy link
Contributor Author

Wambere commented Nov 7, 2023

My guess/assumption though is that it would probably give the same or a related error

@pld
Copy link
Member

pld commented Nov 7, 2023

Yea ok, I think should pause on trying to use $populate then

@pld
Copy link
Member

pld commented Jul 11, 2024

is this complete now?

@Wambere
Copy link
Contributor Author

Wambere commented Jul 15, 2024

@pld not yet, I'll spare some time this week to see if I can close it out

@pld
Copy link
Member

pld commented Jul 15, 2024

No worries, I certainly think this is higher priority, I wasn't sure if this was left open by mistake because I thought I saw documentation that covered this feature when I was using the translation generation in fct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
efsity FCT features
Projects
None yet
3 participants