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

Create the structured data capture library #97

Merged
merged 52 commits into from Dec 23, 2020

Conversation

jingtang10
Copy link
Collaborator

@jingtang10 jingtang10 commented Jul 22, 2020

This module includes

  • QuestionnaireFragment that displays the Questionnaire and collects the QuestionnaireResponse from the user
  • QuestionnaireViewModel that works as the fragment's data backend

The QuestionnaireFragment class acts as the public API

Copy link
Collaborator Author

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks florina!

i've decided to package this into a new module -- which can eventually be shipped as a separate library.

fhirengine/build.gradle Outdated Show resolved Hide resolved
@jingtang10 jingtang10 changed the title Create fragment that renders a Questionnaire resource and generates … Create a module for structured data collection Nov 27, 2020
@jingtang10 jingtang10 marked this pull request as ready for review December 2, 2020 19:15
@jingtang10 jingtang10 changed the title Create a module for structured data collection Create a module for structured data capture Dec 7, 2020
@jingtang10 jingtang10 force-pushed the questionnaire-rendering branch 2 times, most recently from 9880bad to 8b25a80 Compare December 15, 2020 09:51
@jingtang10 jingtang10 changed the title Create a module for structured data capture Create the structured data capture library and gallery application Dec 15, 2020
Copy link
Collaborator Author

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks yigit for the review - ptal!

regarding integration tests vs unit tests, i actually think that test file itself is best kept as unit tests. it does not have any dependencies on UI or android components, it's purely about the logic to create a questionnaire response from a questionnaire and keep the same structure.

i will add more integration tests.

datacapture/build.gradle Outdated Show resolved Hide resolved
datacapture/build.gradle Outdated Show resolved Hide resolved
@jingtang10
Copy link
Collaborator Author

@yigit sorry this PR has bloated quite a bit. If possible at all I'd love to be able to merge this asap as this will unblock future work as well for @pankajkatoch. Just wanted to make sure the core structure is good. thanks again.

Copy link
Contributor

@yigit yigit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly i just skimmed through the PR because it is way too big to review properly :/

would be good to divide it up (e.g. merge skeleton, then merge type by type etc).

but also, i don't want to block the progress right before holidays so feel free to merge.

// TODO: find a more robust way to do this.
val context = itemView.context as AppCompatActivity
DatePickerFragment().show(context.supportFragmentManager, DatePickerFragment.TAG)
context.supportFragmentManager.setFragmentResultListener(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should take this out of the view model.
view model might disappear for various reasons.
ideally, such changes should be reflected just on the view model which can notify the change via submit list.

this CL is monster so might be a followup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean view holder?

so here the user is opening a new dialog to enter date, i think the challenge here is that view holder doesn't have the proper reference to the context (the cast here to appcompatactivity might crash if using non-appcompatactivity?).

jingtang10 added a commit that referenced this pull request Dec 17, 2020
@jingtang10
Copy link
Collaborator Author

honestly i just skimmed through the PR because it is way too big to review properly :/

would be good to divide it up (e.g. merge skeleton, then merge type by type etc).

but also, i don't want to block the progress right before holidays so feel free to merge.

Thanks Yigit for the review I have separated the gallery app into a different branch now... Will do the same for the individual types.

With particularly big changes, would it make sense to merge them (with review) into a feature branch and then send a final review from feature branch to master branch? I know we have missed that boat for this PR now.

@jingtang10 jingtang10 changed the title Create the structured data capture library and gallery application Create the structured data capture library Dec 17, 2020
- stop using ListAdapter and use RecyclerView.Adapter instead
- remove the QuestionnaireReponseRecorder interface as it's no longer needed
- create QuestionnaireItemViewItem data class to hold a pair of question and answer
- refactor QuestionnaireViewModel to create a list of QuestionnaireItemViewItem which is passed to the adapter
Copy link
Collaborator Author

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yigit and Kashyap for your reviews. I think I addressed all comments now.

@yigit and I discussed the use of recycler view yesterday.

  • we will not use list adapter any more. we will use recycler view adapter instead. this is mainly because we don't really need it...
  • the view model will produce a list which is passed to the adapter. the adapter will no longer hold reference to the view model (which is incorrect)

Please take another look -- would love to merge this asap if poss :)

// TODO: find a more robust way to do this.
val context = itemView.context as AppCompatActivity
DatePickerFragment().show(context.supportFragmentManager, DatePickerFragment.TAG)
context.supportFragmentManager.setFragmentResultListener(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean view holder?

so here the user is opening a new dialog to enter date, i think the challenge here is that view holder doesn't have the proper reference to the context (the cast here to appcompatactivity might crash if using non-appcompatactivity?).

jingtang10 added a commit that referenced this pull request Dec 18, 2020
Copy link
Contributor

@deepankarb deepankarb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of nits. Approved!

datacapture/proguard-rules.pro Outdated Show resolved Hide resolved
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.setFragmentResult
import java.util.Calendar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should switch to java.time

E.g.

LocalDate today = LocalDate.now();
int month = today.getMonthValue();
...

Perhaps that can be a dedicated PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks done. had to add suppress warning though - but is ok as long as user of library uses desugaring.

Copy link
Collaborator Author

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.setFragmentResult
import java.util.Calendar
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks done. had to add suppress warning though - but is ok as long as user of library uses desugaring.

datacapture/proguard-rules.pro Outdated Show resolved Hide resolved
@jingtang10 jingtang10 merged commit 1065a23 into master Dec 23, 2020
@jingtang10 jingtang10 deleted the questionnaire-rendering branch December 23, 2020 19:00
jingtang10 added a commit that referenced this pull request Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants