/**
 * Generated by orval v7.21.0 🍺
 * Do not edit manually.
 * FastAPI
 * OpenAPI spec version: 0.1.0
 */
import {
  useMutation,
  useQuery
} from '@tanstack/react-query';
import type {
  DataTag,
  DefinedInitialDataOptions,
  DefinedUseQueryResult,
  MutationFunction,
  QueryClient,
  QueryFunction,
  QueryKey,
  UndefinedInitialDataOptions,
  UseMutationOptions,
  UseMutationResult,
  UseQueryOptions,
  UseQueryResult
} from '@tanstack/react-query';

import type {
  ClinicCreate,
  ClinicCreateResponse,
  ClinicHistoryResponse,
  ClinicResponse,
  HTTPValidationError
} from '../../model';

import { customFetcher } from '../../api';


type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];



/**
 * @summary Create Clinic
 */
export type createClinicResponse201 = {
  data: ClinicCreateResponse
  status: 201
}

export type createClinicResponse422 = {
  data: HTTPValidationError
  status: 422
}
    
export type createClinicResponseSuccess = (createClinicResponse201) & {
  headers: Headers;
};
export type createClinicResponseError = (createClinicResponse422) & {
  headers: Headers;
};

export type createClinicResponse = (createClinicResponseSuccess | createClinicResponseError)

export const getCreateClinicUrl = () => {


  

  return `/api/clinics`
}

export const createClinic = async (clinicCreate: ClinicCreate, options?: RequestInit): Promise<createClinicResponse> => {
  
  return customFetcher<createClinicResponse>(getCreateClinicUrl(),
  {      
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(
      clinicCreate,)
  }
);}




