Skip to content

Commit

Permalink
MK: added user in TeamMemberResource
Browse files Browse the repository at this point in the history
  • Loading branch information
Maimoona Kausar committed Aug 25, 2017
1 parent 0d7d8fa commit b6bb500
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import java.util.List;

import org.openmrs.Person;
import org.openmrs.User;
import org.openmrs.api.context.Context;
import org.openmrs.module.teammodule.TeamMember;
import org.openmrs.module.teammodule.api.TeamMemberService;
import org.openmrs.module.teammodule.rest.v1_0.resource.TeamModuleResourceController;
import org.openmrs.module.webservices.rest.SimpleObject;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation;
import org.openmrs.module.webservices.rest.web.representation.FullRepresentation;
Expand Down Expand Up @@ -64,6 +66,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
description.addProperty("uuid");
description.addProperty("location");
description.addProperty("team");
description.addProperty("user");
description.addProperty("patients", Representation.REF);
}
}
Expand Down Expand Up @@ -112,4 +115,9 @@ public SimpleObject search(RequestContext context) {
return new NeedsPaging<TeamMember>(memberList, context).toSimpleObject(this);
}

@PropertyGetter("user")
public User getUser(TeamMember member){
List<User> user = Context.getUserService().getUsersByPerson(member.getPerson(), false);
return user.size()>0?user.get(0):null;
}
}

0 comments on commit b6bb500

Please sign in to comment.