use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class EventDefinitionCRFDAO method findByStudyEventIdAndFormLayoutIdAndSiteIdAndParentStudyId.
public EventDefinitionCRFBean findByStudyEventIdAndFormLayoutIdAndSiteIdAndParentStudyId(int studyEventId, int formLayoutId, int siteId, int parentStudyId) {
EventDefinitionCRFBean answer = new EventDefinitionCRFBean();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(studyEventId));
variables.put(new Integer(2), new Integer(formLayoutId));
variables.put(new Integer(3), new Integer(siteId));
variables.put(new Integer(4), new Integer(parentStudyId));
variables.put(new Integer(5), new Integer(siteId));
String sql = digester.getQuery("findByStudyEventIdAndFormLayoutIdAndSiteIdAndParentStudyId");
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
while (it.hasNext()) {
answer = (EventDefinitionCRFBean) this.getEntityFromHashMap((HashMap) it.next());
}
return answer;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class StudySubjectServiceImpl method getDisplayEventCRFs.
private List<DisplayEventCRFBean> getDisplayEventCRFs(List eventCRFs, UserAccountBean ub, StudyUserRoleBean currentRole, SubjectEventStatus status, StudyBean study, Set<Integer> nonEmptyEventCrf, Map<Integer, FormLayoutBean> formLayoutById, Map<Integer, CRFBean> crfById, Integer studyEventDefinitionId, List eventDefinitionCRFs) {
ArrayList<DisplayEventCRFBean> answer = new ArrayList<DisplayEventCRFBean>();
for (int i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
// populate the event CRF with its crf bean
int formLayoutId = ecb.getFormLayoutId();
FormLayoutBean flb = formLayoutById.get(formLayoutId);
ecb.setFormLayout(flb);
CRFBean cb = crfById.get(flb.getCrfId());
ecb.setCrf(cb);
EventDefinitionCRFBean edc = null;
Iterator it = eventDefinitionCRFs.iterator();
while (it.hasNext()) {
EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) it.next();
if (edcBean.getCrfId() == cb.getId()) {
edc = edcBean;
break;
}
}
// rules updated 112007 tbh
if (status.equals(SubjectEventStatus.LOCKED) || status.equals(SubjectEventStatus.SKIPPED) || status.equals(SubjectEventStatus.STOPPED)) {
ecb.setStage(DataEntryStage.LOCKED);
// we need to set a SED-wide flag here, because other edcs
// in this event can be filled in and change the status, tbh
} else if (status.equals(SubjectEventStatus.INVALID)) {
ecb.setStage(DataEntryStage.LOCKED);
} else if (!cb.getStatus().equals(Status.AVAILABLE)) {
ecb.setStage(DataEntryStage.LOCKED);
} else if (!flb.getStatus().equals(Status.AVAILABLE)) {
ecb.setStage(DataEntryStage.LOCKED);
}
// TODO need to refactor since this is similar to other code, tbh
if (edc != null) {
// System.out.println("edc is not null, need to set flags");
DisplayEventCRFBean dec = new DisplayEventCRFBean();
dec.setEventDefinitionCRF(edc);
// System.out.println("edc.isDoubleEntry()" +
// edc.isDoubleEntry() + ecb.getId());
dec.setFlags(ecb, ub, currentRole, edc.isDoubleEntry());
if (dec.isLocked()) {
// System.out.println("*** found a locked DEC:
// "+edc.getCrfName());
}
if (nonEmptyEventCrf.contains(ecb.getId())) {
// consider an event crf started only if item data get
// created
answer.add(dec);
}
}
}
return answer;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class EventDefinitionCRFDAO method findAllActiveByEventDefinitionIdandStudyId.
public Collection findAllActiveByEventDefinitionIdandStudyId(int definitionId, int studyId) {
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(definitionId));
variables.put(new Integer(2), new Integer(studyId));
String sql = digester.getQuery("findAllActiveByEventDefinitionIdandStudyId");
ArrayList alist = this.select(sql, variables);
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
EventDefinitionCRFBean eb = (EventDefinitionCRFBean) this.getEntityFromHashMap((HashMap) it.next());
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class EventDefinitionCRFDAO method buildEventDefinitionCRFListByStudyEventDefinition.
/**
* Loads all {@link EventDefinitionCRFBean} associated to the list of
* {@link StudyEventDefinitionBean}
*
* @return
*/
public Map<Integer, SortedSet<EventDefinitionCRFBean>> buildEventDefinitionCRFListByStudyEventDefinition(Integer studySubjectId, Integer siteId, Integer parentStudyId) {
// <== Must be called first
this.setTypesExpected();
HashMap<Integer, Object> param = new HashMap<Integer, Object>();
int i = 1;
param.put(i++, studySubjectId);
param.put(i++, siteId);
param.put(i++, parentStudyId);
param.put(i++, studySubjectId);
param.put(i++, siteId);
List selectResult = select(digester.getQuery("buildEventDefinitionCRFListByStudyEventDefinition"), param);
Map<Integer, SortedSet<EventDefinitionCRFBean>> result = new HashMap<Integer, SortedSet<EventDefinitionCRFBean>>();
Iterator it = selectResult.iterator();
while (it.hasNext()) {
EventDefinitionCRFBean bean = (EventDefinitionCRFBean) this.getEntityFromHashMap((HashMap) it.next());
Integer studyEventDefinitionId = bean.getStudyEventDefinitionId();
if (!result.containsKey(studyEventDefinitionId)) {
result.put(studyEventDefinitionId, new TreeSet<EventDefinitionCRFBean>(new EventDefinitionCRFComparator()));
}
result.get(studyEventDefinitionId).add(bean);
}
return result;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class EventDefinitionCRFDAO method findAllParentsByEventDefinitionId.
public Collection findAllParentsByEventDefinitionId(int definitionId) {
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(definitionId));
String sql = digester.getQuery("findAllParentsByEventDefinitionId");
ArrayList alist = this.select(sql, variables);
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
EventDefinitionCRFBean eb = (EventDefinitionCRFBean) this.getEntityFromHashMap((HashMap) it.next());
al.add(eb);
}
return al;
}
Aggregations