-
Notifications
You must be signed in to change notification settings - Fork 249
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
Update Customize-how-a-Questionnaire-is-displayed.md #2577
Conversation
Update documentation for custom widget support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks jajoo for fixing our doc!
@aditya-07 made some changes to the custom widget mechanism. @aditya-07 can you also review this doc change? thanks
3. When rendering your questionnaire, use your custom implementation of | ||
<code>QuestionnaireFragment</code> instead. | ||
### 1. Create a factory of custom ViewHolderFactoryMatchersProvider | ||
Develop a class that implements the [QuestionnaireItemViewHolderFactoryMatchersProviderFactory](https://github.com/google/android-fhir/blob/ced8527a5481972591615ad4364487e89130fb6e/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt#L563) interface. This class acts as a registry for associating custom widgets with their corresponding view holder factories. ([example](https://github.com/google/android-fhir/blob/master/catalog/src/main/java/com/google/android/fhir/catalog/ContribQuestionnaireItemViewHolderFactoryMatchersProviderFactory.kt)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your first link goes to QuestionnaireItemViewHolderFactoryMatchersProvider
instead of QuestionnaireItemViewHolderFactoryMatchersProviderFactory. please correct it.
this class actually doesn't act as a registry. it just produces matchers. the registry bit is in the next step.
### 2. Register the above factory with datacapture library via DataCaptureConfig | ||
Within your [DataCaptureConfig](https://github.com/google/android-fhir/blob/ced8527a5481972591615ad4364487e89130fb6e/datacapture/src/main/java/com/google/android/fhir/datacapture/DataCaptureConfig.kt#L35) object, assign the custom factory matchers provider to the `questionnaireItemViewHolderFactoryMatchersProviderFactory` property. This step makes your provider available for resolving view holders during questionnaire rendering. ([example](https://github.com/google/android-fhir/blob/ced8527a5481972591615ad4364487e89130fb6e/catalog/src/main/java/com/google/android/fhir/catalog/CatalogApplication.kt#L42C5-L47C8)) | ||
|
||
### 3. Configure the QuestionnaireFragment Builder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### 3. Configure the QuestionnaireFragment Builder | |
### 3. Use the custom matcher in the QuestionnaireFragment |
Within your [DataCaptureConfig](https://github.com/google/android-fhir/blob/ced8527a5481972591615ad4364487e89130fb6e/datacapture/src/main/java/com/google/android/fhir/datacapture/DataCaptureConfig.kt#L35) object, assign the custom factory matchers provider to the `questionnaireItemViewHolderFactoryMatchersProviderFactory` property. This step makes your provider available for resolving view holders during questionnaire rendering. ([example](https://github.com/google/android-fhir/blob/ced8527a5481972591615ad4364487e89130fb6e/catalog/src/main/java/com/google/android/fhir/catalog/CatalogApplication.kt#L42C5-L47C8)) | ||
|
||
### 3. Configure the QuestionnaireFragment Builder | ||
When constructing your QuestionnaireFragment using the builder pattern, utilize the `setCustomQuestionnaireItemViewHolderFactoryMatchersProvider` method. Provide the appropriate string identifier to specify which custom widgets to use. ([example](https://github.com/google/android-fhir/blob/ced8527a5481972591615ad4364487e89130fb6e/catalog/src/main/java/com/google/android/fhir/catalog/DemoQuestionnaireFragment.kt#L142C13-L150C23)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When constructing your QuestionnaireFragment using the builder pattern, utilize the `setCustomQuestionnaireItemViewHolderFactoryMatchersProvider` method. Provide the appropriate string identifier to specify which custom widgets to use. ([example](https://github.com/google/android-fhir/blob/ced8527a5481972591615ad4364487e89130fb6e/catalog/src/main/java/com/google/android/fhir/catalog/DemoQuestionnaireFragment.kt#L142C13-L150C23)) | |
When constructing your QuestionnaireFragment using the builder pattern, call the `setCustomQuestionnaireItemViewHolderFactoryMatchersProvider` method with the appropriate string identifier to specify which custom widgets to use. ([example](https://github.com/google/android-fhir/blob/ced8527a5481972591615ad4364487e89130fb6e/catalog/src/main/java/com/google/android/fhir/catalog/DemoQuestionnaireFragment.kt#L142C13-L150C23)) |
2. matches: A predicate function which, given a | ||
[`Questionnaire.QuestionnaireItemComponent`](https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-structures-r4/org/hl7/fhir/r4/model/Questionnaire.QuestionnaireItemComponent.html), returns true if the factory should apply to that item. | ||
|
||
### 2. Register the above factory with datacapture library via DataCaptureConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### 2. Register the above factory with datacapture library via DataCaptureConfig | |
### 2. Register the factory with datacapture library |
Co-authored-by: Jing Tang <[email protected]>
Closing this as the PR is moved to #2580 |
Update documentation for custom widget support.
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).
Fixes #[issue number]
Description
Clear and concise code change description.
Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?
Type
Choose one: (Bug fix | Feature | Documentation | Testing | Code health | Builds | Releases | Other)
Screenshots (if applicable)
Checklist
./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the style guide of this project../gradlew check
and./gradlew connectedCheck
to test my changes locally.