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
Conversation
02b6728
to
dcfab23
Compare
example/src/main/java/com/google/fhirengine/example/QuestionnaireActivity.kt
Outdated
Show resolved
Hide resolved
fhirengine/src/main/java/com/google/fhirengine/ui/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
fhirengine/src/main/java/com/google/fhirengine/ui/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
fhirengine/src/main/java/com/google/fhirengine/ui/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
fhirengine/src/main/java/com/google/fhirengine/ui/QuestionnaireViewModel.kt
Outdated
Show resolved
Hide resolved
fhirengine/src/main/java/com/google/fhirengine/ui/QuestionnaireViewModel.kt
Outdated
Show resolved
Hide resolved
fhirengine/src/main/java/com/google/fhirengine/ui/QuestionnaireViewModel.kt
Outdated
Show resolved
Hide resolved
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 florina!
i've decided to package this into a new module -- which can eventually be shipped as a separate library.
fhirengine/src/main/java/com/google/fhirengine/ui/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
76fbea1
to
c3b86b9
Compare
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
datacapture/src/test/java/com/google/android/fhir/datacapture/QuestionnaireViewModelTest.kt
Show resolved
Hide resolved
example/src/main/java/com/google/fhirengine/example/QuestionnaireActivity.kt
Outdated
Show resolved
Hide resolved
9880bad
to
8b25a80
Compare
7df9a94
to
048e3ae
Compare
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 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/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
cf8f80f
to
37df6e1
Compare
@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. |
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.
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.
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
...capture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemViewHolderType.kt
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemAdapter.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemAdapter.kt
Outdated
Show resolved
Hide resolved
...java/com/google/android/fhir/datacapture/views/QuestionnaireItemCheckBoxViewHolderFactory.kt
Show resolved
Hide resolved
// TODO: find a more robust way to do this. | ||
val context = itemView.context as AppCompatActivity | ||
DatePickerFragment().show(context.supportFragmentManager, DatePickerFragment.TAG) | ||
context.supportFragmentManager.setFragmentResultListener( |
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.
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.
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.
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?).
datacapture/src/test/java/com/google/android/fhir/datacapture/QuestionnaireItemAdapterTest.kt
Outdated
Show resolved
Hide resolved
…he branch in order to split PR #97
60b8af1
to
621656d
Compare
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. |
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
…he enum from integer
- 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
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 @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 :)
...capture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemViewHolderType.kt
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemAdapter.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Show resolved
Hide resolved
...java/com/google/android/fhir/datacapture/views/QuestionnaireItemCheckBoxViewHolderFactory.kt
Show resolved
Hide resolved
// TODO: find a more robust way to do this. | ||
val context = itemView.context as AppCompatActivity | ||
DatePickerFragment().show(context.supportFragmentManager, DatePickerFragment.TAG) | ||
context.supportFragmentManager.setFragmentResultListener( |
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.
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?).
…he branch in order to split PR #97
…he branch in order to split PR #97
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.
Left a couple of nits. Approved!
import androidx.core.os.bundleOf | ||
import androidx.fragment.app.DialogFragment | ||
import androidx.fragment.app.setFragmentResult | ||
import java.util.Calendar |
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.
We should switch to java.time
E.g.
LocalDate today = LocalDate.now();
int month = today.getMonthValue();
...
Perhaps that can be a dedicated PR.
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 done. had to add suppress warning though - but is ok as long as user of library uses desugaring.
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!
import androidx.core.os.bundleOf | ||
import androidx.fragment.app.DialogFragment | ||
import androidx.fragment.app.setFragmentResult | ||
import java.util.Calendar |
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 done. had to add suppress warning though - but is ok as long as user of library uses desugaring.
This reverts commit 7dcfc45.
…he branch in order to split PR #97
This module includes
The QuestionnaireFragment class acts as the public API