-
Notifications
You must be signed in to change notification settings - Fork 251
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
Allow using a custom TransformSupportServices for StructureMap-based extraction #712
Allow using a custom TransformSupportServices for StructureMap-based extraction #712
Conversation
295e871
to
1ad28bb
Compare
Codecov Report
@@ Coverage Diff @@
## master #712 +/- ##
============================================
+ Coverage 84.53% 84.57% +0.03%
- Complexity 646 651 +5
============================================
Files 140 140
Lines 10488 10494 +6
Branches 795 795
============================================
+ Hits 8866 8875 +9
+ Misses 1223 1220 -3
Partials 399 399
Continue to review full report at Codecov.
|
@jingtang10 Kindly review. This is a small PR that fixes an issue with ResourceMapper extraction using StructureMap-based extraction. The issue came up while trying to implement a StructureMap for patient registration |
…-support-services
…-support-services
…-support-services
…-support-services
…-support-services
0a8111c
to
0b1938d
Compare
@ekigamba , is there an ETA by when the changes can be committed to make the PR ready for review? |
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.
A few comments, otherwise the PR looks good.
else extractByStructureMap(context, questionnaire, questionnaireResponse, structureMapProvider) | ||
else | ||
extractByStructureMap( | ||
context, |
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.
Since context
is also just used for structure map based extraction, maybe it should also be encapsulated inside StructureMapExtractionContext
.
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.
Agreed
val structureMapProvider: (suspend (String, IWorkerContext) -> StructureMap?), | ||
val transformSupportServices: StructureMapUtilities.ITransformerServices? = null |
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.
I think reversing these would be better for creating StructureMapExtractionContext objects with lambda.
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.
Agreed
iParser.parseResource(QuestionnaireResponse::class.java, questionnaireResponseJson) as | ||
QuestionnaireResponse | ||
|
||
val outputs: MutableList<Base> = mutableListOf() |
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.
Since outputs
is not being used anywhere, can it be avoided altogether?
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.
Yes
- Disable TransformSupportServices required for extraction - Re-add the validation and optimize the Q & QR copy - Pass Q and QR as objects to QuestionnaireFragment instead of encoding and decoding again - Fix breaking changes due to missing PRs google/android-fhir#712 and google/android-fhir#807
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.
Please address aditya's comments.
@ekigamba - thanks for this pr and the good work in creating the tests. i think the knowledge and experience to create structure map from a mapping is pretty lacking in general (i have no idea how to do this). can you please write a little bit of documentation somewhere and we can put it on the wiki?
thanks!
StructureMapUtilities(simpleWorkerContext) | ||
StructureMapUtilities( | ||
simpleWorkerContext, | ||
structureMapExtractionContext.transformSupportServices |
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.
i went into hapi's code for a quick look, can't really figure out what they do in the case of this being null. just to be safe, shouldn't we call different contructors if this is null or not?
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.
I confirmed that that both constructors have the same logic with one having the setting for the TransformSupportServices
- https://github.com/hapifhir/org.hl7.fhir.core/blob/master/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/StructureMapUtilities.java#L253..L259
- https://github.com/hapifhir/org.hl7.fhir.core/blob/master/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/StructureMapUtilities.java#L261..L266
@jingtang10 I will add some documentation on the conversion |
…-support-services
…-support-services
…-support-services
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.
Please check the comment. Apart from that LGTM
val transformSupportServices: StructureMapUtilities.ITransformerServices? = null, | ||
val context: Context, |
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.
nit: Can you please swap these? Context is usually the first param.
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.
Definitely
…-support-services
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).
Allow using a custom TransformSupportServices for StructureMap. When using StructureMap-based extraction, we use the command
create('ResourceType')
to generate new instances of resources. The current implementation lacks support for internal/embedded model types egRiskAssessment.Prediction
,Immunization.Reaction
. Here is the usage https://github.com/opensrp/fhircore/blob/issue/403-refactor-extraction-code/android/engine/src/main/java/org/smartregister/fhircore/engine/helper/TransformSupportServices.kt#L50Description
Add an optional
TransformSupportServices
param to theResourceMapper#extract
method andResourceMapper#extractByStructureMap
Alternative(s) considered
Yes, adding support for the internal models inside the datacapture module. This would take longer to implement because the number of models lacking support is not clear. Adding support for an internal models would also require making changes to android-fhir.
Type
Choose one: Feature
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