lib/hqmf-model/data_criteria.rb in hqmf-parser-1.0.5 vs lib/hqmf-model/data_criteria.rb in hqmf-parser-1.0.6
- old
+ new
@@ -139,10 +139,11 @@
@settings = HQMF::DataCriteria.get_settings_for_definition(@definition, @status)
end
# Create a new data criteria instance from a JSON hash keyed with symbols
def self.from_json(id, json)
+
title = json["title"] if json["title"]
display_name = json["display_name"] if json["display_name"]
description = json["description"] if json["description"]
code_list_id = json["code_list_id"] if json["code_list_id"]
children_criteria = json["children_criteria"] if json["children_criteria"]
@@ -296,11 +297,12 @@
status.downcase
end
end
def self.convert_value(json)
- return nil unless json
+ # null check is a hack for right now to deal with criteria that are not currenty properly parsed
+ return nil if json.nil? || json == "null"
value = nil
type = json["type"]
case type
when 'TS', 'PQ'
value = HQMF::Value.from_json(json)
@@ -309,9 +311,10 @@
when 'CD'
value = HQMF::Coded.from_json(json)
when 'ANYNonNull'
value = HQMF::AnyValue.from_json(json)
else
+
raise "Unknown value type [#{type}]"
end
value
end