Record.java
001 package com.bea.medrec.value;
002 
003 import java.util.Calendar;
004 
005 /**
006  <p>Represents information about a record.  This includes
007  * the record's vital signs.</p>
008  *
009  @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
010  */
011 public final class Record extends BaseVO {
012 
013   // Attributes
014   private Integer patientId;
015   private Calendar date;
016   private String symptoms;
017   private String diagnosis;
018   private String notes;
019   private Physician physician;
020   private VitalSigns vitalSigns;
021   private Prescription[] prescriptions;
022 
023   // Constructors
024   public Record() {
025   }
026 
027   public Record(String patientId,
028                 Calendar date,
029                 String symptoms,
030                 String diagnosis,
031                 String notes,
032                 Physician physician,
033                 VitalSigns vitalSigns,
034                 Prescription[] prescriptions) {
035     this.patientId = str2Integer(patientId);
036     this.date = date;
037     this.symptoms = symptoms;
038     this.diagnosis = diagnosis;
039     this.notes = notes;
040     this.physician = physician;
041     this.vitalSigns = vitalSigns;
042     this.prescriptions = prescriptions;
043   }
044 
045   public Record(Integer id,
046                 Integer patientId,
047                 Calendar date,
048                 String symptoms,
049                 String diagnosis,
050                 String notes,
051                 Physician physician,
052                 VitalSigns vitalSigns,
053                 Prescription[] prescriptions) {
054     super.setId(id);
055     this.patientId = patientId;
056     this.date = date;
057     this.symptoms = symptoms;
058     this.diagnosis = diagnosis;
059     this.notes = notes;
060     this.physician = physician;
061     this.vitalSigns = vitalSigns;
062     this.prescriptions = prescriptions;
063   }
064 
065   // Getters
066   public Integer getPatientId() {
067     return this.patientId;
068   }
069 
070   public Calendar getDate() {
071     return this.date;
072   }
073 
074   public String getSymptoms() {
075     return this.symptoms;
076   }
077 
078   public String getDiagnosis() {
079     return this.diagnosis;
080   }
081 
082   public String getNotes() {
083     return this.notes;
084   }
085 
086   public Physician getPhysician() {
087     return this.physician;
088   }
089 
090   public VitalSigns getVitalSigns() {
091     return this.vitalSigns;
092   }
093 
094   public Prescription[] getPrescriptions() {
095     return (this.prescriptions == null new Prescription[0this.prescriptions);
096   }
097 
098   public Integer getPhysicianId() {
099     return getPhysician().getId();
100   }
101 
102   public String getPhysicianName() {
103     return this.physician.getFirstName()+" "+this.physician.getMiddleName() +
104         " "+this.physician.getLastName();
105   }
106 
107   // Setters
108   public void setPatientId(Integer pPatientId) {
109     this.patientId = pPatientId;
110   }
111 
112   public void setDate(Calendar pDate) {
113     this.date = pDate;
114   }
115 
116   public void setSymptoms(String pSymptoms) {
117     this.symptoms = pSymptoms;
118   }
119 
120   public void setDiagnosis(String pDiagnosis) {
121     this.diagnosis = pDiagnosis;
122   }
123 
124   public void setNotes(String pNotes) {
125     this.notes = pNotes;
126   }
127 
128   public void setPhysician(Physician pPhysician) {
129     this.physician = pPhysician;
130   }
131 
132   public void setVitalSigns(VitalSigns pVitalSigns) {
133     this.vitalSigns = pVitalSigns;
134   }
135 
136   public void setPrescriptions(Prescription[] pPrescriptionVOs) {
137     this.prescriptions = pPrescriptionVOs;
138   }
139 
140   public int getNumOfPrescriptions() {
141     return (this.prescriptions == null this.prescriptions.length);
142   }
143 
144   // Utitily
145   public String toString() {
146     StringBuffer str = new StringBuffer();
147     str.append("RECORD [Id: "+super.getId());
148     str.append(" | PatId: "+toStr(this.patientId));
149     str.append(" | DOB: " +
150         (this.date == null "null" : getDisplayDate(this.date)));
151     str.append(" | Syms: "+this.symptoms);
152     str.append(" | Diag: "+this.diagnosis);
153     str.append(" | Notes: "+this.notes);
154     str.append(" | " +
155         (this.physician == null "PHYSICIAN: [null]" this.physician.toString()));
156     str.append(" | " +
157         (this.vitalSigns == null "VITALS: [null]" this.vitalSigns.toString()));
158     str.append(" | "+prescriptionsToString());
159     str.append("]");
160 
161     return str.toString();
162   }
163 
164   private String prescriptionsToString() {
165     StringBuffer str = new StringBuffer();
166     if (getNumOfPrescriptions() 0) {
167       str.append(" Num of prescriptions: "+getNumOfPrescriptions()+" |");
168       for (int i = 0; i < getNumOfPrescriptions(); i++) {
169         str.append(" "+(prescriptions[i].toString()));
170       }
171     else {
172       str.append("PRESCRIPTIONS: [null]");
173     }
174     return str.toString();
175   }
176 
177 }