Skip to content

Commit

Permalink
update data
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenreup committed Sep 21, 2023
1 parent 491ce27 commit 7913dd3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ constructor(
onFetchPractitioner = { bundleResult ->
_showProgressBar.postValue(false)
if (bundleResult.isSuccess) {
updateNavigateHome(true)
val bundle = bundleResult.getOrDefault(Bundle())
savePractitionerDetails(bundle) {
_showProgressBar.postValue(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.rounded.BugReport
import androidx.compose.material.icons.rounded.ChevronRight
import androidx.compose.material.icons.rounded.Download
import androidx.compose.material.icons.rounded.Logout
import androidx.compose.material.icons.rounded.Sync
import androidx.compose.material.rememberModalBottomSheetState
Expand Down Expand Up @@ -105,13 +106,18 @@ fun SettingsScreen(
Column(modifier = modifier.padding(paddingValues).padding(vertical = 20.dp)) {
InfoCard(viewModel = settingsViewModel)
Divider(color = DividerColor)
UserProfileRow(
icon = Icons.Rounded.Download,
text = "Re-fetch Practitioner",
clickListener = settingsViewModel::fetchPractitionerDetails,
modifier = modifier
)
UserProfileRow(
icon = Icons.Rounded.Sync,
text = stringResource(id = R.string.sync),
clickListener = settingsViewModel::runSync,
modifier = modifier
)

UserProfileRow(
icon = Icons.Rounded.BugReport,
text = "Dev Menu",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ import com.google.android.fhir.logicalId
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.hl7.fhir.r4.model.Bundle
import org.hl7.fhir.r4.model.CareTeam
import org.hl7.fhir.r4.model.Location
import org.hl7.fhir.r4.model.Organization
import org.hl7.fhir.r4.model.Practitioner
import org.hl7.fhir.r4.model.ResourceType
import org.smartregister.fhircore.engine.auth.AccountAuthenticator
import org.smartregister.fhircore.engine.configuration.ConfigurationRegistry
import org.smartregister.fhircore.engine.data.local.DefaultRepository
import org.smartregister.fhircore.engine.data.remote.auth.KeycloakService
import org.smartregister.fhircore.engine.data.remote.fhir.resource.FhirResourceService
import org.smartregister.fhircore.engine.domain.model.Language
Expand All @@ -42,8 +45,12 @@ 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.annotation.ExcludeFromJacocoGeneratedReport
import org.smartregister.fhircore.engine.util.extension.extractLogicalIdUuid
import org.smartregister.fhircore.engine.util.extension.getActivity
import org.smartregister.fhircore.engine.util.extension.launchActivityWithNoBackStackHistory
import org.smartregister.fhircore.engine.util.extension.practitionerEndpointUrl
import org.smartregister.fhircore.engine.util.extension.valueToString
import org.smartregister.model.practitioner.PractitionerDetails

@HiltViewModel
@ExcludeFromJacocoGeneratedReport
Expand All @@ -53,9 +60,10 @@ constructor(
val syncBroadcaster: SyncBroadcaster,
val accountAuthenticator: AccountAuthenticator,
val secureSharedPreference: SecureSharedPreference,
val sharedPreferencesHelper: SharedPreferencesHelper,
val sharedPreferences: SharedPreferencesHelper,
val configurationRegistry: ConfigurationRegistry,
val fhirEngine: FhirEngine,
val defaultRepository: DefaultRepository,
val keycloakService: KeycloakService,
val fhirResourceService: FhirResourceService,
) : ViewModel() {
Expand All @@ -72,7 +80,7 @@ constructor(

private suspend fun fetchData() {
var practitionerName: String? = null
sharedPreferencesHelper.read(
sharedPreferences.read(
key = SharedPreferenceKey.PRACTITIONER_ID.name,
defaultValue = null
)
Expand All @@ -82,7 +90,7 @@ constructor(
}

val organizationIds =
sharedPreferencesHelper.read<List<String>>(
sharedPreferences.read<List<String>>(
key = ResourceType.Organization.name,
decodeWithGson = true
)
Expand All @@ -92,7 +100,7 @@ constructor(
}

val locationIds =
sharedPreferencesHelper.read<List<String>>(
sharedPreferences.read<List<String>>(
key = ResourceType.Location.name,
decodeWithGson = true
)
Expand All @@ -102,7 +110,7 @@ constructor(
}

val careTeamIds =
sharedPreferencesHelper.read<List<String>>(
sharedPreferences.read<List<String>>(
key = ResourceType.CareTeam.name,
decodeWithGson = true
)
Expand Down Expand Up @@ -136,7 +144,10 @@ constructor(
}

fun retrieveUsername(): String? =
sharedPreferencesHelper.read<Practitioner>(key = LOGGED_IN_PRACTITIONER, decodeWithGson = true)
sharedPreferences.read<Practitioner>(key = LOGGED_IN_PRACTITIONER, decodeWithGson = true)
?.nameFirstRep
?.nameAsSingleString

fun fetchPractitionerDetails() {
}
}

0 comments on commit 7913dd3

Please sign in to comment.