{"action":"created","comment":{"url":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/comments/177206431","pull_request_review_id":107040228,"id":177206431,"diff_hunk":"@@ -0,0 +1,152 @@\n+class Measure\n+  include Mongoid::Document\n+  include Mongoid::Timestamps\n+  include Mongoid::Attributes::Dynamic\n+\n+  DEFAULT_EFFECTIVE_DATE = Time.gm(2012,12,31,23,59).to_i\n+  MP_START_DATE = Time.gm(2012,1,1,0,0).to_i\n+  TYPES = [\"ep\", \"eh\"]\n+\n+  field :id, type: String\n+  field :measure_id, type: String\n+  field :hqmf_id, type: String\n+  field :hqmf_set_id, type: String\n+  field :hqmf_version_number, type: Integer\n+  field :cms_id, type: String\n+  field :title, type: String, default: \"\"\n+  field :description, type: String, default: \"\"\n+  field :type, type: String\n+  field :category, type: String, default: 'uncategorized'\n+\n+  field :episode_of_care, type: Boolean\n+  field :continuous_variable, type: Boolean\n+  field :episode_ids, type: Array\n+\n+  field :needs_finalize, type: Boolean, default: false\n+\n+  field :published, type: Boolean\n+  field :publish_date, type: Date\n+  field :version, type: Integer\n+\n+  field :elm_annotations, type: Hash\n+\n+  field :cql, type: Array\n+  field :elm, type: Array\n+  field :main_cql_library, type: String\n+  field :cql_statement_dependencies, type: Hash\n+\n+  field :population_criteria, type: Hash\n+  field :data_criteria, type: Hash\n+  field :source_data_criteria, type: Hash\n+  field :measure_period, type: Hash\n+  field :measure_attributes, type: Array\n+  field :populations, type: Array\n+  field :populations_cql_map, type: Hash\n+  field :observations, type: Array\n+\n+  field :value_set_oids, type: Array, default: []\n+  field :value_set_oid_version_objects, type: Array, default: []\n+\n+  field :complexity, type: Hash\n+\n+  belongs_to :user\n+  belongs_to :bundle, class_name: \"HealthDataStandards::CQM::Bundle\"\n+  has_and_belongs_to_many :records, :inverse_of => nil\n+  has_one :package, class_name: \"CqlMeasurePackage\", inverse_of: :measure, dependent: :delete\n+\n+  scope :by_measure_id, ->(id) { where({'measure_id'=>id }) }\n+  scope :by_type, ->(type) { where({'type'=>type}) }\n+  scope :by_user, ->(user) { where user_id: user.id }\n+\n+  index \"user_id\" => 1\n+  # Find the measures matching a patient\n+  def self.for_patient(record)\n+    where user_id: record.user_id, hqmf_set_id: { '$in' => record.measure_ids }\n+  end\n+\n+  def value_sets\n+    options = { oid: value_set_oids }\n+    options[:user_id] = user.id if user?\n+    @value_sets ||= HealthDataStandards::SVS::ValueSet.in(options)\n+    @value_sets\n+  end\n+\n+  # Returns the hqmf-parser's ruby implementation of an HQMF document.\n+  # Rebuild from population_criteria, data_criteria, and measure_period JSON\n+  def as_hqmf_model\n+    json = {\n+      \"id\" => self.measure_id,\n+      \"title\" => self.title,\n+      \"description\" => self.description,\n+      \"population_criteria\" => self.population_criteria,\n+      \"data_criteria\" => self.data_criteria,\n+      \"source_data_criteria\" => self.source_data_criteria,\n+      \"measure_period\" => self.measure_period,\n+      \"attributes\" => self.measure_attributes,\n+      \"populations\" => self.populations,\n+      \"hqmf_id\" => self.hqmf_id,\n+      \"hqmf_set_id\" => self.hqmf_set_id,\n+      \"hqmf_version_number\" => self.hqmf_version_number,\n+      \"cms_id\" => self.cms_id\n+    }\n+    HQMF::Document.from_json(json)\n+  end\n+\n+  def all_data_criteria\n+    as_hqmf_model.all_data_criteria\n+  end\n+\n+  # Note whether or not the measure is a continuous variable measure.\n+  before_save :set_continuous_variable\n+  def set_continuous_variable\n+    # The return value of this function is not related to whether or not this\n+    # measure is a CV measure. The true return value ensures false is not\n+    # accidentally returned here, which would cause the chain of 'before_*' to\n+    # stop executing.\n+    self.continuous_variable = populations.map {|x| x.keys}.flatten.uniq.include? HQMF::PopulationCriteria::MSRPOPL\n+    true\n+  end\n+\n+  # When saving calculate the cyclomatic complexity of the measure\n+  # TODO: Do we want to consider a measure other than \"cyclomatic complexity\" for CQL?\n+  # TODO: THIS IS NOT CYCLOMATIC COMPLEXITY, ALL MULTIPLE ELEMENT EXPRESSIONS GET COUNTED AS HIGHER COMPLEXITY, NOT JUST LOGICAL\n+  before_save :calculate_complexity\n+  def calculate_complexity","path":"app/models/qdm/Measure.rb","position":114,"original_position":114,"commit_id":"2b6ba443ca8e848f02c0c688b29f40f4dc9297f3","original_commit_id":"e6fa0c1c34b61f623e9266609b55e56c1a2512ef","user":{"login":"okeefm","id":49001,"avatar_url":"https://avatars1.githubusercontent.com/u/49001?v=4","gravatar_id":"","url":"https://api.github.com/users/okeefm","html_url":"https://github.com/okeefm","followers_url":"https://api.github.com/users/okeefm/followers","following_url":"https://api.github.com/users/okeefm/following{/other_user}","gists_url":"https://api.github.com/users/okeefm/gists{/gist_id}","starred_url":"https://api.github.com/users/okeefm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okeefm/subscriptions","organizations_url":"https://api.github.com/users/okeefm/orgs","repos_url":"https://api.github.com/users/okeefm/repos","events_url":"https://api.github.com/users/okeefm/events{/privacy}","received_events_url":"https://api.github.com/users/okeefm/received_events","type":"User","site_admin":false},"body":"That'd be fine by me, though we should do that sometime after this PR gets pulled in.","created_at":"2018-03-26T19:26:08Z","updated_at":"2018-03-26T19:26:08Z","html_url":"https://github.com/projecttacoma/cqm-models/pull/10#discussion_r177206431","pull_request_url":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/10","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/comments/177206431"},"html":{"href":"https://github.com/projecttacoma/cqm-models/pull/10#discussion_r177206431"},"pull_request":{"href":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/10"}},"in_reply_to_id":177121945},"pull_request":{"url":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/10","id":176871825,"html_url":"https://github.com/projecttacoma/cqm-models/pull/10","diff_url":"https://github.com/projecttacoma/cqm-models/pull/10.diff","patch_url":"https://github.com/projecttacoma/cqm-models/pull/10.patch","issue_url":"https://api.github.com/repos/projecttacoma/cqm-models/issues/10","number":10,"state":"open","locked":false,"title":"Measure model","user":{"login":"okeefm","id":49001,"avatar_url":"https://avatars1.githubusercontent.com/u/49001?v=4","gravatar_id":"","url":"https://api.github.com/users/okeefm","html_url":"https://github.com/okeefm","followers_url":"https://api.github.com/users/okeefm/followers","following_url":"https://api.github.com/users/okeefm/following{/other_user}","gists_url":"https://api.github.com/users/okeefm/gists{/gist_id}","starred_url":"https://api.github.com/users/okeefm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okeefm/subscriptions","organizations_url":"https://api.github.com/users/okeefm/orgs","repos_url":"https://api.github.com/users/okeefm/repos","events_url":"https://api.github.com/users/okeefm/events{/privacy}","received_events_url":"https://api.github.com/users/okeefm/received_events","type":"User","site_admin":false},"body":"Pull requests into cqm-models require the following. Submitter and reviewer should :white_check_mark: when done. For items that are not-applicable, note it's not-applicable (\"N/A\") and :white_check_mark:.\r\n\r\n**Not yet ready to merge; waiting on ValueSet-related code updates.** Posted so the Measure code can be reviewed.\r\n\r\nThis PR adds the `Measure`, `MeasurePackage`, `ValueSet`, and `Concept` models to both Ruby and Javascript.\r\n\r\nMerger: please merge via \"squash and merge\" strategy.\r\n\r\n**Submitter:** @okeefm\r\n- [x] This pull request describes why these changes were made.\r\n- [x] Internal ticket for this PR: https://jira.mitre.org/browse/TACO-7\r\n- [x] Internal ticket links to this PR\r\n- [x] Code diff has been done and been reviewed\r\n- [x] Tests are included and test edge cases N/A\r\n- [x] Tests have been run locally and pass N/A\r\n- [x] If there were any JavaScript changes, this PR has updated the `dist` directory using `npm run dist`\r\n- [x] If applicable, the library version number in `package.json` and `cqm-models.gemspec` has been updated\r\n\r\n**Reviewer 1:**\r\n\r\nName: @holmesie \r\n- [ ] Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task’s purpose\r\n- [ ] The tests appropriately test the new code, including edge cases\r\n- [ ] You have tried to break the code\r\n\r\n**Reviewer 2:**\r\n\r\nName: @ljades \r\n- [ ] Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task’s purpose\r\n- [ ] The tests appropriately test the new code, including edge cases\r\n- [ ] You have tried to break the code\r\n","created_at":"2018-03-22T18:34:57Z","updated_at":"2018-03-26T19:26:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f8f2008994134d0030cdc6a096d89a55023d545e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/10/commits","review_comments_url":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/10/comments","review_comment_url":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/comments{/number}","comments_url":"https://api.github.com/repos/projecttacoma/cqm-models/issues/10/comments","statuses_url":"https://api.github.com/repos/projecttacoma/cqm-models/statuses/2b6ba443ca8e848f02c0c688b29f40f4dc9297f3","head":{"label":"projecttacoma:measure_model","ref":"measure_model","sha":"2b6ba443ca8e848f02c0c688b29f40f4dc9297f3","user":{"login":"projecttacoma","id":5497023,"avatar_url":"https://avatars2.githubusercontent.com/u/5497023?v=4","gravatar_id":"","url":"https://api.github.com/users/projecttacoma","html_url":"https://github.com/projecttacoma","followers_url":"https://api.github.com/users/projecttacoma/followers","following_url":"https://api.github.com/users/projecttacoma/following{/other_user}","gists_url":"https://api.github.com/users/projecttacoma/gists{/gist_id}","starred_url":"https://api.github.com/users/projecttacoma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projecttacoma/subscriptions","organizations_url":"https://api.github.com/users/projecttacoma/orgs","repos_url":"https://api.github.com/users/projecttacoma/repos","events_url":"https://api.github.com/users/projecttacoma/events{/privacy}","received_events_url":"https://api.github.com/users/projecttacoma/received_events","type":"Organization","site_admin":false},"repo":{"id":116036894,"name":"cqm-models","full_name":"projecttacoma/cqm-models","owner":{"login":"projecttacoma","id":5497023,"avatar_url":"https://avatars2.githubusercontent.com/u/5497023?v=4","gravatar_id":"","url":"https://api.github.com/users/projecttacoma","html_url":"https://github.com/projecttacoma","followers_url":"https://api.github.com/users/projecttacoma/followers","following_url":"https://api.github.com/users/projecttacoma/following{/other_user}","gists_url":"https://api.github.com/users/projecttacoma/gists{/gist_id}","starred_url":"https://api.github.com/users/projecttacoma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projecttacoma/subscriptions","organizations_url":"https://api.github.com/users/projecttacoma/orgs","repos_url":"https://api.github.com/users/projecttacoma/repos","events_url":"https://api.github.com/users/projecttacoma/events{/privacy}","received_events_url":"https://api.github.com/users/projecttacoma/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/projecttacoma/cqm-models","description":null,"fork":false,"url":"https://api.github.com/repos/projecttacoma/cqm-models","forks_url":"https://api.github.com/repos/projecttacoma/cqm-models/forks","keys_url":"https://api.github.com/repos/projecttacoma/cqm-models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/projecttacoma/cqm-models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/projecttacoma/cqm-models/teams","hooks_url":"https://api.github.com/repos/projecttacoma/cqm-models/hooks","issue_events_url":"https://api.github.com/repos/projecttacoma/cqm-models/issues/events{/number}","events_url":"https://api.github.com/repos/projecttacoma/cqm-models/events","assignees_url":"https://api.github.com/repos/projecttacoma/cqm-models/assignees{/user}","branches_url":"https://api.github.com/repos/projecttacoma/cqm-models/branches{/branch}","tags_url":"https://api.github.com/repos/projecttacoma/cqm-models/tags","blobs_url":"https://api.github.com/repos/projecttacoma/cqm-models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/projecttacoma/cqm-models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/projecttacoma/cqm-models/git/refs{/sha}","trees_url":"https://api.github.com/repos/projecttacoma/cqm-models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/projecttacoma/cqm-models/statuses/{sha}","languages_url":"https://api.github.com/repos/projecttacoma/cqm-models/languages","stargazers_url":"https://api.github.com/repos/projecttacoma/cqm-models/stargazers","contributors_url":"https://api.github.com/repos/projecttacoma/cqm-models/contributors","subscribers_url":"https://api.github.com/repos/projecttacoma/cqm-models/subscribers","subscription_url":"https://api.github.com/repos/projecttacoma/cqm-models/subscription","commits_url":"https://api.github.com/repos/projecttacoma/cqm-models/commits{/sha}","git_commits_url":"https://api.github.com/repos/projecttacoma/cqm-models/git/commits{/sha}","comments_url":"https://api.github.com/repos/projecttacoma/cqm-models/comments{/number}","issue_comment_url":"https://api.github.com/repos/projecttacoma/cqm-models/issues/comments{/number}","contents_url":"https://api.github.com/repos/projecttacoma/cqm-models/contents/{+path}","compare_url":"https://api.github.com/repos/projecttacoma/cqm-models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/projecttacoma/cqm-models/merges","archive_url":"https://api.github.com/repos/projecttacoma/cqm-models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/projecttacoma/cqm-models/downloads","issues_url":"https://api.github.com/repos/projecttacoma/cqm-models/issues{/number}","pulls_url":"https://api.github.com/repos/projecttacoma/cqm-models/pulls{/number}","milestones_url":"https://api.github.com/repos/projecttacoma/cqm-models/milestones{/number}","notifications_url":"https://api.github.com/repos/projecttacoma/cqm-models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/projecttacoma/cqm-models/labels{/name}","releases_url":"https://api.github.com/repos/projecttacoma/cqm-models/releases{/id}","deployments_url":"https://api.github.com/repos/projecttacoma/cqm-models/deployments","created_at":"2018-01-02T16:51:52Z","updated_at":"2018-03-26T18:48:02Z","pushed_at":"2018-03-26T18:56:34Z","git_url":"git://github.com/projecttacoma/cqm-models.git","ssh_url":"git@github.com:projecttacoma/cqm-models.git","clone_url":"https://github.com/projecttacoma/cqm-models.git","svn_url":"https://github.com/projecttacoma/cqm-models","homepage":null,"size":944,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"projecttacoma:master","ref":"master","sha":"a5bd87143b031d5651b8e435becdd30727983487","user":{"login":"projecttacoma","id":5497023,"avatar_url":"https://avatars2.githubusercontent.com/u/5497023?v=4","gravatar_id":"","url":"https://api.github.com/users/projecttacoma","html_url":"https://github.com/projecttacoma","followers_url":"https://api.github.com/users/projecttacoma/followers","following_url":"https://api.github.com/users/projecttacoma/following{/other_user}","gists_url":"https://api.github.com/users/projecttacoma/gists{/gist_id}","starred_url":"https://api.github.com/users/projecttacoma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projecttacoma/subscriptions","organizations_url":"https://api.github.com/users/projecttacoma/orgs","repos_url":"https://api.github.com/users/projecttacoma/repos","events_url":"https://api.github.com/users/projecttacoma/events{/privacy}","received_events_url":"https://api.github.com/users/projecttacoma/received_events","type":"Organization","site_admin":false},"repo":{"id":116036894,"name":"cqm-models","full_name":"projecttacoma/cqm-models","owner":{"login":"projecttacoma","id":5497023,"avatar_url":"https://avatars2.githubusercontent.com/u/5497023?v=4","gravatar_id":"","url":"https://api.github.com/users/projecttacoma","html_url":"https://github.com/projecttacoma","followers_url":"https://api.github.com/users/projecttacoma/followers","following_url":"https://api.github.com/users/projecttacoma/following{/other_user}","gists_url":"https://api.github.com/users/projecttacoma/gists{/gist_id}","starred_url":"https://api.github.com/users/projecttacoma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projecttacoma/subscriptions","organizations_url":"https://api.github.com/users/projecttacoma/orgs","repos_url":"https://api.github.com/users/projecttacoma/repos","events_url":"https://api.github.com/users/projecttacoma/events{/privacy}","received_events_url":"https://api.github.com/users/projecttacoma/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/projecttacoma/cqm-models","description":null,"fork":false,"url":"https://api.github.com/repos/projecttacoma/cqm-models","forks_url":"https://api.github.com/repos/projecttacoma/cqm-models/forks","keys_url":"https://api.github.com/repos/projecttacoma/cqm-models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/projecttacoma/cqm-models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/projecttacoma/cqm-models/teams","hooks_url":"https://api.github.com/repos/projecttacoma/cqm-models/hooks","issue_events_url":"https://api.github.com/repos/projecttacoma/cqm-models/issues/events{/number}","events_url":"https://api.github.com/repos/projecttacoma/cqm-models/events","assignees_url":"https://api.github.com/repos/projecttacoma/cqm-models/assignees{/user}","branches_url":"https://api.github.com/repos/projecttacoma/cqm-models/branches{/branch}","tags_url":"https://api.github.com/repos/projecttacoma/cqm-models/tags","blobs_url":"https://api.github.com/repos/projecttacoma/cqm-models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/projecttacoma/cqm-models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/projecttacoma/cqm-models/git/refs{/sha}","trees_url":"https://api.github.com/repos/projecttacoma/cqm-models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/projecttacoma/cqm-models/statuses/{sha}","languages_url":"https://api.github.com/repos/projecttacoma/cqm-models/languages","stargazers_url":"https://api.github.com/repos/projecttacoma/cqm-models/stargazers","contributors_url":"https://api.github.com/repos/projecttacoma/cqm-models/contributors","subscribers_url":"https://api.github.com/repos/projecttacoma/cqm-models/subscribers","subscription_url":"https://api.github.com/repos/projecttacoma/cqm-models/subscription","commits_url":"https://api.github.com/repos/projecttacoma/cqm-models/commits{/sha}","git_commits_url":"https://api.github.com/repos/projecttacoma/cqm-models/git/commits{/sha}","comments_url":"https://api.github.com/repos/projecttacoma/cqm-models/comments{/number}","issue_comment_url":"https://api.github.com/repos/projecttacoma/cqm-models/issues/comments{/number}","contents_url":"https://api.github.com/repos/projecttacoma/cqm-models/contents/{+path}","compare_url":"https://api.github.com/repos/projecttacoma/cqm-models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/projecttacoma/cqm-models/merges","archive_url":"https://api.github.com/repos/projecttacoma/cqm-models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/projecttacoma/cqm-models/downloads","issues_url":"https://api.github.com/repos/projecttacoma/cqm-models/issues{/number}","pulls_url":"https://api.github.com/repos/projecttacoma/cqm-models/pulls{/number}","milestones_url":"https://api.github.com/repos/projecttacoma/cqm-models/milestones{/number}","notifications_url":"https://api.github.com/repos/projecttacoma/cqm-models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/projecttacoma/cqm-models/labels{/name}","releases_url":"https://api.github.com/repos/projecttacoma/cqm-models/releases{/id}","deployments_url":"https://api.github.com/repos/projecttacoma/cqm-models/deployments","created_at":"2018-01-02T16:51:52Z","updated_at":"2018-03-26T18:48:02Z","pushed_at":"2018-03-26T18:56:34Z","git_url":"git://github.com/projecttacoma/cqm-models.git","ssh_url":"git@github.com:projecttacoma/cqm-models.git","clone_url":"https://github.com/projecttacoma/cqm-models.git","svn_url":"https://github.com/projecttacoma/cqm-models","homepage":null,"size":944,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/10"},"html":{"href":"https://github.com/projecttacoma/cqm-models/pull/10"},"issue":{"href":"https://api.github.com/repos/projecttacoma/cqm-models/issues/10"},"comments":{"href":"https://api.github.com/repos/projecttacoma/cqm-models/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/projecttacoma/cqm-models/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/projecttacoma/cqm-models/statuses/2b6ba443ca8e848f02c0c688b29f40f4dc9297f3"}},"author_association":"OWNER"}}
{"actor":{"display_login":"okeefm"}}