Search in sources :

Example 1 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean 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);
    }
}
Also used : HashMap(java.util.HashMap) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) 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) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 2 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method getFormLayoutRefs.

List<ElementRefBean> getFormLayoutRefs(ElementRefBean formRef, int defaultVersionId) {
    CRFBean crfBean = crfdao.findByOid(formRef.getElementDefOID());
    List<FormLayoutBean> formLayouts = fldao.findAllByCRFId(crfBean.getId());
    List<ElementRefBean> elementRefs = new ArrayList<>();
    ElementRefBean element;
    for (FormLayoutBean formLayout : formLayouts) {
        element = new ElementRefBean();
        element.setName(formLayout.getName());
        if (formLayout.getId() == defaultVersionId) {
            element.setDefaultVersion(true);
        } else {
            element.setDefaultVersion(false);
        }
        elementRefs.add(element);
    }
    return elementRefs;
}
Also used : ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 3 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class OdmController method getFormDataPerCrf.

private ODMcomplexTypeDefinitionFormData getFormDataPerCrf(FormLayoutBean formLayout, StudyEventBean nextEvent, List<EventCRFBean> eventCrfs, CRFDAO crfDAO, String formUrl, boolean itemDataExists) {
    EventCRFBean selectedEventCRFBean = null;
    CRFBean crfBean = (CRFBean) crfDAO.findByVersionId(formLayout.getId());
    for (EventCRFBean eventCRFBean : eventCrfs) {
        if (eventCRFBean.getCRFVersionId() == formLayout.getId()) {
            selectedEventCRFBean = eventCRFBean;
            break;
        }
    }
    return generateFormData(formLayout, nextEvent, selectedEventCRFBean, crfBean, formUrl, itemDataExists);
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 4 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class RuleRunner method prepareEmailContents.

HashMap<String, String> prepareEmailContents(RuleSetBean ruleSet, RuleSetRuleBean ruleSetRule, StudyBean currentStudy, RuleActionBean ruleAction) {
    // get the Study Event
    StudyEventBean studyEvent = (StudyEventBean) getStudyEventDao().findByPK(Integer.valueOf(getExpressionService().getStudyEventDefenitionOrdninalCurated(ruleSet.getTarget().getValue())));
    // get the Study Subject
    StudySubjectBean studySubject = (StudySubjectBean) getStudySubjectDao().findByPK(studyEvent.getStudySubjectId());
    // get Study/Site Associated with Subject
    StudyBean theStudy = (StudyBean) getStudyDao().findByPK(studySubject.getStudyId());
    String theStudyName, theSiteName = "";
    if (theStudy.getParentStudyId() > 0) {
        StudyBean theParentStudy = (StudyBean) getStudyDao().findByPK(theStudy.getParentStudyId());
        theStudyName = theParentStudy.getName() + " / " + theParentStudy.getIdentifier();
        theSiteName = theStudy.getName() + " / " + theStudy.getIdentifier();
    } else {
        theStudyName = theStudy.getName() + " / " + theStudy.getIdentifier();
    }
    // get the eventCrf & subsequently the CRF Version
    // EventCRFBean eventCrf = (EventCRFBean) getEventCrfDao().findAllByStudyEvent(studyEvent).get(0);
    EventCRFBean eventCrf = (EventCRFBean) getEventCrfDao().findAllByStudyEventAndCrfOrCrfVersionOid(studyEvent, getExpressionService().getCrfOid(ruleSet.getTarget().getValue())).get(0);
    CRFVersionBean crfVersion = (CRFVersionBean) getCrfVersionDao().findByPK(eventCrf.getCRFVersionId());
    CRFBean crf = (CRFBean) getCrfDao().findByPK(crfVersion.getCrfId());
    String studyEventDefinitionName = getExpressionService().getStudyEventDefinitionFromExpression(ruleSet.getTarget().getValue(), currentStudy).getName();
    studyEventDefinitionName += " [" + studyEvent.getSampleOrdinal() + "]";
    String itemGroupName = getExpressionService().getItemGroupNameAndOrdinal(ruleSet.getTarget().getValue());
    ItemGroupBean itemGroupBean = getExpressionService().getItemGroupExpression(ruleSet.getTarget().getValue());
    ItemBean itemBean = getExpressionService().getItemExpression(ruleSet.getTarget().getValue(), itemGroupBean);
    String itemName = itemBean.getName();
    SectionBean section = (SectionBean) getSectionDAO().findByPK(getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemBean.getId(), crfVersion.getId()).getSectionId());
    StringBuffer sb = new StringBuffer();
    ResourceBundle respage = ResourceBundleProvider.getPageMessagesBundle();
    sb.append(respage.getString("email_header_1"));
    sb.append(" " + contextPath + " ");
    sb.append(respage.getString("email_header_2"));
    sb.append(" '" + currentStudy.getName() + "' ");
    sb.append(respage.getString("email_header_3"));
    sb.append(" \n\n ");
    sb.append(respage.getString("email_body_1") + " " + theStudyName + " \n ");
    sb.append(respage.getString("email_body_1_a") + " " + theSiteName + " \n ");
    sb.append(respage.getString("email_body_2") + " " + studySubject.getName() + " \n ");
    sb.append(respage.getString("email_body_3") + " " + studyEventDefinitionName + " \n ");
    sb.append(respage.getString("email_body_4") + " " + crf.getName() + " " + crfVersion.getName() + " \n ");
    sb.append(respage.getString("email_body_5") + " " + section.getTitle() + " \n ");
    sb.append(respage.getString("email_body_6") + " " + itemGroupName + " \n ");
    sb.append(respage.getString("email_body_7") + " " + itemName + " \n ");
    sb.append(respage.getString("email_body_8") + " " + ruleAction.getCuratedMessage() + " \n ");
    sb.append(" \n\n ");
    sb.append(respage.getString("email_body_9"));
    sb.append(" " + contextPath + " ");
    sb.append(respage.getString("email_body_10"));
    sb.append(" \n");
    requestURLMinusServletPath = requestURLMinusServletPath == null ? "" : requestURLMinusServletPath;
    sb.append(requestURLMinusServletPath + "/ViewSectionDataEntry?ecId=" + eventCrf.getId() + "&sectionId=" + section.getId() + "&tabId=" + section.getOrdinal());
    // &eventId="+ studyEvent.getId());
    sb.append("\n\n");
    sb.append(respage.getString("email_footer"));
    String subject = contextPath + " - [" + currentStudy.getName() + "] ";
    String ruleSummary = ruleAction.getSummary() != null ? ruleAction.getSummary() : "";
    String message = ruleSummary.length() < 20 ? ruleSummary : ruleSummary.substring(0, 20) + " ... ";
    subject += message;
    HashMap<String, String> emailContents = new HashMap<String, String>();
    emailContents.put("body", sb.toString());
    emailContents.put("subject", subject);
    return emailContents;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) HashMap(java.util.HashMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) ResourceBundle(java.util.ResourceBundle) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean)

