Skip to content

Commit 1d5d9d6

Browse files
authored
Refactor Transfer out screen to send email (#62)
* Add Transfer out screen * Transfer out patient * Get support email from configs
1 parent 32b66e2 commit 1d5d9d6

File tree

18 files changed

+599
-19
lines changed

18 files changed

+599
-19
lines changed

android/dataclerk/src/main/java/org/dtree/fhircore/dataclerk/DataClerkApplication.kt

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import android.util.Log
2121
import androidx.hilt.work.HiltWorkerFactory
2222
import androidx.work.Configuration
2323
import com.google.android.fhir.datacapture.DataCaptureConfig
24+
import com.google.firebase.analytics.ktx.analytics
2425
import com.google.firebase.crashlytics.ktx.crashlytics
2526
import com.google.firebase.ktx.Firebase
2627
import com.google.firebase.perf.ktx.performance
@@ -50,6 +51,7 @@ class DataClerkApplication : Application(), DataCaptureConfig.Provider, Configur
5051
if (BuildConfig.DEBUG) {
5152
Firebase.performance.isPerformanceCollectionEnabled = false
5253
Firebase.crashlytics.setCrashlyticsCollectionEnabled(false)
54+
Firebase.analytics.setAnalyticsCollectionEnabled(false)
5355
Timber.plant(Timber.DebugTree())
5456
}
5557
}

android/engine/build.gradle.kts

