use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class UnlockCRFVersionServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int crfVersionId = fp.getInt("id");
String action = fp.getString("action");
// checks which module the requests are from
String module = fp.getString(MODULE);
request.setAttribute(MODULE, module);
if (crfVersionId == 0) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study"));
forwardPage(Page.CRF_LIST_SERVLET);
return;
}
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionBean version = (CRFVersionBean) cvdao.findByPK(crfVersionId);
CRFBean crf = (CRFBean) cdao.findByPK(version.getCrfId());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
ArrayList eventCRFs = ecdao.findAllStudySubjectByCRFVersion(crfVersionId);
if (StringUtil.isBlank(action)) {
request.setAttribute("crfVersionToUnlock", version);
request.setAttribute("crf", crf);
request.setAttribute("eventSubjectsUsingVersion", eventCRFs);
forwardPage(Page.CONFIRM_UNLOCKING_CRF_VERSION);
} else if ("confirm".equalsIgnoreCase(action)) {
version.setStatus(Status.AVAILABLE);
version.setUpdater(ub);
cvdao.update(version);
addPageMessage(respage.getString("crf_version_unarchived_successfully"));
forwardPage(Page.CRF_LIST_SERVLET);
}
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class SignStudySubjectServlet method getDisplayEventCRFs.
/**
* Each of the event CRFs with its corresponding CRFBean. Then generates a
* list of DisplayEventCRFBeans, one for each event CRF.
*
* @param eventCRFs
* The list of event CRFs for this study event.
* @return The list of DisplayEventCRFBeans for this study event.
*/
public static ArrayList getDisplayEventCRFs(StudyBean study, DataSource ds, ArrayList eventCRFs, UserAccountBean ub, StudyUserRoleBean currentRole, SubjectEventStatus status) {
ArrayList answer = new ArrayList();
// HashMap definitionsById = new HashMap();
int i;
/*
* for (i = 0; i < eventDefinitionCRFs.size(); i++) {
* EventDefinitionCRFBean edc = (EventDefinitionCRFBean)
* eventDefinitionCRFs.get(i); definitionsById.put(new
* Integer(edc.getStudyEventDefinitionId()), edc); }
*/
StudyEventDAO sedao = new StudyEventDAO(ds);
CRFDAO cdao = new CRFDAO(ds);
CRFVersionDAO cvdao = new CRFVersionDAO(ds);
ItemDataDAO iddao = new ItemDataDAO(ds);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
// populate the event CRF with its crf bean
int crfVersionId = ecb.getCRFVersionId();
CRFBean cb = cdao.findByVersionId(crfVersionId);
ecb.setCrf(cb);
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(crfVersionId);
ecb.setCrfVersion(cvb);
// then get the definition so we can call
// DisplayEventCRFBean.setFlags
int studyEventId = ecb.getStudyEventId();
int studyEventDefinitionId = sedao.getDefinitionIdFromStudyEventId(studyEventId);
// EventDefinitionCRFBean edc = (EventDefinitionCRFBean)
// definitionsById.get(new Integer(
// studyEventDefinitionId));
// fix problem of the above code(commented out), find the correct
// edc, note that on definitionId can be related to multiple
// eventdefinitioncrfBeans
EventDefinitionCRFBean edc = edcdao.findByStudyEventDefinitionIdAndCRFId(study, studyEventDefinitionId, cb.getId());
// 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 (!cvb.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();
// 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());
// }
ArrayList idata = iddao.findAllByEventCRFId(ecb.getId());
if (!idata.isEmpty()) {
// consider an event crf started only if item data get
// created
answer.add(dec);
}
}
}
return answer;
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class TableOfContentsServlet method getDisplayBean.
public static DisplayTableOfContentsBean getDisplayBean(EventCRFBean ecb, DataSource ds, StudyBean currentStudy) {
DisplayTableOfContentsBean answer = new DisplayTableOfContentsBean();
answer.setEventCRF(ecb);
// get data
StudySubjectDAO ssdao = new StudySubjectDAO(ds);
StudySubjectBean ssb = (StudySubjectBean) ssdao.findByPK(ecb.getStudySubjectId());
answer.setStudySubject(ssb);
StudyEventDAO sedao = new StudyEventDAO(ds);
StudyEventBean seb = (StudyEventBean) sedao.findByPK(ecb.getStudyEventId());
answer.setStudyEvent(seb);
SectionDAO sdao = new SectionDAO(ds);
ArrayList sections = getSections(ecb, ds);
answer.setSections(sections);
// get metadata
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(ds);
StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(seb.getStudyEventDefinitionId());
answer.setStudyEventDefinition(sedb);
CRFVersionDAO cvdao = new CRFVersionDAO(ds);
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(ecb.getCRFVersionId());
answer.setCrfVersion(cvb);
CRFDAO cdao = new CRFDAO(ds);
CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
answer.setCrf(cb);
StudyBean studyForStudySubject = new StudyDAO(ds).findByStudySubjectId(ssb.getId());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
EventDefinitionCRFBean edcb = edcdao.findByStudyEventDefinitionIdAndCRFId(studyForStudySubject, sedb.getId(), cb.getId());
answer.setEventDefinitionCRF(edcb);
answer.setAction(getActionForStage(ecb.getStage()));
return answer;
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class ViewDiscrepancyNoteServlet method setupStudyEventCRFAttributes.
private void setupStudyEventCRFAttributes(EventCRFBean eventCRFBean) {
StudyEventDAO sed = new StudyEventDAO(sm.getDataSource());
StudyEventBean studyEventBean = (StudyEventBean) sed.findByPK(eventCRFBean.getStudyEventId());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(studyEventBean.getStudyEventDefinitionId());
studyEventBean.setName(sedb.getName());
request.setAttribute("studyEvent", studyEventBean);
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFVersionBean cv = (CRFVersionBean) cvdao.findByPK(eventCRFBean.getCRFVersionId());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFBean crf = (CRFBean) cdao.findByPK(cv.getCrfId());
request.setAttribute("crf", crf);
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class StudyEventDefinitionEndpoint method mapConfirmation.
/**
* Create Response
*
* @param confirmation
* @return
* @throws Exception
*/
private Element mapConfirmation(StudyBean study, String confirmation) throws Exception {
DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
Document document = docBuilder.newDocument();
Element responseElement = document.createElementNS(NAMESPACE_URI_V1, "listAllResponse");
Element resultElement = document.createElementNS(NAMESPACE_URI_V1, "result");
resultElement.setTextContent(confirmation);
responseElement.appendChild(resultElement);
Element studyListElement = document.createElementNS(NAMESPACE_URI_V1, "studyEventDefinitions");
responseElement.appendChild(studyListElement);
List<StudyEventDefinitionBean> eventList = getStudyEventDefinitionDao().findAllByStudy(study);
for (int index = 0; index < eventList.size(); index++) {
StudyEventDefinitionBean event = eventList.get(index);
Element studyElement = document.createElementNS(NAMESPACE_URI_V1, "studyEventDefinition");
Element element = document.createElementNS(NAMESPACE_URI_V1, "oid");
element.setTextContent(event.getOid());
studyElement.appendChild(element);
element = document.createElementNS(NAMESPACE_URI_V1, "name");
element.setTextContent(event.getName());
studyElement.appendChild(element);
studyListElement.appendChild(studyElement);
List<EventDefinitionCRFBean> eventCrfs = (List<EventDefinitionCRFBean>) getEventDefinitionCRFDao().findAllByDefinition(study, event.getId());
Element eventDefinitionCrfListElement = document.createElementNS(NAMESPACE_URI_V1, "eventDefinitionCrfs");
studyElement.appendChild(eventDefinitionCrfListElement);
for (int i = 0; i < eventCrfs.size(); i++) {
EventDefinitionCRFBean eventCrf = eventCrfs.get(i);
Element eventDefinitionCrfElement = document.createElementNS(NAMESPACE_URI_V1, "eventDefinitionCrf");
eventDefinitionCrfListElement.appendChild(eventDefinitionCrfElement);
element = document.createElementNS(NAMESPACE_URI_V1, "required");
element.setTextContent(String.valueOf(eventCrf.isRequiredCRF()));
eventDefinitionCrfElement.appendChild(element);
element = document.createElementNS(NAMESPACE_URI_V1, "doubleDataEntry");
element.setTextContent(String.valueOf(eventCrf.isDoubleEntry()));
eventDefinitionCrfElement.appendChild(element);
element = document.createElementNS(NAMESPACE_URI_V1, "passwordRequired");
element.setTextContent(String.valueOf(eventCrf.isElectronicSignature()));
eventDefinitionCrfElement.appendChild(element);
element = document.createElementNS(NAMESPACE_URI_V1, "hideCrf");
element.setTextContent(String.valueOf(eventCrf.isHideCrf()));
eventDefinitionCrfElement.appendChild(element);
element = document.createElementNS(NAMESPACE_URI_V1, "participantForm");
element.setTextContent(String.valueOf(eventCrf.isParticipantForm()));
eventDefinitionCrfElement.appendChild(element);
element = document.createElementNS(NAMESPACE_URI_V1, "allowAnonymousSubmission");
element.setTextContent(String.valueOf(eventCrf.isAllowAnonymousSubmission()));
eventDefinitionCrfElement.appendChild(element);
element = document.createElementNS(NAMESPACE_URI_V1, "submissionUrl");
element.setTextContent(String.valueOf(eventCrf.getSubmissionUrl()));
eventDefinitionCrfElement.appendChild(element);
element = document.createElementNS(NAMESPACE_URI_V1, "offline");
element.setTextContent(String.valueOf(eventCrf.isOffline()));
eventDefinitionCrfElement.appendChild(element);
element = document.createElementNS(NAMESPACE_URI_V1, "sourceDataVerificaiton");
element.setTextContent(String.valueOf(eventCrf.getSourceDataVerification()));
eventDefinitionCrfElement.appendChild(element);
Element crfElement = document.createElementNS(NAMESPACE_URI_V1, "crf");
eventDefinitionCrfElement.appendChild(crfElement);
CRFBean crfBean = (CRFBean) getCrfDao().findByPK(eventCrf.getCrfId());
element = document.createElementNS(NAMESPACE_URI_V1, "oid");
element.setTextContent(crfBean.getOid());
crfElement.appendChild(element);
element = document.createElementNS(NAMESPACE_URI_V1, "name");
element.setTextContent(crfBean.getName());
crfElement.appendChild(element);
Element crfVersionElement = document.createElementNS(NAMESPACE_URI_V1, "defaultCrfVersion");
eventDefinitionCrfElement.appendChild(crfVersionElement);
CRFVersionBean crfVersionBean = (CRFVersionBean) getCrfVersionDao().findByPK(eventCrf.getDefaultVersionId());
element = document.createElementNS(NAMESPACE_URI_V1, "oid");
element.setTextContent(crfVersionBean.getOid());
crfVersionElement.appendChild(element);
element = document.createElementNS(NAMESPACE_URI_V1, "name");
element.setTextContent(crfVersionBean.getName());
crfVersionElement.appendChild(element);
}
}
return responseElement;
}
Aggregations