Exemple #1
0
        public static ReturnObject ETASUSelections(HttpContext context, Dictionary<string, object> drug_selection)
        {
            // THIS IMPLELEMTATION WILL NOT WORK LONG TERM.  CHECKBOXES = BAD
            try
            {
                var userProfile = Data.UserProfile.FindByUser(Framework.Security.Manager.GetUser());
                var prescriber = Data.Prescriber.FindByProfile(userProfile);

                // process each drug
                foreach(string key in drug_selection.Keys)
                {
                    long id = long.Parse(key);
                    Lib.Data.Drug drug = new Lib.Data.Drug(id);

                    if(!drug.Active)
                        throw new ArgumentException("That is not a valid drug", "drug_selections");

                    // record the selected value
                    var drugSelection = new DrugSelection
                    {
                        PrescriberID = prescriber.ID ?? 0,
                        DrugID = drug.ID ?? 0,
                        DateRecorded = DateTime.Now,
                        Prescribes = ((string)drug_selection[key]).ToLower() == "yes"
                    };

                    drugSelection.Save();

                    // now add the drug to the prescriber
                    if(drugSelection.Prescribes)
                        Drug.AddDrugToPrescriber(drug.ID ?? 0, 9999);
                }
            }
            catch(FormatException)
            {
                return Failure(404, "The selected drug does not exist in the system.");
            }
            catch(ArgumentException ex)
            {
                return Failure(404, ex.Message);
            }
            catch(SecurityException ex)
            {
                return Failure(403, ex.Message);
            }

            return Success(
                "Drugs Updated",
                "Your drug selections have been updated.",
                "prescriber/wizards/non-etasu-selections");
        }
Exemple #2
0
        private static void SetAllRemainingDrugsToNo()
        {
            // After the ETASU selection screen and the non-ETASU selection screen,
            // the only drugs left with no selection would be the non-ETASU drugs
            // the user did not check on the non-ETASU selection page.  Let's set
            // those all to "no".
            IList<Lib.Data.Drug> drugs = Lib.Systems.Drugs.GetDrugsWithNoSelection(Framework.Security.Manager.GetUser());

            var userProfile = Data.UserProfile.FindByUser(Framework.Security.Manager.GetUser());
            var prescriber = Data.Prescriber.FindByProfile(userProfile);

            foreach(Lib.Data.Drug drug in drugs)
            {
                // record the "no" drug selection
                DrugSelection drugSelection = new DrugSelection
                {
                    PrescriberID = prescriber.ID ?? 0,
                    DrugID = drug.ID ?? 0,
                    DateRecorded = DateTime.Now,
                    Prescribes = false
                };

                drugSelection.Save();
            }
        }
Exemple #3
0
        public static ReturnObject NonETASUSelections(HttpContext context, string[] drug_selections)
        {
            User user = Framework.Security.Manager.GetUser();

            // NonETASU seleciton is opitonal.  For this reason checkboxes are used and not radio
            // buttons.  Any drug in drug_selections has been selected by the user.
            try
            {
                var userProfile = Data.UserProfile.FindByUser(user);
                var prescriber = Data.Prescriber.FindByProfile(userProfile);

                // process each drug
                foreach(string selection in drug_selections)
                {
                    Lib.Data.Drug drug = new Lib.Data.Drug(long.Parse(selection));

                    if(!drug.Active)
                        throw new ArgumentException("That is not a valid drug", "drug_selections");

                    // record the "yes" drug selection
                    var drugSelection = new DrugSelection
                    {
                        PrescriberID = prescriber.ID ?? 0,
                        DrugID = drug.ID ?? 0,
                        DateRecorded = DateTime.Now,
                        Prescribes = true
                    };

                    drugSelection.Save();

                    // now add the drug to the prescriber
                    Drug.AddDrugToPrescriber(drug.ID ?? 0, 9999);
                }

                SetAllRemainingDrugsToNo();
            }
            catch(FormatException)
            {
                return Failure(404, "The selected drug does not exist in the system.");
            }
            catch(ArgumentException ex)
            {
                return Failure(404, ex.Message);
            }
            catch(SecurityException ex)
            {
                return Failure(403, ex.Message);
            }

            NotificationService.Send(
                NotificationService.Create("Profile Complete", "You have successfully completed filling out your profile", false),
                user
                );

            return Success(
                "Drugs Updated",
                "Your drug selections have been updated.",
                null,
                "Default.aspx#prescriber/drugs/list");
        }