public void SetupTest() { var connection = DbConnectionFactory.CreateTransient(); _context = new PHSContext(connection); _unitOfWork = new MockUnitOfWork(_context); _target = new MockStandardReferenceManager(_unitOfWork); }
public static IEnumerable <SelectListItem> StandardReference() { using (var standardReferenceManager = new StandardReferenceManager()) { string message = string.Empty; var standardReferences = standardReferenceManager.GetAllStandardReferences(out message); return(standardReferences.Select(v => new SelectListItem { Value = v.StandardReferenceID.ToString(), Text = v.Title })); } }
public void CleanupTest() { // dispose of the database and connection _context.Dispose(); _unitOfWork.Dispose(); _target.Dispose(); _unitOfWork = null; _context = null; _target = null; }
// GET: Admin/StandardReference public ActionResult Index() { if (!IsUserAuthenticated()) { return(RedirectToLogin()); } string message = string.Empty; using (var standardReferenceManager = new StandardReferenceManager()) { var standardReferences = standardReferenceManager.GetAllStandardReferences(out message); GetErrorAneMessage(); return(View(standardReferences)); } }
public ActionResult GetReferenceRange(int standardReferenceId, string value) { string message = string.Empty; using (var stdReferenceManager = new StandardReferenceManager()) { var referenceRange = stdReferenceManager.GetReferenceRange(standardReferenceId, value, out message); if (referenceRange == null) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { Error = message })); } return(Json(new { Status = referenceRange.Result, Highlight = referenceRange.Highlight })); } }
public ActionResult Edit([Bind(Include = "StandardReferenceID,Title,DataType")] StandardReference standardReference) { if (!IsUserAuthenticated()) { return(RedirectToLogin()); } string message = string.Empty; using (var standardReferenceManager = new StandardReferenceManager(GetLoginUser())) { if (standardReferenceManager.UpdateStandardReference(standardReference, out message)) { SetTempDataMessage(Constants.ValueSuccessfuly("Standard Reference " + standardReference.Title + " has been updated")); return(RedirectToAction("Index")); } SetViewBagError(message); return(View(standardReference)); } }
// GET: Admin/StandardReference/Details/5 public ActionResult Details(int id = 0) { if (!IsUserAuthenticated()) { return(RedirectToLogin()); } string message = string.Empty; using (var standardReferenceManager = new StandardReferenceManager()) { StandardReference standardReference = standardReferenceManager.GetStandardReferenceByID(id, out message); if (standardReference == null) { SetViewBagError(message); return(RedirectToAction("Index")); } return(View(standardReference)); } }
// GET: Admin/StandardReference/Delete/5 public ActionResult Delete(int id = 0) { if (!IsUserAuthenticated()) { return(RedirectToLogin()); } string message = string.Empty; using (var standardReferenceManager = new StandardReferenceManager()) { if (standardReferenceManager.DeleteStandardReference(id, out message)) { SetTempDataMessage(Constants.ValueSuccessfuly("Standard Reference has been deleted")); return(RedirectToAction("Index")); } SetViewBagError(message); return(RedirectToAction("Index")); } }
// GET: Admin/StandardReference/CreateReferenceRange public ActionResult CreateReferenceRange(int standardReferenceID = 0) { if (!IsUserAuthenticated()) { return(RedirectToLogin()); } string message = string.Empty; using (var standardReferenceManager = new StandardReferenceManager()) { StandardReference standardReference = standardReferenceManager.GetStandardReferenceByID(standardReferenceID, out message); if (standardReference == null) { SetViewBagError("Invalid Standard Reference ID. Create Standard Reference first."); return(View()); } ReferenceRange referenceRange = new ReferenceRange(); referenceRange.StandardReferenceID = standardReferenceID; return(View(referenceRange)); } }
public List <SummaryCategoryViewModel> GetSummaryCategories(string summaryType) { List <SummaryCategoryViewModel> result = new List <SummaryCategoryViewModel>(); List <string> categoryNames = null; Dictionary <string, List <string> > summaryLabelMap = null; using (var summaryMappingManager = new SummaryMappingManager()) { categoryNames = summaryMappingManager.GetAllCategoryNamesBySummaryType(summaryType); summaryLabelMap = summaryMappingManager.GetSummaryLabelMapBySummaryType(summaryType); } if (categoryNames == null) { return(result); } foreach (var summaryCategoryName in categoryNames) { SummaryCategoryViewModel sumCategoryViewModel = new SummaryCategoryViewModel(summaryCategoryName); if (summaryCategoryName.Contains("Gastrointestinal Health")) { sumCategoryViewModel.Highlight = true; } foreach (var summary in Participant.Summaries) { if (summary != null && summary.PHSEventID.Equals(Event.PHSEventID)) { if (SummaryHelper.IsFieldNameAndCategoryFoundInSummaryMap(summaryLabelMap, summaryCategoryName, summary.Label)) { if (summary.SummaryValue == null || summary.SummaryValue.Count() <= 0) { continue; } SummaryViewModel sumview = new SummaryViewModel(summary); if (sumCategoryViewModel.Highlight != true) { // summary.TemplateFieldID; if (SummaryHelper.IsHighlightCategoryRequired(summaryCategoryName, summary.TemplateField.SummaryFieldName, summary.SummaryValue)) { sumCategoryViewModel.Highlight = true; } } if (summary.StandardReferenceID != null && summary.StandardReferenceID > 0 && summary.SummaryValue != null) { if (SummaryHelper.IsJson(summary.SummaryValue)) { //if (summary.StandardReferenceID == 1) //Systolic Blood Pressure //{ // sumview.SummaryValue = summary.SummaryValue; // sumview.SummaryInnerValue = summary.SummaryValue; //}else if (summary.StandardReferenceID == 2) //Diastolic Blood Pressure //{ // sumview.SummaryValue = summary.SummaryValue; // sumview.SummaryInnerValue = summary.SummaryValue; //}else if (summary.StandardReferenceID == 3) //Sugar //{ // sumview.SummaryValue = summary.SummaryValue; // sumview.SummaryInnerValue = summary.SummaryValue; //}else if (summary.StandardReferenceID == 4) //BMI { JavaScriptSerializer serializer = new JavaScriptSerializer(); BMIViewModel bmi = serializer.Deserialize <BMIViewModel>(summary.SummaryValue as string); if (bmi.BodyMassIndex != null) { //Weight: 50, Height: 180, BodyMassIndex: 15.43 (UNDERWEIGHT) sumview.SummaryValue = "Weight: " + bmi.Weight + ", Height: " + bmi.Height + ", BodyMassIndex: " + bmi.BodyMassIndex; sumview.SummaryInnerValue = bmi.BodyMassIndex; } } } else { sumview.SummaryInnerValue = summary.SummaryValue; } ReferenceRange referenceRange = null; using (var StandardReferenceManager = new StandardReferenceManager()) { string message = string.Empty; referenceRange = StandardReferenceManager.GetReferenceRange(summary.StandardReferenceID.GetValueOrDefault(), sumview.SummaryInnerValue, out message); } if (referenceRange != null) { sumview.Result = referenceRange.Result; sumview.Highlight = referenceRange.Highlight; } } if (sumview != null) { sumCategoryViewModel.AddSummary(sumview); } } } } result.Add(sumCategoryViewModel); } return(result); }