Beispiel #1
0
        public async Task <ServiceReturn <string> > FindCentralPatientByNIFPhoneAsync(AuthenticationType tipoAuth, string _nif, DateTime?_birthday, string _phoneNumber, string successMessage = "", string errorMessage = "")
        {
            // retorna id pat unico
            string ret = string.Empty;

            #region uimessage
            var uiMessages = new Dictionary <string, string>();
            if (!string.IsNullOrEmpty(errorMessage))
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, errorMessage);
            }
            else
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, "Não foi possível encontrar paciente.");
            }
            if (!string.IsNullOrEmpty(successMessage))
            {
                uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage);
            }
            #endregion

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

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

                // if _birthday != datetime.today???
                DateTime defaultDate = DateTime.Now;

                // retorna id pat unico
                if (_birthday.HasValue)
                {
                    ret = await sc.GetCentralPatientByNifPhoneAndBirthDateAsync(_nif, _phoneNumber, string.Empty, string.Empty, _birthday.Value, GetGPAppVersion());
                }
                else
                {
                    ret = await sc.GetCentralPatientByNifAndPhoneAsync(_nif, _phoneNumber, string.Empty, string.Empty, GetGPAppVersion());
                }

                return(ServiceReturnHandling.BuildSuccessCallReturn <string>(ret, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <string>(ex, uiMessages));
            }
        }
Beispiel #2
0
        public async Task <ServiceReturn <string> > CreateProPatientAsync(AuthenticationType tipoAuth, string facilityId, string patName, string patEmail, DateTime patBirthDate, string patientNif, string patientPhoneNumber, string patGender, 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 foi possível registar o novo paciente.");
            }
            if (!string.IsNullOrEmpty(successMessage))
            {
                uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage);
            }
            #endregion

            try
            {
                facilityId = string.IsNullOrEmpty(facilityId) ? "" : facilityId;

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

                Generated.PatientCoreClient sc = new Generated.PatientCoreClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient()));
                var ret = await sc.GetCreateProPatientAsync(facilityId, patName, patEmail, patBirthDate, patientNif, patientPhoneNumber, patGender, GetGPAppVersion());

                if (ret != null && !string.IsNullOrEmpty(ret.CorporatePatientId))
                {
                    return(ServiceReturnHandling.BuildSuccessCallReturn <string>(ret.CorporatePatientId, uiMessages));
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <string>(ex, uiMessages));
            }
        }