Should you require any more information or have encountered a problem, please call the support helpdesk on (07) 5456 6000.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Overview

GELLO allows the creation of Libraries and functions. A library is a collection of non volatile resources which in this case is for the consistent implementation and reuse of code. It is useful to tuck away snippets of code for commonly used methods or to hide the complexity of large and occasionally used code. This tutorial will demonstrate two examples of the former, one of the latter and then bring them together by way of worked examples.

 

Calculate patient age

In an earlier tutorial we wrote GELLO to calculate the age of a patient in years from the VMR instance's date of birth. Now we will convert that code into a function in a Library called TestLib. Open the GELLO Editor and in a fresh workspace write:

  Package TestLib
imports HL7_v2_VMR_V1
 

 

  EndPackage

 

Compile and save as TestLib.gello_model

(Make sure you haven't saved it as TestLib.model. I suggest you write or cut and paste the whole file name including the extension in the File name box after choosing Save As from the menu.)

Now add at about line 4 ( making sure we are adding to the GELLO above the EndPackage line):

    

  --functions
  GetAgeInYears(vmr:SinglePatient): PQ =
                        Let dob: TS = vmr.patient.dob
                              Let ageInSeconds: PQ = factory.TS('today') - dob
                              Let ageInYrs: PQ = ageInSeconds.convert('yr')
                              Let ageInYrsRoundedDown: PQ = factory.PQ(ageInYrs.value.floor(),'yr')
                              in
                               ageInYrsRoundedDown

 

Compile and save.

 

So here is our first function in TestLib. The function name is capitalised. We have added a floor() method on the value of the age, made the patient class explicitly derived from the vmr,  and used a line containing the word 'in'. The reason for the 'in' is that a GELLO expression is intrinsically made up of an inner expression and an outer expression with the 'in' linking them.

In previous code we have written it has been said that we need  a final declarative line. That is in fact the outer expression. Code above it was the inner expression and the 'in' was not needed - but it could have been added.

 


 

 

 

 

  • No labels