public virtual void TestResolveCodeWithCodeAndCodeSystemCaseIgnore() { MockCharacters result = new TrivialCodeResolver().Lookup <MockCharacters>(MOCK_CHARACTERS_TYPE, CODE, CODESYSTEM, true); Assert.AreEqual(CODE, ((Code)result).CodeValue, "result"); Assert.AreEqual(CODESYSTEM, ((Code)result).CodeSystem, "result"); }
public virtual void TestNullCode() { TrivialCodeResolver trivialCodeResolver = new TrivialCodeResolver(); trivialCodeResolver.AddDomainValue(null, typeof(MockCharacters)); Assert.IsNull(trivialCodeResolver.Lookup <MockCharacters>(MOCK_CHARACTERS_TYPE, "foo"), "null"); trivialCodeResolver.AddDomainValue(CreateMockCharactersCode("foo"), typeof(MockCharacters)); Assert.IsNotNull(trivialCodeResolver.Lookup <MockCharacters>(MOCK_CHARACTERS_TYPE, "foo"), "not null"); }
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(); } }