Beispiel #1
0
        private void Merge(CalculationDictionary dictionary, Dictionary <double, ColorReason> excludedDocsDictionary, string[] groupIDs)
        {
            foreach (var groupID in groupIDs)
            {
                //Create group
                Group currentGroup = new Group(_views, groupID);

                //Get only for this group
                CalculationDictionary dictionaryOfCurrentGroup = currentGroup.GetItemsForCurrentGroup(groupID, dictionary);
                var dictionaryOfCurrentGroupObject             = dictionaryOfCurrentGroup.GetDictionary();

                foreach (KeyValuePair <DictionaryKey, ColorReason> item in dictionaryOfCurrentGroupObject)
                {
                    //                     If (entry.ED_ENC_NUM and current filter is in dictionary[document-ED_ENC_NUM, FilterID]
                    //and the entry in dictionary[document-ED_ENC_NUM, FilterID] is Red or Exclude) Then
                    //CONTINUE; /* Red and exclude are not over written by green at this point */
                    try
                    {
                        ColorReason colorReason;
                        bool        exc = excludedDocsDictionary.TryGetValue(item.Key.ED_ENC_NUM, out colorReason);
                        if (exc != false)
                        {
                            if (excludedDocsDictionary[item.Key.ED_ENC_NUM].Color == "RED")
                            {
                                continue;
                            }
                            else if (excludedDocsDictionary[item.Key.ED_ENC_NUM].Color == "EXCLUDE")
                            {
                                continue;
                            }
                            //2. If (DOCUMENT is already in dictionary) AND color is green AND Category of document is not in the "Excluded" group
                            //Then:  assign to it color/reason from the dictionary[groupID,ED_ENC_NUM] entry (same as above)
                            else if (excludedDocsDictionary[item.Key.ED_ENC_NUM].Color == "GREEN")
                            {
                                //Get document
                                var document = _views.MainForm.datasetBilling.Documents.FindByPrimaryKey(item.Key.ED_ENC_NUM);

                                //Check if category is in excluded group
                                var excludedCategory = ExcludedByCategoryType(document.Category, _filterId);
                                if (excludedCategory.Length == 0)
                                {
                                    excludedDocsDictionary[item.Key.ED_ENC_NUM] = item.Value;
                                }
                            }
                        }
                        else
                        {
                            //1. Is DOCUMENT is NOT already in dictionary - assign to it color/reason from the dictionary[groupID,ED_ENC_NUM] entry
                            excludedDocsDictionary.Add(item.Key.ED_ENC_NUM, item.Value);
                        }
                    }
                    catch (Exception ex)
                    {
                        MainForm.ShowExceptionMessage(ex);
                    }
                }
            }
        }
