Example usage for org.springframework.web.context.request WebRequest getParameter

List of usage examples for org.springframework.web.context.request WebRequest getParameter

Introduction

In this page you can find the example usage for org.springframework.web.context.request WebRequest getParameter.

Prototype

@Nullable
String getParameter(String paramName);

Source Link

Document

Return the request parameter of the given name, or null if none.

Usage

From source file:org.openmrs.module.rwandaprimarycare.EnterSimpleEncounterController.java

@RequestMapping(method = RequestMethod.POST)
public String processSubmit(@RequestParam("patientId") Integer patientId,
        @RequestParam("encounterType") Integer encounterTypeId, @RequestParam("form") String form,
        @RequestParam(required = false, value = "visitDate") Long visitDate, WebRequest request,
        HttpSession session) throws PrimaryCareException {
    //LK: Need to ensure that all primary care methods only throw a PrimaryCareException
    //So that errors will be directed to a touch screen error page
    try {/*from w  w  w .ja va  2 s  .  co  m*/

        Patient patient = getPatient(patientId);
        Location workstationLocation = PrimaryCareBusinessLogic.getLocationLoggedIn(session);
        EncounterType encounterType = Context.getEncounterService().getEncounterType(encounterTypeId);
        if (encounterType == null)
            throw new RuntimeException("encounterType is required");
        List<Obs> obsToCreate = new ArrayList<Obs>();
        int i = 0;
        while (true) {
            String conceptId = request.getParameter("obs_concept_" + i);
            String value = request.getParameter("obs_value_" + i);
            ++i;
            if (conceptId == null)
                break;
            if (!StringUtils.hasText(value))
                continue;
            Obs obs = new Obs();
            obs.setPerson(patient);
            obs.setConcept(Context.getConceptService().getConcept(Integer.valueOf(conceptId)));
            obs.setLocation(workstationLocation);
            try {
                obs.setValueAsString(value);
            } catch (ParseException ex) {
                throw new IllegalArgumentException("Cannot set "
                        + obs.getConcept().getName(Context.getLocale()).getName() + " to " + value);
            }
            obsToCreate.add(obs);
        }

        //LK: if we are entering vitals we are going to check to see if we should 
        //be automatically calculating the BMI, based on a global property  
        Boolean calculateBMI = new Boolean(
                Context.getAdministrationService().getGlobalProperty("registration.calculateBMI"));
        if (calculateBMI) {
            //LK: we are only going to calcuate BMI for people over 20 as kiddies have different rules
            patient = getPatient(patient.getPatientId());
            if (patient.getAge() > 20) {
                String bmi = PrimaryCareUtil.calculateBMI(patient, obsToCreate);
                if (bmi != null) {
                    Obs obs = new Obs();
                    obs.setPerson(patient);
                    obs.setConcept(Context.getConceptService()
                            .getConcept(PrimaryCareBusinessLogic.getBMIConcept().getConceptId()));
                    obs.setLocation(workstationLocation);
                    obs.setValueAsString(bmi);
                    obsToCreate.add(obs);
                }
            }
        }

        if (visitDate != null) {
            PrimaryCareBusinessLogic.createEncounter(patient, encounterType, workstationLocation,
                    new Date(visitDate), Context.getAuthenticatedUser(), obsToCreate);
            return "redirect:/module/rwandaprimarycare/patient.form?patientId=" + patientId + "&visitDate="
                    + visitDate;
        } else {
            PrimaryCareBusinessLogic.createEncounter(patient, encounterType, workstationLocation, new Date(),
                    Context.getAuthenticatedUser(), obsToCreate);
            return "redirect:/module/rwandaprimarycare/patient.form?patientId=" + patientId;
        }

    } catch (Exception e) {
        throw new PrimaryCareException(e);
    }
}

From source file:org.openmrs.module.department.web.controller.DepartmentManageController.java

