Search in sources :

Example 6 with StudyEvent

use of org.akaza.openclinica.domain.datamap.StudyEvent in project OpenClinica by OpenClinica.

the class RuleSetListenerService method onApplicationEvent.

@Override
public void onApplicationEvent(final OnStudyEventUpdated event) {
    LOGGER.debug("listening");
    if (event.getContainer().getChangeDetails().getStartDateChanged() || event.getContainer().getChangeDetails().getStatusChanged()) {
        StudyEvent studyEvent = event.getContainer().getEvent();
        Integer studyEventDefId = studyEvent.getStudyEventDefinition().getStudyEventDefinitionId();
        Integer studyEventOrdinal = studyEvent.getSampleOrdinal();
        Integer userId = studyEvent.getUpdateId();
        if (userId == null && studyEvent.getUserAccount() != null)
            userId = studyEvent.getUserAccount().getUserId();
        StudyEventBean studyEventBean = new StudyEventBean();
        studyEventBean.setId(studyEvent.getStudyEventId());
        ArrayList<RuleSetBean> ruleSets = (ArrayList<RuleSetBean>) createRuleSet(studyEventDefId);
        for (RuleSetBean ruleSet : ruleSets) {
            ArrayList<RuleSetBean> ruleSetBeans = new ArrayList();
            ExpressionBean eBean = new ExpressionBean();
            eBean.setValue(ruleSet.getTarget().getValue() + ".A.B");
            ruleSet.setTarget(eBean);
            ruleSet.addExpression(getRuleSetService().replaceSEDOrdinal(ruleSet.getTarget(), studyEventBean));
            ruleSetBeans.add(ruleSet);
            getRuleSetService().runIndividualRulesInBeanProperty(ruleSetBeans, userId, event.getContainer().getChangeDetails(), studyEventOrdinal);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) StudyEvent(org.akaza.openclinica.domain.datamap.StudyEvent) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) ExpressionBean(org.akaza.openclinica.domain.rule.expression.ExpressionBean)

Example 7 with StudyEvent

use of org.akaza.openclinica.domain.datamap.StudyEvent in project OpenClinica by OpenClinica.

the class GenerateClinicalDataServiceImpl method constructClinicalDataStudy.

private OdmClinicalDataBean constructClinicalDataStudy(List<StudySubject> studySubjs, Study study, List<StudyEvent> studyEvents, String formVersionOID) {
    OdmClinicalDataBean odmClinicalDataBean = new OdmClinicalDataBean();
    ExportSubjectDataBean expSubjectBean;
    List<ExportSubjectDataBean> exportSubjDataBeanList = new ArrayList<ExportSubjectDataBean>();
    for (StudySubject studySubj : studySubjs) {
        studyEvents = (ArrayList<StudyEvent>) getStudySubjectDao().fetchListSEs(studySubj.getOcOid());
        if (studyEvents != null) {
            expSubjectBean = setExportSubjectDataBean(studySubj, study, studyEvents, formVersionOID);
            exportSubjDataBeanList.add(expSubjectBean);
            odmClinicalDataBean.setExportSubjectData(exportSubjDataBeanList);
            odmClinicalDataBean.setStudyOID(study.getOc_oid());
        }
    }
    return odmClinicalDataBean;
// return null;
}
Also used : StudySubject(org.akaza.openclinica.domain.datamap.StudySubject) ArrayList(java.util.ArrayList) OdmClinicalDataBean(org.akaza.openclinica.bean.odmbeans.OdmClinicalDataBean) StudyEvent(org.akaza.openclinica.domain.datamap.StudyEvent) ExportSubjectDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean)

Example 8 with StudyEvent

use of org.akaza.openclinica.domain.datamap.StudyEvent in project OpenClinica by OpenClinica.

the class GenerateClinicalDataServiceImpl method setExportStudyEventDataBean.

private ArrayList<ExportStudyEventDataBean> setExportStudyEventDataBean(StudySubject ss, List<StudyEvent> sEvents, String formVersionOID) {
    ArrayList<ExportStudyEventDataBean> al = new ArrayList<ExportStudyEventDataBean>();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    for (StudyEvent se : sEvents) {
        if (se != null) {
            ExportStudyEventDataBean expSEBean = new ExportStudyEventDataBean();
            expSEBean.setLocation(se.getLocation());
            if (se.getDateEnd() != null)
                if (se.getEndTimeFlag())
                    expSEBean.setEndDate(se.getDateEnd() + "");
                else {
                    String temp = sdf.format(se.getDateEnd());
                    expSEBean.setEndDate(temp);
                }
            if (se.getStartTimeFlag())
                expSEBean.setStartDate(se.getDateStart() + "");
            else {
                String temp = sdf.format(se.getDateStart());
                expSEBean.setStartDate(temp);
            }
            expSEBean.setStudyEventOID(se.getStudyEventDefinition().getOc_oid());
            expSEBean.setStudyEventRepeatKey(se.getSampleOrdinal().toString());
            if (se.getStudySubject().getSubject().getDateOfBirth() != null && se.getDateStart() != null)
                expSEBean.setAgeAtEvent(Utils.getAge(se.getStudySubject().getSubject().getDateOfBirth(), se.getDateStart()));
            expSEBean.setStatus(fetchStudyEventStatus(se.getSubjectEventStatusId()));
            if (collectAudits)
                expSEBean.setAuditLogs(fetchAuditLogs(se.getStudyEventId(), "study_event", se.getStudyEventDefinition().getOc_oid(), null));
            if (collectDns)
                expSEBean.setDiscrepancyNotes(fetchDiscrepancyNotes(se));
            expSEBean.setExportFormData(getFormDataForClinicalStudy(ss, se, formVersionOID));
            expSEBean.setStudyEventDefinition(se.getStudyEventDefinition());
            al.add(expSEBean);
        }
    }
    return al;
}
Also used : ArrayList(java.util.ArrayList) StudyEvent(org.akaza.openclinica.domain.datamap.StudyEvent) SimpleDateFormat(java.text.SimpleDateFormat) ExportStudyEventDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportStudyEventDataBean)