export const getCreateClinicMutationOptions = <TError = HTTPValidationError,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createClinic>>, TError,{data: ClinicCreate}, TContext>, request?: SecondParameter<typeof customFetcher>}
): UseMutationOptions<Awaited<ReturnType<typeof createClinic>>, TError,{data: ClinicCreate}, TContext> => {

const mutationKey = ['createClinic'];
const {mutation: mutationOptions, request: requestOptions} = options ?
      options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
      options
      : {...options, mutation: {...options.mutation, mutationKey}}
      : {mutation: { mutationKey, }, request: undefined};

      


      const mutationFn: MutationFunction<Awaited<ReturnType<typeof createClinic>>, {data: ClinicCreate}> = (props) => {
          const {data} = props ?? {};

          return  createClinic(data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type CreateClinicMutationResult = NonNullable<Awaited<ReturnType<typeof createClinic>>>
    export type CreateClinicMutationBody = ClinicCreate
    export type CreateClinicMutationError = HTTPValidationError

    /**
 * @summary Create Clinic
 */
export const useCreateClinic = <TError = HTTPValidationError,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createClinic>>, TError,{data: ClinicCreate}, TContext>, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof createClinic>>,
        TError,
        {data: ClinicCreate},
        TContext
      > => {

      const mutationOptions = getCreateClinicMutationOptions(options);

      return useMutation(mutationOptions, queryClient);
    }
    /**
 * @summary Get Clinic
 */
export type getClinicResponse200 = {
  data: ClinicResponse
  status: 200
}

export type getClinicResponse422 = {
  data: HTTPValidationError
  status: 422
}
    
export type getClinicResponseSuccess = (getClinicResponse200) & {
  headers: Headers;
};
export type getClinicResponseError = (getClinicResponse422) & {
  headers: Headers;
};

export type getClinicResponse = (getClinicResponseSuccess | getClinicResponseError)

export const getGetClinicUrl = (hospitalId: string,) => {


  

  return `/api/clinics/${hospitalId}`
}

export const getClinic = async (hospitalId: string, options?: RequestInit): Promise<getClinicResponse> => {
  
  return customFetcher<getClinicResponse>(getGetClinicUrl(hospitalId),
  {      
    ...options,
    method: 'GET'
    
    
  }
);}





export const getGetClinicQueryKey = (hospitalId?: string,) => {
    return [
    `/api/clinics/${hospitalId}`
    ] as const;
    }

    
export const getGetClinicQueryOptions = <TData = Awaited<ReturnType<typeof getClinic>>, TError = HTTPValidationError>(hospitalId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getClinic>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
) => {

const {query: queryOptions, request: requestOptions} = options ?? {};

  const queryKey =  queryOptions?.queryKey ?? getGetClinicQueryKey(hospitalId);

  

    const queryFn: QueryFunction<Awaited<ReturnType<typeof getClinic>>> = () => getClinic(hospitalId, requestOptions);

      

      

   return  { queryKey, queryFn, enabled: !!(hospitalId),  staleTime: 60000,  ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getClinic>>, TError, TData> & { queryKey: DataTag<QueryKey, TData> }
}

export type GetClinicQueryResult = NonNullable<Awaited<ReturnType<typeof getClinic>>>
export type GetClinicQueryError = HTTPValidationError


export function useGetClinic<TData = Awaited<ReturnType<typeof getClinic>>, TError = HTTPValidationError>(
 hospitalId: string, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getClinic>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getClinic>>,
          TError,
          Awaited<ReturnType<typeof getClinic>>
        > , 'initialData'
      >, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient
  ):  DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
export function useGetClinic<TData = Awaited<ReturnType<typeof getClinic>>, TError = HTTPValidationError>(
 hospitalId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getClinic>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getClinic>>,
          TError,
          Awaited<ReturnType<typeof getClinic>>
        > , 'initialData'
      >, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
export function useGetClinic<TData = Awaited<ReturnType<typeof getClinic>>, TError = HTTPValidationError>(
 hospitalId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getClinic>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
/**
 * @summary Get Clinic
 */

export function useGetClinic<TData = Awaited<ReturnType<typeof getClinic>>, TError = HTTPValidationError>(
 hospitalId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getClinic>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient 
 ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> } {

  const queryOptions = getGetClinicQueryOptions(hospitalId,options)

  const query = useQuery(queryOptions, queryClient) as  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };

  query.queryKey = queryOptions.queryKey ;

  return query;
}




/**
 * @summary Get Clinic History
 */
export type getClinicHistoryResponse200 = {
  data: ClinicHistoryResponse
  status: 200
}

export type getClinicHistoryResponse422 = {
  data: HTTPValidationError
  status: 422
}
    
export type getClinicHistoryResponseSuccess = (getClinicHistoryResponse200) & {
  headers: Headers;
};
export type getClinicHistoryResponseError = (getClinicHistoryResponse422) & {
  headers: Headers;
};

export type getClinicHistoryResponse = (getClinicHistoryResponseSuccess | getClinicHistoryResponseError)

export const getGetClinicHistoryUrl = (id: string,) => {


  

  return `/api/clinics/${id}/history`
}

export const getClinicHistory = async (id: string, options?: RequestInit): Promise<getClinicHistoryResponse> => {
  
  return customFetcher<getClinicHistoryResponse>(getGetClinicHistoryUrl(id),
  {      
    ...options,
    method: 'GET'
    
    
  }
);}





export const getGetClinicHistoryQueryKey = (id?: string,) => {
    return [
    `/api/clinics/${id}/history`
    ] as const;
    }

    
export const getGetClinicHistoryQueryOptions = <TData = Awaited<ReturnType<typeof getClinicHistory>>, TError = HTTPValidationError>(id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getClinicHistory>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
) => {

const {query: queryOptions, request: requestOptions} = options ?? {};

  const queryKey =  queryOptions?.queryKey ?? getGetClinicHistoryQueryKey(id);

  

    const queryFn: QueryFunction<Awaited<ReturnType<typeof getClinicHistory>>> = () => getClinicHistory(id, requestOptions);

      

      

   return  { queryKey, queryFn, enabled: !!(id),  staleTime: 60000,  ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getClinicHistory>>, TError, TData> & { queryKey: DataTag<QueryKey, TData> }
}

export type GetClinicHistoryQueryResult = NonNullable<Awaited<ReturnType<typeof getClinicHistory>>>
export type GetClinicHistoryQueryError = HTTPValidationError


export function useGetClinicHistory<TData = Awaited<ReturnType<typeof getClinicHistory>>, TError = HTTPValidationError>(
 id: string, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getClinicHistory>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getClinicHistory>>,
          TError,
          Awaited<ReturnType<typeof getClinicHistory>>
        > , 'initialData'
      >, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient
  ):  DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
export function useGetClinicHistory<TData = Awaited<ReturnType<typeof getClinicHistory>>, TError = HTTPValidationError>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getClinicHistory>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getClinicHistory>>,
          TError,
          Awaited<ReturnType<typeof getClinicHistory>>
        > , 'initialData'
      >, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
export function useGetClinicHistory<TData = Awaited<ReturnType<typeof getClinicHistory>>, TError = HTTPValidationError>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getClinicHistory>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
/**
 * @summary Get Clinic History
 */

export function useGetClinicHistory<TData = Awaited<ReturnType<typeof getClinicHistory>>, TError = HTTPValidationError>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getClinicHistory>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient 
 ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> } {

  const queryOptions = getGetClinicHistoryQueryOptions(id,options)

  const query = useQuery(queryOptions, queryClient) as  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };

  query.queryKey = queryOptions.queryKey ;

  return query;
}




