use of de.symeda.sormas.app.backend.exposure.Exposure in project SORMAS-Project by hzi-braunschweig.
the class EpiDataDtoHelper method fillInnerFromAdo.
@Override
public void fillInnerFromAdo(EpiDataDto target, EpiData source) {
target.setExposureDetailsKnown(source.getExposureDetailsKnown());
target.setActivityAsCaseDetailsKnown(source.getActivityAsCaseDetailsKnown());
target.setContactWithSourceCaseKnown(source.getContactWithSourceCaseKnown());
target.setHighTransmissionRiskArea(source.getHighTransmissionRiskArea());
target.setLargeOutbreaksArea(source.getLargeOutbreaksArea());
target.setAreaInfectedAnimals(source.getAreaInfectedAnimals());
List<ExposureDto> exposureDtos = new ArrayList<>();
if (!source.getExposures().isEmpty()) {
for (Exposure exposure : source.getExposures()) {
ExposureDto exposureDto = exposureDtoHelper.adoToDto(exposure);
exposureDtos.add(exposureDto);
}
}
target.setExposures(exposureDtos);
List<ActivityAsCaseDto> activityAsCaseDtos = new ArrayList<>();
if (!source.getActivitiesAsCase().isEmpty()) {
for (ActivityAsCase activityAsCase : source.getActivitiesAsCase()) {
ActivityAsCaseDto exposureDto = activityAsCaseDtoHelper.adoToDto(activityAsCase);
activityAsCaseDtos.add(exposureDto);
}
}
target.setActivitiesAsCase(activityAsCaseDtos);
target.setPseudonymized(source.isPseudonymized());
}
use of de.symeda.sormas.app.backend.exposure.Exposure in project SORMAS-Project by hzi-braunschweig.
the class EpidemiologicalDataEditFragment method setUpControlListeners.
private void setUpControlListeners(final FragmentEditEpidLayoutBinding contentBinding) {
onExposureItemClickListener = (v, item) -> {
final Exposure exposure = (Exposure) item;
final Exposure exposureClone = (Exposure) exposure.clone();
final ExposureDialog dialog = new ExposureDialog(CaseEditActivity.getActiveActivity(), exposureClone, getActivityRootData(), false);
dialog.setPositiveCallback(() -> {
record.getExposures().set(record.getExposures().indexOf(exposure), exposureClone);
updateExposures();
});
dialog.setDeleteCallback(() -> {
removeExposure(exposure);
dialog.dismiss();
});
dialog.show();
};
contentBinding.btnAddExposure.setOnClickListener(v -> {
final Exposure exposure = DatabaseHelper.getExposureDao().build();
final ExposureDialog dialog = new ExposureDialog(CaseEditActivity.getActiveActivity(), exposure, getActivityRootData(), true);
dialog.setPositiveCallback(() -> addExposure(exposure));
dialog.show();
});
contentBinding.epiDataExposureDetailsKnown.addValueChangedListener(field -> {
YesNoUnknown value = (YesNoUnknown) field.getValue();
contentBinding.exposuresLayout.setVisibility(value == YesNoUnknown.YES ? VISIBLE : GONE);
if (value != YesNoUnknown.YES) {
clearExposures();
}
getContentBinding().epiDataExposureDetailsKnown.setEnabled(getExposureList().isEmpty());
});
onActivityAsCaseItemClickListener = (v, item) -> {
final ActivityAsCase activityAsCase = (ActivityAsCase) item;
final ActivityAsCase activityAsCaseClone = (ActivityAsCase) activityAsCase.clone();
final ActivityAsCaseDialog dialog = new ActivityAsCaseDialog(CaseEditActivity.getActiveActivity(), activityAsCaseClone, getActivityRootData(), false);
dialog.setPositiveCallback(() -> {
record.getActivitiesAsCase().set(record.getActivitiesAsCase().indexOf(activityAsCase), activityAsCaseClone);
updateActivitiesAsCase();
});
dialog.setDeleteCallback(() -> {
removeActivityAsCase(activityAsCase);
dialog.dismiss();
});
dialog.show();
};
contentBinding.btnAddActivityascase.setOnClickListener(v -> {
final ActivityAsCase activityAsCase = DatabaseHelper.getActivityAsCaseDao().build();
final ActivityAsCaseDialog dialog = new ActivityAsCaseDialog(CaseEditActivity.getActiveActivity(), activityAsCase, getActivityRootData(), true);
dialog.setPositiveCallback(() -> addActivityAsCase(activityAsCase));
dialog.show();
});
contentBinding.epiDataActivityAsCaseDetailsKnown.addValueChangedListener(field -> {
YesNoUnknown value = (YesNoUnknown) field.getValue();
contentBinding.activityascaseLayout.setVisibility(value == YesNoUnknown.YES ? VISIBLE : GONE);
if (value != YesNoUnknown.YES) {
clearActivitiesAsCase();
}
getContentBinding().epiDataActivityAsCaseDetailsKnown.setEnabled(getActivityAsCaseList().isEmpty());
});
}
use of de.symeda.sormas.app.backend.exposure.Exposure in project SORMAS-Project by hzi-braunschweig.
the class TestEntityCreator method createExposure.
public static Exposure createExposure(Case caze) {
Exposure exposure = DatabaseHelper.getExposureDao().build();
exposure.setEpiData(caze.getEpiData());
try {
DatabaseHelper.getExposureDao().saveAndSnapshot(exposure);
DatabaseHelper.getExposureDao().accept(exposure);
} catch (DaoException e) {
throw new RuntimeException(e);
}
return DatabaseHelper.getExposureDao().queryForIdWithEmbedded(exposure.getId());
}
use of de.symeda.sormas.app.backend.exposure.Exposure in project SORMAS-Project by hzi-braunschweig.
the class DatabaseHelper method getAdoDaoInner.
public <ADO extends AbstractDomainObject> AbstractAdoDao<ADO> getAdoDaoInner(Class<ADO> type) {
if (!adoDaos.containsKey(type)) {
// build dao
AbstractAdoDao<ADO> dao;
Dao<ADO, Long> innerDao;
try {
innerDao = super.getDao(type);
if (type.equals(Case.class)) {
dao = (AbstractAdoDao<ADO>) new CaseDao((Dao<Case, Long>) innerDao);
} else if (type.equals(Immunization.class)) {
dao = (AbstractAdoDao<ADO>) new ImmunizationDao((Dao<Immunization, Long>) innerDao);
} else if (type.equals(Vaccination.class)) {
dao = (AbstractAdoDao<ADO>) new VaccinationDao((Dao<Vaccination, Long>) innerDao);
} else if (type.equals(Therapy.class)) {
dao = (AbstractAdoDao<ADO>) new TherapyDao((Dao<Therapy, Long>) innerDao);
} else if (type.equals(Prescription.class)) {
dao = (AbstractAdoDao<ADO>) new PrescriptionDao((Dao<Prescription, Long>) innerDao);
} else if (type.equals(Treatment.class)) {
dao = (AbstractAdoDao<ADO>) new TreatmentDao((Dao<Treatment, Long>) innerDao);
} else if (type.equals(Person.class)) {
dao = (AbstractAdoDao<ADO>) new PersonDao((Dao<Person, Long>) innerDao);
} else if (type.equals(PersonContactDetail.class)) {
dao = (AbstractAdoDao<ADO>) new PersonContactDetailDao((Dao<PersonContactDetail, Long>) innerDao);
} else if (type.equals(Location.class)) {
dao = (AbstractAdoDao<ADO>) new LocationDao((Dao<Location, Long>) innerDao);
} else if (type.equals(PointOfEntry.class)) {
dao = (AbstractAdoDao<ADO>) new PointOfEntryDao((Dao<PointOfEntry, Long>) innerDao);
} else if (type.equals(Facility.class)) {
dao = (AbstractAdoDao<ADO>) new FacilityDao((Dao<Facility, Long>) innerDao);
} else if (type.equals(Continent.class)) {
dao = (AbstractAdoDao<ADO>) new ContinentDao((Dao<Continent, Long>) innerDao);
} else if (type.equals(Subcontinent.class)) {
dao = (AbstractAdoDao<ADO>) new SubcontinentDao((Dao<Subcontinent, Long>) innerDao);
} else if (type.equals(Country.class)) {
dao = (AbstractAdoDao<ADO>) new CountryDao((Dao<Country, Long>) innerDao);
} else if (type.equals(Area.class)) {
dao = (AbstractAdoDao<ADO>) new AreaDao((Dao<Area, Long>) innerDao);
} else if (type.equals(Region.class)) {
dao = (AbstractAdoDao<ADO>) new RegionDao((Dao<Region, Long>) innerDao);
} else if (type.equals(District.class)) {
dao = (AbstractAdoDao<ADO>) new DistrictDao((Dao<District, Long>) innerDao);
} else if (type.equals(Community.class)) {
dao = (AbstractAdoDao<ADO>) new CommunityDao((Dao<Community, Long>) innerDao);
} else if (type.equals(User.class)) {
dao = (AbstractAdoDao<ADO>) new UserDao((Dao<User, Long>) innerDao);
} else if (type.equals(UserRoleConfig.class)) {
dao = (AbstractAdoDao<ADO>) new UserRoleConfigDao((Dao<UserRoleConfig, Long>) innerDao);
} else if (type.equals(DiseaseConfiguration.class)) {
dao = (AbstractAdoDao<ADO>) new DiseaseConfigurationDao((Dao<DiseaseConfiguration, Long>) innerDao);
} else if (type.equals(CustomizableEnumValue.class)) {
dao = (AbstractAdoDao<ADO>) new CustomizableEnumValueDao((Dao<CustomizableEnumValue, Long>) innerDao);
} else if (type.equals(FeatureConfiguration.class)) {
dao = (AbstractAdoDao<ADO>) new FeatureConfigurationDao((Dao<FeatureConfiguration, Long>) innerDao);
} else if (type.equals(Symptoms.class)) {
dao = (AbstractAdoDao<ADO>) new SymptomsDao((Dao<Symptoms, Long>) innerDao);
} else if (type.equals(HealthConditions.class)) {
dao = (AbstractAdoDao<ADO>) new HealthConditionsDao((Dao<HealthConditions, Long>) innerDao);
} else if (type.equals(ClinicalCourse.class)) {
dao = (AbstractAdoDao<ADO>) new ClinicalCourseDao((Dao<ClinicalCourse, Long>) innerDao);
} else if (type.equals(ClinicalVisit.class)) {
dao = (AbstractAdoDao<ADO>) new ClinicalVisitDao((Dao<ClinicalVisit, Long>) innerDao);
} else if (type.equals(MaternalHistory.class)) {
dao = (AbstractAdoDao<ADO>) new MaternalHistoryDao((Dao<MaternalHistory, Long>) innerDao);
} else if (type.equals(PortHealthInfo.class)) {
dao = (AbstractAdoDao<ADO>) new PortHealthInfoDao((Dao<PortHealthInfo, Long>) innerDao);
} else if (type.equals(Task.class)) {
dao = (AbstractAdoDao<ADO>) new TaskDao((Dao<Task, Long>) innerDao);
} else if (type.equals(Contact.class)) {
dao = (AbstractAdoDao<ADO>) new ContactDao((Dao<Contact, Long>) innerDao);
} else if (type.equals(Visit.class)) {
dao = (AbstractAdoDao<ADO>) new VisitDao((Dao<Visit, Long>) innerDao);
} else if (type.equals(Event.class)) {
dao = (AbstractAdoDao<ADO>) new EventDao((Dao<Event, Long>) innerDao);
} else if (type.equals(EventParticipant.class)) {
dao = (AbstractAdoDao<ADO>) new EventParticipantDao((Dao<EventParticipant, Long>) innerDao);
} else if (type.equals(Sample.class)) {
dao = (AbstractAdoDao<ADO>) new SampleDao((Dao<Sample, Long>) innerDao);
} else if (type.equals(PathogenTest.class)) {
dao = (AbstractAdoDao<ADO>) new PathogenTestDao((Dao<PathogenTest, Long>) innerDao);
} else if (type.equals(AdditionalTest.class)) {
dao = (AbstractAdoDao<ADO>) new AdditionalTestDao((Dao<AdditionalTest, Long>) innerDao);
} else if (type.equals(Hospitalization.class)) {
dao = (AbstractAdoDao<ADO>) new HospitalizationDao((Dao<Hospitalization, Long>) innerDao);
} else if (type.equals(PreviousHospitalization.class)) {
dao = (AbstractAdoDao<ADO>) new PreviousHospitalizationDao((Dao<PreviousHospitalization, Long>) innerDao);
} else if (type.equals(EpiData.class)) {
dao = (AbstractAdoDao<ADO>) new EpiDataDao((Dao<EpiData, Long>) innerDao);
} else if (type.equals(Exposure.class)) {
dao = (AbstractAdoDao<ADO>) new ExposureDao((Dao<Exposure, Long>) innerDao);
} else if (type.equals(ActivityAsCase.class)) {
dao = (AbstractAdoDao<ADO>) new ActivityAsCaseDao((Dao<ActivityAsCase, Long>) innerDao);
} else if (type.equals(WeeklyReport.class)) {
dao = (AbstractAdoDao<ADO>) new WeeklyReportDao((Dao<WeeklyReport, Long>) innerDao);
} else if (type.equals(WeeklyReportEntry.class)) {
dao = (AbstractAdoDao<ADO>) new WeeklyReportEntryDao((Dao<WeeklyReportEntry, Long>) innerDao);
} else if (type.equals(AggregateReport.class)) {
dao = (AbstractAdoDao<ADO>) new AggregateReportDao((Dao<AggregateReport, Long>) innerDao);
} else if (type.equals(Outbreak.class)) {
dao = (AbstractAdoDao<ADO>) new OutbreakDao((Dao<Outbreak, Long>) innerDao);
} else if (type.equals(DiseaseClassificationCriteria.class)) {
dao = (AbstractAdoDao<ADO>) new DiseaseClassificationCriteriaDao((Dao<DiseaseClassificationCriteria, Long>) innerDao);
} else if (type.equals(SormasToSormasOriginInfo.class)) {
dao = (AbstractAdoDao<ADO>) new SormasToSormasOriginInfoDao((Dao<SormasToSormasOriginInfo, Long>) innerDao);
} else if (type.equals(Campaign.class)) {
dao = (AbstractAdoDao<ADO>) new CampaignDao((Dao<Campaign, Long>) innerDao);
} else if (type.equals(CampaignFormMeta.class)) {
dao = (AbstractAdoDao<ADO>) new CampaignFormMetaDao((Dao<CampaignFormMeta, Long>) innerDao);
} else if (type.equals(CampaignFormData.class)) {
dao = (AbstractAdoDao<ADO>) new CampaignFormDataDao((Dao<CampaignFormData, Long>) innerDao);
} else {
throw new UnsupportedOperationException(type.toString());
}
adoDaos.put(type, dao);
} catch (SQLException e) {
Log.e(DatabaseHelper.class.getName(), "Can't build dao", e);
throw new RuntimeException(e);
}
}
return (AbstractAdoDao<ADO>) adoDaos.get(type);
}
use of de.symeda.sormas.app.backend.exposure.Exposure in project SORMAS-Project by hzi-braunschweig.
the class DatabaseHelper method migrateEpiData.
private void migrateEpiData() throws SQLException {
getDao(EpiData.class).executeRaw("UPDATE epidata SET wildbirds = 'YES', poultryEat = 'YES' WHERE poultry = 'YES' AND changeDate = 0 AND snapshot = 0;");
// Epi data field names sometimes don't match the actual field names because the columns were renamed in the past
migrateEpiDataField("processingConfirmedCaseFluidUnsafe", Exposure.HANDLING_SAMPLES, YesNoUnknown.YES, ExposureType.WORK);
migrateEpiDataField("percutaneousCaseBlood", Exposure.PERCUTANEOUS, YesNoUnknown.YES, ExposureType.WORK);
migrateEpiDataField("wildbirdsLocation", Exposure.PHYSICAL_CONTACT_WITH_BODY, YesNoUnknown.YES, ExposureType.BURIAL);
migrateEpiDataField("wildbirdsDetails", Exposure.HANDLING_SAMPLES, YesNoUnknown.YES, ExposureType.WORK);
migrateEpiDataField("poultrySick", Exposure.ANIMAL_CONDITION, AnimalCondition.DEAD, ExposureType.ANIMAL_CONTACT, "poultryDate", "poultryDate", "poultrySickDetails", "poultryLocation");
migrateEpiDataField("poultryEat", Exposure.EATING_RAW_ANIMAL_PRODUCTS, YesNoUnknown.YES, ExposureType.ANIMAL_CONTACT, null, null, "poultryDetails", null);
migrateEpiDataField("rodents", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.RODENT, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("bats", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.BAT, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("primates", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.PRIMATE, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("swine", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.SWINE, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("birds", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.POULTRY, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("rabbits", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.RABBIT, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("cattle", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.CATTLE, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("dogs", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.DOG, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("cats", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.CAT, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("canidae", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.CANIDAE, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("camels", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.CAMEL, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("snakes", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.SNAKE, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("tickBite", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.TICK, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("fleaBite", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.FLEA, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("otherAnimals", Exposure.TYPE_OF_ANIMAL, TypeOfAnimal.OTHER, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("waterBody", Exposure.BODY_OF_WATER, YesNoUnknown.YES, ExposureType.OTHER, null, null, "waterBodyDetails", null);
migrateEpiDataField("visitedHealthFacility", Exposure.HABITATION_TYPE, HabitationType.MEDICAL, ExposureType.HABITATION);
migrateEpiDataField("visitedAnimalMarket", Exposure.ANIMAL_MARKET, YesNoUnknown.YES, ExposureType.OTHER);
migrateEpiDataField("areaConfirmedCases", Exposure.RISK_AREA, YesNoUnknown.YES, ExposureType.TRAVEL);
migrateEpiDataField("kindOfExposureBite", Exposure.ANIMAL_CONTACT_TYPE, AnimalContactType.BITE, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("kindOfExposureTouch", Exposure.ANIMAL_CONTACT_TYPE, AnimalContactType.TOUCH, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("kindOfExposureScratch", Exposure.ANIMAL_CONTACT_TYPE, AnimalContactType.SCRATCH, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("kindOfExposureLick", Exposure.ANIMAL_CONTACT_TYPE, AnimalContactType.LICK, ExposureType.ANIMAL_CONTACT);
migrateEpiDataField("kindOfExposureOther", Exposure.ANIMAL_CONTACT_TYPE, AnimalContactType.OTHER, ExposureType.ANIMAL_CONTACT);
GenericRawResults<Object[]> lastExposureInfo = getDao(EpiData.class).queryRaw("SELECT id, dateOfLastExposure, placeOfLastExposure, animalCondition, animalVaccinationStatus, prophylaxisStatus, dateOfProphylaxis" + " FROM epidata WHERE changeDate = 0 AND snapshot = 0 AND (dateOfLastExposure IS NOT NULL OR placeOfLastExposure IS NOT NULL" + " OR animalCondition IS NOT NULL OR animalVaccinationStatus IS NOT NULL OR prophylaxisStatus IS NOT NULL OR dateOfProphylaxis IS NOT NULL);", new DataType[] { DataType.BIG_INTEGER, DataType.DATE_LONG, DataType.STRING, DataType.ENUM_STRING, DataType.ENUM_STRING, DataType.ENUM_STRING, DataType.DATE_LONG });
for (Object[] result : lastExposureInfo) {
doNullCheckOnString(result, 2);
formatRawResultDate(result, 1);
formatRawResultDate(result, 6);
Long locationId = insertLocation((String) result[2]);
VaccinationStatus vaccinationStatus = result[4] != null ? VaccinationStatus.valueOf((String) result[4]) : null;
String exposureQuery = "INSERT INTO exposures" + "(" + " uuid, changeDate, localChangeDate, creationDate, epiData_id, location_id, exposureType, " + " startDate, endDate, animalCondition, animalVaccinated, prophylaxis, prophylaxisDate, description, pseudonymized, modified, snapshot" + ")" + "VALUES (?, ?, " + generateDateNowSQL() + ", " + generateDateNowSQL() + ", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
executeRaw(Exposure.class, exposureQuery, DataHelper.createUuid(), 0, result[0], locationId, ExposureType.ANIMAL_CONTACT.name(), result[1], result[1], result[3], (vaccinationStatus == VaccinationStatus.VACCINATED ? YesNoUnknown.YES.name() : vaccinationStatus == VaccinationStatus.UNVACCINATED ? YesNoUnknown.NO.name() : vaccinationStatus == VaccinationStatus.UNKNOWN ? YesNoUnknown.UNKNOWN.name() : null), result[5], result[6], "Automatic epi data migration based on last exposure details; this exposure may be merged with another exposure with animal contact", 0, 0, 0);
}
getDao(Exposure.class).executeRaw("UPDATE exposures SET typeOfAnimalDetails = (SELECT otherAnimalsDetails FROM epidata WHERE id = exposures.epidata_id AND exposures.typeOfAnimal = 'OTHER');");
getDao(Exposure.class).executeRaw("UPDATE exposures SET animalContactTypeDetails = (SELECT kindOfExposureDetails FROM epidata WHERE id = exposures.epidata_id AND exposures.animalContactType = 'OTHER');");
getDao(Exposure.class).executeRaw("UPDATE exposures SET waterSource = (SELECT waterSource FROM epidata WHERE id = exposures.epidata_id AND exposures.bodyOfWater = 'YES');");
getDao(Exposure.class).executeRaw("UPDATE exposures SET waterSourceDetails = (SELECT waterSourceOther FROM epidata WHERE id = exposures.epidata_id AND exposures.bodyOfWater = 'YES');");
getDao(Exposure.class).executeRaw("UPDATE exposures SET description = 'Automatic epi data migration based on selected kinds of exposure; this exposure may be merged with another exposure with animal contact' WHERE exposureType = 'ANIMAL_CONTACT' AND typeOfAnimal IS NULL;");
getDao(EpiData.class).executeRaw("UPDATE epidata SET contactWithSourceCaseKnown = 'YES' WHERE snapshot = 0 AND changeDate = 0 AND (directContactConfirmedCase = 'YES' OR directContactProbableCase = 'YES' OR closeContactProbableCase = 'YES' OR contactWithSourceRespiratoryCase = 'YES');");
getDao(EpiData.class).executeRaw("UPDATE epidata SET exposureDetailsKnown = 'YES' WHERE snapshot = 0 AND changeDate = 0 AND (exposureDetailsKnown IS NULL OR exposureDetailsKnown != 'YES') " + "AND (SELECT COUNT(id) FROM exposures WHERE exposures.epidata_id = epidata.id LIMIT 1) > 0;");
}
Aggregations