Beispiel #1
0
		public static void SendOtherNutritionMail(string[] toAddress, string[] ccAddress, CalOtherNutrition con, CalStudyInfo csi, string name, string siteName, HttpServerUtilityBase server, string url)
		{
			string subject = "Halfpint - Other Nutrition Added";
			StringBuilder sbBody = new StringBuilder("<p>" + name + " from " + siteName + " has included other nutrition:</p>");
			
			sbBody.Append("Study ID: " + csi.SStudyId + ", Date: " + csi.CalcDate);
			sbBody.Append("<br/>");
			sbBody.Append("<table><tr><th>Type</th><th>Checked</th></tr>");
			sbBody.Append("<tr><td>Breast Feeding</td><td>" + con.BreastFeeding + "</td></tr>");
			sbBody.Append("<tr><td>Drinks</td><td>" + con.Drinks + "</td></tr>");
			sbBody.Append("<tr><td>Solid Foods</td><td>" + con.SolidFoods + "</td></tr>");
			sbBody.Append("<tr><td>Other</td><td>" + con.Other + "</td></tr>");            
			sbBody.Append("</table>");
			sbBody.Append("<br/>");
			sbBody.Append("Other Text:");
			sbBody.Append("<br/>");
			sbBody.Append(con.OtherText);

			string siteUrl = "Website: <a href='" + url + "'>HalfpintStudy.org</a>";
			SendHtmlEmail(subject, toAddress, ccAddress, sbBody.ToString(), server, siteUrl);
		}
Beispiel #2
0
        public JsonResult Save(int calStudyID, CalParenteral[] pis, CalInfuseColumn[] cic, CalStudyInfo csi, CalEnteral[] ces, CalAdditive[] cas, CalOtherNutrition con)
        {
            bool isEdit = false || calStudyID > 0;
            var  dto    = new DTO();

            if (isEdit)
            {
                //get the original calcdate and see if it has been changed
                //if changed then check for duplicate


                CalorieCalc.DeleteCurrentEntries(calStudyID);
                csi.Id = calStudyID;

                dto = CalorieCalc.UpdateCalStudyInfo(csi);
                if (dto.ReturnValue == -1)
                {
                    dto.Message = "There was an error updating this caloric entry.  It has been reported to the web master!";
                    return(Json(dto));
                }
            }
            else
            {
                if (CalorieCalc.IsCalStudyInfoDuplicate(csi.StudyId, csi.CalcDate) == 1)
                {
                    dto.ReturnValue = 0;
                    dto.Message     = "This study id for the date, " + csi.CalcDate + ", has already been entered!";

                    return(Json(dto));
                }

                dto = CalorieCalc.AddCalStudyInfo(csi);
                if (dto.ReturnValue == -1)
                {
                    dto.Message = "There was an error adding this caloric entry.  It has been reported to the web master!";
                    return(Json(dto));
                }
            }

            con.CalStudyId = csi.Id;
            if (con.OtherText == null)
            {
                con.OtherText = "";
            }
            dto = CalorieCalc.AddCalOtherNutrition(con);
            //check for any data and if there is data - send email
            if ((con.BreastFeeding) || (con.Drinks) || (con.SolidFoods) || (con.Other) || (con.OtherText.Trim().Length > 0))
            {
                //string[] users = ConfigurationManager.AppSettings["NewFormulaNotify"].ToString().Split(new[] { ',' }, StringSplitOptions.None);

                var siteId = DbUtils.GetSiteidIdForUser(User.Identity.Name);
                var staff  = NotificationUtils.GetStaffForEvent(6, siteId);

                string siteName = DbUtils.GetSiteNameForUser(User.Identity.Name);

                var    u   = new UrlHelper(this.Request.RequestContext);
                string url = "http://" + this.Request.Url.Host + u.RouteUrl("Default", new { Controller = "Account", Action = "Logon" });

                Utility.SendOtherNutritionMail(staff.ToArray(), null, con, csi, User.Identity.Name, siteName, Server, url);
            }

            if (dto.ReturnValue == -1)
            {
                dto.Message = "There was an error adding other nutrition.  It has been reported to the web master!";
                return(Json(dto));
            }

            if (cic != null)
            {
                foreach (var ci in cic)
                {
                    if (ci.Volumes == null)
                    {
                        continue;
                    }
                    var cid = new CalInfusionDex();
                    cid.DexVal     = ci.DexValue;
                    cid.CalStudyID = csi.Id;

                    dto = CalorieCalc.AddCalInfusionDex(cid);
                    if (dto.ReturnValue == -1)
                    {
                        dto.Message = "There was an error adding a infusion dextrose entry.  It has been reported to the web master!";
                        return(Json(dto));
                    }

                    foreach (var vol in ci.Volumes)
                    {
                        var civ = new CalInfusionVol();
                        civ.DexID  = cid.ID;
                        civ.Volume = vol;
                        CalorieCalc.AddCalInfusionVol(civ);
                        if (dto.ReturnValue == -1)
                        {
                            dto.Message = "There was an error adding a infusion volume entry.  It has been reported to the web master!";
                            return(Json(dto));
                        }
                    }
                }
            }

            if (pis != null)
            {
                foreach (var pi in pis)
                {
                    pi.CalStudyID = csi.Id;
                    dto           = CalorieCalc.AddCalParenteral(pi);
                    if (dto.ReturnValue == -1)
                    {
                        dto.Message = "There was an error adding a parenteral entry.  It has been reported to the web master!";
                        return(Json(dto));
                    }
                }
            }

            if (ces != null)
            {
                foreach (var ce in ces)
                {
                    ce.CalStudyID = csi.Id;
                    dto           = CalorieCalc.AddCalEnteral(ce);
                    if (dto.ReturnValue == -1)
                    {
                        dto.Message = "There was an error adding an enteral entry.  It has been reported to the web master!";
                        return(Json(dto));
                    }
                }
            }

            if (cas != null)
            {
                foreach (var ca in cas)
                {
                    ca.CalStudyID = csi.Id;
                    dto           = CalorieCalc.AddCalAdditive(ca);
                    if (dto.ReturnValue == -1)
                    {
                        dto.Message = "There was an error adding an additive entry.  It has been reported to the web master!";
                        return(Json(dto));
                    }
                }
            }

            dto.ReturnValue = 1;
            dto.Message     = "Caloric Entries were added successfully!";
            return(Json(dto));
        }