@RequestMapping(value = "/module/department/addDepartment.form", method = RequestMethod.POST)
public String submitDepartment(WebRequest request, HttpSession httpSession, ModelMap model,
        @RequestParam(required = false, value = "action") String action,
        @ModelAttribute("department") Department department, BindingResult errors) {
    MessageSourceService mss = Context.getMessageSourceService();
    DepartmentService departmentService = Context.getService(DepartmentService.class);
    if (!Context.isAuthenticated()) {
        errors.reject("department.auth.required");
    } else if (mss.getMessage("department.purgeDepartment").equals(action)) {
        try {//ww  w.j  a v a2 s.c om
            departmentService.purgeDepartment(department);
            httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "department.delete.success");
            return "redirect:manage.form";
        } catch (Exception ex) {
            httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "department.delete.failure");
            log.error("Failed to delete department", ex);
            return "redirect:departmentForm.form?departmentId=" + request.getParameter("departmentId");
        }
    } else {
        departmentService.saveDepartment(department);
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "department.saved");
    }
    return "redirect:manage.form";
}

From source file:org.openmrs.module.basicexample.web.controller.openMRSnewManageController.java

@RequestMapping(value = "/module/basicexample/addDepartment.form", method = RequestMethod.POST)
public String submitDepartment(WebRequest request, HttpSession httpSession, ModelMap model,
        @RequestParam(required = false, value = "action") String action,
        @ModelAttribute("department") openMRSnew department, BindingResult errors) {

    MessageSourceService mss = Context.getMessageSourceService();
    openMRSnewService departmentService = Context.getService(openMRSnewService.class);
    if (!Context.isAuthenticated()) {
        errors.reject("department.auth.required");
    } else if (mss.getMessage("department.purgeDepartment").equals(action)) {
        try {// ww  w  .j  a v a 2  s  . c o  m
            departmentService.purgeDepartment(department);
            httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "department.delete.success");
            return "redirect:departmentList.list";
        } catch (Exception ex) {
            httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "department.delete.failure");
            log.error("Failed to delete department", ex);
            return "redirect:departmentForm.form?departmentId=" + request.getParameter("departmentId");
        }
    } else {
        departmentService.saveDepartment(department);
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "department.saved");
    }
    return "redirect:departmentList.list";
}

From source file:org.openmrs.web.controller.patient.ShortPatientFormController.java

@ModelAttribute("patientModel")
public ShortPatientModel getPatientModel(@RequestParam(value = "patientId", required = false) Integer patientId,
        ModelMap model, WebRequest request) {
    Patient patient;/*from   w ww . j  av a 2 s.  co  m*/
    if (patientId != null) {
        patient = Context.getPatientService().getPatientOrPromotePerson(patientId);
        if (patient == null) {
            throw new IllegalArgumentException("No patient or person with the given id");
        }
    } else {
        // we may have some details to add to a blank patient
        patient = new Patient();
        String name = request.getParameter("addName");
        if (!StringUtils.isBlank(name)) {
            String gender = request.getParameter("addGender");
            String date = request.getParameter("addBirthdate");
            String age = request.getParameter("addAge");
            PersonFormController.getMiniPerson(patient, name, gender, date, age);
        }
    }

    // if we have an existing personName, cache the original name so that we
    // can use it to
    // track changes in givenName, middleName, familyName, will also use
    // it to restore the original values
    if (patient.getPersonName() != null && patient.getPersonName().getId() != null) {
        model.addAttribute("personNameCache", PersonName.newInstance(patient.getPersonName()));
    } else {
        model.addAttribute("personNameCache", new PersonName());
    }

    // cache a copy of the person address for comparison in case the name is
    // edited
    if (patient.getPersonAddress() != null && patient.getPersonAddress().getId() != null) {
        model.addAttribute("personAddressCache", patient.getPersonAddress().clone());
    } else {
        model.addAttribute("personAddressCache", new PersonAddress());
    }

    String propCause = Context.getAdministrationService().getGlobalProperty("concept.causeOfDeath");
    Concept conceptCause = Context.getConceptService().getConcept(propCause);
    String causeOfDeathOther = "";
    if (conceptCause != null && patient.getPatientId() != null) {
        List<Obs> obssDeath = Context.getObsService().getObservationsByPersonAndConcept(patient, conceptCause);

        if (obssDeath.size() == 1) {
            Obs obsDeath = obssDeath.iterator().next();
            causeOfDeathOther = obsDeath.getValueText();
            if (causeOfDeathOther == null) {
                log.debug("cod is null, so setting to empty string");
                causeOfDeathOther = "";
            } else {
                log.debug("cod is valid: " + causeOfDeathOther);
            }
        } else {
            log.debug("obssDeath is wrong size: " + obssDeath.size());
        }
    } else {
        log.debug("No concept cause found");
    }
    // end get 'other' cause of death
    model.addAttribute("causeOfDeathOther", causeOfDeathOther);

    return new ShortPatientModel(patient);
}

