MedicalRecord.java
001 package com.bea.medrec.value;
002 
003 import java.io.Serializable;
004 import java.util.ArrayList;
005 import java.util.Iterator;
006 import java.util.List;
007 
008 /**
009  <p>Encapsulates patient's medical record summary.
010  * Includes List of abbreviated records and
011  * List of current and recent prescriptions.</p>
012  *
013  @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
014  */
015 public final class MedicalRecord implements Serializable {
016 
017   private Integer srcId;
018   private String srcName;
019   private Patient patient;
020   private List<Record> records;
021   private User user;
022 
023   public MedicalRecord() {
024   }
025 
026   public MedicalRecord(Integer srcId, String srcName) {
027     this.srcId = srcId;
028     this.srcName = srcName;
029   }
030 
031   public MedicalRecord(Integer srcId,
032                        String srcName,
033                        Patient patient,
034                        List<Record> records) {
035     this.srcId = srcId;
036     this.srcName = srcName;
037     this.patient = patient;
038     this.records = records;
039   }
040 
041   public MedicalRecord(Integer srcId,
042                        String srcName,
043                        Patient patient,
044                        List<Record> records,
045                        User user) {
046     this.srcId = srcId;
047     this.srcName = srcName;
048     this.patient = patient;
049     this.records = records;
050     this.user = user;
051   }
052 
053   public MedicalRecord(Patient patient, List<Record> records) {
054     this.patient = patient;
055     this.records = records;
056   }
057 
058   public Integer getSrcId() {
059     return this.srcId;
060   }
061 
062   public String getSrcName() {
063     return this.srcName;
064   }
065 
066   public Patient getPatient() {
067     return this.patient;
068   }
069 
070   public List<Record> getRecords() {
071     return this.records == null new ArrayList<Record>() this.records;
072   }
073 
074   public User getUser() {
075     return this.user;
076   }
077 
078   public void setSrcId(Integer srcId) {
079     this.srcId = srcId;
080   }
081 
082   public void setSrcName(String srcName) {
083     this.srcName = srcName;
084   }
085 
086   public void setPatient(Patient patient) {
087     this.patient = patient;
088   }
089 
090   public void setRecords(List<Record> records) {
091     this.records = records;
092   }
093 
094   public void setUser(User user) {
095     this.user = user;
096   }
097 
098   public void addRecord(Record record) {
099     if (records == nullrecords = new ArrayList<Record>();
100     records.add(record);
101   }
102 
103   public int numOfRecords() {
104     return (records != null ? records.size() 0);
105   }
106 
107   public String toString() {
108     StringBuffer str = new StringBuffer();
109     str.append("MedicalRecord [");
110     str.append("SrcId: "+srcId);
111     str.append(" | SrcName: "+srcName);
112     str.append(" | User: "+user.toString());
113     str.append(" | Patient: "+patient.toString());
114     str.append(" | Num of Records: "+getRecordCount());
115     if (numOfRecords() 0) {
116       Iterator patItr = records.iterator();
117       while (patItr.hasNext()) {
118         Record record = (RecordpatItr.next();
119         str.append(" | "+record.toString());
120       }
121     }
122     str.append("]");
123     return str.toString();
124   }
125 
126   private String getRecordCount() {
127     return (this.records == null "0" : String.valueOf(records.size()));
128   }
129 }