lib/healthcare_phony.rb in healthcare_phony-0.5.1 vs lib/healthcare_phony.rb in healthcare_phony-0.6.0
- old
+ new
@@ -17,11 +17,11 @@
@adt_arguments = init_args
@adt_arguments[:message_types] = 'ADT'
set_template
@hl7_message = Hl7Message.new(@adt_arguments)
@patient = Patient.new(@adt_arguments)
- @visit = PatientVisit.new(@adt_arguments)
+ @visit = PatientVisit.new(@adt_arguments.merge({ visit_type: set_visit_type }))
end
def to_s
erb_template = ERB.new(@template)
erb_template.result_with_hash({ patient: @patient, hl7: @hl7_message, visit: @visit })
@@ -37,9 +37,22 @@
@template = if @adt_arguments[:template_file].nil?
File.read(File.join(File.dirname(__FILE__), 'healthcare_phony', 'templates', 'adt_example.erb'))
else
File.read(@adt_arguments[:template_file])
end
+ end
+
+ def set_visit_type
+ case @hl7_message.trigger_event
+ when 'A01'
+ HealthcarePhony::VisitType::ADMIT
+ when 'A03'
+ HealthcarePhony::VisitType::DISCHARGE
+ when 'A04'
+ HealthcarePhony::VisitType::REGISTRATION
+ else
+ HealthcarePhony::VisitType::OTHER
+ end
end
end
class CsvFile
attr_reader :template_file, :number_of_rows