Skip to content

Commit c42650f

Browse files
authoredJul 16, 2024
Merge pull request #585 from bcgov/feature/HAPP-1904
HAPP-1904
2 parents 04c9e9f + 06e8102 commit c42650f

File tree

9 files changed

+207
-187
lines changed

9 files changed

+207
-187
lines changed
 

‎app/src/main/java/ca/bc/gov/bchealth/SplashViewModel.kt

+5-155
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@ import androidx.lifecycle.MutableLiveData
55
import androidx.lifecycle.ViewModel
66
import androidx.lifecycle.viewModelScope
77
import ca.bc.gov.common.BuildConfig.LOCAL_API_VERSION
8-
import ca.bc.gov.common.model.AppFeatureName
9-
import ca.bc.gov.common.model.QuickAccessLinkName
10-
import ca.bc.gov.common.model.settings.AppFeatureDto
11-
import ca.bc.gov.common.model.settings.QuickAccessTileDto
128
import ca.bc.gov.repository.OnBoardingRepository
139
import ca.bc.gov.repository.settings.AppFeatureRepository
14-
import ca.bc.gov.repository.settings.QuickAccessTileRepository
1510
import ca.bc.gov.repository.worker.MobileConfigRepository
1611
import dagger.hilt.android.lifecycle.HiltViewModel
1712
import kotlinx.coroutines.async
@@ -25,8 +20,7 @@ private const val MAX_SPLASH_DELAY = 2000L
2520
class SplashViewModel @Inject constructor(
2621
private val mobileConfigRepository: MobileConfigRepository,
2722
onBoardingRepository: OnBoardingRepository,
28-
private val appFeatureRepository: AppFeatureRepository,
29-
private val quickAccessTileRepository: QuickAccessTileRepository
23+
private val appFeatureRepository: AppFeatureRepository
3024
) : ViewModel() {
3125

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

3630
init {
3731
onBoardingRepository.checkIfReOnBoardingRequired(BuildConfig.VERSION_CODE)
38-
initializeAppData()
39-
addBCCancerQuickLink()
32+
viewModelScope.launch {
33+
appFeatureRepository.initializeAppData()
34+
appFeatureRepository.addBCCancerQuickLink()
35+
}
4036
}
4137

4238
fun checkAppVersion() {
@@ -60,152 +56,6 @@ class SplashViewModel @Inject constructor(
6056
}
6157
}
6258

63-
private fun initializeAppData() = viewModelScope.launch {
64-
val healthRecord = AppFeatureDto(
65-
name = AppFeatureName.HEALTH_RECORDS,
66-
hasManageableQuickAccessLinks = true,
67-
showAsQuickAccess = true
68-
)
69-
val id = appFeatureRepository.insert(healthRecord)
70-
71-
if (id > 0) {
72-
73-
val tiles = timelineQuickLinkTiles(id)
74-
quickAccessTileRepository.insertAll(tiles)
75-
}
76-
77-
val immunizationSchedule = AppFeatureDto(
78-
name = AppFeatureName.IMMUNIZATION_SCHEDULES,
79-
hasManageableQuickAccessLinks = false,
80-
showAsQuickAccess = true
81-
)
82-
appFeatureRepository.insert(immunizationSchedule)
83-
84-
val recommendations = AppFeatureDto(
85-
name = AppFeatureName.RECOMMENDED_IMMUNIZATIONS,
86-
hasManageableQuickAccessLinks = false,
87-
showAsQuickAccess = true
88-
)
89-
appFeatureRepository.insert(recommendations)
90-
91-
val healthResources = AppFeatureDto(
92-
name = AppFeatureName.HEALTH_RESOURCES,
93-
hasManageableQuickAccessLinks = false,
94-
showAsQuickAccess = true
95-
)
96-
appFeatureRepository.insert(healthResources)
97-
98-
val proofOfVaccine = AppFeatureDto(
99-
name = AppFeatureName.PROOF_OF_VACCINE,
100-
hasManageableQuickAccessLinks = false,
101-
showAsQuickAccess = true
102-
)
103-
appFeatureRepository.insert(proofOfVaccine)
104-
105-
val services = AppFeatureDto(
106-
name = AppFeatureName.SERVICES,
107-
hasManageableQuickAccessLinks = true,
108-
showAsQuickAccess = false
109-
)
110-
111-
val serviceId = appFeatureRepository.insert(services)
112-
if (serviceId > 0) {
113-
quickAccessTileRepository.insertAll(serviceQuickLinkTilesItem(serviceId))
114-
}
115-
}
116-
117-
private fun addBCCancerQuickLink() = viewModelScope.launch {
118-
try {
119-
val appFeature = appFeatureRepository.getAppFeature(AppFeatureName.HEALTH_RECORDS)
120-
val tile = QuickAccessTileDto(
121-
featureId = appFeature.id,
122-
tileName = QuickAccessLinkName.BC_CANCER_SCREENING,
123-
tilePayload = "CancerScreening",
124-
showAsQuickAccess = false
125-
)
126-
quickAccessTileRepository.insert(tile)
127-
} catch (e: Exception) {
128-
e.printStackTrace()
129-
}
130-
}
131-
132-
private fun serviceQuickLinkTilesItem(id: Long): List<QuickAccessTileDto> {
133-
return listOf(
134-
QuickAccessTileDto(
135-
featureId = id,
136-
tileName = QuickAccessLinkName.ORGAN_DONOR,
137-
tilePayload = "Organ Donor",
138-
showAsQuickAccess = false
139-
)
140-
)
141-
}
142-
143-
private fun timelineQuickLinkTiles(id: Long): List<QuickAccessTileDto> {
144-
return listOf(
145-
QuickAccessTileDto(
146-
featureId = id,
147-
tileName = QuickAccessLinkName.IMMUNIZATIONS,
148-
tilePayload = "Immunization",
149-
showAsQuickAccess = false
150-
),
151-
QuickAccessTileDto(
152-
featureId = id,
153-
tileName = QuickAccessLinkName.MEDICATIONS,
154-
tilePayload = "Medications",
155-
showAsQuickAccess = false
156-
),
157-
QuickAccessTileDto(
158-
featureId = id,
159-
tileName = QuickAccessLinkName.LAB_RESULTS,
160-
tilePayload = "Laboratory",
161-
showAsQuickAccess = false
162-
),
163-
QuickAccessTileDto(
164-
featureId = id,
165-
tileName = QuickAccessLinkName.COVID_19_TESTS,
166-
tilePayload = "COVID19Laboratory",
167-
showAsQuickAccess = false
168-
),
169-
QuickAccessTileDto(
170-
featureId = id,
171-
tileName = QuickAccessLinkName.HEALTH_VISITS,
172-
tilePayload = "HealthVisit",
173-
showAsQuickAccess = false
174-
),
175-
QuickAccessTileDto(
176-
featureId = id,
177-
tileName = QuickAccessLinkName.SPECIAL_AUTHORITY,
178-
tilePayload = "SpecialAuthority",
179-
showAsQuickAccess = false
180-
),
181-
QuickAccessTileDto(
182-
featureId = id,
183-
tileName = QuickAccessLinkName.HOSPITAL_VISITS,
184-
tilePayload = "HospitalVisit",
185-
showAsQuickAccess = false
186-
),
187-
QuickAccessTileDto(
188-
featureId = id,
189-
tileName = QuickAccessLinkName.CLINICAL_DOCUMENTS,
190-
tilePayload = "ClinicalDocument",
191-
showAsQuickAccess = false
192-
),
193-
QuickAccessTileDto(
194-
featureId = id,
195-
tileName = QuickAccessLinkName.IMAGING_REPORTS,
196-
tilePayload = "ImagingReports",
197-
showAsQuickAccess = false
198-
),
199-
QuickAccessTileDto(
200-
featureId = id,
201-
tileName = QuickAccessLinkName.BC_CANCER_SCREENING,
202-
tilePayload = "CancerScreening",
203-
showAsQuickAccess = false
204-
)
205-
206-
)
207-
}
208-
20959
enum class UpdateType {
21060
FORCE_UPDATE, CHECK_SOFT_UPDATE
21161
}

‎app/src/main/java/ca/bc/gov/bchealth/ui/onboarding/OnBoardingSliderViewModel.kt

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel
44
import androidx.lifecycle.viewModelScope
55
import ca.bc.gov.common.BuildConfig
66
import ca.bc.gov.repository.OnBoardingRepository
7+
import ca.bc.gov.repository.settings.AppFeatureRepository
78
import dagger.hilt.android.lifecycle.HiltViewModel
89
import kotlinx.coroutines.Dispatchers
910
import kotlinx.coroutines.launch
@@ -15,11 +16,19 @@ import javax.inject.Inject
1516
*/
1617
@HiltViewModel
1718
class OnBoardingSliderViewModel @Inject constructor(
18-
private val onBoardingRepository: OnBoardingRepository
19+
private val onBoardingRepository: OnBoardingRepository,
20+
private val appFeatureRepository: AppFeatureRepository,
1921
) : ViewModel() {
2022

2123
val isReOnBoardingRequired = onBoardingRepository.isReOnBoardingRequired
2224

25+
init {
26+
viewModelScope.launch {
27+
appFeatureRepository.initializeAppData()
28+
appFeatureRepository.addBCCancerQuickLink()
29+
}
30+
}
31+
2332
fun setOnBoardingRequired(isRequired: Boolean) = viewModelScope.launch {
2433
withContext(Dispatchers.IO) {
2534
onBoardingRepository.onBoardingRequired = isRequired

‎app/src/main/res/navigation/dependents.xml

+12
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,16 @@
212212
app:nullable="true" />
213213
</fragment>
214214

215+
<fragment
216+
android:id="@+id/commentsFragment"
217+
android:name="ca.bc.gov.bchealth.ui.comment.CommentsFragment"
218+
android:label="fragment_comments"
219+
tools:layout="@layout/fragment_comments">
220+
<argument
221+
android:name="recordType"
222+
app:argType="string" />
223+
<argument
224+
android:name="parentEntryId"
225+
app:argType="string" />
226+
</fragment>
215227
</navigation>

‎app/src/main/res/navigation/health_pass.xml

+20-1
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,29 @@
5757
<action
5858
android:id="@+id/action_addCardOptionFragment_to_onBoardingFragment"
5959
app:destination="@id/onBoardingFragment" />
60-
60+
<action
61+
android:id="@+id/action_addCardOptionFragment_to_fetchVaccineRecord"
62+
app:destination="@id/fetchVaccineRecordFragment" />
6163
</fragment>
6264

65+
<fragment
66+
android:id="@+id/fetchVaccineRecordFragment"
67+
android:name="ca.bc.gov.bchealth.ui.healthpass.add.FetchVaccineRecordFragment"
68+
tools:layout="@layout/fragment_fetch_vaccine_record">
69+
<action
70+
android:id="@+id/action_fetchVaccineRecordFragment_to_vaccineRecordDetailFragment"
71+
app:destination="@id/vaccineRecordDetailFragment" />
72+
</fragment>
6373

74+
<fragment
75+
android:id="@+id/vaccineRecordDetailFragment"
76+
android:name="ca.bc.gov.bchealth.ui.healthrecord.vaccine.VaccineRecordDetailFragment"
77+
android:label="fragment_vaccine_record_detail"
78+
tools:layout="@layout/fragment_vaccine_record_detail">
79+
<argument
80+
android:name="patientId"
81+
app:argType="long" />
82+
</fragment>
6483
<dialog
6584
android:id="@+id/expandQRFragment"
6685
android:name="ca.bc.gov.bchealth.ui.healthpass.ExpandQRFragment"

‎app/src/main/res/navigation/health_records.xml

+1-21
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
android:id="@+id/healthRecordFragment"
99
android:name="ca.bc.gov.bchealth.ui.healthrecord.HealthRecordFragment"
1010
android:label="HealthRecordFragment" >
11-
<action
12-
android:id="@+id/action_healthRecordFragment_to_vaccineRecordDetailFragment"
13-
app:destination="@id/vaccineRecordDetailFragment" />
11+
1412
<action
1513
android:id="@+id/action_healthRecordFragment_to_medicationDetailFragment"
1614
app:destination="@id/medicationDetailsFragment" />
@@ -53,24 +51,6 @@
5351
android:label="AddHealthRecordsFragment"
5452
tools:layout="@layout/scene_health_records_add" />
5553

56-
<fragment
57-
android:id="@+id/fetchVaccineRecordFragment"
58-
android:name="ca.bc.gov.bchealth.ui.healthpass.add.FetchVaccineRecordFragment"
59-
tools:layout="@layout/fragment_fetch_vaccine_record">
60-
<action
61-
android:id="@+id/action_fetchVaccineRecordFragment_to_vaccineRecordDetailFragment"
62-
app:destination="@id/vaccineRecordDetailFragment" />
63-
</fragment>
64-
65-
<fragment
66-
android:id="@+id/vaccineRecordDetailFragment"
67-
android:name="ca.bc.gov.bchealth.ui.healthrecord.vaccine.VaccineRecordDetailFragment"
68-
android:label="fragment_vaccine_record_detail"
69-
tools:layout="@layout/fragment_vaccine_record_detail">
70-
<argument
71-
android:name="patientId"
72-
app:argType="long" />
73-
</fragment>
7454
<fragment
7555
android:id="@+id/medicationDetailsFragment"
7656
android:name="ca.bc.gov.bchealth.ui.healthrecord.medication.MedicationDetailsFragment"

‎app/src/main/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@
429429

430430
<!-- Error -->
431431
<string name="bcsc_auth_error_title">Problem with log in</string>
432-
<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>
432+
<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>
433433
<string name="bcsc_auth_error_click_email">healthgateway@gov.bc.ca</string>
434434
<string name="bcsc_auth_error_button">Email us</string>
435435

‎repository/src/main/java/ca/bc/gov/repository/di/RepositoriesModule.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,9 @@ class RepositoriesModule {
360360
@Provides
361361
@Singleton
362362
fun provideAppFeatureRepository(
363-
appFeatureLocalDataSource: AppFeatureLocalDataSource
364-
): AppFeatureRepository = AppFeatureRepository(appFeatureLocalDataSource)
363+
appFeatureLocalDataSource: AppFeatureLocalDataSource,
364+
quickAccessTileRepository: QuickAccessTileRepository
365+
): AppFeatureRepository = AppFeatureRepository(appFeatureLocalDataSource, quickAccessTileRepository)
365366

366367
@Provides
367368
@Singleton

0 commit comments

Comments
 (0)
Failed to load comments.