Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Transfer out screen to send email #62

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.util.Log
import androidx.hilt.work.HiltWorkerFactory
import androidx.work.Configuration
import com.google.android.fhir.datacapture.DataCaptureConfig
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import com.google.firebase.perf.ktx.performance
Expand Down Expand Up @@ -50,6 +51,7 @@ class DataClerkApplication : Application(), DataCaptureConfig.Provider, Configur
if (BuildConfig.DEBUG) {
Firebase.performance.isPerformanceCollectionEnabled = false
Firebase.crashlytics.setCrashlyticsCollectionEnabled(false)
Firebase.analytics.setAnalyticsCollectionEnabled(false)
Timber.plant(Timber.DebugTree())
}
}
Expand Down
5 changes: 3 additions & 2 deletions android/engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,12 @@ dependencies {
api("com.squareup.okhttp3:okhttp:$okhttpVersion")
api("com.squareup.okhttp3:logging-interceptor:$okhttpVersion")

implementation(platform("com.google.firebase:firebase-bom:32.7.3"))
implementation(platform("com.google.firebase:firebase-bom:33.0.0"))
implementation("com.google.firebase:firebase-perf-ktx")
implementation("com.google.firebase:firebase-crashlytics-ktx")
implementation("com.google.firebase:firebase-analytics")

implementation("androidx.core:core-splashscreen:1.0.0")
implementation("androidx.core:core-splashscreen:1.0.1")

// Hilt test dependencies
testImplementation("com.google.dagger:hilt-android-testing:${Deps.versions.hiltVersion}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ data class ApplicationConfiguration(
var taskOrderFilterTagViaMetaCodingSystem: String = SystemConstants.TASK_TASK_ORDER_SYSTEM,
var taskFilterTagViaMetaCodingSystem: String = SystemConstants.TASK_FILTER_TAG_SYSTEM,
var registrationForm: String = "patient-demographic-registration",
var supportEmail: String = "info@tingathe.org",
var supportPhoneNumber: String = ""
) : Configuration

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
import org.smartregister.fhircore.engine.trace.AnalyticReporter
import org.smartregister.fhircore.engine.trace.FirebaseAnalyticReporter
import org.smartregister.fhircore.engine.trace.FirebasePerformanceReporter
import org.smartregister.fhircore.engine.trace.PerformanceReporter

Expand All @@ -35,4 +37,6 @@ class AnalyticsModule {
@Provides
fun providePerformanceReporter(firebasePerformance: FirebasePerformance): PerformanceReporter =
FirebasePerformanceReporter(firebasePerformance)

@Provides fun providesAnalyticsReporter(): AnalyticReporter = FirebaseAnalyticReporter()
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ constructor(
appointment.status = Appointment.AppointmentStatus.WAITLIST
tracingTasksToAdd.addAll(addMissedAppointment(appointment, true))
}
if(missedAppointmentInRange) {
if (missedAppointmentInRange) {
appointment.status = Appointment.AppointmentStatus.NOSHOW
tracingTasksToAdd.addAll(addMissedAppointment(appointment, false))
}
Expand Down Expand Up @@ -361,13 +361,13 @@ constructor(
}
}
}
if(!isMilestoneAppointment) {
if (!isMilestoneAppointment) {
addToTracingList(
appointment,
if (isEID) {
ReasonConstants.missedRoutineAppointmentTracingCode
} else ReasonConstants.missedAppointmentTracingCode,
)
appointment,
if (isEID) {
ReasonConstants.missedRoutineAppointmentTracingCode
} else ReasonConstants.missedAppointmentTracingCode,
)
?.let { tracingTasks.add(it) }
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2021 Ona Systems, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.smartregister.fhircore.engine.trace

interface AnalyticReporter {
fun log(key: String, params: Map<String, String>)

fun log(key: String)

fun login(id: String)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2021 Ona Systems, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.smartregister.fhircore.engine.trace

import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.analytics.logEvent
import com.google.firebase.ktx.Firebase

class FirebaseAnalyticReporter : AnalyticReporter {
private var firebaseAnalytics: FirebaseAnalytics = Firebase.analytics

override fun log(key: String, params: Map<String, String>) {
firebaseAnalytics.logEvent(key) { params.forEach { entry -> param(entry.key, entry.value) } }
}

override fun log(key: String) {
firebaseAnalytics.logEvent(key, null)
}

override fun login(id: String) {
log(AnalyticsKeys.LOGIN)
}
}

object AnalyticsKeys {
const val LOGIN = "login"
const val SEARCH = "search"
const val TRANSFER_OUT = "transfer_out"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ object SystemConstants {
const val OBSERVATION_CODE_SYSTEM = "https://d-tree.org/fhir/observation-codes"
const val CARE_PLAN_REFERENCE_SYSTEM = "https://d-tree.org/fhir/careplan-reference"
const val QUESTIONNAIRE_REFERENCE_SYSTEM = "https://d-tree.org/fhir/procedure-code"
const val LOCATION_TAG = "http://smartregister.org/fhir/location-tag"
}

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

var pendingTransferOutCode =
Coding("https://d-tree.org/fhir/transfer-out-status", "pending", "Pending")

const val TRACING_OUTCOME_CODE = "tracing-outcome"
const val DATE_OF_AGREED_APPOINTMENT = "date-of-agreed-appointment"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import ca.uhn.fhir.util.UrlUtil
import com.google.android.fhir.FhirEngine
import com.google.android.fhir.db.ResourceNotFoundException
import com.google.android.fhir.get
import com.google.android.fhir.logicalId
import com.google.android.fhir.search.Operation
import com.google.android.fhir.search.SearchQuery
import com.google.android.fhir.search.filter.TokenParamFilterCriterion
Expand Down Expand Up @@ -116,3 +117,20 @@ suspend inline fun <reified R : Resource> FhirEngine.getResourcesByIds(
}
.map { it.resource }
}

suspend fun FhirEngine.forceTagsUpdate(source: Resource) {
try {
var resource = source
/** Increment [Resource.meta] versionId of [source]. */
resource.meta.versionId?.toInt()?.plus(1)?.let {
/** Assign [Resource.meta] versionId of [source]. */
resource = resource.copy().apply { meta.versionId = "$it" }
/** Delete a FHIR [source] in the local storage. */
this.purge(resource.resourceType, resource.logicalId, forcePurge = true)
/** Recreate a FHIR [source] in the local storage. */
this.create(resource)
}
} catch (e: Exception) {
Timber.e(e)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.lifecycle.ProcessLifecycleOwner
import androidx.work.Configuration
import com.github.anrwatchdog.ANRWatchDog
import com.google.android.fhir.datacapture.DataCaptureConfig
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import com.google.firebase.perf.ktx.performance
Expand Down Expand Up @@ -93,6 +94,7 @@ class QuestApplication :
} else {
Firebase.performance.isPerformanceCollectionEnabled = false
Firebase.crashlytics.setCrashlyticsCollectionEnabled(false)
Firebase.analytics.setAnalyticsCollectionEnabled(false)
Timber.plant(Timber.DebugTree())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ sealed class MainNavigationScreen(
route = "tracingProfileRoute",
)

object TransferOut : MainNavigationScreen(route = "transferOut")

object PatientGuardians : MainNavigationScreen(route = "patientProfileGuardians")

object FamilyProfile : MainNavigationScreen(route = "familyProfileRoute")
Expand All @@ -94,6 +96,7 @@ sealed class MainNavigationScreen(
FamilyProfile,
ViewChildContacts,
GuardianProfile,
TransferOut,
TracingProfile,
TracingHistory,
TracingOutcomes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ open class AppMainActivity : BaseMultiLanguageActivity(), OnSyncListener {
schedulePlan(applicationContext)
scheduleCheckForMissedAppointments(applicationContext)
scheduleWelcomeServiceAppointments(applicationContext)
// scheduleWelcomeServiceToCarePlanForMissedAppointments(applicationContext)
// scheduleWelcomeServiceToCarePlanForMissedAppointments(applicationContext)
scheduleResourcePurger(applicationContext)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import org.smartregister.fhircore.quest.ui.patient.profile.PatientProfileScreen
import org.smartregister.fhircore.quest.ui.patient.profile.childcontact.ChildContactsProfileScreen
import org.smartregister.fhircore.quest.ui.patient.profile.guardians.GuardianRelatedPersonProfileScreen
import org.smartregister.fhircore.quest.ui.patient.profile.guardians.GuardiansRoute
import org.smartregister.fhircore.quest.ui.patient.profile.tranfer.TransferOutScreen
import org.smartregister.fhircore.quest.ui.patient.register.PatientRegisterScreen
import org.smartregister.fhircore.quest.ui.report.measure.MeasureReportViewModel
import org.smartregister.fhircore.quest.ui.report.measure.measureReportNavigationGraph
Expand Down Expand Up @@ -213,6 +214,18 @@ private fun AppMainNavigationGraph(
onBackPress = { navController.popBackStack() },
)
}
MainNavigationScreen.TransferOut ->
composable(
route = "${it.route}/{${NavigationArg.PATIENT_ID}}",
arguments =
commonNavArgs.plus(
listOf(
navArgument(NavigationArg.PATIENT_ID) { type = NavType.StringType },
),
),
) { _ ->
TransferOutScreen { navController.popBackStack() }
}
MainNavigationScreen.GuardianProfile ->
composable(
route =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,26 @@ constructor(
questionnaireType = QuestionnaireType.DEFAULT,
populationResources = profile.populationResources,
)
R.id.patient_transfer_out ->
QuestionnaireActivity.launchQuestionnaire(
event.context,
questionnaireId = PATIENT_TRANSFER_OUT,
clientIdentifier = patientId,
questionnaireType = QuestionnaireType.DEFAULT,
populationResources = profile.populationResources,
)
R.id.patient_transfer_out -> {
// QuestionnaireActivity.launchQuestionnaire(
// event.context,
// questionnaireId = PATIENT_TRANSFER_OUT,
// clientIdentifier = patientId,
// questionnaireType = QuestionnaireType.DEFAULT,
// populationResources = profile.populationResources,
// )
patientId.let {
val urlParams =
NavigationArg.bindArgumentsOf(
Pair(NavigationArg.FEATURE, AppFeature.PatientManagement.name),
Pair(NavigationArg.HEALTH_MODULE, HealthModule.HIV),
Pair(NavigationArg.PATIENT_ID, it),
)
event.navController.navigate(
route = "${MainNavigationScreen.TransferOut.route}/$it$urlParams",
)
}
}
R.id.patient_change_status ->
QuestionnaireActivity.launchQuestionnaire(
event.context,
Expand Down
Loading