Skip to content

Commit

Permalink
Fix response not showing in summary mode (#3670)
Browse files Browse the repository at this point in the history
* Remove save draft dialog in summary mode

* Fix answers in Summary mode

* Add test

---------

Co-authored-by: Peter Lubell-Doughtie <peter@ona.io>
  • Loading branch information
hamza-vd and pld authored Jan 8, 2025
1 parent 0f1a333 commit 0ee9b06
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import org.smartregister.fhircore.engine.domain.model.ActionParameterType
import org.smartregister.fhircore.engine.domain.model.RuleConfig
import org.smartregister.fhircore.engine.domain.model.isEditable
import org.smartregister.fhircore.engine.domain.model.isReadOnly
import org.smartregister.fhircore.engine.domain.model.isSummary
import org.smartregister.fhircore.engine.util.castToType

fun QuestionnaireResponse.QuestionnaireResponseItemComponent.asLabel() =
Expand Down Expand Up @@ -298,10 +299,11 @@ suspend fun Questionnaire.prepopulateUniqueIdAssignment(
* Determines the [QuestionnaireResponse.Status] depending on the [saveDraft] and [isEditable]
* values contained in the [QuestionnaireConfig]
*
* returns [COMPLETED] when [isEditable] is [true] returns [INPROGRESS] when [saveDraft] is [true]
* returns [COMPLETED] when [isEditable] or [isSummary] is [true] returns [INPROGRESS] when
* [saveDraft] is [true]
*/
fun QuestionnaireConfig.questionnaireResponseStatus(): String? {
return if (this.isEditable()) {
return if (this.isEditable() || this.isSummary()) {
QuestionnaireResponseStatus.COMPLETED.toCode()
} else if (this.saveDraft) {
QuestionnaireResponseStatus.INPROGRESS.toCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,4 +488,11 @@ class QuestionnaireExtensionTest : RobolectricTest() {
val questionnaireConfig = QuestionnaireConfig(id = "patient-reg-config", saveDraft = true)
Assert.assertEquals("in-progress", questionnaireConfig.questionnaireResponseStatus())
}

@Test
fun testQuestionnaireResponseStatusReturnsCompletedWhenIsSummaryIsTrue() {
val questionnaireConfig =
QuestionnaireConfig(id = "patient-reg-config", type = QuestionnaireType.SUMMARY.name)
Assert.assertEquals("completed", questionnaireConfig.questionnaireResponseStatus())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class QuestionnaireActivity : BaseMultiLanguageActivity() {
}

private fun handleBackPress() {
if (questionnaireConfig.isReadOnly()) {
if (questionnaireConfig.isReadOnly() || questionnaireConfig.isSummary()) {
finish()
} else if (questionnaireConfig.saveDraft) {
AlertDialogue.showThreeButtonAlert(
Expand Down

0 comments on commit 0ee9b06

Please sign in to comment.