Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

568 | Quest Patient List View with configurable views #595

Merged
merged 35 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a20b649
Setup quest application
ellykits Sep 28, 2021
7a07a6c
Implement authentication
ellykits Sep 29, 2021
28426f4
Application flowgit status
Sep 29, 2021
8ac940c
Application login flow fix
Sep 29, 2021
816b9d1
Implement login screen
ellykits Sep 29, 2021
3d573b3
merge quest-app branch
Sep 29, 2021
0713b57
Load and show config from json
Sep 30, 2021
7b49dc6
Hide unneccessary ui widgets
Sep 30, 2021
6aa83ab
Patient list view with configurable views
Oct 1, 2021
f6758c2
Merge with main and resolve conflicts
Oct 1, 2021
6d8754a
Load config from Binary Resource | Unit tests
Oct 4, 2021
58ca2c5
Merge branch 'main' into 568-quest-list
maimoonak Oct 4, 2021
52ad46f
Register button style | Menu Option in-app implementation
Oct 4, 2021
a0ece6a
Quest v0.1 / G6PD: Patient Profile View (#600)
owais-vd Oct 4, 2021
ca14d5c
Merge and add details screens into flow
Oct 4, 2021
d46ddd6
Fix for bottom nav and rounded corner button test
Oct 4, 2021
2f42997
Adding quest to codecov settings
maimoonak Oct 5, 2021
223f473
Merge branch 'main' into 568-quest-list
maimoonak Oct 5, 2021
e9f6e8d
Merge branch 'main' into 568-quest-list
ndegwamartin Oct 5, 2021
9c2411d
Tests for Dynamic Config
Oct 5, 2021
8afb41a
Merge branch '568-quest-list' of https://github.com/opensrp/fhircore …
Oct 5, 2021
05d8561
spotless apply
Oct 5, 2021
cc626f0
apply codecov token
maimoonak Oct 6, 2021
aeac693
Merge main
Oct 8, 2021
9b3f3ed
Merge branch '568-quest-list' of https://github.com/opensrp/fhircore …
Oct 8, 2021
8b93f9d
Test coverage increased
Oct 8, 2021
b106016
RegisterFragment tests
Oct 8, 2021
5f7bc38
Fix failing test
Oct 8, 2021
218e8d7
OutOfMemoryError fix try
Oct 7, 2021
0cd75b4
Shadow implement the WorkerContextProvider
Oct 8, 2021
72c0469
Fix faily vaccine actitvity test
Oct 8, 2021
e9a3168
EncounterListViewTest ignore
Oct 7, 2021
f09e37b
Ignore measure evaluate test
Oct 8, 2021
21e7039
Unit tests for Register activity views
Oct 8, 2021
fe285c6
Merge branch 'main' into 568-quest-list
pld Oct 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
env:
FHIRCORE_USERNAME: ${{ secrets.FHIRCORE_USERNAME }}
FHIRCORE_ACCESS_TOKEN: ${{ secrets.FHIRCORE_ACCESS_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

steps:
- name: Checkout 🛎️
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added class for Measure report evaluation which will be used in ANC application
- ANC | Added Condition resource to sync params list
- Moved Token to secure storage from AccountManager
- QUEST | Patient List, Load Config from server
- QUEST | Added Patient Profile View

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{
"linkId": "PR-name",
"type": "group",
"text": "Family Head Information",
"text": "Demographic Information",
"definition": "http://hl7.org/fhir/StructureDefinition/Patient#Patient.name",
"item": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AncRegisterActivity : BaseRegisterActivity() {
)
)

override fun onSideMenuOptionSelected(item: MenuItem): Boolean {
override fun onMenuOptionSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_item_family -> startActivity(Intent(this, FamilyRegisterActivity::class.java))
R.id.menu_item_anc -> startActivity(Intent(this, AncRegisterActivity::class.java))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class FamilyRegisterActivity : BaseRegisterActivity() {
)
)

override fun onSideMenuOptionSelected(item: MenuItem): Boolean {
override fun onMenuOptionSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_item_family -> startActivity(Intent(this, FamilyRegisterActivity::class.java))
R.id.menu_item_anc -> startActivity(Intent(this, AncRegisterActivity::class.java))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ internal class AncRegisterActivityTest : ActivityRobolectricTest() {
fun testOnSideMenuOptionSelectedShouldVerifyActivityStarting() {

val menuItemFamily = RoboMenuItem(R.id.menu_item_family)
ancRegisterActivity.onSideMenuOptionSelected(menuItemFamily)
ancRegisterActivity.onMenuOptionSelected(menuItemFamily)

var expectedIntent = Intent(ancRegisterActivity, FamilyRegisterActivity::class.java)
var actualIntent =
Expand All @@ -127,7 +127,7 @@ internal class AncRegisterActivityTest : ActivityRobolectricTest() {
assertEquals(expectedIntent.component, actualIntent.component)

val menuItemAnc = RoboMenuItem(R.id.menu_item_anc)
ancRegisterActivity.onSideMenuOptionSelected(menuItemAnc)
ancRegisterActivity.onMenuOptionSelected(menuItemAnc)

expectedIntent = Intent(ancRegisterActivity, AncRegisterActivity::class.java)
actualIntent =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ internal class FamilyRegisterActivityTest : ActivityRobolectricTest() {
fun testOnSideMenuOptionSelectedShouldVerifyActivityStarting() {

val menuItemFamily = RoboMenuItem(R.id.menu_item_family)
familyRegisterActivity.onSideMenuOptionSelected(menuItemFamily)
familyRegisterActivity.onMenuOptionSelected(menuItemFamily)

var expectedIntent = Intent(familyRegisterActivity, FamilyRegisterActivity::class.java)
var actualIntent =
Expand All @@ -134,7 +134,7 @@ internal class FamilyRegisterActivityTest : ActivityRobolectricTest() {
assertEquals(expectedIntent.component, actualIntent.component)

val menuItemAnc = RoboMenuItem(R.id.menu_item_anc)
familyRegisterActivity.onSideMenuOptionSelected(menuItemAnc)
familyRegisterActivity.onMenuOptionSelected(menuItemAnc)

expectedIntent = Intent(familyRegisterActivity, AncRegisterActivity::class.java)
actualIntent =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PatientRegisterActivity : BaseRegisterActivity() {
)
)

override fun onSideMenuOptionSelected(item: MenuItem): Boolean {
override fun onMenuOptionSelected(item: MenuItem): Boolean {
return true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,32 @@ package org.smartregister.fhircore.eir.ui.patient.register

import android.app.Activity
import androidx.core.content.ContextCompat
import io.mockk.every
import io.mockk.mockk
import io.mockk.spyk
import kotlinx.coroutines.test.runBlockingTest
import org.junit.Assert
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Rule
import org.junit.Test
import org.robolectric.Robolectric
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
import org.robolectric.fakes.RoboMenuItem
import org.smartregister.fhircore.eir.R
import org.smartregister.fhircore.eir.activity.ActivityRobolectricTest
import org.smartregister.fhircore.eir.coroutine.CoroutineTestRule
import org.smartregister.fhircore.eir.shadow.EirApplicationShadow
import org.smartregister.fhircore.eir.shadow.FakeKeyStore
import org.smartregister.fhircore.eir.shadow.ShadowNpmPackageProvider
import org.smartregister.fhircore.engine.ui.register.model.SideMenuOption

@Config(shadows = [EirApplicationShadow::class, ShadowNpmPackageProvider::class])
class PatientRegisterActivityTest : ActivityRobolectricTest() {

private lateinit var patientRegisterActivity: PatientRegisterActivity
@get:Rule var coroutinesTestRule = CoroutineTestRule()

@Before
fun setUp() {
Expand All @@ -62,7 +70,22 @@ class PatientRegisterActivityTest : ActivityRobolectricTest() {

@Test
fun testOnSideMenuOptionSelectedShouldReturnTrue() {
Assert.assertTrue(patientRegisterActivity.onSideMenuOptionSelected(RoboMenuItem()))
Assert.assertTrue(patientRegisterActivity.onMenuOptionSelected(RoboMenuItem()))
}

@Test
fun testUpdateCountShouldSetRightValue() = runBlockingTest {
val spy = spyk(patientRegisterActivity)
every { spy.findSideMenuItem(any()) } returns
RoboMenuItem().apply { itemId = R.id.menu_item_covax }

val sideMenuOption =
SideMenuOption(R.id.menu_item_covax, R.string.covax_app, mockk(), countMethod = { 123 })
sideMenuOption.count = 0

spy.updateCount(sideMenuOption)

Assert.assertEquals(123, sideMenuOption.count)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,34 +95,32 @@ class RecordVaccineActivityTest : ActivityRobolectricTest() {
}

@Test
fun testVerifyRecordedVaccineSavedDialogProperty() {
coroutinesTestRule.runBlockingTest {
val spyViewModel =
spyk((recordVaccineActivity.questionnaireViewModel as RecordVaccineViewModel))
recordVaccineActivity.questionnaireViewModel = spyViewModel

val callback = slot<Observer<PatientVaccineSummary>>()

coEvery { spyViewModel.performExtraction(any(), any(), any()) } returns
Bundle().apply { addEntry().apply { resource = getImmunization() } }

every { spyViewModel.getVaccineSummary(any()) } returns
mockk<LiveData<PatientVaccineSummary>>().apply {
every { observe(any(), capture(callback)) } answers
{
callback.captured.onChanged(PatientVaccineSummary(1, "vaccine"))
}
}
fun testVerifyRecordedVaccineSavedDialogProperty() = runBlockingTest {
val spyViewModel =
spyk((recordVaccineActivity.questionnaireViewModel as RecordVaccineViewModel))
recordVaccineActivity.questionnaireViewModel = spyViewModel

Assert.assertNull(ShadowAlertDialog.getLatestAlertDialog())
recordVaccineActivity.handleQuestionnaireResponse(mockk())
val callback = slot<Observer<PatientVaccineSummary>>()

val dialog = shadowOf(ShadowAlertDialog.getLatestAlertDialog())
coEvery { spyViewModel.performExtraction(any(), any(), any()) } returns
Bundle().apply { addEntry().apply { resource = getImmunization() } }

Assert.assertNotNull(dialog)
Assert.assertEquals("Initially received vaccine", dialog.title)
Assert.assertEquals("Second vaccine dose should be same as first", dialog.message)
}
every { spyViewModel.getVaccineSummary(any()) } returns
mockk<LiveData<PatientVaccineSummary>>().apply {
every { observe(any(), capture(callback)) } answers
{
callback.captured.onChanged(PatientVaccineSummary(1, "vaccine"))
}
}

Assert.assertNull(ShadowAlertDialog.getLatestAlertDialog())
recordVaccineActivity.handleQuestionnaireResponse(mockk())

val dialog = shadowOf(ShadowAlertDialog.getLatestAlertDialog())

Assert.assertNotNull(dialog)
Assert.assertEquals("Initially received vaccine", dialog.title)
Assert.assertEquals("Second vaccine dose should be same as first", dialog.message)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@

package org.smartregister.fhircore.engine.configuration.app

import android.content.Context
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.Serializable
import org.smartregister.fhircore.engine.util.extension.decodeJson
import org.smartregister.fhircore.engine.util.extension.loadBinaryResourceConfiguration

@Serializable
data class ApplicationConfiguration(
var oauthServerBaseUrl: String,
var fhirServerBaseUrl: String,
var id: String = "",
var theme: String = "",
var oauthServerBaseUrl: String = "",
var fhirServerBaseUrl: String = "",
var clientId: String = "",
var clientSecret: String = "",
var scope: String = "openid",
Expand All @@ -44,6 +50,8 @@ data class ApplicationConfiguration(
* @param syncInterval Sets the periodic sync interval in seconds. Default 30.
*/
fun applicationConfigurationOf(
id: String = "",
theme: String = "",
oauthServerBaseUrl: String = "",
fhirServerBaseUrl: String = "",
clientId: String = "",
Expand All @@ -53,6 +61,8 @@ fun applicationConfigurationOf(
syncInterval: Long = 30
): ApplicationConfiguration =
ApplicationConfiguration(
id = id,
theme = theme,
oauthServerBaseUrl = oauthServerBaseUrl,
fhirServerBaseUrl = fhirServerBaseUrl,
clientId = clientId,
Expand All @@ -61,3 +71,15 @@ fun applicationConfigurationOf(
languages = languages,
syncInterval = syncInterval
)

private const val APPLICATION_CONFIG_FILE = "application_config.json"

fun Context.loadApplicationConfiguration(id: String): ApplicationConfiguration {
return runBlocking { loadBinaryResourceConfiguration(id) }
?: assets
.open(APPLICATION_CONFIG_FILE)
.bufferedReader()
.use { it.readText() }
.decodeJson<List<ApplicationConfiguration>>()
.first { it.id == id }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,30 @@ package org.smartregister.fhircore.engine.configuration.view

import android.content.Context
import androidx.compose.runtime.Stable
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.Serializable
import org.smartregister.fhircore.engine.R
import org.smartregister.fhircore.engine.configuration.Configuration
import org.smartregister.fhircore.engine.util.extension.decodeJson
import org.smartregister.fhircore.engine.util.extension.loadBinaryResourceConfiguration

@Serializable
@Stable
data class RegisterViewConfiguration(
var id: String,
var appTitle: String,
var filterText: String,
var searchBarHint: String,
var newClientButtonText: String,
var newClientButtonStyle: String,
var showSearchBar: Boolean = true,
var showFilter: Boolean = true,
var switchLanguages: Boolean = true,
var showScanQRCode: Boolean = true,
var showNewClientButton: Boolean = true,
var registrationForm: String = "patient-registration",
var showSideMenu: Boolean = true,
var showBottomMenu: Boolean = false
) : Configuration

/**
Expand All @@ -54,28 +61,48 @@ data class RegisterViewConfiguration(
*/
@Stable
fun Context.registerViewConfigurationOf(
id: String = this.getString(R.string.default_app_title),
appTitle: String = this.getString(R.string.default_app_title),
filterText: String = this.getString(R.string.show_overdue),
searchBarHint: String = this.getString(R.string.search_hint),
newClientButtonText: String = this.getString(R.string.register_new_client),
newClientButtonStyle: String = "",
showSearchBar: Boolean = true,
showFilter: Boolean = true,
switchLanguages: Boolean = true,
showScanQRCode: Boolean = true,
showNewClientButton: Boolean = true,
languages: List<String> = listOf("en"),
registrationForm: String = "patient-registration"
registrationForm: String = "patient-registration",
showSideMenu: Boolean = true,
showBottomMenu: Boolean = false
): RegisterViewConfiguration {
return RegisterViewConfiguration(
id = id,
appTitle = appTitle,
filterText = filterText,
searchBarHint = searchBarHint,
newClientButtonText = newClientButtonText,
newClientButtonStyle = newClientButtonStyle,
showSearchBar = showSearchBar,
showFilter = showFilter,
switchLanguages = switchLanguages,
showScanQRCode = showScanQRCode,
showNewClientButton = showNewClientButton,
registrationForm = registrationForm,
showSideMenu = showSideMenu,
showBottomMenu = showBottomMenu
)
}

private const val REGISTER_VIEW_CONFIG_FILE = "register_view_config.json"

fun Context.loadRegisterViewConfiguration(id: String): RegisterViewConfiguration {
return runBlocking { loadBinaryResourceConfiguration(id) }
?: assets
.open(REGISTER_VIEW_CONFIG_FILE)
.bufferedReader()
.use { it.readText() }
.decodeJson<List<RegisterViewConfiguration>>()
.first { it.id == id }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@
package org.smartregister.fhircore.engine.ui.base

import android.content.Context
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import java.util.Locale
import org.smartregister.fhircore.engine.util.SharedPreferencesHelper
import org.smartregister.fhircore.engine.util.extension.getTheme
import org.smartregister.fhircore.engine.util.extension.setAppLocale

abstract class BaseMultiLanguageActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val themePref = SharedPreferencesHelper.read(SharedPreferencesHelper.THEME, "")!!
theme.applyStyle(getTheme(themePref), true)
}

override fun attachBaseContext(baseContext: Context) {
val lang =
Expand Down
Loading