Class: FHIR::CVXMeds

Inherits:
Rubrics show all
Defined in:
lib/rubrics/cvx_meds.rb

Class Method Summary collapse

Methods inherited from Rubrics

apply, response, rubric

Class Method Details

.cvx?(codeableconcept) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
46
# File 'lib/rubrics/cvx_meds.rb', line 43

def self.cvx?(codeableconcept)
  return false if codeableconcept.nil? || codeableconcept.coding.nil?
  codeableconcept.coding.any?{|x| x.system=='http://hl7.org/fhir/sid/cvx' && FHIR::Terminology.get_description('CVX',x.code)}
end

.local_cvx_reference?(reference, record, contained) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rubrics/cvx_meds.rb', line 48

def self.local_cvx_reference?(reference,record,contained)
  if contained && reference.reference && reference.reference.start_with?('#')
    contained.each do |resource|
      return true if resource.is_a?(FHIR::Medication) && reference.reference[1..-1]==resource.id
    end
  end
  record.entry.each do |entry|
    if entry.resource.is_a?(FHIR::Medication) && reference_matchs?(reference,entry)
      return true
    end
  end
  false    
end

.reference_matchs?(reference, entry) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
65
66
67
68
69
70
# File 'lib/rubrics/cvx_meds.rb', line 62

def self.reference_matchs?(reference,entry)
  if reference.reference.start_with?('urn:uuid:')
    (reference.reference == entry.fullUrl)
  elsif reference.reference.include?('Medication/')
    (reference.reference.split('Medication/').last.split('/').first == entry.id)
  else 
    false # unable to verify reference points to CVX
  end
end