personList.add(PersonListItem.createBestMatch(p));
}
}
}
Cohort cohort = null;
if(searchAttribute != null)
{
String[] attributes = searchAttribute.split(",");
String[] attrValues = null;
if(attributeValue != null)
{
attrValues = searchAttribute.split(",");
}
for(int i = 0; i < attributes.length; i++)
{
String attr = attributes[i];
String val = null;
if(attrValues != null && attrValues[i].trim().length() > 0)
{
val = attrValues[i];
}
if(attr != null && attr.trim().length() > 0)
{
List<Integer> ids = Context.getService(HtmlFormEntryService.class).getPersonIdsHavingAttributes(attr, val);
Set<Integer> setOfIds = new HashSet<Integer>();
setOfIds.addAll(ids);
Cohort pp = new Cohort();
pp.setMemberIds(setOfIds);
if(cohort != null)
{
cohort = Cohort.intersect(cohort, pp);
}
else
{
cohort = pp;
}
}
}
}
if(searchProgram != null)
{
String[] programs = searchProgram.split(",");
for(int i = 0; i < programs.length; i++)
{
String prog = programs[i];
if(prog != null && prog.trim().length() > 0)
{
Program personProgram = Context.getProgramWorkflowService().getProgramByUuid(prog);
if(personProgram == null)
{
personProgram = Context.getProgramWorkflowService().getProgram(Integer.parseInt(prog));
}
if(personProgram != null)
{
Cohort pp = Context.getPatientSetService().getPatientsInProgram(personProgram, null, null);
if(cohort != null)
{
cohort = Cohort.intersect(cohort, pp);
}
else