use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method getDNotesForStudyAsThreads.
public List<DiscrepancyNoteThread> getDNotesForStudyAsThreads(StudyBean currentStudy, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType) {
List<DiscrepancyNoteBean> allDiscNotes = new ArrayList<DiscrepancyNoteBean>();
List<DiscrepancyNoteThread> threadedNotes = new ArrayList<DiscrepancyNoteThread>();
if (currentStudy == null)
return threadedNotes;
// Do the returned DN's have to be filtered? A valid resolution status
// has to be between 1 and 5; 0 is "invalid";
// -1 means that no resolutionStatus parameter was passed into the
// servlet
boolean filterDiscNotes = checkResolutionStatus(resolutionStatusIds);
boolean filterforDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
// what is the purpose of this data member?
discrepancyNoteDAO.setFetchMapping(true);
// method finds only parents
ArrayList itemDataNotes = discrepancyNoteDAO.findAllItemDataByStudy(currentStudy);
// ArrayList eventCRFNotes =
// discrepancyNoteDAO.findAllEventCRFByStudy(currentStudy);
allDiscNotes.addAll(itemDataNotes);
// not doing this for now allDiscNotes.addAll(eventCRFNotes);
// make sure that any "parent" notes have the last resolution status of
// any
// of their child notes
updateStatusOfParents(allDiscNotes, dataSource, currentStudy);
if (filterDiscNotes) {
// filter for the resolution status
allDiscNotes = filterDiscNotes(allDiscNotes, resolutionStatusIds);
}
if (filterforDiscNoteType) {
// filter for the ddiscrepancyNoteTypeId
allDiscNotes = filterforDiscNoteType(allDiscNotes, discNoteType);
}
// convert or encapsulate List of notes in List of disc note thread
// objects
threadedNotes = createThreadsOfParents(allDiscNotes, dataSource, currentStudy, null, 0, false);
return threadedNotes;
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method getThreadedDNotesForStudy.
/**
* Get all discrepancy notes for a study, including "threads" of parent and
* child discrepancy notes.
*
* @param currentStudy
* A StudyBean object.
* @param resolutionStatusIds
* A HashSet object consisting of resolution status ids (i.e.,
* 1,2,3).
* @param dataSource
* A DataSource used for various DAO methods.
* @param discNoteType
* An int discrepancy note type id; only DiscrepancyNoteBeans
* will be returned if they have this discrepancyNoteTypeId.
* @param updateStatusOfParents
* @return A List of DiscrepancyNoteBeans.
*/
public List<DiscrepancyNoteBean> getThreadedDNotesForStudy(StudyBean currentStudy, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType, boolean updateStatusOfParents) {
List<DiscrepancyNoteBean> allDiscNotes = new ArrayList<DiscrepancyNoteBean>();
if (currentStudy == null)
return allDiscNotes;
// Do the returned DN's have to be filtered? A valid resolution status
// has to be between 1 and 5; 0 is "invalid";
// -1 means that no resolutionStatus parameter was passed into the
// servlet
boolean filterDiscNotes = checkResolutionStatus(resolutionStatusIds);
boolean filterforDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
StudyDAO studyDAO = new StudyDAO(dataSource);
// what is the purpose of this data member?
discrepancyNoteDAO.setFetchMapping(true);
int parentStudyId = currentStudy.getParentStudyId();
Set<String> hiddenCrfNames = new TreeSet<String>();
if (parentStudyId > 0) {
hiddenCrfNames = new EventDefinitionCRFDAO(dataSource).findHiddenCrfNamesBySite(currentStudy);
}
allDiscNotes = discrepancyNoteDAO.findAllDiscrepancyNotesDataByStudy(currentStudy);
if (filterDiscNotes) {
// filter for the resolution status
allDiscNotes = filterDiscNotes(allDiscNotes, resolutionStatusIds);
}
if (filterforDiscNoteType) {
// filter for the ddiscrepancyNoteTypeId
allDiscNotes = filterforDiscNoteType(allDiscNotes, discNoteType);
}
return allDiscNotes;
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method filterDiscNotesBySubject.
/**
* Filter a List of DiscrepancyNoteBeans by subject id.
*
* @param allDiscNotes
* A List of DiscrepancyNoteBeans prior to filtering.
* @param subjectId
* An int subject id.
* @param dataSource
* A DataSource object used by DAO methods.
* @return The filtered List of DiscrepancyNoteBeans.
*/
public List<DiscrepancyNoteBean> filterDiscNotesBySubject(List<DiscrepancyNoteBean> allDiscNotes, int subjectId, DataSource dataSource) {
// Do not filter this List if the subjectId < 1
if (!(subjectId >= 1)) {
return allDiscNotes;
}
StudySubjectDAO studySubjDAO = new StudySubjectDAO(dataSource);
StudySubjectBean studySubjBean = new StudySubjectBean();
studySubjBean = (StudySubjectBean) studySubjDAO.findByPK(subjectId);
List<DiscrepancyNoteBean> newDiscNotes = new ArrayList<DiscrepancyNoteBean>();
for (DiscrepancyNoteBean dnBean : allDiscNotes) {
if (dnBean.getSubjectName().equalsIgnoreCase(studySubjBean.getLabel())) {
newDiscNotes.add(dnBean);
}
}
return newDiscNotes;
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method getDiscNoteCountFromDisplayEvents.
private Map<String, Integer> getDiscNoteCountFromDisplayEvents(List<DisplayStudyEventBean> disBeans, int eventCRFId) {
Map<String, Integer> discNoteMap = new HashMap<String, Integer>();
if (eventCRFId == 0 || disBeans == null) {
return discNoteMap;
}
List<DiscrepancyNoteBean> dnBeans;
for (DisplayStudyEventBean eventBean : disBeans) {
dnBeans = eventBean.getStudyEvent().getDiscBeanList();
for (String statusName : RESOLUTION_STATUS.keySet()) {
discNoteMap.put(statusName, getDiscNoteCountByStatusEventCRFId(dnBeans, RESOLUTION_STATUS.get(statusName), eventCRFId));
}
}
return discNoteMap;
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method createThreads.
public List<DiscrepancyNoteThread> createThreads(List<DiscrepancyNoteBean> allDiscNotes, DataSource dataSource, StudyBean currentStudy) {
List<DiscrepancyNoteThread> dnThreads = new ArrayList<DiscrepancyNoteThread>();
if (allDiscNotes == null || allDiscNotes.isEmpty()) {
return dnThreads;
}
if (currentStudy == null) {
currentStudy = new StudyBean();
}
List<DiscrepancyNoteBean> childDiscBeans = new ArrayList<DiscrepancyNoteBean>();
List<DiscrepancyNoteBean> eventCRFChildDiscBeans = new ArrayList<DiscrepancyNoteBean>();
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
DiscrepancyNoteThread tempDNThread = null;
int resolutionStatusId = 0;
for (DiscrepancyNoteBean discBean : allDiscNotes) {
tempDNThread = new DiscrepancyNoteThread();
tempDNThread.setStudyId(currentStudy.getId());
tempDNThread.getLinkedNoteList().addFirst(discBean);
// childDiscBeans should be empty here
if (!childDiscBeans.isEmpty()) {
childDiscBeans.clear();
}
childDiscBeans = discBean.getChildren();
Collections.sort(childDiscBeans);
resolutionStatusId = discBean.getResolutionStatusId();
// the thread's status id is the parent's in this case, when there
// are no children
tempDNThread.setLatestResolutionStatus(this.getResolutionStatusName(resolutionStatusId));
if (!childDiscBeans.isEmpty()) {
for (DiscrepancyNoteBean childBean : childDiscBeans) {
/*
if (childBean.getResolutionStatusId() != resolutionStatusId) {
// BWP issue 3468 WHO 5/2009: this local variable needs
// to be updated>>
resolutionStatusId = childBean.getResolutionStatusId();
// <<
tempDNThread.setLatestResolutionStatus(this.getResolutionStatusName(childBean.getResolutionStatusId()));
}
*/
tempDNThread.getLinkedNoteList().offer(childBean);
}
}
dnThreads.add(tempDNThread);
}
/*
// Do the filtering here; remove any DN threads that do not have any
// notes
LinkedList<DiscrepancyNoteBean> linkedList = null;
if (resolutionStatusIds != null && !resolutionStatusIds.isEmpty()) {
for (DiscrepancyNoteThread dnThread : dnThreads) {
linkedList = new LinkedList<DiscrepancyNoteBean>();
for (DiscrepancyNoteBean discBean : dnThread.getLinkedNoteList()) {
for (int statusId : resolutionStatusIds) {
if (discBean.getResolutionStatusId() == statusId) {
linkedList.offer(discBean);
}
}
}
dnThread.setLinkedNoteList(linkedList);
}
dnThreads = removeEmptyDNThreads(dnThreads);
}
if (discNoteType >= 1 && discNoteType <= 5) {
for (DiscrepancyNoteThread dnThread : dnThreads) {
linkedList = new LinkedList<DiscrepancyNoteBean>();
for (DiscrepancyNoteBean discBean : dnThread.getLinkedNoteList()) {
if (discBean.getDiscrepancyNoteTypeId() == discNoteType) {
linkedList.offer(discBean);
}
}
dnThread.setLinkedNoteList(linkedList);
}
dnThreads = removeEmptyDNThreads(dnThreads);
}
*/
return dnThreads;
}
Aggregations