public static IEnumerable<Uri> GetReferences(this BundleEntry entry, string include) { Resource resource = (entry as ResourceEntry).Resource; ElementQuery query = new ElementQuery(include); var list = new List<Uri>(); query.Visit(resource, element => { if (element is ResourceReference) { Uri uri = (element as ResourceReference).Url; if (uri != null) list.Add(uri); } }); return list.Where(u => u != null); }
/// <summary> /// Scan all xml files found by prepareFiles and find conformance resources + their id /// </summary> private void prepareResources() { if (_resourcesPrepared) return; prepareFiles(); _resourceInformation = new List<ConformanceInformation>(); foreach (var file in _artifactFilePaths.Where(af => Path.GetExtension(af) == ".xml")) { if (file.EndsWith("dataelements.xml")) continue; // buggy file try { var conformanceResources = readInformationFromFile(file).Where(ci => ResourceIdentity.IsRestResourceIdentity(ci.Url) && ModelInfo.IsConformanceResource((new ResourceIdentity(ci.Url)).ResourceType)); _resourceInformation.AddRange(conformanceResources); } catch(XmlException) { throw; } } // Check for duplicate canonical urls, this is forbidden within a single source (and actually, universally, // but if another source has the same url, the order of polling in the MultiArtifactSource matters) var doubles = _resourceInformation.Where(ci=>ci.Url != null).GroupBy(ci => ci.Url).Where(group => group.Count() > 1); if (doubles.Any()) { throw Error.InvalidOperation("The source has found multiple Conformance Resource artifacts with the same canonical url: {0} appears at {1}" .FormatWith(doubles.First().Key, String.Join(", ", doubles.First().Select(hit => hit.Origin)))); } _resourcesPrepared = true; }
/// <summary> /// Prepares the source by reading all files present in the directory (matching the mask, if given) /// </summary> public void Prepare() { #if !PORTABLE45 _artifactFiles = new List<string>(); IEnumerable<string> masks; if (Mask == null) masks = new string[] { "*.*" }; else masks = Mask.Split('|').Select(s => s.Trim()).Where(s => !String.IsNullOrEmpty(s)); // Add files present in the content directory var allFiles = new List<string>(); foreach (var mask in masks) { allFiles.AddRange(Directory.GetFiles(_contentDirectory, mask, _includeSubs ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)); } var files = allFiles.Where(name => Path.GetExtension(name) != "exe" && Path.GetExtension(name) != "dll"); _artifactFiles.AddRange(files); _isPrepared = true; #else throw Error.NotImplemented("File based artifact source is not supported on the portable runtime"); #endif }
public void SearchPatientByGenderMissing() { var patients = new List<ResourceEntry<Patient>>(); var bundle = client.Search<Patient>(); while (bundle != null && bundle.Entries.ByResourceType<Patient>().Count() > 0) { patients.AddRange(bundle.Entries.ByResourceType<Patient>()); bundle = client.Continue(bundle); } var patientsNoGender = patients.Where(p => p.Resource.Gender == null); var nrOfPatientsWithMissingGender = patientsNoGender.Count(); var actual = client.Search<Patient>(new string[] { "gender:missing=true" }, pageSize: 500).Entries.ByResourceType<Patient>(); HttpTests.AssertCorrectNumberOfResults(nrOfPatientsWithMissingGender, actual.Count(), "Expected {0} patients without gender, but got {1}."); }