use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class StudySubjectServiceImpl method getUncompletedCRFs.
private ArrayList<DisplayEventDefinitionCRFBean> getUncompletedCRFs(List eventDefinitionCRFs, List eventCRFs, SubjectEventStatus status, Set<Integer> nonEmptyEventCrf, Map<Integer, FormLayoutBean> formLayoutById, Map<Integer, CRFBean> crfById) {
int i;
HashMap<Integer, Boolean> completed = new HashMap<Integer, Boolean>();
HashMap<Integer, EventCRFBean> startedButIncompleted = new HashMap<Integer, EventCRFBean>();
ArrayList<DisplayEventDefinitionCRFBean> answer = new ArrayList<DisplayEventDefinitionCRFBean>();
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
}
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
int crfId = formLayoutById.get(ecrf.getFormLayoutId()).getCrfId();
if (nonEmptyEventCrf.contains(ecrf.getId())) {
// this crf has data
// already
completed.put(new Integer(crfId), Boolean.TRUE);
} else {
// event crf got created, but no data entered
startedButIncompleted.put(new Integer(crfId), ecrf);
}
}
// TODO possible relation to 1689 here, tbh
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
// available (i.e., not removed)
if (edcrf.getStatus().equals(Status.AVAILABLE)) {
dedc.setEdc(edcrf);
// below added tbh, 112007 to fix bug 1943
if (status.equals(SubjectEventStatus.LOCKED)) {
dedc.setStatus(Status.LOCKED);
}
Boolean b = completed.get(new Integer(edcrf.getCrfId()));
EventCRFBean ev = startedButIncompleted.get(new Integer(edcrf.getCrfId()));
if (b == null || !b.booleanValue()) {
dedc.setEventCRF(ev);
answer.add(dedc);
}
}
}
return answer;
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class StudySubjectServiceImpl method populateUncompletedCRFsWithCRFAndVersions.
@SuppressWarnings({ "rawtypes", "unchecked" })
public void populateUncompletedCRFsWithCRFAndVersions(ArrayList<DisplayEventDefinitionCRFBean> uncompletedEventDefinitionCRFs, Map<Integer, FormLayoutBean> formLayoutById, Map<Integer, CRFBean> crfById) {
FormLayoutDAO formLayoutDAo = new FormLayoutDAO(dataSource);
int size = uncompletedEventDefinitionCRFs.size();
for (int i = 0; i < size; i++) {
DisplayEventDefinitionCRFBean dedcrf = uncompletedEventDefinitionCRFs.get(i);
CRFBean cb = crfById.get(dedcrf.getEdc().getCrfId());
dedcrf.getEdc().setCrf(cb);
ArrayList<FormLayoutBean> theVersions = (ArrayList<FormLayoutBean>) formLayoutDAo.findAllActiveByCRF(dedcrf.getEdc().getCrfId());
ArrayList<FormLayoutBean> versions = new ArrayList<FormLayoutBean>();
HashMap<String, FormLayoutBean> formLayoutIds = new HashMap<String, FormLayoutBean>();
for (int j = 0; j < theVersions.size(); j++) {
FormLayoutBean formLayout = theVersions.get(j);
formLayoutIds.put(String.valueOf(formLayout.getId()), formLayout);
}
if (!dedcrf.getEdc().getSelectedVersionIds().equals("")) {
String[] kk = dedcrf.getEdc().getSelectedVersionIds().split(",");
for (String string : kk) {
if (formLayoutIds.get(string) != null) {
versions.add(formLayoutIds.get(string));
}
}
} else {
versions = theVersions;
}
dedcrf.getEdc().setVersions(versions);
uncompletedEventDefinitionCRFs.set(i, dedcrf);
}
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class EnterDataForStudyEventServlet method getUncompletedCRFs.
/**
* Finds all the event definitions for which no event CRF exists - which is
* the list of event definitions with uncompleted event CRFs.
*
* @param eventDefinitionCRFs
* All of the event definition CRFs for this study event.
* @param eventCRFs
* All of the event CRFs for this study event.
* @return The list of event definitions for which no event CRF exists.
*/
private ArrayList getUncompletedCRFs(ArrayList eventDefinitionCRFs, ArrayList eventCRFs) {
int i;
HashMap completed = new HashMap();
HashMap startedButIncompleted = new HashMap();
ArrayList answer = new ArrayList();
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
}
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
int crfId = cvdao.getCRFIdFromCRFVersionId(ecrf.getCRFVersionId());
ArrayList idata = iddao.findAllByEventCRFId(ecrf.getId());
if (!idata.isEmpty()) {
// this crf has data already
completed.put(new Integer(crfId), Boolean.TRUE);
} else {
// event crf got created, but no data entered
startedButIncompleted.put(new Integer(crfId), ecrf);
}
}
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
dedc.setEdc(edcrf);
Boolean b = (Boolean) completed.get(new Integer(edcrf.getCrfId()));
EventCRFBean ev = (EventCRFBean) startedButIncompleted.get(new Integer(edcrf.getCrfId()));
if (b == null || !b.booleanValue()) {
dedc.setEventCRF(ev);
answer.add(dedc);
}
}
return answer;
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class ViewStudySubjectServlet method getUncompletedCRFs.
/**
* Finds all the event definitions for which no event CRF exists - which is
* the list of event definitions with uncompleted event CRFs.
*
* @param eventDefinitionCRFs
* All of the event definition CRFs for this study event.
* @param eventCRFs
* All of the event CRFs for this study event.
* @return The list of event definitions for which no event CRF exists.
*/
public static ArrayList getUncompletedCRFs(DataSource ds, ArrayList eventDefinitionCRFs, ArrayList eventCRFs, SubjectEventStatus status) {
int i;
HashMap completed = new HashMap();
HashMap startedButIncompleted = new HashMap();
ArrayList answer = new ArrayList();
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
}
CRFVersionDAO cvdao = new CRFVersionDAO(ds);
ItemDataDAO iddao = new ItemDataDAO(ds);
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
// System.out.println("########event crf id:" + ecrf.getId());
int crfId = cvdao.getCRFIdFromCRFVersionId(ecrf.getCRFVersionId());
ArrayList idata = iddao.findAllByEventCRFId(ecrf.getId());
if (!idata.isEmpty()) {
// this crf has data already
completed.put(new Integer(crfId), Boolean.TRUE);
} else {
// event crf got created, but no data entered
// System.out.println("added one into startedButIncompleted" + ecrf.getId());
startedButIncompleted.put(new Integer(crfId), ecrf);
}
}
// TODO possible relation to 1689 here, tbh
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
// System.out.println("created dedc with edcrf
// "+edcrf.getCrfName()+" default version "+
// edcrf.getDefaultVersionName()+", id
// "+edcrf.getDefaultVersionId());
dedc.setEdc(edcrf);
// below added tbh, 112007 to fix bug 1943
if (status.equals(SubjectEventStatus.LOCKED)) {
dedc.setStatus(Status.LOCKED);
}
Boolean b = (Boolean) completed.get(new Integer(edcrf.getCrfId()));
EventCRFBean ev = (EventCRFBean) startedButIncompleted.get(new Integer(edcrf.getCrfId()));
if (b == null || !b.booleanValue()) {
// System.out.println("entered boolean loop with ev
// "+ev.getId()+" crf version id "+
// ev.getCRFVersionId());
dedc.setEventCRF(ev);
answer.add(dedc);
// System.out.println("just added dedc to answer");
// removed, tbh, since this is proving nothing, 11-2007
/*
* if (dedc.getEdc().getDefaultVersionId() !=
* dedc.getEventCRF().getId()) { System.out.println("ID
* MISMATCH: edc name "+dedc.getEdc().getName()+ ", default
* version id "+dedc.getEdc().getDefaultVersionId()+ " event crf
* id "+dedc.getEventCRF().getId()); }
*/
}
}
// System.out.println("size of answer" + answer.size());
return answer;
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class EnterDataForStudyEventServlet method populateUncompletedCRFsWithCRFAndVersions.
private void populateUncompletedCRFsWithCRFAndVersions(ArrayList uncompletedEventDefinitionCRFs) {
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
int size = uncompletedEventDefinitionCRFs.size();
for (int i = 0; i < size; i++) {
DisplayEventDefinitionCRFBean dedcrf = (DisplayEventDefinitionCRFBean) uncompletedEventDefinitionCRFs.get(i);
CRFBean cb = (CRFBean) cdao.findByPK(dedcrf.getEdc().getCrfId());
// check it here, tbh 102007
if (cb.getStatus().equals(Status.AVAILABLE)) {
// the above does not allow us to show the CRF as a thing with
// status of 'invalid' so we have to
// go to the JSP for this one, I think
dedcrf.getEdc().setCrf(cb);
ArrayList theVersions = (ArrayList) cvdao.findAllActiveByCRF(dedcrf.getEdc().getCrfId());
ArrayList versions = new ArrayList();
HashMap<String, CRFVersionBean> crfVersionIds = new HashMap<String, CRFVersionBean>();
for (int j = 0; j < theVersions.size(); j++) {
CRFVersionBean crfVersion = (CRFVersionBean) theVersions.get(j);
crfVersionIds.put(String.valueOf(crfVersion.getId()), crfVersion);
}
if (!dedcrf.getEdc().getSelectedVersionIds().equals("")) {
String[] kk = dedcrf.getEdc().getSelectedVersionIds().split(",");
for (String string : kk) {
if (crfVersionIds.get(string) != null) {
versions.add(crfVersionIds.get(string));
}
}
} else {
versions = theVersions;
}
dedcrf.getEdc().setVersions(versions);
// added tbh 092007, fix for 1461
if (versions != null && versions.size() != 0) {
boolean isLocked = false;
for (int ii = 0; ii < versions.size(); ii++) {
CRFVersionBean crfvb = (CRFVersionBean) versions.get(ii);
logger.debug("...checking versions..." + crfvb.getName());
if (!crfvb.getStatus().equals(Status.AVAILABLE)) {
logger.debug("found a non active crf version");
isLocked = true;
}
}
logger.debug("re-set event def, line 240: " + isLocked);
if (isLocked) {
dedcrf.setStatus(Status.LOCKED);
dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
}
uncompletedEventDefinitionCRFs.set(i, dedcrf);
} else {
// above added 092007, tbh
dedcrf.setStatus(Status.LOCKED);
dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
uncompletedEventDefinitionCRFs.set(i, dedcrf);
}
// added 102007, tbh
} else {
dedcrf.getEdc().setCrf(cb);
logger.debug("_found a non active crf _");
dedcrf.setStatus(Status.LOCKED);
dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
dedcrf.getEdc().getCrf().setStatus(Status.LOCKED);
uncompletedEventDefinitionCRFs.set(i, dedcrf);
}
// enclosing if statement added 102007, tbh
}
}
Aggregations