Search in sources :

Example 86 with StudySubjectBean

use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.

the class ExpressionBeanService method getSSTimeZone.

public String getSSTimeZone() {
    Integer subjectId = expressionBeanWrapper.getStudySubjectBeanId();
    System.out.print("  subjectId  " + subjectId + "  : ");
    if (subjectId == null)
        return null;
    StudySubjectBean ssBean = (StudySubjectBean) getStudySubjectDao().findByPK(subjectId);
    return ssBean.getTime_zone().trim();
}
Also used : StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean)

Example 87 with StudySubjectBean

use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.

the class ExpressionService method getSSZoneId.

public String getSSZoneId() {
    Integer subjectId = expressionWrapper.getStudySubjectId();
    System.out.println("  subjectId  " + subjectId + "  : ");
    if (subjectId == null)
        return null;
    StudySubjectBean ssBean = (StudySubjectBean) getStudySubjectDao().findByPK(subjectId);
    return ssBean.getTime_zone().trim();
}
Also used : StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean)

Example 88 with StudySubjectBean

use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.

the class RandomizeService method getRandomizationCode.

// Rest Call to OCUI to get Randomization
public String getRandomizationCode(EventCRFBean eventCrfBean, List<StratificationFactorBean> stratificationFactorBeans, RuleSetBean ruleSet) throws JSONException {
    StudySubjectDAO ssdao = new StudySubjectDAO<>(ds);
    StudySubjectBean ssBean = (StudySubjectBean) ssdao.findByPK(eventCrfBean.getStudySubjectId());
    // study subject oid
    String identifier = ssBean.getOid();
    StudyDAO sdao = new StudyDAO<>(ds);
    StudyBean sBean = (StudyBean) sdao.findByPK(ssBean.getStudyId());
    // site or study oid
    String siteIdentifier = sBean.getOid();
    // site or study name
    String name = sBean.getName();
    UserAccountDAO udao = new UserAccountDAO(ds);
    int userId = 0;
    if (eventCrfBean.getUpdaterId() == 0) {
        userId = eventCrfBean.getOwnerId();
    } else {
        userId = eventCrfBean.getUpdaterId();
    }
    UserAccountBean uBean = (UserAccountBean) udao.findByPK(userId);
    String user = uBean.getName();
    // sBean should be parent study
    // put randomization object in cache
    StudyBean study = getParentStudy(sBean.getOid());
    SeRandomizationDTO randomization = null;
    try {
        randomization = getCachedRandomizationDTOObject(study.getOid(), false);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String randomiseUrl = randomization.getUrl();
    String username = randomization.getUsername();
    String password = randomization.getPassword();
    String timezone = "America/New_York";
    // String randomiseUrl = "https://evaluation.sealedenvelope.com/redpill/seti2";
    // String username = "oc";
    // String password = "secret";
    HttpHeaders headers = createHeaders(username, password);
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    // retrieve json object if Randomization exist ,otherwise return a null object
    JSONObject jsonRandObject = retrieveARandomisation(randomiseUrl, ssBean, headers);
    if (jsonRandObject != null) {
        return (String) jsonRandObject.get("code");
    } else {
        // if Site identifier exists ,then update otherwise create new Site identifier
        addOrUpdateASite(randomiseUrl, sBean, headers, timezone);
        // send for Randomization
        JSONObject jsonRandomisedObject = randomiseSubject(randomiseUrl, ssBean, sBean, headers, user, stratificationFactorBeans, eventCrfBean, ruleSet);
        if (jsonRandomisedObject != null)
            return (String) jsonRandomisedObject.get("code");
        else
            return "";
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) JSONObject(org.json.JSONObject) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) JSONException(org.json.JSONException)

Example 89 with StudySubjectBean

use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.

the class EventService method scheduleEvent.

public HashMap<String, String> scheduleEvent(UserAccountBean user, Date startDateTime, Date endDateTime, String location, String studyUniqueId, String siteUniqueId, String eventDefinitionOID, String studySubjectId) throws OpenClinicaSystemException {
    // Business Validation
    StudyBean study = getStudyDao().findByUniqueIdentifier(studyUniqueId);
    int parentStudyId = study.getId();
    if (siteUniqueId != null) {
        study = getStudyDao().findSiteByUniqueIdentifier(studyUniqueId, siteUniqueId);
    }
    StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionDao().findByOidAndStudy(eventDefinitionOID, study.getId(), parentStudyId);
    StudySubjectBean studySubject = getStudySubjectDao().findByLabelAndStudy(studySubjectId, study);
    Integer studyEventOrdinal = null;
    if (canSubjectScheduleAnEvent(studyEventDefinition, studySubject)) {
        StudyEventBean studyEvent = new StudyEventBean();
        studyEvent.setStudyEventDefinitionId(studyEventDefinition.getId());
        studyEvent.setStudySubjectId(studySubject.getId());
        studyEvent.setLocation(location);
        studyEvent.setDateStarted(startDateTime);
        studyEvent.setDateEnded(endDateTime);
        studyEvent.setOwner(user);
        studyEvent.setStatus(Status.AVAILABLE);
        studyEvent.setSubjectEventStatus(SubjectEventStatus.SCHEDULED);
        studyEvent.setSampleOrdinal(getStudyEventDao().getMaxSampleOrdinal(studyEventDefinition, studySubject) + 1);
        studyEvent = (StudyEventBean) getStudyEventDao().create(studyEvent, true);
        studyEventOrdinal = studyEvent.getSampleOrdinal();
    } else {
        throw new OpenClinicaSystemException("Cannot schedule an event for this Subject");
    }
    HashMap<String, String> h = new HashMap<String, String>();
    h.put("eventDefinitionOID", eventDefinitionOID);
    h.put("studyEventOrdinal", studyEventOrdinal.toString());
    h.put("studySubjectOID", studySubject.getOid());
    return h;
}
Also used : StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) HashMap(java.util.HashMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException)

Example 90 with StudySubjectBean

use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteUtil method getStudySubjectIdForDiscNote.

public int getStudySubjectIdForDiscNote(DiscrepancyNoteBean discrepancyNoteBean, DataSource dataSource, int studyId) {
    if (discrepancyNoteBean == null)
        return 0;
    StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
    List<StudySubjectBean> studySubjectBeans = new ArrayList<StudySubjectBean>();
    if ("subject".equalsIgnoreCase(discrepancyNoteBean.getEntityType())) {
        studySubjectBeans = studySubjectDAO.findAllBySubjectId(discrepancyNoteBean.getEntityId());
        for (StudySubjectBean bean : studySubjectBeans) {
            if (bean.getStudyId() == studyId) {
                return bean.getId();
            } else {
                if (((StudyBean) new StudyDAO(dataSource).findByPK(bean.getStudyId())).getParentStudyId() == studyId) {
                    return bean.getId();
                }
            }
        }
    } else if ("studySub".equalsIgnoreCase(discrepancyNoteBean.getEntityType())) {
        return discrepancyNoteBean.getEntityId();
    }
    return 0;
}
Also used : StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) ArrayList(java.util.ArrayList) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Aggregations

StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)155 ArrayList (java.util.ArrayList)102 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)86 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)71 HashMap (java.util.HashMap)66 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)66 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)57 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)52 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)52 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)49 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)45 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)43 Date (java.util.Date)42 Iterator (java.util.Iterator)38 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)35 SubjectBean (org.akaza.openclinica.bean.submit.SubjectBean)29 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)26 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)26 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)26 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)23