124 lines
2.5 KiB
Java
124 lines
2.5 KiB
Java
package jpa;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.Collection;
|
|
import java.util.Date;
|
|
|
|
import javax.persistence.CascadeType;
|
|
import javax.persistence.Entity;
|
|
import javax.persistence.FetchType;
|
|
import javax.persistence.GeneratedValue;
|
|
import javax.persistence.GenerationType;
|
|
import javax.persistence.Id;
|
|
import javax.persistence.JoinColumn;
|
|
import javax.persistence.ManyToOne;
|
|
import javax.persistence.OneToMany;
|
|
import javax.persistence.Table;
|
|
|
|
/**
|
|
*
|
|
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
|
*
|
|
*/
|
|
@Entity
|
|
@Table(name = "MyHealth.Visit")
|
|
public class VisitJPA implements Serializable {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
@Id
|
|
private Integer id;
|
|
private Date date;
|
|
private String time;
|
|
private String observations;
|
|
private String result;
|
|
@ManyToOne
|
|
@JoinColumn (name="FamilyDoctorId")
|
|
private FamilyDoctorJPA familyDoctor;
|
|
@ManyToOne
|
|
@JoinColumn (name="PatientId")
|
|
private PatientJPA patient;
|
|
|
|
|
|
/**
|
|
* Class constructor methods
|
|
*/
|
|
public VistitJPA() {
|
|
super();
|
|
}
|
|
|
|
public VisitJPA(Integer id, Date date, Time time, String observations, String result) {
|
|
this.id = id;
|
|
this.date=date;
|
|
this.time = time;
|
|
this.observations = observations;
|
|
this.result = result;
|
|
}
|
|
|
|
@Id
|
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
|
public Integer getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(Integer value) {
|
|
this.id = value;
|
|
}
|
|
|
|
public String getDate() {
|
|
return date;
|
|
}
|
|
|
|
public void setDate(String value) {
|
|
this.date = value;
|
|
}
|
|
|
|
public String getTime() {
|
|
return time;
|
|
}
|
|
|
|
public void setTime(String value) {
|
|
this.time = value;
|
|
}
|
|
|
|
public String getObservations() {
|
|
return observations;
|
|
}
|
|
|
|
public void setObservations(String observation) {
|
|
this.observations = observations;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Metodos para get/set de relaciones (pacientes)
|
|
* @return
|
|
*/
|
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
|
@JoinColumn(name = "FamilyDoctorId")
|
|
public Collection<PatientJPA> getPatients() {
|
|
return patients;
|
|
}
|
|
|
|
public void setPatients(Collection<PatientJPA> patients) {
|
|
this.patients = patients;
|
|
}
|
|
/**
|
|
* Methods get/set persistent relationships
|
|
*/
|
|
public FamilyDoctorJPA getFamilyDoctor() {
|
|
return familyDoctor;
|
|
}
|
|
public void setFamilyDoctor(FamilyDoctorJPA familyDoc) {
|
|
this.familyDoctor = familyDoc;
|
|
}
|
|
public PatientJPA getPatient() {
|
|
return patient;
|
|
}
|
|
public void setPatient(PatientJPA pat) {
|
|
this.patient=pat;
|
|
}
|
|
|
|
}
|