Changeset 4358 for openmrs/trunk/src/api/org/openmrs/PatientState.java
- Timestamp:
- 05/24/08 14:37:02 (8 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs/trunk/src/api/org/openmrs/PatientState.java
r4245 r4358 18 18 import org.openmrs.util.OpenmrsUtil; 19 19 20 public class PatientState { 20 import org.apache.commons.logging.Log; 21 import org.apache.commons.logging.LogFactory; 22 23 /** 24 * PatientState 25 */ 26 public class PatientState implements java.io.Serializable { 27 28 public static final long serialVersionUID = 0L; 29 protected final Log log = LogFactory.getLog(getClass()); 30 31 // ****************** 32 // Properties 33 // ****************** 21 34 22 35 private Integer patientStateId; 23 // private Program program;24 // private ProgramWorkflow programWorkflow;25 36 private PatientProgram patientProgram; 26 37 private ProgramWorkflowState state; … … 37 48 private String voidReason; 38 49 50 // ****************** 51 // Constructors 52 // ****************** 53 54 /** Default Constructor */ 39 55 public PatientState() { } 56 57 /** Constructor with id */ 58 public PatientState(Integer patientStateId) { 59 setPatientStateId(patientStateId); 60 } 40 61 41 62 /** … … 70 91 return target; 71 92 } 93 94 // ****************** 95 // Instance methods 96 // ****************** 97 98 /** 99 * Returns true if this {@link PatientState} is active as of the passed {@link Date} 100 * @param onDate - {@link Date} to check for {@link PatientState} enrollment 101 * @return boolean - true if this {@link PatientState} is active as of the passed {@link Date} 102 */ 103 public boolean getActive(Date onDate) { 104 if (onDate == null) { 105 onDate = new Date(); 106 } 107 return !getVoided() && (startDate == null || OpenmrsUtil.compare(startDate, onDate) <= 0) && (endDate == null || OpenmrsUtil.compare(endDate, onDate) > 0); 108 } 109 110 /** 111 * Returns true if this {@link PatientState} is currently active 112 * @return boolean - true if this {@link PatientState} is currently active 113 */ 114 public boolean getActive() { 115 return getActive(null); 116 } 117 118 /** @see Object#equals(Object) */ 119 public boolean equals(Object obj) { 120 if (obj != null && obj instanceof PatientState) { 121 PatientState p = (PatientState)obj; 122 if (this.getPatientStateId() == null) { 123 return p.getPatientStateId() == null; 124 } 125 return (this.getPatientStateId().equals(p.getPatientStateId())); 126 } 127 return false; 128 } 129 130 /** @see Object#toString() */ 131 public String toString() { 132 return "PatientState(id=" + getPatientStateId() + ", patientProgram=" + getPatientProgram() + ", state=" + getState() + ", startDate=" + getStartDate() + ", endDate=" + getEndDate(); 133 } 134 135 // ****************** 136 // Property Access 137 // ****************** 72 138 73 139 public PatientProgram getPatientProgram() { … … 174 240 this.startDate = startDate; 175 241 } 176 177 public boolean getActive() {178 return getActive(null);179 }180 181 public boolean getActive(Date onDate) {182 if (onDate == null)183 onDate = new Date();184 return (startDate == null || OpenmrsUtil.compare(startDate, onDate) <= 0) && (endDate == null || OpenmrsUtil.compare(endDate, onDate) > 0);185 }186 187 242 }