Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 3513-minification-and…
Browse files Browse the repository at this point in the history
…-shrinking
  • Loading branch information
qiarie committed Sep 30, 2024
2 parents 9f61d04 + ebd0355 commit 6ccdc02
Show file tree
Hide file tree
Showing 60 changed files with 1,299 additions and 929 deletions.
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
@@ -0,0 +1,42 @@
/*
* 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.configuration

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable
import org.smartregister.fhircore.engine.util.extension.interpolate

@Serializable
@Parcelize
data class PdfConfig(
val title: String? = null,
val titleSuffix: String? = null,
val structureReference: String? = null,
val subjectReference: String? = null,
val questionnaireReferences: List<String> = emptyList(),
) : java.io.Serializable, Parcelable {

fun interpolate(computedValuesMap: Map<String, Any>) =
this.copy(
title = title?.interpolate(computedValuesMap),
titleSuffix = titleSuffix?.interpolate(computedValuesMap),
structureReference = structureReference?.interpolate(computedValuesMap),
subjectReference = subjectReference?.interpolate(computedValuesMap),
questionnaireReferences = questionnaireReferences.map { it.interpolate(computedValuesMap) },
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ data class QuestionnaireConfig(
val managingEntityRelationshipCode: String? = null,
val uniqueIdAssignment: UniqueIdAssignmentConfig? = null,
val linkIds: List<LinkIdConfig>? = null,
val htmlBinaryId: String? = null,
val htmlTitle: String? = null,
) : java.io.Serializable, Parcelable {

fun interpolate(computedValuesMap: Map<String, Any>) =
Expand Down Expand Up @@ -102,8 +100,6 @@ data class QuestionnaireConfig(
uniqueIdAssignment?.copy(linkId = uniqueIdAssignment.linkId.interpolate(computedValuesMap)),
linkIds = linkIds?.onEach { it.linkId.interpolate(computedValuesMap) },
saveButtonText = saveButtonText?.interpolate(computedValuesMap),
htmlBinaryId = htmlBinaryId?.interpolate(computedValuesMap),
htmlTitle = htmlTitle?.interpolate(computedValuesMap),
)
}

Expand Down
Loading

0 comments on commit 6ccdc02

Please sign in to comment.