public async Task <ServiceReturn <List <AppRequested> > > GetSchedulingRequestsAsync(AuthenticationType tipoAuth, List <string> userIds, IEnumerable <string> facilityIds, DateTime minDate, DateTime maxDate, int skip, int take, string successMessage = "", string errorMessage = "")
        {
            var uiMessages = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(errorMessage))
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, errorMessage);
            }
            else
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, "Não é possível obter lista de pedidos de marcações");
            }

            if (!string.IsNullOrEmpty(successMessage))
            {
                uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage);
            }

            try
            {
                List <AppRequested> appointments = new List <AppRequested>();
                var locIds = facilityIds.Select(x => double.Parse(x)).ToList();

                string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL");

                Generated.SchedulingRequestClient sc = new Generated.SchedulingRequestClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient()));

                foreach (var userID in userIds)
                {
                    var result = await sc.GetPendingScheduleByUniquePatientAsync(locIds, Generated.RequestType4.TELEF, userID, skip, take, GetGPAppVersion());

                    if (result != null)
                    {
                        foreach (var item in result)
                        {
                            appointments.Add(TranslateRequestedApptGPToLocal(item, userID));
                        }
                    }
                }

                return(ServiceReturnHandling.BuildSuccessCallReturn <List <AppRequested> >(appointments, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <List <AppRequested> >(ex, uiMessages));
            }
        }
        public async Task <ServiceReturn <Dictionary <string, string> > > GetSchedulingIdsAsync(AuthenticationType tipoAuth, List <string> schedulingApptIDs, string successMessage = "", string errorMessage = "")
        {
            var uiMessages = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(errorMessage))
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, errorMessage);
            }
            else
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, "Não é possível obter lista de IDs de pedidos de marcações");
            }

            if (!string.IsNullOrEmpty(successMessage))
            {
                uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage);
            }

            try
            {
                string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL");

                Generated.SchedulingRequestClient sc = new Generated.SchedulingRequestClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient()));

                var dicIds = new Dictionary <string, string>();

                foreach (var schedulingApptID in schedulingApptIDs)
                {
                    var appId = await sc.GetAppointmentIdByScheduleRequestAsync(schedulingApptID, GetGPAppVersion());

                    if (!string.IsNullOrEmpty(appId))
                    {
                        dicIds.Add(schedulingApptID, appId);
                    }
                }

                return(ServiceReturnHandling.BuildSuccessCallReturn <Dictionary <string, string> >(dicIds, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <Dictionary <string, string> >(ex, uiMessages));
            }
        }
        public async Task <ServiceReturn <bool> > CreateSchedulingRequestAsync(AuthenticationType tipoAuth, string userId, string facilityId, string medActId, string specialityId, string humanResourceId, string observations, DateTime datePref, string successMessage = "", string errorMessage = "")
        {
            var uiMessages = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(errorMessage))
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, errorMessage);
            }
            else
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, "Não é possível criar o pedido de marcação");
            }

            if (!string.IsNullOrEmpty(successMessage))
            {
                uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage);
            }

            try
            {
                string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL");

                Generated.SchedulingRequestClient sc = new Generated.SchedulingRequestClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient()));
                var facilityIdFinal      = !string.IsNullOrEmpty(facilityId) ? facilityId : string.Empty;
                var medActIdFinal        = !string.IsNullOrEmpty(medActId) ? medActId : string.Empty;
                var specialityIdFinal    = !string.IsNullOrEmpty(specialityId) ? specialityId : string.Empty;
                var humanResourceIdFinal = !string.IsNullOrEmpty(humanResourceId) ? humanResourceId : string.Empty;
                var observationsFinal    = !string.IsNullOrEmpty(observations) ? observations : string.Empty;

                //var result = await sc.CreateSchedulingRequestAsync(Generated.RequestType.TELEF, User.UserId, facilityIdFinal, medActIdFinal, specialityIdFinal, humanResourceIdFinal, observationsFinal, datePref, GetGPAppVersion());
                var result = await sc.CreateSchedulingRequestAsync(Generated.RequestType3.TELEF, userId, facilityIdFinal, medActIdFinal, specialityIdFinal, humanResourceIdFinal, observationsFinal, datePref, DateTime.Now, string.Empty, string.Empty, GetGPAppVersion());

                return(ServiceReturnHandling.BuildSuccessCallReturn <bool>(true, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <bool>(ex, uiMessages));
            }
        }