public BusinessLayer.Entities.FreeTimeSlot TranslateFreeTimeSlotGPToLocal(Generated.FreeTimeSlot2 freeSlotGP) { FreeTimeSlot freeSlotLocal = new FreeTimeSlot(); try { if (freeSlotGP != null) { freeSlotLocal.Begin = freeSlotGP.StartDate.HasValue ? freeSlotGP.StartDate.Value : DateTime.Today; // necessario validar este campo..colocada data de hoje freeSlotLocal.End = freeSlotGP.EndDate.HasValue ? freeSlotGP.EndDate.Value : DateTime.Today; freeSlotLocal.HumanResourceId = (int)freeSlotGP.HumanResourceId; freeSlotLocal.Id = freeSlotGP.FreeTimeSlotId; //freeSlotLocal.ClinicalServiceId = freeSlotGP.; freeSlotLocal.MedicalActCode = freeSlotGP.MedicalActId.ToString(); freeSlotLocal.CabinetId = freeSlotGP.LocalCabinetId; freeSlotLocal.ScheduleId = freeSlotGP.LocalScheduleId; //freeSlotLocal.PersonnelNumber = freeSlotGP.; freeSlotLocal.FacilityId = (int)freeSlotGP.FacilityId; //freeSlotLocal.Group = freeSlotGP.; freeSlotLocal.Duration = freeSlotGP.Duration.HasValue ? freeSlotGP.Duration.Value : new DateTime(); freeSlotLocal.FirstTimeFlag = freeSlotGP.IsFirstTime.HasValue ? freeSlotGP.IsFirstTime.Value : false; } } catch (Exception ex) { Debug.WriteLine("Erro a realizar o convert de FreeTimeSlot (GP) para FreeTimeSlot (local)"); } return(freeSlotLocal); }
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 <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)); } }