Skip to content

Commit

Permalink
[Bug]Failure to change preferred name, or identifier using a POST req…
Browse files Browse the repository at this point in the history
…uest to the REST API
  • Loading branch information
chibujax committed Sep 29, 2017
1 parent 49ed4dc commit 671863d
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,31 @@ public PatientIdentifier getByUniqueId(String uniqueId) {
*/
@Override
public PatientIdentifier save(PatientIdentifier delegate) {
// make sure it has already been added to the patient

boolean needToAdd = true;
for (PatientIdentifier pi : delegate.getPatient().getActiveIdentifiers()) {
if (pi.equals(delegate)) {
needToAdd = false;
break;
}
}
if (needToAdd)

if (needToAdd) {
delegate.getPatient().addIdentifier(delegate);
return service().savePatientIdentifier(delegate);
}

if (delegate.isPreferred()) {
for (PatientIdentifier pI : delegate.getPatient().getActiveIdentifiers()) {
if (!pI.equals(delegate)) {
pI.setPreferred(false);
}
}
}

service().savePatient(delegate.getPatient());

return delegate;

}

@Override
Expand Down

0 comments on commit 671863d

Please sign in to comment.