Skip to content

Commit 4814123

Browse files
authored
Demo app for activity flow (google#2711)
* Demo app for activity flow * Review comments * Review comments: Code cleanup * Review comments: extracted initialization * Added readme * Fixxed build error * Removed unused files
1 parent b59acf2 commit 4814123

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1754
-8
lines changed

buildSrc/src/main/kotlin/Dependencies.kt

-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ object Dependencies {
101101
const val mockWebServer = "com.squareup.okhttp3:mockwebserver:${Versions.http}"
102102

103103
const val jsonToolsPatch = "com.github.java-json-tools:json-patch:${Versions.jsonToolsPatch}"
104-
const val material = "com.google.android.material:material:${Versions.material}"
105104
const val sqlcipher = "net.zetetic:android-database-sqlcipher:${Versions.sqlcipher}"
106105
const val timber = "com.jakewharton.timber:timber:${Versions.timber}"
107106
const val woodstox = "com.fasterxml.woodstox:woodstox-core:${Versions.woodstox}"
@@ -143,7 +142,6 @@ object Dependencies {
143142

144143
const val jsonToolsPatch = "1.13"
145144
const val jsonAssert = "1.5.1"
146-
const val material = "1.9.0"
147145
const val retrofit = "2.9.0"
148146
const val gsonConverter = "2.1.0"
149147
const val sqlcipher = "4.5.4"

buildSrc/src/main/kotlin/Releases.kt

+6
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ object Releases {
9898
const val versionCode = 1
9999
const val versionName = "1.0"
100100
}
101+
102+
object WorkflowDemo {
103+
const val applicationId = "com.google.android.fhir.workflow.demo"
104+
const val versionCode = 1
105+
const val versionName = "1.0"
106+
}
101107
}
102108

103109
fun Project.publishArtifact(artifact: LibraryArtifact) {

catalog/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ dependencies {
4646

4747
coreLibraryDesugaring(Dependencies.desugarJdkLibs)
4848

49-
implementation(Dependencies.material)
5049
implementation(libs.androidx.appcompat)
5150
implementation(libs.androidx.constraintlayout)
5251
implementation(libs.androidx.core)
5352
implementation(libs.androidx.fragment)
5453
implementation(libs.androidx.navigation.fragment)
5554
implementation(libs.androidx.navigation.ui)
5655
implementation(libs.kotlin.stdlib)
56+
implementation(libs.material)
5757

5858
implementation(project(path = ":datacapture"))
5959
implementation(project(path = ":engine"))

contrib/barcode/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ dependencies {
7070
implementation(Dependencies.Mlkit.barcodeScanning)
7171
implementation(Dependencies.Mlkit.objectDetection)
7272
implementation(Dependencies.Mlkit.objectDetectionCustom)
73-
implementation(Dependencies.material)
7473
implementation(Dependencies.timber)
7574
implementation(libs.androidx.appcompat)
7675
implementation(libs.androidx.core)
7776
implementation(libs.androidx.fragment)
77+
implementation(libs.material)
7878

7979
testImplementation(Dependencies.mockitoInline)
8080
testImplementation(Dependencies.mockitoKotlin)

contrib/locationwidget/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ dependencies {
6565

6666
implementation(project(":datacapture"))
6767
implementation(Dependencies.playServicesLocation)
68-
implementation(Dependencies.material)
6968
implementation(Dependencies.timber)
7069
implementation(libs.androidx.appcompat)
7170
implementation(libs.androidx.core)
7271
implementation(libs.androidx.fragment)
7372
implementation(libs.kotlinx.coroutines.playservices)
73+
implementation(libs.material)
7474

7575
coreLibraryDesugaring(Dependencies.desugarJdkLibs)
7676

datacapture/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ dependencies {
9090
exclude(module = "commons-logging")
9191
exclude(module = "httpclient")
9292
}
93-
implementation(Dependencies.material)
9493
implementation(Dependencies.timber)
9594
implementation(libs.android.fhir.common)
9695
implementation(libs.androidx.appcompat)
@@ -101,6 +100,7 @@ dependencies {
101100
implementation(libs.glide)
102101
implementation(libs.kotlin.stdlib)
103102
implementation(libs.kotlinx.coroutines.core)
103+
implementation(libs.material)
104104

105105
testImplementation(Dependencies.mockitoInline)
106106
testImplementation(Dependencies.mockitoKotlin)

demo/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ dependencies {
4343

4444
coreLibraryDesugaring(Dependencies.desugarJdkLibs)
4545

46-
implementation(Dependencies.material)
4746
implementation(Dependencies.timber)
4847
implementation(libs.androidx.activity)
4948
implementation(libs.androidx.appcompat)
@@ -60,6 +59,7 @@ dependencies {
6059
implementation(libs.kotlin.stdlib)
6160
implementation(libs.kotlinx.coroutines.android)
6261
implementation(libs.kotlinx.coroutines.core)
62+
implementation(libs.material)
6363
implementation(project(":datacapture")) {
6464
exclude(group = "com.google.android.fhir", module = "engine")
6565
}

document/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ dependencies {
3838

3939
coreLibraryDesugaring(Dependencies.desugarJdkLibs)
4040

41-
implementation(Dependencies.material)
4241
implementation(Dependencies.Retrofit.coreRetrofit)
4342
implementation(Dependencies.Retrofit.gsonConverter)
4443
implementation(Dependencies.httpInterceptor)
@@ -48,6 +47,7 @@ dependencies {
4847
implementation(libs.android.fhir.engine)
4948
implementation(libs.androidx.appcompat)
5049
implementation(libs.androidx.core)
50+
implementation(libs.material)
5151

5252
testImplementation(Dependencies.robolectric)
5353
testImplementation(Dependencies.mockitoKotlin)

gradle/libs.versions.toml

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ kotlinx-coroutines = "1.8.1"
3131
logback-android = "3.0.0"
3232
opencds-cqf-fhir = "3.8.0"
3333
truth = "1.1.5"
34+
material = "1.9.0"
3435

3536
[libraries]
3637
android-fhir-common = { module = "com.google.android.fhir:common", version.ref = "android-fhir-common" }
@@ -78,6 +79,7 @@ opencds-cqf-fhir-cr = { module = "org.opencds.cqf.fhir:cqf-fhir-cr", version.ref
7879
opencds-cqf-fhir-jackson = { module = "org.opencds.cqf.fhir:cqf-fhir-jackson", version.ref = "opencds-cqf-fhir" }
7980
opencds-cqf-fhir-utility = { module = "org.opencds.cqf.fhir:cqf-fhir-utility", version.ref = "opencds-cqf-fhir" }
8081
truth = { module = "com.google.truth:truth", version.ref = "truth" }
82+
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
8183

8284
[bundles]
8385

settings.gradle.kts

+2
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,5 @@ include(":workflow-testing")
6666
include(":workflow:benchmark")
6767

6868
include(":engine:benchmark")
69+
70+
include(":workflow_demo")

workflow_demo/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

workflow_demo/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Workflow Activity API usage
2+
3+
## Setup
4+
5+
### Where does configuration come from
6+
7+
The configurations for Activity flows available in the demo app are based on [these examples](https://build.fhir.org/ig/cqframework/cpg-example/branches/master/examples.html#examples).
8+
The required PlanDefinition, ActivityDefinition and CQL Library are available [here](https://github.com/cqframework/cpg-example/tree/master).

workflow_demo/build.gradle.kts

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
plugins {
2+
id("com.android.application")
3+
id("org.jetbrains.kotlin.android")
4+
}
5+
6+
android {
7+
namespace = "com.google.android.fhir.workflow.demo"
8+
compileSdk = Sdk.COMPILE_SDK
9+
10+
defaultConfig {
11+
applicationId = Releases.WorkflowDemo.applicationId
12+
minSdk = Sdk.MIN_SDK
13+
targetSdk = Sdk.TARGET_SDK
14+
versionCode = Releases.WorkflowDemo.versionCode
15+
versionName = Releases.WorkflowDemo.versionName
16+
testInstrumentationRunner = Dependencies.androidJunitRunner
17+
}
18+
19+
buildTypes {
20+
release {
21+
isMinifyEnabled = false
22+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
23+
}
24+
}
25+
compileOptions {
26+
// sourceCompatibility = JavaVersion.VERSION_1_8
27+
// targetCompatibility = JavaVersion.VERSION_1_8
28+
// Flag to enable support for the new language APIs
29+
// See https://developer.android.com/studio/write/java8-support
30+
isCoreLibraryDesugaringEnabled = true
31+
}
32+
// kotlinOptions {
33+
// jvmTarget = "1.8"
34+
// }
35+
kotlin { jvmToolchain(11) }
36+
packaging {
37+
resources.excludes.addAll(
38+
listOf(
39+
"META-INF/ASL-2.0.txt",
40+
"META-INF/LGPL-3.0.txt",
41+
"META-INF/LICENSE.md",
42+
"META-INF/NOTICE.md",
43+
"META-INF/INDEX.LIST",
44+
),
45+
)
46+
}
47+
}
48+
49+
dependencies {
50+
androidTestImplementation(libs.androidx.test.espresso.core)
51+
androidTestImplementation(libs.androidx.test.ext.junit)
52+
53+
compileOnly(libs.opencds.cqf.fhir.cr)
54+
coreLibraryDesugaring(Dependencies.desugarJdkLibs)
55+
56+
implementation(libs.androidx.appcompat)
57+
implementation(libs.androidx.constraintlayout)
58+
implementation(libs.androidx.core)
59+
implementation(libs.androidx.fragment)
60+
implementation(libs.androidx.lifecycle.livedata)
61+
implementation(libs.androidx.lifecycle.viewmodel)
62+
implementation(libs.material)
63+
implementation(project(":engine"))
64+
implementation(project(":knowledge")) {
65+
exclude(group = "com.google.android.fhir", module = "engine")
66+
}
67+
implementation(project(":workflow")) {
68+
exclude(group = "com.google.android.fhir", module = "engine")
69+
exclude(group = "com.google.android.fhir", module = "knowledge")
70+
}
71+
implementation(project(":workflow-testing"))
72+
73+
testImplementation(libs.junit)
74+
constraints {
75+
Dependencies.hapiFhirConstraints().forEach { (libName, constraints) ->
76+
api(libName, constraints)
77+
implementation(libName, constraints)
78+
}
79+
}
80+
}

workflow_demo/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<application
5+
android:allowBackup="true"
6+
android:icon="@mipmap/ic_launcher"
7+
android:label="@string/app_name"
8+
android:roundIcon="@mipmap/ic_launcher_round"
9+
android:supportsRtl="true"
10+
android:theme="@style/Theme.Androidfhir"
11+
>
12+
<activity android:name=".MainActivity" android:exported="true">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"resourceType": "ActivityDefinition",
3+
"id": "DailyAppleActivity",
4+
"url": "http://fhir.org/guides/cqf/cpg/example/ActivityDefinition/DailyAppleActivity",
5+
"name": "DailyAppleActivity",
6+
"title": "Daily Apple Activity",
7+
"status": "active",
8+
"experimental": true,
9+
"description": "Activity to provide an apple daily",
10+
"kind": "MedicationRequest",
11+
"profile": "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-medicationrequest",
12+
"intent": "proposal",
13+
"priority": "routine",
14+
"productCodeableConcept": {
15+
"coding": [
16+
{
17+
"system": "http://snomed.info/sct",
18+
"code": "735215001",
19+
"display": "Apple (substance)"
20+
}
21+
],
22+
"text": "Apple"
23+
},
24+
"dosage": [
25+
{
26+
"timing": {
27+
"repeat": {
28+
"frequency": 1,
29+
"period": 1,
30+
"periodUnit": "d"
31+
}
32+
},
33+
"doseAndRate": [
34+
{
35+
"doseQuantity": {
36+
"value": 1,
37+
"code": "{apple}"
38+
},
39+
"rateQuantity": {
40+
"value": 1
41+
}
42+
}
43+
]
44+
}
45+
]
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
library DailyAppleLogic version '1.0.0'
2+
3+
using FHIR version '4.0.1'
4+
5+
include FHIRHelpers version '4.0.1' called FHIRHelpers
6+
7+
valueset "Apple": 'http://fhir.org/guides/cqf/cpg/example/ValueSet/Apple'
8+
9+
context Patient
10+
11+
define "Inclusion Criteria":
12+
Patient.active
13+
14+
define "Active Daily Apple Order":
15+
[MedicationRequest: "Apple"] M
16+
where M.intent = 'order'
17+
and M.status = 'active'
18+
and M.doNotPerform is not true
19+
20+
define "Contraindications For Daily Apple Order":
21+
[MedicationRequest: "Apple"] M
22+
where M.intent = 'order'
23+
and M.status = 'active'
24+
and M.doNotPerform is true
25+
26+
define "No Daily Apple Order":
27+
not exists ("Active Daily Apple Order")
28+
and not exists ("Contraindications For Daily Apple Order")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"resourceType": "PlanDefinition",
3+
"id": "DailyAppleRecommendation",
4+
"url": "http://fhir.org/guides/cqf/cpg/example/PlanDefinition/DailyAppleRecommendation",
5+
"name": "DailyAppleRecommendation",
6+
"title": "Daily Apple Recommendation",
7+
"description": "An apple a day keeps the doctor away",
8+
"library": [
9+
"http://fhir.org/guides/cqf/cpg/example/Library/DailyAppleLogic"
10+
],
11+
"action": [
12+
{
13+
"textEquivalent": "An apple a day keeps the doctor away",
14+
"condition": [
15+
{
16+
"kind": "applicability",
17+
"expression": {
18+
"language": "text/cql-identifier",
19+
"expression": "No Daily Apple Order"
20+
}
21+
}
22+
],
23+
"definitionCanonical": "http://fhir.org/guides/cqf/cpg/example/ActivityDefinition/DailyAppleActivity"
24+
}
25+
]
26+
}

0 commit comments

Comments
 (0)