Search in sources :

Example 96 with CRFVersionBean

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);
    }
}
Also used : EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 97 with CRFVersionBean

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;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) ArrayList(java.util.ArrayList) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean)

Example 98 with CRFVersionBean

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;
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) DisplayTableOfContentsBean(org.akaza.openclinica.bean.submit.DisplayTableOfContentsBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 99 with CRFVersionBean

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);
}
Also used : EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 100 with CRFVersionBean

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;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) NodeList(org.w3c.dom.NodeList) List(java.util.List) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) Document(org.w3c.dom.Document) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) Endpoint(org.springframework.ws.server.endpoint.annotation.Endpoint) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Aggregations

CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)100 ArrayList (java.util.ArrayList)70 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)61 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)54 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)53 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)46 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)44 HashMap (java.util.HashMap)38 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)37 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)36 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)36 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)33 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)32 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)30 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)30 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)29 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)25 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)22 Iterator (java.util.Iterator)20 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)20