-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TRUNK-36:Expand Merge Patient to Merge Person #2971
Conversation
mergedData.setPriorCauseOfDeath(preferred.getCauseOfDeath().getUuid()); | ||
} | ||
if (preferred.getCauseOfDeath() == null) { | ||
preferred.setCauseOfDeath(notPreferred.getCauseOfDeath()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are checking preferred.getCauseOfDeath() != null in the previous if block this can be the else statement. No need to check preferred.getCauseOfDeath() == null again
return tmpName; | ||
} | ||
|
||
private void mergeAddresses(Person preferred, Person notPreferred, PersonMergeLogData mergedData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method could be break in to several methods. name of the method is called mergeAddresses but there are lot of things happening apart from merging addresses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed this now...I was trying to use already written code in the patientserviceimpl class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reagan-meant I still cannot see your new changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reagan-meant Also its not a good practice just to copy the code from patientserviceimpl. Better to move it to a common place and use it in Patientserviceimpl and PersonServiceImpl to avoid code duplication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original idea was to put all the merges in personservice class ..however when I tried it I realised I would still have code duplications since the three classes are only related but don't extend each other....this meant I would have similar method signatures that I have to overload for different classes....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reagan-meant How about moving the common methods to a util class and use it from there. for example if you create a class called mergeUtils and add mergeRelationships method there. Then use that method in both service classes ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dilanthas I have failed to figure how to create a util class for two these different classes..
if (preferred.getCauseOfDeath() != null) { | ||
mergedData.setPriorCauseOfDeath(preferred.getCauseOfDeath().getUuid()); | ||
} | ||
if (preferred.getCauseOfDeath() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also could be moved to else statement without doing if (preferred.getCauseOfDeath() == null)
@reagan-meant Please write unit tests |
3dd4b85
to
69f5ae0
Compare
69f5ae0
to
8990a93
Compare
Closing as this PR has been hanging around here for awhile. While these changes are not necessarily a bad idea, it's hard to support merging this without any tests. |
Expanding Merge Patient to Merge Person
TRUNK-36:Expand Merge Patient to Merge Person
https://issues.openmrs.org/browse/TRUNK-36
I added a merge for person to person, user to user and person to patient.
Description of what I changed
Issue I worked on
see https://issues.openmrs.org/browse/TRUNK-
Checklist: I completed these to help reviewers :)
My pull request only contains ONE single commit
(the number above, next to the 'Commits' tab is 1).
No? -> read here on how to squash multiple commits into one
My IDE is configured to follow the code style of this project.
No? Unsure? -> configure your IDE, format the code and add the changes with
git add . && git commit --amend
I have added tests to cover my changes. (If you refactored
existing code that was well tested you do not have to add tests)
No? -> write tests and add them to this commit
git add . && git commit --amend
I ran
mvn clean package
right before creating this pull request andadded all formatting changes to my commit.
No? -> execute above command
All new and existing tests passed.
No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.
My pull request is based on the latest changes of the master branch.
No? Unsure? -> execute command
git pull --rebase upstream master