import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; import useSWR from 'swr'; interface Service { serviceId: number; name: string; description: string; concept: { uuid: string; display: string; }; } interface ServicesResponse { results: Service[]; } export function useAppointmentServices() { const { data, error, isLoading } = useSWR(`${restBaseUrl}/mohappointment/services`, (url) => openmrsFetch(url).then((res) => res.data), ); const serviceTypes = data?.results?.map((service) => ({ uuid: service.concept.uuid, name: service.name, description: service.description, })) ?? []; return { serviceTypes, isLoading, error }; }