Skip to content

Commit

Permalink
Merge branch 'mwcore-dev' into mwcore-sdc-V1.0.0-preview15-SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
evance-mose authored Sep 8, 2023
2 parents 4de2e0c + 04e1cb0 commit 360ec91
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ constructor(
const val ID = "_id"
const val COUNT = "count"
const val DEFAULT_COUNT = "100"
const val DEFAULT_TASK_FILTER_TAG_META_CODING_SYSTEM = "https://d-tree.org/fhir/task-filter-tag"
const val TYPE_REFERENCE_DELIMITER = "/"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.smartregister.fhircore.engine.configuration.app
import kotlinx.serialization.Serializable
import org.smartregister.fhircore.engine.configuration.Configuration
import org.smartregister.fhircore.engine.configuration.ConfigurationRegistry
import org.smartregister.fhircore.engine.configuration.ConfigurationRegistry.Companion.DEFAULT_TASK_FILTER_TAG_META_CODING_SYSTEM

@Serializable
data class ApplicationConfiguration(
Expand All @@ -31,7 +32,8 @@ data class ApplicationConfiguration(
var applicationName: String = "",
var appLogoIconResourceFile: String = "ic_default_logo",
var patientTypeFilterTagViaMetaCodingSystem: String = "",
var count: String = ConfigurationRegistry.DEFAULT_COUNT
var count: String = ConfigurationRegistry.DEFAULT_COUNT,
var taskFilterTagViaMetaCodingSystem: String = DEFAULT_TASK_FILTER_TAG_META_CODING_SYSTEM
) : Configuration

/**
Expand All @@ -57,7 +59,8 @@ fun applicationConfigurationOf(
applicationName: String = "",
appLogoIconResourceFile: String = "",
patientTypeFilterTagViaMetaCodingSystem: String = "",
count: String = ConfigurationRegistry.DEFAULT_COUNT
count: String = ConfigurationRegistry.DEFAULT_COUNT,
taskFilterTagViaMetaCodingSystem: String = ""
): ApplicationConfiguration =
ApplicationConfiguration(
appId = appId,
Expand All @@ -69,5 +72,6 @@ fun applicationConfigurationOf(
applicationName = applicationName,
appLogoIconResourceFile = appLogoIconResourceFile,
patientTypeFilterTagViaMetaCodingSystem = patientTypeFilterTagViaMetaCodingSystem,
count = count
count = count,
taskFilterTagViaMetaCodingSystem = taskFilterTagViaMetaCodingSystem
)
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class ApplicationConfigurationTest {
applicationName = "Test App",
appLogoIconResourceFile = "ic_launcher",
patientTypeFilterTagViaMetaCodingSystem = "test-filter-tag",
count = "100"
count = "100",
taskFilterTagViaMetaCodingSystem = "task-filter-tag"
)
Assert.assertEquals("ancApp", applicationConfiguration.appId)
Assert.assertEquals("classification", applicationConfiguration.classification)
Expand All @@ -46,6 +47,10 @@ class ApplicationConfigurationTest {
applicationConfiguration.patientTypeFilterTagViaMetaCodingSystem
)
Assert.assertEquals("100", applicationConfiguration.count)
Assert.assertEquals(
"task-filter-tag",
applicationConfiguration.taskFilterTagViaMetaCodingSystem
)
}

@Test
Expand All @@ -60,7 +65,8 @@ class ApplicationConfigurationTest {
applicationName = "Test App",
appLogoIconResourceFile = "ic_launcher",
patientTypeFilterTagViaMetaCodingSystem = "test-filter-tag",
count = "100"
count = "100",
taskFilterTagViaMetaCodingSystem = "task-filter-tag"
)
Assert.assertEquals("ancApp", applicationConfiguration.appId)
Assert.assertEquals("classification", applicationConfiguration.classification)
Expand All @@ -73,5 +79,9 @@ class ApplicationConfigurationTest {
applicationConfiguration.patientTypeFilterTagViaMetaCodingSystem
)
Assert.assertEquals("100", applicationConfiguration.count)
Assert.assertEquals(
"task-filter-tag",
applicationConfiguration.taskFilterTagViaMetaCodingSystem
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import org.smartregister.fhircore.engine.sync.SyncBroadcaster
import org.smartregister.fhircore.engine.ui.questionnaire.QuestionnaireActivity
import org.smartregister.fhircore.engine.ui.questionnaire.QuestionnaireType
import org.smartregister.fhircore.engine.util.extension.asReference
import org.smartregister.fhircore.engine.util.extension.extractId
import org.smartregister.fhircore.engine.util.extension.isGuardianVisit
import org.smartregister.fhircore.quest.R
import org.smartregister.fhircore.quest.data.patient.model.PatientPagingSourceState
Expand Down Expand Up @@ -108,27 +107,6 @@ constructor(

private val isClientVisit: MutableState<Boolean> = mutableStateOf(true)

fun completedTask(value: String) {
patientProfileData?.let { data ->
if (data is ProfileData.HivProfileData) {
val patientData =
data.copy(
tasks =
data.tasks.map { task ->
if (task.reasonReference.extractId() == value) {
task.status = Task.TaskStatus.COMPLETED
task
} else task
}
)
_patientProfileViewDataFlow.value =
profileViewDataMapper.transformInputToOutputModel(patientData) as
ProfileViewData.PatientProfileViewData
patientProfileData = patientData
}
}
}

init {
syncBroadcaster.registerSyncListener(
object : OnSyncListener {
Expand Down Expand Up @@ -189,7 +167,7 @@ constructor(
hivPatientProfileData.copy(
tasks =
hivPatientProfileData.tasks.filter {
it.isGuardianVisit(applicationConfiguration.patientTypeFilterTagViaMetaCodingSystem)
it.isGuardianVisit(applicationConfiguration.taskFilterTagViaMetaCodingSystem)
}
)
_patientProfileViewDataFlow.value =
Expand Down

0 comments on commit 360ec91

Please sign in to comment.