Skip to content

Commit

Permalink
Merge branch 'main' into interpolate-conditionalfhirpathexpressions
Browse files Browse the repository at this point in the history
  • Loading branch information
LZRS authored Oct 4, 2024
2 parents 9441982 + 8cf03cf commit 0ce6f51
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,29 @@ interface ConfigService {
description = "Search the status field"
}

return listOf(activeGroupSearchParameter, flagStatusSearchParameter)
val medicationSortSearchParameter =
SearchParameter().apply {
url = MEDICATION_SORT_URL
addBase("Medication")
name = SORT_SEARCH_PARAM
code = SORT_SEARCH_PARAM
type = Enumerations.SearchParamType.NUMBER
expression = "Medication.extension.where(url = '$MEDICATION_SORT_URL').value"
description = "Search the sort field"
}

return listOf(
activeGroupSearchParameter,
flagStatusSearchParameter,
medicationSortSearchParameter,
)
}

companion object {
const val ACTIVE_SEARCH_PARAM = "active"
const val APP_VERSION = "AppVersion"
const val STATUS_SEARCH_PARAM = "status"
const val SORT_SEARCH_PARAM = "sort"
const val MEDICATION_SORT_URL = "http://smartregister.org/SearchParameter/medication-sort"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import org.smartregister.fhircore.engine.rule.CoroutineTestRule
import org.smartregister.fhircore.engine.rulesengine.services.LocationService
import org.smartregister.fhircore.engine.util.DispatcherProvider
import org.smartregister.fhircore.engine.util.extension.SDF_YYYY_MM_DD
import org.smartregister.fhircore.engine.util.extension.plusYears
import org.smartregister.fhircore.engine.util.fhirpath.FhirPathDataExtractor

@HiltAndroidTest
Expand Down Expand Up @@ -424,7 +425,7 @@ class RulesFactoryTest : RobolectricTest() {
@Test
fun mapResourceToLabeledCSVReturnsCorrectLabels() {
val fhirPathExpression = "Patient.active and (Patient.birthDate >= today() - 5 'years')"
val resource = Patient().setActive(true).setBirthDate(LocalDate.parse("2019-10-03").toDate())
val resource = Patient().setActive(true).setBirthDate(Date().plusYears(-5))

val result = rulesEngineService.mapResourceToLabeledCSV(resource, fhirPathExpression, "CHILD")
Assert.assertEquals("CHILD", result)
Expand Down

0 comments on commit 0ce6f51

Please sign in to comment.