From a41fc00fff08ef3cb90ea23ac8b607d264323762 Mon Sep 17 00:00:00 2001 From: Raazia Tariq <89384079+RaaziaTarique@users.noreply.github.com> Date: Wed, 16 Mar 2022 16:50:17 +0100 Subject: [PATCH 01/20] Create blank.yml --- .github/workflows/blank.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/workflows/blank.yml diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml new file mode 100644 index 0000000000..dbb9d606ae --- /dev/null +++ b/.github/workflows/blank.yml @@ -0,0 +1,9 @@ +name: CI +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup upterm session + uses: lhotari/action-upterm@v1 From 7db66c7e95816557d214b8bbec147c87058f44d4 Mon Sep 17 00:00:00 2001 From: Raazia Tariq <89384079+RaaziaTarique@users.noreply.github.com> Date: Wed, 16 Mar 2022 16:50:44 +0100 Subject: [PATCH 02/20] Delete blank.yml --- .github/workflows/blank.yml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .github/workflows/blank.yml diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml deleted file mode 100644 index dbb9d606ae..0000000000 --- a/.github/workflows/blank.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: CI -on: [push] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup upterm session - uses: lhotari/action-upterm@v1 From 03baeb2f642d50bce9db5029d85f101713d7f6c9 Mon Sep 17 00:00:00 2001 From: Raazia Tariq <89384079+RaaziaTarique@users.noreply.github.com> Date: Thu, 17 Mar 2022 09:00:50 +0100 Subject: [PATCH 03/20] - Testing commit --- .../android/fhir/datacapture/validation/ConstraintValidator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/validation/ConstraintValidator.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/validation/ConstraintValidator.kt index fdcf2f6a8c..cb0dbbe48b 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/validation/ConstraintValidator.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/validation/ConstraintValidator.kt @@ -20,7 +20,7 @@ import android.content.Context import org.hl7.fhir.r4.model.Questionnaire import org.hl7.fhir.r4.model.QuestionnaireResponse -/** A interface for validating FHIR native supported constraints on a questionnaire response. */ +/** A interface for validating FHIR native supported constraints on a questionnaire res */ internal interface ConstraintValidator { /** * Validates the `answer`(s) in [questionnaireResponseItem] satisfy any constraints of the From b078aefde9cc8a018da4d76c56e166a762ec7755 Mon Sep 17 00:00:00 2001 From: Raazia Tariq <89384079+RaaziaTarique@users.noreply.github.com> Date: Thu, 17 Mar 2022 09:01:13 +0100 Subject: [PATCH 04/20] - Testing commit changes reverted --- .../android/fhir/datacapture/validation/ConstraintValidator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/validation/ConstraintValidator.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/validation/ConstraintValidator.kt index cb0dbbe48b..fdcf2f6a8c 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/validation/ConstraintValidator.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/validation/ConstraintValidator.kt @@ -20,7 +20,7 @@ import android.content.Context import org.hl7.fhir.r4.model.Questionnaire import org.hl7.fhir.r4.model.QuestionnaireResponse -/** A interface for validating FHIR native supported constraints on a questionnaire res */ +/** A interface for validating FHIR native supported constraints on a questionnaire response. */ internal interface ConstraintValidator { /** * Validates the `answer`(s) in [questionnaireResponseItem] satisfy any constraints of the From 749edbde2ad5f10e0365afe12b482e508cca3f01 Mon Sep 17 00:00:00 2001 From: Raazia Tariq <89384079+RaaziaTarique@users.noreply.github.com> Date: Mon, 4 Apr 2022 17:05:31 +0200 Subject: [PATCH 05/20] - Changes for repeated groups --- .../datacapture/QuestionnaireItemAdapter.kt | 78 +++-- .../QuestionnaireItemViewHolderType.kt | 3 +- ...nnaireItemAutoCompleteViewHolderFactory.kt | 2 - .../QuestionnaireItemViewHolderFactory.kt | 3 + datacapture/src/main/res/drawable/border.xml | 10 + .../questionnaire_item_edit_text_view.xml | 31 ++ .../questionnaire_item_group_header_view.xml | 15 + datacapture/src/main/res/values/colors.xml | 1 + .../new-patient-registration-paginated.json | 320 +----------------- 9 files changed, 111 insertions(+), 352 deletions(-) create mode 100644 datacapture/src/main/res/drawable/border.xml diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemAdapter.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemAdapter.kt index c0c575e8cd..99c21a8fee 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemAdapter.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemAdapter.kt @@ -38,6 +38,7 @@ import com.google.android.fhir.datacapture.views.QuestionnaireItemRadioGroupView import com.google.android.fhir.datacapture.views.QuestionnaireItemSliderViewHolderFactory import com.google.android.fhir.datacapture.views.QuestionnaireItemViewHolder import com.google.android.fhir.datacapture.views.QuestionnaireItemViewItem +import com.google.android.fhir.datacapture.views.RepeatViewHolderFactory import org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType internal class QuestionnaireItemAdapter( @@ -61,38 +62,46 @@ internal class QuestionnaireItemAdapter( parent ) - val viewHolderFactory = - when (QuestionnaireItemViewHolderType.fromInt(viewType)) { - QuestionnaireItemViewHolderType.GROUP -> QuestionnaireItemGroupViewHolderFactory - QuestionnaireItemViewHolderType.BOOLEAN_TYPE_PICKER -> - QuestionnaireItemBooleanTypePickerViewHolderFactory - QuestionnaireItemViewHolderType.DATE_PICKER -> QuestionnaireItemDatePickerViewHolderFactory - QuestionnaireItemViewHolderType.DATE_TIME_PICKER -> - QuestionnaireItemDateTimePickerViewHolderFactory - QuestionnaireItemViewHolderType.EDIT_TEXT_SINGLE_LINE -> - QuestionnaireItemEditTextSingleLineViewHolderFactory - QuestionnaireItemViewHolderType.EDIT_TEXT_MULTI_LINE -> - QuestionnaireItemEditTextMultiLineViewHolderFactory - QuestionnaireItemViewHolderType.EDIT_TEXT_INTEGER -> - QuestionnaireItemEditTextIntegerViewHolderFactory - QuestionnaireItemViewHolderType.EDIT_TEXT_DECIMAL -> - QuestionnaireItemEditTextDecimalViewHolderFactory - QuestionnaireItemViewHolderType.RADIO_GROUP -> QuestionnaireItemRadioGroupViewHolderFactory - QuestionnaireItemViewHolderType.DROP_DOWN -> QuestionnaireItemDropDownViewHolderFactory - QuestionnaireItemViewHolderType.DISPLAY -> QuestionnaireItemDisplayViewHolderFactory - QuestionnaireItemViewHolderType.QUANTITY -> - QuestionnaireItemEditTextQuantityViewHolderFactory - QuestionnaireItemViewHolderType.CHECK_BOX_GROUP -> - QuestionnaireItemCheckBoxGroupViewHolderFactory - QuestionnaireItemViewHolderType.AUTO_COMPLETE -> - QuestionnaireItemAutoCompleteViewHolderFactory - QuestionnaireItemViewHolderType.DIALOG_SELECT -> - QuestionnaireItemDialogSelectViewHolderFactory - QuestionnaireItemViewHolderType.SLIDER -> QuestionnaireItemSliderViewHolderFactory - QuestionnaireItemViewHolderType.PHONE_NUMBER -> - QuestionnaireItemPhoneNumberViewHolderFactory - } - return viewHolderFactory.create(parent) + if (QuestionnaireItemViewHolderType.fromInt(viewType) == QuestionnaireItemViewHolderType.REPEAT + ) { + return RepeatViewHolderFactory.create(parent, viewType) + } else { + val viewHolderFactory = + when (QuestionnaireItemViewHolderType.fromInt(viewType)) { + QuestionnaireItemViewHolderType.GROUP -> QuestionnaireItemGroupViewHolderFactory + QuestionnaireItemViewHolderType.BOOLEAN_TYPE_PICKER -> + QuestionnaireItemBooleanTypePickerViewHolderFactory + QuestionnaireItemViewHolderType.DATE_PICKER -> + QuestionnaireItemDatePickerViewHolderFactory + QuestionnaireItemViewHolderType.DATE_TIME_PICKER -> + QuestionnaireItemDateTimePickerViewHolderFactory + QuestionnaireItemViewHolderType.EDIT_TEXT_SINGLE_LINE -> + QuestionnaireItemEditTextSingleLineViewHolderFactory + QuestionnaireItemViewHolderType.EDIT_TEXT_MULTI_LINE -> + QuestionnaireItemEditTextMultiLineViewHolderFactory + QuestionnaireItemViewHolderType.EDIT_TEXT_INTEGER -> + QuestionnaireItemEditTextIntegerViewHolderFactory + QuestionnaireItemViewHolderType.EDIT_TEXT_DECIMAL -> + QuestionnaireItemEditTextDecimalViewHolderFactory + QuestionnaireItemViewHolderType.RADIO_GROUP -> + QuestionnaireItemRadioGroupViewHolderFactory + QuestionnaireItemViewHolderType.DROP_DOWN -> QuestionnaireItemDropDownViewHolderFactory + QuestionnaireItemViewHolderType.DISPLAY -> QuestionnaireItemDisplayViewHolderFactory + QuestionnaireItemViewHolderType.QUANTITY -> + QuestionnaireItemEditTextQuantityViewHolderFactory + QuestionnaireItemViewHolderType.CHECK_BOX_GROUP -> + QuestionnaireItemCheckBoxGroupViewHolderFactory + QuestionnaireItemViewHolderType.AUTO_COMPLETE -> + QuestionnaireItemAutoCompleteViewHolderFactory + QuestionnaireItemViewHolderType.DIALOG_SELECT -> + QuestionnaireItemDialogSelectViewHolderFactory + QuestionnaireItemViewHolderType.SLIDER -> QuestionnaireItemSliderViewHolderFactory + QuestionnaireItemViewHolderType.PHONE_NUMBER -> + QuestionnaireItemPhoneNumberViewHolderFactory + else -> throw NotImplementedError("Question type $viewType not supported.") + } + return viewHolderFactory.create(parent) + } } override fun onBindViewHolder(holder: QuestionnaireItemViewHolder, position: Int) { @@ -114,12 +123,17 @@ internal class QuestionnaireItemAdapter( val questionnaireItem = questionnaireItemViewItem.questionnaireItem // For custom widgets, generate an int value that's greater than any int assigned to the // canonical FHIR widgets + questionnaireItemViewHolderMatchers.forEachIndexed { index, matcher -> if (matcher.matches(questionnaireItem)) { return index + QuestionnaireItemViewHolderType.values().size } } + if (questionnaireItem.repeats) { + return QuestionnaireItemViewHolderType.REPEAT.value + } + return when (val type = questionnaireItem.type) { QuestionnaireItemType.GROUP -> QuestionnaireItemViewHolderType.GROUP QuestionnaireItemType.BOOLEAN -> QuestionnaireItemViewHolderType.BOOLEAN_TYPE_PICKER diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemViewHolderType.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemViewHolderType.kt index 81d774382e..f8b8bea9cd 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemViewHolderType.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemViewHolderType.kt @@ -43,7 +43,8 @@ internal enum class QuestionnaireItemViewHolderType(val value: Int) { AUTO_COMPLETE(13), DIALOG_SELECT(14), SLIDER(15), - PHONE_NUMBER(16); + PHONE_NUMBER(16), + REPEAT(17); companion object { private val VALUES = values() diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemAutoCompleteViewHolderFactory.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemAutoCompleteViewHolderFactory.kt index 5dc5118686..50cff2653f 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemAutoCompleteViewHolderFactory.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemAutoCompleteViewHolderFactory.kt @@ -62,8 +62,6 @@ internal object QuestionnaireItemAutoCompleteViewHolderFactory : private lateinit var chipContainer: FlexboxLayout private lateinit var editText: TextInputEditText - private val canHaveMultipleAnswers - get() = questionnaireItemViewItem.questionnaireItem.repeats override lateinit var questionnaireItemViewItem: QuestionnaireItemViewItem override fun init(itemView: View) { diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemViewHolderFactory.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemViewHolderFactory.kt index 09c5e05d41..c5ed999e7a 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemViewHolderFactory.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemViewHolderFactory.kt @@ -104,6 +104,9 @@ interface QuestionnaireItemViewHolderDelegate { displayValidationResult(getValidationResult(context)) } + val canHaveMultipleAnswers + get() = questionnaireItemViewItem.questionnaireItem.repeats + /** Run the [QuestionnaireResponseItemValidator.validate] function. */ fun getValidationResult(context: Context): ValidationResult { return QuestionnaireResponseItemValidator.validate( diff --git a/datacapture/src/main/res/drawable/border.xml b/datacapture/src/main/res/drawable/border.xml new file mode 100644 index 0000000000..8b92e8109d --- /dev/null +++ b/datacapture/src/main/res/drawable/border.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/datacapture/src/main/res/layout/questionnaire_item_edit_text_view.xml b/datacapture/src/main/res/layout/questionnaire_item_edit_text_view.xml index fa208f15ed..8068e6644a 100644 --- a/datacapture/src/main/res/layout/questionnaire_item_edit_text_view.xml +++ b/datacapture/src/main/res/layout/questionnaire_item_edit_text_view.xml @@ -29,6 +29,21 @@ android:orientation="horizontal" > +