示例#1
0
        /// <summary>
        /// Reschedules the visit.
        /// </summary>
        /// <param name="p">parameters</param>
        public void RescheduleVisit(VisitRescheduleVisitSP p)
        {
            IDoctorScheduleService doctorScheduleService = (IDoctorScheduleService)
                                                           EntityFactory.GetEntityServiceByName(vDoctorSchedule.EntityName, "");

            vVisit visit = GetByIDV(p.VisitID, new GetByIDParameters());

            OwnerPatientOrOwnerDoctorSecurity.Check("reschedule an appointment", visit, vVisit.ColumnNames.PatientUserID, vVisit.ColumnNames.DoctorID);

            DoctorSchedule oldDoctorSchedule = doctorScheduleService.GetByIDT(visit.DoctorScheduleID, new GetByIDParameters());
            DoctorSchedule newDoctorSchedule = doctorScheduleService.GetByIDT(p.NewDoctorScheduleID, new GetByIDParameters());

            // checking business rules
            ((VisitBR)BusinessLogicObject).RescheduleVisit(visit, oldDoctorSchedule, newDoctorSchedule);

            // updating old schedule (it should allow +1 number of patients)
            if (oldDoctorSchedule.NumberOfRegisteredPatients != 0)
            {
                oldDoctorSchedule.NumberOfRegisteredPatients--;
            }
            UpdateParameters updateParameters = new UpdateParameters();

            updateParameters.DetailEntityObjects.Add(new DetailObjectInfo()
            {
                EntityName = vDoctorSchedule.EntityName,
                EntitySet  = oldDoctorSchedule,
                FnName     = RuleFunctionSEnum.Update
            });

            // updating new schedule (it should allow -1 number of patients)
            newDoctorSchedule.NumberOfRegisteredPatients++;
            updateParameters.DetailEntityObjects.Add(new DetailObjectInfo()
            {
                EntityName = vDoctorSchedule.EntityName,
                EntitySet  = newDoctorSchedule,
                FnName     = RuleFunctionSEnum.Update
            });

            // Adding notification for user
            var notification = CreateScheduleNotification(visit);

            notification.NotificationTemplateID = (int)EntityEnums.NotificationTemplateEnum.VisitRescheduled;
            TemplateParams tmpP = new TemplateParams();

            tmpP.AddParameter("FromDate", DateTimeEpoch.ConvertUnixEpochToLocalTime(oldDoctorSchedule.SlotUnixEpoch, visit.PatientWorldTimeZoneID).ToString());
            tmpP.AddParameter("ToDate", DateTimeEpoch.ConvertUnixEpochToLocalTime(newDoctorSchedule.SlotUnixEpoch, visit.PatientWorldTimeZoneID).ToString());
            notification.ParametersValues = tmpP.SerializeToString();
            updateParameters.DetailEntityObjects.Add(new DetailObjectInfo()
            {
                EntityName = vNotification.EntityName,
                EntitySet  = notification,
                FnName     = RuleFunctionSEnum.Insert
            }
                                                     );

            // updating visit changes
            visit.DoctorScheduleID = p.NewDoctorScheduleID;
            Update(visit, updateParameters);
        }
示例#2
0
 public DoctorScheduleController(IDoctorScheduleService service)
 {
     _service = service;
 }
 public DoctorSchedulesController(IMapper mapper, IDoctorScheduleService doctorScheduleService)
 {
     _mapper = mapper;
     _doctorScheduleService = doctorScheduleService;
 }