예제 #1
0
        private static void UpdateEventStatus(Event eventInfo, string externalId)
        {
            EventStatus newStatus;

            switch (eventInfo.Status)
            {
            case EventStatus.ToSend:
            case EventStatus.Sent:
                newStatus = EventStatus.Sent;
                break;

            case EventStatus.Fill:
                newStatus = EventStatus.Complete;
                break;

            case EventStatus.InActive:
            default:
                newStatus = eventInfo.Status;
                break;
            }
            //update the event to the new status
            //currently we have to update the Event object as well as create a history entry for it
            eventInfo.Status = newStatus;
            using (var service = new EventHistoryService())
            {
                EventHistory eh = new EventHistory();
                eh.Date       = DateTime.Now;
                eh.Status     = newStatus;
                eh.Event      = eventInfo;
                eh.ExternalId = externalId;
                service.Create(eh);
            }
        }
예제 #2
0
        public static Event GetEvent(string externalId)
        {
            EventHistory eh;

            using (var service = new EventHistoryService())
            {
                eh = service.GetWhere(EventHistoryService.ExternalIdCol == externalId).FirstOrDefault();
            }
            if (eh == null)
            {
                throw new ArgumentException("Invalid external id: " + externalId);
            }
            return(eh.Event);
        }
예제 #3
0
        private static List <Event> GetOpenSMSEventsFor(string fromNumber)
        {
            List <Event> events;
            //add filter with one week ago when Jon adds date comparisons to CRUDService
            DateTime oneWeekAgo = DateTime.Today.AddDays(-7);

            using (var eventService = new EventService())
                using (var patientService = new PatientService())
                    using (var service = new EventHistoryService())
                    {
                        events = service.GetWhere(
                            (PatientService.PhoneCol.In("Event") == fromNumber) &
                            (PatientService.ContactPreferenceCol.In("Event") == ContactPreference.TEXT &
                             EventService.StatusCol == EventStatus.Sent &
                             EventHistoryService.DateCol >= oneWeekAgo)).Select(hist => hist.Event).ToList();
                    }
            return(events);
        }
예제 #4
0
        //prescription needs to be filled
        public static string FillPrescription(Event e)
        {
            e.Status = EventStatus.Fill;
            EventHistory eh = new EventHistory();

            eh.Event  = e;
            eh.Date   = DateTime.Now;
            eh.Status = EventStatus.Fill;
            using (var eventService = new EventService())
                using (var service = new EventHistoryService())
                {
                    try
                    {
                        eventService.Update(e);
                        service.Create(eh);
                        //this should be persisted in the database
                        return("Your prescription is on the way! We will contact you when it is ready to be picked up.");
                    } catch (Exception exception)
                    {
                        //this should be persisted in the database
                        return("We're sorry, an application error has occurred; please contact your pharmacy to process your request.");
                    }
                }
        }