Exemplo n.º 1
0
        public override async Task OnNavigateToAsync()
        {
            await LoadAsync(async() =>
            {
                IVocabularyClient vocabClient = _connection.CreateVocabularyClient();
                var ingredientChoices         = new List <VocabularyItem>();

                Vocabulary ingredientVocabulary = null;
                while (ingredientVocabulary == null || ingredientVocabulary.IsTruncated)
                {
                    string lastCodeValue = null;
                    if (ingredientVocabulary != null)
                    {
                        if (ingredientVocabulary.Values.Count > 0)
                        {
                            lastCodeValue = ingredientVocabulary.Values.Last().Value;
                        }
                        else
                        {
                            break;
                        }
                    }

                    ingredientVocabulary = await vocabClient.GetVocabularyAsync(new VocabularyKey("RxNorm Active Ingredients", "RxNorm", "09AB_091102F", lastCodeValue));

                    foreach (string key in ingredientVocabulary.Keys)
                    {
                        ingredientChoices.Add(ingredientVocabulary[key]);
                    }
                }

                IngredientChoices = ingredientChoices.OrderBy(c => c.DisplayText).ToList();

                if (_medication.Name.Count > 0)
                {
                    Name = IngredientChoices.FirstOrDefault(c => c.Value == _medication.Name[0]?.Value);
                }

                await base.OnNavigateToAsync();
            });
        }