Skip to content

Commit

Permalink
Fix geowidget location population (#3014)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Lubell-Doughtie <[email protected]>
  • Loading branch information
FikriMilano and pld authored Jan 25, 2024
1 parent ec598b0 commit 2895939
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ open class GeoWidgetFragment : Fragment(), Observer<FeatureCollection> {

override fun onChanged(value: FeatureCollection) {
Timber.e("Feature collection loaded")
this.featureCollection = featureCollection
this.featureCollection = value

geoJsonSource?.also { source ->
featureCollection?.also { collection ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -228,19 +229,20 @@ constructor(
questionnaireConfig: QuestionnaireConfig,
) {
viewModelScope.launch {
val location = registerRepository.loadResource<Location>(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),
)
}
}
Expand Down

0 comments on commit 2895939

Please sign in to comment.