From 28959399679ce0094da4540db1efbf8e4263b5e8 Mon Sep 17 00:00:00 2001 From: FikriMilano Date: Fri, 26 Jan 2024 06:47:15 +0700 Subject: [PATCH] Fix geowidget location population (#3014) Co-authored-by: Peter Lubell-Doughtie --- .../geowidget/screens/GeoWidgetFragment.kt | 2 +- .../quest/ui/main/AppMainViewModel.kt | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/android/geowidget/src/main/java/org/smartregister/fhircore/geowidget/screens/GeoWidgetFragment.kt b/android/geowidget/src/main/java/org/smartregister/fhircore/geowidget/screens/GeoWidgetFragment.kt index 6976382866..4f7e4083b8 100644 --- a/android/geowidget/src/main/java/org/smartregister/fhircore/geowidget/screens/GeoWidgetFragment.kt +++ b/android/geowidget/src/main/java/org/smartregister/fhircore/geowidget/screens/GeoWidgetFragment.kt @@ -188,7 +188,7 @@ open class GeoWidgetFragment : Fragment(), Observer { override fun onChanged(value: FeatureCollection) { Timber.e("Feature collection loaded") - this.featureCollection = featureCollection + this.featureCollection = value geoJsonSource?.also { source -> featureCollection?.also { collection -> diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainViewModel.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainViewModel.kt index acc4b4230d..04c9128536 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainViewModel.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainViewModel.kt @@ -40,8 +40,9 @@ import kotlin.time.Duration import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.hl7.fhir.r4.model.Binary -import org.hl7.fhir.r4.model.Location +import org.hl7.fhir.r4.model.Enumerations import org.hl7.fhir.r4.model.QuestionnaireResponse +import org.hl7.fhir.r4.model.ResourceType import org.hl7.fhir.r4.model.Task import org.smartregister.fhircore.engine.R import org.smartregister.fhircore.engine.configuration.ConfigType @@ -55,6 +56,8 @@ import org.smartregister.fhircore.engine.configuration.navigation.NavigationMenu import org.smartregister.fhircore.engine.configuration.report.measure.MeasureReportConfiguration import org.smartregister.fhircore.engine.configuration.workflow.ActionTrigger import org.smartregister.fhircore.engine.data.local.register.RegisterRepository +import org.smartregister.fhircore.engine.domain.model.ActionParameter +import org.smartregister.fhircore.engine.domain.model.ActionParameterType import org.smartregister.fhircore.engine.sync.SyncBroadcaster import org.smartregister.fhircore.engine.task.FhirCarePlanGenerator import org.smartregister.fhircore.engine.task.FhirCompleteCarePlanWorker @@ -66,7 +69,6 @@ import org.smartregister.fhircore.engine.util.SecureSharedPreference import org.smartregister.fhircore.engine.util.SharedPreferenceKey import org.smartregister.fhircore.engine.util.SharedPreferencesHelper import org.smartregister.fhircore.engine.util.extension.decodeToBitmap -import org.smartregister.fhircore.engine.util.extension.encodeResourceToString import org.smartregister.fhircore.engine.util.extension.extractLogicalIdUuid import org.smartregister.fhircore.engine.util.extension.fetchLanguages import org.smartregister.fhircore.engine.util.extension.getActivity @@ -77,7 +79,6 @@ import org.smartregister.fhircore.engine.util.extension.showToast import org.smartregister.fhircore.engine.util.extension.tryParse import org.smartregister.fhircore.quest.navigation.MainNavigationScreen import org.smartregister.fhircore.quest.navigation.NavigationArg -import org.smartregister.fhircore.quest.ui.questionnaire.QuestionnaireActivity import org.smartregister.fhircore.quest.ui.report.measure.worker.MeasureReportMonthPeriodWorker import org.smartregister.fhircore.quest.ui.shared.QuestionnaireHandler import org.smartregister.fhircore.quest.ui.shared.models.QuestionnaireSubmission @@ -228,19 +229,20 @@ constructor( questionnaireConfig: QuestionnaireConfig, ) { viewModelScope.launch { - val location = registerRepository.loadResource(locationId)?.encodeResourceToString() + val prePopulateLocationIdParameter = + ActionParameter( + key = "locationId", + paramType = ActionParameterType.PREPOPULATE, + dataType = Enumerations.DataType.STRING, + resourceType = ResourceType.Location, + value = locationId, + linkId = "household-location-reference", + ) if (context is QuestionnaireHandler) { context.launchQuestionnaire( context = context, - extraIntentBundle = - bundleOf( - Pair( - QuestionnaireActivity.QUESTIONNAIRE_POPULATION_RESOURCES, - arrayListOf(location), - ), - ), questionnaireConfig = questionnaireConfig, - actionParams = emptyList(), + actionParams = listOf(prePopulateLocationIdParameter), ) } }