Search in sources :

Example 1 with ImmunizationStatus

use of de.symeda.sormas.api.immunization.ImmunizationStatus in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationEditFragment method updateImmunizationStatus.

private void updateImmunizationStatus(FragmentImmunizationEditLayoutBinding contentBinding) {
    if (Boolean.TRUE.equals(contentBinding.overwriteImmunizationManagementStatusCheckBox.getValue())) {
        return;
    }
    MeansOfImmunization meansOfImmunizationValue = (MeansOfImmunization) contentBinding.immunizationMeansOfImmunization.getValue();
    if (meansOfImmunizationValue == MeansOfImmunization.OTHER || meansOfImmunizationValue == MeansOfImmunization.RECOVERY) {
        contentBinding.immunizationImmunizationManagementStatus.setValue(ImmunizationManagementStatus.COMPLETED);
        contentBinding.overwriteImmunizationManagementStatusCheckBox.setValue(false);
        contentBinding.immunizationImmunizationManagementStatus.setEnabled(false);
    }
    if (MeansOfImmunization.isVaccination(meansOfImmunizationValue)) {
        ImmunizationStatus immunizationStatus = (ImmunizationStatus) contentBinding.immunizationImmunizationStatus.getValue();
        if (immunizationStatus != ImmunizationStatus.NOT_ACQUIRED && immunizationStatus != ImmunizationStatus.EXPIRED) {
            Integer numberOfDoses = null;
            try {
                numberOfDoses = Integer.valueOf(contentBinding.immunizationNumberOfDoses.getValue());
            } catch (Exception e) {
                numberOfDoses = null;
            }
            if (numberOfDoses != null && CollectionUtils.isNotEmpty(record.getVaccinations())) {
                if (record.getVaccinations().size() >= numberOfDoses) {
                    contentBinding.immunizationImmunizationManagementStatus.setValue(ImmunizationManagementStatus.COMPLETED);
                } else {
                    contentBinding.immunizationImmunizationManagementStatus.setValue(ImmunizationManagementStatus.ONGOING);
                }
            }
        }
    }
}
Also used : ImmunizationStatus(de.symeda.sormas.api.immunization.ImmunizationStatus) MeansOfImmunization(de.symeda.sormas.api.immunization.MeansOfImmunization)

Example 2 with ImmunizationStatus

use of de.symeda.sormas.api.immunization.ImmunizationStatus in project SORMAS-Project by hzi-braunschweig.

the class DatabaseHelper method migrateVaccinationInfo.

