Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#13204 - RSV disease variants - add support for similar Customizable … #13219

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import de.symeda.sormas.api.contact.QuarantineType;
import de.symeda.sormas.api.infrastructure.facility.FacilityType;
import de.symeda.sormas.api.person.OccupationType;
import de.symeda.sormas.api.person.OccupationTypeConverter;
import de.symeda.sormas.api.person.Sex;
import de.symeda.sormas.api.sample.PathogenTestResultType;
import de.symeda.sormas.api.sample.PathogenTestType;
Expand All @@ -32,6 +33,7 @@
import de.symeda.sormas.api.utils.YesNoUnknown;

public class BAGExportCaseDto implements Serializable {

private Integer caseIdIsm;
private Long caseId;
private Long personId;
Expand Down Expand Up @@ -124,7 +126,7 @@ public BAGExportCaseDto(Integer caseIdIsm, Long caseId, Long personId,
String homeAddressStreet, String homeAddressHouseNumber, String homeAddressCity, String homeAddressPostalCode, String homeAddressCountry,
String phoneNumber, String mobileNumber, String emailAddress,
Sex sex, Integer birthdateDD, Integer birthdateMM, Integer birthdateYYYY,
OccupationType occupationType,
String occupationType,
boolean symptomatic, Date symptomOnsetDate,
String activityMappingYn,
Date contactTracingContactDate,
Expand All @@ -148,7 +150,7 @@ public BAGExportCaseDto(Integer caseIdIsm, Long caseId, Long personId,
this.emailAddress = emailAddress;
this.sex = sex;
this.birthDate = new BirthDateDto(birthdateDD, birthdateMM, birthdateYYYY);
this.occupationType = occupationType;
this.occupationType = new OccupationTypeConverter().convertToEntityAttribute(null, occupationType);
this.symptomatic = symptomatic ? YesNoUnknown.YES : YesNoUnknown.NO;
this.symptomOnsetDate = symptomOnsetDate;
this.activityMappingYn = activityMappingYn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import de.symeda.sormas.api.contact.QuarantineType;
import de.symeda.sormas.api.infrastructure.facility.FacilityType;
import de.symeda.sormas.api.person.OccupationType;
import de.symeda.sormas.api.person.OccupationTypeConverter;
import de.symeda.sormas.api.person.Sex;
import de.symeda.sormas.api.sample.PathogenTestResultType;
import de.symeda.sormas.api.sample.PathogenTestType;
Expand Down Expand Up @@ -91,7 +92,7 @@ public BAGExportContactDto(Long contactId, Long personId, String lastName, Strin
String homeAddressStreet, String homeAddressHouseNumber, String homeAddressCity, String homeAddressPostalCode,
String phoneNumber, String mobileNumber, Sex sex,
Integer birthdateDD, Integer birthdateMM, Integer birthdateYYYY,
OccupationType occupationType,
String occupationType,
QuarantineType quarantineType, String quarantineDetails,
Integer caseLinkCaseIdIsm, Long caseLinkCaseId, Date caseLinkContactDate,
Date startOfQuarantineDate, Date endOfQuarantineDate, EndOfQuarantineReason endOfQuarantineReason, String endOfQuarantineReasonDetails
Expand All @@ -112,7 +113,7 @@ public BAGExportContactDto(Long contactId, Long personId, String lastName, Strin
this.mobileNumber = mobileNumber;
this.sex = sex;
this.birthDate = new BirthDateDto(birthdateDD, birthdateMM, birthdateYYYY);
this.occupationType = occupationType;
this.occupationType = new OccupationTypeConverter().convertToEntityAttribute(null, occupationType);

this.quarantineType = quarantineType;
this.quarantineDetails = quarantineDetails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import de.symeda.sormas.api.contact.FollowUpStatus;
import de.symeda.sormas.api.contact.QuarantineType;
import de.symeda.sormas.api.disease.DiseaseVariant;
import de.symeda.sormas.api.disease.DiseaseVariantConverter;
import de.symeda.sormas.api.epidata.EpiDataDto;
import de.symeda.sormas.api.event.EventStatus;
import de.symeda.sormas.api.feature.FeatureType;
Expand All @@ -49,6 +50,7 @@
import de.symeda.sormas.api.person.BurialConductor;
import de.symeda.sormas.api.person.EducationType;
import de.symeda.sormas.api.person.OccupationType;
import de.symeda.sormas.api.person.OccupationTypeConverter;
import de.symeda.sormas.api.person.PersonDto;
import de.symeda.sormas.api.person.PresentCondition;
import de.symeda.sormas.api.person.Salutation;
Expand Down Expand Up @@ -362,7 +364,7 @@ public class CaseExportDto extends AbstractUuidDto implements IsCase {
@SuppressWarnings("unchecked")
public CaseExportDto(long id, long personId, Double personAddressLatitude, Double personAddressLongitude, Float personAddressLatLonAcc, long epiDataId, long symptomsId,
long hospitalizationId, long healthConditionsId, String uuid, String epidNumber,
Disease disease, DiseaseVariant diseaseVariant, String diseaseDetails, String diseaseVariantDetails,
Disease disease, String diseaseVariant, String diseaseDetails, String diseaseVariantDetails,
String personUuid, String firstName, String lastName, Salutation salutation, String otherSalutation, Sex sex, YesNoUnknown pregnant,
Integer approximateAge, ApproximateAgeType approximateAgeType, Integer birthdateDD, Integer birthdateMM,
Integer birthdateYYYY, Date reportDate, String region, String district, String community,
Expand All @@ -389,7 +391,7 @@ public CaseExportDto(long id, long personId, Double personAddressLatitude, Doubl
String addressRegion, String addressDistrict, String addressCommunity, String city, String street, String houseNumber, String additionalInformation, String postalCode,
String facility, String facilityUuid, String facilityDetails,
String phone, String phoneOwner, String emailAddress, String otherContactDetails, EducationType educationType, String educationDetails,
OccupationType occupationType, String occupationDetails, ArmedForcesRelationType ArmedForcesRelationType, YesNoUnknown contactWithSourceCaseKnown,
String occupationType, String occupationDetails, ArmedForcesRelationType ArmedForcesRelationType, YesNoUnknown contactWithSourceCaseKnown,
//Date onsetDate,
VaccinationStatus vaccinationStatus, YesNoUnknown postpartum, Trimester trimester,
long eventCount, Long prescriptionCount, Long treatmentCount, Long clinicalVisitCount,
Expand Down Expand Up @@ -419,7 +421,7 @@ public CaseExportDto(long id, long personId, Double personAddressLatitude, Doubl
this.armedForcesRelationType = ArmedForcesRelationType;
this.disease = disease;
this.diseaseDetails = diseaseDetails;
this.diseaseVariant = diseaseVariant;
this.diseaseVariant = new DiseaseVariantConverter().convertToEntityAttribute(disease, diseaseVariant);
this.diseaseVariantDetails = diseaseVariantDetails;
this.personUuid = personUuid;
this.firstName = firstName;
Expand Down Expand Up @@ -501,7 +503,7 @@ public CaseExportDto(long id, long personId, Double personAddressLatitude, Doubl
this.otherContactDetails = otherContactDetails;
this.educationType = educationType;
this.educationDetails = educationDetails;
this.occupationType = occupationType;
this.occupationType = new OccupationTypeConverter().convertToEntityAttribute(null, occupationType);
this.occupationDetails = occupationDetails;
this.contactWithSourceCaseKnown = contactWithSourceCaseKnown;
// this.onsetDate = onsetDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class CaseIndexDetailedDto extends CaseIndexDto {

//@formatter:off
public CaseIndexDetailedDto(long id, String uuid, String epidNumber, String externalID, String externalToken, String internalToken,String caseReferenceNumber, String personUuid, String personFirstName, String personLastName,
Disease disease, DiseaseVariant diseaseVariant, String diseaseDetails, CaseClassification caseClassification, InvestigationStatus investigationStatus,
Disease disease, String diseaseVariant, String diseaseDetails, CaseClassification caseClassification, InvestigationStatus investigationStatus,
PresentCondition presentCondition, Date reportDate, Date creationDate,
String regionUuid, String districtUuid,
String healthFacilityUuid, String healthFacilityName, String healthFacilityDetails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import de.symeda.sormas.api.common.DeletionReason;
import de.symeda.sormas.api.contact.FollowUpStatus;
import de.symeda.sormas.api.disease.DiseaseVariant;
import de.symeda.sormas.api.disease.DiseaseVariantConverter;
import de.symeda.sormas.api.infrastructure.InfrastructureHelper;
import de.symeda.sormas.api.infrastructure.facility.FacilityHelper;
import de.symeda.sormas.api.person.ApproximateAgeType;
Expand Down Expand Up @@ -141,7 +142,7 @@ public class CaseIndexDto extends PseudonymizableIndexDto implements MergeableIn

//@formatter:off
public CaseIndexDto(long id, String uuid, String epidNumber, String externalID, String externalToken, String internalToken, String caseReferenceNumber, String personUuid, String personFirstName, String personLastName, Disease disease,
DiseaseVariant diseaseVariant, String diseaseDetails, CaseClassification caseClassification, InvestigationStatus investigationStatus,
String diseaseVariant, String diseaseDetails, CaseClassification caseClassification, InvestigationStatus investigationStatus,
PresentCondition presentCondition, Date reportDate, Date creationDate, String regionUuid,
String districtUuid, String healthFacilityUuid, String healthFacilityName, String healthFacilityDetails,
String pointOfEntryUuid, String pointOfEntryName, String pointOfEntryDetails, String surveillanceOfficerUuid, CaseOutcome outcome,
Expand All @@ -166,7 +167,7 @@ public CaseIndexDto(long id, String uuid, String epidNumber, String externalID,
this.personFirstName = personFirstName;
this.personLastName = personLastName;
this.disease = disease;
this.diseaseVariant = diseaseVariant;
this.diseaseVariant = new DiseaseVariantConverter().convertToEntityAttribute(disease, diseaseVariant);
this.diseaseDetails = diseaseDetails;
this.caseClassification = caseClassification;
this.investigationStatus = investigationStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CaseMergeIndexDto extends CaseIndexDto {
//@formatter:off
public CaseMergeIndexDto(
long id, String uuid, String epidNumber, String externalID, String externalToken, String internalToken, String caseReferenceNumber, String personUuid, String personFirstName, String personLastName, Disease disease,
DiseaseVariant diseaseVariant, String diseaseDetails, CaseClassification caseClassification, InvestigationStatus investigationStatus,
String diseaseVariant, String diseaseDetails, CaseClassification caseClassification, InvestigationStatus investigationStatus,
PresentCondition presentCondition, Date reportDate, Date creationDate, String regionUuid,
String districtUuid, String healthFacilityUuid, String healthFacilityName, String healthFacilityDetails,
String pointOfEntryUuid, String pointOfEntryName, String pointOfEntryDetails, String surveillanceOfficerUuid, CaseOutcome outcome,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

import java.util.Date;

import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.disease.DiseaseVariant;
import de.symeda.sormas.api.disease.DiseaseVariantConverter;
import de.symeda.sormas.api.uuid.AbstractUuidDto;

public class PreviousCaseDto extends AbstractUuidDto {
Expand All @@ -29,11 +31,11 @@ public class PreviousCaseDto extends AbstractUuidDto {
private final DiseaseVariant diseaseVariant;
private final Date onsetDate;

public PreviousCaseDto(String uuid, Date reportDate, String externalToken, DiseaseVariant diseaseVariant, Date onsetDate) {
public PreviousCaseDto(String uuid, Date reportDate, String externalToken, Disease disease, String diseaseVariant, Date onsetDate) {
super(uuid);
this.reportDate = reportDate;
this.externalToken = externalToken;
this.diseaseVariant = diseaseVariant;
this.diseaseVariant = new DiseaseVariantConverter().convertToEntityAttribute(disease, diseaseVariant);
this.onsetDate = onsetDate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import de.symeda.sormas.api.person.ApproximateAgeType.ApproximateAgeHelper;
import de.symeda.sormas.api.person.ArmedForcesRelationType;
import de.symeda.sormas.api.person.OccupationType;
import de.symeda.sormas.api.person.OccupationTypeConverter;
import de.symeda.sormas.api.person.PersonDto;
import de.symeda.sormas.api.person.PresentCondition;
import de.symeda.sormas.api.person.Salutation;
Expand Down Expand Up @@ -259,7 +260,7 @@ public ContactExportDto(long id, long personId, String uuid, String sourceCaseUu
PresentCondition presentCondition, Date deathDate,
String addressRegion, String addressDistrict, String addressCommunity, String city, String street, String houseNumber, String additionalInformation, String postalCode,
String facility, String facilityUuid, String facilityDetails,
String phone, String phoneOwner, String emailAddress, String otherContactDetails, OccupationType occupationType, String occupationDetails, ArmedForcesRelationType armedForcesRelationType,
String phone, String phoneOwner, String emailAddress, String otherContactDetails, String occupationType, String occupationDetails, ArmedForcesRelationType armedForcesRelationType,
String region, String district, String community,
long epiDataId, YesNoUnknown contactWithSourceCaseKnown, YesNoUnknown returningTraveler,
VaccinationStatus vaccinationStatus, String externalID, String externalToken, String internalToken, String caseReferenceNumber,
Expand Down Expand Up @@ -337,7 +338,7 @@ public ContactExportDto(long id, long personId, String uuid, String sourceCaseUu
// this.otherContactDetails += this.otherContactDetails.equals("") ? otherContactDetail : ", " + otherContactDetail;
// }
this.otherContactDetails = otherContactDetails;
this.occupationType = occupationType;
this.occupationType = new OccupationTypeConverter().convertToEntityAttribute(null, occupationType);
this.occupationDetails = occupationDetails;
this.armedForcesRelationType = armedForcesRelationType;
this.region = region;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package de.symeda.sormas.backend.customizableenum;
package de.symeda.sormas.api.customizableenum;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.AttributeConverter;

import org.apache.commons.lang3.StringUtils;

import de.symeda.sormas.api.customizableenum.CustomizableEnum;
import de.symeda.sormas.api.customizableenum.CustomizableEnumFacade;
import de.symeda.sormas.api.customizableenum.CustomizableEnumType;
import de.symeda.sormas.api.Disease;

/**
* JPA Converter that converts a JSON String stored in the database to an instance of {@link CustomizableEnum} and vice versa.
Expand All @@ -36,7 +33,7 @@
* @param <T>
* The specific extension of {@link CustomizableEnum} for type safety
*/
public abstract class CustomizableEnumConverter<T extends CustomizableEnum> implements AttributeConverter<T, String> {
public abstract class CustomizableEnumConverter<T extends CustomizableEnum> {

private final Class<T> enumClass;
private CustomizableEnumFacade customizableEnumFacade;
Expand All @@ -45,13 +42,11 @@ public CustomizableEnumConverter(Class<T> enumClass) {
this.enumClass = enumClass;
}

@Override
public String convertToDatabaseColumn(T enumValue) {
return enumValue != null ? enumValue.getValue() : null;
}

@Override
public T convertToEntityAttribute(String enumString) {
public T convertToEntityAttribute(Disease disease, String enumString) {
if (StringUtils.isBlank(enumString)) {
return null;
}
Expand All @@ -66,7 +61,11 @@ public T convertToEntityAttribute(String enumString) {
throw new RuntimeException("No CustomizableEnumType for given enumClass " + enumClass + "found");
}

return customizableEnumFacade.getEnumValue(CustomizableEnumType.getByEnumClass(enumClass), enumString);
T enumValue = customizableEnumFacade.getEnumValue(enumType, disease, enumString);
if (enumValue == null && disease != null) {
enumValue = customizableEnumFacade.getEnumValue(enumType, null, enumString);
}
return enumValue;
} catch (NamingException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public interface CustomizableEnumFacade
* The specific extension of {@link CustomizableEnum} for type safety
* @return The enum instance containing its value, internationalized caption, and optional properties
*/
<T extends CustomizableEnum> T getEnumValue(CustomizableEnumType type, String value);
<T extends CustomizableEnum> T getEnumValue(CustomizableEnumType type, Disease disease, String value);

/**
* Works similar to the {@link CustomizableEnumFacade#getEnumValues(CustomizableEnumType, Disease)}, but looks up a specific value.
* Unlike the {@link CustomizableEnumFacade#getEnumValue(CustomizableEnumType, String)}, this method does not throw a RuntimeException
* Unlike the {@link CustomizableEnumFacade#getEnumValue(CustomizableEnumType, Disease, String)}, this method does not throw a RuntimeException
* when an enum can not be found.
*
* @param type
Expand Down Expand Up @@ -106,7 +106,7 @@ public interface CustomizableEnumFacade

/**
* Clears the caches and reloads the customizable enum values from the database. Does not load enum values by language
* or disease as those are retrieved on demand by using {@link #getEnumValue(CustomizableEnumType, String)} and
* or disease as those are retrieved on demand by using {@link #getEnumValue(CustomizableEnumType, Disease, String)} and
* {@link #getEnumValues(CustomizableEnumType, Disease)}. Exposed to this facade to allow reloading the caches without
* having to restart the server.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package de.symeda.sormas.backend.disease;
package de.symeda.sormas.api.disease;

import de.symeda.sormas.api.disease.DiseaseVariant;
import de.symeda.sormas.backend.customizableenum.CustomizableEnumConverter;
import de.symeda.sormas.api.customizableenum.CustomizableEnumConverter;

public class DiseaseVariantConverter extends CustomizableEnumConverter<DiseaseVariant> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package de.symeda.sormas.backend.disease;
package de.symeda.sormas.api.disease;

import de.symeda.sormas.api.environment.environmentsample.Pathogen;
import de.symeda.sormas.backend.customizableenum.CustomizableEnumConverter;
import de.symeda.sormas.api.customizableenum.CustomizableEnumConverter;

public class PathogenConverter extends CustomizableEnumConverter<Pathogen> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import de.symeda.sormas.api.action.ActionPriority;
import de.symeda.sormas.api.action.ActionStatus;
import de.symeda.sormas.api.disease.DiseaseVariant;
import de.symeda.sormas.api.disease.DiseaseVariantConverter;
import de.symeda.sormas.api.importexport.format.ExportFormat;
import de.symeda.sormas.api.importexport.format.ImportExportFormat;
import de.symeda.sormas.api.user.UserReferenceDto;
Expand Down Expand Up @@ -64,7 +65,7 @@ public EventActionExportDto(
String eventUuid,
String eventTitle,
Disease eventDisease,
DiseaseVariant eventDiseaseVariant,
String eventDiseaseVariant,
String eventDiseaseDetails,
String eventDesc,
EventIdentificationSource eventIdentificationSource,
Expand Down Expand Up @@ -98,7 +99,7 @@ public EventActionExportDto(
this.eventUuid = eventUuid;
this.eventTitle = eventTitle;
this.eventDisease = eventDisease;
this.eventDiseaseVariant = eventDiseaseVariant;
this.eventDiseaseVariant = new DiseaseVariantConverter().convertToEntityAttribute(eventDisease, eventDiseaseVariant);
this.eventDiseaseDetails = eventDiseaseDetails;
this.eventDesc = eventDesc;
this.eventIdentificationSource = eventIdentificationSource;
Expand Down
Loading
Loading