Esempio n. 1
0
        public async Task <ServiceReturn <List <FinancialEntity> > > GetFinancialEntitiesByIdsAsync(AuthenticationType tipoAuth, List <string> efrIds, string skip, string 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, AppResources.GetFinancialEntitiesError);
            }

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

            List <FinancialEntity> lstFinEnt = null;

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

                Generated.FinancialEntityClient sc = new Generated.FinancialEntityClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient()));
                ObservableCollection <Generated.ExternalFilterFinancialEntity> listFilters = new ObservableCollection <Generated.ExternalFilterFinancialEntity>();
                foreach (var item in efrIds)
                {
                    Generated.ExternalFilterFinancialEntity filter = new Generated.ExternalFilterFinancialEntity()
                    {
                        Id = item,
                    };
                    listFilters.Add(filter);
                }

                var retTemp = await sc.SearchFinancialEntitiesAsync(string.Empty, listFilters, skip, take, GetGPAppVersion());

                if (retTemp != null)
                {
                    lstFinEnt = new List <FinancialEntity>();
                    foreach (var item in retTemp)
                    {
                        lstFinEnt.Add(TranslateFinancialEntityGPToLocal(item));
                    }
                }

                // Aqui deveria ser realizada uma nova chamada assincrona para complementar os objectos finantial entities com os campos  cardmandatory/expDatemandatory/cardFormats
                // como este método é apenas chamado num método que não irá utilizar estes campo não foi adicionada esta mesma rotina..
                // Posteriormente se estes campos forem necessário será necessário realizar refactor e obrigar este método a ter como input um dicionário com <idFacility,List<idsFinantialEnts>>
                // por forma a carregar corretamente os dados no

                return(ServiceReturnHandling.BuildSuccessCallReturn <List <FinancialEntity> >(lstFinEnt, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <List <FinancialEntity> >(ex, uiMessages));
            }
        }
Esempio n. 2
0
        private async Task <ServiceReturn <List <FinancialEntity> > > GetFinancialEntitiesCardInformationForSpecificFAcAsync(AuthenticationType tipoAuth, string facilityId, List <FinancialEntity> finantialEnts, string successMessage = "", string errorMessage = "")
        {
            var uiMessages = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(errorMessage))
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, errorMessage);
            }
            else
            {
            }
            uiMessages.Add(ServiceReturnHandling.GenericMessageKey, AppResources.GetFinancialEntitiesError);

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

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

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

                var facilityIdFinal     = (!string.IsNullOrEmpty(facilityId)) ? facilityId : string.Empty;
                var finatialEntIdsFinal = finantialEnts != null?finantialEnts.Select(x => (double)x.FinancialEntityId).ToList() : new List <double>();

                var retTemp = await sc.FinancialEntitiesByCodeListAsync(finatialEntIdsFinal, facilityIdFinal, GetGPAppVersion());

                if (retTemp != null && retTemp.Count > 0)
                {
                    foreach (var efrMoreInfo in retTemp)
                    {
                        finantialEnts.Where(x => x.FinancialEntityId == efrMoreInfo.Id.Value).Select(s => { s.Format1 = efrMoreInfo.CardFormat1; s.Format2 = efrMoreInfo.CardFormat2; s.CardMandatoryFlag = efrMoreInfo.IsCardMandatory.Value; s.ExpDateMandatoryFlag = efrMoreInfo.IsExpirationDateMandatory.Value; return(s); }).ToList();
                    }
                }

                return(ServiceReturnHandling.BuildSuccessCallReturn <List <FinancialEntity> >(finantialEnts, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.BuildSuccessCallReturn <List <FinancialEntity> >(finantialEnts, uiMessages)); // Retornar sempre sucesso..para devolver as efr mesmo sem a info de cartao e formatos
                //return ServiceReturnHandling.HandleException<List<FinancialEntity>>(ex, uiMessages);
            }
        }
Esempio n. 3
0
        public async Task <ServiceReturn <List <FinancialEntity> > > GetFinancialEntitiesAsync(AuthenticationType tipoAuth, List <double> facilityIds, List <double> humanResourceId, string specialtyId, List <double> medicalActId, string successMessage = "", string errorMessage = "")
        {
            var uiMessages = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(errorMessage))
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, errorMessage);
            }
            else
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, AppResources.GetFinancialEntitiesError);
            }

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

            List <FinancialEntity> lstFinEnt = null;

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

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

                var facilityIdsFinal     = (facilityIds != null) ? facilityIds : new List <double>();
                var humanResourceIdFinal = (humanResourceId != null) ? humanResourceId : new List <double>();
                var specialtyIdFinal     = (!string.IsNullOrEmpty(specialtyId)) ? specialtyId : string.Empty;
                var medicalActIdFinal    = (medicalActId != null) ? medicalActId : new List <double>();
                //var rubricIdFinal = (!string.IsNullOrEmpty(rubricId)) ? rubricId : string.Empty;

                Generated.FinancialEntityBaseFilter filter = new Generated.FinancialEntityBaseFilter()
                {
                    ListFacilityIds   = new ObservableCollection <double>(facilityIdsFinal),
                    ListHumanResource = new ObservableCollection <double>(humanResourceIdFinal),
                    ListMedicalActIds = new ObservableCollection <double>(medicalActIdFinal)
                };

                var retTemp = await sc.GetFinancialEntitiesBaseAsync(filter, specialtyIdFinal, "S", 0, 10000, GetGPAppVersion());

                if (retTemp != null)
                {
                    lstFinEnt = new List <FinancialEntity>();
                    foreach (var item in retTemp)
                    {
                        lstFinEnt.Add(TranslateFinancialEntityGPToLocal(item));
                    }
                }

                // Cacete.. o metodo seguinte valida para uma determinada facility se a EFR tem obrigatoriedade de enviar Cartao/dataExpCartao
                // Estes campos só são necessários em momentos de marcação/remarcação de consultas daí o if facilityIds.Count (nas marcações tenho sempre a facility definida no inicio)
                // Não é realizada quando existem mais facilities porque, apesar de raro, a mesma EFR numa inst pode obrigar e noutra não..e os dados seriam insconsistentes
                if (facilityIds != null && facilityIds.Count == 1 && lstFinEnt != null && lstFinEnt.Count > 0)
                {
                    try
                    {
                        lstFinEnt = (await GetFinancialEntitiesCardInformationForSpecificFAcAsync(tipoAuth, facilityIds[0].ToString(), lstFinEnt)).Result;
                    }
                    catch (Exception) { }
                }

                return(ServiceReturnHandling.BuildSuccessCallReturn <List <FinancialEntity> >(lstFinEnt, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <List <FinancialEntity> >(ex, uiMessages));
            }
        }