Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

reagan-meant
Copy link
Contributor

@reagan-meant reagan-meant commented Jul 7, 2019

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 and
    added 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

@coveralls
Copy link

coveralls commented Jul 7, 2019

Coverage Status

Coverage increased (+0.2%) to 60.085% when pulling 8990a93 on reagan-meant:TRUNK-36 into 18eaf68 on openmrs:master.

mergedData.setPriorCauseOfDeath(preferred.getCauseOfDeath().getUuid());
}
if (preferred.getCauseOfDeath() == null) {
preferred.setCauseOfDeath(notPreferred.getCauseOfDeath());

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)

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.

Copy link
Contributor Author

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

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

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

Copy link
Contributor Author

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....

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 ?

Copy link
Contributor Author

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) {

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)

@dilanthas
Copy link

@reagan-meant Please write unit tests

@ibacher
Copy link
Member

ibacher commented Nov 9, 2020

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.

@ibacher ibacher closed this Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants