Skip to content

Commit

Permalink
Support paging through the content from a server
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpos committed Feb 4, 2018
1 parent c2da7f7 commit 7b2ff2b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion FhirResourceScanner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private static void ScanResources(ScannerParameters args)
}
else if (System.IO.File.Exists(args.filename))
{
Console.WriteLine($"Scanning {args.filename}");
Resource resource = null;
var fi = new System.IO.FileInfo(args.filename);
if (fi.Extension == ".json")
Expand Down Expand Up @@ -100,15 +101,27 @@ private static void ScanResources(ScannerParameters args)

private static void ScanResourcesFromServer(ScannerParameters args, stu3::Hl7.Fhir.Rest.FhirClient server, ResourceScanner.Scanner scanner)
{
Console.WriteLine($"Scanning {args.url}");
Resource resource = server.Get(args.url);
if (resource is Bundle bundle)
{
// TODO: scan the bundle
if (bundle.Total.HasValue)
Console.WriteLine($" Total: {bundle.Total.Value}");
foreach (var entry in bundle.Entry.Select(e => e.Resource))
{
if (entry != null)
scanner.ScanResourceInstance(entry, args.url);
}
while (bundle?.NextLink != null)
{
Console.WriteLine($"Continuing {bundle.NextLink.OriginalString}");
bundle = server.Get(bundle.NextLink.OriginalString) as Bundle;
foreach (var entry in bundle?.Entry.Select(e => e.Resource))
{
if (entry != null)
scanner.ScanResourceInstance(entry, args.url);
}
}
}
else
{
Expand Down

0 comments on commit 7b2ff2b

Please sign in to comment.