+3-2
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,12 @@ dependencies {
216216
api("com.squareup.okhttp3:okhttp:$okhttpVersion")
217217
api("com.squareup.okhttp3:logging-interceptor:$okhttpVersion")
218218

219-
implementation(platform("com.google.firebase:firebase-bom:32.7.3"))
219+
implementation(platform("com.google.firebase:firebase-bom:33.0.0"))
220220
implementation("com.google.firebase:firebase-perf-ktx")
221221
implementation("com.google.firebase:firebase-crashlytics-ktx")
222+
implementation("com.google.firebase:firebase-analytics")
222223

223-
implementation("androidx.core:core-splashscreen:1.0.0")
224+
implementation("androidx.core:core-splashscreen:1.0.1")
224225

225226
// Hilt test dependencies
226227
testImplementation("com.google.dagger:hilt-android-testing:${Deps.versions.hiltVersion}")

android/engine/src/main/java/org/smartregister/fhircore/engine/configuration/app/ApplicationConfiguration.kt

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ data class ApplicationConfiguration(
3636
var taskOrderFilterTagViaMetaCodingSystem: String = SystemConstants.TASK_TASK_ORDER_SYSTEM,
3737
var taskFilterTagViaMetaCodingSystem: String = SystemConstants.TASK_FILTER_TAG_SYSTEM,
3838
var registrationForm: String = "patient-demographic-registration",
39+
var supportEmail: String = "info@tingathe.org",
40+
var supportPhoneNumber: String = ""
3941
) : Configuration
4042

4143
/**

android/engine/src/main/java/org/smartregister/fhircore/engine/di/AnalyticsModule.kt

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import dagger.Provides
2222
import dagger.hilt.InstallIn
2323
import dagger.hilt.components.SingletonComponent
2424
import javax.inject.Singleton
25+
import org.smartregister.fhircore.engine.trace.AnalyticReporter
26+
import org.smartregister.fhircore.engine.trace.FirebaseAnalyticReporter
2527
import org.smartregister.fhircore.engine.trace.FirebasePerformanceReporter
2628
import org.smartregister.fhircore.engine.trace.PerformanceReporter
2729

@@ -35,4 +37,6 @@ class AnalyticsModule {
3537
@Provides
3638
fun providePerformanceReporter(firebasePerformance: FirebasePerformance): PerformanceReporter =
3739
FirebasePerformanceReporter(firebasePerformance)
40+
41+
@Provides fun providesAnalyticsReporter(): AnalyticReporter = FirebaseAnalyticReporter()
3842
}

android/engine/src/main/java/org/smartregister/fhircore/engine/task/FhirResourceUtil.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ constructor(
209209
appointment.status = Appointment.AppointmentStatus.WAITLIST
210210
tracingTasksToAdd.addAll(addMissedAppointment(appointment, true))
211211
}
212-
if(missedAppointmentInRange) {
212+
if (missedAppointmentInRange) {
213213
appointment.status = Appointment.AppointmentStatus.NOSHOW
214214
tracingTasksToAdd.addAll(addMissedAppointment(appointment, false))
215215
}
@@ -361,13 +361,13 @@ constructor(
361361
}
362362
}
363363
}
364-
if(!isMilestoneAppointment) {
364+
if (!isMilestoneAppointment) {
365365
addToTracingList(
366-
appointment,
367-
if (isEID) {
368-
ReasonConstants.missedRoutineAppointmentTracingCode
369-
} else ReasonConstants.missedAppointmentTracingCode,
370-
)
366+
appointment,
367+
if (isEID) {
368+
ReasonConstants.missedRoutineAppointmentTracingCode
369+
} else ReasonConstants.missedAppointmentTracingCode,
370+
)
371371
?.let { tracingTasks.add(it) }
372372
}
373373

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2021 Ona Systems, Inc
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.smartregister.fhircore.engine.trace
18+
19+
interface AnalyticReporter {
20+
fun log(key: String, params: Map<String, String>)
21+
22+
fun log(key: String)
23+
24+
fun login(id: String)
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2021 Ona Systems, Inc
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.smartregister.fhircore.engine.trace
18+
19+
import com.google.firebase.analytics.FirebaseAnalytics
20+
import com.google.firebase.analytics.ktx.analytics
21+
import com.google.firebase.analytics.logEvent
22+
import com.google.firebase.ktx.Firebase
23+
24+
class FirebaseAnalyticReporter : AnalyticReporter {
25+
private var firebaseAnalytics: FirebaseAnalytics = Firebase.analytics
26+
27+
override fun log(key: String, params: Map<String, String>) {
28+
firebaseAnalytics.logEvent(key) { params.forEach { entry -> param(entry.key, entry.value) } }
29+
}
30+
31+
override fun log(key: String) {
32+
firebaseAnalytics.logEvent(key, null)
33+
}
34+
35+
override fun login(id: String) {
36+
log(AnalyticsKeys.LOGIN)
37+
}
38+
}
39+
40+
object AnalyticsKeys {
41+
const val LOGIN = "login"
42+
const val SEARCH = "search"
43+
const val TRANSFER_OUT = "transfer_out"
44+
}

android/engine/src/main/java/org/smartregister/fhircore/engine/util/SystemConstants.kt

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ object SystemConstants {
3131
const val OBSERVATION_CODE_SYSTEM = "https://d-tree.org/fhir/observation-codes"
3232
const val CARE_PLAN_REFERENCE_SYSTEM = "https://d-tree.org/fhir/careplan-reference"
3333
const val QUESTIONNAIRE_REFERENCE_SYSTEM = "https://d-tree.org/fhir/procedure-code"
34+
const val LOCATION_TAG = "http://smartregister.org/fhir/location-tag"
3435
}
3536

3637
object ReasonConstants {
@@ -53,6 +54,9 @@ object ReasonConstants {
5354
var interruptedTreatmentTracingCode =
5455
Coding(SystemConstants.REASON_CODE_SYSTEM, "interrupted-treatment", "Interrupted Treatment")
5556

57+
var pendingTransferOutCode =
58+
Coding("https://d-tree.org/fhir/transfer-out-status", "pending", "Pending")
59+
5660
const val TRACING_OUTCOME_CODE = "tracing-outcome"
5761
const val DATE_OF_AGREED_APPOINTMENT = "date-of-agreed-appointment"
5862
}

android/engine/src/main/java/org/smartregister/fhircore/engine/util/extension/FhirEngineExtension.kt

+18
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import ca.uhn.fhir.util.UrlUtil
2121
import com.google.android.fhir.FhirEngine
2222
import com.google.android.fhir.db.ResourceNotFoundException
2323
import com.google.android.fhir.get
24+
import com.google.android.fhir.logicalId
2425
import com.google.android.fhir.search.Operation
2526
import com.google.android.fhir.search.SearchQuery
2627
import com.google.android.fhir.search.filter.TokenParamFilterCriterion
@@ -116,3 +117,20 @@ suspend inline fun <reified R : Resource> FhirEngine.getResourcesByIds(
116117
}
117118
.map { it.resource }
118119
}
120+
121+
suspend fun FhirEngine.forceTagsUpdate(source: Resource) {
122+
try {
123+
var resource = source
124+
/** Increment [Resource.meta] versionId of [source]. */
125+
resource.meta.versionId?.toInt()?.plus(1)?.let {
126+
/** Assign [Resource.meta] versionId of [source]. */
127+
resource = resource.copy().apply { meta.versionId = "$it" }
128+
/** Delete a FHIR [source] in the local storage. */
129+
this.purge(resource.resourceType, resource.logicalId, forcePurge = true)
130+
/** Recreate a FHIR [source] in the local storage. */
131+
this.create(resource)
132+
}
133+
} catch (e: Exception) {
134+
Timber.e(e)
135+
}
136+
}

android/quest/src/main/java/org/smartregister/fhircore/quest/QuestApplication.kt

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import androidx.lifecycle.ProcessLifecycleOwner
3030
import androidx.work.Configuration
3131
import com.github.anrwatchdog.ANRWatchDog
3232
import com.google.android.fhir.datacapture.DataCaptureConfig
33+
import com.google.firebase.analytics.ktx.analytics
3334
import com.google.firebase.crashlytics.ktx.crashlytics
3435
import com.google.firebase.ktx.Firebase
3536
import com.google.firebase.perf.ktx.performance
@@ -93,6 +94,7 @@ class QuestApplication :
9394
} else {
9495
Firebase.performance.isPerformanceCollectionEnabled = false
9596
Firebase.crashlytics.setCrashlyticsCollectionEnabled(false)
97+
Firebase.analytics.setAnalyticsCollectionEnabled(false)
9698
Timber.plant(Timber.DebugTree())
9799
}
98100

