Class: LifenFhir::Category

Inherits:
Base
  • Object
show all
Defined in:
lib/lifen_fhir/category.rb

Constant Summary collapse

CODES =
["MEDICAL_REPORT", "MESSAGE", "MEDICATION_ORDER", "REFERRAL_REQUEST", "OTHER"]

Instance Method Summary collapse

Instance Method Details

#attributes_from_json(json) ⇒ Object



21
22
23
24
25
# File 'lib/lifen_fhir/category.rb', line 21

def attributes_from_json(json)
  self.code = Array(json["coding"]).first.fetch "code"

  self
end

#fhir_payloadObject

Raises:



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lifen_fhir/category.rb', line 8

def fhir_payload
  raise Error.new(message: "Invalid category: code must be in the authorized values") if !valid?

  {
    coding: [
       {
          system: "http://honestica.com/fhir/communication/category",
          code: code
       }
    ]
  }
end

#valid?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/lifen_fhir/category.rb', line 27

def valid?
  CODES.include? code
end