diff --git a/android/buildSrc/src/main/kotlin/BuildConfigs.kt b/android/buildSrc/src/main/kotlin/BuildConfigs.kt index b0121e19b3..d2175235cb 100644 --- a/android/buildSrc/src/main/kotlin/BuildConfigs.kt +++ b/android/buildSrc/src/main/kotlin/BuildConfigs.kt @@ -2,8 +2,8 @@ object BuildConfigs { const val minSdk = 26 const val compileSdk = 34 const val targetSdk = 34 - const val versionCode = 10 - const val versionName = "1.1.0" + const val versionCode = 11 + const val versionName = "2.0.0" const val applicationId = "org.smartregister.opensrp" const val jvmToolchain = 17 const val kotlinCompilerExtensionVersion = "1.5.8" diff --git a/android/engine/src/main/java/org/smartregister/fhircore/engine/rulesengine/RulesFactory.kt b/android/engine/src/main/java/org/smartregister/fhircore/engine/rulesengine/RulesFactory.kt index 61f2b853f1..68664ffc4d 100644 --- a/android/engine/src/main/java/org/smartregister/fhircore/engine/rulesengine/RulesFactory.kt +++ b/android/engine/src/main/java/org/smartregister/fhircore/engine/rulesengine/RulesFactory.kt @@ -351,6 +351,11 @@ constructor( SharedPreferenceKey.PRACTITIONER_LOCATION.name, "", ) + SharedPreferenceKey.PRACTITIONER_LOCATION_ID -> + configurationRegistry.sharedPreferencesHelper.read( + SharedPreferenceKey.PRACTITIONER_LOCATION_ID.name, + "", + ) else -> "" } } catch (exception: Exception) { diff --git a/android/engine/src/main/java/org/smartregister/fhircore/engine/util/SharedPreferenceKey.kt b/android/engine/src/main/java/org/smartregister/fhircore/engine/util/SharedPreferenceKey.kt index ab38d4268e..e9277ec5b8 100644 --- a/android/engine/src/main/java/org/smartregister/fhircore/engine/util/SharedPreferenceKey.kt +++ b/android/engine/src/main/java/org/smartregister/fhircore/engine/util/SharedPreferenceKey.kt @@ -24,6 +24,7 @@ enum class SharedPreferenceKey { PRACTITIONER_DETAILS, PRACTITIONER_LOCATION_HIERARCHIES, PRACTITIONER_LOCATION, + PRACTITIONER_LOCATION_ID, REMOTE_SYNC_RESOURCES, LOGIN_CREDENTIAL_KEY, LOGIN_PIN_KEY, diff --git a/android/engine/src/test/java/org/smartregister/fhircore/engine/rulesengine/RulesFactoryTest.kt b/android/engine/src/test/java/org/smartregister/fhircore/engine/rulesengine/RulesFactoryTest.kt index 66f93f9966..cbbe276f3f 100644 --- a/android/engine/src/test/java/org/smartregister/fhircore/engine/rulesengine/RulesFactoryTest.kt +++ b/android/engine/src/test/java/org/smartregister/fhircore/engine/rulesengine/RulesFactoryTest.kt @@ -977,7 +977,23 @@ class RulesFactoryTest : RobolectricTest() { @Test fun testExtractSharedPrefValuesReturnsPractitionerLocation() { val sharedPreferenceKey = "PRACTITIONER_LOCATION" - val expectedValue = "1234" + val expectedValue = "Demo Facility" + every { + configurationRegistry.sharedPreferencesHelper.read( + sharedPreferenceKey, + "", + ) + } returns expectedValue + val result = rulesEngineService.extractPractitionerInfoFromSharedPrefs(sharedPreferenceKey) + + verify { configurationRegistry.sharedPreferencesHelper.read(sharedPreferenceKey, "") } + Assert.assertEquals(expectedValue, result) + } + + @Test + fun testExtractSharedPrefValuesReturnsPractitionerLocationId() { + val sharedPreferenceKey = "PRACTITIONER_LOCATION_ID" + val expectedValue = "ABCD1234" every { configurationRegistry.sharedPreferencesHelper.read( sharedPreferenceKey, diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/login/LoginViewModel.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/login/LoginViewModel.kt index dc72fe99be..4fda6dd085 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/login/LoginViewModel.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/login/LoginViewModel.kt @@ -415,7 +415,7 @@ constructor( ) } - private fun writePractitionerDetailsToShredPref( + fun writePractitionerDetailsToShredPref( careTeam: List, organization: List, location: List, @@ -452,6 +452,10 @@ constructor( key = SharedPreferenceKey.ORGANIZATION.name, value = organization.joinToString(separator = ""), ) + sharedPreferences.write( + key = SharedPreferenceKey.PRACTITIONER_LOCATION_ID.name, + value = locations.joinToString(separator = ""), + ) } fun downloadNowWorkflowConfigs(isInitialLogin: Boolean = true) { diff --git a/android/quest/src/main/res/layout/password_view.xml b/android/quest/src/main/res/layout/password_view.xml index 26e36e732d..97e1dcd5ec 100644 --- a/android/quest/src/main/res/layout/password_view.xml +++ b/android/quest/src/main/res/layout/password_view.xml @@ -1,45 +1,39 @@ - + android:orientation="vertical"> + android:layout_height="wrap_content" /> + android:layout_height="wrap_content" /> + android:orientation="vertical"> + android:layout_height="wrap_content"> + + android:maxLines="1" /> diff --git a/android/quest/src/test/java/org/smartregister/fhircore/quest/ui/login/LoginViewModelTest.kt b/android/quest/src/test/java/org/smartregister/fhircore/quest/ui/login/LoginViewModelTest.kt index 9c61a4ff8a..5f0b9d57f1 100644 --- a/android/quest/src/test/java/org/smartregister/fhircore/quest/ui/login/LoginViewModelTest.kt +++ b/android/quest/src/test/java/org/smartregister/fhircore/quest/ui/login/LoginViewModelTest.kt @@ -33,6 +33,7 @@ import io.mockk.verify import java.net.SocketTimeoutException import java.net.UnknownHostException import javax.inject.Inject +import kotlin.test.assertEquals import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.internal.http.RealResponseBody @@ -638,6 +639,25 @@ internal class LoginViewModelTest : RobolectricTest() { verify { workManager.enqueue(any()) } } + @Test + fun testWritePractitionerDetailsToShredPrefSavesPractitionerLocationId() { + val locationId = "ABCD123" + loginViewModel.writePractitionerDetailsToShredPref( + careTeams = listOf(""), + careTeam = listOf(""), + organization = listOf(""), + organizations = listOf(""), + location = listOf(""), + locations = listOf(locationId), + fhirPractitionerDetails = PractitionerDetails(), + locationHierarchies = listOf(LocationHierarchy()), + ) + assertEquals( + locationId, + sharedPreferencesHelper.read(SharedPreferenceKey.PRACTITIONER_LOCATION_ID.name), + ) + } + private fun updateCredentials() { loginViewModel.run { onUsernameUpdated(thisUsername) diff --git a/docs/engineering/android-app/configuring/config-types/ImplementationGuide.mdx b/docs/engineering/android-app/configuring/config-types/ImplementationGuide.mdx index 38f70a206d..e24d8db1fb 100644 --- a/docs/engineering/android-app/configuring/config-types/ImplementationGuide.mdx +++ b/docs/engineering/android-app/configuring/config-types/ImplementationGuide.mdx @@ -1,15 +1,16 @@ -#Implementation Guide +# Implementation Guide This is a FHIR resource that is used for version management of the application. Currently an Implementation Guide should point to a Composition resource. The idea is that a given app version should use the resources that a given Composition resource is pointing to. In the sample JSON below, the Implementation Guide points to a composition with an id 8294. The valueRange object implies that the composition resource in this Implementation guide supports applications with `version_code` between 1 to 10. -#Fetching an Implementation Guide. +## Fetching an Implementation Guide. We need to get an Implementation Guide before user authentication. And for this to work, your project should have a version of [fhir-gateway](https://github.com/onaio/fhir-gateway-extension) that has the ImplementationGuide endpoint whitelisted. The ideal query to use to fetch an implementation guide is `ImplementationGuide?name=zeir&context-quantity=le10&_sort=-context-quantity&_count=1`. The url queries `context-quantity=le10&_sort=-context-quantity&_count=1` ensures that you get the Implementation Guide whose useContext.valueRange.high.value is 10 or highest value near 10. -#Sample JSON +## Sample JSON +``` json { "resourceType": "ImplementationGuide", "id": "12967310", @@ -65,3 +66,4 @@ The ideal query to use to fetch an implementation guide is `ImplementationGuide? ] } } +```