From source file:org.openmrs.calculation.web.controller.CalculationAutoRegistrationFormController.java

/**
 * Attempt to auto-register any select groups of Calculations
 *//*from ww  w.j av a 2 s  . c o m*/
@RequestMapping(value = "/module/calculation/calculationAutoRegistration", method = RequestMethod.POST)
public String handleSubmission(WebRequest request,
        @RequestParam(value = "conflictMode", required = true) String conflictMode) {

    boolean overwrite = "overwrite".equals(conflictMode);
    CalculationRegistrationService service = Context.getService(CalculationRegistrationService.class);

    Map<String, CalculationRegistration> existingRegistrations = new HashMap<String, CalculationRegistration>();
    for (CalculationRegistration r : service.getAllCalculationRegistrations()) {
        existingRegistrations.put(r.getToken(), r);
    }

    Map<String, Integer> results = new HashMap<String, Integer>();
    results.put("created", 0);
    results.put("skipped", 0);
    results.put("replaced", 0);
    results.put("failed", 0);

    List<CalculationRegistrationSuggestion> suggestions = Context
            .getRegisteredComponents(CalculationRegistrationSuggestion.class);
    for (CalculationRegistrationSuggestion suggestion : suggestions) {
        if (suggestion.getSuggestions() != null) {
            boolean selected = "t"
                    .equals(request.getParameter(suggestion.getClass().getName() + "_" + suggestion.getName()));
            if (selected) {
                for (CalculationRegistration toRegister : suggestion.getSuggestions()) {
                    try {
                        CalculationRegistration r = existingRegistrations.get(toRegister.getToken());
                        if (r != null) {
                            if (overwrite) {
                                r.setProviderClassName(toRegister.getProviderClassName());
                                r.setCalculationName(toRegister.getCalculationName());
                                r.setConfiguration(toRegister.getConfiguration());
                                service.saveCalculationRegistration(r);
                                results.put("replaced", results.get("replaced") + 1);
                            } else {
                                results.put("skipped", results.get("skipped") + 1);
                            }
                        } else {
                            r = new CalculationRegistration();
                            r.setToken(toRegister.getToken());
                            r.setProviderClassName(toRegister.getProviderClassName());
                            r.setCalculationName(toRegister.getCalculationName());
                            r.setConfiguration(toRegister.getConfiguration());
                            service.saveCalculationRegistration(r);
                            results.put("created", results.get("created") + 1);
                        }
                    } catch (Exception e) {
                        log.error("Failed to auto-register: " + toRegister, e);
                        results.put("failed", results.get("failed") + 1);
                    }
                }
            }
        }
    }

    StringBuilder msg = new StringBuilder();
    appendToMessage(msg, results, "created");
    appendToMessage(msg, results, "skipped");
    appendToMessage(msg, results, "replaced");
    appendToMessage(msg, results, "failed");
    request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, msg.toString(), WebRequest.SCOPE_SESSION);

    return "redirect:calculationRegistrations.list";
}

From source file:org.openmrs.web.controller.concept.ConceptReferenceTermFormController.java

/**
 * Processes requests to save/update a concept reference term
 *
 * @param request the {@link WebRequest} object
 * @param conceptReferenceTermModel the concept reference term object to save/update
 * @param result the {@link BindingResult} object
 * @return the url to redirect to/*from  w  ww  .ja va2s.  co  m*/
 */
