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

Bugfix/failed to retrieve record when no vaccine record #527

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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 @@ -19,6 +19,6 @@ data class VaccineResourcePayload(
val vaccineDate: String?,
val doses: Int,
val state: Int,
val qrCode: Media,
val federalVaccineProof: Media
val qrCode: Media?,
val federalVaccineProof: Media?
)
4 changes: 2 additions & 2 deletions data/src/main/java/ca/bc/gov/data/model/VaccineStatus.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ package ca.bc.gov.data.model
*/
data class VaccineStatus(
val phn: String? = null,
val qrCode: MediaMetaData,
val federalVaccineProof: MediaMetaData
val qrCode: MediaMetaData?,
val federalVaccineProof: MediaMetaData?
)
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ fun Media.toMediaMetaData(): MediaMetaData = MediaMetaData(

fun VaccineResourcePayload.toVaccineStatus(): VaccineStatus = VaccineStatus(
phn = phn,
qrCode = qrCode.toMediaMetaData(),
federalVaccineProof = federalVaccineProof.toMediaMetaData()
qrCode = qrCode?.toMediaMetaData(),
federalVaccineProof = federalVaccineProof?.toMediaMetaData()
)

fun LabTestResponse.toDto(): List<LabOrderWithLabTestDto> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ class FetchVaccineRecordRepository @Inject constructor(
}

private suspend fun processResponse(vaccineStatus: VaccineStatus): Pair<VaccineRecordState, PatientVaccineRecord?> {
val image = base64ToInputImageConverter.convert(vaccineStatus.qrCode.data)
if (vaccineStatus.qrCode?.data.isNullOrEmpty()) {
return Pair(VaccineRecordState.INVALID, null)
}
val image = base64ToInputImageConverter.convert(vaccineStatus.qrCode?.data!!)
val patientVaccineRecord = processQrRepository.processQrCode(image)
val (status, record) = patientVaccineRecord
record?.vaccineRecordDto?.federalPass = vaccineStatus.federalVaccineProof.data
record?.vaccineRecordDto?.federalPass = vaccineStatus.federalVaccineProof?.data
record?.patientDto?.phn = vaccineStatus.phn
return Pair(status, record)
}
Expand Down