private void migrateVaccinationInfo() throws SQLException {
    // Retrieve all new unsynchronized cases with vaccinationStatus == VACCINATED from the database
    GenericRawResults<Object[]> caseInfoResult = getDao(Case.class).queryRaw("SELECT cases.id, person_id, disease, diseaseDetails, reportDate, reportingUser_id, responsibleRegion_id, responsibleDistrict_id, " + "responsibleCommunity_id, COALESCE(symptoms.onsetDate, cases.reportDate), firstVaccinationDate, vaccinationDate, vaccinationDoses, vaccineName, otherVaccineName, vaccine, " + "vaccineManufacturer, otherVaccineManufacturer, vaccinationInfoSource, vaccineInn, vaccineBatchNumber, vaccineUniiCode, vaccineAtcCode," + "pregnant, trimester, healthConditions_id FROM cases LEFT JOIN clinicalCourse ON cases.clinicalCourse_id = clinicalCourse.id " + "LEFT JOIN symptoms ON cases.symptoms_id = symptoms.id WHERE cases.snapshot = 0 AND cases.changeDate = 0 AND vaccination = 'VACCINATED';", new DataType[] { // 0: cases.id
    DataType.BIG_INTEGER, // 1: person_id
    DataType.BIG_INTEGER, // 2: disease
    DataType.ENUM_STRING, // 3: diseaseDetails
    DataType.STRING, // 4: reportDate
    DataType.DATE_LONG, // 5: reportingUser_id
    DataType.BIG_INTEGER, // 6: responsibleRegion_id
    DataType.BIG_INTEGER, // 7: responsibleDistrict_id
    DataType.BIG_INTEGER, // 8: responsibleCommunity_id
    DataType.BIG_INTEGER, // 9: symptoms.onsetDate OR cases.reportDate
    DataType.DATE_LONG, // 10: firstVaccinationDate
    DataType.DATE_LONG, // 11: vaccinationDate
    DataType.DATE_LONG, // 12: vaccinationDoses
    DataType.STRING, // 13: vaccineName
    DataType.ENUM_STRING, // 14: otherVaccineName
    DataType.STRING, // 15: vaccine
    DataType.STRING, // 16: vaccineManufacturer
    DataType.ENUM_STRING, // 17: otherVaccineManufacturer
    DataType.STRING, // 18: vaccinationInfoSource
    DataType.ENUM_STRING, // 19: vaccineInn
    DataType.STRING, // 20: vaccineBatchNumber
    DataType.STRING, // 21: vaccineUniiCode
    DataType.STRING, // 22: vaccineAtcCode
    DataType.STRING, // 23: pregnant
    DataType.ENUM_STRING, // 24: trimester
    DataType.ENUM_STRING, // 25: healthConditions_id
    DataType.BIG_INTEGER });
    List<Object[]> caseInfoList = caseInfoResult.getResults();
    for (Object[] caseInfo : caseInfoList) {
        doNullCheckOnString(caseInfo, 3);
        doNullCheckOnString(caseInfo, 14);
        doNullCheckOnString(caseInfo, 15);
        doNullCheckOnString(caseInfo, 17);
        doNullCheckOnString(caseInfo, 19);
        doNullCheckOnString(caseInfo, 20);
        doNullCheckOnString(caseInfo, 21);
        doNullCheckOnString(caseInfo, 22);
        formatRawResultDate(caseInfo, 4);
        formatRawResultDate(caseInfo, 9);
        formatRawResultDate(caseInfo, 10);
        formatRawResultDate(caseInfo, 11);
        if (DataHelper.isNullOrEmpty((String) caseInfo[12])) {
            Array.set(caseInfo, 12, null);
        } else {
            try {
                Array.set(caseInfo, 12, new Integer((String) caseInfo[12]));
            } catch (NumberFormatException e) {
                Array.set(caseInfo, 12, 1);
            }
        }
    }
    // Retrieve earlier cases of each person for each disease
    Comparator<Object[]> comparator = Comparator.comparing(c -> new Date((Long) c[9]));
    List<Object[]> filteredCaseInfo = new ArrayList<>();
    Map<Disease, List<Object[]>> caseInfoByDisease = caseInfoList.stream().collect(Collectors.groupingBy(c -> Disease.valueOf((String) c[2])));
    caseInfoByDisease.keySet().forEach(d -> {
        filteredCaseInfo.addAll(caseInfoByDisease.get(d).stream().sorted(comparator).collect(Collectors.collectingAndThen(Collectors.toMap(c -> ((BigInteger) c[1]), Function.identity(), (c1, c2) -> new Date((Long) c1[9]).after(new Date((Long) c2[9])) ? c1 : c2), r -> new ArrayList<>(r.values()))));
    });
    filteredCaseInfo.forEach(objects -> {
        // Retrieve all cases of the case person with the respective disease
        final Object caseId = objects[0];
        final Object personId = objects[1];
        final List<Object[]> objectList = caseInfoByDisease.get(Disease.valueOf((String) objects[2])).stream().filter(c -> ((BigInteger) c[0]).intValue() != ((BigInteger) caseId).intValue() && ((BigInteger) c[1]).intValue() == ((BigInteger) personId).intValue()).collect(Collectors.toList());
        // set earliest report date
        Comparator<Object[]> reportDateComparator = Comparator.comparing(c -> new Date((Long) c[4]));
        objectList.stream().min(reportDateComparator).ifPresent(earliestObject -> {
            objects[4] = earliestObject[4];
        });
        // set earliest first vaccination date
        if (objects[10] == null) {
            Comparator<Object[]> firstVacDateComparator = Comparator.comparing(c -> new Date((Long) c[10]));
            objectList.stream().filter(c -> c[10] != null).max(firstVacDateComparator).ifPresent(earliestObject -> {
                objects[10] = earliestObject[10];
            });
        }
        // set latest last vaccination date
        if (objects[11] == null) {
            Comparator<Object[]> lastVacDateComparator = Comparator.comparing(c -> new Date((Long) c[11]));
            objectList.stream().filter(c -> c[11] != null).min(lastVacDateComparator).ifPresent(earliestObject -> {
                objects[11] = earliestObject[11];
            });
        }
        // set latest available vaccine name
        if (objects[13] == null) {
            objectList.stream().filter(c -> c[13] != null).min(comparator).ifPresent(latestObject -> {
                objects[13] = latestObject[13];
                objects[14] = latestObject[14];
            });
        }
        // set latest available vaccine
        if (objects[15] == null) {
            objectList.stream().filter(c -> c[15] != null).min(comparator).ifPresent(latestObject -> objects[15] = latestObject[15]);
        }
        // set latest available vaccine manufacturer
        if (objects[16] == null) {
            objectList.stream().filter(c -> c[16] != null).min(comparator).ifPresent(latestObject -> {
                objects[16] = latestObject[16];
                objects[17] = latestObject[17];
            });
        }
        // set latest available vaccination info source
        if (objects[18] == null) {
            objectList.stream().filter(c -> c[18] != null).min(comparator).ifPresent(latestObject -> objects[18] = latestObject[18]);
        }
        // set latest available INN
        if (objects[19] == null) {
            objectList.stream().filter(c -> c[19] != null).min(comparator).ifPresent(latestObject -> objects[19] = latestObject[19]);
        }
        // set latest available batch number
        if (objects[20] == null) {
            objectList.stream().filter(c -> c[20] != null).min(comparator).ifPresent(latestObject -> objects[20] = latestObject[20]);
        }
        // set latest available UNII code
        if (objects[21] == null) {
            objectList.stream().filter(c -> c[21] != null).min(comparator).ifPresent(latestObject -> objects[21] = latestObject[21]);
        }
        // set latest available ATC code
        if (objects[22] == null) {
            objectList.stream().filter(c -> c[22] != null).min(comparator).ifPresent(latestObject -> objects[22] = latestObject[22]);
        }
    });
    // Create immunizations and vaccinations for each case
    for (Object[] caseInfo : filteredCaseInfo) {
        // Create immunization
        String immunizationInsertQuery = "INSERT INTO immunization " + "(" + "		uuid, changeDate, localChangeDate, creationDate, person_id," + "		disease, diseaseDetails, reportDate, reportingUser_id, immunizationStatus, meansOfImmunization, immunizationManagementStatus," + "		responsibleRegion_id, responsibleDistrict_id, responsibleCommunity_id, startDate, endDate, numberOfDoses, pseudonymized," + "		modified, snapshot" + ")" + "VALUES (?, ?, " + generateDateNowSQL() + ", " + generateDateNowSQL() + ", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
        executeRaw(Immunization.class, immunizationInsertQuery, DataHelper.createUuid(), 0, caseInfo[1], caseInfo[2], caseInfo[3], caseInfo[4], caseInfo[5], ImmunizationStatus.ACQUIRED.name(), MeansOfImmunization.VACCINATION.name(), ImmunizationManagementStatus.COMPLETED.name(), caseInfo[6], caseInfo[7], caseInfo[8], caseInfo[10], caseInfo[11], caseInfo[12], 0, 1, 0);
        if (caseInfo[12] == null) {
            // No vaccination doses specified
            if (caseInfo[10] != null || caseInfo[11] == null) {
                cloneHealthConditions(caseInfo[25]);
                insertFirstVaccination(caseInfo, caseInfo[10]);
            }
            // Last vaccination
            if (caseInfo[11] != null || ("ASTRA_ZENECA_COMIRNATY".equals(caseInfo[13]) || "ASTRA_ZENECA_MRNA_1273".equals(caseInfo[13]))) {
                cloneHealthConditions(caseInfo[25]);
                insertVaccination(caseInfo, caseInfo[11]);
            }
        } else {
            // Vaccination doses specified
            int vaccinationDoses = (int) caseInfo[12];
            if (vaccinationDoses == 1) {
                cloneHealthConditions(caseInfo[25]);
                insertFirstVaccination(caseInfo, caseInfo[11] != null ? caseInfo[11] : caseInfo[10]);
            } else {
                cloneHealthConditions(caseInfo[25]);
                insertFirstVaccination(caseInfo, caseInfo[10]);
                for (int i = 2; i <= vaccinationDoses - 1; i++) {
                    cloneHealthConditions(caseInfo[25]);
                    insertVaccination(caseInfo, null);
                }
                cloneHealthConditions(caseInfo[25]);
                insertVaccination(caseInfo, caseInfo[11]);
            }
        }
    }
}
Also used : Arrays(java.util.Arrays) AggregateReport(de.symeda.sormas.app.backend.report.AggregateReport) Vaccine(de.symeda.sormas.api.caze.Vaccine) MeansOfImmunization(de.symeda.sormas.api.immunization.MeansOfImmunization) Region(de.symeda.sormas.app.backend.region.Region) StringUtils(org.apache.commons.lang3.StringUtils) CampaignDao(de.symeda.sormas.app.backend.campaign.CampaignDao) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) VaccineManufacturer(de.symeda.sormas.api.caze.VaccineManufacturer) ClinicalCourse(de.symeda.sormas.app.backend.clinicalcourse.ClinicalCourse) RegionDao(de.symeda.sormas.app.backend.region.RegionDao) Map(java.util.Map) BigInteger(java.math.BigInteger) AnimalContactType(de.symeda.sormas.api.exposure.AnimalContactType) TreatmentDao(de.symeda.sormas.app.backend.therapy.TreatmentDao) Vaccination(de.symeda.sormas.app.backend.vaccination.Vaccination) Log(android.util.Log) LbdsSync(de.symeda.sormas.app.backend.lbds.LbdsSync) SampleDao(de.symeda.sormas.app.backend.sample.SampleDao) WeeklyReportDao(de.symeda.sormas.app.backend.report.WeeklyReportDao) Campaign(de.symeda.sormas.app.backend.campaign.Campaign) Hospitalization(de.symeda.sormas.app.backend.hospitalization.Hospitalization) PersonDao(de.symeda.sormas.app.backend.person.PersonDao) HospitalizationDao(de.symeda.sormas.app.backend.hospitalization.HospitalizationDao) ConfigDao(de.symeda.sormas.app.backend.config.ConfigDao) Dao(com.j256.ormlite.dao.Dao) DataType(com.j256.ormlite.field.DataType) AreaDao(de.symeda.sormas.app.backend.region.AreaDao) Country(de.symeda.sormas.app.backend.region.Country) Stream(java.util.stream.Stream) DiseaseClassificationCriteria(de.symeda.sormas.app.backend.classification.DiseaseClassificationCriteria) District(de.symeda.sormas.app.backend.region.District) Visit(de.symeda.sormas.app.backend.visit.Visit) HealthConditionsDao(de.symeda.sormas.app.backend.clinicalcourse.HealthConditionsDao) LbdsSyncDao(de.symeda.sormas.app.backend.lbds.LbdsSyncDao) SubcontinentDao(de.symeda.sormas.app.backend.region.SubcontinentDao) Location(de.symeda.sormas.app.backend.location.Location) TypeOfAnimal(de.symeda.sormas.api.exposure.TypeOfAnimal) SyncLogDao(de.symeda.sormas.app.backend.synclog.SyncLogDao) FeatureConfiguration(de.symeda.sormas.app.backend.feature.FeatureConfiguration) CountryDao(de.symeda.sormas.app.backend.region.CountryDao) PathogenTest(de.symeda.sormas.app.backend.sample.PathogenTest) CampaignFormMetaDao(de.symeda.sormas.app.backend.campaign.form.CampaignFormMetaDao) EpiData(de.symeda.sormas.app.backend.epidata.EpiData) ArrayList(java.util.ArrayList) WeeklyReportEntry(de.symeda.sormas.app.backend.report.WeeklyReportEntry) SQLException(java.sql.SQLException) ConnectionSource(com.j256.ormlite.support.ConnectionSource) Contact(de.symeda.sormas.app.backend.contact.Contact) Therapy(de.symeda.sormas.app.backend.therapy.Therapy) AnimalCondition(de.symeda.sormas.api.epidata.AnimalCondition) PersonContactDetailDao(de.symeda.sormas.app.backend.person.PersonContactDetailDao) Event(de.symeda.sormas.app.backend.event.Event) Symptoms(de.symeda.sormas.app.backend.symptoms.Symptoms) SormasToSormasOriginInfoDao(de.symeda.sormas.app.backend.sormastosormas.SormasToSormasOriginInfoDao) ClinicalCourseDao(de.symeda.sormas.app.backend.clinicalcourse.ClinicalCourseDao) PointOfEntryDao(de.symeda.sormas.app.backend.infrastructure.PointOfEntryDao) DataHelper(de.symeda.sormas.api.utils.DataHelper) EventParticipant(de.symeda.sormas.app.backend.event.EventParticipant) Continent(de.symeda.sormas.app.backend.region.Continent) ActivityAsCaseDao(de.symeda.sormas.app.backend.activityascase.ActivityAsCaseDao) TextUtils(android.text.TextUtils) PersonContactDetail(de.symeda.sormas.app.backend.person.PersonContactDetail) Outbreak(de.symeda.sormas.app.backend.outbreak.Outbreak) Disease(de.symeda.sormas.api.Disease) Immunization(de.symeda.sormas.app.backend.immunization.Immunization) ClinicalVisitDao(de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisitDao) PreviousHospitalizationDao(de.symeda.sormas.app.backend.hospitalization.PreviousHospitalizationDao) CaseDao(de.symeda.sormas.app.backend.caze.CaseDao) ImmunizationStatus(de.symeda.sormas.api.immunization.ImmunizationStatus) SymptomsDao(de.symeda.sormas.app.backend.symptoms.SymptomsDao) HealthConditions(de.symeda.sormas.app.backend.clinicalcourse.HealthConditions) PrescriptionDao(de.symeda.sormas.app.backend.therapy.PrescriptionDao) ClinicalVisit(de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisit) ContactDao(de.symeda.sormas.app.backend.contact.ContactDao) FeatureConfigurationDao(de.symeda.sormas.app.backend.feature.FeatureConfigurationDao) ImmunizationManagementStatus(de.symeda.sormas.api.immunization.ImmunizationManagementStatus) ActivityAsCase(de.symeda.sormas.app.backend.activityascase.ActivityAsCase) MaternalHistory(de.symeda.sormas.app.backend.caze.maternalhistory.MaternalHistory) Array(java.lang.reflect.Array) Community(de.symeda.sormas.app.backend.region.Community) Date(java.util.Date) ExposureDao(de.symeda.sormas.app.backend.exposure.ExposureDao) AggregateReportDao(de.symeda.sormas.app.backend.report.AggregateReportDao) ExposureType(de.symeda.sormas.api.exposure.ExposureType) Exposure(de.symeda.sormas.app.backend.exposure.Exposure) Facility(de.symeda.sormas.app.backend.facility.Facility) FacilityDao(de.symeda.sormas.app.backend.facility.FacilityDao) ContinentDao(de.symeda.sormas.app.backend.region.ContinentDao) UserRoleConfig(de.symeda.sormas.app.backend.user.UserRoleConfig) WeeklyReport(de.symeda.sormas.app.backend.report.WeeklyReport) VisitDao(de.symeda.sormas.app.backend.visit.VisitDao) GenericRawResults(com.j256.ormlite.dao.GenericRawResults) ConfigProvider(de.symeda.sormas.app.backend.config.ConfigProvider) TableUtils(com.j256.ormlite.table.TableUtils) SyncLog(de.symeda.sormas.app.backend.synclog.SyncLog) Task(de.symeda.sormas.app.backend.task.Task) DiseaseClassificationCriteriaDao(de.symeda.sormas.app.backend.classification.DiseaseClassificationCriteriaDao) VaccinationStatus(de.symeda.sormas.api.caze.VaccinationStatus) EventDao(de.symeda.sormas.app.backend.event.EventDao) Case(de.symeda.sormas.app.backend.caze.Case) OutbreakDao(de.symeda.sormas.app.backend.outbreak.OutbreakDao) TaskDao(de.symeda.sormas.app.backend.task.TaskDao) AdditionalTest(de.symeda.sormas.app.backend.sample.AdditionalTest) Collectors(java.util.stream.Collectors) CampaignFormMeta(de.symeda.sormas.app.backend.campaign.form.CampaignFormMeta) Objects(java.util.Objects) ImmunizationDao(de.symeda.sormas.app.backend.immunization.ImmunizationDao) List(java.util.List) DiseaseConfigurationDao(de.symeda.sormas.app.backend.disease.DiseaseConfigurationDao) OrmLiteSqliteOpenHelper(com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper) PersonContactDetailType(de.symeda.sormas.api.person.PersonContactDetailType) LocationDao(de.symeda.sormas.app.backend.location.LocationDao) DiseaseConfiguration(de.symeda.sormas.app.backend.disease.DiseaseConfiguration) Context(android.content.Context) PointOfEntry(de.symeda.sormas.app.backend.infrastructure.PointOfEntry) PreviousHospitalization(de.symeda.sormas.app.backend.hospitalization.PreviousHospitalization) AdditionalTestDao(de.symeda.sormas.app.backend.sample.AdditionalTestDao) VaccinationDao(de.symeda.sormas.app.backend.vaccination.VaccinationDao) HashMap(java.util.HashMap) HabitationType(de.symeda.sormas.api.exposure.HabitationType) Treatment(de.symeda.sormas.app.backend.therapy.Treatment) Function(java.util.function.Function) User(de.symeda.sormas.app.backend.user.User) WeeklyReportEntryDao(de.symeda.sormas.app.backend.report.WeeklyReportEntryDao) EventParticipantDao(de.symeda.sormas.app.backend.event.EventParticipantDao) CampaignFormData(de.symeda.sormas.app.backend.campaign.data.CampaignFormData) Area(de.symeda.sormas.app.backend.region.Area) CustomizableEnumValueDao(de.symeda.sormas.app.backend.customizableenum.CustomizableEnumValueDao) Subcontinent(de.symeda.sormas.app.backend.region.Subcontinent) Cursor(android.database.Cursor) CampaignFormDataDao(de.symeda.sormas.app.backend.campaign.data.CampaignFormDataDao) UserRoleConfigDao(de.symeda.sormas.app.backend.user.UserRoleConfigDao) PortHealthInfoDao(de.symeda.sormas.app.backend.caze.porthealthinfo.PortHealthInfoDao) Person(de.symeda.sormas.app.backend.person.Person) CustomizableEnumValue(de.symeda.sormas.app.backend.customizableenum.CustomizableEnumValue) Config(de.symeda.sormas.app.backend.config.Config) SormasToSormasOriginInfo(de.symeda.sormas.app.backend.sormastosormas.SormasToSormasOriginInfo) CommunityDao(de.symeda.sormas.app.backend.region.CommunityDao) UserDao(de.symeda.sormas.app.backend.user.UserDao) Sample(de.symeda.sormas.app.backend.sample.Sample) EpiDataDao(de.symeda.sormas.app.backend.epidata.EpiDataDao) DistrictDao(de.symeda.sormas.app.backend.region.DistrictDao) PortHealthInfo(de.symeda.sormas.app.backend.caze.porthealthinfo.PortHealthInfo) Prescription(de.symeda.sormas.app.backend.therapy.Prescription) PathogenTestDao(de.symeda.sormas.app.backend.sample.PathogenTestDao) TherapyDao(de.symeda.sormas.app.backend.therapy.TherapyDao) Comparator(java.util.Comparator) MaternalHistoryDao(de.symeda.sormas.app.backend.caze.maternalhistory.MaternalHistoryDao) Disease(de.symeda.sormas.api.Disease) ArrayList(java.util.ArrayList) Date(java.util.Date) ActivityAsCase(de.symeda.sormas.app.backend.activityascase.ActivityAsCase) Case(de.symeda.sormas.app.backend.caze.Case) BigInteger(java.math.BigInteger) BigInteger(java.math.BigInteger) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with ImmunizationStatus

