Commit d6bde937 authored by Javier Tomás Acín's avatar Javier Tomás Acín
Browse files

Corrección de errores al refactorizar la librería

parent ce8d3a3f
......@@ -10,23 +10,24 @@ import es.mdef.mipediatra.models.PutModel;
import es.mdef.mipediatra.models.consultation.*;
import es.mdef.mipediatra.repositories.MeasurementRepository;
import es.mdef.mipediatra.services.AssemblerService;
import jakarta.persistence.EntityManager;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
@Component
@Log4j2
public class ConsultationAssembler extends AssemblerService<ConsultationEntity, ConsultationModel, ConsultationPostModel, PutModel, ListModel> {
private final MeasurementAssembler measurementAssembler;
private final MeasurementRepository measurementRepository;
private final EntityManager entityManager;
public ConsultationAssembler(MeasurementAssembler measurementAssembler, MeasurementRepository measurementRepository, EntityManager entityManager) {
public ConsultationAssembler(MeasurementAssembler measurementAssembler, MeasurementRepository measurementRepository) {
super(() -> linkTo(methodOn(ConsultationsController.class).getAll()).withSelfRel());
this.measurementAssembler = measurementAssembler;
this.measurementRepository = measurementRepository;
this.entityManager = entityManager;
}
@Override
......@@ -94,7 +95,10 @@ public class ConsultationAssembler extends AssemblerService<ConsultationEntity,
EmergencyEntity emergency = new EmergencyEntity();
emergency.setDiagnosis(model.getDiagnosis());
emergency.setTreatment(model.getTreatment());
emergency.setSymptoms(model.getSymptoms());
emergency.setSymptoms(new HashSet<>(model.getSymptoms()));
emergency.getSymptoms().forEach(e -> log.info(e.toString()));
consultation = emergency;
}
......
......@@ -25,7 +25,6 @@ public class MeasurementAssembler extends AssemblerService<MeasurementEntity, Me
measurementModel.setHeight(measurement.getHeight());
measurementModel.setWeight(measurement.getWeight());
measurementModel.add(linkTo(methodOn(MeasurementsController.class).getById(measurement.getId())).withSelfRel());
return measurementModel;
}
......@@ -36,7 +35,6 @@ public class MeasurementAssembler extends AssemblerService<MeasurementEntity, Me
measurementModel.setHeight(measurement.getHeight());
measurementModel.setWeight(measurement.getWeight());
measurementModel.add(linkTo(methodOn(MeasurementsController.class).getById(measurement.getId())).withSelfRel());
return measurementModel;
}
......
......@@ -26,4 +26,4 @@ public class VaccinesPersonsController implements ControllerService<VaccinesPers
public CrudService<VaccinesPersonsEntity, VaccinesPersonsModel, VaccinesPersonsPostModel, VaccinesPersonsPutModel, VaccinesPersonsListModel> getService() {
return vaccinesPersonsService;
}
}
}
\ No newline at end of file
......@@ -11,7 +11,6 @@ import java.util.Set;
@EqualsAndHashCode(callSuper = true)
@Data
public class EmergencyEntity extends ConsultationEntity implements IEmergency {
private long id;
private String diagnosis;
private String treatment;
private Set<ISymptom> symptoms = new HashSet<>();
......
......@@ -8,7 +8,6 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class RegularVisitEntity extends ConsultationEntity implements IRegularVisit {
private long id;
private IMeasurement measurement;
@Override
......
package es.mdef.mipediatra.models.autonomous_community;
import es.mdef.mipediatra.models.ListModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
@Relation(collectionRelation = "autonomous_communities")
@EqualsAndHashCode(callSuper = true)
@Data
public class AutonomousCommunityListModel extends ListModel {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
\ No newline at end of file
package es.mdef.mipediatra.models.autonomous_community;
import es.mdef.mipediatra.models.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
@Relation(itemRelation = "autonomous_community")
@EqualsAndHashCode(callSuper = true)
@Data
public class AutonomousCommunityModel extends Model {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package es.mdef.mipediatra.models.autonomous_community;
import es.mdef.mipediatra.models.PostModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
@Relation(itemRelation = "autonomous_community")
@EqualsAndHashCode(callSuper = true)
@Data
public class AutonomousCommunityPostModel extends PostModel {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package es.mdef.mipediatra.models.autonomous_community;
import es.mdef.mipediatra.models.PutModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
@Relation(itemRelation = "autonomous_community")
@EqualsAndHashCode(callSuper = true)
@Data
public class AutonomousCommunityPutModel extends PutModel {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
\ No newline at end of file
......@@ -2,40 +2,20 @@ package es.mdef.mipediatra.models.consultation;
import es.mdef.mipediatra.constants.ConsultationType;
import es.mdef.mipediatra.models.ListModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
import java.time.ZonedDateTime;
@Relation(collectionRelation = "consultations")
@EqualsAndHashCode(callSuper = true)
@Data
public class ConsultationListModel extends ListModel {
private String comments;
private ZonedDateTime date;
private String specialist;
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public ZonedDateTime getDate() {
return date;
}
public void setDate(ZonedDateTime date) {
this.date = date;
}
public String getSpecialist() {
return specialist;
}
public void setSpecialist(String specialist) {
this.specialist = specialist;
}
public ConsultationType getType() {
return null;
}
......
......@@ -2,11 +2,15 @@ package es.mdef.mipediatra.models.consultation;
import es.mdef.mipediatra.constants.ConsultationType;
import es.mdef.mipediatra.models.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
import java.time.ZonedDateTime;
@Relation(itemRelation = "consultation")
@EqualsAndHashCode(callSuper = true)
@Data
public class ConsultationModel extends Model {
private String center;
private String comments;
......@@ -16,36 +20,4 @@ public class ConsultationModel extends Model {
public ConsultationType getType() {
return null;
}
public String getCenter() {
return center;
}
public void setCenter(String center) {
this.center = center;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public String getSpecialist() {
return specialist;
}
public void setSpecialist(String specialist) {
this.specialist = specialist;
}
public ZonedDateTime getDate() {
return date;
}
public void setDate(ZonedDateTime date) {
this.date = date;
}
}
......@@ -3,14 +3,16 @@ package es.mdef.mipediatra.models.consultation;
import es.mdef.mipediatra.constants.ConsultationType;
import es.mdef.mipediatra.entities.PatientEntity;
import es.mdef.mipediatra.entities.SymptomEntity;
import es.mdef.mipediatra.mappers.SymptomMapper;
import es.mdef.mipediatra.models.PostModel;
import es.mdef.mipediatra.models.measurement.MeasurementPostModel;
import es.mdef.mipediatralib.interfaces.ISymptom;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.ZonedDateTime;
import java.util.Set;
@EqualsAndHashCode(callSuper = true)
@Data
public class ConsultationPostModel extends PostModel {
private ConsultationType type;
private String center;
......@@ -22,84 +24,4 @@ public class ConsultationPostModel extends PostModel {
private String diagnosis;
private String treatment;
private Set<SymptomEntity> symptoms;
public ConsultationType getType() {
return type;
}
public void setType(ConsultationType type) {
this.type = type;
}
public String getCenter() {
return center;
}
public void setCenter(String center) {
this.center = center;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public String getSpecialist() {
return specialist;
}
public void setSpecialist(String specialist) {
this.specialist = specialist;
}
public ZonedDateTime getDate() {
return date;
}
public void setDate(ZonedDateTime date) {
this.date = date;
}
public PatientEntity getPatient() {
return patient;
}
public void setPatient(PatientEntity patient) {
this.patient = patient;
}
public MeasurementPostModel getMeasurement() {
return measurement;
}
public void setMeasurement(MeasurementPostModel measurement) {
this.measurement = measurement;
}
public String getDiagnosis() {
return diagnosis;
}
public void setDiagnosis(String diagnosis) {
this.diagnosis = diagnosis;
}
public String getTreatment() {
return treatment;
}
public void setTreatment(String treatment) {
this.treatment = treatment;
}
public Set<ISymptom> getSymptoms() {
return SymptomMapper.INSTANCE.toModel(symptoms);
}
public void setSymptoms(Set<SymptomEntity> symptoms) {
this.symptoms = symptoms;
}
}
package es.mdef.mipediatra.models.consultation;
import es.mdef.mipediatra.constants.ConsultationType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
@Relation(itemRelation = "emergency")
@EqualsAndHashCode(callSuper = true)
@Data
public class EmergencyModel extends ConsultationModel {
private String diagnosis;
private String treatment;
......@@ -12,20 +16,4 @@ public class EmergencyModel extends ConsultationModel {
public ConsultationType getType() {
return ConsultationType.Emergency;
}
public String getTreatment() {
return treatment;
}
public void setTreatment(String treatment) {
this.treatment = treatment;
}
public String getDiagnosis() {
return diagnosis;
}
public void setDiagnosis(String diagnosis) {
this.diagnosis = diagnosis;
}
}
......@@ -2,9 +2,13 @@ package es.mdef.mipediatra.models.consultation;
import es.mdef.mipediatra.constants.ConsultationType;
import es.mdef.mipediatra.models.measurement.MeasurementModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
@Relation(itemRelation = "regularVisit")
@EqualsAndHashCode(callSuper = true)
@Data
public class RegularVisitModel extends ConsultationModel {
private MeasurementModel measurement;
......@@ -12,12 +16,4 @@ public class RegularVisitModel extends ConsultationModel {
public ConsultationType getType() {
return ConsultationType.RegularVisit;
}
public MeasurementModel getMeasurement() {
return measurement;
}
public void setMeasurement(MeasurementModel measurement) {
this.measurement = measurement;
}
}
package es.mdef.mipediatra.models.file;
import es.mdef.mipediatra.models.ListModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
@Relation(collectionRelation = "files")
@EqualsAndHashCode(callSuper = true)
@Data
public class FileListModel extends ListModel {
private String name;
private Long size;
private byte[] data;
private String type;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getSize() {
return size;
}
public void setSize(Long size) {
this.size = size;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package es.mdef.mipediatra.models.file;
import es.mdef.mipediatra.models.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
@Relation(itemRelation = "file")
@EqualsAndHashCode(callSuper = true)
@Data
public class FileModel extends Model {
private String name;
private Long size;
private byte[] data;
private String type;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getSize() {
return size;
}
public void setSize(Long size) {
this.size = size;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package es.mdef.mipediatra.models.measurement;
import es.mdef.mipediatra.models.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
@Relation(itemRelation = "measurement")
@EqualsAndHashCode(callSuper = true)
@Data
public class MeasurementModel extends Model {
private double cranialDiameter;
private double height;
private double weight;
public double getCranialDiameter() {
return cranialDiameter;
}
public void setCranialDiameter(double cranialDiameter) {
this.cranialDiameter = cranialDiameter;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
}
package es.mdef.mipediatra.models.measurement;
import es.mdef.mipediatra.models.PostModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class MeasurementPostModel extends PostModel {
private double cranialDiameter;
private double height;
private double weight;
public double getCranialDiameter() {
return cranialDiameter;
}
public void setCranialDiameter(double cranialDiameter) {
this.cranialDiameter = cranialDiameter;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
}
package es.mdef.mipediatra.models.measurement;
import es.mdef.mipediatra.models.ListModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
@Relation(collectionRelation = "measurements")
@EqualsAndHashCode(callSuper = true)
@Data
public class MeasurementsListModel extends ListModel {
private double cranialDiameter;
private double height;
private double weight;
public double getCranialDiameter() {
return cranialDiameter;
}
public void setCranialDiameter(double cranialDiameter) {
this.cranialDiameter = cranialDiameter;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
}
......@@ -2,26 +2,14 @@ package es.mdef.mipediatra.models.patient;
import es.mdef.mipediatra.models.ListModel;
import es.mdef.mipediatra.models.file.FileModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.server.core.Relation;
@Relation(collectionRelation = "patients")
@EqualsAndHashCode(callSuper = true)
@Data
public class PatientListModel extends ListModel {
private String comments;
private FileModel photo;
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public FileModel getPhoto() {
return photo;
}
public void setPhoto(FileModel photo) {
this.photo = photo;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment