Slide 29
Slide 29 text
class GetImportantMessagesUseCase @Inject constructor(
private val loadSessionConfigurationUseCase: LoadSessionConfigurationUseCase,
private val getAppointmentsUseCase: GetAppointmentsUseCase,
private val getLoggedInPatientUseCase: GetLoggedInPatientUseCase,
private val getNotificationsUseCase: GetNotificationsUseCase,
private val isHealthCheckCompletedUseCase: IsHealthCheckCompletedUseCase,
private val systemUtil: SystemUtil
) : AuthenticatedUseCase() {
override fun applyUseCase(upstream: Observable): Observable {
return upstream.switchMap {
Observable.just(GetLoggedInPatientRequest())
.compose(getLoggedInPatientUseCase)
.toReadyData()
.toObservable()
.switchMap { patient ->
Observable.combineLatest(
Observable.just(LoadSessionConfigurationRequest())
.compose(loadSessionConfigurationUseCase),
Observable.just(GetAppointmentsRequest(patient.id !!))
.compose(getAppointmentsUseCase),
Observable.just(GetNotificationsRequest)
.compose(getNotificationsUseCase),
Observable.just(IsHealthCheckCompletedRequest)
.compose(isHealthCheckCompletedUseCase),
Function4 { sessionConfigurationStatus, getAppointmentsStatus, getNotificationsStatus,
isHealthCheckCompletedStatus ->
when {
getAppointmentsStatus is GetAppointmentsStatus.Error ->
GetImportantMessagesStatus.Error(getAppointmentsStatus.throwable)
sessionConfigurationStatus is LoadSessionConfigurationStatus.Error ->
GetImportantMessagesStatus.Error(sessionConfigurationStatus.throwable)
getNotificationsStatus is GetNotificationsStatus.Error ->
GetImportantMessagesStatus.Error(getNotificationsStatus.throwable)
isHealthCheckCompletedStatus is IsHealthCheckCompletedStatus.Error ->