@RequestMapping(method = RequestMethod.POST, value = CONCEPT_REFERENCE_TERM_FORM_URL)
public String saveConceptReferenceTerm(WebRequest request,
        @ModelAttribute(value = "conceptReferenceTermModel") ConceptReferenceTermModel conceptReferenceTermModel,
        BindingResult result) {

    ConceptReferenceTerm conceptReferenceTerm = conceptReferenceTermModel.getConceptReferenceTerm();
    // add all the term maps
    //store ids of already mapped terms so that we don't map a term multiple times
    Set<Integer> mappedTermIds = null;
    for (int x = 0; x < conceptReferenceTermModel.getTermMaps().size(); x++) {
        if (mappedTermIds == null) {
            mappedTermIds = new HashSet<Integer>();
        }
        ConceptReferenceTermMap map = conceptReferenceTermModel.getTermMaps().get(x);

        if (map != null && map.getTermB() != null) {
            //skip past this mapping because its term is already in use by another mapping for this term
            if (!mappedTermIds.add(map.getTermB().getConceptReferenceTermId())) {
                continue;
            }

            if (request.getParameter("_termMaps[" + x + "].exists") == null) {
                // because of the _termMap[x].exists input name in the jsp, the value will be null for
                // deleted maps, remove the map.
                conceptReferenceTerm.removeConceptReferenceTermMap(map);
            } else {
                if (map.getConceptMapType() == null) {
                    result.rejectValue("termMaps[" + x + "]", "ConceptReferenceTerm.error.mapTypeRequired",
                            "Concept Map Type is required");
                    log.warn("Concept Map Type is required");
                    break;
                } else if (map.getTermB().equals(conceptReferenceTerm)) {
                    result.rejectValue("termMaps[" + x + "]", "ConceptReferenceTerm.map.sameTerm",
                            "Cannot map a concept reference term to itself");
                    log.warn("Cannot map a concept reference term to itself");
                    break;
                } else if (!conceptReferenceTerm.getConceptReferenceTermMaps().contains(map)) {
                    conceptReferenceTerm.addConceptReferenceTermMap(map);
                }
            }
        }
    }

    //if there are errors  with the term
    if (!result.hasErrors()) {
        try {
            result.pushNestedPath("conceptReferenceTerm");
            ValidationUtils.invokeValidator(new ConceptReferenceTermValidator(), conceptReferenceTerm, result);
            ValidationUtils.invokeValidator(new ConceptReferenceTermWebValidator(), conceptReferenceTerm,
                    result);
        } finally {
            result.popNestedPath();
        }
    }

    if (!result.hasErrors()) {
        try {
            conceptReferenceTerm = Context.getConceptService().saveConceptReferenceTerm(conceptReferenceTerm);
            if (log.isDebugEnabled()) {
                log.debug("Saved concept reference term: " + conceptReferenceTerm.toString());
            }
            request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "ConceptReferenceTerm.saved",
                    WebRequest.SCOPE_SESSION);
            return "redirect:" + CONCEPT_REFERENCE_TERM_FORM_URL + ".form?conceptReferenceTermId="
                    + conceptReferenceTerm.getConceptReferenceTermId();
        } catch (APIException e) {
            log.error("Error while saving concept reference term", e);
            request.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "ConceptReferenceTerm.save.error",
                    WebRequest.SCOPE_SESSION);
        }
    }

    return CONCEPT_REFERENCE_TERM_FORM;
}

From source file:com.seajas.search.profiler.controller.FeedController.java

/**
 * Render the submit action in the same way as a regular page view is rendered.
 * //  w  ww . j  a v  a 2 s. c o  m
 * @param command
 * @param result
 * @param model
 * @param request
 * @return String
 */
