TRUNK-4954 obs and its encounter point to different persons

I am currently working on[ this issue on

I have added validation in to accommodate few test cases in Feel free give ideas to improve work on this issue.

Here is my pull request


Did you take a look at this?

@dkayiwa Yes I modified my PR. Feel free to review on

@dkayiwa The travis build fails in saveObs_shouldCascadeUpdateToNewChildObsGroups in Feel free to help me to proceed from here.

@raff Could you please help me to correct the travis build in #PR- 2541

@madushan, you need to fix tests. They do not pass the validation you introduced. See e.g. , which should be fixed to groupMember.setPerson(origParentObs.getPerson())

@raff The build fails due to the test method written before my modification in Shall I modify the failing methods.

Yes, you need to fix the 4 failing tests, even though they were written long ago.

@raff Thanks. In the first failing test it shows following error. “saveObs_shouldCascadeUpdateToNewChildObsGroups(org.openmrs.api.ObsServiceTest) Time elapsed: 0.174 sec <<< ERROR! org.openmrs.api.ValidationException: ‘Obs #2’ failed to validate with reason: person: person objects of the obs and the encounter do not match” I find it hard to understand why the exception occurs? sets the person to new Patient(2) which is probably different from what is set on an encounter for that obs. See my previous reply on how to fix it.

@raff Thanks .I will follow your steps.

@raff I modified the code with your line. But it still caused the same exception. Digging into the matter showed me that an encounter with a different patient is auto assigned to the origParentObs which causes the exception. Here are the details.

in the test method

origParentObs id =2, origParentObs encounter = null, origParentObs person = Patient#2

in the new validation in

origParentObs id =9, origParentObs encounter = Encounter: [3 2008-08-01 00:00:00.0 Emergency Unknown Location 7 Basic Form num Obs: [Obs #7] num Orders: 3 ], origParentObs person = Person(personId=9)

@jwnasambu @dkayiwa Could you please tell me why the above scenario happens ?

@f4ww4z Could you please tell me why the above scenario happens ?

@suthagar23 @navareth Could you please help me to understand why this happens.