openmrs-core icon indicating copy to clipboard operation
openmrs-core copied to clipboard

TRUNK-4954:ObsService.saveObs should throw a validation message if the obs and its encounter point to different persons

Open HerbertYiga opened this issue 4 years ago • 26 comments

Added a validation exception on saving an obs if the obs and its encounter point to different persons

Ticket ID:https://issues.openmrs.org/browse/TRUNK-4954

HerbertYiga avatar Nov 27 '20 07:11 HerbertYiga

Coverage Status

Coverage increased (+0.003%) to 63.628% when pulling 965ab53794a16b144e40e1ae78b72dd68fb84451 on HerbertYiga:TRUNK-4954 into f557f41272968e1b34bbeba92e6557703714a790 on openmrs:master.

coveralls avatar Jan 04 '21 13:01 coveralls

got all the tests passing,@dkayiwa how does this pr look to you?

HerbertYiga avatar Jan 04 '21 14:01 HerbertYiga

@ibacher hi ian,while trying to squash this ,i use git rebase -i master,but i get a couple of commits for which i didnot even make as seen here https://pastebin.com/kMdumzPD any idea about the cause of this?

HerbertYiga avatar Jan 06 '21 18:01 HerbertYiga

@HerbertYiga You did a rebase on master rather than the TRUNK-4954 branch, which gives Git permission to rewrite the root commit of this branch. Essentially, if you complete that rebase, it will squash your commits with all the commits that have been written to master since you first created this branch. Since there aren't any conflicts with this branch, I would recommend not trying to do a rebase at all. We can squash the commits via the GitHub tools when this is ready to go.

ibacher avatar Jan 06 '21 19:01 ibacher

If you do want to squash just the relevant commits, run git rebase -i HEAD~3 (3 comes from the fact that there are three commits on this branch).

ibacher avatar Jan 06 '21 19:01 ibacher

@ibacher on introducing

if (obs.getPerson() != null && obs.getPerson().getIsPatient() && obs.getEncounter() != null && obs.getEncounter().getPatient() != null) { errors.reject("Person objects of the obs and the encounter do not match"); } i run into a stack over flow error,https://pastebin.com/TaSJ729z by the way @ibacher to me the the above code simply checks if a patient exists for a given person having the observation and if a patient exists in an given observation for a given a encounter but never checks if the patient objects for both scenarios

Am wondering if there is no scenario of all the above not being null,but at the same time patient objects are not the same

HerbertYiga avatar Jan 06 '21 20:01 HerbertYiga

@HerbertYiga So the overall code for that if statement should be something like this:

if (obs.getPerson() != null && obs.getPerson().getIsPatient() && obs.getEncounter() != null && obs.getEncounter().getPatient() != null) {
	if (!obs.getPerson().equals(obs.getEncounter().getPatient().getPerson())) {
		errors.reject("Person objects of the obs and the encounter do not match");
	}
}

I.e., we do still need to check that the two persons are equal.

ibacher avatar Jan 06 '21 20:01 ibacher

@HerbertYiga So the overall code for that if statement should be something like this:

if (obs.getPerson() != null && obs.getPerson().getIsPatient() && obs.getEncounter() != null && obs.getEncounter().getPatient() != null) {
	if (!obs.getPerson().equals(obs.getEncounter().getPatient().getPerson())) {
		errors.reject("Person objects of the obs and the encounter do not match");
	}
}

I.e., we do still need to check that the two persons are equal.

perfect

HerbertYiga avatar Jan 06 '21 20:01 HerbertYiga

Hmmmm... and the stack overflow error doesn't occur when the obs.getPerson().getIsPatient() call is absent?

ibacher avatar Jan 06 '21 20:01 ibacher

Hmmmm... and the stack overflow error doesn't occur when the obs.getPerson().getIsPatient() call is absent?

ohh it still occurs

HerbertYiga avatar Jan 06 '21 20:01 HerbertYiga

i run into a stack over flow error

@HerbertYiga So, I tried checking out this branch and then applying my suggested code above and I don't get the stack overflow error (it's a bit hard to diagnosis since I can't see the call that originally kicked it off).

ibacher avatar Jan 06 '21 21:01 ibacher

