Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/24/08 14:37:02 (8 months ago)
Author:
bwolfe
Message:

Merging api-refactoring to trunk [3595]:[4355]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/trunk/src/api/org/openmrs/PatientState.java

    r4245 r4358  
    1818import org.openmrs.util.OpenmrsUtil; 
    1919 
    20 public class PatientState { 
     20import org.apache.commons.logging.Log; 
     21import org.apache.commons.logging.LogFactory; 
     22 
     23/** 
     24 * PatientState 
     25 */ 
     26public 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        // ****************** 
    2134 
    2235        private Integer patientStateId; 
    23         // private Program program; 
    24         // private ProgramWorkflow programWorkflow; 
    2536        private PatientProgram patientProgram; 
    2637        private ProgramWorkflowState state; 
     
    3748        private String voidReason; 
    3849         
     50        // ****************** 
     51        // Constructors 
     52        // ****************** 
     53         
     54        /** Default Constructor */ 
    3955        public PatientState() { } 
     56         
     57        /** Constructor with id */ 
     58        public PatientState(Integer patientStateId) { 
     59                setPatientStateId(patientStateId); 
     60        } 
    4061         
    4162        /** 
     
    7091                return target; 
    7192        } 
     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        // ****************** 
    72138 
    73139        public PatientProgram getPatientProgram() { 
     
    174240                this.startDate = startDate; 
    175241        } 
    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          
    187242}