Search in sources :

Example 6 with ParticipantPortalRegistrar

use of org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar in project OpenClinica by OpenClinica.

the class EditFormController method mayProceed.

private boolean mayProceed(String studyOid) throws Exception {
    boolean accessPermission = false;
    StudyBean siteStudy = getStudy(studyOid);
    StudyBean study = getParentStudy(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
    participantPortalRegistrar = new ParticipantPortalRegistrar();
    // ACTIVE ,
    String pManageStatus = participantPortalRegistrar.getRegistrationStatus(study.getOid()).toString();
    // PENDING ,
    // INACTIVE
    // enabled , disabled
    String participateStatus = pStatus.getValue().toString();
    // available , pending , frozen , locked
    String studyStatus = study.getStatus().getName().toString();
    // available , pending , frozen , locked
    String siteStatus = siteStudy.getStatus().getName().toString();
    logger.info("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus + "   siteStatus: " + siteStatus);
    if (participateStatus.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && siteStatus.equalsIgnoreCase("available") && pManageStatus.equalsIgnoreCase("ACTIVE")) {
        accessPermission = true;
    }
    return accessPermission;
}
Also used : ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO)

Example 7 with ParticipantPortalRegistrar

use of org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar in project OpenClinica by OpenClinica.

the class StudyEventController method mayProceed.

private boolean mayProceed(Study study) throws Exception {
    boolean accessPermission = false;
    StudyParameterValue pStatus = studyParameterValueDao.findByStudyIdParameter(study.getStudyId(), "participantPortal");
    ParticipantPortalRegistrar participantPortalRegistrar = new ParticipantPortalRegistrar();
    // ACTIVE,PENDING,INACTIVE
    String pManageStatus = participantPortalRegistrar.getRegistrationStatus(study.getOc_oid()).toString();
    // enabled , disabled
    String participateStatus = pStatus.getValue().toString();
    // available , pending , frozen , locked
    String studyStatus = study.getStatus().getName().toString();
    logger.info("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus);
    System.out.println("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus);
    if (participateStatus.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && pManageStatus.equalsIgnoreCase("ACTIVE")) {
        accessPermission = true;
    }
    return accessPermission;
}
Also used : ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyParameterValue(org.akaza.openclinica.domain.datamap.StudyParameterValue)

Example 8 with ParticipantPortalRegistrar

use of org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar in project OpenClinica by OpenClinica.

the class OpenRosaSubmissionController method mayProceed.

private boolean mayProceed(Study childStudy, StudySubjectBean ssBean) throws Exception {
    boolean accessPermission = false;
    ParticipantPortalRegistrar participantPortalRegistrar = new ParticipantPortalRegistrar();
    Study study = getParentStudy(childStudy);
    StudyParameterValue pStatus = studyParameterValueDao.findByStudyIdParameter(study.getStudyId(), "participantPortal");
    // ACTIVE, PENDING, or INACTIVE
    String pManageStatus = participantPortalRegistrar.getRegistrationStatus(childStudy.getOc_oid()).toString();
    // enabled or disabled
    String participateStatus = pStatus.getValue().toString();
    // available, pending, frozen, or locked
    String studyStatus = study.getStatus().getName().toString();
    if (ssBean == null) {
        logger.info("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus);
        if (participateStatus.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && pManageStatus.equalsIgnoreCase("ACTIVE"))
            accessPermission = true;
    } else {
        logger.info("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus + "  studySubjectStatus: " + ssBean.getStatus().getName());
        // pManageStatus.equalsIgnoreCase("ACTIVE")
        if (participateStatus.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && ssBean.getStatus() == Status.AVAILABLE)
            accessPermission = true;
    }
    return accessPermission;
}
Also used : Study(org.akaza.openclinica.domain.datamap.Study) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyParameterValue(org.akaza.openclinica.domain.datamap.StudyParameterValue)

Example 9 with ParticipantPortalRegistrar

use of org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar in project OpenClinica by OpenClinica.

the class NotificationActionProcessor method run.

@Override
public void run() {
    String hostname = "";
    String url = "";
    participantPortalRegistrar = new ParticipantPortalRegistrar();
    try {
        hostname = participantPortalRegistrar.getStudyHost(studyBean.getOid());
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    url = hostname.replaceAll("login", "plogin");
    message = message.replaceAll("\\$\\{participant.url}", url);
    emailSubject = emailSubject.replaceAll("\\$\\{participant.url}", url);
    pDTO = getParticipantInfo(uBean);
    if (pDTO != null) {
        String msg = null;
        String eSubject = null;
        msg = message.replaceAll("\\$\\{participant.accessCode}", pDTO.getAccessCode());
        msg = msg.replaceAll("\\$\\{participant.firstname}", pDTO.getfName());
        eSubject = emailSubject.replaceAll("\\$\\{participant.accessCode}", pDTO.getAccessCode());
        eSubject = eSubject.replaceAll("\\$\\{participant.firstname}", pDTO.getfName());
        String loginUrl = url + "?access_code=" + pDTO.getAccessCode() + "&auto_login=true";
        msg = msg.replaceAll("\\$\\{participant.loginurl}", loginUrl);
        eSubject = eSubject.replaceAll("\\$\\{participant.loginurl}", loginUrl);
        msg = msg.replaceAll("\\\\n", "\n");
        eSubject = eSubject.replaceAll("\\\\n", "\n");
        message = message.replaceAll("\\\\n", "\n");
        emailSubject = emailSubject.replaceAll("\\\\n", "\n");
        pDTO.setMessage(msg);
        pDTO.setEmailSubject(eSubject);
        pDTO.setUrl(url);
        pDTO.setOrigMessage(message);
        pDTO.setOrigEmailSubject(emailSubject);
        pDTO.setParticipantEmailAccount(pDTO.getEmailAccount());
    } else {
        pDTO = buildNewPDTO();
        message = message.replaceAll("\\\\n", "\n");
        emailSubject = emailSubject.replaceAll("\\\\n", "\n");
        pDTO.setOrigMessage(message);
        pDTO.setOrigEmailSubject(emailSubject);
    }
    for (String email : listOfEmails) {
        if (email.trim().equals("${participant}") || participateStatus.equals("enabled")) {
            if (email.trim().equals("${participant}")) {
                pDTO.setEmailAccount(pDTO.getParticipantEmailAccount());
                pDTO.setEncryptedEmailAccount(Boolean.TRUE);
            } else {
                pDTO.setEmailAccount(email.trim());
                pDTO.setPhone(null);
                pDTO.setEncryptedEmailAccount(Boolean.FALSE);
            }
            // Send Email thru Mandrill Mail Server
            try {
                participantPortalRegistrar.sendEmailThruMandrillViaOcui(pDTO, hostname);
            } catch (Exception e) {
                e.getStackTrace();
            }
            System.out.println(pDTO.getMessage() + "   (Email Send to Participant from Mandrill :  " + pDTO.getEmailAccount() + ")");
        } else {
            pDTO.setEmailAccount(email.trim());
            //	System.out.println();
            // Send Email thru Local Mail Server
            execute(ExecutionMode.SAVE, ruleActionBean, pDTO, email.trim());
            System.out.println(pDTO.getMessage() + "  (Email sent to Hard Coded email address from OC Mail Server :  " + pDTO.getEmailAccount() + ")");
        }
    }
}
Also used : ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) MessagingException(javax.mail.MessagingException) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) MailException(org.springframework.mail.MailException)

Example 10 with ParticipantPortalRegistrar

use of org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar in project OpenClinica by OpenClinica.

the class OdmImportServiceImpl method importOdmToOC.

@Transactional
public void importOdmToOC(ODM odm) {
    UserAccount userAccount = getCurrentUser();
    // TODO add validation to all entities
    ODMcomplexTypeDefinitionStudy odmStudy = odm.getStudy().get(0);
    Study study = saveOrUpdateStudy(odm, userAccount, odmStudy);
    ParticipantPortalRegistrar portal = new ParticipantPortalRegistrar();
    portal.registerStudy(study.getOc_oid(), study.getOc_oid(), study.getName());
    StudyParameterValue spv = getStudyParameterValueDao().findByStudyIdParameter(study.getStudyId(), "participantPortal");
    // Update OC Study configuration
    if (spv == null) {
        spv = new StudyParameterValue();
        spv.setStudy(study);
    }
    spv.setValue("enabled");
    spv = getStudyParameterValueDao().saveOrUpdate(spv);
    StudyUserRole studyUserRole = null;
    StudyUserRoleId studyUserRoleId = null;
    Form[] fmCrfs = getAllCrfsByProtIdFromFormManager(study);
    ArrayList<StudyUserRole> surRoles = getStudyUserRoleDao().findAllUserRolesByUserAccount(userAccount, study.getStudyId(), study.getStudyId());
    if (surRoles.size() == 0) {
        studyUserRoleId = new StudyUserRoleId();
        studyUserRole = new StudyUserRole();
        studyUserRole = getStudyUserRoleDao().saveOrUpdate(populateUserRole(study, userAccount, studyUserRole, studyUserRoleId));
    }
    StudyEventDefinition studyEventDefinition = null;
    List<ODMcomplexTypeDefinitionMetaDataVersion> odmMetadataVersions = odmStudy.getMetaDataVersion();
    List<ODMcomplexTypeDefinitionStudyEventDef> odmStudyEventDefs = saveOrUpdateEvent(userAccount, study, odmMetadataVersions);
    CrfBean crf = null;
    FormLayout formLayout = null;
    saveOrUpdateCrf(userAccount, study, odmMetadataVersions, fmCrfs);
    List<ODMcomplexTypeDefinitionStudyEventRef> odmStudyEventRefs = odmMetadataVersions.get(0).getProtocol().getStudyEventRef();
    for (ODMcomplexTypeDefinitionStudyEventRef odmStudyEventRef : odmStudyEventRefs) {
        for (ODMcomplexTypeDefinitionStudyEventDef odmStudyEventDef : odmStudyEventDefs) {
            if (odmStudyEventDef.getOID().equals(odmStudyEventRef.getStudyEventOID())) {
                studyEventDefinition = getStudyEventDefDao().findByOcOID(odmStudyEventDef.getOID());
                studyEventDefinition.setOrdinal(odmStudyEventRef.getOrderNumber().intValue());
                studyEventDefinition = getStudyEventDefDao().saveOrUpdate(studyEventDefinition);
                List<EventDefinitionCrf> jsonEventDefCrfList = new ArrayList<>();
                EventDefinitionCrf eventDefinitionCrf = null;
                for (ODMcomplexTypeDefinitionFormRef odmFormRef : odmStudyEventDef.getFormRef()) {
                    crf = getCrfDao().findByOcOID(odmFormRef.getFormOID());
                    eventDefinitionCrf = getEventDefinitionCrfDao().findByStudyEventDefinitionIdAndCRFIdAndStudyId(studyEventDefinition.getStudyEventDefinitionId(), crf.getCrfId(), study.getStudyId());
                    String defaultVersionName = null;
                    OCodmComplexTypeDefinitionConfigurationParameters conf = odmFormRef.getConfigurationParameters();
                    List<OCodmComplexTypeDefinitionFormLayoutRef> formLayoutRefs = odmFormRef.getFormLayoutRef();
                    if (formLayoutRefs.size() == 1 && formLayoutRefs.get(0).getIsDefaultVersion() == null) {
                        defaultVersionName = formLayoutRefs.get(0).getOID();
                    } else {
                        for (OCodmComplexTypeDefinitionFormLayoutRef formLayoutRef : formLayoutRefs) {
                            if (formLayoutRef.getIsDefaultVersion().equalsIgnoreCase("Yes")) {
                                defaultVersionName = formLayoutRef.getOID();
                            }
                        }
                    }
                    if (defaultVersionName == null) {
                        defaultVersionName = formLayoutRefs.get(0).getOID();
                    }
                    formLayout = getFormLayoutDao().findByNameCrfId(defaultVersionName, crf.getCrfId());
                    EventDefinitionCrfDTO edcObj = new EventDefinitionCrfDTO();
                    edcObj.setUserAccount(userAccount);
                    edcObj.setConf(conf);
                    edcObj.setCrf(crf);
                    edcObj.setEventDefinitionCrf(eventDefinitionCrf);
                    edcObj.setOdmFormRef(odmFormRef);
                    edcObj.setStudy(study);
                    edcObj.setFormLayout(formLayout);
                    edcObj.setStudyEventDefinition(studyEventDefinition);
                    EDCTagDTO populateEDCTagParameter = new EDCTagDTO();
                    populateEDCTagParameter.setConf(conf);
                    populateEDCTagParameter.setConf(conf);
                    populateEDCTagParameter.setEventDefinitionCrf(eventDefinitionCrf);
                    populateEDCTagParameter.setUserAccount(userAccount);
                    eventDefinitionCrf = saveOrUpdateEventDefnCrf(new EventDefinitionCrfDTO(edcObj));
                    saveOrUpdateEDCTag(new EDCTagDTO(populateEDCTagParameter), studyEventDefinition, crf);
                    jsonEventDefCrfList.add(eventDefinitionCrf);
                }
                List<EventDefinitionCrf> ocEventDefCrfList = getEventDefinitionCrfDao().findAvailableByStudyEventDefStudy(studyEventDefinition.getStudyEventDefinitionId(), study.getStudyId());
                for (EventDefinitionCrf ocEventDefCrf : ocEventDefCrfList) {
                    if (!jsonEventDefCrfList.contains(ocEventDefCrf)) {
                        ocEventDefCrf.setStatusId(Status.DELETED.getCode());
                        getEventDefinitionCrfDao().saveOrUpdate(ocEventDefCrf);
                    }
                }
            }
        }
    }
}
Also used : CrfBean(org.akaza.openclinica.domain.datamap.CrfBean) Form(org.akaza.openclinica.service.dto.Form) ArrayList(java.util.ArrayList) ODMcomplexTypeDefinitionStudy(org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionStudy) EventDefinitionCrf(org.akaza.openclinica.domain.datamap.EventDefinitionCrf) ODMcomplexTypeDefinitionMetaDataVersion(org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionMetaDataVersion) StudyUserRole(org.akaza.openclinica.domain.datamap.StudyUserRole) ODMcomplexTypeDefinitionFormRef(org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionFormRef) StudyUserRoleId(org.akaza.openclinica.domain.datamap.StudyUserRoleId) FormLayout(org.akaza.openclinica.domain.datamap.FormLayout) Study(org.akaza.openclinica.domain.datamap.Study) ODMcomplexTypeDefinitionStudy(org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionStudy) StudyEventDefinition(org.akaza.openclinica.domain.datamap.StudyEventDefinition) StudyParameterValue(org.akaza.openclinica.domain.datamap.StudyParameterValue) ODMcomplexTypeDefinitionStudyEventDef(org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionStudyEventDef) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) OCodmComplexTypeDefinitionConfigurationParameters(org.openclinica.ns.odm_ext_v130.v31.OCodmComplexTypeDefinitionConfigurationParameters) OCodmComplexTypeDefinitionFormLayoutRef(org.openclinica.ns.odm_ext_v130.v31.OCodmComplexTypeDefinitionFormLayoutRef) ODMcomplexTypeDefinitionStudyEventRef(org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionStudyEventRef) UserAccount(org.akaza.openclinica.domain.user.UserAccount) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ParticipantPortalRegistrar (org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar)19 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)12 StudyParameterValueBean (org.akaza.openclinica.bean.service.StudyParameterValueBean)9 StudyParameterValueDAO (org.akaza.openclinica.dao.service.StudyParameterValueDAO)9 URL (java.net.URL)4 Authorization (org.akaza.openclinica.service.pmanage.Authorization)4 MalformedURLException (java.net.MalformedURLException)3 ArrayList (java.util.ArrayList)3 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)3 StudyParameterValue (org.akaza.openclinica.domain.datamap.StudyParameterValue)3 HashMap (java.util.HashMap)2 MessagingException (javax.mail.MessagingException)2 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)2 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)2 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)2 Study (org.akaza.openclinica.domain.datamap.Study)2 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)2 RandomizationRegistrar (org.akaza.openclinica.service.pmanage.RandomizationRegistrar)2 SeRandomizationDTO (org.akaza.openclinica.service.pmanage.SeRandomizationDTO)2 MailException (org.springframework.mail.MailException)2