Search in sources :

Example 21 with StudyParameterValueBean

use of org.akaza.openclinica.bean.service.StudyParameterValueBean in project OpenClinica by OpenClinica.

the class StudyConfigService method hasDefinedParameterValue.

/**
     *  true if the study has a value defined for this parameter o if studyId
     * is a parent study, then this is true iff there is a row for this
     * study/parameter pair in the study_parameter_value table o if studyId is a
     * site, then this is true if: ? * the parameter is inheritable and the
     * studys parent has a defined parameter value; OR ? * the parameter is not
     * inheritable and there is a row for this studyId/parameter pair in the
     * study_parameter_value table
     *
     * @param studyId
     * @param parameterHandle
     * @return
     */
public String hasDefinedParameterValue(int studyId, String parameterHandle) {
    StudyDAO sdao = new StudyDAO(ds);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(ds);
    if (studyId <= 0 || StringUtil.isBlank(parameterHandle)) {
        return null;
    }
    StudyParameterValueBean spv = spvdao.findByHandleAndStudy(studyId, parameterHandle);
    StudyParameter sp = spvdao.findParameterByHandle(parameterHandle);
    StudyBean study = (StudyBean) sdao.findByPK(studyId);
    if (spv.getId() > 0) {
        // top study or not
        return spv.getValue();
    }
    int parentId = study.getParentStudyId();
    if (parentId > 0) {
        StudyParameterValueBean spvParent = spvdao.findByHandleAndStudy(parentId, parameterHandle);
        if (spvParent.getId() > 0 && sp.isInheritable()) {
            return spvParent.getValue();
        }
    }
    return null;
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyParameter(org.akaza.openclinica.bean.service.StudyParameter) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 22 with StudyParameterValueBean

use of org.akaza.openclinica.bean.service.StudyParameterValueBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method setStudyParemeterConfig.

protected void setStudyParemeterConfig(StudyBean study) {
    StudyParameterValueBean param = new StudyParameterValueDAO(this.ds).findByHandleAndStudy(study.getId(), "collectDob");
    study.getStudyParameterConfig().setCollectDob(param.getValue());
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO)

Example 23 with StudyParameterValueBean

use of org.akaza.openclinica.bean.service.StudyParameterValueBean in project OpenClinica by OpenClinica.

the class NotificationActionProcessor method runNotificationAction.

public void runNotificationAction(RuleActionBean ruleActionBean, RuleSetBean ruleSet, int studySubjectBeanId, int eventOrdinal) {
    String emailList = ((NotificationActionBean) ruleActionBean).getTo();
    String message = ((NotificationActionBean) ruleActionBean).getMessage();
    String emailSubject = ((NotificationActionBean) ruleActionBean).getSubject();
    int sed_Id = ruleSet.getStudyEventDefinitionId();
    int studyId = ruleSet.getStudyId();
    String eventName = getStudyEventDefnBean(sed_Id).getName();
    if (eventOrdinal != 1)
        eventName = eventName + "(" + eventOrdinal + ")";
    String studyName = getStudyBean(studyId).getName();
    if (message == null)
        message = "";
    if (emailSubject == null)
        emailSubject = "";
    message = message.replaceAll("\\$\\{event.name}", eventName);
    message = message.replaceAll("\\$\\{study.name}", studyName);
    emailSubject = emailSubject.replaceAll("\\$\\{event.name}", eventName);
    emailSubject = emailSubject.replaceAll("\\$\\{study.name}", studyName);
    ParticipantDTO pDTO = null;
    StudyBean studyBean = getStudyBean(studyId);
    String[] listOfEmails = emailList.split(",");
    StudySubjectBean ssBean = (StudySubjectBean) ssdao.findByPK(studySubjectBeanId);
    StudyBean parentStudyBean = getParentStudy(ds, studyBean);
    String pUserName = parentStudyBean.getOid() + "." + ssBean.getOid();
    UserAccountBean uBean = (UserAccountBean) udao.findByUserName(pUserName);
    StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(studyBean.getId(), "participantPortal");
    // enabled , disabled
    String participateStatus = pStatus.getValue().toString();
    Thread thread = new Thread(new NotificationActionProcessor(listOfEmails, uBean, studyBean, message, emailSubject, participantPortalRegistrar, mailSender, participateStatus));
    thread.start();
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) ParticipantDTO(org.akaza.openclinica.bean.login.ParticipantDTO)

Example 24 with StudyParameterValueBean

use of org.akaza.openclinica.bean.service.StudyParameterValueBean in project OpenClinica by OpenClinica.

the class SubjectService method createStudySubject.

private StudySubjectBean createStudySubject(SubjectBean subject, StudyBean studyBean, Date enrollmentDate, String secondaryId) {
    StudySubjectBean studySubject = new StudySubjectBean();
    studySubject.setSecondaryLabel(secondaryId);
    studySubject.setOwner(getUserAccount());
    studySubject.setEnrollmentDate(enrollmentDate);
    studySubject.setSubjectId(subject.getId());
    studySubject.setStudyId(studyBean.getId());
    studySubject.setStatus(Status.AVAILABLE);
    int handleStudyId = studyBean.getParentStudyId() > 0 ? studyBean.getParentStudyId() : studyBean.getId();
    StudyParameterValueBean subjectIdGenerationParameter = getStudyParameterValueDAO().findByHandleAndStudy(handleStudyId, "subjectIdGeneration");
    String idSetting = subjectIdGenerationParameter.getValue();
    if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
        // Warning: Here we have a race condition. 
        // At least, a uniqueness constraint should be set on the database! Better provide an atomic method which stores a new label in the database and returns it.  
        int nextLabel = getStudySubjectDao().findTheGreatestLabel() + 1;
        studySubject.setLabel(Integer.toString(nextLabel));
    } else {
        studySubject.setLabel(subject.getLabel());
        subject.setLabel(null);
    }
    return studySubject;
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean)

