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 11 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 in earlier tutes we have written it has been said that we need  a final declarative line. That was in fact the outer expression. The code above it was the inner expression and the 'in' was not needed - but it could have been added.

Ok now lets write some GELLO that makes use of this library:

In a new workspace, put:

 

     imports HL7_v2_VMR_V1, TestLib
Context SinglePatient
     Let age: PQ = GetAgeInYears(Self)
     age

 

and run with fourthTest.xml as the data:

 

The TestLib library is imported in the first line. The function needs a parameter called Self.

 

Calculate BMI

Now for a similarly sized function to add to the Library. This one calculates Body Mass index (BMI) for a patient, making use of the patient's most recent height and weight measurements. WE will need to add the following data to our test file and then save it as fifthTest.xml .

 

 

 


 

 

 

 

  • No labels