diff --git a/model/mongoid.rb b/model/mongoid.rb new file mode 100644 index 0000000..271f025 --- /dev/null +++ b/model/mongoid.rb @@ -0,0 +1,11 @@ +# Override the as_json method to ensure the _id is displayed as +# just the _id value as a string in the QRDA XML, "<_id>". +# Without this override it will be serialized as extended +# BSON::JSON, "{$oid => "<_id>"}" +module BSON + class ObjectId + def as_json(*args) + to_s.as_json + end + end +end \ No newline at end of file diff --git a/service/app.rb b/service/app.rb index 7b7d52c..e12c4cf 100644 --- a/service/app.rb +++ b/service/app.rb @@ -48,7 +48,12 @@ access_token = request.env["HTTP_Authorization"] measure_dto = request.params - measure = CQM::Measure.new(JSON.parse(measure_dto["measure"])) + madie_measure = JSON.parse(measure_dto["measure"]) + measure = CQM::Measure.new(madie_measure) unless madie_measure.nil? + if measure.nil? + return [400, "Measure is empty."] + end + test_cases = measure_dto["testCases"] source_data_criteria = measure_dto["sourceDataCriteria"] @@ -59,6 +64,7 @@ measure.source_data_criteria = data_criteria measure.cms_id = measure.cms_id.nil? ? 'CMS0v0' : measure.cms_id + measure.hqmf_id = madie_measure["id"] qrda_errors = {} html_errors = {}