Skip to content

Commit

Permalink
Merge branch 'main' into stack-widget
Browse files Browse the repository at this point in the history
  • Loading branch information
dubdabasoduba authored May 25, 2024
2 parents 5d5b94f + ab3170f commit 3219126
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 21 deletions.
4 changes: 2 additions & 2 deletions android/buildSrc/src/main/kotlin/BuildConfigs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ constructor(
)
}

private fun writePractitionerDetailsToShredPref(
fun writePractitionerDetailsToShredPref(
careTeam: List<String>,
organization: List<String>,
location: List<String>,
Expand Down Expand Up @@ -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) {
Expand Down
22 changes: 8 additions & 14 deletions android/quest/src/main/res/layout/password_view.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,39 @@
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/item_margin_horizontal"
android:layout_marginVertical="@dimen/item_margin_vertical"
android:orientation="vertical"
>
android:orientation="vertical">

<com.google.android.fhir.datacapture.views.HeaderView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
android:layout_height="wrap_content" />

<com.google.android.fhir.datacapture.views.MediaView
android:id="@+id/item_media"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
android:layout_height="wrap_content" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
android:orientation="vertical">

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/password_input_layout"
style="?attr/questionnaireTextInputLayoutStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
android:layout_height="wrap_content">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/password_edit_text"
style="?attr/questionnaireTextInputEditTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:inputType="textPassword"
/>
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -638,6 +639,25 @@ internal class LoginViewModelTest : RobolectricTest() {
verify { workManager.enqueue(any<OneTimeWorkRequest>()) }
}

@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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -65,3 +66,4 @@ The ideal query to use to fetch an implementation guide is `ImplementationGuide?
]
}
}
```

0 comments on commit 3219126

Please sign in to comment.