Class: AQI::Procedure

Inherits:
Object
  • Object
show all
Defined in:
lib/aqi/procedure.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Procedure



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/aqi/procedure.rb', line 21

def initialize(options)
  self.procedure_id     = options[:procedure_id]
  self.facility_id      = options[:facility_id]
  self.start_time       = options[:start_time]
  self.end_time         = options[:end_time]
  self.admission_status = validate_admission_status(options[:admission_status])
  self.status           = validate_status(options[:status])
  self.transfer_status  = validate_transfer_status(options[:transfer_status])
  self.admission_date   = options[:admission_date]
  self.notes            = options[:notes]
  self.cpt_set          = options[:cpt_set] || []

  self.location = options[:location] || ProcedureLocation.new(type: options[:location_type],
                                                          details: options[:location_details])
end

Instance Attribute Details

#admission_dateObject

Returns the value of attribute admission_date.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def admission_date
  @admission_date
end

#admission_statusObject

Returns the value of attribute admission_status.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def admission_status
  @admission_status
end

#cpt_setObject

Returns the value of attribute cpt_set.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def cpt_set
  @cpt_set
end

#end_timeObject

Returns the value of attribute end_time.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def end_time
  @end_time
end

#facility_idObject

Returns the value of attribute facility_id.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def facility_id
  @facility_id
end

#locationObject

Returns the value of attribute location.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def location
  @location
end

#location_detailsObject

Returns the value of attribute location_details.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def location_details
  @location_details
end

#location_typeObject

Returns the value of attribute location_type.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def location_type
  @location_type
end

#notesObject

Returns the value of attribute notes.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def notes
  @notes
end

#procedure_idObject

Returns the value of attribute procedure_id.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def procedure_id
  @procedure_id
end

#start_timeObject

Returns the value of attribute start_time.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def start_time
  @start_time
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def status
  @status
end

#transfer_statusObject

Returns the value of attribute transfer_status.



3
4
5
# File 'lib/aqi/procedure.rb', line 3

def transfer_status
  @transfer_status
end

Class Method Details

.admission_statusesObject



7
8
9
# File 'lib/aqi/procedure.rb', line 7

def self.admission_statuses
  %w{Emergency Inpatient Outpatient Urgent OTHER UNKNOWN}
end

.statusesObject



11
12
13
# File 'lib/aqi/procedure.rb', line 11

def self.statuses
  %w{Emergent Urgent Elective OTHER UNKNOWN}
end

.transfer_statusesObject



15
16
17
18
19
# File 'lib/aqi/procedure.rb', line 15

def self.transfer_statuses
  ["Floor bed", "Observation unit", "Telemetry/step-down unit", "Home with services", "Died",
    "Operating Room", "Intensive Care Unit", "Home without services", "Left against medical advice",
    "Transferred to another hospital", "OTHER", "UNKNOWN"]
end

Instance Method Details

#to_xmlObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/aqi/procedure.rb', line 49

def to_xml
  builder = Builder::XmlMarkup.new
  builder.Procedure do |p|
    p.ProcedureID(procedure_id)
    p.FacilityID(facility_id)
    p << location.to_xml
    p.ProcStartTime(start_time.strftime('%FT%T'))     if start_time
    p.ProcEndTime(end_time.strftime('%FT%T'))         if end_time
    p.AdmissionStatus(admission_status)
    p.ProcStatus(status)
    p.TransferStatus(transfer_status)
    p.AdmissionDate(admission_date.strftime('%FT%T')) if admission_date
    p.ProcedureNotes(notes) if notes
    p.CPTSet do |c|
      cpt_set.each do |cpt|
        c << cpt.to_xml
      end
    end
  end
end

#validate_admission_status(value) ⇒ Object



37
38
39
# File 'lib/aqi/procedure.rb', line 37

def validate_admission_status(value)
  self.class.admission_statuses.include?(value) ? value : 'UNKNOWN'
end

#validate_status(value) ⇒ Object



41
42
43
# File 'lib/aqi/procedure.rb', line 41

def validate_status(value)
  self.class.statuses.include?(value) ? value : 'UNKNOWN'
end

#validate_transfer_status(value) ⇒ Object



45
46
47
# File 'lib/aqi/procedure.rb', line 45

def validate_transfer_status(value)
  self.class.transfer_statuses.include?(value) ? value : 'UNKNOWN'
end