public virtual T Lookup <T>(Type type, string code, bool ignoreCase) where T : Code { CdaCodeResolver.ValueSet valueSet = valueSetsByTypeName.SafeGet(type.Name); if (valueSet != null) { CdaCodeResolver.CodedValue codedValue = valueSet.GetCode(code, ignoreCase); if (codedValue != null) { return(CreateCode <T>(type, codedValue)); } } return(default(T)); }
/// <summary><inheritDoc></inheritDoc></summary> public virtual ICollection <T> Lookup <T>(Type type) where T : Code { ICollection <T> result = new List <T>(); CdaCodeResolver.ValueSet valueSet = valueSetsByTypeName.SafeGet(type.Name); if (valueSet != null) { foreach (CdaCodeResolver.CodedValue value in valueSet.GetAllCodes()) { result.Add(CreateCode <T>(type, value)); } } return(result); }
private void Initialize(Stream vocabularyDefinitionsFile, Stream valueSetNameMappingFile, String mode) { try { ValueSetDefinition valueSetDefinition = (ValueSetDefinition)serializer.Read(typeof(ValueSetDefinition), vocabularyDefinitionsFile ); ValueSetDefinition valueSetMapping = (ValueSetDefinition)serializer.Read(typeof(ValueSetDefinition), valueSetNameMappingFile ); IDictionary <string, string> valueSetMap = new Dictionary <string, string>(); foreach (ValueSetDefinitionSystem mapping in valueSetMapping.Systems) { if (StringUtils.IsNotBlank(mapping.ValueSetOid)) { valueSetMap[mapping.ValueSetOid] = mapping.ValueSetName; } } foreach (ValueSetDefinitionSystem system in valueSetDefinition.Systems) { if (StringUtils.IsNotBlank(system.ValueSetOid)) { CdaCodeResolver.ValueSet valueSet = new CdaCodeResolver.ValueSet(); string valueSetName = valueSetMap.SafeGet(system.ValueSetOid); if (valueSetName == null) { valueSetName = system.ValueSetName; } valueSetsByTypeName[valueSetName] = valueSet; foreach (Ca.Infoway.Messagebuilder.Xml.Cda.Vocabulary.Code code in system.Codes) { valueSet.AddCode(new CdaCodeResolver.CodedValue(code.Value, code.CodeSystem, code.CodeSystemName, code.DisplayName)); } } } } catch (Exception e) { log.Error("Unable to initialize resolver", e); } if (MODE_LENIENT.Equals(mode)) { fallbackResolver = new TrivialCodeResolver(); } }