Skip to content

Commit 72340da

Browse files
authored
Merge pull request #11 from the-commons-project/add_payer
TCPE-1364 Update Sample App with 1.6.2 SDK/Insurance information
2 parents 8ceb40e + 51c26d5 commit 72340da

File tree

6 files changed

+61
-39
lines changed

6 files changed

+61
-39
lines changed

README.md

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Once CommonHealth Developer Edition is installed, you will need to add a sample
3030
The CommonHealth Client SDK consists of two modules: commonhealth-client and commonhealth-common. CommonHealthClient contains the bulk of functionality for the SDK, while common contains 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:
3131

3232
```
33-
implementation "org.thecommonsproject:commonhealth-common:1.3.15"
34-
implementation "org.thecommonsproject:commonhealth-client:1.3.15"
33+
implementation "org.thecommonsproject:commonhealth-common:1.6.2"
34+
implementation "org.thecommonsproject:commonhealth-client:1.6.2"
3535
```
3636

3737
The release artifacts are made avalable via the Maven Central repository, so you will need to have the following in your list of dependency repositories:
@@ -187,17 +187,19 @@ Client applications should follow the principle of least privilege and only requ
187187

188188
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.
189189

190-
The following sample creates a `ScopeRequest` object requesting read access to all currently available clinical data types:
190+
The following sample creates a `ScopeRequest` object requesting read access to all currently available FHIR data types:
191191

192192
```
193-
val allDataTypes: List<DataType.ClinicalResource> = listOf(
194-
DataType.ClinicalResource.AllergyIntoleranceResource,
195-
DataType.ClinicalResource.ClinicalVitalsResource,
196-
DataType.ClinicalResource.ConditionsResource,
197-
DataType.ClinicalResource.ImmunizationsResource,
198-
DataType.ClinicalResource.LaboratoryResultsResource,
199-
DataType.ClinicalResource.MedicationResource,
200-
DataType.ClinicalResource.ProceduresResource
193+
val allDataTypes: List<DataType.FHIRResource> = listOf(
194+
DataType.ClinicalResource.AllergyIntoleranceResource,
195+
DataType.ClinicalResource.ClinicalVitalsResource,
196+
DataType.ClinicalResource.ConditionsResource,
197+
DataType.ClinicalResource.ImmunizationsResource,
198+
DataType.ClinicalResource.LaboratoryResultsResource,
199+
DataType.ClinicalResource.MedicationResource,
200+
DataType.ClinicalResource.ProceduresResource,
201+
DataType.PayerResource.ExplanationOfBenefitResource,
202+
DataType.PayerResource.CoverageResource,
201203
)
202204
203205
val scopeRequest: ScopeRequest by lazy {
@@ -294,16 +296,15 @@ In order to fetch data, the SDK provides the `readSampleQuery` method on the `Co
294296

295297
```
296298
suspend fun readSampleQuery(
297-
context: Context,
298-
connectionAlias: String,
299-
dataTypes: Set<DataType>,
300-
before: Date? = null,
301-
after: Date? = null,
302-
fetchedAfter: Date? = null
303-
): List<DataQueryResult>
299+
context: Context,
300+
connectionAlias: String,
301+
dataTypes: Set<DataType.FHIRResource>,
302+
beforeAfterDatePair: Pair<Date?, Date?>,
303+
fetchedAfter: Date? = null
304+
): List<SampleDataQueryResult>
304305
```
305306

306-
As you can see, the method returns a list of `SampleDataQueryResult` instances. For requests for clinical data, these can be cast to `FHIRSampleDataQueryResult` instances. Each `FHIRSampleDataQueryResult` instance contains the following:
307+
As you can see, the method returns a list of `SampleDataQueryResult` instances. For requests for FHIR data, these can be cast to `FHIRSampleDataQueryResult` instances. Each `FHIRSampleDataQueryResult` instance contains the following:
307308

308309
- resourceType: DataType.FHIRResource - the type of the resource
309310
- json: String - JSON string representation of the FHIR resource
@@ -341,6 +342,18 @@ Upon receiving the NEW_DATA_AVAILABLE notification, you can invoke a method on t
341342

342343
Using these can help you identify when and if you need to pull data from CommonHealth, or if data has been deleted in CommonHealth and should be removed from your local datastore, if persisted.
343344

