Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- */
- package com.dxc.medxc.persistence.jpa.entities;
- import java.sql.Timestamp;
- import java.util.List;
- import java.util.Objects;
- import javax.persistence.Column;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.Id;
- import javax.persistence.JoinColumn;
- import javax.persistence.ManyToOne;
- import javax.persistence.OneToMany;
- import javax.persistence.OneToOne;
- import javax.persistence.Table;
- import com.dxc.medxc.persistence.model.Appointment;
- import com.dxc.medxc.persistence.model.Doctor;
- import com.dxc.medxc.persistence.model.Patient;
- import com.dxc.medxc.persistence.model.Record;
- import com.dxc.medxc.persistence.model.Specialty;
- import com.dxc.medxc.persistence.model.Status;
- import com.dxc.medxc.persistence.model.Test;
- /**
- * Appointment entity
- *
- * @author yyayya
- */
- @Entity
- @Table(name = "APPOINTMENT")
- // @NamedQuery(name="Test", query="SELECT c FROM APPOINTMENT c WHERE ")
- public class JpaAppointment implements Appointment {
- /*
- * APP_ID NUMBER (10) GENERATED BY DEFAULT AS IDENTITY, APP_DATE_TIME DATE NOT
- * NULL, STATUS_ID NUMBER (1) NOT NULL, PAT_ID NUMBER (10), SPEC_ID NUMBER (4),
- * DOC_NUM CHAR (10 CHAR) NOT NULL, PRIMARY KEY(APP_ID), FOREIGN KEY (STATUS_ID)
- * REFERENCES STATUS(STATUS_ID), FOREIGN KEY (PAT_ID) REFERENCES
- * PATIENT(PAT_ID), FOREIGN KEY (DOC_NUM) REFERENCES DOCTOR(DOC_NUM), FOREIGN
- * KEY (SPEC_ID) REFERENCES SPECIALTY(SPEC_ID)
- */
- @Id
- @GeneratedValue
- @Column(name = "APP_ID", nullable = false)
- private int id;
- @Column(name = "APP_DATE_TIME", nullable = false)
- private Timestamp date;
- @ManyToOne(targetEntity = JpaStatus.class)
- @JoinColumn(name = "STATUS_ID")
- private Status status;
- @ManyToOne(targetEntity = JpaSpecialty.class)
- @JoinColumn(name = "SPEC_ID")
- private Specialty specialty;
- @ManyToOne(targetEntity = JpaPatient.class)
- @JoinColumn(name = "PIN")
- private Patient patient;
- @ManyToOne(targetEntity = JpaDoctor.class)
- @JoinColumn(name = "DOC_NUM")
- private Doctor doctor;
- @OneToMany(targetEntity = JpaTest.class, mappedBy = "appointment")
- private List<Test> tests;
- @OneToOne(targetEntity = JpaRecord.class, mappedBy = "appointment")
- private Record record;
- /**
- * Needed by JPA
- */
- public JpaAppointment() {
- }
- /**
- * @param status
- * Status of the appointment
- * @param patient
- * The patient who scheduled the appointment
- * @param doctor
- * The doctor the appointment is scheduled with
- * @param date
- * Date of the appointment
- */
- public JpaAppointment(final Status status, final Patient patient, final Doctor doctor, final Timestamp date) {
- Objects.requireNonNull(status);
- Objects.requireNonNull(patient);
- Objects.requireNonNull(doctor);
- Objects.requireNonNull(date);
- this.status = status;
- this.patient = patient;
- this.doctor = doctor;
- this.date = (Timestamp) date.clone();
- }
- @Override
- public Status getStatus() {
- return status;
- }
- @Override
- public Patient getPIN() {
- return patient;
- }
- @Override
- public Doctor getDocNum() {
- return doctor;
- }
- @Override
- public Timestamp getDate() {
- return (Timestamp) date.clone();
- }
- @Override
- public int getId() {
- return id;
- }
- @Override
- public Patient getPatient() {
- return patient;
- }
- @Override
- public Specialty getSpecialty() {
- return specialty;
- }
- @Override
- public Doctor getDoctor() {
- return doctor;
- }
- @Override
- public List<Test> getTests() {
- return null;
- }
- @Override
- public Record getRecord() {
- return record;
- }
- @Override
- public boolean equals(final Object other) {
- if (this == other) {
- return true;
- }
- if (other == null) {
- return false;
- }
- if (this.getClass() != other.getClass()) {
- return false;
- }
- final JpaAppointment appointmentOther = (JpaAppointment) other;
- return this.id == appointmentOther.id;
- }
- @Override
- public int hashCode() {
- return Objects.hash(Integer.valueOf(this.id));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement