Skip to content

Commit

Permalink
fix task order tag filter
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenreup committed Jan 25, 2024
1 parent dcd4b46 commit a8cd46e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ constructor(
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 DEFAULT_TASK_ORDER_FILTER_TAG_META_CODING_SYSTEM = "https://d-tree.org"
const val TYPE_REFERENCE_DELIMITER = "/"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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
import org.smartregister.fhircore.engine.configuration.ConfigurationRegistry.Companion.DEFAULT_TASK_ORDER_FILTER_TAG_META_CODING_SYSTEM

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ constructor(

override suspend fun loadProfileData(appFeatureName: String?, resourceId: String): ProfileData {
val patient = defaultRepository.loadResource<Patient>(resourceId)!!
val metaCodingSystemTag = getApplicationConfiguration().patientTypeFilterTagViaMetaCodingSystem
val configuration = getApplicationConfiguration()

return ProfileData.HivProfileData(
logicalId = patient.logicalId,
Expand All @@ -165,13 +165,13 @@ constructor(
phoneContacts = patient.extractTelecom(),
chwAssigned = patient.generalPractitionerFirstRep,
showIdentifierInProfile = true,
healthStatus = patient.extractHealthStatusFromMeta(metaCodingSystemTag),
healthStatus = patient.extractHealthStatusFromMeta(configuration.patientTypeFilterTagViaMetaCodingSystem),
tasks =
patient
.activeTasks()
.sortedWith(
compareBy<Task>(
{ it.clinicVisitOrder(metaCodingSystemTag) ?: Double.MAX_VALUE },
compareBy(
{ it.clinicVisitOrder(configuration.taskOrderFilterTagViaMetaCodingSystem) ?: Double.MAX_VALUE },
// tasks with no clinicVisitOrder, would be sorted with Task#description
{ it.description }
)
Expand Down

0 comments on commit a8cd46e

Please sign in to comment.