# coding: utf-8

"""
    Green Team Clinical API

    The Green Team’s Clinical Data Service API provides defined access to clinical data on ~16,000 ‘HuSH+’ patients with an ‘asthma-like’ phenotype. Users can select input parameters, and the service returns select output based on the input parameters. The input parameters are: age; sex; race; type of visit; and specific ICD and CPT codes1. Based on the input parameters, the service returns the following outpatient parameters: (1) a list of patient IDs and dates of ED and outpatient visits over the 12-month period after diagnosis; and (2) a list of medications prescribed over the 12-month period after diagnosis. The output data are stratified by patients with ≤2 or >2 ED visits over the 12-month period after diagnosis—the primary clinical endpoint used to define, respectively, patients who are ‘responsive’ and ‘non-responsive’ to treatment.

    OpenAPI spec version: 0.0.1
    Contact: champioj@email.unc.edu
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


from __future__ import absolute_import

import sys
import os
import re

# python 2 and python 3 compatibility library
from six import iteritems

from ..configuration import Configuration
from ..api_client import ApiClient


class ClinicalApi(object):
    """
    NOTE: This class is auto generated by the swagger code generator program.
    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        config = Configuration()
        if api_client:
            self.api_client = api_client
        else:
            if not config.api_client:
                config.api_client = ApiClient()
            self.api_client = config.api_client

    def get_pet_by_id(self, age, sex, race, location, **kwargs):
        """
        Find patient set
        Returns a patient set
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_pet_by_id(age, sex, race, location, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param int age: Age of patient (required)
        :param str sex: Sex of patient (required)
        :param str race: Race of patient (required)
        :param str location: Location (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.get_pet_by_id_with_http_info(age, sex, race, location, **kwargs)
        else:
            (data) = self.get_pet_by_id_with_http_info(age, sex, race, location, **kwargs)
            return data

    def get_pet_by_id_with_http_info(self, age, sex, race, location, **kwargs):
        """
        Find patient set
        Returns a patient set
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_pet_by_id_with_http_info(age, sex, race, location, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param int age: Age of patient (required)
        :param str sex: Sex of patient (required)
        :param str race: Race of patient (required)
        :param str location: Location (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['age', 'sex', 'race', 'location']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_pet_by_id" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'age' is set
        if ('age' not in params) or (params['age'] is None):
            raise ValueError("Missing the required parameter `age` when calling `get_pet_by_id`")
        # verify the required parameter 'sex' is set
        if ('sex' not in params) or (params['sex'] is None):
            raise ValueError("Missing the required parameter `sex` when calling `get_pet_by_id`")
        # verify the required parameter 'race' is set
        if ('race' not in params) or (params['race'] is None):
            raise ValueError("Missing the required parameter `race` when calling `get_pet_by_id`")
        # verify the required parameter 'location' is set
        if ('location' not in params) or (params['location'] is None):
            raise ValueError("Missing the required parameter `location` when calling `get_pet_by_id`")


        collection_formats = {}

        resource_path = '/age/{age}/sex/{sex}/race/{race}/location/{location}'.replace('{format}', 'json')
        path_params = {}
        if 'age' in params:
            path_params['age'] = params['age']
        if 'sex' in params:
            path_params['sex'] = params['sex']
        if 'race' in params:
            path_params['race'] = params['race']
        if 'location' in params:
            path_params['location'] = params['location']

        query_params = {}

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api(resource_path, 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)
