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

Upgrade FHIR SDK dependencies ⬆️ #3423

Merged
merged 43 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c04024f
Upgrade FHIR SDK depenencies ⬆️
ndegwamartin Jul 31, 2024
e2da55e
Upragde SDC library
ndegwamartin Aug 8, 2024
f6bbada
Replace JWT token parser library
ndegwamartin Aug 9, 2024
64c6297
Fix CQL Content Test
ndegwamartin Aug 9, 2024
7e616ac
Fix unit tests ✅
ndegwamartin Aug 13, 2024
4f3c74c
Refactor to remove Dispatch Provider
ndegwamartin Aug 13, 2024
6d35db9
Fix unit test ✅
ndegwamartin Aug 16, 2024
21420ae
Refactor Knowledge Manager Resources Persistance
ndegwamartin Aug 19, 2024
6920620
Refactor CQL Content tests
ndegwamartin Aug 20, 2024
fdc9097
Fix AppSettingModel unit tests ✅
ndegwamartin Aug 20, 2024
ed1dee7
Refactor Cancel previous worflow to use native commands
ndegwamartin Aug 20, 2024
35f22b4
Upgrade CI API level to 34
ndegwamartin Aug 20, 2024
9d83a1d
Clean up Translations
ndegwamartin Aug 21, 2024
8aa5740
Fix measure reporting
ndegwamartin Aug 28, 2024
5074b5a
Fix Workflow Configuration
ndegwamartin Aug 28, 2024
e603cda
Fix QuestionnaireViewModel unit tests ✅
ndegwamartin Aug 28, 2024
25df56e
Clean up WorkManager after running unit tests
ndegwamartin Aug 29, 2024
9b9f922
Remove skyscreamer test dependency
ndegwamartin Aug 29, 2024
2cfe37c
Fix build 💚
ndegwamartin Aug 29, 2024
ff1e3c6
Clean up gradle dependencies configuration
ndegwamartin Sep 2, 2024
9a96a82
Move measure reporting evaluation to BG thread
ndegwamartin Sep 2, 2024
8ff7951
Fix MeasureReportRepositoryTest
ndegwamartin Sep 2, 2024
6c56419
Fix MeasureReportRepositoryTest
ndegwamartin Sep 2, 2024
4057e11
Fix MeasureReportViewModel unit tests ✅
ndegwamartin Sep 3, 2024
74f754d
Fix Measure Reporting
ndegwamartin Sep 9, 2024
5e6b203
Migrate Engine and Workflow libraries
ndegwamartin Sep 10, 2024
a1ef8cd
Update Workflow library
ndegwamartin Sep 11, 2024
ae6708d
Fix evaluate Population Measure
ndegwamartin Sep 11, 2024
afb4ade
Update SDC snapshot to 14.1
ndegwamartin Sep 13, 2024
3d7b2e2
Remove unrecommended forced portrait format
ndegwamartin Sep 13, 2024
affa880
Refactor from using deprecated KnowledgeManager methods loadResources
ndegwamartin Sep 13, 2024
37a462b
Clean up TOML catalog file
ndegwamartin Sep 16, 2024
d3250b2
Revert Knowledge Manager and Workflow Library Upgrades
ndegwamartin Sep 17, 2024
9774be9
Display symbol instead of unicode
FikriMilano Sep 18, 2024
c9d2bde
Refactor usage of FHIR JSONParser to support concurrency
ndegwamartin Sep 18, 2024
d2ffbb5
Update FHIR SDK library versions
ndegwamartin Sep 18, 2024
234c7d6
Geowidget configuration
ndegwamartin Sep 18, 2024
0a72665
Fix build 💚
ndegwamartin Sep 18, 2024
7f4da95
SDK Engine to RC3
ndegwamartin Sep 20, 2024
f694d0b
Fix build
ndegwamartin Sep 20, 2024
d3e1933
Merge remote-tracking branch 'origin/main' into migrate-deps
ndegwamartin Sep 24, 2024
053bfad
Fix build 💚
ndegwamartin Sep 24, 2024
9e3ed9e
Fix build 💚
ndegwamartin Sep 24, 2024
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
37 changes: 15 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
merge_group:
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FHIRCORE_USERNAME: ${{ secrets.FHIRCORE_USERNAME }}
FHIRCORE_ACCESS_TOKEN: ${{ secrets.FHIRCORE_ACCESS_TOKEN }}
Expand All @@ -21,13 +25,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [30]
api-level: [34]

