Search in sources :

Example 1 with ExpressionBeanService

use of org.akaza.openclinica.service.rule.expression.ExpressionBeanService in project OpenClinica by OpenClinica.

the class BeanPropertyService method runAction.

/**
 * Complete adding to this Service to evaluate Event action
 * @param ruleActionBean
 * @param eow
 * @param isTransaction
 */
public void runAction(RuleActionBean ruleActionBean, ExpressionBeanObjectWrapper eow, Integer userId, Boolean isTransaction) {
    boolean statusMatch = false;
    OpenClinicaExpressionParser oep = new OpenClinicaExpressionParser(eow);
    ExpressionBeanService ebs = new ExpressionBeanService(eow);
    StudyEvent studyEvent = ebs.getStudyEventFromOID(((EventActionBean) ruleActionBean).getOc_oid_reference());
    RuleActionRunBean runOnStatuses = ruleActionBean.getRuleActionRun();
    if (studyEvent != null) {
        switch(SubjectEventStatus.getByCode(studyEvent.getSubjectEventStatusId())) {
            case NOT_SCHEDULED:
                if (runOnStatuses.getNot_started())
                    statusMatch = true;
                break;
            case SCHEDULED:
                if (runOnStatuses.getScheduled())
                    statusMatch = true;
                break;
            case DATA_ENTRY_STARTED:
                if (runOnStatuses.getData_entry_started())
                    statusMatch = true;
                break;
            case COMPLETED:
                if (runOnStatuses.getComplete())
                    statusMatch = true;
                break;
            case SKIPPED:
                if (runOnStatuses.getSkipped())
                    statusMatch = true;
                break;
            case STOPPED:
                if (runOnStatuses.getStopped())
                    statusMatch = true;
                break;
            case SIGNED:
            case LOCKED:
            default:
                statusMatch = false;
                break;
        }
    } else // Special case if destination study event doesn't exist yet, ie not scheduled.
    {
        if (runOnStatuses.getNot_started())
            statusMatch = true;
    }
    if (statusMatch) {
        for (PropertyBean propertyBean : ((EventActionBean) ruleActionBean).getProperties()) {
            // This will execute the contents of <ValueExpression>SS.ENROLLMENT_DATE + 2</ValueExpression>
            LOGGER.debug("Values:expression??::" + propertyBean.getValueExpression().getValue());
            Object result = oep.parseAndEvaluateExpression(propertyBean.getValueExpression().getValue());
            executeAction(result, propertyBean, eow, (EventActionBean) ruleActionBean, userId, isTransaction);
        }
    }
}
Also used : OpenClinicaExpressionParser(org.akaza.openclinica.logic.expressionTree.OpenClinicaExpressionParser) ExpressionBeanService(org.akaza.openclinica.service.rule.expression.ExpressionBeanService) EventActionBean(org.akaza.openclinica.domain.rule.action.EventActionBean) RuleActionRunBean(org.akaza.openclinica.domain.rule.action.RuleActionRunBean) StudyEvent(org.akaza.openclinica.domain.datamap.StudyEvent) PropertyBean(org.akaza.openclinica.domain.rule.action.PropertyBean)

Aggregations

StudyEvent (org.akaza.openclinica.domain.datamap.StudyEvent)1 EventActionBean (org.akaza.openclinica.domain.rule.action.EventActionBean)1 PropertyBean (org.akaza.openclinica.domain.rule.action.PropertyBean)1 RuleActionRunBean (org.akaza.openclinica.domain.rule.action.RuleActionRunBean)1 OpenClinicaExpressionParser (org.akaza.openclinica.logic.expressionTree.OpenClinicaExpressionParser)1 ExpressionBeanService (org.akaza.openclinica.service.rule.expression.ExpressionBeanService)1