-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor register filter with REL tags (#3488)
* Refactor register filter with REL tags Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Update default pageSize to 15 Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Fix loading locations on map Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Refactor data structure used on base resource search results Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Refactor code Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Delete unnecessary code Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Refactor retrieving related resources Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Optimize data structures and perform parallel processing Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Use recent version of rules engine library Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Refactor implementation for decoding image resources to bitmap Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Fix related resource count on register Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Fix loading related resources This fix ensures all the nested related resources are loaded too. Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Batch related resource queries Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Map resources to RepositoryResourceData with async map Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Make infinite scroll the default register behavior Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Disable automatic intialization of emoji2 A lot of memory was used in heap during the allocation. Emojis are not used in the app so intializing them automatically is unnecessary. Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * ⬆️ Update the map box and kujaku versions * Run spotlessApply Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Update tests for displaying images (#3506) * Refactor load images tests for different views. Signed-off-by: Lentumunai-Mark <lentumunai.mark@students.jkuat.ac.ke> * Remove unutilized imports. Signed-off-by: Lentumunai-Mark <lentumunai.mark@students.jkuat.ac.ke> * Run spotlessApply Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> Signed-off-by: Lentumunai-Mark <lentumunai.mark@students.jkuat.ac.ke> * Refactor load images tests for different views. Signed-off-by: Lentumunai-Mark <lentumunai.mark@students.jkuat.ac.ke> * Resolve conflicts. Signed-off-by: Lentumunai-Mark <lentumunai.mark@students.jkuat.ac.ke> --------- Signed-off-by: Lentumunai-Mark <lentumunai.mark@students.jkuat.ac.ke> Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Refactor navigation to GeowidgetLauncher workflow Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Load map data in batches (#3511) * Load map data in batches Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Update observer Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Deactivate infinite scroll by default Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> --------- Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Fix failing tests Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Batch searching when list might be large or when count is not defined (#3456) * Fetch search results in batches for when loading all * Fix infinite loop for mocks with FhirEngine#search in tests * Add comparable FhirEngine#search vs batchedSearch integration tests * Run spotlessApply Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Fix Geowidget tests Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Fix spotlessCheck Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Add missing import Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Fix rules execution before map render Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * - Update android manifest to use exported values * Prevent leaking map features via viewmodel Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Format code Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> * Only search map features via keyboard action We need to reload all features when the search term is reset Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> --------- Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com> Signed-off-by: Lentumunai-Mark <lentumunai.mark@students.jkuat.ac.ke> Co-authored-by: Benjamin Mwalimu <dubdabasoduba@gmail.com> Co-authored-by: Lentumunai Mark <90028422+Lentumunai-Mark@users.noreply.github.com> Co-authored-by: L≡ZRS <12814349+LZRS@users.noreply.github.com>
- Loading branch information
1 parent
041762f
commit 62c9e89
Showing
76 changed files
with
1,480 additions
and
1,077 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...idTest/java/org/smartregister/fhircore/engine/util/extension/FhirEngineExtensionKtTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright 2021-2024 Ona Systems, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.smartregister.fhircore.engine.util.extension | ||
|
||
import android.content.Context | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.filters.MediumTest | ||
import com.google.android.fhir.FhirEngine | ||
import com.google.android.fhir.FhirEngineConfiguration | ||
import com.google.android.fhir.FhirEngineProvider | ||
import com.google.android.fhir.search.search | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.runBlocking | ||
import org.hl7.fhir.r4.model.Patient | ||
import org.hl7.fhir.r4.model.Questionnaire | ||
import org.hl7.fhir.r4.model.Resource | ||
import org.hl7.fhir.r4.model.ResourceType | ||
import org.junit.After | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
@MediumTest | ||
class FhirEngineExtensionKtTest { | ||
|
||
private val context = ApplicationProvider.getApplicationContext<Context>() | ||
private lateinit var fhirEngine: FhirEngine | ||
|
||
@Before | ||
fun setUp() { | ||
FhirEngineProvider.init(FhirEngineConfiguration(testMode = true)) | ||
fhirEngine = FhirEngineProvider.getInstance(context) | ||
|
||
val patients = (0..1000).map { Patient().apply { id = "test-patient-$it" } } | ||
val questionnaires = (0..3).map { Questionnaire().apply { id = "test-questionnaire-$it" } } | ||
runBlocking { fhirEngine.create(*patients.toTypedArray(), *questionnaires.toTypedArray()) } | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
runBlocking { fhirEngine.clearDatabase() } | ||
FhirEngineProvider.cleanup() | ||
} | ||
|
||
@Test | ||
fun test_search_time_searches_sequentially_and_short_running_query_waits() { | ||
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 indexOfResultOfShortQuery = | ||
fetchedResources.indexOfFirst { it.resourceType == ResourceType.Questionnaire } | ||
val indexOfResultOfLongQuery = | ||
fetchedResources.indexOfFirst { it.resourceType == ResourceType.Patient } | ||
Assert.assertTrue(indexOfResultOfShortQuery > indexOfResultOfLongQuery) | ||
} | ||
|
||
@Test | ||
fun test_batchedSearch_returns_short_running_query_and_long_running_does_not_block() { | ||
val fetchedResources = mutableListOf<Resource>() | ||
runBlocking { | ||
launch { | ||
val patients = fhirEngine.batchedSearch<Patient> {}.map { it.resource } | ||
fetchedResources += patients | ||
} | ||
|
||
launch { | ||
val questionnaires = fhirEngine.search<Questionnaire> {} | ||
fetchedResources + questionnaires | ||
} | ||
} | ||
|
||
val indexOfResultOfShortQuery = | ||
fetchedResources.indexOfFirst { it.resourceType == ResourceType.Questionnaire } | ||
val indexOfResultOfLongQuery = | ||
fetchedResources.indexOfFirst { it.resourceType == ResourceType.Patient } | ||
Assert.assertTrue(indexOfResultOfShortQuery < indexOfResultOfLongQuery) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.