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-1855 #580

Merged
merged 1 commit into from
Feb 28, 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 @@ -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,9 +32,11 @@ 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
import ca.bc.gov.common.utils.toPST
import java.time.Instant
import java.time.LocalDate

Expand Down Expand Up @@ -101,7 +103,7 @@ fun ClinicalDocumentDto.toUiModel() =
fun LabOrderWithLabTestDto.toUiModel(): HealthRecordItem {
var description = ""
description = mapOrderStatus(labOrder.orderStatus ?: "").plus(" • ")
.plus(labOrder.timelineDateTime.toDate())
.plus(labOrder.timelineDateTime.dateString())
return HealthRecordItem(
patientId = labOrder.patientId,
title = labOrder.commonName ?: "",
Expand Down Expand Up @@ -168,9 +170,9 @@ fun CovidOrderWithCovidTestDto.toUiModel(): HealthRecordItem {
patientId = covidOrder.patientId,
recordId = covidOrder.id,
title = "COVID-19 test result",
description = "$testOutcome • ${date.toDate()}",
description = "$testOutcome • ${date.dateString()}",
icon = R.drawable.ic_health_record_covid_test,
date = date,
date = date.toPST(),
healthRecordType = HealthRecordType.COVID_TEST_RECORD,
dataSource = covidOrder.dataSource.name
)
Expand All @@ -182,7 +184,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 +209,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 +230,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 +241,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 +263,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 +290,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 +307,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 +322,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 @@ -11,7 +11,7 @@ import ca.bc.gov.common.exceptions.ServiceDownException
import ca.bc.gov.common.model.AuthenticationStatus
import ca.bc.gov.common.model.ProtectiveWordState
import ca.bc.gov.common.model.relation.PatientWithMedicationRecordDto
import ca.bc.gov.common.utils.toDate
import ca.bc.gov.common.utils.dateToInstant
import ca.bc.gov.common.utils.toStartOfDayInstant
import ca.bc.gov.repository.CacheRepository
import ca.bc.gov.repository.MedicationRecordRepository
Expand Down Expand Up @@ -128,13 +128,13 @@ class HealthRecordViewModel @Inject constructor(

private fun getFilterByDate(healthRecords: List<HealthRecordItem>, fromDate: String?, toDate: String?): MutableList<HealthRecordItem> {
return if (!fromDate.isNullOrBlank() && !toDate.isNullOrBlank()) {
healthRecords.filter { it.date.toStartOfDayInstant() >= fromDate.toDate() && it.date <= toDate.toDate() }
healthRecords.filter { it.date.toStartOfDayInstant() >= fromDate.dateToInstant().toStartOfDayInstant() && it.date.toStartOfDayInstant() <= toDate.dateToInstant().toStartOfDayInstant() }
.toMutableList()
} else if (!fromDate.isNullOrBlank()) {
healthRecords.filter { it.date.toStartOfDayInstant() >= fromDate.toDate() }
healthRecords.filter { it.date.toStartOfDayInstant() >= fromDate.dateToInstant().toStartOfDayInstant() }
.toMutableList()
} else if (!toDate.isNullOrBlank()) {
healthRecords.filter { it.date.toStartOfDayInstant() <= toDate.toDate() }.toMutableList()
healthRecords.filter { it.date.toStartOfDayInstant() <= toDate.dateToInstant().toStartOfDayInstant() }.toMutableList()
} else {
healthRecords.toMutableList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import ca.bc.gov.bchealth.widget.AddCommentLayout
import ca.bc.gov.common.model.patient.PatientDto
import ca.bc.gov.common.model.test.CovidOrderDto
import ca.bc.gov.common.model.test.CovidTestDto
import ca.bc.gov.common.utils.toDateTimeString
import ca.bc.gov.common.utils.dateTimeString
import dagger.hilt.android.AndroidEntryPoint

private const val COVID_ORDER_ID = "COVID_ORDER_ID"
Expand Down Expand Up @@ -99,10 +99,10 @@ class CovidTestResultFragment(private val itemClickListener: ItemClickListener)
getString(R.string.tested_on)
.plus(" ")
.plus(
covidTest?.collectedDateTime?.toDateTimeString()
covidTest?.collectedDateTime?.dateTimeString()
)
tvDot.text =
covidTest?.collectedDateTime?.toDateTimeString().showIfNullOrBlank(requireContext())
covidTest?.collectedDateTime?.dateTimeString().showIfNullOrBlank(requireContext())
tvTestStatus.text = covidTest?.testStatus.showIfNullOrBlank(requireContext())
tvTypeName.text = covidTest?.testType.showIfNullOrBlank(requireContext())
tvProviderClinic.text = covidOrder.reportingLab.showIfNullOrBlank(requireContext())
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const val eee_dd_mmm_yyyy_hh_mm_ss_z = "EEE, dd MMM yyyy HH:mm:ss XXXX"
private const val full_date_time_plus_time = "yyyy-MM-dd'T'HH:mm:ssXXX"
private const val yyyy_MMM_dd_HH_mm_sss_long = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
private const val yyyy_MMM_dd_HH_mm_short = "yyyy-MM-dd'T'HH:mm:ss'Z'"
private const val PST_ZONE_ID = "America/Los_Angeles"

fun Instant.toDateTimeString(dateFormat: String = yyyy_MMM_dd_HH_mm): String {
val dateTime = LocalDateTime.ofInstant(this, ZoneOffset.UTC)
Expand Down Expand Up @@ -93,9 +94,24 @@ fun Instant.toStartOfDayInstant(): Instant {
* provides the date time in UTC+00:00
* */
fun Instant.toLocalDateTimeInstant(): Instant? {
return this.atZone(ZoneId.of("America/Los_Angeles"))
return this.atZone(ZoneId.of(PST_ZONE_ID))
?.toLocalDateTime()?.toInstant(ZoneOffset.UTC)
}

fun Instant.toPST(): Instant {
return this.atZone(ZoneId.of(PST_ZONE_ID))
.toLocalDateTime().toInstant(ZoneOffset.UTC)
}

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

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

fun String.dateToInstant(): Instant = LocalDate.parse(this).atStartOfDay(ZoneId.of(PST_ZONE_ID)).toInstant()

fun Instant.dateTimeString(pattern: String = yyyy_MMM_dd_HH_mm): String {
return atZone(ZoneId.of(PST_ZONE_ID)).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
Loading