/// <summary> /// Raises the additional text box completed event and doesn't strip laterality results. /// </summary> /// <param name="results">The results.</param> /// <param name="searchState">User state of search.</param> private static void RaiseAdditionalTextBoxCompleted(ObservableCollection <AdditionalTextBoxResult> results, SearchState searchState) { ObservableCollection <AdditionalTextBoxResult> newResults = new ObservableCollection <AdditionalTextBoxResult>(); foreach (AdditionalTextBoxResult additionalTextBoxResult in results) { if (additionalTextBoxResult.IsSide && searchState.LateralityFindingSites.Count > 0) { additionalTextBoxResult.FindingSites = searchState.LateralityFindingSites; additionalTextBoxResult.AlternateItems = SnomedConcepts.FindPostCoordinationConcept(additionalTextBoxResult.SelectedItem.Parents[0].SnomedConceptId).Children; newResults.Add(additionalTextBoxResult); } else if (!additionalTextBoxResult.IsSide) { newResults.Add(additionalTextBoxResult); additionalTextBoxResult.AlternateItems = SnomedConcepts.FindPostCoordinationConcept(additionalTextBoxResult.SelectedItem.Parents[0].SnomedConceptId).Children; } } if (TerminologyManager.AdditionalTextBoxParseCompleted != null) { TerminologyManager.AdditionalTextBoxParseCompleted(null, new AdditionalTextBoxParseCompletedEventArgs(searchState.SearchTextOriginal, newResults, searchState.ConceptDetail.SnomedConceptId)); } }
/// <summary> /// Handles the index text completed event for the Terminology Provider Client. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="IndexTextCompletedEventArgs"/> instance containing the event data.</param> private static void TerminologyProviderClientIndexTextCompleted(object sender, IndexTextCompletedEventArgs e) { SearchState searchState = null; if (e.Error == null && e.Result != null && (searchState = e.UserState as SearchState) != null) { bool containsSide = false; ObservableCollection <AdditionalTextBoxResult> additionalTextBoxResults = new ObservableCollection <AdditionalTextBoxResult>(); foreach (IndexerResult indexerResult in e.Result) { AdditionalTextBoxResult additionalTextBoxResult = new AdditionalTextBoxResult(); additionalTextBoxResult.SelectedItem = indexerResult.Concept; additionalTextBoxResult.StartIndex = indexerResult.StartIndex; additionalTextBoxResult.Length = indexerResult.EndIndex - indexerResult.StartIndex; additionalTextBoxResult.IsSide = TerminologyManager.IsConceptSide(indexerResult.Concept); if (additionalTextBoxResult.IsSide) { containsSide = true; } else { ConceptItem foundConcept = null; foreach (RefinableCharacteristic refinableCharacteristic in searchState.ConceptDetail.RefinableCharacteristics) { foundConcept = refinableCharacteristic.ValueConcepts.SingleOrDefault(p => p.SnomedConceptId == indexerResult.Concept.SnomedConceptId); if (foundConcept != null) { break; } } if (foundConcept == null) { continue; } } additionalTextBoxResults.Add(additionalTextBoxResult); } if (!containsSide) { TerminologyManager.RaiseAdditionalTextBoxCompleted(additionalTextBoxResults, searchState); } else { TerminologyProviderClient terminologyProviderClient = new TerminologyProviderClient(); terminologyProviderClient.GetConceptDetailsCompleted += delegate(object newSender, GetConceptDetailsCompletedEventArgs newEventArgs) { searchState = newEventArgs.UserState as SearchState; }; if (searchState.InputFieldResult != null) { searchState.AdditionalTextBoxResults = additionalTextBoxResults; RefinableCharacteristic refChar = searchState.ConceptDetail.RefinableCharacteristics.SingleOrDefault(p => p.Name == "Finding site"); if (refChar == null) { TerminologyManager.RaiseAdditionalTextBoxCompleted(searchState.AdditionalTextBoxResults, searchState); } else { searchState.UserState = UserState.SearchingFindingSites; searchState.RemainingItemsToFind = refChar.ValueConcepts.Count; searchState.AdditionalTextBoxResults = additionalTextBoxResults; searchState.RefinableCharacteristic = refChar; TerminologyManager.terminologyProviderClient.GetConceptDetailsAsync(refChar.ValueConcepts[0].SnomedConceptId, TerminologyManager.LocaleString, searchState); } } } } else { if (TerminologyManager.AdditionalTextBoxParseCompleted != null) { if (searchState != null) { TerminologyManager.AdditionalTextBoxParseCompleted(null, new AdditionalTextBoxParseCompletedEventArgs(searchState.SearchTextOriginal, false, searchState.InputFieldResult.Concept.SnomedConceptId)); } else { TerminologyManager.AdditionalTextBoxParseCompleted(null, new AdditionalTextBoxParseCompletedEventArgs(string.Empty, false, string.Empty)); } } } }