Skip to content

Commit

Permalink
Merge branch 'master' into syncjob-status-callback
Browse files Browse the repository at this point in the history
  • Loading branch information
ndegwamartin authored Dec 2, 2024
2 parents b519c23 + f42e804 commit 3d9f2be
Show file tree
Hide file tree
Showing 164 changed files with 7,914 additions and 801 deletions.
13 changes: 0 additions & 13 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ object Dependencies {
const val playServicesLocation =
"com.google.android.gms:play-services-location:${Versions.playServicesLocation}"

const val androidFhirGroup = "com.google.android.fhir"
const val androidFhirEngineModule = "engine"
const val androidFhirKnowledgeModule = "knowledge"
const val androidFhirCommon = "$androidFhirGroup:common:${Versions.androidFhirCommon}"
const val androidFhirEngine =
"$androidFhirGroup:$androidFhirEngineModule:${Versions.androidFhirEngine}"
const val androidFhirKnowledge = "$androidFhirGroup:knowledge:${Versions.androidFhirKnowledge}"

const val apacheCommonsCompress =
"org.apache.commons:commons-compress:${Versions.apacheCommonsCompress}"

Expand All @@ -109,7 +101,6 @@ object Dependencies {
const val mockWebServer = "com.squareup.okhttp3:mockwebserver:${Versions.http}"

const val jsonToolsPatch = "com.github.java-json-tools:json-patch:${Versions.jsonToolsPatch}"
const val material = "com.google.android.material:material:${Versions.material}"
const val sqlcipher = "net.zetetic:android-database-sqlcipher:${Versions.sqlcipher}"
const val timber = "com.jakewharton.timber:timber:${Versions.timber}"
const val woodstox = "com.fasterxml.woodstox:woodstox-core:${Versions.woodstox}"
Expand All @@ -131,9 +122,6 @@ object Dependencies {
const val xmlUnit = "org.xmlunit:xmlunit-core:${Versions.xmlUnit}"

object Versions {
const val androidFhirCommon = "0.1.0-alpha05"
const val androidFhirEngine = "0.1.0-beta05"
const val androidFhirKnowledge = "0.1.0-alpha03"
const val apacheCommonsCompress = "1.21"
const val desugarJdkLibs = "2.0.3"
const val caffeine = "2.9.1"
Expand All @@ -154,7 +142,6 @@ object Dependencies {

const val jsonToolsPatch = "1.13"
const val jsonAssert = "1.5.1"
const val material = "1.9.0"
const val retrofit = "2.9.0"
const val gsonConverter = "2.1.0"
const val sqlcipher = "4.5.4"
Expand Down
10 changes: 8 additions & 2 deletions buildSrc/src/main/kotlin/Releases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object Releases {

object Engine : LibraryArtifact {
override val artifactId = "engine"
override val version = "1.0.0"
override val version = "1.1.0"
override val name = "Android FHIR Engine Library"
}

Expand All @@ -60,7 +60,7 @@ object Releases {

object Workflow : LibraryArtifact {
override val artifactId = "workflow"
override val version = "0.1.0-alpha04"
override val version = "0.1.0-beta01"
override val name = "Android FHIR Workflow Library"
}

Expand Down Expand Up @@ -98,6 +98,12 @@ object Releases {
const val versionCode = 1
const val versionName = "1.0"
}

object WorkflowDemo {
const val applicationId = "com.google.android.fhir.workflow.demo"
const val versionCode = 1
const val versionName = "1.0"
}
}

fun Project.publishArtifact(artifact: LibraryArtifact) {
Expand Down
2 changes: 1 addition & 1 deletion catalog/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ dependencies {

coreLibraryDesugaring(Dependencies.desugarJdkLibs)

implementation(Dependencies.material)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.core)
implementation(libs.androidx.fragment)
implementation(libs.androidx.navigation.fragment)
implementation(libs.androidx.navigation.ui)
implementation(libs.kotlin.stdlib)
implementation(libs.material)

implementation(project(path = ":datacapture"))
implementation(project(path = ":engine"))
Expand Down
60 changes: 18 additions & 42 deletions catalog/src/main/assets/component_modal.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
"resourceType": "Questionnaire",
"item": [
{
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/questionnaire-item-control",
"code": "check-box",
"display": "Check Box"
}
],
"text": "Check box"
}
},
{
"url": "https://github.com/google/android-fhir/StructureDefinition/dialog"
}
],
"linkId": "1.1",
"type": "choice",
"repeats": true,
Expand Down Expand Up @@ -44,48 +62,6 @@
"code": "diarrhoea",
"display": "Diarrhoea"
}
},
{
"valueCoding": {
"code": "fever",
"display": "Fever"
}
},
{
"valueCoding": {
"code": "injury",
"display": "Injury"
}
},
{
"valueCoding": {
"code": "jaundice",
"display": "Jaundice"
}
},
{
"valueCoding": {
"code": "mental-health",
"display": "Mental health"
}
},
{
"valueCoding": {
"code": "nausea",
"display": "Nausea"
}
},
{
"valueCoding": {
"code": "pain",
"display": "Pain"
}
},
{
"valueCoding": {
"code": "bleeding",
"display": "Bleeding"
}
}
]
}
Expand Down
20 changes: 10 additions & 10 deletions codelabs/datacapture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ of the `app/build.gradle.kts` file of your project:
dependencies {
// ...

implementation("com.google.android.fhir:data-capture:1.0.0")
implementation("androidx.fragment:fragment-ktx:1.5.5")
implementation("com.google.android.fhir:data-capture:1.2.0")
implementation("androidx.fragment:fragment-ktx:1.6.0")
}
```

Expand Down Expand Up @@ -150,11 +150,11 @@ Open `MainActivity.kt` and add the following code to the `MainActivity` class:

```kotlin
// Step 2: Configure a QuestionnaireFragment
val questionnaireJsonString = getStringFromAssets("questionnaire.json")
questionnaireJsonString = getStringFromAssets("questionnaire.json")