steps:
- name: Cancel Previous workflow runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout 🛎️
uses: actions/checkout@v4

Expand Down Expand Up @@ -106,21 +106,17 @@ jobs:


- name: Upload Engine module test coverage report to Codecov
if: matrix.api-level == 30 # Only upload coverage on API level 30
if: matrix.api-level == 34 # Only upload coverage on API level 34
working-directory: android
run: bash <(curl -s https://codecov.io/bash) -F engine -f "engine/build/reports/jacoco/fhircoreJacocoReport/fhircoreJacocoReport.xml"

geowidget-tests:
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [30]
api-level: [34]

steps:
- name: Cancel Previous workflow runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout 🛎️
uses: actions/checkout@v4

Expand Down Expand Up @@ -198,20 +194,17 @@ jobs:
path: android/geowidget/build/reports

- name: Upload Geowidget module test coverage report to Codecov
if: matrix.api-level == 30 # Only upload coverage on API level 30
if: matrix.api-level == 34 # Only upload coverage on API level 34
working-directory: android
run: bash <(curl -s https://codecov.io/bash) -F geowidget -f "geowidget/build/reports/jacoco/fhircoreJacocoReport/fhircoreJacocoReport.xml"

quest-tests:
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [30]
steps:
- name: Cancel Previous workflow runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
api-level: [34]

steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

Expand Down Expand Up @@ -315,6 +308,6 @@ jobs:
path: android/quest/build/reports

- name: Upload Quest module test coverage report to Codecov
if: matrix.api-level == 30 # Only upload coverage on API level 30
if: matrix.api-level == 34 # Only upload coverage on API level 34
working-directory: android
run: bash <(curl -s https://codecov.io/bash) -F quest -f "quest/build/reports/jacoco/fhircoreJacocoReport/fhircoreJacocoReport.xml"
run: bash <(curl -s https://codecov.io/bash) -F quest -f "quest/build/reports/jacoco/fhircoreJacocoReport/fhircoreJacocoReport.xml"
12 changes: 4 additions & 8 deletions android/engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
`jacoco-report`
`ktlint`
ktlint
id("com.android.library")
id("kotlin-android")
id("kotlin-kapt")
Expand Down Expand Up @@ -162,7 +162,7 @@ dependencies {
api(libs.glide)
api(libs.knowledge) { exclude(group = "org.slf4j", module = "jcl-over-slf4j") }
api(libs.p2p.lib)
api(libs.jjwt)
api(libs.java.jwt)
api(libs.fhir.common.utils) { exclude(group = "org.slf4j", module = "jcl-over-slf4j") }
api(libs.runtime.livedata)
api(libs.foundation)
Expand All @@ -180,8 +180,8 @@ dependencies {
api(libs.data.capture) {
isTransitive = true
exclude(group = "ca.uhn.hapi.fhir")
exclude(group = "com.google.android.fhir", module = "engine")
exclude(group = "com.google.android.fhir", module = "common")
exclude(group = "org.smartregister", module = "common")
exclude(group = "org.slf4j", module = "jcl-over-slf4j")
}
api(libs.cqf.fhir.cr) {
Expand All @@ -194,23 +194,19 @@ dependencies {
exclude(group = "xerces")
exclude(group = "com.github.java-json-tools")
exclude(group = "org.codehaus.woodstox")
exclude(group = "com.google.android.fhir", module = "common")
exclude(group = "com.google.android.fhir", module = "engine")
exclude(group = "org.smartregister", module = "engine")
exclude(group = "com.github.ben-manes.caffeine")
}
api(libs.contrib.barcode) {
isTransitive = true
exclude(group = "org.smartregister", module = "data-capture")
exclude(group = "ca.uhn.hapi.fhir")
exclude(group = "com.google.android.fhir", module = "common")
exclude(group = "com.google.android.fhir", module = "engine")
}
api(libs.contrib.locationwidget) {
isTransitive = true
exclude(group = "org.smartregister", module = "data-capture")
exclude(group = "ca.uhn.hapi.fhir")
exclude(group = "com.google.android.fhir", module = "common")
exclude(group = "com.google.android.fhir", module = "engine")
}
api(libs.fhir.engine) {
isTransitive = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.google.android.fhir.FhirEngineProvider
import com.google.android.fhir.search.search
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest
import org.hl7.fhir.r4.model.Patient
import org.hl7.fhir.r4.model.Questionnaire
import org.hl7.fhir.r4.model.Resource
Expand Down Expand Up @@ -57,19 +58,15 @@ class FhirEngineExtensionKtTest {
}

@Test
fun test_search_time_searches_sequentially_and_short_running_query_waits() {
fun test_search_time_searches_sequentially_and_short_running_query_waits() = runTest {
val fetchedResources = mutableListOf<Resource>()
runBlocking {
launch {
val patients = fhirEngine.search<Patient> {}.map { it.resource }
fetchedResources += patients
}

launch {
val questionnaires = fhirEngine.search<Questionnaire> {}.map { it.resource }
fetchedResources += questionnaires
}
}
val patients = fhirEngine.search<Patient> {}.map { it.resource }
fetchedResources += patients

val questionnaires = fhirEngine.search<Questionnaire> {}.map { it.resource }
fetchedResources += questionnaires

val indexOfResultOfShortQuery =
fetchedResources.indexOfFirst { it.resourceType == ResourceType.Questionnaire }
val indexOfResultOfLongQuery =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ constructor(
private var _isNonProxy = BuildConfig.IS_NON_PROXY_APK
private val fhirContext = FhirContext.forR4Cached()
private val authConfiguration = configService.provideAuthConfiguration()
private val jsonParser = fhirContext.newJsonParser()

/**
* Retrieve configuration for the provided [ConfigType]. The JSON retrieved from [configsJsonMap]
Expand Down Expand Up @@ -629,9 +628,14 @@ constructor(
resource.idElement.idPart
}

return File(context.filesDir, "$fileName.json").apply {
writeText(jsonParser.encodeResourceToString(resource))
}
return File(
context.filesDir,
"$KNOWLEDGE_MANAGER_ASSETS_SUBFOLDER/${resource.resourceType}/$fileName.json",
)
.apply {
this.parentFile?.mkdirs()
writeText(fhirContext.newJsonParser().encodeResourceToString(resource))
}
}

/**
Expand Down Expand Up @@ -813,6 +817,7 @@ constructor(
const val PAGINATION_NEXT = "next"
const val RESOURCES_PATH = "resources/"
const val SYNC_LOCATION_IDS = "_syncLocations"
const val KNOWLEDGE_MANAGER_ASSETS_SUBFOLDER = "km"

/**
* The list of resources whose types can be synced down as part of the Composition configs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,15 @@
@ApplicationContext open val context: Context,
) {

suspend inline fun <reified T : Resource> loadResource(resourceId: String): T? {
return withContext(dispatcherProvider.io()) { fhirEngine.loadResource(resourceId) }
}
suspend inline fun <reified T : Resource> loadResource(resourceId: String): T? =
fhirEngine.loadResource(resourceId)

Check warning on line 118 in android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt#L118

Added line #L118 was not covered by tests

suspend fun loadResource(resourceId: String, resourceType: ResourceType): Resource =
withContext(dispatcherProvider.io()) { fhirEngine.get(resourceType, resourceId) }
fhirEngine.get(resourceType, resourceId)

suspend fun loadResource(reference: Reference) =
withContext(dispatcherProvider.io()) {
IdType(reference.reference).let {
fhirEngine.get(ResourceType.fromCode(it.resourceType), it.idPart)
}
IdType(reference.reference).let {
fhirEngine.get(ResourceType.fromCode(it.resourceType), it.idPart)
}

suspend inline fun <reified T : Resource> searchResourceFor(
Expand All @@ -135,19 +132,17 @@
dataQueries: List<DataQuery> = listOf(),
configComputedRuleValues: Map<String, Any>,
): List<T> =
withContext(dispatcherProvider.io()) {
fhirEngine
.batchedSearch<T> {
filterByResourceTypeId(token, subjectType, subjectId)
dataQueries.forEach {
filterBy(
dataQuery = it,
configComputedRuleValues = configComputedRuleValues,
)
}
fhirEngine
.batchedSearch<T> {
filterByResourceTypeId(token, subjectType, subjectId)
dataQueries.forEach {
filterBy(
dataQuery = it,
configComputedRuleValues = configComputedRuleValues,

Check warning on line 141 in android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt#L135-L141

Added lines #L135 - L141 were not covered by tests
)
}
.map { it.resource }
}
}
.map { it.resource }

Check warning on line 145 in android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt#L145

Added line #L145 was not covered by tests

suspend inline fun <reified R : Resource> search(search: Search) =
fhirEngine.batchedSearch<R>(search).map { it.resource }
Expand All @@ -162,17 +157,13 @@
* param [addResourceTags]
*/
suspend fun create(addResourceTags: Boolean = true, vararg resource: Resource): List<String> {
return withContext(dispatcherProvider.io()) {
preProcessResources(addResourceTags, *resource)
fhirEngine.create(*resource)
}
preProcessResources(addResourceTags, *resource)
return fhirEngine.create(*resource)
}

suspend fun createRemote(addResourceTags: Boolean = true, vararg resource: Resource) {
return withContext(dispatcherProvider.io()) {
preProcessResources(addResourceTags, *resource)
fhirEngine.create(*resource, isLocalOnly = true)
}
preProcessResources(addResourceTags, *resource)
fhirEngine.create(*resource, isLocalOnly = true)
}

private fun preProcessResources(addResourceTags: Boolean, vararg resource: Resource) {
Expand All @@ -198,23 +189,19 @@
resourceId: String,
softDelete: Boolean = false,
) {
withContext(dispatcherProvider.io()) {
if (softDelete) {
val resource = fhirEngine.get(resourceType, resourceId)
softDelete(resource)
} else {
fhirEngine.delete(resourceType, resourceId)
}
if (softDelete) {
val resource = fhirEngine.get(resourceType, resourceId)
softDelete(resource)

Check warning on line 194 in android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt#L193-L194

Added lines #L193 - L194 were not covered by tests
} else {
fhirEngine.delete(resourceType, resourceId)
}
}

suspend fun delete(resource: Resource, softDelete: Boolean = false) {
withContext(dispatcherProvider.io()) {
if (softDelete) {
softDelete(resource)
} else {
fhirEngine.delete(resource.resourceType, resource.logicalId)
}
if (softDelete) {
softDelete(resource)

Check warning on line 202 in android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt#L202

Added line #L202 was not covered by tests
} else {
fhirEngine.delete(resource.resourceType, resource.logicalId)
}
}

Expand Down Expand Up @@ -243,24 +230,20 @@
* param [addMandatoryTags]
*/
suspend fun <R : Resource> addOrUpdate(addMandatoryTags: Boolean = true, resource: R) {
return withContext(dispatcherProvider.io()) {
resource.updateLastUpdated()
try {
fhirEngine.get(resource.resourceType, resource.logicalId).run {
val updateFrom = updateFrom(resource)
fhirEngine.update(updateFrom)
}
} catch (resourceNotFoundException: ResourceNotFoundException) {
create(addMandatoryTags, resource)
resource.updateLastUpdated()
try {
fhirEngine.get(resource.resourceType, resource.logicalId).run {
val updateFrom = updateFrom(resource)
fhirEngine.update(updateFrom)
}
} catch (resourceNotFoundException: ResourceNotFoundException) {
create(addMandatoryTags, resource)
}
}

suspend fun <R : Resource> update(resource: R) {
return withContext(dispatcherProvider.io()) {
resource.updateLastUpdated()
fhirEngine.update(resource)
}
resource.updateLastUpdated()
fhirEngine.update(resource)
}

suspend fun loadManagingEntity(group: Group) =
Expand Down Expand Up @@ -904,7 +887,7 @@
val updatedResource =
parser.parseResource(resourceDefinition, updatedResourceDocument.jsonString())
updatedResource.setId(updatedResource.idElement.idPart)
withContext(dispatcherProvider.io()) { fhirEngine.update(updatedResource as Resource) }
fhirEngine.update(updatedResource as Resource)
}

private fun getJsonContent(jsonElement: JsonElement): Any? {
Expand Down Expand Up @@ -935,9 +918,7 @@

suspend fun purge(resource: Resource, forcePurge: Boolean) {
try {
withContext(dispatcherProvider.io()) {
fhirEngine.purge(resource.resourceType, resource.logicalId, forcePurge)
}
fhirEngine.purge(resource.resourceType, resource.logicalId, forcePurge)
} catch (resourceNotFoundException: ResourceNotFoundException) {
Timber.e(
"Purge failed -> Resource with ID ${resource.logicalId} does not exist",
Expand Down
Loading
Loading