org.openmrs
Class PatientProgram

java.lang.Object
  extended by org.openmrs.BaseOpenmrsObject
      extended by org.openmrs.BaseOpenmrsData
          extended by org.openmrs.PatientProgram
All Implemented Interfaces:
java.io.Serializable, Auditable, OpenmrsData, OpenmrsObject, Voidable

public class PatientProgram
extends BaseOpenmrsData
implements java.io.Serializable

PatientProgram

See Also:
Serialized Form

Field Summary
static long serialVersionUID
           
 
Fields inherited from class org.openmrs.BaseOpenmrsData
creator
 
Constructor Summary
PatientProgram()
          Default Constructor
PatientProgram(java.lang.Integer patientProgramId)
          Constructor with id
 
Method Summary
 PatientProgram copy()
          Does a mostly-shallow copy of this PatientProgram.
protected  PatientProgram copyHelper(PatientProgram target)
          The purpose of this method is to allow subclasses of PatientProgram to delegate a portion of their copy() method back to the superclass, in case the base class implementation changes.
 boolean equals(java.lang.Object obj)
           
 boolean getActive()
          Returns true if the associated Patient is currently enrolled in the associated Program
 boolean getActive(java.util.Date onDate)
          Returns true if the associated Patient is enrolled in the associated Program on the passed Date
 PatientState getCurrentState()
          Deprecated. use getCurrentState(ProgramWorkflow)
 PatientState getCurrentState(ProgramWorkflow programWorkflow)
          Returns the current PatientState for the passed ProgramWorkflow within this PatientProgram.
 java.util.Set<PatientState> getCurrentStates()
          Returns a Set of all current PatientStates for the PatientProgram
 java.util.Date getDateCompleted()
           
 java.util.Date getDateEnrolled()
           
 java.lang.Integer getId()
           
 Patient getPatient()
           
 java.lang.Integer getPatientProgramId()
           
 PatientState getPatientState(java.lang.Integer patientStateId)
          Returns the PatientState associated with this PatientProgram that has an id that matches the passed patientStateId
 Program getProgram()
           
 java.util.Set<PatientState> getStates()
           
 void setDateCompleted(java.util.Date dateCompleted)
           
 void setDateEnrolled(java.util.Date dateEnrolled)
           
 void setId(java.lang.Integer id)
           
 void setPatient(Patient patient)
           
 void setPatientProgramId(java.lang.Integer patientProgramId)
           
 void setProgram(Program program)
           
 void setStates(java.util.Set<PatientState> states)
           
 java.util.List<PatientState> statesInWorkflow(ProgramWorkflow programWorkflow, boolean includeVoided)
          Returns a List of all PatientStates in the passed ProgramWorkflow for the PatientProgram
 java.lang.String toString()
           
 void transitionToState(ProgramWorkflowState programWorkflowState, java.util.Date onDate)
          Attempts to transition the PatientProgram to the passed ProgramWorkflowState on the passed Date by ending the most recent PatientState in the PatientProgram and creating a new one with the passed ProgramWorkflowState This will throw an IllegalArgumentException if the transition is invalid
 void voidLastState(ProgramWorkflow workflow, User voidBy, java.util.Date voidDate, java.lang.String voidReason)
          Attempts to void the latest PatientState in the PatientProgram If earlier PatientStates exist, it will try to reset the endDate to null so that the next latest state becomes the current PatientState
 
Methods inherited from class org.openmrs.BaseOpenmrsData
getChangedBy, getCreator, getDateChanged, getDateCreated, getDateVoided, getVoided, getVoidedBy, getVoidReason, isVoided, setChangedBy, setCreator, setDateChanged, setDateCreated, setDateVoided, setVoided, setVoidedBy, setVoidReason
 
Methods inherited from class org.openmrs.BaseOpenmrsObject
getUuid, setUuid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openmrs.OpenmrsObject
getUuid, setUuid
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

PatientProgram

public PatientProgram()
Default Constructor


PatientProgram

public PatientProgram(java.lang.Integer patientProgramId)
Constructor with id

Method Detail

copy

public PatientProgram copy()
Does a mostly-shallow copy of this PatientProgram. Does not copy patientProgramId. The 'states' property will be deep-copied.

Returns:
a shallow copy of this PatientProgram

copyHelper

protected PatientProgram copyHelper(PatientProgram target)
The purpose of this method is to allow subclasses of PatientProgram to delegate a portion of their copy() method back to the superclass, in case the base class implementation changes.