345+
### Using CMS Blue Button Sandbox -- new in v1.6.2 and currently in beta
346+
347+
_Note: This feature is currently in beta and should not yet be used in production applications. We'd love your feedback as you start using it; please open a Github issue, or email developers [at] commonhealth.org with any thoughts that you have. Thank you!_
348+
349+
Client applications can now request to read Insurance data from CommonHealth. This data flows similarly to the existing clinical data types.
350+
351+
Important note: CMS requires a client id and secret. [Register with CMS](https://sandbox.bluebutton.cms.gov/v1/accounts/create) to get a client id and secret.
352+
353+
Be sure to register your sandbox app with our redirect url: org.thecommonsproject.android.phr.developer://oauth/redirect
354+
355+
We can\'t use our own so you\'ll have to provide one. We will save this id and secret only locally, for your development convenience. We never send this client id/secret anywhere except to the authorization server for OAuth.
356+
344357
### Reading Verifiable Credentials (SMART® Health Cards) -- new in v1.3.15 and currently in beta
345358

346359
_Note: This feature is currently in beta and should not yet be used in production applications. We'd love your feedback as you start using it; please open a Github issue, or email developers [at] commonhealth.org with any thoughts that you have. Thank you!_
@@ -375,6 +388,12 @@ CommonHealth performs SMART® Health Card validation prior to ingesting the card
375388

376389
Registering with CommonHealth is not required to begin testing integrations with CommonHealth Developer Edition. However, if you have a client application that you would like to use in staging or 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 developers [at] commonhealth.org for more information.
377390

391+
## Upgrading from v1.3.15 to v1.6.2
392+
`v1.6.12` introduced insurance data:
393+
394+
- Support for Insurance data through the CMS Blue Button 2.0 Sandbox. This will require you to register with CMS an app with a redirect url to CommonHealth, and then for you to provide the client id/secret locally into CommonHealth so that you can download the data. Please see section "Using CMS Blue Button Sandbox" above.
395+
- Minor change to readSampleQuery(..) parameters
396+
378397
## Upgrading from v1.1.2 to v1.3.15
379398
`v1.3.15` introduced a small number of changes:
380399

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ class MainViewModel(
4040

4141
var storedVCResults = emptyList<VerifiableRecordSampleDataQueryResult>()
4242

43-
val allDataTypes: List<DataType.ClinicalResource> = listOf(
43+
val allDataTypes: List<DataType.FHIRResource> = listOf(
4444
DataType.ClinicalResource.AllergyIntoleranceResource,
4545
DataType.ClinicalResource.ClinicalVitalsResource,
4646
DataType.ClinicalResource.ConditionsResource,
4747
DataType.ClinicalResource.ImmunizationsResource,
4848
DataType.ClinicalResource.LaboratoryResultsResource,
4949
DataType.ClinicalResource.MedicationResource,
50-
DataType.ClinicalResource.ProceduresResource
50+
DataType.ClinicalResource.ProceduresResource,
51+
DataType.PayerResource.ExplanationOfBenefitResource,
52+
DataType.PayerResource.CoverageResource,
5153
)
5254

5355

@@ -60,12 +62,12 @@ class MainViewModel(
6062
}
6163

6264
sealed class ResultHolderMessage {
63-
class SetResults(val resourceType: DataType.ClinicalResource, val results: List<FHIRSampleDataQueryResult>) : ResultHolderMessage()
65+
class SetResults(val resourceType: DataType.FHIRResource, val results: List<FHIRSampleDataQueryResult>) : ResultHolderMessage()
6466
class SetRecordUpdateResults(val results: List<RecordUpdateQueryResult>) : ResultHolderMessage()
6567
}
6668

67-
private var resultsMap: Map<DataType.ClinicalResource, List<FHIRSampleDataQueryResult>> = emptyMap()
68-
var resultsLiveData: MutableLiveData<Map<DataType.ClinicalResource, List<FHIRSampleDataQueryResult>>> = MutableLiveData(resultsMap)
69+
private var resultsMap: Map<DataType.FHIRResource, List<FHIRSampleDataQueryResult>> = emptyMap()
70+
var resultsLiveData: MutableLiveData<Map<DataType.FHIRResource, List<FHIRSampleDataQueryResult>>> = MutableLiveData(resultsMap)
6971
val recordUpdatesLiveData = MutableLiveData<List<RecordUpdateQueryResult>>()
7072

7173
// This function launches a new counter actor
@@ -126,12 +128,13 @@ class MainViewModel(
126128
)
127129
}
128130

129-
private suspend fun fetchData(context: Context, clinicalResource: DataType.ClinicalResource) : List<DataQueryResult>{
131+
private suspend fun fetchData(context: Context, dataType: DataType.FHIRResource) : List<DataQueryResult>{
130132
return try {
131133
commonHealthStore.readSampleQuery(
132134
context,
133135
connectionAlias,
134-
setOf(clinicalResource)
136+
setOf(dataType),
137+
Pair(null, null)
135138
)
136139
} catch (e: Throwable) {
137140
Timber.e( e, "Exception fetching data")
@@ -153,12 +156,12 @@ class MainViewModel(
153156

154157
suspend fun fetchAllData(context: Context) {
155158
val typesToFetch = allDataTypes
156-
val sampleQueryFetchJobs = typesToFetch.map { clinicalResource ->
159+
val sampleQueryFetchJobs = typesToFetch.map { dataType ->
157160
CoroutineScope(Dispatchers.IO).launch {
158-
val results = fetchData(context, clinicalResource).mapNotNull { it as? FHIRSampleDataQueryResult }
161+
val results = fetchData(context, dataType).mapNotNull { it as? FHIRSampleDataQueryResult }
159162
resultsHolderActor!!.send(
160163
ResultHolderMessage.SetResults(
161-
clinicalResource,
164+
dataType,
162165
results
163166
)
164167
)

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ class CategoryListFragment : Fragment() {
137137
private fun updateUI() {
138138
viewModel.viewModelScope.launch {
139139
when(viewModel.getCommonHealthAvailability(requireContext())) {
140-
CommonHealthAvailability.AVAILABLE -> {
140+
CommonHealthAvailability.Available -> {
141141
requestShcsButton.isEnabled = true
142142
}
143-
CommonHealthAvailability.NOT_INSTALLED,
144-
CommonHealthAvailability.ACCOUNT_NOT_CONFIGURED_FOR_SHARING -> {
143+
CommonHealthAvailability.NotInstalled,
144+
CommonHealthAvailability.NotConfiguredForSharing -> {
145145
Toast.makeText(
146146
requireContext(),
147147
"Please make sure CommonHealth is installed and setup",
@@ -202,12 +202,12 @@ class CategoryListFragment : Fragment() {
202202
}
203203

204204
class ContentAdapter(
205-
private val categories: List<DataType.ClinicalResource>,
205+
private val categories: List<DataType>,
206206
private val generateOnClickListener: (DataType) -> View.OnClickListener
207207
) : RecyclerView.Adapter<CategoryListItemViewHolder>() {
208208

209-
private var resultsCounts: Map<DataType.ClinicalResource, Int>? = null
210-
fun updateResultsCounts(newResultsCounts: Map<DataType.ClinicalResource, Int>) {
209+
private var resultsCounts: Map<DataType.FHIRResource, Int>? = null
210+
fun updateResultsCounts(newResultsCounts: Map<DataType.FHIRResource, Int>) {
211211
resultsCounts = newResultsCounts
212212
notifyDataSetChanged()
213213
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ResourceListFragment : Fragment() {
4040
super.onViewCreated(view, savedInstanceState)
4141

4242
val safeArgs: ResourceListFragmentArgs by navArgs()
43-
val dataType = (safeArgs.dataType as? DataType.ClinicalResource) ?: run {
43+
val dataType = (safeArgs.dataType as? DataType.FHIRResource) ?: run {
4444
throw Exception("Unsupported data type")
4545
}
4646

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ buildscript {
1212
maven { url "https://jcenter.bintray.com" }
1313
}
1414
dependencies {
15-
classpath 'com.android.tools.build:gradle:7.0.1'
15+
classpath 'com.android.tools.build:gradle:7.2.2'
1616
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
1717
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1818
// NOTE: Do not place your application dependencies here; they belong
@@ -43,7 +43,7 @@ ext {
4343
targetSdkVersion = 31
4444
compileSdkVersion = 31
4545

46-
commonHealthVersion = '1.3.15'
46+
commonHealthVersion = '1.6.2'
4747

4848
appCompatVersion = '1.4.1'
4949
androidXVersion = '1.7.0'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Fri Feb 25 11:23:37 EST 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)