Skip to content

Commit

Permalink
Merge branch 'gh-release-1.87.0' of https://github.com/ePareto-Inform…
Browse files Browse the repository at this point in the history
…ation-System/SORMAS-Project into gh-release-1.87.0
  • Loading branch information
Anthony4m committed Jan 23, 2025
2 parents d8854f3 + 3974af3 commit b80d3b3
Show file tree
Hide file tree
Showing 25 changed files with 1,430 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
import de.symeda.sormas.app.backend.foodhistory.FoodHistory;
import de.symeda.sormas.app.backend.investigationnotes.InvestigationNotes;
import de.symeda.sormas.app.backend.patientsymptomsprecedence.PatientSymptomsPrecedence;
import de.symeda.sormas.app.backend.patienttraveldetailsduring.PatientTravelDetailsDuring;
import de.symeda.sormas.app.backend.patienttraveldetailsprior.PatientTravelDetailsPrior;
import de.symeda.sormas.app.backend.person.Person;
import de.symeda.sormas.app.backend.persontravelhistory.PersonTravelHistory;
import de.symeda.sormas.app.backend.region.Community;
Expand Down Expand Up @@ -252,6 +254,16 @@ public Date getLatestChangeDate() {
date = affectedPersonDate;
}

Date patientTravelDetailsDuringDate = getLatestChangeDateSubJoin(RiskFactor.TABLE_NAME, Case.RISK_FACTOR, PatientTravelDetailsDuring.TABLE_NAME);
if (patientTravelDetailsDuringDate != null && patientTravelDetailsDuringDate.after(date)) {
date = patientTravelDetailsDuringDate;
}

Date patientTravelDetailsPriorDate = getLatestChangeDateSubJoin(RiskFactor.TABLE_NAME, Case.RISK_FACTOR, PatientTravelDetailsPrior.TABLE_NAME);
if (patientTravelDetailsPriorDate != null && patientTravelDetailsPriorDate.after(date)) {
date = patientTravelDetailsPriorDate;
}

