We are working with openmrs 2.0. We figured out that call to personService#savePerson()
is not changing the state of person voided field. We found this while writing integration tests.
I wrote this simple test to check:-
@Test
public void shouldVoidAPerson() throws Exception {
Person person = new Person();
person.addName(new PersonName("Test",null,"Person"));
person.setGender("M");
person.setBirthdate(new Date());
Person savedPerson = personService.savePerson(person);
assertFalse(savedPerson.getPersonVoided());
savedPerson.setVoided(true);
savedPerson.setVoidReason("Test");
Person voidedPerson = personService.savePerson(savedPerson);
Context.flushSession();
Context.clearSession();
assertTrue(voidedPerson.getVoided());
}
The above test fails for the last assertion. I wanted to know is this the expected behavior?
NOTE:- I figured out there are specific methods personService.voidPerson()
and personService.unvoidPerson()
which are working, but the even they are delegating it to patientDao.savePerson
.
I want to know why savePerson
is not doing it and should I always call personService.voidPerson()/personService.unvoidPerson()
to change voided status.
Thanks