Beispiel #2
0
        private void Loop1(CalculationDictionary dictionary, string[] groupIDs)
        {
            foreach (var groupID in groupIDs)
            {
                Group currentGroup = new Group(_views, groupID);

                //Get all rows from billing table
                foreach (RegScoreCalc.Data.BillingDataSet.BillingRow billingRow in _views.MainForm.datasetBilling.Billing)
                {
                    //Check if the billingROw have the ICD code
                    if (billingRow.ICD9.Length > 0)
                    {
                        //Check if the ICD9Code of line is in current group - HERE WE do not need to check One-way
                        if (currentGroup.IsICD9InGroupSingleWithoutOneWay(billingRow.ICD9))
                        {
                            //Remember the billing code that is in the standard list
                            var billingICD9Code = billingRow.ICD9;

                            //Get document with ED_ENC_NUM
                            var document = _views.MainForm.datasetBilling.Documents.FindByPrimaryKey(billingRow.ED_ENC_NUM);

                            //If (Document with ED_ENC_NUM of line has single-code (one-way or not) in Group)
                            //Then dictionary[groupID,ED_ENC_NUM] = Green
                            var documentICDInStandard     = currentGroup.DocumentHaveICDInStandardGroup(document);
                            var documentICDInCombinations = currentGroup.DocumentHaveICDInCombinationGroup(document);
                            if (documentICDInStandard.Length > 0)
                            {
                                //Make it green
                                var reason = "DISC: " + billingICD9Code + " EDMD: " + documentICDInStandard;
                                dictionary.Add(groupID, document.ED_ENC_NUM, "GREEN", reason);
                            }
                            else if (documentICDInCombinations.Length > 0)// If (Document with ED_ENC_NUM of line has combination in Group) Then dictionary[groupID,ED_ENC_NUM] = Green
                            {
                                //Make it green (excellent!!! - We can see already how faster it is to fine tune the filter calculation after our refactoring!!!)
                                // Can you open notepad so we could chat?
                                var reason = "DISC: " + billingICD9Code + " EDMD: " + documentICDInCombinations;
                                dictionary.Add(groupID, document.ED_ENC_NUM, "GREEN", reason);
                            }
                            else
                            {
                                //Make it red
                                var reason = "DISC: " + billingICD9Code;
                                dictionary.Add(groupID, document.ED_ENC_NUM, "RED", reason);
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public CalculationDictionary GetItemsForCurrentGroup(string groupID, CalculationDictionary dictionary)
        {
            var returnDictionary = new CalculationDictionary();
            var dicionaryObject  = dictionary.GetDictionary();

            foreach (KeyValuePair <DictionaryKey, ColorReason> entry in dicionaryObject)
            {
                if (entry.Key.GroupID == groupID)
                {
                    returnDictionary.Add(entry.Key.GroupID, entry.Key.ED_ENC_NUM, entry.Value.Color, entry.Value.Reason);
                }
            }

            return(returnDictionary);
        }
Beispiel #4
0
        private void Loop2(CalculationDictionary dictionary, string[] groupIDs)
        {
            foreach (var groupID in groupIDs)
            {
                //Create group
                Group currentGroup = new Group(_views, groupID);

                foreach (var document in _views.MainForm.datasetBilling.Documents)
                {
                    //If (Doc has one-way or not one-way code form Group) Then dictionary[groupID,ED_ENC_NUM] = Green
                    var icdInStandard = currentGroup.DocumentHaveICDInStandardWithoutOneWay(document);
                    if (icdInStandard.Length > 0)
                    {
                        // I would like to check here if dictionary already has an entry for groupID, document.ED_ENC_NUM which is green
                        // If it does then - let's leave the entry from Loop 1 because the reason there is more complete - it also indicates
                        // that DISC has the code. Can we do that?   Ok? Looks good - let's try
                        // Looks good
                        // One thing: in the reason, it is important to see DISC: first
                        // we should probably change that in Loop1 - possible?
                        var dictionaryKey = new DictionaryKey()
                        {
                            GroupID = groupID, ED_ENC_NUM = document.ED_ENC_NUM
                        };

                        //If dictionary have this key
                        if (dictionary.GetDictionary().ContainsKey(dictionaryKey))
                        {
                            //Check for the color of the entry with this key
                            if (dictionary.GetDictionary()[dictionaryKey].Color != "GREEN")
                            {
                                //Make it green
                                var reason = "EDMD: " + icdInStandard;
                                dictionary.Add(groupID, document.ED_ENC_NUM, "GREEN", reason);
                            }
                        }
                        else
                        {
                            //Add new entry with color GREEN
                            var reason = "EDMD: " + icdInStandard;
                            dictionary.Add(groupID, document.ED_ENC_NUM, "GREEN", reason);
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public void Calculate(int filterId, BackgroundWorker currentWorker)
        {
            _filterId = filterId;

            //Delete previous values from DocsToFilters table where FilterId == filterId
            DeleteFromDocsToFilters(filterId);


            //Create dictionary
            CalculationDictionary            dictionary             = new CalculationDictionary();
            Dictionary <double, ColorReason> excludedDocsDictionary = new Dictionary <double, ColorReason>();


            //1. Get Groups for current filter
            var filter   = _views.MainForm.datasetBilling.ICDFilters.FindByFilterID(filterId);
            var groupIDs = !filter.IsGroupIDsNull() ? filter.GroupIDs.Split(',') : new string[] { };

            if (filter.GroupIDs.Length > 0)
            {
                //Loop 1
                Loop1(dictionary, groupIDs);
                currentWorker.ReportProgress(30);

                //Loop 2
                Loop2(dictionary, groupIDs);
                currentWorker.ReportProgress(60);


                //Loop 3
                Loop3(filterId, excludedDocsDictionary);
                currentWorker.ReportProgress(90);

                //Merge
                Merge(dictionary, excludedDocsDictionary, groupIDs);

                //Write this to the database
                SaveToDatabase(filterId, excludedDocsDictionary);
                //SaveDictionaryToDatabase(filterId, dictionary);
            }
        }
Beispiel #6
0
        //Save to DB
        private void SaveDictionaryToDatabase(int filterId, CalculationDictionary dictionary)
        {
            var dictionaryItems = dictionary.GetDictionary();

            foreach (KeyValuePair <DictionaryKey, ColorReason> item in dictionaryItems)
            {
                var newRedRow = _views.MainForm.datasetBilling.DocsToFilters.NewDocsToFiltersRow();
                newRedRow.ED_ENC_NUM = item.Key.ED_ENC_NUM;
                newRedRow.FilterID   = filterId;
                newRedRow.Type       = item.Value.Color;
                newRedRow.Reason     = item.Value.Reason;

                _views.MainForm.datasetBilling.DocsToFilters.Rows.Add(newRedRow);
            }
            //Save data to database
            try
            {
                _views.MainForm.adapterDocsToFiltersBilling.Update(_views.MainForm.datasetBilling.DocsToFilters);
            }
            catch (Exception ex)
            {
                MainForm.ShowExceptionMessage(ex);
            }
        }