android/quest/src/main/java/org/smartregister/fhircore/quest/navigation/MainNavigationScreen.kt

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ sealed class MainNavigationScreen(
6868
route = "tracingProfileRoute",
6969
)
7070

71+
object TransferOut : MainNavigationScreen(route = "transferOut")
72+
7173
object PatientGuardians : MainNavigationScreen(route = "patientProfileGuardians")
7274

7375
object FamilyProfile : MainNavigationScreen(route = "familyProfileRoute")
@@ -94,6 +96,7 @@ sealed class MainNavigationScreen(
9496
FamilyProfile,
9597
ViewChildContacts,
9698
GuardianProfile,
99+
TransferOut,
97100
TracingProfile,
98101
TracingHistory,
99102
TracingOutcomes,

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ open class AppMainActivity : BaseMultiLanguageActivity(), OnSyncListener {
158158
schedulePlan(applicationContext)
159159
scheduleCheckForMissedAppointments(applicationContext)
160160
scheduleWelcomeServiceAppointments(applicationContext)
161-
// scheduleWelcomeServiceToCarePlanForMissedAppointments(applicationContext)
161+
// scheduleWelcomeServiceToCarePlanForMissedAppointments(applicationContext)
162162
scheduleResourcePurger(applicationContext)
163163
}
164164
}

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainScreen.kt

+13
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import org.smartregister.fhircore.quest.ui.patient.profile.PatientProfileScreen
4949
import org.smartregister.fhircore.quest.ui.patient.profile.childcontact.ChildContactsProfileScreen
5050
import org.smartregister.fhircore.quest.ui.patient.profile.guardians.GuardianRelatedPersonProfileScreen
5151
import org.smartregister.fhircore.quest.ui.patient.profile.guardians.GuardiansRoute
52+
import org.smartregister.fhircore.quest.ui.patient.profile.tranfer.TransferOutScreen
5253
import org.smartregister.fhircore.quest.ui.patient.register.PatientRegisterScreen
5354
import org.smartregister.fhircore.quest.ui.report.measure.MeasureReportViewModel
5455
import org.smartregister.fhircore.quest.ui.report.measure.measureReportNavigationGraph
@@ -213,6 +214,18 @@ private fun AppMainNavigationGraph(
213214
onBackPress = { navController.popBackStack() },
214215
)
215216
}
217+
MainNavigationScreen.TransferOut ->
218+
composable(
219+
route = "${it.route}/{${NavigationArg.PATIENT_ID}}",
220+
arguments =
221+
commonNavArgs.plus(
222+
listOf(
223+
navArgument(NavigationArg.PATIENT_ID) { type = NavType.StringType },
224+
),
225+
),
226+
) { _ ->
227+
TransferOutScreen { navController.popBackStack() }
228+
}
216229
MainNavigationScreen.GuardianProfile ->
217230
composable(
218231
route =

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/patient/profile/PatientProfileViewModel.kt

+20-8
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,26 @@ constructor(
302302
questionnaireType = QuestionnaireType.DEFAULT,
303303
populationResources = profile.populationResources,
304304
)
305-
R.id.patient_transfer_out ->
306-
QuestionnaireActivity.launchQuestionnaire(
307-
event.context,
308-
questionnaireId = PATIENT_TRANSFER_OUT,
309-
clientIdentifier = patientId,
310-
questionnaireType = QuestionnaireType.DEFAULT,
311-
populationResources = profile.populationResources,
312-
)
305+
R.id.patient_transfer_out -> {
306+
// QuestionnaireActivity.launchQuestionnaire(
307+
// event.context,
308+
// questionnaireId = PATIENT_TRANSFER_OUT,
309+
// clientIdentifier = patientId,
310+
// questionnaireType = QuestionnaireType.DEFAULT,
311+
// populationResources = profile.populationResources,
312+
// )
313+
patientId.let {
314+
val urlParams =
315+
NavigationArg.bindArgumentsOf(
316+
Pair(NavigationArg.FEATURE, AppFeature.PatientManagement.name),
317+
Pair(NavigationArg.HEALTH_MODULE, HealthModule.HIV),
318+
Pair(NavigationArg.PATIENT_ID, it),
319+
)
320+
event.navController.navigate(
321+
route = "${MainNavigationScreen.TransferOut.route}/$it$urlParams",
322+
)
323+
}
324+
}
313325
R.id.patient_change_status ->
314326
QuestionnaireActivity.launchQuestionnaire(
315327
event.context,

0 commit comments

Comments
 (0)