Parameters:
target - a PatientProgram that will have the state of this copied into it
Returns:
the PatientProgram that was passed in, with state copied into it

getActive

public boolean getActive(java.util.Date onDate)
Returns true if the associated Patient is enrolled in the associated Program on the passed Date

Parameters:
onDate - - Date to check for PatientProgram enrollment
Returns:
boolean - true if the associated Patient is enrolled in the associated Program on the passed Date

getActive

public boolean getActive()
Returns true if the associated Patient is currently enrolled in the associated Program

Returns:
boolean - true if the associated Patient is currently enrolled in the associated Program

getPatientState

public PatientState getPatientState(java.lang.Integer patientStateId)
Returns the PatientState associated with this PatientProgram that has an id that matches the passed patientStateId

Parameters:
patientStateId - - The identifier to use to lookup a PatientState
Returns:
PatientState that has an id that matches the passed patientStateId

transitionToState

public void transitionToState(ProgramWorkflowState programWorkflowState,
                              java.util.Date onDate)
Attempts to transition the PatientProgram to the passed ProgramWorkflowState on the passed Date by ending the most recent PatientState in the PatientProgram and creating a new one with the passed ProgramWorkflowState This will throw an IllegalArgumentException if the transition is invalid

Parameters:
programWorkflowState - - The ProgramWorkflowState to transition to
onDate - - The Date of the transition
Throws:
java.lang.IllegalArgumentException

voidLastState

public void voidLastState(ProgramWorkflow workflow,
                          User voidBy,
                          java.util.Date voidDate,
                          java.lang.String voidReason)
Attempts to void the latest PatientState in the PatientProgram If earlier PatientStates exist, it will try to reset the endDate to null so that the next latest state becomes the current PatientState

Parameters:
workflow - - The ProgramWorkflow whose last PatientState within the current PatientProgram we want to void
voidBy - - The user who is voiding the PatientState
voidDate - - The date to void the PatientState
voidReason - - The reason for voiding the PatientState

getCurrentState

public PatientState getCurrentState(ProgramWorkflow programWorkflow)
Returns the current PatientState for the passed ProgramWorkflow within this PatientProgram.

Parameters:
programWorkflow - The ProgramWorkflow whose current PatientState we want to retrieve
Returns:
PatientState The current PatientState for the passed ProgramWorkflow within this PatientProgram

getCurrentState

public PatientState getCurrentState()
Deprecated. use getCurrentState(ProgramWorkflow)


getCurrentStates

public java.util.Set<PatientState> getCurrentStates()
Returns a Set of all current PatientStates for the PatientProgram

Returns:
Set of all current PatientStates for the PatientProgram

statesInWorkflow

public java.util.List<PatientState> statesInWorkflow(ProgramWorkflow programWorkflow,
                                                     boolean includeVoided)
Returns a List of all PatientStates in the passed ProgramWorkflow for the PatientProgram

Parameters:
programWorkflow - - The ProgramWorkflow to check
includeVoided - - If true, return voided PatientStates in the returned List
Returns:
List of all PatientStates in the passed ProgramWorkflow for the PatientProgram

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getDateCompleted

public java.util.Date getDateCompleted()

setDateCompleted

public void setDateCompleted(java.util.Date dateCompleted)

getDateEnrolled

public java.util.Date getDateEnrolled()

setDateEnrolled

public void setDateEnrolled(java.util.Date dateEnrolled)

getPatient

public Patient getPatient()

setPatient

public void setPatient(Patient patient)

getPatientProgramId

public java.lang.Integer getPatientProgramId()

setPatientProgramId

public void setPatientProgramId(java.lang.Integer patientProgramId)

getProgram

public Program getProgram()

setProgram

public void setProgram(Program program)

getStates

public java.util.Set<PatientState> getStates()

setStates

public void setStates(java.util.Set<PatientState> states)

getId

public java.lang.Integer getId()
Specified by:
getId in interface OpenmrsObject
Returns:
id - The unique Identifier for the object
Since:
1.5
See Also:
OpenmrsObject.getId()

setId

public void setId(java.lang.Integer id)
Specified by:
setId in interface OpenmrsObject
Parameters:
id - - The unique Identifier for the object
Since:
1.5
See Also:
OpenmrsObject.setId(java.lang.Integer)

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change