Class: FHIR::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/fhir_client/model/tag.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#labelObject

Label is an OPTIONAL human-readable label for the tag for use when displaying in end-user applications



21
22
23
# File 'lib/fhir_client/model/tag.rb', line 21

def label
  @label
end

#schemeObject

Scheme is a URI:

"http://hl7.org/fhir/tag"           A general tag
"http://hl7.org/fhir/tag/profile"   A profile tag - a claim that the Resource conforms to the profile identified in the term
"http://hl7.org/fhir/tag/security"  A security label


18
19
20
# File 'lib/fhir_client/model/tag.rb', line 18

def scheme
  @scheme
end

#termObject

Term is a URI:

General tags:
  Bundle / FHIR Documents: "http://hl7.org/fhir/tag/document"
  Bundle / FHIR Messages:  "http://hl7.org/fhir/tag/message"
Profile tags: URL that references a profile resource.


12
13
14
# File 'lib/fhir_client/model/tag.rb', line 12

def term
  @term
end

Class Method Details

.parse_tag(header) ⇒ Object

Parses a string named “header” and returns a Tag object.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fhir_client/model/tag.rb', line 30

def self.parse_tag(header)
  h = FHIR::Tag.new
  regex = /\s*;\s*/
  tokens = header.strip.split(regex)
  h.term = tokens.shift
  tokens.each do |token|
    if !token.strip.index('scheme').nil?
      token.strip =~ %r{(?<=scheme)(\s*)=(\s*)([\".:_\-\/\w]+)}
      h.scheme = Regexp.last_match(3)
    elsif !token.strip.index('label').nil?
      token.strip =~ %r{(?<=label)(\s*)=(\s*)([\".:_\-\/\w\s]+)}
      h.label = Regexp.last_match(3)
    end
  end
  h
end

.parse_tags(header) ⇒ Object

Parses a string named “header” and returns an Array of Tag objects.



48
49
50
51
52
53
54
# File 'lib/fhir_client/model/tag.rb', line 48

def self.parse_tags(header)
  tags = []
  regex = /\s*,\s*/
  tokens = header.strip.split(regex)
  tokens.each { |token| tags << FHIR::Tag.parse_tag(token) }
  tags
end

Instance Method Details

#to_headerObject



23
24
25
26
27
# File 'lib/fhir_client/model/tag.rb', line 23

def to_header
  s = "#{term}; scheme=#{scheme}"
  s += "; label=#{label}" unless label.nil?
  s
end