ministero-salute / it-dgc-verificac19-sdk-android

Digital Covid Certificate SDK
Apache License 2.0
57 stars 30 forks source link

Wrong BOOSTER lasting selection boolean expression #121

Closed fricoepolenta closed 2 years ago

fricoepolenta commented 2 years ago

The boolean expression in checkVaccinations in verificaC19sdk/model/VerificationViewModel.kt to select startDaysToAdd and endDaysToAdd for booster and second dose doesn't cover all possible cases. People vaxinated after recovery, and getting their booster injection may have 2/1, which actually the boolean expression at 590 (it.last().doseNumber == it.last().totalSeriesOfDoses && it.last().doseNumber < 3) covers, while (it.last().medicinalProduct != MedicinalProduct.JOHNSON && it.last().doseNumber >= 3) at 567 doesn't cover. So, as long as booster and 2nd dose last the same period, will be fine. Since today italian council will meet to decide about whether making booster dose lasting longer, will be a good idea to fix this issue, to avoid further problem in recognition of some booster doses.

As further proof, !(it.last().doseNumber == it.last().totalSeriesOfDoses && it.last().doseNumber < 3) can be expressed as: it.last().doseNumber != it.last().totalSeriesOfDoses || it.last().doseNumber >= 3. As you can see, the boolean expression at 567 lacks of it.last().doseNumber > it.last().totalSeriesOfDoses, making the two logic expression giving different results for booster cases: 3/3 and 2/1 (both doses not with johson, of course)

rawmain commented 2 years ago

Hello @fricoepolenta

The boolean expression in checkVaccinations in verificaC19sdk/model/VerificationViewModel.kt to select startDaysToAdd and endDaysToAdd for booster and second dose doesn't cover all possible cases. [...]

Such dn>sd alternative condition for booster start/end check has already been added 3 days ago into feature/school-scan-mode-sdk branch = commit 3a2ac53 .

Once merged, you'll find it also in develop & upcoming release branches' code.

fricoepolenta commented 2 years ago

school-scan-mode-sdk merged to main branch. Issue fixed