use of org.openmrs.PatientProgram in project openmrs-core by openmrs.
the class PatientProgramValidatorTest method validate_shouldFailIfPatientProgramEndDateComesBeforeItsEnrolledDate.
/**
* @throws ParseException
* @see PatientProgramValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfPatientProgramEndDateComesBeforeItsEnrolledDate() throws ParseException {
PatientProgram program = Context.getProgramWorkflowService().getPatientProgram(1);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Date dateEnrolled = sdf.parse("12/04/2014");
Date dateCompleted = sdf.parse("21/03/2014");
program.setDateEnrolled(dateEnrolled);
program.setDateCompleted(dateCompleted);
BindException errors = new BindException(program, "");
new PatientProgramValidator().validate(program, errors);
Assert.assertTrue(errors.hasFieldErrors("dateCompleted"));
}
use of org.openmrs.PatientProgram in project openmrs-core by openmrs.
the class PatientProgramValidatorTest method validate_shouldFailIfAnyPatientStateHasANullWorkFlowState.
/**
* @see PatientProgramValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfAnyPatientStateHasANullWorkFlowState() {
PatientProgram program = Context.getProgramWorkflowService().getPatientProgram(1);
PatientState patientState = program.getStates().iterator().next();
patientState.setState(null);
BindException errors = new BindException(program, "");
new PatientProgramValidator().validate(program, errors);
Assert.assertTrue(errors.hasFieldErrors("states"));
}
use of org.openmrs.PatientProgram in project openmrs-core by openmrs.
the class PatientProgramValidatorTest method validate_shouldFailIfPatientProgramEnrollDateIsEmpty.
/**
* @see PatientProgramValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfPatientProgramEnrollDateIsEmpty() {
PatientProgram program = Context.getProgramWorkflowService().getPatientProgram(1);
program.setDateEnrolled(null);
BindException errors = new BindException(program, "");
new PatientProgramValidator().validate(program, errors);
Assert.assertTrue(errors.hasFieldErrors("dateEnrolled"));
}
use of org.openmrs.PatientProgram in project openmrs-core by openmrs.
the class PatientProgramValidatorTest method validate_shouldPassForAValidProgram.
/**
* @see PatientProgramValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassForAValidProgram() {
PatientProgram program = Context.getProgramWorkflowService().getPatientProgram(1);
PatientState patientState = program.getStates().iterator().next();
patientState.getPatientProgram().transitionToState(patientState.getState().getProgramWorkflow().getState(4), new Date());
ValidateUtil.validate(program);
}
use of org.openmrs.PatientProgram in project openmrs-core by openmrs.
the class PatientProgramValidatorTest method validate_shouldFailIfTheProgramPropertyIsNull.
/**
* @see PatientProgramValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfTheProgramPropertyIsNull() {
PatientProgram program = new PatientProgram();
program.setPatient(new Patient());
}
Aggregations