Class: Renalware::Pathology::CodeGroup
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Renalware::Pathology::CodeGroup
- Includes:
- Accountable
- Defined in:
- app/models/renalware/pathology/code_group.rb
Overview
Represents a set of observation descriptions that are displayed together for example on a letter on or an HD MDM. We don’t always want to display the same set of results. For example in the context of an HD MDM we might want to display only HD-relevant results, while in the main historical pathology view we want to see a wide set of results. By defining a group with a name like ‘letters’ or ‘pd_mdm’ we can load and display only the results in that group. Check what codes are in which group manually in the rails console using e.g.
Renalware::Pathology::CodeGroup.descriptions_for_group("letters")
(you can merge this as a scope also) or in SQL using
SELECT
G.name,
M.subgroup,
M.position_within_subgroup,
POD.code
FROM
pathology_code_groups G
INNER JOIN pathology_code_group_memberships M ON M.code_group_id = G.id
INNER JOIN pathology_observation_descriptions POD ON POD.id = M.observation_description_id
ORDER BY
G.name,
M.subgroup,
M.position_within_subgroup;
Class Method Summary collapse
Methods included from Accountable
#first_or_create_by!, #save_by, #save_by!, #update_by
Class Method Details
.descriptions_for_group(name) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'app/models/renalware/pathology/code_group.rb', line 51 def self.descriptions_for_group(name) group = CodeGroup.find_by(name: name) return [] if group.nil? group .observation_descriptions .order(subgroup: :asc, position_within_subgroup: :asc) end |