internal static BMS.Appointment TranslateServiceToBusiness(DataTypes.Appointment from) { Application application = Helper.GetApplication(); BMS.Patient patient = (BMS.Patient)application.FindPatientById(from.Patient.Id); BMS.Referrer referrer = null; if (from.Referrer == null) { referrer = patient.ReferringClinician; } else { referrer = (BMS.Referrer)application.FindReferrerById(from.Referrer.Id); } BMS.Provider provider = (BMS.Provider)application.FindProviderById(from.Provider.Id); BMS.ClinicType clinicType = (BMS.ClinicType)application.FindClinicTypeById(from.ClinicType.Id); EAppointments.BMS.Appointment to = application.NewAppointment( patient, referrer, provider, clinicType ); return(to); }
internal static DataTypes.Appointment TranslateBusinessToService(BMS.Appointment from) { DataTypes.Appointment to = new DataTypes.Appointment(); to.Ubrn = from.Ubrn; to.StartDateTime = from.StartDateTime; to.EndDateTime = from.EndDateTime; to.CreatedDateTime = from.CreatedDateTime; to.UpdatedDateTime = from.UpdatedDateTime; to.CancelledDateTime = from.CancelledDateTime; to.CancellationReason = from.CancellationReason; to.Referrer = DirectoryTranslator.TranslateBusinessToService(from.Referrer); to.Patient = DirectoryTranslator.TranslateBusinessToService(from.Patient); to.Provider = ProviderTranslator.TranslateBusinessToService(from.Provider); to.ClinicType = DirectoryTranslator.TranslateBusinessToService(from.ClinicType); to.Status = (DataTypes.AppointmentStatus)from.Status; to.Comments = from.Comments; to.ReminderDate = from.ReminderDate; to.WorkflowId = from.WorkflowId; if (from.CancelledBy != null) { to.CancelledById = from.CancelledBy.Id; } if (from.Slot != null) { to.Slot = SlotTranslator.TranslateBusinessToService(from.Slot); } return(to); }
internal static BMS.Appointment TranslateServiceToBusiness(DataTypes.Appointment from, BMS.Appointment to) { to.Comments = from.Comments; to.ReminderDate = from.ReminderDate; to.WorkflowId = from.WorkflowId; return(to); }
public DataTypes.Appointment Save(DataTypes.Appointment appointment) { if (appointment == null) { throw new ArgumentNullException("appointment"); } SetupWorkflowEnvironment(); BMS.Appointment[] businessAppointments = Helper.GetApplication().Find(new AppointmentSearchCriteria(appointment.Ubrn)); BMS.Appointment businessAppointment; if (businessAppointments.Length > 0) { // Existing Appointment // No need to use the workflow as no state change happening. businessAppointment = businessAppointments[0]; businessAppointment = AppointmentTranslator.TranslateServiceToBusiness(appointment, businessAppointment); businessAppointment.Save(); } else { // New Appointment if (appointment.Patient == null || appointment.Provider == null || appointment.ClinicType == null) { throw new ArgumentNullException("appointment"); } Guid workflowInstanceId = Guid.NewGuid(); WorkflowInstance workflowInstance = _workflowRuntime.CreateWorkflow(typeof(AppointmentWorkflow), null, workflowInstanceId); workflowInstance.Start(); _appointmentLocalService.RaiseAppointmentCreateEvent (workflowInstanceId, appointment.Patient.Id, appointment.Provider.Id, appointment.ClinicType.Id); RunWorkFlow(workflowInstanceId); AppointmentSearchCriteria criteria = new AppointmentSearchCriteria(null); criteria.WorkflowId = workflowInstanceId; businessAppointment = Helper.GetApplication().Find(criteria)[0]; } return(AppointmentTranslator.TranslateBusinessToService(businessAppointment)); }