Skip to content

Commit

Permalink
Merge pull request #3046 from opensrp/main-lw-sample
Browse files Browse the repository at this point in the history
Add the SDC Location picker widget to the `main` branch
  • Loading branch information
dubdabasoduba authored Mar 15, 2024
2 parents b860328 + 7323d45 commit 6487605
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
7 changes: 7 additions & 0 deletions android/engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ dependencies {
exclude(group = "com.google.android.fhir", module = "common")
exclude(group = "com.google.android.fhir", module = "engine")
}
api(libs.contrib.locationwidget) {
isTransitive = true
exclude(group = "org.smartregister", module = "data-capture")
exclude(group = "ca.uhn.hapi.fhir")
exclude(group = "com.google.android.fhir", module = "common")
exclude(group = "com.google.android.fhir", module = "engine")
}
api(libs.fhir.engine) {
isTransitive = true
exclude(group = "com.google.android.fhir", module = "common")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.hl7.fhir.r4.model.Encounter
import org.hl7.fhir.r4.model.EpisodeOfCare
import org.hl7.fhir.r4.model.Group
import org.hl7.fhir.r4.model.Immunization
import org.hl7.fhir.r4.model.Location
import org.hl7.fhir.r4.model.Observation
import org.hl7.fhir.r4.model.Patient
import org.hl7.fhir.r4.model.PlanDefinition
Expand Down Expand Up @@ -79,6 +80,7 @@ class TransformSupportServices @Inject constructor(val simpleWorkerContext: Simp
"Task_Output" -> Task.TaskOutputComponent()
"Task_Restriction" -> Task.TaskRestrictionComponent()
"AdverseEvent_SuspectEntity" -> AdverseEvent.AdverseEventSuspectEntityComponent()
"Location_Position" -> Location.LocationPositionComponent()
else -> ResourceFactory.createResourceOrType(name)
}
}
Expand Down
2 changes: 2 additions & 0 deletions android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ compressor = "3.0.1"
constraintlayout = "2.1.4"
constraintlayout-compose = "1.0.1"
contrib-barcode = "0.1.0-beta3-preview5-SNAPSHOT"
contrib-locationwidget = "0.1.0-alpha01-preview-SNAPSHOT"
converter-gson = "2.9.0"
core-ktx = "1.12.0"
android-x-test= "1.5.2"
Expand Down Expand Up @@ -93,6 +94,7 @@ compressor = { group = "id.zelory", name = "compressor", version.ref = "compress
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
constraintlayout-compose = { group = "androidx.constraintlayout", name = "constraintlayout-compose", version.ref = "constraintlayout-compose" }
contrib-barcode = { group = "org.smartregister", name = "contrib-barcode", version.ref = "contrib-barcode" }
contrib-locationwidget = { group = "org.smartregister", name = "contrib-locationwidget", version.ref = "contrib-locationwidget" }
converter-gson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "converter-gson" }
core-desugar = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "desugar-jdk-libs" }
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ class QuestionnaireActivity : BaseMultiLanguageActivity() {
val questionnaireFragmentBuilder =
QuestionnaireFragment.builder()
.setQuestionnaire(questionnaire.json())
.setCustomQuestionnaireItemViewHolderFactoryMatchersProvider(
OPENSRP_ITEM_VIEWHOLDER_FACTORY_MATCHERS_PROVIDER,
)
.showAsterisk(questionnaireConfig.showRequiredTextAsterisk)
.showRequiredText(questionnaireConfig.showRequiredText)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,30 @@ package org.smartregister.fhircore.quest.ui.questionnaire
import com.google.android.fhir.datacapture.QuestionnaireFragment
import com.google.android.fhir.datacapture.QuestionnaireItemViewHolderFactoryMatchersProviderFactory
import com.google.android.fhir.datacapture.contrib.views.barcode.BarCodeReaderViewHolderFactory
import com.google.android.fhir.datacapture.contrib.views.locationwidget.LocationGpsCoordinateViewHolderFactory
import com.google.android.fhir.datacapture.contrib.views.locationwidget.LocationWidgetViewHolderFactory
import com.google.android.fhir.datacapture.extensions.asStringValue

const val OPENSRP_ITEM_VIEWHOLDER_FACTORY_MATCHERS_PROVIDER =
"org.smartregister.fhircore.quest.QuestionnaireItemViewHolderFactoryMatchersProvider"

object QuestionnaireItemViewHolderFactoryMatchersProviderFactoryImpl :
QuestionnaireItemViewHolderFactoryMatchersProviderFactory {

override fun get(
provider: String,
): QuestionnaireFragment.QuestionnaireItemViewHolderFactoryMatchersProvider {
return QuestionnaireItemViewHolderFactoryMatchersProviderImpl
return when (provider) {
OPENSRP_ITEM_VIEWHOLDER_FACTORY_MATCHERS_PROVIDER ->
OpenSRPQuestionnaireItemViewHolderFactoryMatchersProviderImpl
else -> throw NotImplementedError()
}
}

object QuestionnaireItemViewHolderFactoryMatchersProviderImpl :
object OpenSRPQuestionnaireItemViewHolderFactoryMatchersProviderImpl :
QuestionnaireFragment.QuestionnaireItemViewHolderFactoryMatchersProvider() {

const val BARCODE_URL = "https://fhir.labs.smartregister.org/barcode-type-widget-extension"
const val BARCODE_URL = "https://smartregister.org/barcode-type-widget-extension"
const val BARCODE_NAME = "barcode"

override fun get(): List<QuestionnaireFragment.QuestionnaireItemViewHolderFactoryMatcher> {
Expand All @@ -45,6 +54,14 @@ object QuestionnaireItemViewHolderFactoryMatchersProviderFactoryImpl :
if (it == null) false else it.value.asStringValue() == BARCODE_NAME
}
},
QuestionnaireFragment.QuestionnaireItemViewHolderFactoryMatcher(
factory = LocationGpsCoordinateViewHolderFactory,
matches = LocationGpsCoordinateViewHolderFactory::matcher,
),
QuestionnaireFragment.QuestionnaireItemViewHolderFactoryMatcher(
factory = LocationWidgetViewHolderFactory,
matches = LocationWidgetViewHolderFactory::matcher,
),
)
}
}
Expand Down

0 comments on commit 6487605

Please sign in to comment.