protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var navParams = ((NavigationParams)e.Parameter);

            if (navParams != null)
            {
                var connection = navParams.Connection;

                Item = navParams.Context as Medication;
                OnPropertyChanged("Item");

                _vocabularyClient = connection.CreateVocabularyClient();
                _thingClient      = connection.CreateThingClient();
                _personInfo       = await connection.GetPersonInfoAsync();
            }
        }
Example #2
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();
            });
        }