Skip to content

Commit

Permalink
Updated logic to display disease text (#86)
Browse files Browse the repository at this point in the history
* Updated logic to display disease text

* Updated version

* Added type of test conversion
  • Loading branch information
oleksandrsarapulovgl authored Jul 21, 2021
1 parent add62cb commit 7f7c116
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 15 deletions.
10 changes: 10 additions & 0 deletions .idea/sonarIssues.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import dgca.wallet.app.android.parseFromTo
class RecoveryViewHolder(private val binding: ItemRecoveryBinding) : RecyclerView.ViewHolder(binding.root) {

fun bind(data: RecoveryModel) {
binding.diseaseValue.text = data.disease
binding.diseaseValue.text = data.disease.value
binding.validFromValue.text = data.certificateValidFrom.parseFromTo(YEAR_MONTH_DAY, FORMATTED_YEAR_MONTH_DAY)
binding.validUntilValue.text = data.certificateValidUntil.parseFromTo(YEAR_MONTH_DAY, FORMATTED_YEAR_MONTH_DAY)
binding.dateOfPositiveValue.text = data.dateOfFirstPositiveTest.parseFromTo(YEAR_MONTH_DAY, FORMATTED_YEAR_MONTH_DAY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class TestViewHolder(private val binding: ItemTestBinding) : RecyclerView.ViewHo
binding.dateOfTestResultValue.visibility = this
}

binding.diseaseValue.text = data.disease
binding.typeOfTestValue.text = data.typeOfTest
binding.diseaseValue.text = data.disease.value
binding.typeOfTestValue.text = data.typeOfTest.value
binding.countryValue.text = data.countryOfVaccination
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class VaccinationViewHolder(private val binding: ItemVaccinationBinding) : Recyc

fun bind(data: VaccinationModel) {
binding.dateValue.text = data.dateOfVaccination.parseFromTo(YEAR_MONTH_DAY, FORMATTED_YEAR_MONTH_DAY)
binding.diseaseValue.text = data.disease
binding.diseaseValue.text = data.disease.value
binding.doseTotalNumberValue.text = data.totalSeriesOfDoses.toString()
binding.doseSequenceValue.text = data.doseNumber.toString()
binding.countryValue.text = data.countryOfVaccination
Expand Down
21 changes: 16 additions & 5 deletions app/src/main/java/dgca/wallet/app/android/data/CertificateModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ data class PersonModel(
)

data class VaccinationModel(
override val disease: String,
override val disease: DiseaseType,
val vaccine: String,
val medicinalProduct: String,
val manufacturer: String,
Expand All @@ -74,8 +74,8 @@ data class VaccinationModel(
) : CertificateData

data class TestModel(
override val disease: String,
val typeOfTest: String,
override val disease: DiseaseType,
val typeOfTest: TypeOfTest,
val testName: String?,
val testNameAndManufacturer: String?,
val dateTimeOfCollection: String,
Expand All @@ -93,8 +93,19 @@ enum class TestResult(val value: String) {
NOT_DETECTED("NOT DETECTED")
}

enum class DiseaseType(val value: String) {
COVID_19("COVID-19"),
UNDEFINED("UNDEFINED")
}

enum class TypeOfTest(val value: String) {
NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION("Nucleic acid amplification with probe detection"),
RAPID_IMMUNOASSAY("Rapid immunoassay"),
UNDEFINED("")
}

data class RecoveryModel(
override val disease: String,
override val disease: DiseaseType,
val dateOfFirstPositiveTest: String,
val countryOfVaccination: String,
val certificateIssuer: String,
Expand All @@ -104,7 +115,7 @@ data class RecoveryModel(
) : CertificateData

interface CertificateData {
val disease: String
val disease: DiseaseType
}

fun CertificateModel.getCertificateListData(): List<CertificateData> {
Expand Down
41 changes: 37 additions & 4 deletions app/src/main/java/dgca/wallet/app/android/data/local/Mapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun GreenCertificate.toCertificateModel(): CertificateModel {

fun RecoveryStatement.toRecoveryModel(): RecoveryModel {
return RecoveryModel(
disease,
disease.toDiseaseCode().toDiseaseType(),
dateOfFirstPositiveTest,
countryOfVaccination,
certificateIssuer,
Expand All @@ -49,8 +49,8 @@ fun RecoveryStatement.toRecoveryModel(): RecoveryModel {

fun Test.toTestModel(): TestModel {
return TestModel(
disease,
typeOfTest,
disease.toDiseaseCode().toDiseaseType(),
typeOfTest.toTypeOfTestCode().toTypeOfTest(),
testName,
testNameAndManufacturer,
dateTimeOfCollection,
Expand All @@ -71,9 +71,20 @@ fun Test.TestResult.toTestResult(): TestResult {
}
}

fun DiseaseCode.toDiseaseType(): DiseaseType = when (this) {
DiseaseCode.COVID_19 -> DiseaseType.COVID_19
else -> DiseaseType.UNDEFINED
}

fun TypeOfTestCode.toTypeOfTest(): TypeOfTest = when (this) {
TypeOfTestCode.NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION -> TypeOfTest.NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION
TypeOfTestCode.RAPID_IMMUNOASSAY -> TypeOfTest.RAPID_IMMUNOASSAY
else -> TypeOfTest.UNDEFINED
}

fun Vaccination.toVaccinationModel(): VaccinationModel {
return VaccinationModel(
disease,
disease.toDiseaseCode().toDiseaseType(),
vaccine,
medicinalProduct,
manufacturer,
Expand All @@ -93,4 +104,26 @@ fun Person.toPersonModel(): PersonModel {
standardisedGivenName,
givenName
)
}

fun String.toDiseaseCode(): DiseaseCode = when (this) {
DiseaseCode.COVID_19.value -> DiseaseCode.COVID_19
else -> DiseaseCode.UNDEFINED
}

fun String.toTypeOfTestCode(): TypeOfTestCode = when (this) {
TypeOfTestCode.NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION.value -> TypeOfTestCode.NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION
TypeOfTestCode.RAPID_IMMUNOASSAY.value -> TypeOfTestCode.RAPID_IMMUNOASSAY
else -> TypeOfTestCode.UNDEFINED
}

enum class DiseaseCode(val value: String) {
COVID_19("840539006"),
UNDEFINED("")
}

enum class TypeOfTestCode(val value: String) {
NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION("LP6464-4"),
RAPID_IMMUNOASSAY("LP217198-3"),
UNDEFINED("")
}
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/AppConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ object Config {
const val targetSdk = 29
val javaVersion = JavaVersion.VERSION_1_8

const val versionCode = 10
const val versionName = "1.1.1"
const val versionCode = 11
const val versionName = "1.1.2"

const val androidTestInstrumentation = "androidx.test.runner.AndroidJUnitRunner"
const val proguardConsumerRules = "consumer-rules.pro"
Expand Down

0 comments on commit 7f7c116

Please sign in to comment.