use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteDAO method findExistingNotesForItemData.
public ArrayList findExistingNotesForItemData(int itemDataId) {
this.setTypesExpected();
ArrayList alist = new ArrayList();
HashMap variables = new HashMap();
variables.put(Integer.valueOf(1), Integer.valueOf(itemDataId));
alist = this.select(digester.getQuery("findExistingNotesForItemData"), variables);
ArrayList<DiscrepancyNoteBean> al = new ArrayList<DiscrepancyNoteBean>();
Iterator it = alist.iterator();
while (it.hasNext()) {
HashMap hm = (HashMap) it.next();
DiscrepancyNoteBean eb = (DiscrepancyNoteBean) this.getEntityFromHashMap(hm);
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method filterDiscNotesForOnlyParents.
/**
* Take a List of DiscrepancyNoteBeans, and filter the List to return only
* "parent" DiscrepancyNoteBeans. the parameter List<DiscrepancyNoteThread>
* contains each parent the DiscrepancyNoteBeans are compared to in order to
* filter the original List.
*
* @param dnBeans
* A List of DiscrepancyNoteBeans.
* @param dnThreads
* A List of DiscrepancyNoteThreads.
* @return The filtered List of DiscrepancyNoteBeans.
*/
public List<DiscrepancyNoteBean> filterDiscNotesForOnlyParents(List<DiscrepancyNoteBean> dnBeans, List<DiscrepancyNoteThread> dnThreads) {
// Take the parent of each thread, and compare it to each passed
// in DiscrepancyNoteBean; only return a DiscrepancyNoteBean if it
// equals a parent bean
List<DiscrepancyNoteBean> newBeans = new ArrayList<DiscrepancyNoteBean>();
DiscrepancyNoteBean tempBean;
outer: for (DiscrepancyNoteBean noteBean : dnBeans) {
for (DiscrepancyNoteThread dnThread : dnThreads) {
// the parent...
tempBean = dnThread.getLinkedNoteList().getFirst();
if (tempBean != null) {
if (tempBean.getId() == noteBean.getId()) {
newBeans.add(noteBean);
// next noteBean
continue outer;
}
}
}
}
return newBeans;
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method injectParentDiscNotesIntoDisplayStudyEvents.
public void injectParentDiscNotesIntoDisplayStudyEvents(List<DisplayStudyEventBean> displayStudyBeans, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType) {
if (displayStudyBeans == null) {
return;
}
// booleans representing whether this method should only get
// DiscrepancyNoteBeans with
// certain resolution status or discrepancyNoteTypeId number.
boolean hasResolutionStatus = this.checkResolutionStatus(resolutionStatusIds);
boolean hasDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
StudyEventBean studyEventBean;
List<EventCRFBean> eventCRFBeans = new ArrayList<EventCRFBean>();
List<DiscrepancyNoteBean> foundDiscNotes = new ArrayList<DiscrepancyNoteBean>();
for (DisplayStudyEventBean dStudyEventBean : displayStudyBeans) {
studyEventBean = dStudyEventBean.getStudyEvent();
// All EventCRFs for a study event
eventCRFBeans = eventCRFDAO.findAllByStudyEvent(studyEventBean);
for (EventCRFBean eventCrfBean : eventCRFBeans) {
// Find ItemData type notes associated with an event crf
foundDiscNotes = discrepancyNoteDAO.findParentItemDataDNotesFromEventCRF(eventCrfBean);
// filter for any specified disc note type
if (!foundDiscNotes.isEmpty() && hasDiscNoteType) {
// only include disc notes that have the specified disc note
// type id
foundDiscNotes = filterforDiscNoteType(foundDiscNotes, discNoteType);
}
if (!foundDiscNotes.isEmpty()) {
if (!hasResolutionStatus) {
studyEventBean.getDiscBeanList().addAll(foundDiscNotes);
} else {
// session variable
for (DiscrepancyNoteBean discBean : foundDiscNotes) {
for (int statusId : resolutionStatusIds) {
if (discBean.getResolutionStatusId() == statusId) {
studyEventBean.getDiscBeanList().add(discBean);
}
}
}
}
}
}
// end for(EventCRFBean...
}
// end for (DisplayStudyEventBean
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method injectDiscNotesIntoStudyEvents.
/**
* This method links discrepancy notes to the study event and study subject
* associated with those notes
*
* @param studyBeans
* A List of StudyEventBeans.
* @param allDiscNotes
* A List of DiscrepancyNoteBeans associated with a single study.
* @param dataSource
* A DataSource used to get from the database a study subject
* associated with a study event.
*/
public void injectDiscNotesIntoStudyEvents(List<StudyEventBean> studyBeans, List<DiscrepancyNoteBean> allDiscNotes, DataSource dataSource) {
if (studyBeans == null || allDiscNotes == null) {
return;
}
StudySubjectDAO studySubjDAO = new StudySubjectDAO(dataSource);
StudySubjectBean studySubjBean = new StudySubjectBean();
for (StudyEventBean sbean : studyBeans) {
// Get the StudySubjectBean associated with the study event
studySubjBean = (StudySubjectBean) studySubjDAO.findByPK(sbean.getStudySubjectId());
// equals the StudySubjectBean's name
for (DiscrepancyNoteBean discBean : allDiscNotes) {
if (sbean.getStudyEventDefinition().getName().equalsIgnoreCase(discBean.getEventName()) && studySubjBean.getLabel().equalsIgnoreCase(discBean.getSubjectName())) {
// add discrepancy note to the study event list of notes
// Each study bean has a List property containing its
// associated
// DiscrepancyNoteBeans
sbean.getDiscBeanList().add(discBean);
}
}
}
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method updateStatusOfParents.
/**
* Take a List of "parent" DiscrepancyNoteBeans and if they have any
* "children," make sure that the resolution status id of the parent matches
* that of the last child DiscrepancyNoteBean.
*
* @param allDiscNotes
* A List of DiscrepancyNoteBeans.
* @param dataSource
* The DataSource the DAO uses.
* @param currentStudy
* A StudyBean representing the current study.
*/
public void updateStatusOfParents(List<DiscrepancyNoteBean> allDiscNotes, DataSource dataSource, StudyBean currentStudy) {
if (allDiscNotes == null || allDiscNotes.isEmpty()) {
return;
}
List<DiscrepancyNoteBean> childDiscBeans = new ArrayList<DiscrepancyNoteBean>();
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
DiscrepancyNoteBean lastChild = new DiscrepancyNoteBean();
int resolutionStatusId = 0;
for (DiscrepancyNoteBean discBean : allDiscNotes) {
childDiscBeans = discrepancyNoteDAO.findAllByStudyAndParent(currentStudy, discBean.getId());
if (!childDiscBeans.isEmpty()) {
lastChild = childDiscBeans.get(childDiscBeans.size() - 1);
resolutionStatusId = lastChild.getResolutionStatusId();
if (discBean.getResolutionStatusId() != resolutionStatusId) {
discBean.setResolutionStatusId(resolutionStatusId);
}
}
// clear the List for the next iteration
if (childDiscBeans != null) {
childDiscBeans.clear();
}
}
}
Aggregations