Skip to content

Commit

Permalink
ZM: TeamMember Add UI
Browse files Browse the repository at this point in the history
  • Loading branch information
zohaibmk committed May 15, 2017
1 parent e50bf88 commit 6484989
Show file tree
Hide file tree
Showing 30 changed files with 682 additions and 838 deletions.
30 changes: 9 additions & 21 deletions api/src/main/java/org/openmrs/module/teammodule/TeamMember.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@ public class TeamMember extends BaseOpenmrsData implements Serializable {

private Date leaveDate;

private Set<Location> location = new HashSet<Location>();
private Set<Location> locations = new HashSet<Location>();

private Set<TeamMemberPatientRelation> patients = new HashSet<TeamMemberPatientRelation>();

// private Set<Team> subTeams = new HashSet<Team>(0);

private TeamRole teamRole;

private String provider;

private boolean isDataProvider;

private Boolean isDataProvider;

public TeamMember() { }

Expand Down Expand Up @@ -89,12 +85,12 @@ public void setLeaveDate(Date leaveDate) {
this.leaveDate = leaveDate;
}

public Set<Location> getLocation() {
return location;
public Set<Location> getLocations() {
return locations;
}

public void setLocation(Set<Location> location) {
this.location = location;
public void setLocations(Set<Location> locations) {
this.locations = locations;
}

public Set<TeamMemberPatientRelation> getPatients() {
Expand Down Expand Up @@ -131,19 +127,11 @@ public void setTeamRole(TeamRole teamRole) {
this.teamRole = teamRole;
}

public String getProvider() {
return provider;
}

public void setProvider(String provider) {
this.provider = provider;
}

public boolean getIsDataProvider() {
public Boolean getIsDataProvider() {
return isDataProvider;
}

public void setIsDataProvider(boolean isDataProvider) {
public void setIsDataProvider(Boolean isDataProvider) {
this.isDataProvider = isDataProvider;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ public interface TeamMemberService extends OpenmrsService {

public List<TeamMember> getTeamMemberByPersonId(Integer personId);

public List<TeamMember> getAllTeamMember(Integer id, boolean voided, Integer offset, Integer pageSize);

public List<TeamMember> getAllTeamMember( boolean voided, Integer offset, Integer pageSize);

public List<TeamMember> getAllTeamMember(Integer id, Boolean voided, Integer offset, Integer pageSize);

public void saveTeamMember(TeamMember teamMember);

public void purgeTeamMember(TeamMember teamMember);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public interface TeamRoleLogService extends OpenmrsService {

public void purgeTeamRoleLog(TeamRoleLog teamRoleLog);

public List<TeamRoleLog> searchTeamRoleLog(Integer teamRoleId,Integer offset, Integer pageSize);
public List<TeamRoleLog> searchTeamRoleLog(String teamRoleId,Integer offset, Integer pageSize);

public TeamRoleLog getTeamRoleLog(String uuid);

public List<TeamRoleLog> searchTeamRoleLog(Integer teamRoleId,Integer offset, Integer pageSize);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import org.openmrs.api.OpenmrsService;
import org.openmrs.module.teammodule.TeamMember;
import org.openmrs.module.teammodule.TeamRole;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -19,7 +20,9 @@ public interface TeamRoleService extends OpenmrsService {

public List<TeamRole> searchTeamRoleByRole(String role);

public TeamRole getTeamRoleByUuid(String uuid);

public TeamRole getTeamRoleByUuid(String uuid);

public List<TeamRole> getSubTeamRoles(TeamMember teamMember);

public List<TeamRole> searchTeamRoleReportBy(int id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ public interface TeamMemberDAO {

public List<TeamMember> getTeamMemberByPersonId(Integer personId);

public List<TeamMember> getAllTeamMember(Integer id, boolean voided, Integer offset, Integer pageSize);

public List<TeamMember> getAllTeamMember( boolean voided, Integer offset, Integer pageSize);
public List<TeamMember> getAllTeamMember(Integer id, Boolean voided, Integer offset, Integer pageSize);

public void saveTeamMember(TeamMember teamMember);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import org.openmrs.module.teammodule.TeamMember;
import org.openmrs.module.teammodule.TeamRole;

public interface TeamRoleDAO {
Expand All @@ -18,5 +19,7 @@ public interface TeamRoleDAO {

public TeamRole getTeamRoleByUuid(String uuid);

public List<TeamRole> getSubTeamRoles(TeamMember teamMember);

public List<TeamRole> searchTeamRoleReportBy(int id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public interface TeamRoleLogDAO {

public void purgeTeamRoleLog(TeamRoleLog teamRoleLog);

public List<TeamRoleLog> searchTeamRoleLog(Integer teamRole, Integer offset, Integer pageSize);
public List<TeamRoleLog> searchTeamRoleLog(String teamRole, Integer offset, Integer pageSize);

public TeamRoleLog getTeamRoleLog(String uuid);

public List<TeamRoleLog> searchTeamRoleLog(Integer teamRoleId, Integer offset, Integer pageSize);
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public List<TeamMember> getTeamMemberByPersonId(Integer personId) {
}

@Override
public List<TeamMember> getAllTeamMember(Integer id, boolean voided, Integer offset, Integer pageSize) {

public List<TeamMember> getAllTeamMember(Integer id, Boolean voided, Integer offset, Integer pageSize) {
if(id != null) {// id is not null
if (!voided) { // get by team member id & voided
Criteria criteria_member = sessionFactory.getCurrentSession().createCriteria(TeamMember.class).add(Restrictions.eq("voided", false));
Expand Down Expand Up @@ -153,22 +152,20 @@ public List<TeamMember> searchTeamMemberByTeam(Integer teamId) {
return sessionFactory.getCurrentSession().createQuery("from TeamMember teamMember where teamMember.team = :teamId").setInteger("teamId", teamId).list();
}

//id - TODO
@Override
public List<TeamMember> searchTeamMember(String identifier, TeamMember supervisor, TeamRole teamRole, Team team, Location location, Integer offset, Integer pageSize) {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(TeamMember.class);

if (location != null) {
criteria.createAlias("location", "l").add(Restrictions.eq("l.locationId", location.getId()));
criteria.createAlias("locations", "l").add(Restrictions.eq("l.locationId", location.getId()));
}

if (teamRole != null) {
criteria.add(Restrictions.eq("teamRole", teamRole));
}

if (identifier != null) {
criteria.add(Restrictions.like("identifier", "%"+identifier+"%"));
//criteria.add(Restrictions.or(Restrictions.or(Restrictions.like("identifier", "%"+identifier+"%"),Restrictions.like("identifier", "%"+identifier+"%")),Restrictions.or(Restrictions.like("identifier", "%"+identifier+"%"),Restrictions.like("identifier", "%"+identifier+"%"))));
criteria.createAlias("person", "p").createAlias("p.names", "pn").add(Restrictions.or(Restrictions.like("pn.givenName", "%"+identifier+"%"),Restrictions.or(Restrictions.like("pn.middleName", "%"+identifier+"%"),Restrictions.or(Restrictions.like("pn.familyName", "%"+identifier+"%"),Restrictions.like("identifier", "%"+identifier+"%")))));
}

if (team != null) {
Expand Down Expand Up @@ -217,13 +214,6 @@ else if (name == null && (joinDateFrom != null && joinDateTo != null)) {
@Override
public int count(Integer teamId) {
// TODO Auto-generated method stub
return (int) sessionFactory.getCurrentSession().createQuery("from TeamMember tm where tm.team= :teamId").setInteger("teamId", teamId).list().size();
}

@Override
public List<TeamMember> getAllTeamMember(boolean voided, Integer offset,
Integer pageSize) {
// TODO Auto-generated method stub
return sessionFactory.getCurrentSession().createQuery("from TeamMember").list();
return (int) sessionFactory.getCurrentSession().createQuery("from TeamMember teammember where team= :teamId").setInteger("teamId", teamId).list().size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import org.openmrs.module.teammodule.TeamMember;
import org.openmrs.module.teammodule.TeamRole;
import org.openmrs.module.teammodule.api.db.TeamRoleDAO;

Expand Down Expand Up @@ -52,13 +53,20 @@ public void purgeTeamRole(TeamRole TeamRole) {

@SuppressWarnings("unchecked")
public List<TeamRole> searchTeamRoleByRole(String role) {
return (List<TeamRole>)sessionFactory.getCurrentSession().createQuery("from TeamRole teamRole where teamRole.name = :role ").setString("role", role).list();
return (List<TeamRole>)sessionFactory.getCurrentSession().createQuery("from TeamRole teamRole where teamRole.name = :role").setString("role", role).list();
}

public TeamRole getTeamRoleByUuid(String uuid) {
return (TeamRole)sessionFactory.getCurrentSession().createQuery("from TeamRole teamRole where teamRole.uuid = :uuid").setString("uuid", uuid).uniqueResult();
}

@Override
@SuppressWarnings("unchecked")
public List<TeamRole> getSubTeamRoles(TeamMember teamMember) {
return sessionFactory.getCurrentSession().createQuery("from TeamRole teamRole where teamRole.reportTo = :id").setInteger("id", teamMember.getTeamRole().getId()).list();
}

@SuppressWarnings("unchecked")
@Override
public List<TeamRole> searchTeamRoleReportBy(int id) {
// TODO Auto-generated method stub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public void purgeTeamRoleLog(TeamRoleLog TeamRoleLog) {
}

@SuppressWarnings("unchecked")
public List<TeamRoleLog> searchTeamRoleLog(Integer teamRole, Integer offset, Integer pageSize) {
Query createQuery =sessionFactory.getCurrentSession().createQuery("from TeamRoleLog teamRoleLog where teamRoleLog.teamRole = :teamRole").setInteger("teamRole", teamRole);
public List<TeamRoleLog> searchTeamRoleLog(String teamRole, Integer offset, Integer pageSize) {
Query createQuery =sessionFactory.getCurrentSession().createQuery("from TeamRoleLog teamRoleLog where teamRoleLog.teamRole = :teamRole").setInteger("teamRole", Integer.parseInt(teamRole));
if(offset != null) {
createQuery.setFirstResult(offset);
}
Expand All @@ -74,6 +74,15 @@ public TeamRoleLog getTeamRoleLog(String uuid) {
return (TeamRoleLog) createQuery.uniqueResult();
}



@SuppressWarnings("unchecked")
public List<TeamRoleLog> searchTeamRoleLog(Integer teamRole, Integer offset, Integer pageSize) {
Query createQuery =sessionFactory.getCurrentSession().createQuery("from TeamRoleLog teamRoleLog where teamRoleLog.teamRole = :teamRole").setInteger("teamRole", teamRole);
if(offset != null) {
createQuery.setFirstResult(offset);
}
if(pageSize != null) {
createQuery.setMaxResults(pageSize);
}
return createQuery.list();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public List<TeamMember> getTeamMemberByPersonId(Integer personId) {
}

@Override
public List<TeamMember> getAllTeamMember(Integer id, boolean voided, Integer offset, Integer pageSize) {
public List<TeamMember> getAllTeamMember(Integer id, Boolean voided, Integer offset, Integer pageSize) {
return this.dao.getAllTeamMember(id, voided, offset, pageSize);
}

Expand All @@ -93,14 +93,6 @@ public List<TeamMember> searchTeamMember(String identifier, TeamMember superviso

@Override
public int count(Integer teamId) {
// TODO Auto-generated method stub
return this.dao.count(teamId);
}

@Override
public List<TeamMember> getAllTeamMember(boolean voided, Integer offset,
Integer pageSize) {
// TODO Auto-generated method stub
return this.dao.getAllTeamMember(voided, offset, pageSize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void purgeTeamRoleLog(TeamRoleLog TeamRoleLog) {
dao.purgeTeamRoleLog(TeamRoleLog);
}

public List<TeamRoleLog> searchTeamRoleLog(Integer teamRole,Integer offset, Integer pageSize) {
public List<TeamRoleLog> searchTeamRoleLog(String teamRole,Integer offset, Integer pageSize) {
return dao.searchTeamRoleLog(teamRole,offset, pageSize);
}

Expand All @@ -52,4 +52,7 @@ public TeamRoleLog getTeamRoleLog(String uuid) {
return dao.getTeamRoleLog(uuid);
}

public List<TeamRoleLog> searchTeamRoleLog(Integer teamRoleId,Integer offset, Integer pageSize) {
return dao.searchTeamRoleLog(teamRoleId, offset, pageSize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.api.impl.BaseOpenmrsService;
import org.openmrs.module.teammodule.TeamMember;
import org.openmrs.module.teammodule.TeamRole;
import org.openmrs.module.teammodule.api.TeamRoleService;
import org.openmrs.module.teammodule.api.db.TeamRoleDAO;
Expand Down Expand Up @@ -52,10 +53,13 @@ public TeamRole getTeamRoleByUuid(String uuid) {
return dao.getTeamRoleByUuid(uuid);
}

@Override
public List<TeamRole> getSubTeamRoles(TeamMember teamMember) {
return dao.getSubTeamRoles(teamMember);
}

@Override
public List<TeamRole> searchTeamRoleReportBy(int id) {
// TODO Auto-generated method stub
return dao.searchTeamRoleReportBy(id);
}

}
22 changes: 11 additions & 11 deletions api/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
<column name="date_voided" type="datetime" />
<column name="void_reason" type="varchar(255)" />
<column name="uuid" type="varchar(255)" />
</createTable>
</createTable>
</changeSet>
<changeSet id="teammodule-13.1.0A" author="Shakeeb Raza">
<createTable tableName="team_role_log">
Expand Down Expand Up @@ -270,11 +270,8 @@
<column name="creator" type="int(11)">
<constraints nullable="false" />
</column>
<column name="uuid" type="varchar(255)" />
<column name="uuid" type="varchar(255)" />
</addColumn>



<addColumn tableName="team_member_log">
<column name="date_created" type="datetime">
<constraints nullable="false" />
Expand Down Expand Up @@ -353,19 +350,22 @@
</addColumn>
</changeSet>

<changeSet author="Shakeeb Raza" id="teammodule-32.1.0A">
<addColumn tableName="team_log">
<column name="data_old" type="varchar(500)" />
</addColumn>
</changeSet>

<changeSet author="Zohaib Masood" id="teammodule-33.1.0A">
<addColumn tableName="team_member">
<column name="provider" type="varchar(45)" />
<column name="is_data_provider" type="tinyint(4)">
<constraints nullable="false" />
</column>
</addColumn>
</changeSet>

<changeSet author="Shakeeb Raza" id="teammodule-32.1.0A">
<addColumn tableName="team_log">
<column name="data_old" type="varchar(500)" />
</addColumn>
</changeSet>
<changeSet author="Zohaib Masood" id="teammodule-34.1.0A">
<renameTable newTableName="team_member_location" oldTableName="member_location"/>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ public String getTitle() {
*/
public Map<String, String> getLinks() {
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();

map.put("module/teammodule/addTeam.form", "New Team");
map.put("module/teammodule/teamMemberAddForm.form", "New Team Member");
map.put("module/teammodule/teamRole.form", "Team Hierarchy (Roles)");
map.put("module/teammodule/team.form", "Manage Teams");
//map.put("module/teammodule/allMember.form?searchMember=&from=&to=", "View Members");
map.put("module/teammodule/teamMemberView.form", "View All Members");
map.put("module/teammodule/teamMemberAddForm.form", "Add Members");
map.put("module/teammodule/teamRole.form", "All Teams Hierarchy");
map.put("module/teammodule/teamMemberView.form", "Manage Team Members");
return map;
}
}
Loading

0 comments on commit 6484989

Please sign in to comment.