Date investigationNotesDate = getLatestChangeDateJoin(InvestigationNotes.TABLE_NAME, Case.INVESTIGATION_NOTES);
if (investigationNotesDate != null && investigationNotesDate.after(date)) {
date = investigationNotesDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
import de.symeda.sormas.app.backend.outbreak.OutbreakDao;
import de.symeda.sormas.app.backend.patientsymptomsprecedence.PatientSymptomsPrecedence;
import de.symeda.sormas.app.backend.patientsymptomsprecedence.PatientSymptomsPrecedenceDao;
import de.symeda.sormas.app.backend.patienttraveldetailsduring.PatientTravelDetailsDuring;
import de.symeda.sormas.app.backend.patienttraveldetailsduring.PatientTravelDetailsDuringDao;
import de.symeda.sormas.app.backend.patienttraveldetailsprior.PatientTravelDetailsPrior;
import de.symeda.sormas.app.backend.patienttraveldetailsprior.PatientTravelDetailsPriorDao;
import de.symeda.sormas.app.backend.person.Person;
import de.symeda.sormas.app.backend.person.PersonContactDetail;
import de.symeda.sormas.app.backend.person.PersonContactDetailDao;
Expand Down Expand Up @@ -318,6 +322,8 @@ public static void clearTables(boolean clearInfrastructure) {
TableUtils.clearTable(connectionSource, AfpImmunization.class);
TableUtils.clearTable(connectionSource, SixtyDay.class);
TableUtils.clearTable(connectionSource, PatientSymptomsPrecedence.class);
TableUtils.clearTable(connectionSource, PatientTravelDetailsDuring.class);
TableUtils.clearTable(connectionSource, PatientTravelDetailsPrior.class);

if (clearInfrastructure) {
TableUtils.clearTable(connectionSource, UserUserRole.class);
Expand Down Expand Up @@ -678,6 +684,14 @@ public static PatientSymptomsPrecedenceDao getPatientSymptomsPrecedenceDao() {
return (PatientSymptomsPrecedenceDao) getAdoDao(PatientSymptomsPrecedence.class);
}

public static PatientTravelDetailsDuringDao getPatientTravelDetailsDuringDao() {
return (PatientTravelDetailsDuringDao) getAdoDao(PatientTravelDetailsDuring.class);
}

public static PatientTravelDetailsPriorDao getPatientTravelDetailsPriorDao() {
return (PatientTravelDetailsPriorDao) getAdoDao(PatientTravelDetailsPrior.class);
}

// TODO [vaccination info] integrate vaccination info
// public static VaccinationInfoDao getVaccinationInfoDao() {
// return (VaccinationInfoDao) getAdoDao(VaccinationInfo.class);
Expand Down Expand Up @@ -796,6 +810,8 @@ public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) {
TableUtils.createTable(connectionSource, AfpImmunization.class);
TableUtils.createTable(connectionSource, SixtyDay.class);
TableUtils.createTable(connectionSource, PatientSymptomsPrecedence.class);
TableUtils.createTable(connectionSource, PatientTravelDetailsPrior.class);
TableUtils.createTable(connectionSource, PatientTravelDetailsDuring.class);
TableUtils.createTable(connectionSource, DiseaseFacility.class);

} catch (SQLException e) {
Expand Down Expand Up @@ -4459,6 +4475,44 @@ public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int
case 428:
currentVersion = 428;
getDao(DiseaseConfiguration.class).executeRaw("CREATE TABLE IF NOT EXISTS facility_diseaseconfiguration(diseaseConfiguration_id integer, facility_id integer);");

case 429:
currentVersion = 429;
getDao(PatientTravelDetailsDuring.class).executeRaw(
"CREATE TABLE patienttraveldetailsduring ("
+ " id INTEGER PRIMARY KEY AUTOINCREMENT,"
+ " uuid VARCHAR(36) NOT NULL UNIQUE,"
+ " changedate BIGINT NOT NULL,"
+ " creationdate BIGINT NOT NULL,"
+ " riskfactor_id BIGINT NOT NULL,"
+ " dateOfTravel DATE,"
+ " placeOfTravel VARCHAR(255),"
+ " pseudonymized SMALLINT,"
+ " lastOpenedDate BIGINT,"
+ " localChangeDate BIGINT NOT NULL,"
+ " modified SMALLINT,"
+ " snapshot SMALLINT,"
+ " UNIQUE (snapshot ASC, uuid ASC)"
+ ");"
);

getDao(PatientTravelDetailsPrior.class).executeRaw(
"CREATE TABLE patienttraveldetailsprior ("
+ " id INTEGER PRIMARY KEY AUTOINCREMENT,"
+ " uuid VARCHAR(36) NOT NULL UNIQUE,"
+ " changedate BIGINT NOT NULL,"
+ " creationdate BIGINT NOT NULL,"
+ " riskfactor_id BIGINT NOT NULL,"
+ " dateOfTravel DATE,"
+ " placeOfTravel VARCHAR(255),"
+ " pseudonymized SMALLINT,"
+ " lastOpenedDate BIGINT,"
+ " localChangeDate BIGINT NOT NULL,"
+ " modified SMALLINT,"
+ " snapshot SMALLINT,"
+ " UNIQUE (snapshot ASC, uuid ASC)"
+ ");"
);
// ATTENTION: break should only be done after last version
break;
default:
Expand Down Expand Up @@ -5277,6 +5331,8 @@ private void upgradeFromUnupgradableVersion(SQLiteDatabase db, ConnectionSource
TableUtils.dropTable(connectionSource, ContaminationSource.class, true);
TableUtils.dropTable(connectionSource, ContainmentMeasure.class, true);
TableUtils.dropTable(connectionSource, AffectedPerson.class, true);
TableUtils.dropTable(connectionSource, PatientTravelDetailsDuring.class, true);
TableUtils.dropTable(connectionSource, PatientTravelDetailsPrior.class, true);
TableUtils.dropTable(connectionSource, SixtyDay.class, true);
TableUtils.dropTable(connectionSource, PatientSymptomsPrecedence.class, true);

Expand Down Expand Up @@ -5446,6 +5502,10 @@ public <ADO extends AbstractDomainObject> AbstractAdoDao<ADO> getAdoDaoInner(Cla
dao = (AbstractAdoDao<ADO>) new SixtyDayDao((Dao<SixtyDay, Long>) innerDao);
} else if (type.equals(PatientSymptomsPrecedence.class)) {
dao = (AbstractAdoDao<ADO>) new PatientSymptomsPrecedenceDao((Dao<PatientSymptomsPrecedence, Long>) innerDao);
} else if (type.equals(PatientTravelDetailsDuring.class)) {
dao = (AbstractAdoDao<ADO>) new PatientTravelDetailsDuringDao((Dao<PatientTravelDetailsDuring, Long>) innerDao);
} else if (type.equals(PatientTravelDetailsPrior.class)) {
dao = (AbstractAdoDao<ADO>) new PatientTravelDetailsPriorDao((Dao<PatientTravelDetailsPrior, Long>) innerDao);
} else {
throw new UnsupportedOperationException(type.toString());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package de.symeda.sormas.app.backend.patienttraveldetailsduring;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import de.symeda.sormas.api.utils.TravelLocation;
import de.symeda.sormas.app.backend.common.EmbeddedAdo;
import de.symeda.sormas.app.backend.common.PseudonymizableAdo;
import de.symeda.sormas.app.backend.riskfactor.RiskFactor;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.util.Date;

@Entity(name = PatientTravelDetailsDuring.TABLE_NAME)
@DatabaseTable(tableName = PatientTravelDetailsDuring.TABLE_NAME)
@EmbeddedAdo(parentAccessor = PatientTravelDetailsDuring.RISK_FACTOR)

public class PatientTravelDetailsDuring extends PseudonymizableAdo {
public static final String I18N_PREFIX = "PatientTravelDetailsDuring";
private static final long serialVersionUID = 6551672739041643942L;

public static final String TABLE_NAME = "patienttraveldetailsduring";
public static final String RISK_FACTOR = "riskFactor";

@DatabaseField(dataType = DataType.DATE_LONG)
private Date dateOfTravel;
@Enumerated(EnumType.STRING)
private TravelLocation placeOfTravel;
@DatabaseField(foreign = true, foreignAutoRefresh = true)
private RiskFactor riskFactor;

@Override
public String getI18nPrefix() {
return I18N_PREFIX;
}

public RiskFactor getRiskFactor() {
return riskFactor;
}
public void setRiskFactor(RiskFactor riskFactor) {
this.riskFactor = riskFactor;
}

public Date getDateOfTravel() {
return dateOfTravel;
}

public void setDateOfTravel(Date dateOfTravel) {
this.dateOfTravel = dateOfTravel;
}

public TravelLocation getPlaceOfTravel() {
return placeOfTravel;
}

public void setPlaceOfTravel(TravelLocation placeOfTravel) {
this.placeOfTravel = placeOfTravel;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package de.symeda.sormas.app.backend.patienttraveldetailsduring;

import com.j256.ormlite.dao.Dao;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

import de.symeda.sormas.app.backend.common.AbstractAdoDao;
import de.symeda.sormas.app.backend.riskfactor.RiskFactor;

public class PatientTravelDetailsDuringDao extends AbstractAdoDao<PatientTravelDetailsDuring> {

public PatientTravelDetailsDuringDao(Dao<PatientTravelDetailsDuring, Long> innerDao) {
super(innerDao);
}

@Override
protected Class<PatientTravelDetailsDuring> getAdoClass() {
return PatientTravelDetailsDuring.class;
}

@Override
public PatientTravelDetailsDuring build() {
PatientTravelDetailsDuring patientTravelDetailsDuring = super.build();
return patientTravelDetailsDuring;
}

@Override
public void deleteCascade(PatientTravelDetailsDuring patientTravelDetailsDuring) throws SQLException {
super.delete(patientTravelDetailsDuring);
}

public List<PatientTravelDetailsDuring> getByRiskFactor(RiskFactor riskFactor) {
if (riskFactor.isSnapshot()) {
return querySnapshotsForEq(PatientTravelDetailsDuring.RISK_FACTOR + "_id", riskFactor, PatientTravelDetailsDuring.CHANGE_DATE, false);
}
return queryForEq(PatientTravelDetailsDuring.RISK_FACTOR + "_id", riskFactor, PatientTravelDetailsDuring.CHANGE_DATE, false);
}

@Override
public Date getLatestChangeDate() {
Date date = super.getLatestChangeDate();
if (date == null) {
return null;
}
return date;
}

@Override
public String getTableName() {
return PatientTravelDetailsDuring.TABLE_NAME;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package de.symeda.sormas.app.backend.patienttraveldetailsduring;

import java.util.List;

import de.symeda.sormas.api.PostResponse;
import de.symeda.sormas.api.riskfactor.PatientTravelDetailsDuringDto;
import de.symeda.sormas.app.backend.common.AdoDtoHelper;
import de.symeda.sormas.app.rest.NoConnectionException;
import retrofit2.Call;


public class PatientTravelDetailsDuringDtoHelper extends AdoDtoHelper<PatientTravelDetailsDuring, PatientTravelDetailsDuringDto> {

public PatientTravelDetailsDuringDtoHelper() {
}

@Override
protected Class<PatientTravelDetailsDuring> getAdoClass() {
return PatientTravelDetailsDuring.class;
}

@Override
protected Class<PatientTravelDetailsDuringDto> getDtoClass() {
return PatientTravelDetailsDuringDto.class;
}

@Override
protected Call<List<PatientTravelDetailsDuringDto>> pullAllSince(long since,
Integer size,
String lastSynchronizedUuid) throws NoConnectionException {
throw new UnsupportedOperationException("Entity is embedded");
}

@Override
protected Call<List<PatientTravelDetailsDuringDto>> pullByUuids(List<String> uuids) throws NoConnectionException {
throw new UnsupportedOperationException("Entity is embedded");
}

@Override
protected Call<List<PostResponse>> pushAll(List<PatientTravelDetailsDuringDto> exposureDtos) throws NoConnectionException {
throw new UnsupportedOperationException("Entity is embedded");
}

@Override
protected void fillInnerFromDto(PatientTravelDetailsDuring target, PatientTravelDetailsDuringDto source) {
target.setDateOfTravel(source.getDateOfTravel());
target.setPlaceOfTravel(source.getPlaceOfTravel());
}

@Override
protected void fillInnerFromAdo(PatientTravelDetailsDuringDto target, PatientTravelDetailsDuring source) {
target.setDateOfTravel(source.getDateOfTravel());
target.setPlaceOfTravel(source.getPlaceOfTravel());
}

@Override
protected long getApproximateJsonSizeInBytes() {
return 0;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package de.symeda.sormas.app.backend.patienttraveldetailsprior;


import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.util.Date;

import de.symeda.sormas.app.backend.common.EmbeddedAdo;
import de.symeda.sormas.app.backend.common.PseudonymizableAdo;
import de.symeda.sormas.app.backend.riskfactor.RiskFactor;
import de.symeda.sormas.api.utils.TravelLocation;

@Entity(name = PatientTravelDetailsPrior.TABLE_NAME)
@DatabaseTable(tableName = PatientTravelDetailsPrior.TABLE_NAME)
@EmbeddedAdo(parentAccessor = PatientTravelDetailsPrior.RISK_FACTOR)

public class PatientTravelDetailsPrior extends PseudonymizableAdo {

public static final String I18N_PREFIX = "PatientTravelDetailsPrior";
private static final long serialVersionUID = 6551672739041643942L;

public static final String TABLE_NAME = "patienttraveldetailsprior";
public static final String RISK_FACTOR = "riskFactor";

@DatabaseField(dataType = DataType.DATE_LONG)
private Date dateOfTravel;
@Enumerated(EnumType.STRING)
private TravelLocation placeOfTravel;
@DatabaseField(foreign = true, foreignAutoRefresh = true)
private RiskFactor riskFactor;

@Override
public String getI18nPrefix() {
return I18N_PREFIX;
}

public RiskFactor getRiskFactor() {
return riskFactor;
}
public void setRiskFactor(RiskFactor riskFactor) {
this.riskFactor = riskFactor;
}

public Date getDateOfTravel() {
return dateOfTravel;
}

public void setDateOfTravel(Date dateOfTravel) {
this.dateOfTravel = dateOfTravel;
}

public TravelLocation getPlaceOfTravel() {
return placeOfTravel;
}

public void setPlaceOfTravel(TravelLocation placeOfTravel) {
this.placeOfTravel = placeOfTravel;
}
}
Loading

0 comments on commit b80d3b3

Please sign in to comment.