val questionnaireFragment =
QuestionnaireFragment.builder().setQuestionnaire(questionnaireJsonString!!).build()

val questionnaireParams = bundleOf(
QuestionnaireFragment.EXTRA_QUESTIONNAIRE_JSON_STRING to questionnaireJsonString
)
```

### Step 3: Add the QuestionnaireFragment to the FragmentContainerView
Expand All @@ -168,10 +168,10 @@ Add the following code to the `MainActivity` class:
```kotlin
// Step 3: Add the QuestionnaireFragment to the FragmentContainerView
if (savedInstanceState == null) {
supportFragmentManager.commit {
setReorderingAllowed(true)
add<QuestionnaireFragment>(R.id.fragment_container_view, args = questionnaireParams)
}
supportFragmentManager.commit {
setReorderingAllowed(true)
add(R.id.fragment_container_view, questionnaireFragment)
}
}
// Submit button callback
supportFragmentManager.setFragmentResultListener(
Expand Down
10 changes: 8 additions & 2 deletions codelabs/engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ file of your project:
dependencies {
// ...
implementation("com.google.android.fhir:engine:1.0.0")
implementation("com.google.android.fhir:engine:1.1.0")
}
```
Expand Down Expand Up @@ -257,7 +257,13 @@ outlined below will guide you through the process.
override fun getFhirEngine() = FhirApplication.fhirEngine(applicationContext)
override fun getUploadStrategy() = UploadStrategy.AllChangesSquashedBundlePut
override fun getUploadStrategy() =
UploadStrategy.forBundleRequest(
methodForCreate = HttpCreateMethod.PUT,
methodForUpdate = HttpUpdateMethod.PATCH,
squash = true,
bundleSize = 500,
)
}
```
Expand Down
2 changes: 1 addition & 1 deletion codelabs/engine/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ dependencies {
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")

implementation("com.google.android.fhir:engine:1.0.0")
implementation("com.google.android.fhir:engine:1.1.0")
implementation("androidx.fragment:fragment-ktx:1.8.3")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,8 +30,10 @@ class PatientItemViewHolder(binding: PatientListItemViewBinding) :

fun bind(patientItem: Patient) {
nameTextView.text =
patientItem.name.first().let { it.given.joinToString(separator = " ") + " " + it.family }
genderTextView.text = patientItem.gender.display
patientItem.name.firstOrNull()?.let {
it.given.joinToString(separator = " ") + " " + it.family
}
genderTextView.text = patientItem.gender?.display
cityTextView.text = patientItem.address.singleOrNull()?.city
}
}
2 changes: 1 addition & 1 deletion contrib/barcode/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ dependencies {
implementation(Dependencies.Mlkit.barcodeScanning)
implementation(Dependencies.Mlkit.objectDetection)
implementation(Dependencies.Mlkit.objectDetectionCustom)
implementation(Dependencies.material)
implementation(Dependencies.timber)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core)
implementation(libs.androidx.fragment)
implementation(libs.material)

testImplementation(Dependencies.mockitoInline)
testImplementation(Dependencies.mockitoKotlin)
Expand Down
2 changes: 1 addition & 1 deletion contrib/locationwidget/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ dependencies {

implementation(project(":datacapture"))
implementation(Dependencies.playServicesLocation)
implementation(Dependencies.material)
implementation(Dependencies.timber)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core)
implementation(libs.androidx.fragment)
implementation(libs.kotlinx.coroutines.playservices)
implementation(libs.material)

coreLibraryDesugaring(Dependencies.desugarJdkLibs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.core.view.isVisible
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.google.common.truth.Truth.assertThat
import org.hl7.fhir.r4.model.Questionnaire
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -55,4 +56,30 @@ class LocationGpsCoordinateViewHolderFactoryInstrumentedTest {
)
.isEqualTo(InputType.TYPE_NULL)
}

@Test
fun matcherShouldReturnTrueForOriginalGpsCoordinateUrl() {
val questionnaireItem = Questionnaire.QuestionnaireItemComponent()
questionnaireItem.addExtension(
LocationGpsCoordinateViewHolderFactory.PRIMARY_GPS_COORDINATE_EXTENSION_URL,
null,
)
assertThat(LocationGpsCoordinateViewHolderFactory.matcher(questionnaireItem)).isTrue()
}

@Test
fun matcherShouldReturnTrueForOldGpsCoordinateUrl() {
val questionnaireItem = Questionnaire.QuestionnaireItemComponent()
questionnaireItem.addExtension(
LocationGpsCoordinateViewHolderFactory.GPS_COORDINATE_EXTENSION_URL,
null,
)
assertThat(LocationGpsCoordinateViewHolderFactory.matcher(questionnaireItem)).isTrue()
}

@Test
fun matcherShouldReturnFalseForNoGpsCoordinateUrl() {
val questionnaireItem = Questionnaire.QuestionnaireItemComponent()
assertThat(LocationGpsCoordinateViewHolderFactory.matcher(questionnaireItem)).isFalse()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ object LocationGpsCoordinateViewHolderFactory :
header.context.tryUnwrapContext()?.apply {
val gpsCoordinateExtensionValue =
questionnaireViewItem.questionnaireItem
.getExtensionByUrl(GPS_COORDINATE_EXTENSION_URL)
.value as StringType
.getExtensionByUrl(PRIMARY_GPS_COORDINATE_EXTENSION_URL)
?.value as? StringType
?: questionnaireViewItem.questionnaireItem
.getExtensionByUrl(GPS_COORDINATE_EXTENSION_URL)
.value as StringType
when (gpsCoordinateExtensionValue.valueAsString) {
GPS_COORDINATE_EXTENSION_VALUE_LATITUDE -> {
supportFragmentManager.setFragmentResultListener(
Expand Down Expand Up @@ -148,9 +151,12 @@ object LocationGpsCoordinateViewHolderFactory :
}

fun matcher(questionnaireItem: Questionnaire.QuestionnaireItemComponent): Boolean {
return questionnaireItem.hasExtension(GPS_COORDINATE_EXTENSION_URL)
return questionnaireItem.hasExtension(PRIMARY_GPS_COORDINATE_EXTENSION_URL) ||
questionnaireItem.hasExtension(GPS_COORDINATE_EXTENSION_URL)
}

const val PRIMARY_GPS_COORDINATE_EXTENSION_URL =
"https://github.com/google/android-fhir/StructureDefinition/gps-coordinate"
const val GPS_COORDINATE_EXTENSION_URL = "gps-coordinate"
const val GPS_COORDINATE_EXTENSION_VALUE_LATITUDE = "latitude"
const val GPS_COORDINATE_EXTENSION_VALUE_LONGITUDE = "longitude"
Expand Down
6 changes: 3 additions & 3 deletions datacapture/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ dependencies {
exclude(module = "commons-logging")
exclude(module = "httpclient")
}
implementation(Dependencies.androidFhirCommon)
implementation(Dependencies.material)
implementation(Dependencies.timber)
implementation(libs.android.fhir.common)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.core)
Expand All @@ -101,12 +100,13 @@ dependencies {
implementation(libs.glide)
implementation(libs.kotlin.stdlib)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.material)

testImplementation(Dependencies.mockitoInline)
testImplementation(Dependencies.mockitoKotlin)
testImplementation(Dependencies.robolectric)
testImplementation(project(":knowledge")) {
exclude(group = Dependencies.androidFhirGroup, module = Dependencies.androidFhirEngineModule)
exclude(group = "com.google.android.fhir", module = "engine")
}
testImplementation(libs.androidx.test.core)
testImplementation(libs.androidx.fragment.testing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.android.fhir.datacapture.contrib.views.PhoneNumberViewHolderFactory
import com.google.android.fhir.datacapture.extensions.inflate
import com.google.android.fhir.datacapture.extensions.itemControl
import com.google.android.fhir.datacapture.extensions.shouldUseDialog
import com.google.android.fhir.datacapture.views.NavigationViewHolder
import com.google.android.fhir.datacapture.views.QuestionnaireViewItem
import com.google.android.fhir.datacapture.views.factories.AttachmentViewHolderFactory
Expand Down Expand Up @@ -241,8 +242,11 @@ internal class QuestionnaireEditAdapter(
): QuestionnaireViewHolderType {
val questionnaireItem = questionnaireViewItem.questionnaireItem

// Use the view type that the client wants if they specified an itemControl
return questionnaireItem.itemControl?.viewHolderType
// Use the view type that the client wants if they specified an itemControl or dialog extension
return when {
questionnaireItem.shouldUseDialog -> QuestionnaireViewHolderType.DIALOG_SELECT
else -> questionnaireItem.itemControl?.viewHolderType
}
// Otherwise, choose a sensible UI element automatically
?: run {
val numOptions = questionnaireViewItem.enabledAnswerOptions.size
Expand Down
Loading

0 comments on commit 3d9f2be

Please sign in to comment.