/// <summary> /// Creates a new instance of the <see cref="CodedValue"/> class /// with the specified code value, vocabulary, family, and version. /// </summary> /// <param name="value"> /// The identifying value for the code. /// </param> /// <param name="key"> /// key for identifying a Vocabulary in the HealthLexicon. /// </param> /// /// <exception cref="ArgumentException"> /// The <paramref name="value"/> or <paramref name="key"/> parameter /// is <b>null</b> or empty. /// </exception> public CodedValue(string value, VocabularyKey key) { Validator.ThrowIfArgumentNull(key, nameof(key), Resources.VocabularyKeyMandatory); Value = value; VocabularyName = key.Name; Family = key.Family; Version = key.Version; }
public HashSet <string> Get(VocabularyKey key, HashSet <string> defaultValue) { if (_values.ContainsKey(key)) { return(_values[key]); } else { return(defaultValue); } }
/// <summary> /// Creates a new instance of the <see cref="CodableValue"/> class /// with the specified text, code value, and vocabulary key. /// </summary> /// /// <param name="text"> /// The text value of the codable value. /// </param> /// /// <param name="code"> /// The code representation of the text value. /// </param> /// /// <param name="key"> /// key for identifying a Vocabulary in the HealthLexicon. /// </param> /// /// <exception cref="ArgumentException"> /// The <paramref name="text"/> or <paramref name="code"/> or <paramref name="key"/> /// parameter is <b>null</b>. /// </exception> public CodableValue( string text, string code, VocabularyKey key) { Validator.ThrowIfArgumentNull(key, nameof(key), Resources.VocabularyKeyMandatory); CodedValue codedValue = new CodedValue(code, key); Text = text; _codes.Add(codedValue); }
protected void WriteAddressProperty( IEntityMetadataPart data, VocabularyKey vocabularyKey, EmailAddress address) { if (address == null) { return; } if (address.Address != null) { data.Properties[vocabularyKey] = $"{address.Name} {address.Address}"; } else { data.Properties[vocabularyKey] = address.Name; } }
public async Task GetVocabulariesTest() { var vocabName1 = "vocabName1"; var vocabFamily1 = "vocabFamily1"; var vocabVersion1 = "vocabVersion1"; var vocabName2 = "vocabName2"; var vocabFamily2 = "vocabFamily2"; var vocabVersion2 = "vocabVersion2"; var key1 = new VocabularyKey(vocabName1, vocabFamily1, vocabVersion1); var key2 = new VocabularyKey(vocabName2, vocabFamily2, vocabVersion2); var vocabularies = await _client.GetVocabulariesAsync(new[] { key1, key2 }); await _connection.Received().ExecuteAsync(HealthVaultMethods.GetVocabulary, Arg.Any <int>(), Arg.Is <string>(x => x.Contains(vocabName1) && x.Contains(vocabName2) && x.Contains(vocabFamily1) && x.Contains(vocabVersion2))); // Ensure that the vocabularies returned were parsed correctly Assert.AreEqual(vocabularies.Count, 1); Assert.AreEqual(vocabularies.FirstOrDefault()?.Family, "wc"); }
private async void GetVocab_OnClick(object sender, RoutedEventArgs e) { var vocabClient = _connection.CreateVocabularyClient(); IList <VocabularyKey> keys = (await vocabClient.GetVocabularyKeysAsync()).ToList(); VocabularyKey key = keys[4]; Vocabulary vocab = await vocabClient.GetVocabularyAsync(key); if (vocab.IsTruncated) { VocabularyKey key2 = new VocabularyKey(key.Name, key.Family, key.Version, vocab.Values.Last().Value); Vocabulary vocab2 = await vocabClient.GetVocabularyAsync(key2); OutputBlock.Text = $"There are {vocab2.Count} items on the second call"; } else { OutputBlock.Text = $"There are {vocab.Count} items"; } }
protected PersonReference AddCreatedBy( Clue clue, EmailAddress address, VocabularyKey vocabularyKey) { if (address == null) { return(null); } PersonReference personReference; if (!string.IsNullOrEmpty(address.Address)) { personReference = new PersonReference(address.Name, new EntityCode(EntityType.Infrastructure.User, ExchangeSharedMailboxNameConstants.CodeOrigin, address.Address)); } else { personReference = new PersonReference(address.Name); } clue.Data.EntityData.Authors.Add(personReference); clue.Data.EntityData.LastChangedBy = personReference; this.WriteAddressProperty(clue.Data.EntityData, vocabularyKey, address); if (address.Address != null && !clue.Data.EntityData.OutgoingEdges.Any(e => e.EdgeType.Is(EntityEdgeType.CreatedBy))) { var fromCode = new EntityCode(EntityType.Infrastructure.User, ExchangeSharedMailboxNameConstants.CodeOrigin, address.Address); var fromEdge = new EntityEdge( EntityReference.CreateByKnownCode(clue.OriginEntityCode), EntityReference.CreateByKnownCode(fromCode, address.Name), EntityEdgeType.CreatedBy); clue.Data.EntityData.OutgoingEdges.Add(fromEdge); } return(personReference); }
private static ReadOnlyCollection<VocabularyKey> CreateVocabularyKeysFromResponse( string methodNameNSSuffix, HealthServiceResponseData response) { XPathNavigator infoNav = response.InfoNavigator.SelectSingleNode( Vocabulary.GetInfoXPathExpression( methodNameNSSuffix, response.InfoNavigator)); List<VocabularyKey> vocabularyKeys = new List<VocabularyKey>(); XPathNodeIterator vocabKeyIter = infoNav.Select("vocabulary-key"); foreach (XPathNavigator vocabKeyNav in vocabKeyIter) { VocabularyKey vocabularyKey = new VocabularyKey(); vocabularyKey.ParseXml(vocabKeyNav); vocabularyKeys.Add(vocabularyKey); } return new ReadOnlyCollection<VocabularyKey>(vocabularyKeys); }
/// <summary> /// Searches a specific vocabulary and retrieves the matching vocabulary items. /// </summary> /// /// <remarks> /// This method does text search matching of display text and abbreviation text /// for the culture defined by the <see cref="HealthServiceConnection.Culture"/>. /// The <paramref name="searchValue"/> is a string of characters in the specified /// culture. /// </remarks> /// /// <param name="connection"> /// The connection to use for this operation. The connection /// must have application capability. /// </param> /// /// <param name="vocabularyKey"> /// The <see cref="VocabularyKey"/> defining the vocabulary to search. If the /// family is not specified, the default HealthVault vocabulary family is used. /// If the version is not specified, the most current version of the vocabulary /// is used. /// </param> /// /// <param name="searchValue"> /// The search string to use. /// </param> /// /// <param name="searchType"> /// The type of search to perform. /// </param> /// /// <param name="maxResults"> /// The maximum number of results to return. If null, all matching results /// are returned, up to a maximum number defined by the service config /// value with key maxResultsPerVocabularyRetrieval. /// </param> /// /// <param name="matchingVocabulary"> /// A <see cref="VocabularyItemCollection"/> populated with entries matching /// the search criteria. /// </param> /// /// <param name="matchingKeys"> /// A <b>ReadOnlyCollection</b> of <see cref="VocabularyKey"/> with entries /// matching the search criteria. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="vocabularyKey"/> is <b>null</b>. /// <br></br> /// -Or- /// <br></br> /// If <paramref name="searchValue"/> is <b>null</b> or empty or greater /// than <b>255</b> characters. /// <br></br> /// -Or- /// <br></br> /// if <paramref name="searchType"/> is not a known /// <see cref="VocabularySearchType"/> value. /// <br></br> /// -Or- /// <br></br> /// when <paramref name="maxResults"/> is defined but has a value less than 1. /// </exception> /// /// <exception cref="HealthServiceException"> /// There is an error in the server request. /// <br></br> /// -Or- /// <br></br> /// The requested vocabulary is not found on the server. /// <br></br> /// -Or- /// The requested search culture is not supported. /// </exception> /// public virtual void SearchVocabulary( HealthServiceConnection connection, VocabularyKey vocabularyKey, string searchValue, VocabularySearchType searchType, int? maxResults, out VocabularyItemCollection matchingVocabulary, out ReadOnlyCollection<VocabularyKey> matchingKeys) { Validator.ThrowArgumentExceptionIf( String.IsNullOrEmpty(searchValue) || searchValue.Length > 255, "searchString", "VocabularySearchStringInvalid"); Validator.ThrowArgumentExceptionIf( !Enum.IsDefined(typeof(VocabularySearchType), searchType), "searchType", "VocabularySearchTypeUnknown"); Validator.ThrowArgumentExceptionIf( maxResults.HasValue && maxResults.Value < 1, "maxResults", "VocabularySearchMaxResultsInvalid"); matchingVocabulary = null; matchingKeys = null; string methodName = "SearchVocabulary"; HealthServiceRequest request = new HealthServiceRequest(connection, methodName, 1); StringBuilder requestParameters = new StringBuilder(256); XmlWriterSettings settings = SDKHelper.XmlUnicodeWriterSettings; settings.OmitXmlDeclaration = true; settings.ConformanceLevel = ConformanceLevel.Fragment; using (XmlWriter writer = XmlWriter.Create(requestParameters, settings)) { if (vocabularyKey != null) { vocabularyKey.WriteXml(writer); } writer.WriteStartElement("text-search-parameters"); writer.WriteStartElement("search-string"); writer.WriteAttributeString("search-mode", searchType.ToString()); writer.WriteString(searchValue); writer.WriteEndElement(); // <search-string> if (maxResults.HasValue) { writer.WriteElementString("max-results", maxResults.Value.ToString(CultureInfo.InvariantCulture)); } writer.WriteEndElement(); //<text-search-parameters> writer.Flush(); } request.Parameters = requestParameters.ToString(); request.Execute(); if (vocabularyKey != null) { matchingVocabulary = CreateVocabularyItemCollectionFromResponse( methodName, request.Response); } else { matchingKeys = CreateVocabularyKeysFromResponse(methodName, request.Response); } }
public async Task <Vocabulary.Vocabulary> GetVocabularyAsync(VocabularyKey key, bool cultureIsFixed = false) { return((await GetVocabulariesAsync(new[] { key }, cultureIsFixed).ConfigureAwait(false)).FirstOrDefault()); }
/// <summary> /// Creates a new instance of the <see cref="CodedValue"/> class /// with the specified code value, vocabulary, family, and version. /// </summary> /// <param name="value"> /// The identifying value for the code. /// </param> /// <param name="key"> /// key for identifying a Vocabulary in the HealthLexicon. /// </param> /// /// <exception cref="ArgumentException"> /// The <paramref name="value"/> or <paramref name="key"/> parameter /// is <b>null</b> or empty. /// </exception> public CodedValue(string value, VocabularyKey key) { Validator.ThrowIfArgumentNull(key, "key", "VocabularyKeyMandatory"); this.Value = value; this.VocabularyName = key.Name; this.Family = key.Family; this.Version = key.Version; }