use of de.symeda.sormas.api.immunization.ImmunizationStatus in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationService method updateImmunizationStatusBasedOnVaccinations.

public void updateImmunizationStatusBasedOnVaccinations(Immunization immunization) {
    ImmunizationStatus immunizationStatus = immunization.getImmunizationStatus();
    if (immunizationStatus != ImmunizationStatus.NOT_ACQUIRED && immunizationStatus != ImmunizationStatus.EXPIRED) {
        final Integer numberOfDoses = immunization.getNumberOfDoses();
        final int vaccinationCount = immunization.getVaccinations().size();
        if (numberOfDoses != null) {
            final Date startDate = immunization.getStartDate();
            if ((startDate == null || System.currentTimeMillis() > startDate.getTime()) && vaccinationCount >= 1 && vaccinationCount < numberOfDoses) {
                immunization.setImmunizationManagementStatus(ImmunizationManagementStatus.ONGOING);
                immunization.setImmunizationStatus(ImmunizationStatus.PENDING);
            } else if (vaccinationCount >= numberOfDoses) {
                immunization.setImmunizationManagementStatus(ImmunizationManagementStatus.COMPLETED);
                immunization.setImmunizationStatus(ImmunizationStatus.ACQUIRED);
            }
        }
    }
}
Also used : ImmunizationStatus(de.symeda.sormas.api.immunization.ImmunizationStatus) Date(java.util.Date) LastVaccinationDate(de.symeda.sormas.backend.vaccination.LastVaccinationDate)

Aggregations

ImmunizationStatus (de.symeda.sormas.api.immunization.ImmunizationStatus)3 MeansOfImmunization (de.symeda.sormas.api.immunization.MeansOfImmunization)2 Date (java.util.Date)2 Context (android.content.Context)1 Cursor (android.database.Cursor)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 TextUtils (android.text.TextUtils)1 Log (android.util.Log)1 OrmLiteSqliteOpenHelper (com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper)1 Dao (com.j256.ormlite.dao.Dao)1 GenericRawResults (com.j256.ormlite.dao.GenericRawResults)1 DataType (com.j256.ormlite.field.DataType)1 ConnectionSource (com.j256.ormlite.support.ConnectionSource)1 TableUtils (com.j256.ormlite.table.TableUtils)1 Disease (de.symeda.sormas.api.Disease)1 VaccinationStatus (de.symeda.sormas.api.caze.VaccinationStatus)1 Vaccine (de.symeda.sormas.api.caze.Vaccine)1 VaccineManufacturer (de.symeda.sormas.api.caze.VaccineManufacturer)1 AnimalCondition (de.symeda.sormas.api.epidata.AnimalCondition)1 AnimalContactType (de.symeda.sormas.api.exposure.AnimalContactType)1