Skip to content

Commit 51a6b41

Browse files
authored
Updates for SDK v0.4.4 (#6)
1 parent c88ddba commit 51a6b41

File tree

5 files changed

+95
-14
lines changed

5 files changed

+95
-14
lines changed

.idea/jarRepositories.xml

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ This quick start guide is geared towards participants in our closed beta program
1616
The CommonHealth Client SDK consists of two modules: commonhealthclient and common. Commonhealthclient contains the bulk of functionality for the SDK, while common types shared between the CommonHealth application and the CommonHealth Client SDK. You'll need to add the following to your application's list of dependencies:
1717

1818
```
19-
implementation "org.thecommonsproject.commonhealth:common:0.4.0"
20-
implementation "org.thecommonsproject.commonhealth:commonhealthclient:0.4.0"
19+
implementation "org.thecommonsproject.commonhealth:common:0.4.4"
20+
implementation "org.thecommonsproject.commonhealth:commonhealthclient:0.4.4"
2121
```
2222

2323
The artifacts currently reside in our organization's bintray repo, but at some point these will be migrated to jcenter. In the mean time, you'll need to add the following maven repository to your list of repositories, typically defined in the project's `gradle.build` file:
2424

2525
`maven { url "https://dl.bintray.com/thecommonsproject/CommonHealth" }`
2626

27+
Additionally, some dependency artifacts are served by Jitpack, so you will also need to add the following maven repository:
28+
29+
`maven { url "https://jitpack.io" }`
30+
2731
### Manifest Placeholders
2832

2933
The interapplication data sharing functionality of CommonHealth leverages native Android communication components. The CommonHealth Client SDK defines the following activities, services, and receivers in its `manifest.xml` file, which will be merged into the application's manifest during the build process:
@@ -137,7 +141,7 @@ If this method returns false, you may need to instruct the user to install and o
137141

138142
Client applications should follow the principle of least privilege and only request access to resources deemed truly necessary. The production version of CommonHealth requires that applications are registered and their scope of access does not exceed their registered values. During the development process, the developer version of CommonHealth does not perform this check.
139143

140-
Client applications must define a `ScopeRequest`, which encapsulates a set of `Scope` objects. Each `Scope` object contains a data type (`DataType`) and an access type (`Scope.Access`). `ScopeRequest` contains a `Builder` class to help with implementation.
144+
Client applications must define a `ScopeRequest`, which encapsulates a set of `Scope` objects. Each `Scope` object **must** contain a data type (`DataType`) an access type (`Scope.Access`). If you would like to limit the scope of access to a defined set of codes, you may also provide a list of `ScopedCodeAllowListEntry` objects. `ScopeRequest` contains a `Builder` class to help with implementation.
141145

142146
The following sample creates a `ScopeRequest` object requesting read access to all currently available clinical data types:
143147

@@ -161,6 +165,24 @@ val scopeRequest: ScopeRequest by lazy {
161165
}
162166
```
163167

168+
The following sample creates a `ScopeRequest` object requesting read access to lab results coded with LOINC codes `2339-0` and `49765-1`:
169+
170+
```
171+
val scopeRequestByCodes: ScopeRequest = ScopeRequest.Builder()
172+
.add(
173+
Scope(
174+
DataType.ClinicalResource.LaboratoryResultsResource,
175+
Scope.Access.READ,
176+
listOf(
177+
ScopedCodeAllowListEntry(
178+
codingSystem = "http://loinc.org",
179+
codes = listOf("2339-0", "49765-1")
180+
)
181+
)
182+
)
183+
).build()
184+
```
185+
164186
### Check the authorization status
165187

166188
The `CommonHealthStore` class provides the `checkAuthorizationStatus` method that determines the current authorization status and returns an enum that you can use to determine whether authorization is needed for the specified scope request. The method signature is:
@@ -173,13 +195,14 @@ suspend fun checkAuthorizationStatus(
173195
): CommonHealthAuthorizationStatus
174196
```
175197

176-
The `CommonHealthAuthorizationStatus` enum defines 5 values:
198+
The `CommonHealthAuthorizationStatus` enum defines the following values:
177199

178200
- `shouldRequest`
179201
- `unnecessary`
180202
- `cannotAuthorize`
181203
- `exceedsMaximumAllowedScope`
182204
- `connectionExpired`
205+
- `inactive`
183206

184207
The `shouldRequest` value means that the application needs to request authorization in order to query resources specified in the scope request.
185208

@@ -191,6 +214,8 @@ The `exceedsMaximumAllowedScope` value means that in production environments, th
191214

192215
The `connectionExpired` value means that connection lifetime (90 days) has expired. You may request authorization again. The user may also renew the connection from within CommonHealth.
193216

217+
The `inactive` value indicates that the CommonHealth team has deactivated your application across all users. Please contact CommonHealth support for more information.
218+
194219
### Authorize
195220

196221
Authorization is performed by launching the `AuthorizationManagementActivity`. To do so, create an intent using the `AuthorizationManagementActivity` static method `createStartForResultIntent`, passing in an authorization request. You then start the activity using the `startActivityForResult` like you typically would for any activity. Note that you will also need to implement the `onActivityResult` method of the calling Activity or Fragment to get the status when `AuthorizationManagementActivity` finishes. `CommonHealthAuthorizationActivityResponse.fromActivityResult` can be used to convert the response into a more developer friendly object.
@@ -265,7 +290,8 @@ suspend fun readSampleQuery(
265290
connectionAlias: String,
266291
dataTypes: Set<DataType>,
267292
before: Date? = null,
268-
after: Date? = null
293+
after: Date? = null,
294+
fetchedAfter: Date? = null
269295
): List<DataQueryResult>
270296
```
271297

@@ -282,6 +308,17 @@ See `ResourceListFragment` for an example implementation of the data query build
282308

283309
Registering with CommonHealth is not required to begin testing integrations with CommonHealth. However, if you have a client application that you would like to use in production environments, you'll need to register the application with CommonHealth. This is similar to registering an OAuth client, where you would specify information such as required scope, authorization redirect URI, etc. Please reach out to info [at] commonhealth.org for more information.
284310

311+
## Upgrading from v0.4.0 to v0.4.4
312+
`v0.4.4` introduced a small number of changes to the API:
313+
314+
- Scope requests can now be limited to a specific set of codes within a data type.
315+
- The `inactive` value was added to the `CommonHealthAuthorizationStatus` enum.
316+
- The optional `fetchedAfter` parameter was added to the `readSampleQuery` interface method. This parameter can be used to limit responses to resources added or updated after a certain date.
317+
318+
Additionally, the following maven repo is now required:
319+
320+
maven { url "https://jitpack.io" }
321+
285322
## Upgrading from v0.3.0 to v0.4.0
286323
No functional changes to the API were introduced in `v0.4.0`.
287324

app/src/main/java/org/thecommonsproject/android/commonhealth/sampleapp/fragments/CategoryListFragment.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ class CategoryListFragment : Fragment() {
130130
CommonHealthAuthorizationStatus.connectionExpired -> {
131131
authorizeButton.isEnabled = true
132132
}
133+
CommonHealthAuthorizationStatus.inactive -> {
134+
Toast.makeText(requireContext(), "The application is inactive", Toast.LENGTH_LONG).show()
135+
authorizeButton.isEnabled = false
136+
}
133137
}
134138

135139
if (authorizationStatus == CommonHealthAuthorizationStatus.unnecessary) {

build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
buildscript {
44

55
ext {
6-
kotlin_version = '1.3.61'
6+
kotlin_version = '1.3.72'
77
navigationVersion = "2.1.0-alpha02"
88
}
99

1010
repositories {
1111
google()
1212
jcenter()
13-
1413
}
1514
dependencies {
16-
classpath 'com.android.tools.build:gradle:3.5.3'
15+
classpath 'com.android.tools.build:gradle:4.0.1'
1716
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
1817
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1918
// NOTE: Do not place your application dependencies here; they belong
@@ -25,6 +24,7 @@ allprojects {
2524
repositories {
2625
google()
2726
jcenter()
27+
maven { url 'https://jitpack.io' }
2828
maven { url "https://dl.bintray.com/thecommonsproject/CommonHealth" }
2929
}
3030
}
@@ -37,11 +37,11 @@ ext {
3737

3838
// Sdk and tools
3939
// Support library and architecture components support minSdk 14 and above.
40-
minSdkVersion = 24
41-
targetSdkVersion = 28
42-
compileSdkVersion = 28
40+
minSdkVersion = 23
41+
targetSdkVersion = 29
42+
compileSdkVersion = 29
4343

44-
commonHealthVersion = '0.4.0'
44+
commonHealthVersion = '0.4.4'
4545

4646
appCompatVersion = '1.1.0'
4747
androidXVersion = '1.1.0'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Jan 10 08:20:16 MST 2020
1+
#Fri Jul 31 15:06:49 MDT 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

0 commit comments

Comments
 (0)