Skip to content

Commit

Permalink
HAPP-1855
Browse files Browse the repository at this point in the history
- fixed API date format changes
- updated api version to 3
- updated app version to 2.1.0
  • Loading branch information
PINAKIN-KANSARA-EY committed Feb 14, 2024
1 parent 7028302 commit 1e23d4d
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,7 @@ fun HGTextButton(
modifier,
enabled,
defaultHeight,
contentPadding = if (leadingIcon != null) {
ButtonDefaults.TextButtonContentPadding
} else {
ButtonDefaults.TextButtonContentPadding
}
contentPadding = ButtonDefaults.TextButtonContentPadding
) {
HGButtonContent(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import ca.bc.gov.common.model.services.BcCancerScreeningDataDto
import ca.bc.gov.common.model.services.DiagnosticImagingDataDto
import ca.bc.gov.common.model.specialauthority.SpecialAuthorityDto
import ca.bc.gov.common.model.test.CovidOrderWithCovidTestDto
import ca.bc.gov.common.utils.dateString
import ca.bc.gov.common.utils.toDate
import ca.bc.gov.common.utils.toDateTimeString
import ca.bc.gov.common.utils.toLocalDateTimeInstant
Expand Down Expand Up @@ -182,7 +183,7 @@ fun ImmunizationRecordWithForecastDto.toUiModel(): HealthRecordItem {
patientId = immunizationRecord.patientId,
recordId = immunizationRecord.id,
title = immunizationRecord.immunizationName ?: "",
description = immunizationRecord.dateOfImmunization.toDate(),
description = immunizationRecord.dateOfImmunization.dateString(),
icon = R.drawable.ic_health_record_vaccine,
date = immunizationRecord.dateOfImmunization,
healthRecordType = HealthRecordType.IMMUNIZATION_RECORD,
Expand All @@ -207,12 +208,12 @@ fun ImmunizationRecordWithForecastAndPatientDto.toUiModel(): ImmunizationRecordD
return ImmunizationRecordDetailItem(
id = immunizationRecordWithForecast.immunizationRecord.id,
status = immunizationRecordWithForecast.immunizationRecord.status,
dueDate = immunizationRecordWithForecast.immunizationForecast?.dueDate?.toDate(),
dueDate = immunizationRecordWithForecast.immunizationForecast?.dueDate?.dateString(),
name = immunizationRecordWithForecast.immunizationRecord.immunizationName,
doseDetails = listOf(
ImmunizationDoseDetailItem(
id = immunizationRecordWithForecast.immunizationRecord.id,
date = immunizationRecordWithForecast.immunizationRecord.dateOfImmunization.toDate(),
date = immunizationRecordWithForecast.immunizationRecord.dateOfImmunization.dateString(),
productName = immunizationRecordWithForecast.immunizationRecord.productName,
immunizingAgent = immunizationRecordWithForecast.immunizationRecord.agentName,
providerOrClinicName = immunizationRecordWithForecast.immunizationRecord.provideOrClinic,
Expand All @@ -228,7 +229,7 @@ fun HealthVisitsDto.toUiModel() =
patientId = patientId,
recordId = healthVisitId,
title = specialtyDescription.orEmpty(),
description = practitionerName.orEmpty() + "" + encounterDate.toDate(),
description = practitionerName.orEmpty() + "" + encounterDate.dateString(),
icon = R.drawable.ic_health_record_health_visit,
date = encounterDate,
healthRecordType = HealthRecordType.HEALTH_VISIT_RECORD,
Expand All @@ -239,7 +240,7 @@ fun SpecialAuthorityDto.toUiModel() = HealthRecordItem(
patientId = patientId,
recordId = specialAuthorityId,
title = drugName.orEmpty(),
description = requestStatus.orEmpty() + "" + requestedDate?.toDate(),
description = requestStatus.orEmpty() + "" + requestedDate?.dateString(),
icon = R.drawable.ic_health_record_special_authority,
date = requestedDate!!,
healthRecordType = HealthRecordType.SPECIAL_AUTHORITY_RECORD,
Expand All @@ -261,7 +262,7 @@ fun HospitalVisitDto.toUiModel() =
fun ImmunizationRecommendationsDto.toUiModel() = RecommendationDetailItem(
title = this.recommendedVaccinations.orPlaceholder(),
status = this.status,
date = this.agentDueDate?.toDate().orPlaceholder(),
date = this.agentDueDate?.dateString().orPlaceholder(),
)

fun DependentDto.toUiModel(currentDate: LocalDate) = DependentDetailItem(
Expand All @@ -288,7 +289,7 @@ fun CommentDto.toUiModel() = Comment(
private fun ImmunizationForecastDto.toUiModel() = ForecastDetailItem(
name = this.displayName.orPlaceholder(),
status = this.status,
date = this.dueDate.toDate(),
date = this.dueDate.dateString(),
)

enum class CovidTestResultStatus {
Expand All @@ -305,7 +306,7 @@ private fun DiagnosticImagingDataDto.toUiModel() = HealthRecordItem(
patientId = patientId,
icon = R.drawable.ic_health_record_diagnostic_imaging,
title = modality.orEmpty(),
description = if (isUpdated) { "Updated" } else { examStatus } + "" + examDate?.toDate(),
description = if (isUpdated) { "Updated" } else { examStatus } + "" + examDate?.dateString(),
date = examDate!!,
healthRecordType = HealthRecordType.DIAGNOSTIC_IMAGING,
dataSource = null
Expand All @@ -320,7 +321,7 @@ fun BcCancerScreeningDataDto.toUiModel() = HealthRecordItem(
patientId = patientId,
icon = R.drawable.ic_health_record_bc_cancer_screening,
title = if (eventType == "Recall") { "BC Cancer Screening Reminder Letter" } else { "BC Cancer Screening Result Letter" },
description = programName + "" + if (eventType == "Recall") { eventDateTime } else { resultDateTime }?.toDate(),
description = programName + "" + if (eventType == "Recall") { eventDateTime } else { resultDateTime }?.dateString(),
date = if (eventType == "Recall") { eventDateTime !! } else { resultDateTime!! },
healthRecordType = HealthRecordType.BC_CANCER_SCREENING,
dataSource = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import ca.bc.gov.bchealth.R
import ca.bc.gov.common.model.dependents.DependentDto
import ca.bc.gov.common.utils.toDate
import ca.bc.gov.common.utils.dateString
import ca.bc.gov.repository.DependentsRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -43,7 +43,7 @@ class DependentProfileViewModel @Inject constructor(
),
DependentProfileItem(
label = R.string.dependents_profile_dob,
value = dependentDto.dateOfBirth.toDate()
value = dependentDto.dateOfBirth.dateString()
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.lifecycle.viewModelScope
import ca.bc.gov.bchealth.R
import ca.bc.gov.bchealth.ui.healthrecord.HealthRecordDetailItem
import ca.bc.gov.common.model.hospitalvisits.HospitalVisitDto
import ca.bc.gov.common.utils.toDateTimeString
import ca.bc.gov.common.utils.dateTimeString
import ca.bc.gov.repository.hospitalvisit.HospitalVisitRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -26,7 +26,7 @@ class HospitalVisitDetailViewModel @Inject constructor(
try {
val dto: HospitalVisitDto = repository.getHospitalVisit(hospitalVisitId)

val dischargeDate = dto.dischargeDate?.toDateTimeString().orEmpty()
val dischargeDate = dto.dischargeDate?.dateTimeString().orEmpty()

val uiList: List<HealthRecordDetailItem> = listOf(
HealthRecordDetailItem(
Expand Down Expand Up @@ -55,7 +55,7 @@ class HospitalVisitDetailViewModel @Inject constructor(

HealthRecordDetailItem(
title = R.string.hospital_visits_detail_visit_date_title,
description = dto.visitDate.toDateTimeString()
description = dto.visitDate.dateTimeString()
),

HealthRecordDetailItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import ca.bc.gov.common.exceptions.NetworkConnectionException
import ca.bc.gov.common.exceptions.ServiceDownException
import ca.bc.gov.common.model.labtest.LabOrderWithLabTestDto
import ca.bc.gov.common.model.labtest.LabOrderWithLabTestsAndPatientDto
import ca.bc.gov.common.utils.toDate
import ca.bc.gov.common.utils.toDateTimeString
import ca.bc.gov.common.utils.dateString
import ca.bc.gov.common.utils.dateTimeString
import ca.bc.gov.repository.labtest.LabOrderRepository
import ca.bc.gov.repository.worker.MobileConfigRepository
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down Expand Up @@ -71,8 +71,8 @@ class LabTestDetailViewModel @Inject constructor(
labTestDetails.add(
LabTestDetail(
title1 = R.string.collection_date,
collectionDateTime = labOrderWithLabTestDto.labOrder.collectionDateTime?.toDate(),
timelineDateTime = labOrderWithLabTestDto.labOrder.timelineDateTime.toDateTimeString(),
collectionDateTime = labOrderWithLabTestDto.labOrder.collectionDateTime?.dateString(),
timelineDateTime = labOrderWithLabTestDto.labOrder.timelineDateTime.dateTimeString(),
title2 = R.string.ordering_provider,
orderingProvider = labOrderWithLabTestDto.labOrder.orderingProvider,
title3 = R.string.reporting_lab,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ca.bc.gov.bchealth.ui.healthrecord.specialauthority
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import ca.bc.gov.bchealth.R
import ca.bc.gov.common.utils.toDate
import ca.bc.gov.common.utils.dateString
import ca.bc.gov.repository.specialauthority.SpecialAuthorityRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -50,13 +50,13 @@ class SpecialAuthorityDetailViewModel @Inject constructor(
specialAuthorityDetailItems.add(
SpecialAuthorityDetailItem(
R.string.effective_date,
specialAuthorityDto?.effectiveDate?.toDate() ?: "--"
specialAuthorityDto?.effectiveDate?.dateString() ?: "--"
)
)
specialAuthorityDetailItems.add(
SpecialAuthorityDetailItem(
R.string.expiry_date,
specialAuthorityDto?.expiryDate?.toDate() ?: "--"
specialAuthorityDto?.expiryDate?.dateString() ?: "--"
)
)
specialAuthorityDetailItems.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import ca.bc.gov.bchealth.viewmodel.RecentPhnDobViewModel
import ca.bc.gov.common.model.analytics.AnalyticsAction
import ca.bc.gov.common.model.analytics.AnalyticsActionData
import ca.bc.gov.common.model.relation.PatientWithVaccineAndDosesDto
import ca.bc.gov.common.utils.toDate
import ca.bc.gov.common.utils.dateString
import ca.bc.gov.common.utils.yyyy_MM_dd
import ca.bc.gov.repository.model.PatientVaccineRecord
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -168,8 +168,8 @@ class FetchFederalTravelPassFragment : BaseFragment(R.layout.fragment_fetch_trav
patientDataDto.vaccineWithDoses?.doses?.let { doses ->
viewModel.fetchVaccineRecord(
phn,
patientDataDto.patient.dateOfBirth.toDate(yyyy_MM_dd),
doses.last().date.toDate(yyyy_MM_dd)
patientDataDto.patient.dateOfBirth.dateString(yyyy_MM_dd),
doses.last().date.dateString(yyyy_MM_dd)
)
}
}
Expand Down
18 changes: 18 additions & 0 deletions common/src/main/java/ca/bc/gov/common/utils/DateTimeExtentions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,21 @@ fun Instant.toLocalDateTimeInstant(): Instant? {

fun Instant.toLocalDate(): LocalDate =
this.atZone(ZoneOffset.UTC).toLocalDate()

fun String.toInstant(): Instant {
return try {
Instant.parse(this)
} catch (e: Exception) {
LocalDate.parse(this).atStartOfDay(ZoneId.of("America/Los_Angeles")).toInstant()
}
}

fun String.dateTimeToInstant(): Instant = Instant.parse(this)

fun String.dateToInstant(): Instant = LocalDate.parse(this).atStartOfDay(ZoneId.of("America/Los_Angeles")).toInstant()

fun Instant.dateTimeString(pattern: String = yyyy_MMM_dd_HH_mm): String {
return atZone(ZoneId.of("America/Los_Angeles")).format(DateTimeFormatter.ofPattern(pattern))
}

fun Instant.dateString(pattern: String = yyyy_MMM_dd) = dateTimeString(pattern = pattern)
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ internal class DependentDtoTest {
ownerId = "",
delegateId = "",
reasonCode = 0L,
totalDelegateCount = 0,
version = 0L,
patientId = 0,
isCacheValid = false
)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package ca.bc.gov.data.datasource.remote.model.base

import com.google.gson.annotations.SerializedName

/**
* @author Pinakin Kansara
*/
data class TermsOfServicePayload(
val id: String? = null,
val content: String? = null,
@SerializedName("effectiveDateTime")
val effectiveDate: String? = null
)
Loading

0 comments on commit 1e23d4d

Please sign in to comment.