예제 #1
0
        public Generated.Mulesoft.Descendant TranslatePatientLocaltoDescendantGP(BusinessLayer.Entities.Patient patLocal, string colorHex)
        {
            try
            {
                Generated.Mulesoft.Descendant patGp = new Generated.Mulesoft.Descendant()
                {
                    Id                  = patLocal.PatientUniqueId,
                    Birthdate           = patLocal.BirthDate,
                    Email               = patLocal.Email,
                    Address_local       = patLocal.City,
                    Citizen_number      = patLocal.IdNumber,
                    Name                = patLocal.Name,
                    First_phone_number  = patLocal.PhoneNumber1,
                    Second_phone_number = patLocal.PhoneNumber2,
                    Ssn                 = patLocal.NSns,
                    Tax_number          = patLocal.TaxIdNumber,
                    Gender              = patLocal.Sex,
                    Address             = patLocal.Street,
                    Address_zip_code    = patLocal.PostalCode,
                    Color               = colorHex,
                    Valid               = false,
                    Temporary           = true,
                };

                return(patGp);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Erro em TranslatePatientLocaltoGP " + ex.ToString());
                return(null);
            }
        }
예제 #2
0
        public Generated.Mulesoft.Patient TranslatePatientLocaltoGP(BusinessLayer.Entities.Patient patLocal)
        {
            try
            {
                Generated.Mulesoft.Patient patGp = new Generated.Mulesoft.Patient()
                {
                    Id                  = patLocal.PatientUniqueId,
                    Birthdate           = patLocal.BirthDate,
                    Email               = patLocal.Email,
                    Address_local       = patLocal.City,
                    Citizen_number      = patLocal.IdNumber,
                    Name                = patLocal.Name,
                    First_phone_number  = patLocal.PhoneNumber1,
                    Second_phone_number = patLocal.PhoneNumber2,
                    Ssn                 = patLocal.NSns,
                    Tax_number          = patLocal.TaxIdNumber,
                    Gender              = patLocal.Sex,
                    Address             = patLocal.Street,
                    Address_zip_code    = patLocal.PostalCode,
                    //Temporary = patLocal.IsProPatient, // isto deverá ser gerido do lado do GH/Services
                    Updated = false, // Enviar que tenho alterações pendentes de validação
                    //LastAlterationsDate = // isto deverá ser gerido do lado do GH/Services
                };

                return(patGp);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Erro em TranslatePatientLocaltoGP " + ex.ToString());
                return(null);
            }
        }
예제 #3
0
 public BusinessLayer.Entities.Patient TranslatePatientGPtoLocal(Generated.Mulesoft.Patient patGP)
 {
     try
     {
         if (patGP != null)
         {
             BusinessLayer.Entities.Patient patLocal = new BusinessLayer.Entities.Patient()
             {
                 PatientUniqueId       = patGP.Id,
                 BirthDate             = patGP.Birthdate.HasValue ? patGP.Birthdate.Value : DateTime.Now,
                 Email                 = patGP.Email,
                 City                  = patGP.Address_local,
                 IdNumber              = patGP.Citizen_number,
                 Name                  = patGP.Name,
                 PhoneNumber1          = patGP.First_phone_number,
                 PhoneNumber2          = patGP.Second_phone_number,
                 NSns                  = patGP.Ssn,
                 TaxIdNumber           = patGP.Tax_number,
                 Sex                   = patGP.Gender,
                 Street                = patGP.Address,
                 PostalCode            = patGP.Address_zip_code,
                 IsProPatient          = patGP.Temporary.HasValue ? patGP.Temporary.Value : true,
                 HasPendingAlterations = patGP.Updated.HasValue ? !patGP.Updated.Value : false,
                 LastAlterationsDate   = patGP.Updated_datetime.HasValue ? patGP.Updated_datetime.Value : DateTime.Now,
             };
             return(patLocal);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Erro em TranslatePatientGPtoLocal " + ex.ToString());
         return(null);
     }
     return(null);
 }
예제 #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));
            }
        }
예제 #5
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));
            }
        }