Search in sources :

Example 26 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class RandomizeService method getStudy.

private StudyBean getStudy(String oid) {
    sdao = new StudyDAO(ds);
    StudyBean studyBean = (StudyBean) sdao.findByOid(oid);
    return studyBean;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 27 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class EventActionValidator method isEventActionValueExpressionValid.

private boolean isEventActionValueExpressionValid(PropertyBean property, AuditableBeanWrapper<RuleSetBean> ruleSetBeanWrapper) {
    StudyDAO studyDAO = new StudyDAO<String, ArrayList>(getDataSource());
    StudyBean study = (StudyBean) studyDAO.findByPK(ruleSetBeanWrapper.getAuditableBean().getStudyId());
    ExpressionBean expressionBean = isExpressionValid(property.getValueExpression(), ruleSetBeanWrapper);
    ExpressionObjectWrapper eow = new ExpressionObjectWrapper(dataSource, study, expressionBean, ruleSetBeanWrapper.getAuditableBean(), ExpressionObjectWrapper.CONTEXT_VALUE_EXPRESSION);
    ExpressionProcessor ep = ExpressionProcessorFactory.createExpressionProcessor(eow);
    ep.setRespage(respage);
    String errorString = ep.isRuleExpressionValid();
    if (errorString != null) {
        ruleSetBeanWrapper.error(errorString);
        return false;
    }
    // Verify expression generates a valid date string.
    try {
        SimpleDateFormat df = new SimpleDateFormat(VALUE_EXPRESSION_DATE_FORMAT);
        df.setLenient(false);
        String valueExpression = ep.testEvaluateExpression();
        Date valueExpressionDate = df.parse(valueExpression);
        // date that was entered, if it's not, we assume that the date is invalid
        if (!df.format(valueExpressionDate).equals(valueExpression)) {
            return false;
        }
    } catch (ParseException ex) {
        return false;
    }
    return true;
}
Also used : ExpressionProcessor(org.akaza.openclinica.domain.rule.expression.ExpressionProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ExpressionObjectWrapper(org.akaza.openclinica.domain.rule.expression.ExpressionObjectWrapper) ParseException(java.text.ParseException) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) SimpleDateFormat(java.text.SimpleDateFormat) ExpressionBean(org.akaza.openclinica.domain.rule.expression.ExpressionBean) Date(java.util.Date)

Example 28 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class SampleTest method testStatement.

public void testStatement() {
    StudyDAO studyDao = new StudyDAO(getDataSource());
    StudyBean study = (StudyBean) studyDao.findByPK(1);
    assertNotNull(study);
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 29 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class RuleSetServiceTest method getRuleSetsByCrfStudyAndStudyEventDefinition.

// @pgawade 08-NOV-2010 Commented out the test
// "testFilterRuleSetsByStudyEventOrdinal" temporarily. Krikor will look
// into this.
// public void testFilterRuleSetsByStudyEventOrdinal() {
// List<RuleSetBean> ruleSets = getRuleSets();
// StudyEventDAO studyEventDao = new StudyEventDAO(getDataSource());
// StudyEventBean studyEventBean = (StudyEventBean)
// studyEventDao.findByPK(1);
// 
// RuleSetServiceInterface instance = (RuleSetServiceInterface)
// getContext().getBean("ruleSetService");
// List<RuleSetBean> ruleSets1 =
// instance.filterRuleSetsByStudyEventOrdinal(ruleSets, studyEventBean);
// 
// assertEquals("Expressions Size inside this RuleSet should be 1", 1,
// ruleSets1.get(0).getExpressions().size());
// assertEquals("Expression Value should be SE_ED2REPEA[1].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// "SE_ED2REPEA[1].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// ruleSets1.get(0).getExpressions().get(0).getValue());
// }
// 
// @pgawade 08-NOV-2010 Commented out the test
// "testFilterRuleSetsByStudyEventOrdinalWithALL" temporarily. Krikor will
// look into this.
// public void testFilterRuleSetsByStudyEventOrdinalWithALL() {
// List<RuleSetBean> ruleSets = getRuleSets();
// StudyEventDAO studyEventDao = new StudyEventDAO(getDataSource());
// StudyEventBean studyEventBean = (StudyEventBean)
// studyEventDao.findByPK(2);
// 
// RuleSetServiceInterface instance = (RuleSetServiceInterface)
// getContext().getBean("ruleSetService");
// ruleSets.get(0).getTarget().setValue("SE_ED2REPEA[ALL].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME");
// List<RuleSetBean> ruleSets2 =
// instance.filterRuleSetsByStudyEventOrdinal(ruleSets, studyEventBean);
// 
// assertEquals("Expressions Size inside this RuleSet should be 1", 1,
// ruleSets2.get(0).getExpressions().size());
// assertEquals("Expression Value should be SE_ED2REPEA[2].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// "SE_ED2REPEA[2].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// ruleSets2.get(0).getExpressions().get(0).getValue());
// }
private List<RuleSetBean> getRuleSetsByCrfStudyAndStudyEventDefinition() {
    StudyDAO studyDao = new StudyDAO(getDataSource());
    StudyBean study = (StudyBean) studyDao.findByPK(1);
    assertNotNull(study);
    StudyEventDefinitionDAO studyEventDefinitionDao = new StudyEventDefinitionDAO(getDataSource());
    StudyEventDefinitionBean studyEventDefinition = (StudyEventDefinitionBean) studyEventDefinitionDao.findByPK(2);
    assertNotNull(studyEventDefinition);
    CRFVersionDAO crfVersionDao = new CRFVersionDAO(getDataSource());
    CRFVersionBean crfVersion = (CRFVersionBean) crfVersionDao.findByPK(2);
    assertNotNull(crfVersion);
    RuleSetServiceInterface instance = (RuleSetServiceInterface) getContext().getBean("ruleSetService");
    List<RuleSetBean> ruleSets = instance.getRuleSetsByCrfStudyAndStudyEventDefinition(study, studyEventDefinition, crfVersion);
    return ruleSets;
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean)

Example 30 with StudyDAO

use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.

the class DeleteEventCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    int studySubId = fp.getInt(STUDY_SUB_ID, true);
    int eventCRFId = fp.getInt(EVENT_CRF_ID);
    String action = request.getParameter("action");
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    if (eventCRFId == 0) {
        addPageMessage(respage.getString("please_choose_an_event_CRF_to_delete"));
        request.setAttribute("id", new Integer(studySubId).toString());
        forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
    } else {
        EventCRFBean eventCRF = (EventCRFBean) ecdao.findByPK(eventCRFId);
        StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
        request.setAttribute("studySub", studySub);
        // construct info needed on view event crf page
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
        int crfVersionId = eventCRF.getCRFVersionId();
        CRFBean cb = cdao.findByVersionId(crfVersionId);
        eventCRF.setCrf(cb);
        CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(crfVersionId);
        eventCRF.setCrfVersion(cvb);
        // then get the definition so we can call
        // DisplayEventCRFBean.setFlags
        int studyEventId = eventCRF.getStudyEventId();
        StudyEventBean event = (StudyEventBean) sedao.findByPK(studyEventId);
        int studyEventDefinitionId = sedao.getDefinitionIdFromStudyEventId(studyEventId);
        StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(studyEventDefinitionId);
        event.setStudyEventDefinition(sed);
        request.setAttribute("event", event);
        EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
        StudyBean study = (StudyBean) sdao.findByPK(studySub.getStudyId());
        EventDefinitionCRFBean edc = edcdao.findByStudyEventDefinitionIdAndCRFId(study, studyEventDefinitionId, cb.getId());
        DisplayEventCRFBean dec = new DisplayEventCRFBean();
        dec.setEventCRF(eventCRF);
        dec.setFlags(eventCRF, ub, currentRole, edc.isDoubleEntry());
        // find all item data
        ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
        dnDao = new DiscrepancyNoteDAO(sm.getDataSource());
        ArrayList<ItemDataBean> itemData = iddao.findAllByEventCRFId(eventCRF.getId());
        request.setAttribute("items", itemData);
        if ("confirm".equalsIgnoreCase(action)) {
            request.setAttribute("displayEventCRF", dec);
            forwardPage(Page.DELETE_EVENT_CRF);
        } else {
            logger.info("submit to delete the event CRF from event");
            // OC-6303  Deleting Event CRF resets Show / Hide logic
            // delete records from DynamicItemForm and DynamicItemGroup
            getDynamicsItemFormMetadataDao().delete(eventCRFId);
            getDynamicsItemGroupMetadataDao().delete(eventCRFId);
            eventCRF.setOldStatus(eventCRF.getStatus());
            eventCRF.setStatus(Status.RESET);
            eventCRF.setUpdater(ub);
            // OC-12177 added to fix displaying DDE workflow status
            eventCRF.setValidatorId(0);
            ecdao.update(eventCRF);
            for (ItemDataBean itemdata : itemData) {
                // OC-6343 Rule behaviour must be reset if an Event CRF is deleted
                // delete the records from ruleActionRunLogDao
                getRuleActionRunLogDao().delete(itemdata.getId());
                // OC-6344 Notes & Discrepancies must be set to "closed" when event CRF is deleted
                // parentDiscrepancyNoteList is the list of the parent DNs records only
                ArrayList<DiscrepancyNoteBean> parentDiscrepancyNoteList = getDnDao().findParentNotesOnlyByItemData(itemdata.getId());
                for (DiscrepancyNoteBean parentDiscrepancyNote : parentDiscrepancyNoteList) {
                    if (parentDiscrepancyNote.getResolutionStatusId() != 4) {
                        // if the DN's resolution status is not set to Closed
                        String description = resword.getString("dn_auto-closed_description");
                        String detailedNotes = resword.getString("dn_auto_closed_detailed_notes");
                        // create new DN record , new DN Map record , also update the parent record
                        createDiscrepancyNoteBean(description, detailedNotes, itemdata.getId(), study, ub, parentDiscrepancyNote);
                    }
                }
                iddao = new ItemDataDAO(sm.getDataSource());
                ifmdao = new ItemFormMetadataDAO(sm.getDataSource());
                ItemDataBean idBean = (ItemDataBean) iddao.findByPK(itemdata.getId());
                ItemFormMetadataBean ifmBean = ifmdao.findByItemIdAndCRFVersionId(idBean.getItemId(), crfVersionId);
                // Updating Dn_item_data_map actovated column into false for the existing DNs
                ArrayList<DiscrepancyNoteBean> dnBeans = getDnDao().findExistingNotesForItemData(itemdata.getId());
                if (dnBeans.size() != 0) {
                    DiscrepancyNoteBean dnBean = new DiscrepancyNoteBean();
                    dnBean.setEntityId(itemdata.getId());
                    dnBean.setActivated(false);
                    getDnDao().updateDnMapActivation(dnBean);
                }
                // Default Values are not addressed
                itemdata.setValue("");
                itemdata.setOldStatus(itemdata.getStatus());
                itemdata.setOwner(ub);
                itemdata.setStatus(Status.AVAILABLE);
                itemdata.setUpdater(ub);
                iddao.updateUser(itemdata);
                iddao.update(itemdata);
            }
            // OC-6291 event_crf status change
            eventCRF.setOldStatus(eventCRF.getStatus());
            eventCRF.setStatus(Status.AVAILABLE);
            eventCRF.setUpdater(ub);
            ecdao.update(eventCRF);
            if (event.getSubjectEventStatus().isCompleted() || event.getSubjectEventStatus().isSigned()) {
                event.setSubjectEventStatus(SubjectEventStatus.DATA_ENTRY_STARTED);
                event.setUpdater(ub);
                sedao = new StudyEventDAO(sm.getDataSource());
                sedao.update(event);
            }
            String emailBody = respage.getString("the_event_CRF") + cb.getName() + respage.getString("has_been_deleted_from_the_event") + event.getStudyEventDefinition().getName() + ". " + respage.getString("has_been_deleted_from_the_event_cont");
            addPageMessage(emailBody);
            // sendEmail(emailBody);
            request.setAttribute("id", new Integer(studySubId).toString());
            forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
        }
    }
}
Also used : StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Aggregations

StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)205 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)184 ArrayList (java.util.ArrayList)116 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)73 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)59 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)57 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)50 Date (java.util.Date)49 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)49 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)47 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)46 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)45 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)43 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)43 HashMap (java.util.HashMap)42 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)39 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)37 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)35 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)34 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)30