@RequestMapping(method = RequestMethod.POST)
public String processSubmit(@ModelAttribute("feedCommand") final FeedCommand command,
        final BindingResult result, final ModelMap model, final WebRequest request) {
    Collection<String> feedUrls = new ArrayList<String>();

    if (request.getParameterValues("feedUrls") != null)
        for (String feedUrl : request.getParameterValues("feedUrls"))
            if (StringUtils.hasText(feedUrl))
                feedUrls.add(feedUrl);

    command.setFeedUrls(feedUrls);

    Map<String, String> feedResultParameters = new LinkedHashMap<String, String>();

    if (request.getParameterValues("feedParameterKeys") != null)
        for (int i = 0; i < request.getParameterValues("feedParameterKeys").length; i++)
            if (StringUtils.hasText(request.getParameterValues("feedParameterKeys")[i])
                    || StringUtils.hasText(request.getParameterValues("feedParameterValues")[i]))
                feedResultParameters.put(request.getParameterValues("feedParameterKeys")[i],
                        request.getParameterValues("feedParameterValues")[i]);

    command.setFeedParameterKeys(feedResultParameters.keySet());
    command.setFeedParameterValues(feedResultParameters.values());

    if (request.getParameter("isEnabled") == null)
        command.setIsEnabled(false);
    if (request.getParameter("isSummaryBased") == null)
        command.setIsSummaryBased(false);

    validator.validate(command, result);

    if (!result.hasErrors()) {
        Integer landingPage = 0;

        if (command.getAction().equals("add")) {
            Integer feedId = profilerService.addFeed(command.getName(), command.getDescription(),
                    command.getCollection(), command.getFeedEncodingOverride(),
                    command.getResultEncodingOverride(), command.getLanguage(), command.getFeedUrls(),
                    feedResultParameters, command.getIsSummaryBased(), command.getIsEnabled());

            if (feedId != null
                    && (StringUtils.hasText(command.getQueue()) || StringUtils.hasText(command.getStrategy())))
                profilerService.addFeedConnection(feedId,
                        StringUtils.hasText(command.getQueue()) ? command.getQueue() : null,
                        StringUtils.hasText(command.getStrategy()) ? command.getStrategy() : null);

            landingPage = -1;
        } else if (command.getAction().equals("edit")) {
            profilerService.modifyFeed(command.getId(), command.getName(), command.getDescription(),
                    command.getCollection(), command.getFeedEncodingOverride(),
                    command.getResultEncodingOverride(), command.getLanguage(), command.getFeedUrls(),
                    feedResultParameters, command.getIsSummaryBased(), command.getIsEnabled());

            // Always remove the feed connection explicitly, and then re-add it if needed

            profilerService.deleteFeedConnection(command.getId());

            if (StringUtils.hasText(command.getQueue()) || StringUtils.hasText(command.getStrategy())) {
                profilerService.addFeedConnection(command.getId(),
                        StringUtils.hasText(command.getQueue()) ? command.getQueue() : null,
                        StringUtils.hasText(command.getStrategy()) ? command.getStrategy() : null);
            }

            // TODO: Feed anonymization settings

            try {
                landingPage = Integer.valueOf(
                        StringUtils.hasText(request.getParameter(PARAM_PAGE)) ? request.getParameter(PARAM_PAGE)
                                : null);
            } catch (NumberFormatException e) {
                landingPage = 0;
            }
        } else if (command.getAction().equals("delete")) {
            if (repositoryService.deleteResources(null, command.getId(), null, null, null))
                profilerService.deleteFeed(command.getId());

            landingPage = 0;
        }

        // Re-populate the data

        String filterQuery = request.getParameter(PARAM_QUERY);

        Integer results;

        try {
            results = Integer.valueOf(StringUtils.hasText(request.getParameter(PARAM_RESULTS_PER_PAGE))
                    ? request.getParameter(PARAM_RESULTS_PER_PAGE)
                    : null);
        } catch (NumberFormatException e) {
            results = MAX_RESULTS_PER_PAGE;
        }

        model.put("data", retrieveData(filterQuery, landingPage, results));

        command.clear();
    }

    return "feeds";
}

From source file:org.openmrs.module.cohort.web.controller.AddVisitController.java

