}
}
protected void searchData() {
SearchlogBean searchlogBean = null;
if(searchStringToLog != null && searchStringToLog.length() > 0) {
searchlogBean = logToSearchLog(searchStringToLog.toString(),
this.getClass().getSimpleName(), step);
}
Collection<Object> tempCol = Collections.synchronizedList(new ArrayList<Object>());
try {
//-1 is because we don't want a limit
col = PatientlogviewFinder.searchLog(user,-1, ssn,
loggedUserid, user.getCentreid(), loggedContext,
loggedStep, loggedIntervalFrom, loggedIntervalTo);
//if only userid and no ssn, show only one hit for each patient
if (loggedUserid == null && ssn != null) {
//if only ssn remove all duplicate users
for(Iterator<Patientlogview> it = col.iterator(); it.hasNext();) {
Patientlogview logview = it.next();
if(tempCol.contains(logview.getUserid())) {
it.remove();
}else {
tempCol.add(logview.getUserid());
}
}
//if only ssn and no userid, show only one hit for each user
} else if (loggedUserid != null && ssn == null) {
for(Iterator<Patientlogview> it = col.iterator(); it.hasNext();) {
Patientlogview logview = it.next();
if(tempCol.contains(logview.getPid())) {
it.remove();
}else {
tempCol.add(logview.getPid());
}
}
}
//get the patientid once for each patient
Collection<Long> onlyPid = Collections.synchronizedList(new ArrayList<Long>());
for(Patientlogview searchedPatient : col) {
if(!onlyPid.contains(searchedPatient.getPid())) {
onlyPid.add(searchedPatient.getPid());
}
}
//results are stored in the patientlog, once for each patient
if (null != onlyPid && disp.isPatientlogLogPatientlists()) {
for(Long pidToStore : onlyPid) {
logToPatientLog(pidToStore, this.getClass().getSimpleName(), step,
searchlogBean != null ? searchlogBean.getId() : null);
}
}
if (loggedUserid != null) {
// Search for spec. user committed, get User from DB
loggedUser = (UserBean) UserFinderBase.findByPrimaryKey(