package com.clinichelper.Entity;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Set;
import java.util.UUID;

/**
 * Created by eva_c on 9/25/2016.
 */
@Entity
@Table(name="records")
public class Record implements Serializable{
    // Attributes
    @Id
    private String recordId;
    @OneToOne
    private Patient patient;
    @OneToMany
    private Set<Surgery> surgeries;
    @OneToMany
    private Set<Consultation> consultations;
    @OneToMany
    private Set<History> history;

    // Constructors
    public Record(){

    }

    public Record(Patient patient, Set<Surgery> surgeries, Set<Consultation> consultations, Set<History>history) {
        this.setRecordId(patient.getPatientId() + "-R-" + UUID.randomUUID().toString().split("-")[0].toUpperCase());
        this.setPatient(patient);
        this.setSurgeries(surgeries);
        this.setConsultations(consultations);
        this.setHistory(history);
    }

    public String getRecordId() {
        return recordId;
    }

    public void setRecordId(String recordId) {
        this.recordId = recordId;
    }

    public Patient getPatient() {
        return patient;
    }

    public void setPatient(Patient patient) {
        this.patient = patient;
    }

    public Set<Surgery> getSurgeries() {
        return surgeries;
    }

    public void setSurgeries(Set<Surgery> surgeries) {
        this.surgeries = surgeries;
    }

    public Set<Consultation> getConsultations() {
        return consultations;
    }

    public void setConsultations(Set<Consultation> consultations) {
        this.consultations = consultations;
    }

    public Set<History> getHistory() {
        return history;
    }

    public void setHistory(Set<History> history) {
        this.history = history;
    }
}

@@ -157,16 +157,42 @@
 ayList;%0A
+import java.util.HashSet;%0A
 import j
@@ -692,86 +692,8 @@
 ient
-, Set%3CSurgery%3E surgeries, Set%3CConsultation%3E consultations, Set%3CHistory%3Ehistory
 ) %7B%0A
@@ -869,25 +869,31 @@
 rgeries(
-surgeries
+new HashSet%3C%3E()
 );%0A     
@@ -917,29 +917,31 @@
 tations(
-consultations
+new HashSet%3C%3E()
 );%0A     
@@ -959,23 +959,31 @@
 History(
-history
+new HashSet%3C%3E()
 );%0A    %7D

Refactor Record entity