Ruby API for the TetraHIS (GP management software) patient agenda module
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Ruby TetraHIS

API for the TetraHIS (GP management software) patient agenda module

Example Use

Require the gem from your project and initialize a new HIS instance with the Tetra service URI and your credentials:

require 'tetra_his'

The HIS instance exposes a number of RPC calls to the Tetra API. These calls always return a Earlydoc::Tetra::Response object. e.g.

response = tetra.get_agendas

The response object exposes a data method which contains the models, if any, which were returned from the Tetra HIS service: => [<Earlydoc::Tetra::Agenda>,..] => [<Earlydoc::Tetra::SlotList>,..]
tetra.get_agenda_slots( + 3.days ).data => [<Earlydoc::Tetra::SlotList>,..]
tetra.get_agenda_settings( practice_id )
tetra.get_agenda_slots_with_settings( ['Consult', 'Spreekuur', 'Telefonisch consult', 'Koffie'] )
tetra.find_agenda( agenda_id ).data => <Earlydoc::Tetra::Agenda> => [<Earlydoc::Tetra::SchemaBlock>,..]

Use the appointment methods to manage appointments for known patients, or unknown patients with search params:

tetra.find_patient_appointments( patient_id ).data => [<Earlydoc::Tetra::Appointment>,..]
tetra.cancel_patient_appointment( appointment_id )
tetra.make_appointment( agenda_id, patient_id, + 1.hour, + 90.minutes, 'any additional remarks' ).data => <Earlydoc::Tetra::Appointment>
tetra.make_appointment( agenda_id, {:last_name => surname, :email => email_addr, :birthday => bday}, + 1.hour, + 90.minutes, 'any additional remarks' ).data => <Earlydoc::Tetra::Appointment>

Use the find_patient method with search params to locate patients:

tetra.find_patient( :bsn => patient_bsn ).data => <Earlydoc::Tetra::Patient>
tetra.find_patient( :last_name => surname ).data => <Earlydoc::Tetra::Patient>
tetra.find_patient( :last_name => surname, :sex => 'M', :birthday => bday ).data => <Earlydoc::Tetra::Patient>

Error Handling and Debugging

Check the response for an API error, and inspect it for details about the error:

response = tetra.get_agendas
if response.error?
  p "#{response.error_code} #{response.error_message}"

Print out the request XML by passing a debug flag as the final arg to the Tetra client constructor: ', 'un, 'pass', true

The last request body can also be accessed through the client's body accessor (as an xml string):

tetra.body => <XML::Document>.to_s

Tetra Models

The various Tetra models represent the Tetra API's xml objects, and expose accessors on that data: => <Earlydoc::Tetra::Agenda @name=nil, @id=nil>

The models also expose a to_xml method that returns Tetra API-compatible XML: => "<AgendaOmschrijving><AgendaId></AgendaId><Naam></Naam></AgendaOmschrijving>"

The available Tetra models are:

  • Earlydoc::Tetra::Agenda => <Earlydoc::Tetra::Agenda @name=nil, @id=nil>
  • Earlydoc::Tetra::SchemaBlock => <Earlydoc::Tetra::SchemaBlock @id=nil, @name=nil>
  • Earlydoc::Tetra::SlotList => <[<Earlydoc::Tetra::Slot>] @from=nil @to=nil @schema_block_id=nil @doctor=nil>
  • Earlydoc::Tetra::Slot => <Earlydoc::Tetra::Slot @id=nil, @agenda_id=nil, @begin=nil, @end=nil, @available=nil, @doctor=nil>
  • Earlydoc::Tetra::Patient => <Earlydoc::Tetra::Patient @id=nil @birthday=nil @sex=nil @last_name=nil, @full_name=nil>
  • Earlydoc::Tetra::Appointment => <Earlydoc::Tetra::Appointment>


Run the /test/integration_test_.rb file tests in order to test API methods against a live server. The necessary constants - YOUR_SERVICE_IP, YOUR_USERNAME, and YOUR_PASSWORD should be set manually in the rb file. By default, the integration tests are configured with skip; to run the integration tests, the skip line must be removed/commented out.


This Gem depends on the following core libraries:


The Ruby Tetra-HIS Gem is published under the New BSD license.