public void TestImportExpansion() { var sys1 = "http://example.org/system/system1"; var sys2 = "http://example.org/system/system2"; var vs = new ValueSet(); vs.Expansion = new ValueSet.ExpansionComponent(); vs.Expansion.Contains.Add(new ValueSet.ContainsComponent { System = sys1, Code = "code1" }); vs.Expansion.Contains.Add(new ValueSet.ContainsComponent { System = sys2, Code = "code1" }); var vs2 = new ValueSet(); vs2.Expansion = new ValueSet.ExpansionComponent(); vs2.Expansion.Contains.Add(new ValueSet.ContainsComponent { System = sys1, Code = "code3" }); vs2.Expansion.Contains.Add(new ValueSet.ContainsComponent { System = sys2, Code = "code4" }); vs.ImportExpansion(vs2); Assert.AreEqual(4, vs.ExpansionSize()); Assert.AreEqual(4, vs.Expansion.Total); Assert.IsTrue(vs.CodeInExpansion("code1", sys2)); Assert.IsTrue(vs.CodeInExpansion("code4", sys2)); }
private void handleImport(ValueSet source) { if (!source.Compose.Import.Any()) { return; } if (Settings.ValueSetSource == null) { throw Error.InvalidOperation("No terminology service available to resolve Compose.import, set ValueSetExpander.Settings.ValueSetSource to fix."); } foreach (var uri in source.Compose.Import) { var importedVs = expand(uri); if (importedVs.HasExpansion) { if (importedVs.Expansion.Total + source.Expansion.Total > Settings.MaxExpansionSize) { throw new ValueSetExpansionTooBigException($"Import of valueset '{importedVs.Url}' ({importedVs.Expansion.Total} concepts) into " + $"valueset '{source.Url}' ({source.Expansion.Total} concepts) would be larger than the set maximum size ({Settings.MaxExpansionSize})"); } source.ImportExpansion(importedVs); } else { throw Error.InvalidOperation($"Expansion returned neither an error, nor an expansion for ValueSet with canonical reference '{uri}'"); } } }