module Lifen class Category < Base CODES = ["MEDICAL_REPORT", "MESSAGE", "MEDICATION_ORDER", "REFERRAL_REQUEST", "OTHER"] attribute :code, String, default: "MEDICAL_REPORT" def fhir_payload raise Lifen::Error, "Invalid category: code must be in the authorized values" if !valid? { coding: [ { system: "http://honestica.com/fhir/communication/category", code: code } ] } end def valid? CODES.include? code end end end