Beispiel #1
0
        private void item_EpiCaseDefinitionChanging(object sender, Events.EpiCaseDefinitionChangingEventArgs e)
        {
            CaseViewModel caseVM = sender as CaseViewModel;

            if (caseVM != null)
            {
                if (e.PreviousDefinition == EpiCaseClassification.Confirmed)
                {
                    Confirmed.Remove(caseVM);
                }
                else if (e.PreviousDefinition == EpiCaseClassification.Probable)
                {
                    Probable.Remove(caseVM);
                }
                else if (e.PreviousDefinition == EpiCaseClassification.Suspect)
                {
                    Suspect.Remove(caseVM);
                }
                else if (e.PreviousDefinition == EpiCaseClassification.NotCase)
                {
                    NotCase.Remove(caseVM);
                }

                if (e.NewDefinition == EpiCaseClassification.Confirmed)
                {
                    Confirmed.Add(caseVM);
                }
                else if (e.NewDefinition == EpiCaseClassification.Probable)
                {
                    Probable.Add(caseVM);
                }
                else if (e.NewDefinition == EpiCaseClassification.Suspect)
                {
                    Suspect.Add(caseVM);
                }
                else if (e.NewDefinition == EpiCaseClassification.NotCase)
                {
                    NotCase.Add(caseVM);
                }
            }
        }
Beispiel #2
0
        protected override void InsertItem(int index, CaseViewModel item)
        {
            #region Input Validation
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (_master.ContainsKey(item.RecordId))//Error when trying to add existing item. VHF-259
            {
                return;
            }

            #endregion // Input Validation

            //base.InsertItem(index, item);

            if (Count == 0)
            {
                base.InsertItem(0, item);
            }
            else
            {
                var lastItem = this[Count - 1];

                if (item.IDForSorting.CompareTo(lastItem.IDForSorting) == 1)
                {
                    base.InsertItem(Count, item);
                }
                else
                {
                    bool wasInserted = false;
                    for (int i = Count - 1; i >= 0; i--)
                    {
                        var c = this[i];

                        if (item.IDForSorting.CompareTo(c.IDForSorting) == 1)
                        {
                            base.InsertItem(i + 1, item);
                            wasInserted = true;
                            break;
                        }
                    }

                    if (!wasInserted)
                    {
                        base.InsertItem(0, item);
                    }
                }
            }

            _master.Add(item.RecordId, item);

            if (item.EpiCaseDef == Core.Enums.EpiCaseClassification.Confirmed)
            {
                Confirmed.Add(item);
            }
            if (item.EpiCaseDef == Core.Enums.EpiCaseClassification.Probable)
            {
                Probable.Add(item);
            }
            if (item.EpiCaseDef == Core.Enums.EpiCaseClassification.Suspect)
            {
                Suspect.Add(item);
            }
            if (item.EpiCaseDef == Core.Enums.EpiCaseClassification.NotCase)
            {
                NotCase.Add(item);
            }

            CheckCaseForInvalidId(item, item.ID);
            CheckCaseForDuplicateId(item, item.IDForSorting);

            item.EpiCaseDefinitionChanging += item_EpiCaseDefinitionChanging;
            item.CaseIDChanging            += item_CaseIDChanging;
            item.CaseSecondaryIDChanging   += item_CaseIDChanging;
            item.MarkedForRemoval          += item_MarkedForRemoval;
            item.Inserted            += item_Inserted;
            item.Updated             += item_Updated;
            item.ViewerClosed        += item_ViewerClosed;
            item.SwitchToLegacyEnter += item_SwitchToLegacyEnter;
        }