Skip to content

Commit

Permalink
Merge branch 'master' into overload-workflow-method
Browse files Browse the repository at this point in the history
  • Loading branch information
ndegwamartin authored Nov 4, 2024
2 parents 5bc45d1 + 6977691 commit eb2890c
Show file tree
Hide file tree
Showing 92 changed files with 4,382 additions and 706 deletions.
11 changes: 0 additions & 11 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 Down Expand Up @@ -131,9 +123,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 Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Releases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ object Releases {

object DataCapture : LibraryArtifact {
override val artifactId = "data-capture"
override val version = "1.1.0"
override val version = "1.2.0"
override val name = "Android FHIR Structured Data Capture Library"
}

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
20 changes: 12 additions & 8 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:0.1.0-beta03")
implementation("androidx.fragment:fragment-ktx:1.4.1")
implementation("com.google.android.fhir:data-capture:1.0.0")
implementation("androidx.fragment:fragment-ktx:1.5.5")
}
```

Expand Down Expand Up @@ -173,6 +173,13 @@ if (savedInstanceState == null) {
add<QuestionnaireFragment>(R.id.fragment_container_view, args = questionnaireParams)
}
}
// Submit button callback
supportFragmentManager.setFragmentResultListener(
QuestionnaireFragment.SUBMIT_REQUEST_KEY,
this,
) { _, _ ->
submitQuestionnaire()
}
```

Learn more about
Expand Down Expand Up @@ -244,12 +251,9 @@ questionnaire is already set up for
Find the `submitQuestionnaire()` method and add the following code:

```kotlin
lifecycleScope.launch {
val questionnaire =
jsonParser.parseResource(questionnaireJsonString) as Questionnaire
val bundle = ResourceMapper.extract(questionnaire, questionnaireResponse)
Log.d("extraction result", jsonParser.encodeResourceToString(bundle))
}
val questionnaire = jsonParser.parseResource(questionnaireJsonString) as Questionnaire
val bundle = ResourceMapper.extract(questionnaire, questionnaireResponse)
Log.d("extraction result", jsonParser.encodeResourceToString(bundle))
```

`ResourceMapper.extract()` requires a HAPI FHIR Questionnaire, which you can
Expand Down
12 changes: 6 additions & 6 deletions codelabs/datacapture/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ android {
}

dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.2")
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")

// 3 Add dependencies for Structured Data Capture Library and Fragment KTX
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 Google LLC
* Copyright 2022-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 All @@ -17,8 +17,6 @@
package com.google.codelab.sdclibrary

import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {
Expand All @@ -32,24 +30,12 @@ class MainActivity : AppCompatActivity() {
// 4.2 Replace with code from the codelab to add a questionnaire fragment.
}

private fun submitQuestionnaire() {
// 5 Replace with code from the codelab to get a questionnaire response.
private fun submitQuestionnaire() =
lifecycleScope.launch {
// 5 Replace with code from the codelab to get a questionnaire response.

// 6 Replace with code from the codelab to extract FHIR resources from QuestionnaireResponse.
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.submit_menu, menu)
return super.onCreateOptionsMenu(menu)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.submit) {
submitQuestionnaire()
return true
// 6 Replace with code from the codelab to extract FHIR resources from QuestionnaireResponse.
}
return super.onOptionsItemSelected(item)
}