@RequestMapping(value = "/module/cohort/addvisit.form", method = RequestMethod.POST)
public void onSubmit(WebRequest request, HttpSession httpSession, ModelMap model,
        @RequestParam(required = false, value = "startDate") String startDate,
        @RequestParam(required = false, value = "endDate") String endDate,
        @ModelAttribute("cohortvisit") CohortVisit cvisit, BindingResult errors) {
    CohortService departmentService = Context.getService(CohortService.class);
    if (!Context.isAuthenticated()) {
        errors.reject("Required");
    }//from w ww.j a v  a2s . co m

    VisitService enctype = Context.getVisitService();
    List<VisitType> enctypes = enctype.getAllVisitTypes();
    VisitType e = new VisitType();
    Location l = new Location();
    LocationService service = Context.getLocationService();
    List<String> cohortnames = new ArrayList<String>();
    List<String> etype = new ArrayList<String>();
    CohortService cservice = Context.getService(CohortService.class);
    CohortM c1 = new CohortM();
    List<CohortM> list1 = cservice.findCohorts();
    for (int i = 0; i < list1.size(); i++) {
        CohortM c = list1.get(i);
        cohortnames.add(c.getName());
    }
    for (int k = 0; k < enctypes.size(); k++) {
        VisitType ec = enctypes.get(k);
        etype.add(e.getName());
    }
    List<Location> formats = service.getAllLocations();
    model.addAttribute("formats1", cohortnames);
    model.addAttribute("locations", formats);
    model.addAttribute("enctypes", etype);

    String visittype = request.getParameter("visittype");
    String location = request.getParameter("location");
    String cohort = request.getParameter("names");
    if (startDate == "" && endDate == "") {
        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Values cannot be null");
    } else {
        List<CohortM> cohort2 = cservice.findCohorts(cohort);
        for (int i = 0; i < cohort2.size(); i++) {
            c1 = cohort2.get(i);
        }
        List<VisitType> visittypes1 = enctype.getVisitTypes(visittype);
        for (int i = 0; i < visittypes1.size(); i++) {
            e = visittypes1.get(i);
        }
        List<Location> loc = service.getLocations(location);
        for (int j = 0; j < loc.size(); j++) {
            l = loc.get(j);
        }
        cvisit.setCohort(c1);
        cvisit.setVisitType(e);
        cvisit.setLocation(l);
        cservice.saveCohortVisit(cvisit);
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "insertion success");
    }
}

From source file:org.openmrs.module.cohort.web.controller.AddObs.java

@RequestMapping(value = "/module/cohort/addobs.form", method = RequestMethod.POST)
public ModelAndView onSubmit(WebRequest request, HttpSession httpSession, ModelMap model,
        @RequestParam(required = false, value = "obsDateTime") String date,
        @ModelAttribute("cohortobs") CohortObs cobs, BindingResult errors) {
    CohortService departmentService = Context.getService(CohortService.class);
    if (!Context.isAuthenticated()) {
        errors.reject("Required");
    }/*  w  ww  . jav a  2s  . c o  m*/

    Location l = new Location();
    Concept co = new Concept();
    LocationService service = Context.getLocationService();
    ConceptService cs = Context.getConceptService();
    List<Concept> concept = cs.getAllConcepts();
    List<String> cohortnames = new ArrayList<String>();
    CohortService cservice = Context.getService(CohortService.class);
    CohortM c1 = new CohortM();
    CohortEncounter ce = new CohortEncounter();

    List<CohortM> list1 = cservice.findCohorts();
    for (int d = 0; d < list1.size(); d++) {
        CohortM c = list1.get(d);
        cohortnames.add(c.getName());
    }
    List<Integer> etype = new ArrayList<Integer>();
    List<CohortEncounter> enctypes = cservice.findCohortEncounters();
    for (int a = 0; a < enctypes.size(); a++) {
        CohortEncounter e = enctypes.get(a);
        etype.add(e.getId());
    }
    List<Location> formats = service.getAllLocations();
    model.addAttribute("concepts", concept);
    model.addAttribute("locations", formats);
    model.addAttribute("encids", etype);

    String encounterid = request.getParameter("encid");
    Integer id = Integer.parseInt(encounterid);
    String location = request.getParameter("location");
    String cohort = request.getParameter("names");
    String concept1 = request.getParameter("concept");
    if (date == "") {
        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Values cannot be null");
    } else {
        List<CohortM> cohort2 = cservice.findCohorts(cohort);
        for (int i = 0; i < cohort2.size(); i++) {
            c1 = cohort2.get(i);
        }
        List<CohortEncounter> enctypes1 = cservice.findCohortEnc(id);
        for (int g = 0; g < enctypes1.size(); g++) {
            ce = enctypes1.get(g);
        }
        List<Location> loc = service.getLocations(location);
        for (int j = 0; j < loc.size(); j++) {
            l = loc.get(j);
        }
        List<Concept> con = cs.getConceptsByName(concept1);
        for (int x = 0; x < con.size(); x++) {
            co = con.get(x);
        }
        cobs.setCohort(c1);
        //cobs.setVoided(false);
        //cobs.setConcept(co);
        cobs.setEncounterId(ce);
        cobs.setLocation(l);
        departmentService.saveCohortObs(cobs);
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "insertion success");
    }
    return null;
}