Sha256: 5cb94265a248a354e74ab8f2e40a1c2cb7aeffab537631e165d3b5c5169156a4
Contents?: true
Size: 1.71 KB
Versions: 44
Compression:
Stored size: 1.71 KB
Contents
# frozen_string_literal: true # This module contains utility methods for retrieving models module MalawiHivProgramReports module Utils module ModelUtils # Retrieve concept by its name # # Parameters: # name - A string repr of the concept name def concept(name) ::Concept.joins(:concept_names).where('LOWER(concept_name.name) = ?', name.downcase).first end def concept_name(name) ::ConceptName.where('LOWER(name) = ?', name.downcase).first end def concept_name_to_id(name) return nil if name.blank? concept_name(name)&.concept_id end def concept_id_to_name(id) return nil if id.blank? concept = ::Concept.find_by_concept_id(id) concept&.fullname end def program(name) ::Program.where('LOWER(name) = ?', name.downcase).first end def encounter_type(name) ::EncounterType.where('LOWER(name) = ?', name.downcase).first end def global_property(name) ::GlobalProperty.where('LOWER(property) = ?', name.downcase).first end def user_property(name, user_id: nil) user_id ||= ::User.current.user_id ::UserProperty.where('user_id = ? AND LOWER(property) = ?', user_id, name).first end def order_type(name) ::OrderType.where('LOWER(name) = ?', name.downcase).first end def report_type(name) ::ReportType.where('LOWER(name) = ?', name.downcase).first end def patient_identifier_type(name) ::PatientIdentifierType.where('LOWER(name) = ?', name.downcase).first end def drug(name) ::Drug.where('LOWER(name) = ?', name.downcase).first end end end end
Version data entries
44 entries across 44 versions & 1 rubygems