From ad69b8ebb4a1820dfcffabae41feeebc59f64d63 Mon Sep 17 00:00:00 2001 From: Alejandro Linares Amado Date: Sun, 1 Dec 2019 09:01:39 +0100 Subject: [PATCH] Componente VisitJPA --- 1.sources/MyHealth/src/jpa/VisitJPA.java | 109 +++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 1.sources/MyHealth/src/jpa/VisitJPA.java diff --git a/1.sources/MyHealth/src/jpa/VisitJPA.java b/1.sources/MyHealth/src/jpa/VisitJPA.java new file mode 100644 index 0000000..db42528 --- /dev/null +++ b/1.sources/MyHealth/src/jpa/VisitJPA.java @@ -0,0 +1,109 @@ +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; + + /** + * 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 getPatients() { + return patients; + } + + public void setPatients(Collection patients) { + this.patients = patients; + } + + @ManyToOne + @JoinColumn (name="PrimaryHealthCareCenterId") + public PrimaryHealthCareCenterJPA getPrimaryHealthCareCenter() { + return primaryHealthCareCenter; + } + public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterJPA center) { + this.primaryHealthCareCenter = center; + } +}