Example 5 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class BatchCRFMigrationServlet method processRequest.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    ArrayList<CRFVersionBean> crfVersionList = null;
    ArrayList<StudyEventDefinitionBean> eventList = null;
    ArrayList<StudyBean> siteList = null;
    // checks which module the requests are from, manage or admin
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    int crfId = fp.getInt(CRF_ID);
    if (crfId == 0) {
        addPageMessage(respage.getString("please_choose_a_CRF_to_view"));
        forwardPage(Page.CRF_LIST);
    } else {
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource());
        CRFBean crf = (CRFBean) cdao.findByPK(crfId);
        request.setAttribute("crfName", crf.getName());
        ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) vdao.findAllByCRF(crfId);
        crfVersionList = new ArrayList<CRFVersionBean>();
        for (CRFVersionBean version : versions) {
            if (version.getStatus().isAvailable())
                crfVersionList.add(version);
        }
        crf.setVersions(crfVersionList);
        ArrayList<StudyBean> listOfSites = (ArrayList<StudyBean>) sdao().findAllByParent(currentStudy.getId());
        siteList = new ArrayList<StudyBean>();
        StudyBean studyBean = new StudyBean();
        studyBean.setOid(currentStudy.getOid());
        studyBean.setName(resterm.getString("Study_Level_Subjects_Only"));
        siteList.add(studyBean);
        for (StudyBean s : listOfSites) {
            if (s.getStatus().isAvailable()) {
                siteList.add(s);
            }
        }
        ArrayList<StudyEventDefinitionBean> listOfDefn = seddao().findAllByStudy(currentStudy);
        eventList = new ArrayList<StudyEventDefinitionBean>();
        for (StudyEventDefinitionBean d : listOfDefn) {
            if (d.getStatus().isAvailable()) {
                eventList.add(d);
            }
        }
        // if coming from change crf version -> display message
        String crfVersionChangeMsg = fp.getString("isFromCRFVersionBatchChange");
        if (crfVersionChangeMsg != null && !crfVersionChangeMsg.equals("")) {
            addPageMessage(crfVersionChangeMsg);
        }
        request.setAttribute("study", currentStudy);
        request.setAttribute("siteList", siteList);
        request.setAttribute("eventList", eventList);
        request.setAttribute(CRF, crf);
        forwardPage(Page.BATCH_CRF_MIGRATION);
    }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean)

Aggregations

CRFBean (org.akaza.openclinica.bean.admin.CRFBean)138 ArrayList (java.util.ArrayList)95 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)78 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)78 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)70 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)67 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)63 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)56 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)44 HashMap (java.util.HashMap)43 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)43 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)40 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)37 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)29 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)27 Iterator (java.util.Iterator)26 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)26 DisplayEventCRFBean (org.akaza.openclinica.bean.submit.DisplayEventCRFBean)22 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)21 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)20