<commit_before>package org.openmrs.module.shrclient.web.controller;


import org.apache.log4j.Logger;
import org.openmrs.api.APIAuthenticationException;
import org.openmrs.module.shrclient.service.FacilityCatchmentService;
import org.openmrs.module.shrclient.service.MCIPatientLookupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping(value = "/facilityCatchments")
public class FacilityCatchmentController {
    private static final Logger log = Logger.getLogger(FacilityCatchmentController.class);

    @Autowired
    private FacilityCatchmentService facilityCatchmentService;

    @RequestMapping(method = RequestMethod.GET, value = "/findByFacility")
    @ResponseBody
    public Object findByFacility(int locationId, HttpServletResponse response) throws IOException {
        try {
            return facilityCatchmentService.getCatchmentsForFacility(locationId);
        } catch (APIAuthenticationException e) {
            log.info("Not authorized to access national registry");
            response.sendError(HttpStatus.UNAUTHORIZED.value(), e.getMessage());
            return null;
        }
    }

    @RequestMapping(method = RequestMethod.GET, value = "/findByFacility")
    @ResponseBody
    public Object findByFacility(String catchment, HttpServletResponse response) throws IOException {<commit_msg>request param facility or catchment for queries from FacilityLocation<commit_after>package org.openmrs.module.shrclient.web.controller;


import org.apache.log4j.Logger;
import org.openmrs.api.APIAuthenticationException;
import org.openmrs.module.shrclient.service.FacilityCatchmentService;
import org.openmrs.module.shrclient.service.MCIPatientLookupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping(value = "/facilityCatchments")
public class FacilityCatchmentController {
    private static final Logger log = Logger.getLogger(FacilityCatchmentController.class);

    @Autowired
    private FacilityCatchmentService facilityCatchmentService;

    @RequestMapping(method = RequestMethod.GET, value = "/findByFacility")
    @ResponseBody
    public Object findByFacility(@RequestParam int locationId, HttpServletResponse response) throws IOException {
        try {
            return facilityCatchmentService.getCatchmentsForFacility(locationId);
        } catch (APIAuthenticationException e) {
            log.info("Not authorized to access national registry");
            response.sendError(HttpStatus.UNAUTHORIZED.value(), e.getMessage());
            return null;
        }
    }

    @RequestMapping(method = RequestMethod.GET, value = "/findByFacility")
    @ResponseBody
    public Object findByFacility(@RequestParam String catchment, HttpServletResponse response) throws IOException {
{'fraction_non_alphanumeric': 0.08312412831241284, 'fraction_numerical': 0.0005578800557880056, 'mean_word_length': 5.182758620689655, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5457398', 'n_tokens_mistral': 925, 'n_tokens_neox': 929, 'n_words': 180}