Ejemplo n.º 1
0
        public async Task <ServiceReturn <bool> > CreateDescendantAsync(AuthenticationType tipoAuth, string idParent, MobileApps.Core.BusinessLayer.Entities.Patient desc, string colorHex, 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.Error);
            }
            if (!string.IsNullOrEmpty(successMessage))
            {
                uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage);
            }

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

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

                var descBody = TranslatePatientLocaltoDescendantGP(desc, colorHex);

                await sc.IdDescendantsAsync(descBody, idParent);

                return(ServiceReturnHandling.BuildSuccessCallReturn <bool>(true, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <bool>(ex, uiMessages));
            }
        }
Ejemplo n.º 2
0
        public async Task <ServiceReturn <bool> > DeletePatientByIDAsync(AuthenticationType tipoAuth, string patientID)
        {
            var uiMessages = new Dictionary <string, string>();

            uiMessages.Add(ServiceReturnHandling.GenericMessageKey, AppResources.Error);
            uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, "Success");

            try
            {
                if (string.IsNullOrEmpty(patientID))
                {
                    throw new Exception("Parametros inválidos em DeletePatientByIDAsync");
                }

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

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

                await sc.IdDeleteAsync(patientID);

                return(ServiceReturnHandling.BuildSuccessCallReturn <bool>(true, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <bool>(ex, uiMessages));
            }
        }
Ejemplo n.º 3
0
        public async Task <ServiceReturn <bool> > UpdatePatientInfoAsync(AuthenticationType tipoAuth, BusinessLayer.Entities.Patient patient)
        {
            var uiMessages = new Dictionary <string, string>();

            uiMessages.Add(ServiceReturnHandling.GenericMessageKey, AppResources.Error);
            uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, "Success");

            try
            {
                if (patient == null || string.IsNullOrEmpty(patient.PatientUniqueId))
                {
                    throw new Exception("Parametros inválidos em UpdatePatientInfoAsync");
                }

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

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

                var patientGP = TranslatePatientLocaltoGP(patient);

                if (patientGP == null || string.IsNullOrEmpty(patientGP.Id))
                {
                    throw new Exception("Erro a converter Modelo de Paciente em UpdatePatientInfoAsync");
                }

                await sc.IdRequestInfoUpdateAsync(patientGP, patientGP.Id);

                return(ServiceReturnHandling.BuildSuccessCallReturn <bool>(true, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <bool>(ex, uiMessages));
            }
        }
Ejemplo n.º 4
0
        public async Task <ServiceReturn <BusinessLayer.Entities.Patient> > GetPatientInfoByUniqueIdAsync(AuthenticationType tipoAuth, string uniquePatId, string successMessage = "", string errorMessage = "")
        {
            #region uimessage
            var uiMessages = new Dictionary <string, string>();
            if (!string.IsNullOrEmpty(errorMessage))
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, errorMessage);
            }
            else
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, "Não foram encontrados dados do paciente.");
            }
            if (!string.IsNullOrEmpty(successMessage))
            {
                uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage);
            }
            #endregion

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

                PatientsPatientClient sc = new PatientsPatientClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient()));
                var ret = await sc.IdAsync(uniquePatId);

                BusinessLayer.Entities.Patient localPat = TranslatePatientGPtoLocal(ret);

                return(ServiceReturnHandling.BuildSuccessCallReturn <BusinessLayer.Entities.Patient>(localPat, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <BusinessLayer.Entities.Patient>(ex, uiMessages));
            }
        }
Ejemplo n.º 5
0
        public async Task <ServiceReturn <List <DescendantCollectionItem> > > GetUserDescendants(AuthenticationType tipoAuth, string idUser, 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.Error);
            }
            if (!string.IsNullOrEmpty(successMessage))
            {
                uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage);
            }

            List <DescendantCollectionItem> listFinal = new List <DescendantCollectionItem>();

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

                PatientsPatientClient sc = new PatientsPatientClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient()));
                var resDesc = await sc.IdDescendantsAsync(0, 100, idUser);

                if (resDesc != null)
                {
                    listFinal = resDesc.ToList();
                }

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