Search in sources :

Example 76 with StudyBean

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

the class StudyController method createStudy.

public StudyBean createStudy(StudyBean studyBean, UserAccountBean owner) {
    sdao = new StudyDAO(dataSource);
    StudyBean sBean = (StudyBean) sdao.create(studyBean);
    sBean = (StudyBean) sdao.findByPK(sBean.getId());
    return sBean;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 77 with StudyBean

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

the class StudyController method createEventDefinition.

/**
 * @api {post} /pages/auth/api/v1/studies/:uniqueProtocolId/eventdefinitions Create a study event
 * @apiName createEventDefinition
 * @apiPermission Authenticate using api-key. admin
 * @apiVersion 3.8.0
 * @apiParam {String} uniqueProtocolId Study unique protocol ID.
 * @apiParam {String} name Event Name.
 * @apiParam {String} description Event Description.
 * @apiParam {String} category Category Name.
 * @apiParam {Boolean} repeating 'True' or 'False'.
 * @apiParam {String} type 'Scheduled' , 'UnScheduled' or 'Common'.
 * @apiGroup Study Event
 * @apiHeader {String} api_key Users unique access-key.
 * @apiDescription Creates a study event definition.
 * @apiParamExample {json} Request-Example:
 *                  {
 *                  "name": "Event Name",
 *                  "description": "Event Description",
 *                  "category": "Category Name",
 *                  "repeating": "true",
 *                  "type":"Scheduled"
 *                  }
 * @apiErrorExample {json} Error-Response:
 *                  HTTP/1.1 400 Bad Request
 *                  {
 *                  "name": "Event Name",
 *                  "message": "VALIDATION FAILED",
 *                  "type": "",
 *                  "errors": [
 *                  {"field": "Type","resource": "Event Definition Object","code": "Type Field should be Either 'Scheduled' , 'UnScheduled' or 'Common'"},
 *                  {"field": "Type","resource": "Event Definition Object","code": "This field cannot be blank."}
 *                  ],
 *                  "category": "Category Name",
 *                  "description": "Event Description",
 *                  "eventDefOid": null,
 *                  "repeating": "true"
 *                  }
 * @apiSuccessExample {json} Success-Response:
 *                    HTTP/1.1 200 OK
 *                    {
 *                    "message": "SUCCESS",
 *                    "name": "Event Name",
 *                    "eventDefOid": "SE_EVENTNAME"
 *                    }
 */
@RequestMapping(value = "/{uniqueProtocolID}/eventdefinitions", method = RequestMethod.POST)
public ResponseEntity<Object> createEventDefinition(HttpServletRequest request, @RequestBody HashMap<String, Object> map, @PathVariable("uniqueProtocolID") String uniqueProtocolID) throws Exception {
    System.out.println("I'm in Create Event Definition ");
    ArrayList<ErrorObject> errorObjects = new ArrayList();
    StudyEventDefinitionBean eventBean = null;
    ResponseEntity<Object> response = null;
    String validation_failed_message = "VALIDATION FAILED";
    String validation_passed_message = "SUCCESS";
    String name = (String) map.get("name");
    String description = (String) map.get("description");
    String category = (String) map.get("category");
    String type = (String) map.get("type");
    String repeating = (String) map.get("repeating");
    EventDefinitionDTO eventDefinitionDTO = buildEventDefnDTO(name, description, category, repeating, type);
    if (name == null) {
        ErrorObject errorOBject = createErrorObject("Event Definition Object", "Missing Field", "Name");
        errorObjects.add(errorOBject);
    } else {
        name = name.trim();
    }
    if (description == null) {
        ErrorObject errorOBject = createErrorObject("Event Definition Object", "Missing Field", "Description");
        errorObjects.add(errorOBject);
    } else {
        description = description.trim();
    }
    if (category == null) {
        ErrorObject errorOBject = createErrorObject("Event Definition Object", "Missing Field", "Category");
        errorObjects.add(errorOBject);
    } else {
        category = category.trim();
    }
    if (type == null) {
        ErrorObject errorOBject = createErrorObject("Event Definition Object", "Missing Field", "Type");
        errorObjects.add(errorOBject);
    } else {
        type = type.trim();
    }
    if (repeating == null) {
        ErrorObject errorOBject = createErrorObject("Event Definition Object", "Missing Field", "Repeating");
        errorObjects.add(errorOBject);
    } else {
        repeating = repeating.trim();
    }
    if (repeating != null) {
        if (!repeating.equalsIgnoreCase("true") && !repeating.equalsIgnoreCase("false")) {
            ErrorObject errorOBject = createErrorObject("Event Definition Object", "Repeating Field should be Either 'True' or 'False'", "Repeating");
            errorObjects.add(errorOBject);
        }
    }
    if (type != null) {
        if (!type.equalsIgnoreCase("scheduled") && !type.equalsIgnoreCase("unscheduled") && !type.equalsIgnoreCase("common")) {
            ErrorObject errorOBject = createErrorObject("Event Definition Object", "Type Field should be Either 'Scheduled' , 'UnScheduled' or 'Common'", "Type");
            errorObjects.add(errorOBject);
        }
    }
    request.setAttribute("name", name);
    request.setAttribute("description", description);
    request.setAttribute("category", category);
    request.setAttribute("type", type);
    request.setAttribute("repeating", repeating);
    StudyBean parentStudy = getStudyByUniqId(uniqueProtocolID);
    if (parentStudy == null) {
        ErrorObject errorOBject = createErrorObject("Event Definition Object", "The Study Protocol Id provided in the URL is not a valid Protocol Id", "Unique Study Protocol Id");
        errorObjects.add(errorOBject);
    } else if (parentStudy.getParentStudyId() != 0) {
        ErrorObject errorOBject = createErrorObject("Event Definition Object", "The Study Protocol Id provided in the URL is not a valid Study Protocol Id", "Unique Study Protocol Id");
        errorObjects.add(errorOBject);
    }
    UserAccountBean ownerUserAccount = getStudyOwnerAccount(request);
    if (ownerUserAccount == null) {
        ErrorObject errorOBject = createErrorObject("Study Object", "The Owner User Account is not Valid Account or Does not have Admin user type", "Owner Account");
        errorObjects.add(errorOBject);
    }
    Validator v1 = new Validator(request);
    v1.addValidation("name", Validator.NO_BLANKS);
    HashMap vError1 = v1.validate();
    if (!vError1.isEmpty()) {
        ErrorObject errorOBject = createErrorObject("Event Definition Object", "This field cannot be blank.", "Name");
        errorObjects.add(errorOBject);
    }
    if (name != null) {
        Validator v2 = new Validator(request);
        v2.addValidation("name", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
        HashMap vError2 = v2.validate();
        if (!vError2.isEmpty()) {
            ErrorObject errorOBject = createErrorObject("Event Definition Object", "The Length Should not exceed 2000.", "Name");
            errorObjects.add(errorOBject);
        }
    }
    if (description != null) {
        Validator v3 = new Validator(request);
        v3.addValidation("description", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
        HashMap vError3 = v3.validate();
        if (!vError3.isEmpty()) {
            ErrorObject errorOBject = createErrorObject("Event Definition Object", "The Length Should not exceed 2000.", "Description");
            errorObjects.add(errorOBject);
        }
    }
    if (category != null) {
        Validator v4 = new Validator(request);
        v4.addValidation("category", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
        HashMap vError4 = v4.validate();
        if (!vError4.isEmpty()) {
            ErrorObject errorOBject = createErrorObject("Event Definition Object", "The Length Should not exceed 2000.", "Category");
            errorObjects.add(errorOBject);
        }
    }
    Validator v5 = new Validator(request);
    v5.addValidation("repeating", Validator.NO_BLANKS);
    HashMap vError5 = v5.validate();
    if (!vError5.isEmpty()) {
        ErrorObject errorOBject = createErrorObject("Event Definition Object", "This field cannot be blank.", "Repeating");
        errorObjects.add(errorOBject);
    }
    Validator v6 = new Validator(request);
    v6.addValidation("type", Validator.NO_BLANKS);
    HashMap vError6 = v6.validate();
    if (!vError6.isEmpty()) {
        ErrorObject errorOBject = createErrorObject("Event Definition Object", "This field cannot be blank.", "Type");
        errorObjects.add(errorOBject);
    }
    eventDefinitionDTO.setErrors(errorObjects);
    if (errorObjects != null && errorObjects.size() != 0) {
        eventDefinitionDTO.setMessage(validation_failed_message);
        response = new ResponseEntity(eventDefinitionDTO, org.springframework.http.HttpStatus.BAD_REQUEST);
    } else {
        eventBean = buildEventDefBean(name, description, category, type, repeating, ownerUserAccount, parentStudy);
        StudyEventDefinitionBean sedBean = createEventDefn(eventBean, ownerUserAccount);
        eventDefinitionDTO.setEventDefOid(sedBean.getOid());
        eventDefinitionDTO.setMessage(validation_passed_message);
    }
    ResponseSuccessEventDefDTO responseSuccess = new ResponseSuccessEventDefDTO();
    responseSuccess.setMessage(eventDefinitionDTO.getMessage());
    responseSuccess.setEventDefOid(eventDefinitionDTO.getEventDefOid());
    responseSuccess.setName(eventDefinitionDTO.getName());
    response = new ResponseEntity(responseSuccess, org.springframework.http.HttpStatus.OK);
    return response;
}
Also used : HashMap(java.util.HashMap) ErrorObject(org.akaza.openclinica.bean.login.ErrorObject) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) ResponseEntity(org.springframework.http.ResponseEntity) EventDefinitionDTO(org.akaza.openclinica.bean.login.EventDefinitionDTO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) ErrorObject(org.akaza.openclinica.bean.login.ErrorObject) ResponseSuccessEventDefDTO(org.akaza.openclinica.bean.login.ResponseSuccessEventDefDTO) Validator(org.akaza.openclinica.control.form.Validator)

Example 78 with StudyBean

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

the class StudyController method buildSiteBean.

public StudyBean buildSiteBean(String uniqueSiteProtocolId, String name, String principalInvestigator, int expectedTotalEnrollment, Date startDate, Date protocolDateVerification, String secondaryProId, UserAccountBean owner, int parentStudyId) {
    StudyBean study = new StudyBean();
    ResourceBundle resadmin = org.akaza.openclinica.i18n.util.ResourceBundleProvider.getAdminBundle();
    study.setDatePlannedStart(startDate);
    study.setProtocolDateVerification(protocolDateVerification);
    study.setSecondaryIdentifier(secondaryProId);
    study.setIdentifier(uniqueSiteProtocolId);
    study.setName(name);
    study.setPrincipalInvestigator(principalInvestigator);
    study.setExpectedTotalEnrollment(expectedTotalEnrollment);
    study.setParentStudyId(parentStudyId);
    study.setOwner(owner);
    study.setStatus(Status.AVAILABLE);
    return study;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ResourceBundle(java.util.ResourceBundle)

Example 79 with StudyBean

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

the class StudyController method buildStudyBean.

public StudyBean buildStudyBean(String uniqueProtocolId, String name, String briefSummary, String principalInvestigator, String sponsor, int expectedTotalEnrollment, String protocolType, String status, Date startDate, UserAccountBean owner) {
    StudyBean study = new StudyBean();
    ResourceBundle resadmin = org.akaza.openclinica.i18n.util.ResourceBundleProvider.getAdminBundle();
    if (protocolType.equals(resadmin.getString("interventional"))) {
        study.setProtocolType("interventional");
    } else if (protocolType.equals(resadmin.getString("observational"))) {
        study.setProtocolType("observational");
    }
    ResourceBundle resword = org.akaza.openclinica.i18n.util.ResourceBundleProvider.getWordsBundle();
    if (resword.getString("available").equalsIgnoreCase(status))
        study.setStatus(Status.AVAILABLE);
    else if (resword.getString("design").equalsIgnoreCase(status) || status.equals(""))
        study.setStatus(Status.PENDING);
    study.setIdentifier(uniqueProtocolId);
    study.setName(name);
    study.setPrincipalInvestigator(principalInvestigator);
    study.setSummary(briefSummary);
    study.setSponsor(sponsor);
    study.setExpectedTotalEnrollment(expectedTotalEnrollment);
    study.setDatePlannedStart(startDate);
    study.setOwner(owner);
    return study;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ResourceBundle(java.util.ResourceBundle)

Example 80 with StudyBean

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

the class StudyModuleController method deactivateParticipate.

@RequestMapping(value = "/{study}/deactivate", method = RequestMethod.GET)
public String deactivateParticipate(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
    studyDao = new StudyDAO(dataSource);
    StudyBean study = studyDao.findByOid(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
    spv.setStudyId(study.getId());
    spv.setParameter("participantPortal");
    spv.setValue("disabled");
    if (spv.getId() > 0)
        spvdao.update(spv);
    else
        spvdao.create(spv);
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    currentStudy.getStudyParameterConfig().setParticipantPortal("disabled");
    return "redirect:/pages/studymodule";
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)366 ArrayList (java.util.ArrayList)185 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)184 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)92 HashMap (java.util.HashMap)85 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)68 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)65 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)62 Date (java.util.Date)61 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)59 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)58 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)57 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)56 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)52 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)52 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)45 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)42 Locale (java.util.Locale)41 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)41 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)38