Skip to content

Commit 92ca237

Browse files
authored
Update code labs for engine and sdc (#2747)
* Updated data capture code lab * Updated code lab for engine
1 parent 205bfda commit 92ca237

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

codelabs/datacapture/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ of the `app/build.gradle.kts` file of your project:
7676
dependencies {
7777
// ...
7878

79-
implementation("com.google.android.fhir:data-capture:1.0.0")
80-
implementation("androidx.fragment:fragment-ktx:1.5.5")
79+
implementation("com.google.android.fhir:data-capture:1.2.0")
80+
implementation("androidx.fragment:fragment-ktx:1.6.0")
8181
}
8282
```
8383

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

151151
```kotlin
152152
// Step 2: Configure a QuestionnaireFragment
153-
val questionnaireJsonString = getStringFromAssets("questionnaire.json")
153+
questionnaireJsonString = getStringFromAssets("questionnaire.json")
154+
155+
val questionnaireFragment =
156+
QuestionnaireFragment.builder().setQuestionnaire(questionnaireJsonString!!).build()
154157

155-
val questionnaireParams = bundleOf(
156-
QuestionnaireFragment.EXTRA_QUESTIONNAIRE_JSON_STRING to questionnaireJsonString
157-
)
158158
```
159159

160160
### Step 3: Add the QuestionnaireFragment to the FragmentContainerView
@@ -168,10 +168,10 @@ Add the following code to the `MainActivity` class:
168168
```kotlin
169169
// Step 3: Add the QuestionnaireFragment to the FragmentContainerView
170170
if (savedInstanceState == null) {
171-
supportFragmentManager.commit {
172-
setReorderingAllowed(true)
173-
add<QuestionnaireFragment>(R.id.fragment_container_view, args = questionnaireParams)
174-
}
171+
supportFragmentManager.commit {
172+
setReorderingAllowed(true)
173+
add(R.id.fragment_container_view, questionnaireFragment)
174+
}
175175
}
176176
// Submit button callback
177177
supportFragmentManager.setFragmentResultListener(

codelabs/engine/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ file of your project:
125125
dependencies {
126126
// ...
127127
128-
implementation("com.google.android.fhir:engine:1.0.0")
128+
implementation("com.google.android.fhir:engine:1.1.0")
129129
}
130130
```
131131
@@ -257,7 +257,13 @@ outlined below will guide you through the process.
257257
258258
override fun getFhirEngine() = FhirApplication.fhirEngine(applicationContext)
259259
260-
override fun getUploadStrategy() = UploadStrategy.AllChangesSquashedBundlePut
260+
override fun getUploadStrategy() =
261+
UploadStrategy.forBundleRequest(
262+
methodForCreate = HttpCreateMethod.PUT,
263+
methodForUpdate = HttpUpdateMethod.PATCH,
264+
squash = true,
265+
bundleSize = 500,
266+
)
261267
}
262268
```
263269

codelabs/engine/app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ dependencies {
4949
androidTestImplementation("androidx.test.ext:junit:1.2.1")
5050
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
5151

52-
implementation("com.google.android.fhir:engine:1.0.0")
52+
implementation("com.google.android.fhir:engine:1.1.0")
5353
implementation("androidx.fragment:fragment-ktx:1.8.3")
5454
}

codelabs/engine/app/src/main/java/com/google/android/fhir/codelabs/engine/PatientItemViewHolder.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Google LLC
2+
* Copyright 2023-2024 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,8 +30,10 @@ class PatientItemViewHolder(binding: PatientListItemViewBinding) :
3030

3131
fun bind(patientItem: Patient) {
3232
nameTextView.text =
33-
patientItem.name.first().let { it.given.joinToString(separator = " ") + " " + it.family }
34-
genderTextView.text = patientItem.gender.display
33+
patientItem.name.firstOrNull()?.let {
34+
it.given.joinToString(separator = " ") + " " + it.family
35+
}
36+
genderTextView.text = patientItem.gender?.display
3537
cityTextView.text = patientItem.address.singleOrNull()?.city
3638
}
3739
}

0 commit comments

Comments
 (0)