Example 9 with StudyEvent

use of org.akaza.openclinica.domain.datamap.StudyEvent in project OpenClinica by OpenClinica.

the class GenerateClinicalDataServiceImpl method getClinicalDatas.

private OdmClinicalDataBean getClinicalDatas(String studyOID, String studySubjectOID, String studyEventOID, String formVersionOID) {
    int seOrdinal = 0;
    String temp = studyEventOID;
    List<StudyEvent> studyEvents = new ArrayList<StudyEvent>();
    StudyEventDefinition sed = null;
    Study study = getStudyDao().findByColumnName(studyOID, "oc_oid");
    List<StudySubject> ss = listStudySubjects(studySubjectOID);
    int idx = studyEventOID.indexOf(OPEN_ORDINAL_DELIMITER);
    LOGGER.info("study event oridinal is.." + idx);
    if (idx > 0) {
        studyEventOID = studyEventOID.substring(0, idx);
        seOrdinal = new Integer(temp.substring(idx + 1, temp.indexOf(CLOSE_ORDINAL_DELIMITER))).intValue();
    }
    sed = getStudyEventDefDao().findByColumnName(studyEventOID, "oc_oid");
    LOGGER.info("study event ordinal.." + seOrdinal);
    if (seOrdinal > 0) {
        studyEvents = fetchSE(seOrdinal, sed.getStudyEvents(), studySubjectOID);
    } else {
        studyEvents = fetchSE(sed.getStudyEvents(), studySubjectOID);
    }
    return constructClinicalDataStudy(ss, study, studyEvents, formVersionOID);
}
Also used : Study(org.akaza.openclinica.domain.datamap.Study) StudyEventDefinition(org.akaza.openclinica.domain.datamap.StudyEventDefinition) StudySubject(org.akaza.openclinica.domain.datamap.StudySubject) ArrayList(java.util.ArrayList) StudyEvent(org.akaza.openclinica.domain.datamap.StudyEvent)

Example 10 with StudyEvent

use of org.akaza.openclinica.domain.datamap.StudyEvent in project OpenClinica by OpenClinica.

the class ExpressionBeanService method evaluateExpression.

public String evaluateExpression(String test) {
    String value = "";
    String temp = null;
    String oid = null;
    int index = 0;
    // TODO fix this
    System.out.println("TEST  :: " + test);
    if (checkIfForScheduling(test)) {
        //TODO: get the format from data format properties.??
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        index = test.indexOf(".");
        oid = test.substring(0, index);
        temp = test.substring(index, test.length());
        StudyEvent studyEvent = getStudyEventFromOID(oid);
        if (ExpressionService.STARTDATE.endsWith(temp)) {
            if (studyEvent != null) {
                value = sdf.format(DateUtils.truncate((java.util.Date) studyEvent.getDateStart(), Calendar.DATE));
                value = value.replace(("00:00:00.0"), "");
                value = value.trim();
            }
        }
    }
    return value;
}
Also used : StudyEvent(org.akaza.openclinica.domain.datamap.StudyEvent) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

StudyEvent (org.akaza.openclinica.domain.datamap.StudyEvent)25 StudySubject (org.akaza.openclinica.domain.datamap.StudySubject)6 ArrayList (java.util.ArrayList)5 EventCrf (org.akaza.openclinica.domain.datamap.EventCrf)5 Date (java.util.Date)4 FormLayout (org.akaza.openclinica.domain.datamap.FormLayout)4 Study (org.akaza.openclinica.domain.datamap.Study)4 StudyEventDefinition (org.akaza.openclinica.domain.datamap.StudyEventDefinition)4 Transactional (org.springframework.transaction.annotation.Transactional)4 SimpleDateFormat (java.text.SimpleDateFormat)3 HashMap (java.util.HashMap)2 EventDefinitionCrf (org.akaza.openclinica.domain.datamap.EventDefinitionCrf)2 RuleSetBean (org.akaza.openclinica.domain.rule.RuleSetBean)2 EventActionBean (org.akaza.openclinica.domain.rule.action.EventActionBean)2 ExpressionBean (org.akaza.openclinica.domain.rule.expression.ExpressionBean)2 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)2 OpenClinicaExpressionParser (org.akaza.openclinica.logic.expressionTree.OpenClinicaExpressionParser)2 OnStudyEventUpdated (org.akaza.openclinica.patterns.ocobserver.OnStudyEventUpdated)2 StudyEventChangeDetails (org.akaza.openclinica.patterns.ocobserver.StudyEventChangeDetails)2 StudyEventContainer (org.akaza.openclinica.patterns.ocobserver.StudyEventContainer)2