private fun getStringFromAssets(fileName: String): String {
return assets.open(fileName).bufferedReader().use { it.readText() }
Expand Down
32 changes: 17 additions & 15 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:0.1.0-beta05")
implementation("com.google.android.fhir:engine:1.0.0")
}
```
Expand Down Expand Up @@ -256,6 +256,8 @@ outlined below will guide you through the process.
override fun getConflictResolver() = AcceptLocalConflictResolver
override fun getFhirEngine() = FhirApplication.fhirEngine(applicationContext)
override fun getUploadStrategy() = UploadStrategy.AllChangesSquashedBundlePut
}
```
Expand All @@ -282,7 +284,7 @@ outlined below will guide you through the process.
```kotlin
when (syncJobStatus) {
is SyncJobStatus.Finished -> {
is CurrentSyncJobStatus.Succeeded -> {
Toast.makeText(requireContext(), "Sync Finished", Toast.LENGTH_SHORT).show()
viewModel.searchPatientsByName("")
}
Expand Down Expand Up @@ -434,20 +436,20 @@ the UI to update, incorporate the following conditional code block:
```kotlin
viewModelScope.launch {
val fhirEngine = FhirApplication.fhirEngine(getApplication())
if (nameQuery.isNotEmpty()) {
val searchResult = fhirEngine.search<Patient> {
filter(
Patient.NAME,
{
modifier = StringFilterModifier.CONTAINS
value = nameQuery
},
)
val fhirEngine = FhirApplication.fhirEngine(getApplication())
val searchResult = fhirEngine.search<Patient> {
if (nameQuery.isNotEmpty()) {
filter(
Patient.NAME,
{
modifier = StringFilterModifier.CONTAINS
value = nameQuery
},
)
}
}
liveSearchedPatients.value = searchResult.map { it.resource }
}
liveSearchedPatients.value = searchResult.map { it.resource }
}
}
```
Here, if the `nameQuery` is not empty, the search function will filter the
Expand Down
18 changes: 9 additions & 9 deletions codelabs/engine/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ android {
}

dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.2")

implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.work:work-runtime-ktx:2.8.1")
implementation("androidx.work:work-runtime-ktx:2.9.1")

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")

implementation("com.google.android.fhir:engine:0.1.0-beta05")
implementation("androidx.fragment:fragment-ktx:1.6.1")
implementation("com.google.android.fhir:engine:1.0.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 @@ -35,7 +35,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.google.android.fhir.codelabs.engine.databinding.FragmentPatientListViewBinding
import com.google.android.fhir.sync.SyncJobStatus
import com.google.android.fhir.sync.CurrentSyncJobStatus
import kotlinx.coroutines.launch

class PatientListFragment : Fragment() {
Expand Down Expand Up @@ -75,7 +75,7 @@ class PatientListFragment : Fragment() {
}
}

private fun handleSyncJobStatus(syncJobStatus: SyncJobStatus) {
private fun handleSyncJobStatus(syncJobStatus: CurrentSyncJobStatus) {
// Add code to display Toast when sync job is complete
}

Expand Down
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 All @@ -23,16 +23,16 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.android.fhir.search.Order
import com.google.android.fhir.search.search
import com.google.android.fhir.sync.SyncJobStatus
import com.google.android.fhir.sync.CurrentSyncJobStatus
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import org.hl7.fhir.r4.model.Patient

class PatientListViewModel(application: Application) : AndroidViewModel(application) {
private val _pollState = MutableSharedFlow<SyncJobStatus>()
private val _pollState = MutableSharedFlow<CurrentSyncJobStatus>()

val pollState: Flow<SyncJobStatus>
val pollState: Flow<CurrentSyncJobStatus>
get() = _pollState

val liveSearchedPatients = MutableLiveData<List<Patient>>()
Expand Down
4 changes: 2 additions & 2 deletions datacapture/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ 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 @@ -106,7 +106,7 @@ dependencies {
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 @@ -112,11 +112,23 @@ class QuestionnaireFragment : Fragment() {
} else {
val errorViewModel: QuestionnaireValidationErrorViewModel by activityViewModels()
errorViewModel.setQuestionnaireAndValidation(viewModel.questionnaire, validationMap)
QuestionnaireValidationErrorMessageDialogFragment()
.show(
requireActivity().supportFragmentManager,
QuestionnaireValidationErrorMessageDialogFragment.TAG,
)
val validationErrorMessageDialog = QuestionnaireValidationErrorMessageDialogFragment()
if (requireArguments().containsKey(EXTRA_SHOW_SUBMIT_ANYWAY_BUTTON)) {
validationErrorMessageDialog.arguments =
Bundle().apply {
putBoolean(
EXTRA_SHOW_SUBMIT_ANYWAY_BUTTON,
requireArguments()
.getBoolean(
EXTRA_SHOW_SUBMIT_ANYWAY_BUTTON,
),
)
}
}
validationErrorMessageDialog.show(
requireActivity().supportFragmentManager,
QuestionnaireValidationErrorMessageDialogFragment.TAG,
)
}
}
}
Expand Down Expand Up @@ -407,6 +419,11 @@ class QuestionnaireFragment : Fragment() {
args.add(EXTRA_SHOW_NAVIGATION_IN_DEFAULT_LONG_SCROLL to value)
}

/** Setter to show/hide the Submit anyway button. This button is visible by default. */
fun setShowSubmitAnywayButton(value: Boolean) = apply {
args.add(EXTRA_SHOW_SUBMIT_ANYWAY_BUTTON to value)
}

@VisibleForTesting fun buildArgs() = bundleOf(*args.toTypedArray())

/** @return A [QuestionnaireFragment] with provided [Bundle] arguments. */
Expand Down Expand Up @@ -509,6 +526,12 @@ class QuestionnaireFragment : Fragment() {
internal const val EXTRA_SHOW_NAVIGATION_IN_DEFAULT_LONG_SCROLL =
"show-navigation-in-default-long-scroll"

/**
* A [Boolean] extra to show or hide the Submit anyway button in the questionnaire. Default is
* true.
*/
internal const val EXTRA_SHOW_SUBMIT_ANYWAY_BUTTON = "show-submit-anyway-button"

fun builder() = Builder()
}

Expand Down
Loading

0 comments on commit eb2890c

Please sign in to comment.