Example 25 with StudyParameterValueBean

use of org.akaza.openclinica.bean.service.StudyParameterValueBean in project OpenClinica by OpenClinica.

the class StudyConfigService method setParametersForStudy.

/**
     * This method construct an object which has all the study parameter values
     *
     * @param study
     * @return
     */
public StudyBean setParametersForStudy(StudyBean study) {
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(ds);
    ArrayList parameters = spvdao.findAllParameters();
    StudyParameterConfig spc = new StudyParameterConfig();
    for (int i = 0; i < parameters.size(); i++) {
        StudyParameter sp = (StudyParameter) parameters.get(i);
        String handle = sp.getHandle();
        // logger.info("handle:" + handle);
        StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), handle);
        // TO DO: will change to use java reflection later
        if (spv.getId() > 0) {
            if (handle.equalsIgnoreCase("collectDob")) {
                spc.setCollectDob(spv.getValue());
            } else if (handle.equalsIgnoreCase("genderRequired")) {
                spc.setGenderRequired(spv.getValue());
            } else if (handle.equalsIgnoreCase("discrepancyManagement")) {
                spc.setDiscrepancyManagement(spv.getValue());
            } else if (handle.equalsIgnoreCase("subjectPersonIdRequired")) {
                spc.setSubjectPersonIdRequired(spv.getValue());
            // logger.info("subjectPersonIdRequired" +
            // spc.getSubjectPersonIdRequired());
            } else if (handle.equalsIgnoreCase("interviewerNameRequired")) {
                spc.setInterviewerNameRequired(spv.getValue());
            } else if (handle.equalsIgnoreCase("interviewerNameDefault")) {
                spc.setInterviewerNameDefault(spv.getValue());
            } else if (handle.equalsIgnoreCase("interviewerNameEditable")) {
                spc.setInterviewerNameEditable(spv.getValue());
            } else if (handle.equalsIgnoreCase("interviewDateRequired")) {
                spc.setInterviewDateRequired(spv.getValue());
            } else if (handle.equalsIgnoreCase("interviewDateDefault")) {
                spc.setInterviewDateDefault(spv.getValue());
            } else if (handle.equalsIgnoreCase("interviewDateEditable")) {
                spc.setInterviewDateEditable(spv.getValue());
            } else if (handle.equalsIgnoreCase("subjectIdGeneration")) {
                spc.setSubjectIdGeneration(spv.getValue());
                logger.debug("subjectIdGeneration" + spc.getSubjectIdGeneration());
            } else if (handle.equalsIgnoreCase("subjectIdPrefixSuffix")) {
                spc.setSubjectIdPrefixSuffix(spv.getValue());
            } else if (handle.equalsIgnoreCase("personIdShownOnCRF")) {
                spc.setPersonIdShownOnCRF(spv.getValue());
            } else if (handle.equalsIgnoreCase("secondaryLabelViewable")) {
                spc.setSecondaryLabelViewable(spv.getValue());
            } else if (handle.equalsIgnoreCase("adminForcedReasonForChange")) {
                spc.setAdminForcedReasonForChange(spv.getValue());
            } else if (handle.equalsIgnoreCase("eventLocationRequired")) {
                spc.setEventLocationRequired(spv.getValue());
            } else if (handle.equalsIgnoreCase("participantPortal")) {
                spc.setParticipantPortal(spv.getValue());
            } else if (handle.equalsIgnoreCase("randomization")) {
                spc.setRandomization(spv.getValue());
            }
        }
    }
    study.setStudyParameterConfig(spc);
    return study;
}
Also used : StudyParameterConfig(org.akaza.openclinica.bean.service.StudyParameterConfig) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyParameter(org.akaza.openclinica.bean.service.StudyParameter) ArrayList(java.util.ArrayList)

Aggregations

StudyParameterValueBean (org.akaza.openclinica.bean.service.StudyParameterValueBean)46 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)31 StudyParameterValueDAO (org.akaza.openclinica.dao.service.StudyParameterValueDAO)27 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)18 ArrayList (java.util.ArrayList)16 Date (java.util.Date)9 HashMap (java.util.HashMap)9 ParticipantPortalRegistrar (org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar)9 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)6 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 Iterator (java.util.Iterator)5 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)4 StudyParamsConfig (org.akaza.openclinica.bean.service.StudyParamsConfig)4 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)3 StudyParameter (org.akaza.openclinica.bean.service.StudyParameter)3 RandomizationRegistrar (org.akaza.openclinica.service.pmanage.RandomizationRegistrar)3 IOException (java.io.IOException)2