Exemple #1
0
        public ActionResult Send()
        {
            SendRecallModel m = new SendRecallModel()
            {
                PatientCodesCsv = Request.Form["PatientCodesCsv"],
                TemplateBody    = Request.Form["TemplateBody"]
            };



            List <MessageTemplate> recallTemplates;

            using (var service = new MessageTemplateService())
            {
                recallTemplates = service.GetWhere(MessageTemplateService.PharmacyCodeCol == User.Pharmacy.Code & MessageTemplateService.TypeCol == MessageTemplateType.RECALL);

                foreach (MessageTemplate t in recallTemplates)
                {
                    t.Content = m.TemplateBody;
                    service.Update(t);
                }
            }

            string[]     codes         = m.PatientCodesCsv.Split(',');
            List <Event> eventsCreated = new List <Event>();

            foreach (string code in codes)
            {
                Patient p = null;
                using (var service = new PatientService())
                {
                    p = service.Get(code);
                }
                if (p != null)
                {
                    Event e = new Event
                    {
                        Status  = EventStatus.ToSend,
                        Patient = p,
                        Type    = EventType.RECALL
                    };
                    using (var service = new EventService())
                    {
                        service.Create(e);
                    }
                    eventsCreated.Add(e);
                    EventRecall er = new EventRecall
                    {
                        Event = e
                    };
                    using (var service = new EventRecallService())
                    {
                        service.Create(er);
                    }
                }
            }
            EventProcessingService.SendEvents(eventsCreated, recallTemplates);

            return(RedirectToAction("SendConfirmation", new { numSent = eventsCreated.Count }));
        }
Exemple #2
0
        public static void Test()
        {
            try
            {
                //EventRecallService init = new EventRecallService();
                Console.WriteLine("Creating sample data...");
                Pharmacy pharm = new Pharmacy(2, "test2", "test3", "test4");
                using (var service = new PharmacyService())
                {
                    service.Update(pharm);
                }

                MessageTemplate temp = new MessageTemplate(pharm, MessageTemplateType.RECALL, MessageTemplateMedia.EMAIL, "this is a test");
                using (var service = new MessageTemplateService())
                {
                    service.Update(temp);
                }

                Drug drug = new Drug(7, "Omeprazole Cap Delayed Release 20 MG");
                using (var service = new DrugService())
                {
                    service.Update(drug);
                }
                Console.WriteLine("Samples created successfully.\nUploading patients...");
                //init.SendRecalls(@"..\..\App_Data\RecallCSVTest.csv", pharm, temp, drug);
                Console.WriteLine("Patients uploaded successfully.\nAll tests successful...");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadKey();
            }
        }
 public ActionResult SaveTemplate(MessageTemplateType type, MessageTemplateMedia media, string content)
 {
     using (var service = new MessageTemplateService())
     {
         var template = service.Get(User.Pharmacy, type, media);
         template.Content = content;
         service.Update(template);
     }
     return(null);
 }