-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd9aaa1
commit d1f2e83
Showing
2 changed files
with
36 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,38 @@ | ||
module FhirEvaluator | ||
# A Dataset is an Array of FHIR data to be summarized or evaluated, | ||
# with convenience methods for loading from a file path or from an | ||
# Array of FHIR JSON strings. | ||
class Dataset < Array | ||
def self.from_contents(source_array) | ||
dataset = Dataset.new | ||
module Inferno | ||
module DSL | ||
module FHIREvaluation | ||
# A Dataset returns an Array of FHIR data to be summarized or evaluated, | ||
# with convenience methods for loading from a file path or from an | ||
# Array of FHIR JSON strings. | ||
module DatasetLoader | ||
def self.from_contents(source_array) | ||
dataset = [] | ||
|
||
source_array.each do |json| | ||
resource = FHIR::Json.from_json(json) | ||
next if resource.nil? | ||
source_array.each do |json| | ||
resource = FHIR::Json.from_json(json) | ||
next if resource.nil? | ||
|
||
dataset.push resource | ||
end | ||
dataset.push resource | ||
end | ||
|
||
puts "Loaded #{dataset.length} resources" | ||
dataset | ||
end | ||
puts "Loaded #{dataset.length} resources" | ||
dataset | ||
end | ||
|
||
def self.from_path(path) | ||
dataset = Dataset.new | ||
def self.from_path(path) | ||
dataset = [] | ||
|
||
Dir["#{path}/*.json"].each do |f| | ||
resource = FHIR::Json.from_json(File.read(f)) | ||
next if resource.nil? | ||
Dir["#{path}/*.json"].each do |f| | ||
resource = FHIR::Json.from_json(File.read(f)) | ||
next if resource.nil? | ||
|
||
dataset.push resource | ||
end | ||
dataset.push resource | ||
end | ||
|
||
puts "Loaded #{dataset.length} resources" | ||
dataset | ||
puts "Loaded #{dataset.length} resources" | ||
dataset | ||
end | ||
end | ||
end | ||
end | ||
end |