i run into a stack over flow error

@HerbertYiga So, I tried checking out this branch and then applying my suggested code above and I don't get the stack overflow error (it's a bit hard to diagnosis since I can't see the call that originally kicked it off).

with this,

if (obs.getPerson() != null && obs.getPerson().getIsPatient() && obs.getEncounter() != null && obs.getEncounter().getPatient() != null) { if (!obs.getPerson().equals(obs.getEncounter().getPatient().getPerson())) { errors.reject("Person objects of the obs and the encounter do not match"); } }

i dont get any stack overflow,i have simply fixed some failing tests preparing to make a commit

HerbertYiga avatar Jan 06 '21 21:01 HerbertYiga

@ibacher just tried to fix a couple of things for this,

HerbertYiga avatar Jan 06 '21 23:01 HerbertYiga

@ibacher hi ian,does this look good to be merged!

HerbertYiga avatar Jan 11 '21 13:01 HerbertYiga

@dkayiwa hi Daniel, do you think this is good to be merged?

HerbertYiga avatar Jan 19 '21 06:01 HerbertYiga

@HerbertYiga not without some tests.

dkayiwa avatar Jan 21 '21 22:01 dkayiwa

not without some tests.

aright will ping you when am done on them @dkayiwa

HerbertYiga avatar Jan 22 '21 06:01 HerbertYiga

not without some tests.

@dkayiwa added tests for this, thanks for all the reviews

HerbertYiga avatar Jan 25 '21 09:01 HerbertYiga

@mozzy11 @dkayiwa does this look good for merging?

HerbertYiga avatar Feb 26 '21 07:02 HerbertYiga

hi @dkayiwa does this look good enough for merging?

HerbertYiga avatar Mar 17 '21 10:03 HerbertYiga

@HerbertYiga can you respond to Mozzy's comments above?

gracepotma avatar Apr 05 '21 16:04 gracepotma

@HerbertYiga can you respond to Mozzy's comments above?

@gracepotma Responding to @mozzy11's comment, the test available already covers that

HerbertYiga avatar Apr 06 '21 09:04 HerbertYiga

@HerbertYiga can you assert in your test unit that the obs and its encounter point to different persons ??

mozzy11 avatar Apr 06 '21 10:04 mozzy11

hi @dkayiwa does this now look good enough?

HerbertYiga avatar Jun 21 '21 17:06 HerbertYiga

Hello @HerbertYiga , did you respond to @mozzy11 comment above?

sherrif10 avatar Oct 12 '21 13:10 sherrif10

cc @HerbertYiga . Kindly respond to the above message.Thanks.

sherrif10 avatar Nov 09 '21 13:11 sherrif10

tl;dr our action detected no activity on this PR and will close it in 30 days if the stale label is not removed.

OpenMRS welcomes your contribution! It means a lot to us that you want to contribute to equity in healthcare!

This PR has not seen any activity in the last 5 months. That is why we wanted to check whether you are still working on it or need assistance from our side. Please note that this is an automated message and we might very well be the reason why there has not been any activity lately. We certainly do not want to discourage you from contributing. We do need to be honest in that OpenMRS has limited resources for reviewing PRs.

If you do not have time to continue the work or have moved on you don’t need to do anything. We will automatically close the PR in 30 days. We hope to see you back soon :) If you would like to continue working on it or require help from us please remove the stale label and respond by commenting on the issue.

github-actions[bot] avatar Aug 20 '22 00:08 github-actions[bot]

tl;dr closing this PR since it has not seen any activity in the last 6 months.

OpenMRS welcomes your contribution! It means a lot to us that you want to contribute to equity in healthcare! We certainly do not want to discourage you from contributing. We do need to be honest in that OpenMRS has limited resources for reviewing PRs. Your PR has not seen any activity in the last 6 months. This is why we have decided to close this PR for now. This allows us OpenMRS reviewers to focus our limited time to review all other PRs in a timely and professional manner.

Please feel free to reassign yourself to the issue you worked on in our JIRA when you have time to focus on it. After that reopen a new PR and we will be glad to work with you to get your contribution merged. Thank you very much for your help and understanding :)

github-actions[bot] avatar Sep 19 '22 00:09 github-actions[bot]