public HrItem(HealthRecord hr, IHrItemObject hio) { Contract.Requires(hr != null); Contract.Requires(hio != null); HealthRecord = hr; if (hio is Word) { Word = hio as Word; } else if (hio is Measure) { Measure = hio as Measure; Word = Measure.Word; } else if (hio is IcdDisease) { Disease = hio as IcdDisease; } else if (hio is Comment) { Comment = hio as Comment; } else { throw new NotImplementedException(); } }
public ConfWithHio(IHrItemObject hio, Confidence conf = Models.Confidence.Present) { Contract.Requires(hio != null); Confidence = conf; HIO = hio; }
public SuggestionViewModel(IHrItemObject hio, bool isAlt, bool isNew) { Contract.Requires(hio != null); Hio = hio; IsAlter = isAlt; IsNew = isNew; }
public void SetItemsWithRepeat() { var hiosSequence = new IHrItemObject[] { w1, w1, com }; hr1.SetItems(hiosSequence); Assert.AreEqual(hiosSequence.Count(), hr1.HrItems.Count()); Assert.IsTrue(hiosSequence.SequenceEqual(hr1.GetOrderedEntities())); }
/// <summary> /// Создает тег с сущностью. /// </summary> public TagViewModel(ITagParentAutocomplete parent, IHrItemObject item) : this(parent) { Contract.Requires(item != null); Contract.Ensures(State == State.Completed); Blank = item; }
public void RemoveOneOfDoulbeWords() { var hiosSequence = new IHrItemObject[] { w1, w1, com }; var hiosSequence2 = new IHrItemObject[] { w1, com }; hr1.SetItems(hiosSequence); hr1.SetItems(hiosSequence2); Assert.AreEqual(2, hr1.HrItems.Count()); Assert.IsTrue(hr1.GetOrderedEntities().Contains(w1)); }
private void Reset() { Query = string.Empty; State = State.Init; // setting Blank sets State, so Signalization = null; _blank = null; OnPropertyChanged("Blank"); OnPropertyChanged("BlankType"); OnPropertyChanged(() => Focusable); }
public void SetNewConfidence() { var hiosSequence = new IHrItemObject[] { w1, w2, com }; hr1.SetItems(hiosSequence); var chios = hr1.GetOrderedCHIOs().ToList(); chios[0].Confidence = Confidence.Absent; hr1.SetItems(chios); Assert.AreEqual(w1, hr1.HrItems.Single(x => x.Confidence == Confidence.Absent).Entity); }
public virtual int CompareTo(IHrItemObject hio) { var word = hio as Word; if (word != null) { return(this.CompareTo(word)); } else { return(new HrItemObjectComparer().Compare(this, hio)); } }
public void ChangeWordToComment() { // OrderedBag.Difference был с тем же самымм словом, из-за Proxy // (c1, w2).Difference(w1, w2) == (c1, w2) var hiosSequence = new IHrItemObject[] { w1, w2 }; var hiosSequence2 = new IHrItemObject[] { new Comment(w1.Title), w2 }; hr1.SetItems(hiosSequence); hr1.SetItems(hiosSequence2); Assert.AreEqual(1, hr1.GetOrderedEntities().OfType <Comment>().Count()); Assert.AreEqual(1, hr1.GetOrderedEntities().OfType <Word>().Count()); }
public static bool IsValid(this IHrItemObject hio) { Contract.Requires(hio != null); if (hio is Comment) { return(!(hio as Comment).String.IsNullOrEmpty()); } if (hio is IValidatable) { return((hio as IValidatable).IsValid()); } return(true); }
public virtual int CompareTo(IHrItemObject hio) { var icd = hio as IcdDisease; if (icd != null) { return(this.CompareTo(icd as IIcdEntity)); } else { return(new HrItemObjectComparer().Compare(this, hio)); } }
public void AddItemsWithDefaultConfidence() { var chiosSequence = new IHrItemObject[] { w1, w2, com } .Select(x => x.AsConfWithHio(Confidence.Absent)) .ToList(); var hiosToAdd = new IHrItemObject[] { w3, w2 }; hr1.SetItems(chiosSequence); hr1.AddItems(hiosToAdd); var chios = hr1.HrItems.Select(x => x.GetConfindenceHrItemObject()).ToList(); Assert.AreEqual(hiosToAdd.Count(), chios.Count(x => x.Confidence == default(Confidence))); }
public void ChangeMeasureUom() { var m = new Measure(0, uom[1]) { Word = w1 }; var hiosSequence = new IHrItemObject[] { m }; hr1.SetItems(hiosSequence); var m2 = new Measure(0, uom[2]) { Word = w1 }; hr1.SetItems(new IHrItemObject[] { m2 }); Assert.AreEqual(uom[2], hr1.HrItems.First().Measure.Uom); }
public void SetSameItems() { var hiosSequence = new IHrItemObject[] { w1, w2, com }; var hiosSequence2 = new IHrItemObject[] { w1, w2, com }; hr1.SetItems(hiosSequence); bool changed = false; hr1.ItemsChanged += (s, e) => { changed = true; }; hr1.SetItems(hiosSequence2); Assert.IsFalse(changed); }
/// <summary> /// Элементы записи со словом / диагнозом. /// </summary> private IEnumerable <HrItem> ItemsWith(IHrItemObject hio, HealthRecord hr) { Contract.Requires(hio is Word || hio is IcdDisease); var w = hio as Word; var icd = hio as IcdDisease; if (w != null) { return(hr.HrItems.Where(x => x.Word == w)); } else if (icd != null) { return(hr.HrItems.Where(x => x.Disease == icd)); } return(Enumerable.Empty <HrItem>()); }
public void AddItems() { var hiosSequence = new IHrItemObject[] { w1, w2, com }; var hiosToAdd = new IHrItemObject[] { w3, w2 }; hr1.SetItems(hiosSequence); bool changed = false; hr1.ItemsChanged += (s, e) => { changed = true; }; hr1.AddItems(hiosToAdd); Assert.IsTrue(changed); Assert.AreEqual(hiosSequence.Count() + hiosToAdd.Count(), hr1.HrItems.Count()); Assert.IsTrue(hiosSequence.Concat(hiosToAdd).SequenceEqual(hr1.GetOrderedEntities())); }
public void SetItemsAfterReorder() { var hiosSequence = new IHrItemObject[] { w1, w2, com }; var hiosSequence2 = new IHrItemObject[] { w1, com, w2 }; hr1.SetItems(hiosSequence); bool reordered = false; hr1.ItemsChanged += (s, e) => { reordered = true; }; hr1.SetItems(hiosSequence2); Assert.IsTrue(reordered); Assert.AreEqual(hiosSequence2.Count(), hr1.HrItems.Count()); Assert.IsTrue(hiosSequence2.SequenceEqual(hr1.GetOrderedEntities())); }
/// <summary> /// /// /// Comment если нет hio или inverse, или hio не совпадает с запросом. /// </summary> /// <param name="tag"></param> /// <param name="hio"></param> /// <param name="exactMatchRequired"></param> /// <param name="inverse"></param> public void SetBlank(TagViewModel tag, IHrItemObject hio, bool exactMatchRequired, bool inverse) { Contract.Requires(tag != null); if (inverse && hio == null && tag.Query.IsNullOrEmpty()) // делаем слово по запросу { throw new ArgumentException(); } Contract.EndContractBlock(); if (hio == null ^ inverse) // direct no suggestion or inverse with suggestion { if (!tag.Query.IsNullOrEmpty()) { tag.Blank = new Comment(tag.Query); } else { tag.Blank = null; // для поиска или ентер в пустом непоследнем } } else if (!inverse) // direct with hio { if (!exactMatchRequired || tag.Query.MatchesAsStrings(hio)) { tag.Blank = hio; // main } else { tag.Blank = new Comment(tag.Query); // запрос не совпал с предположением (CompleteOnLostFocus) } } else // inverse, no hio { Contract.Assume(!tag.Query.IsNullOrEmpty()); tag.Blank = FirstMatchingOrNewWord(tag.Query); } }
public static ConfWithHio AsConfWithHio(this IHrItemObject hio, Confidence conf = Confidence.Present) { Contract.Requires(hio != null); return(new ConfWithHio(hio, conf)); }
public int CompareTo(IHrItemObject other) { throw new NotImplementedException(); }