public DrugViewModel(Data.Drug drug) { GID = drug.GID; DrugCode = drug.DrugCode; OrderCode = drug.OrderCode; Title = drug.Title; DrugStockAmount = drug.DrugStock.Sum(a => a.CurrentStock); }
/// <summary> /// This method is used by the Drug system and durring the selections process. /// Durring the selection process the method cannot directly return a ReturnObject /// because it is just one of a few steps. /// </summary> /// <param name="id">Drug to be added</param> /// <param name="order">Where to insert the drug</param> internal static void AddDrugToPrescriber(long id, int order) { var d = new Data.Drug(id); if (d.ID == null || d.ID.Value != id || !d.Active) throw new ArgumentException("That is not a valid drug", "id"); var profile = Data.UserProfile.FindByUser(Framework.Security.Manager.GetUser()); var p = Data.Prescriber.FindByProfile(profile); if (p == null || p.ID == null) throw new SecurityException("You must be logged in to do that"); var drug_list = Systems.Lists.GetMyDrugList(); drug_list.AddItem( d.ID.Value, order ); Systems.PrescriberUpdate.DrugAdded(p, d); AddEocs(profile.ID.Value, d.ID.Value); }
public static ReturnObject Certified( HttpContext context, long drug_id, string eoc_name ) { var d = new Data.Drug( drug_id ); if( d.ID == null || d.ID.Value != drug_id || !d.Active ) { return new ReturnObject { Error = true, StatusCode = 404, Message = "That is not a valid drug." }; } var eoc = Data.Eoc.FindByName( eoc_name ); if( eoc == null || eoc.ID == null ) { return new ReturnObject { Error = true, StatusCode = 404, Message = "That is not a valid EOC." }; } var p = Systems.Security.GetCurrentProfile(); var prescriber = Data.Prescriber.FindByProfile(p); if( p == null || p.ID == null ) { return new ReturnObject { Error = true, StatusCode = 403, Message = "You must be logged in to do that." }; } Data.UserEoc cert = new Data.UserEoc() { DateCompleted = DateTime.Now, DrugID = d.ID.Value, EocID = eoc.ID.Value, ProfileID = p.ID.Value }; RecordCompliance(cert); if( p.UserType.Name == "prescriber" ) Systems.PrescriberUpdate.DrugCertified( Lib.Systems.Security.GetCurrentPrescriber(), d ); TaskService.ScheduleTask( new CertificationReminder { DrugId = d.ID.Value, PrescriberId = p.ID.Value }, DateTime.Now.Add( Lib.Systems.Drugs.GetRenewalPeriod( d ) ) ); if(prescriber != null) Systems.PrescriberUpdate.DrugCertified(prescriber, d); return new ReturnObject { Error = false, StatusCode = 200, Growl = new ReturnGrowlObject { Type = "default", Vars = new ReturnGrowlVarsObject { text = "You have successfully certified \"" + eoc.DisplayName + "\" for \"" + d.GenericName + "\".", title = "EOC Certified" } }, Actions = new List<ReturnActionObject> { new ReturnActionObject { Ele = ".eoc-icon-"+eoc_name, Type = "enable" } } }; }
public static ReturnObject Remove(HttpContext context, long id) { var d = new Data.Drug(id); if (d.ID == null || d.ID.Value != id || !d.Active) { return new ReturnObject { Error = true, StatusCode = 404, Message = "That is not a valid drug." }; } var profile = Data.UserProfile.FindByUser(Framework.Security.Manager.GetUser()); var p = Data.Prescriber.FindByProfile(profile); if (p == null || p.ID == null) { return new ReturnObject { Error = true, StatusCode = 403, Message = "You must be logged in to do that." }; } var drug_list = Systems.Lists.GetMyDrugList(); drug_list.RemoveItem( d.ID.Value ); Systems.PrescriberUpdate.DrugRemoved(p, d); RemoveEocs(profile.ID.Value, d.ID.Value); return new ReturnObject { Error = false, StatusCode = 200 }; }