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

HAPP-1904 #585

Merged
merged 2 commits into from
Jul 16, 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
160 changes: 5 additions & 155 deletions app/src/main/java/ca/bc/gov/bchealth/SplashViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import ca.bc.gov.common.BuildConfig.LOCAL_API_VERSION
import ca.bc.gov.common.model.AppFeatureName
import ca.bc.gov.common.model.QuickAccessLinkName
import ca.bc.gov.common.model.settings.AppFeatureDto
import ca.bc.gov.common.model.settings.QuickAccessTileDto
import ca.bc.gov.repository.OnBoardingRepository
import ca.bc.gov.repository.settings.AppFeatureRepository
import ca.bc.gov.repository.settings.QuickAccessTileRepository
import ca.bc.gov.repository.worker.MobileConfigRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.async
Expand All @@ -25,8 +20,7 @@ private const val MAX_SPLASH_DELAY = 2000L
class SplashViewModel @Inject constructor(
private val mobileConfigRepository: MobileConfigRepository,
onBoardingRepository: OnBoardingRepository,
private val appFeatureRepository: AppFeatureRepository,
private val quickAccessTileRepository: QuickAccessTileRepository
private val appFeatureRepository: AppFeatureRepository
) : ViewModel() {

private val _updateType: MutableLiveData<UpdateType> = MutableLiveData()
Expand All @@ -35,8 +29,10 @@ class SplashViewModel @Inject constructor(

init {
onBoardingRepository.checkIfReOnBoardingRequired(BuildConfig.VERSION_CODE)
initializeAppData()
addBCCancerQuickLink()
viewModelScope.launch {
appFeatureRepository.initializeAppData()
appFeatureRepository.addBCCancerQuickLink()
}
}

fun checkAppVersion() {
Expand All @@ -60,152 +56,6 @@ class SplashViewModel @Inject constructor(
}
}

private fun initializeAppData() = viewModelScope.launch {
val healthRecord = AppFeatureDto(
name = AppFeatureName.HEALTH_RECORDS,
hasManageableQuickAccessLinks = true,
showAsQuickAccess = true
)
val id = appFeatureRepository.insert(healthRecord)

if (id > 0) {

val tiles = timelineQuickLinkTiles(id)
quickAccessTileRepository.insertAll(tiles)
}

val immunizationSchedule = AppFeatureDto(
name = AppFeatureName.IMMUNIZATION_SCHEDULES,
hasManageableQuickAccessLinks = false,
showAsQuickAccess = true
)
appFeatureRepository.insert(immunizationSchedule)

val recommendations = AppFeatureDto(
name = AppFeatureName.RECOMMENDED_IMMUNIZATIONS,
hasManageableQuickAccessLinks = false,
showAsQuickAccess = true
)
appFeatureRepository.insert(recommendations)

val healthResources = AppFeatureDto(
name = AppFeatureName.HEALTH_RESOURCES,
hasManageableQuickAccessLinks = false,
showAsQuickAccess = true
)
appFeatureRepository.insert(healthResources)

val proofOfVaccine = AppFeatureDto(
name = AppFeatureName.PROOF_OF_VACCINE,
hasManageableQuickAccessLinks = false,
showAsQuickAccess = true
)
appFeatureRepository.insert(proofOfVaccine)

val services = AppFeatureDto(
name = AppFeatureName.SERVICES,
hasManageableQuickAccessLinks = true,
showAsQuickAccess = false
)

val serviceId = appFeatureRepository.insert(services)
if (serviceId > 0) {
quickAccessTileRepository.insertAll(serviceQuickLinkTilesItem(serviceId))
}
}

private fun addBCCancerQuickLink() = viewModelScope.launch {
try {
val appFeature = appFeatureRepository.getAppFeature(AppFeatureName.HEALTH_RECORDS)
val tile = QuickAccessTileDto(
featureId = appFeature.id,
tileName = QuickAccessLinkName.BC_CANCER_SCREENING,
tilePayload = "CancerScreening",
showAsQuickAccess = false
)
quickAccessTileRepository.insert(tile)
} catch (e: Exception) {
e.printStackTrace()
}
}

private fun serviceQuickLinkTilesItem(id: Long): List<QuickAccessTileDto> {
return listOf(
QuickAccessTileDto(
featureId = id,
tileName = QuickAccessLinkName.ORGAN_DONOR,
tilePayload = "Organ Donor",
showAsQuickAccess = false
)
)
}

private fun timelineQuickLinkTiles(id: Long): List<QuickAccessTileDto> {
return listOf(
QuickAccessTileDto(
featureId = id,
tileName = QuickAccessLinkName.IMMUNIZATIONS,
tilePayload = "Immunization",
showAsQuickAccess = false
),
QuickAccessTileDto(
featureId = id,
tileName = QuickAccessLinkName.MEDICATIONS,
tilePayload = "Medications",
showAsQuickAccess = false
),
QuickAccessTileDto(
featureId = id,
tileName = QuickAccessLinkName.LAB_RESULTS,
tilePayload = "Laboratory",
showAsQuickAccess = false
),
QuickAccessTileDto(
featureId = id,
tileName = QuickAccessLinkName.COVID_19_TESTS,
tilePayload = "COVID19Laboratory",
showAsQuickAccess = false
),
QuickAccessTileDto(
featureId = id,
tileName = QuickAccessLinkName.HEALTH_VISITS,
tilePayload = "HealthVisit",
showAsQuickAccess = false
),
QuickAccessTileDto(
featureId = id,
tileName = QuickAccessLinkName.SPECIAL_AUTHORITY,
tilePayload = "SpecialAuthority",
showAsQuickAccess = false
),
QuickAccessTileDto(
featureId = id,
tileName = QuickAccessLinkName.HOSPITAL_VISITS,
tilePayload = "HospitalVisit",
showAsQuickAccess = false
),
QuickAccessTileDto(
featureId = id,
tileName = QuickAccessLinkName.CLINICAL_DOCUMENTS,
tilePayload = "ClinicalDocument",
showAsQuickAccess = false
),
QuickAccessTileDto(
featureId = id,
tileName = QuickAccessLinkName.IMAGING_REPORTS,
tilePayload = "ImagingReports",
showAsQuickAccess = false
),
QuickAccessTileDto(
featureId = id,
tileName = QuickAccessLinkName.BC_CANCER_SCREENING,
tilePayload = "CancerScreening",
showAsQuickAccess = false
)

)
}

enum class UpdateType {
FORCE_UPDATE, CHECK_SOFT_UPDATE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import ca.bc.gov.common.BuildConfig
import ca.bc.gov.repository.OnBoardingRepository
import ca.bc.gov.repository.settings.AppFeatureRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand All @@ -15,11 +16,19 @@ import javax.inject.Inject
*/
@HiltViewModel
class OnBoardingSliderViewModel @Inject constructor(
private val onBoardingRepository: OnBoardingRepository
private val onBoardingRepository: OnBoardingRepository,
private val appFeatureRepository: AppFeatureRepository,
) : ViewModel() {

val isReOnBoardingRequired = onBoardingRepository.isReOnBoardingRequired

init {
viewModelScope.launch {
appFeatureRepository.initializeAppData()
appFeatureRepository.addBCCancerQuickLink()
}
}

fun setOnBoardingRequired(isRequired: Boolean) = viewModelScope.launch {
withContext(Dispatchers.IO) {
onBoardingRepository.onBoardingRequired = isRequired
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/navigation/dependents.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,16 @@
app:nullable="true" />
</fragment>

<fragment
android:id="@+id/commentsFragment"
android:name="ca.bc.gov.bchealth.ui.comment.CommentsFragment"
android:label="fragment_comments"
tools:layout="@layout/fragment_comments">
<argument
android:name="recordType"
app:argType="string" />
<argument
android:name="parentEntryId"
app:argType="string" />
</fragment>
</navigation>
21 changes: 20 additions & 1 deletion app/src/main/res/navigation/health_pass.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,29 @@
<action
android:id="@+id/action_addCardOptionFragment_to_onBoardingFragment"
app:destination="@id/onBoardingFragment" />

<action
android:id="@+id/action_addCardOptionFragment_to_fetchVaccineRecord"
app:destination="@id/fetchVaccineRecordFragment" />
</fragment>

<fragment
android:id="@+id/fetchVaccineRecordFragment"
android:name="ca.bc.gov.bchealth.ui.healthpass.add.FetchVaccineRecordFragment"
tools:layout="@layout/fragment_fetch_vaccine_record">
<action
android:id="@+id/action_fetchVaccineRecordFragment_to_vaccineRecordDetailFragment"
app:destination="@id/vaccineRecordDetailFragment" />
</fragment>

<fragment
android:id="@+id/vaccineRecordDetailFragment"
android:name="ca.bc.gov.bchealth.ui.healthrecord.vaccine.VaccineRecordDetailFragment"
android:label="fragment_vaccine_record_detail"
tools:layout="@layout/fragment_vaccine_record_detail">
<argument
android:name="patientId"
app:argType="long" />
</fragment>
<dialog
android:id="@+id/expandQRFragment"
android:name="ca.bc.gov.bchealth.ui.healthpass.ExpandQRFragment"
Expand Down
22 changes: 1 addition & 21 deletions app/src/main/res/navigation/health_records.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
android:id="@+id/healthRecordFragment"
android:name="ca.bc.gov.bchealth.ui.healthrecord.HealthRecordFragment"
android:label="HealthRecordFragment" >
<action
android:id="@+id/action_healthRecordFragment_to_vaccineRecordDetailFragment"
app:destination="@id/vaccineRecordDetailFragment" />

<action
android:id="@+id/action_healthRecordFragment_to_medicationDetailFragment"
app:destination="@id/medicationDetailsFragment" />
Expand Down Expand Up @@ -53,24 +51,6 @@
android:label="AddHealthRecordsFragment"
tools:layout="@layout/scene_health_records_add" />

<fragment
android:id="@+id/fetchVaccineRecordFragment"
android:name="ca.bc.gov.bchealth.ui.healthpass.add.FetchVaccineRecordFragment"
tools:layout="@layout/fragment_fetch_vaccine_record">
<action
android:id="@+id/action_fetchVaccineRecordFragment_to_vaccineRecordDetailFragment"
app:destination="@id/vaccineRecordDetailFragment" />
</fragment>

<fragment
android:id="@+id/vaccineRecordDetailFragment"
android:name="ca.bc.gov.bchealth.ui.healthrecord.vaccine.VaccineRecordDetailFragment"
android:label="fragment_vaccine_record_detail"
tools:layout="@layout/fragment_vaccine_record_detail">
<argument
android:name="patientId"
app:argType="long" />
</fragment>
<fragment
android:id="@+id/medicationDetailsFragment"
android:name="ca.bc.gov.bchealth.ui.healthrecord.medication.MedicationDetailsFragment"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@

<!-- Error -->
<string name="bcsc_auth_error_title">Problem with log in</string>
<string name="bcsc_auth_error_body">We are unable to retrive your health record at this moment because of problem with BC Service Card log in, please contact Health Gateway team: healthgateway@gov.bc.ca for more information</string>
<string name="bcsc_auth_error_body">We are unable to retrieve your health record at this moment because of a problem with the BC Services Card login. Please contact the Health Gateway team at healthgateway@gov.bc.ca for more information.</string>
<string name="bcsc_auth_error_click_email">healthgateway@gov.bc.ca</string>
<string name="bcsc_auth_error_button">Email us</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ class RepositoriesModule {
@Provides
@Singleton
fun provideAppFeatureRepository(
appFeatureLocalDataSource: AppFeatureLocalDataSource
): AppFeatureRepository = AppFeatureRepository(appFeatureLocalDataSource)
appFeatureLocalDataSource: AppFeatureLocalDataSource,
quickAccessTileRepository: QuickAccessTileRepository
): AppFeatureRepository = AppFeatureRepository(appFeatureLocalDataSource, quickAccessTileRepository)

@Provides
@Singleton
Expand Down
Loading
Loading