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)); } }
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)); } }
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)); } }
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)); } }
public async Task <ServiceReturn <bool> > SetNotificationReadStatusAsync(AuthenticationType tipoAuth, Notification notification, bool markAsRead, 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.FailGetNotificationsList); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } bool success; try { string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.NotificationsClient sc = new Generated.NotificationsClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); success = await sc.SetNotificationReadStatusAsync(notification.IdNotification, markAsRead, GetGPAppVersion()); return(ServiceReturnHandling.BuildSuccessCallReturn <bool>(success, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <bool>(ex, uiMessages)); } }
public async Task <ServiceReturn <bool> > CancelAppointmentForUniquePatientAsync(AuthenticationType tipoAuth, string facilityId, string apptId, string userID, string cancelObs, 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 foi possível cancelar a marcação."); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } try { string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.AppointmentClient sc = new Generated.AppointmentClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); //string userID = (User != null && !string.IsNullOrEmpty(User.UserId)) ? User.UserId : string.Empty; int operationTimeOut = 30; await sc.CancelAppointmentByUniquePatientIdAsync(facilityId, apptId, userID, operationTimeOut, GetGPAppVersion()); return(ServiceReturnHandling.BuildSuccessCallReturn <bool>(true, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <bool>(ex, uiMessages)); } }
public async Task<ServiceReturn<bool>> UploadProfilePhotoAsync(AuthenticationType tipoAuth, byte[] photo, string extension, 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); bool uploadSuccess = false; try { string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.PatientDataClient sc = new Generated.PatientDataClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); await sc.PostUploadProfilePhotoAsync(photo, extension, GetGPAppVersion()); uploadSuccess = true; return ServiceReturnHandling.BuildSuccessCallReturn<bool>(uploadSuccess, uiMessages); } catch (Exception ex) { return ServiceReturnHandling.HandleException<bool>(ex, uiMessages); } }
public async Task<ServiceReturn<string>> VerifyUserAndCreatePatient(AuthenticationType tipoAuth, string username, string nif, System.DateTime birthDate, string name, string email, string phoneNumber, string gender, string destination, string version, 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.NotPossibleCreatePacient); if (!string.IsNullOrEmpty(successMessage)) uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); try { string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.UsersClient sc = new Generated.UsersClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); var result = await sc.VerifyUserAndCreatePatientAsync(username, nif, "SMS", birthDate, name, email, phoneNumber, gender, destination, phoneNumber, string.Empty, string.Empty, string.Empty, string.Empty, true, GetGPAppVersion()); return ServiceReturnHandling.BuildSuccessCallReturn<string>(result, uiMessages); } catch (Exception ex) { try { var gpExp = ((Generated.GPlatformException)ex).Response; var localExcp = Newtonsoft.Json.JsonConvert.DeserializeObject<GPlatformClientException>(gpExp); if (!string.IsNullOrEmpty(ex.Message) && ex.Message.Contains("The HTTP status code of the response was not expected (40")) uiMessages[ServiceReturnHandling.GenericMessageKey] = localExcp.Description; } catch (Exception) { } return ServiceReturnHandling.HandleException<string>(ex, uiMessages); } }
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)); } }
public async Task <ServiceReturn <List <Specialty> > > GetSpecialtiesByIdsAsync(AuthenticationType tipoAuth, List <int> specialitiesIds, List <int> facilitiesIds, 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, AppResources.GetSpecialtyError); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <Specialty> ret = null; try { string baseMuleUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_MULE_URL"); Generated.Mulesoft.GETClient sc = new Generated.Mulesoft.GETClient(baseMuleUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); //ObservableCollection<Generated.ExternalFilterSpeciality> listFilter = new ObservableCollection<Generated.ExternalFilterSpeciality>(); //foreach (var item in specialitiesIds) //{ // Generated.ExternalFilterSpeciality filter = new Generated.ExternalFilterSpeciality() // { // Id = item // }; // listFilter.Add(filter); //} var retTemp = await sc.SpecialitiesAsync(specialitiesIds, facilitiesIds, null, skip, take); if (retTemp != null) { ret = new List <Specialty>(); foreach (var item in retTemp) { ret.Add(TranslateSpecialty2GPToLocal(item)); } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <Specialty> >(ret, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <Specialty> >(ex, uiMessages)); } }
public async Task <ServiceReturn <List <Appointment> > > GetAllPatientAndDescendantsAppointmentsAsync(AuthenticationType tipoAuth, IEnumerable <string> facilityIds, IEnumerable <string> patientIds, 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 marcações"); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } try { List <Appointment> appointments = null; string userID = (User != null && !string.IsNullOrEmpty(User.UserId)) ? User.UserId : string.Empty; // Patient uniqueid??? Validar caso seja anonimo access?? string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.AppointmentClient sc = new Generated.AppointmentClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); Generated.AppointmentFilter filter = new Generated.AppointmentFilter(); if (facilityIds.Count() > 0) { filter.FacilityIds = new ObservableCollection <double>(facilityIds.Select(x => double.Parse(x))); } filter.DescendantPatientUniqueIds = new ObservableCollection <string>(patientIds); var result = await sc.AppointmentsByParentAsync(filter, userID, "true", minDate, maxDate, skip, take, GetGPAppVersion()); if (result != null) { appointments = new List <Appointment>(); foreach (var item in result) { appointments.Add(TranslateAppointmentGPToLocal(item)); } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <Appointment> >(appointments, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <Appointment> >(ex, uiMessages)); } }
public async Task <ServiceReturn <bool> > SyncRelatsPacsShareImageAsync(AuthenticationType tipoAuth, List <string> emails, List <string> idDocuments, 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.FailGetResults); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } bool res; try { string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.SyncronizingClient sc = new Generated.SyncronizingClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); // Neste momento só permite partilhar 1 doc/img de cada vez var idDocument = idDocuments.FirstOrDefault(); var emailsConcat = string.Empty; foreach (var email in emails) { emailsConcat += email + ";"; } if (!string.IsNullOrEmpty(emailsConcat) && emailsConcat.Length > 0) { emailsConcat.Remove(emailsConcat.Length - 1); } var result = await sc.SyncRelatsPacsShareImageAsync(idDocument, emailsConcat, GetGPAppVersion()); res = true; // checkar return? return(ServiceReturnHandling.BuildSuccessCallReturn <bool>(res, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <bool>(ex, uiMessages)); } }
public async Task <ServiceReturn <List <MedicalAct> > > GetMedicalActsAsync(AuthenticationType tipoAuth, List <int> facilityIds, int?specialtyId, int?humanResourceID, int?financialEntity, 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.GetMedicalActsError); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <MedicalAct> ret = null; try { string baseMuleUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_MULE_URL"); Generated.Mulesoft.GETClient sc = new Generated.Mulesoft.GETClient(baseMuleUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); //var specialtyIdFinal = !string.IsNullOrEmpty(specialtyId) ? specialtyId : ""; //var humanResourceIdFinal = !string.IsNullOrEmpty(humanResourceId) ? humanResourceId : ""; //var efrIdFinal = !string.IsNullOrEmpty(efrId) ? efrId : ""; //var facilityIdsFinal = facilityIds.Select(x => double.Parse(x)).ToList(); var retTemp = await sc.OfferMedicalActsAsync(facilityIds, specialtyId, humanResourceID, null, financialEntity, "", 0, 10000); if (retTemp != null) { ret = new List <MedicalAct>(); foreach (var item in retTemp) { ret.Add(TranslateMedicalActGPToLocal(item)); } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <MedicalAct> >(ret, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <MedicalAct> >(ex, uiMessages)); } }
public async Task <ServiceReturn <List <FacilityInfoContext> > > GetFacilitiesInfoContextDetailAsync(AuthenticationType tipoAuth, int facilityId, 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, AppResources.GetFacilitiesError); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <FacilityInfoContext> facilitiesInfoDetails = null; try { string baseMuleUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_MULE_URL"); Generated.Mulesoft.GETClient sc = new Generated.Mulesoft.GETClient(baseMuleUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); var retTemp = await sc.FacilitiesIdInfoAsync(skip, take, facilityId); if (retTemp != null) { facilitiesInfoDetails = new List <FacilityInfoContext>(); var groupedByContext = retTemp.GroupBy(x => x.Context); foreach (var sameContextItem in groupedByContext) { var res = TranslateFacilityInfoDetail2GPToLocal(sameContextItem); if (res != null) { facilitiesInfoDetails.Add(res); } } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <FacilityInfoContext> >(facilitiesInfoDetails, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <FacilityInfoContext> >(ex, uiMessages)); } }
public async Task <ServiceReturn <List <ResultDocument> > > GetResultsAsync(AuthenticationType tipoAuth, List <string> userIds, 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.FailGetResultsList); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <ResultDocument> resultsLocal = new List <ResultDocument>(); try { DateTime startDate = DateTime.MinValue; DateTime endDate = DateTime.Today.AddDays(1); string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.ResultsClient sc = new Generated.ResultsClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); foreach (var item in userIds) { var result = await sc.GetResultsAsync(item, startDate, endDate, false, 0, 100, GetGPAppVersion()); if (result != null) { foreach (var resGP in result) { resultsLocal.Add(TranslateResultDocumentGPToLocal(resGP, item)); } } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <ResultDocument> >(resultsLocal, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <ResultDocument> >(ex, uiMessages)); } }
public async Task <ServiceReturn <List <string> > > GetHumanResourceFacilitiesAsync(AuthenticationType tipoAuth, string providerID, 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.GetFacilitiesError); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <string> facilitiesIds = new List <string>(); try { string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.HumanResourceClient sc = new Generated.HumanResourceClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); ObservableCollection <double> listFilter = new ObservableCollection <double>(); listFilter.Add(double.Parse(providerID)); var ret = await sc.GetByIdsAsync(listFilter, GetGPAppVersion()); if (ret != null) { foreach (var item in ret) { if (item.FacilityId.HasValue) { facilitiesIds.Add(item.FacilityId.Value.ToString()); } } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <string> >(facilitiesIds, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <string> >(ex, uiMessages)); } }
public async Task <ServiceReturn <List <Facility> > > GetFacilitiesFilteredByDoctorAsync(AuthenticationType tipoAuth, string medicID, 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, AppResources.GetFacilitiesError); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <Facility> facilities = null; Generated.FacilityBaseFilter humanR = new Generated.FacilityBaseFilter(); humanR.ListHumanResources = new ObservableCollection <double>(); humanR.ListHumanResources.Add(double.Parse(medicID)); try { string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.FacilityClient sc = new Generated.FacilityClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); var retTemp = await sc.GetFacilitiesBaseAsync(humanR, "", "", "", skip, take, GetGPAppVersion()); if (retTemp != null) { facilities = new List <Facility>(); foreach (var item in retTemp) { facilities.Add(TranslateFacilityDoctorGPToLocal(item)); } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <Facility> >(facilities, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <Facility> >(ex, uiMessages)); } }
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)); } }
public async Task <ServiceReturn <ScheduledAppointment> > RescheduleAppointmentAsync(AuthenticationType tipoAuth, string userId, string facilityId, FreeTimeSlot freeTimeSlotLocal, Appointment oldApp, string cod_motivo, DateTime efrExpDate, string efrCard, 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 efetuar a marcação."); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } #endregion ScheduledAppointment scheduledAppoint; try { string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.AppointmentClient sc = new Generated.AppointmentClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); var obsFinal = !string.IsNullOrEmpty(freeTimeSlotLocal.Observations) ? freeTimeSlotLocal.Observations : string.Empty; var resApp = TranslateFreeTimeSlotLocalToGP(freeTimeSlotLocal); var res = await sc.RescheduleAppointmentAsync(resApp, facilityId, oldApp.Id.ToString(), userId, obsFinal, cod_motivo, efrCard, efrExpDate, GetGPAppVersion()); if (res != null) { scheduledAppoint = TranslateScheduledAppointmentGPToLocal(res.First()); } else { throw new Exception(); } return(ServiceReturnHandling.BuildSuccessCallReturn <ScheduledAppointment>(scheduledAppoint, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <ScheduledAppointment>(ex, uiMessages)); } }
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 <List <Specialty> > > GetSpecialtiesAsync(AuthenticationType tipoAuth, List <int> facilityIds, int?financialEntity = null, int?humanResourceId = null, 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.GetSpecialtiesError); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <Specialty> ret = null; try { string baseMuleUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_MULE_URL"); Generated.Mulesoft.GETClient sc = new Generated.Mulesoft.GETClient(baseMuleUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); //Generated.SpecialityBaseFilter extFilter = new Generated.SpecialityBaseFilter(); //extFilter.ListFacilityIds = new ObservableCollection<double>(facilityIds.Select(x => double.Parse(x)).ToList()); var retTemp = await sc.OfferSpecialitiesAsync(facilityIds, humanResourceId, financialEntity, null, 0, 10000); if (retTemp != null) { ret = new List <Specialty>(); foreach (var item in retTemp) { ret.Add(TranslateSpecialty2GPToLocal(item)); } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <Specialty> >(ret, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <Specialty> >(ex, uiMessages)); } }
public async Task <ServiceReturn <ScheduledAppointment> > ScheduleAppointmentForUniquePatientAsync(AuthenticationType tipoAuth, string userId, string facilityId, FreeTimeSlot freeTimeSlotLocal, DateTime efrExpDate, string efrCard, 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 efetuar a marcação."); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } #endregion ScheduledAppointment scheduledAppoint; try { string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.AppointmentClient sc = new Generated.AppointmentClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); string group = Configuration.Instance.Configurations["GROUP"]; Generated.FreeTimeSlot2 freeSlotGP = TranslateFreeTimeSlotLocalToGP(freeTimeSlotLocal); int operationTimeOut = 30; var res = await sc.ScheduleAppointmentForUniquePatientAsync(freeSlotGP, facilityId, userId, efrCard, efrExpDate, operationTimeOut, GetGPAppVersion()); if (res != null) { scheduledAppoint = TranslateScheduledAppointmentGPToLocal(res.First()); } else { throw new Exception(); } return(ServiceReturnHandling.BuildSuccessCallReturn <ScheduledAppointment>(scheduledAppoint, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <ScheduledAppointment>(ex, uiMessages)); } }
public async Task <ServiceReturn <List <Facility> > > GetFacilitiesAsync(AuthenticationType tipoAuth, 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, AppResources.GetFacilitiesError); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <double> locationIds = new List <double>(); //Enviar lista vazia List <Facility> facilities = null; try { string baseMuleUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_MULE_URL"); Generated.Mulesoft.GETClient sc = new Generated.Mulesoft.GETClient(baseMuleUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); var retTemp = await sc.FacilitiesAsync(null, null, null, skip, take); if (retTemp != null) { facilities = new List <Facility>(); foreach (var item in retTemp) { facilities.Add(TranslateFacilityGPToLocal(item)); } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <Facility> >(facilities, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <Facility> >(ex, uiMessages)); } }
public async Task <ServiceReturn <List <Preparation> > > GetPreparationsAfterScheduleAsync(AuthenticationType tipoAuth, string facilityId, string IdAppointment, 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 preparações"); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <Preparation> preps = null; try { string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.AppointmentClient sc = new Generated.AppointmentClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); var prepIni = await sc.GetPreparationsAfterScheduleAsync(facilityId, IdAppointment, GetGPAppVersion()); if (prepIni != null) { preps = new List <Preparation>(); foreach (var item in prepIni) { Preparation prep = TranslatePreparationGPToLocal(item); prep.FacilityId = facilityId; // facility nao vem mapeada.. adicionada manualmente pois é necessária no GetLoadPreparationObjectAsync (obter doc da preparação) preps.Add(prep); } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <Preparation> >(preps, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <Preparation> >(ex, uiMessages)); } }
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); } }
public async Task <ServiceReturn <List <HumanResource> > > GetHumanResourceAsync(AuthenticationType tipoAuth, List <int> facilityIds, int?speciality = null, int?medicalAct = null, int?financialEntity = null, 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.GetMedicsListError); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <HumanResource> listRes = null; try { string baseMuleUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_MULE_URL"); Generated.Mulesoft.GETClient sc = new Generated.Mulesoft.GETClient(baseMuleUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); var ret = await sc.OfferStaffAsync(facilityIds, speciality, medicalAct, financialEntity, "", 0, 10000); if (ret != null) { listRes = new List <HumanResource>(); foreach (var item in ret) { listRes.Add(TranslateHumanResourceGPToLocal(item)); } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <HumanResource> >(listRes, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <HumanResource> >(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 <List <BusinessLayer.Entities.Warning> > > GetSearchWarningsAync(AuthenticationType tipoAuth, int facilityId, string appointId, 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.GetMedicalActsError); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <BusinessLayer.Entities.Warning> ret = null; try { string baseMuleUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_MULE_URL"); Generated.Mulesoft.GETClient sc = new Generated.Mulesoft.GETClient(baseMuleUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); var retTemp = await sc.AppointmentsIdNotesDescriptionAsync(facilityId, appointId); if (retTemp != null) { ret = new List <BusinessLayer.Entities.Warning>(); var warning = TranslateWarningGPToLocal(retTemp); warning.AppointmentId = appointId; ret.Add(warning); } return(ServiceReturnHandling.BuildSuccessCallReturn <List <BusinessLayer.Entities.Warning> >(ret, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <BusinessLayer.Entities.Warning> >(ex, uiMessages)); } }
public static ServiceReturn <List <ScheduledAppointment> > RunSync(Func <Task <List <ScheduledAppointment> > > task) { #region uimessage var uiMessages = new Dictionary <string, string>(); if (!string.IsNullOrEmpty("")) { uiMessages.Add(ServiceReturnHandling.GenericMessageKey, ""); } else { uiMessages.Add(ServiceReturnHandling.GenericMessageKey, "Erro ao concluir a marcação"); } if (!string.IsNullOrEmpty("")) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, ""); } #endregion var oldContext = SynchronizationContext.Current; var synch = new ExclusiveSynchronizationContext(); SynchronizationContext.SetSynchronizationContext(synch); List <ScheduledAppointment> ret = default(List <ScheduledAppointment>); synch.Post(async _ => { try { ret = await task(); } catch (Exception e) { synch.InnerException = e; throw; } finally { synch.EndMessageLoop(); } }, null); synch.BeginMessageLoop(); SynchronizationContext.SetSynchronizationContext(oldContext); return(ServiceReturnHandling.BuildSuccessCallReturn <List <ScheduledAppointment> >(ret, uiMessages)); }
public async Task <ServiceReturn <List <Notification> > > NotificationsByUserTypeAsync(AuthenticationType tipoAuth, string userId, 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.FailGetNotificationsList); } if (!string.IsNullOrEmpty(successMessage)) { uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage); } List <Notification> notifications = null; try { string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL"); Generated.NotificationsClient sc = new Generated.NotificationsClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient())); var retTemp = await sc.NotificationsByUserTypeAsync(null, Generated.UserType4.Patient, userId, 0, 1000, GetGPAppVersion()); if (retTemp != null) { notifications = new List <Notification>(); foreach (var item in retTemp) { notifications.Add(TranslateNotificationsGPToLocal(item)); } } return(ServiceReturnHandling.BuildSuccessCallReturn <List <Notification> >(notifications, uiMessages)); } catch (Exception ex) { return(ServiceReturnHandling.HandleException <List <Notification> >(ex, uiMessages)); } }