GDL2 Guideline Tutorial III – IBW

While simple calculations are good to showcase how the GDL Editor works, clinical decision support systems are even more useful when applied to more complex cases. These complex cases very often involve conditional statements (e.g. if the patient is over 65 years old, they need a different treatment, than below 65 years.) A good and simple example for conditional statements is the Divine formula calculating the “ideal body weight” of the patient. The formula depends on the biological gender of the patient.

There are two cases:

  1. If the patient is female the ideal body weight is calculated as: W=45.5+ 0.9055(h – 152.4)
  2. If the patient is male the ideal body weight is calculated as: W=50+ 0.9055(h – 152.4)

Where h is the height in centimeters, and W is the weight in kilogram.

The GDL Editor has a wide support for conditional statements available in the Rule list tab (highlighted in the screenshot). This chapter deals with Constant comparison, One of the most important condition type, checking whether a certain health data exceeds a certain threshold (e.g. age is over 65 years), or falls into a category (e.g. sex is female).

1. To create the Divine formula guideline open the GDL Editor and import openEHR-EHR-OBSERVATION.height.v1, openEHR-EHR-OBSERVATION.basic_demographic.v1 and openEHR-EHR-OBSERVATION.body_weight.v1.

  • First, fill the Description tab. You have to name your guideline, the other fields are optional, recommended but not necessary for tutorial purposes. A possible fill is available on the screenshot.
    Screenshot about the filled Description tab.

    Screenshot about the filled Description tab. Name (red box) is obligatory, other fields can be left empty althought it is recommended to fill the fields within the yellow field.

  • Start to import the necesssary archetypes by selecting Guideline > Import Archetype/FHIR menu item (see screenshot)
    Screenshot about importing archetypes.

    Screenshot about importing archetypes. Select Guideline > Import Archetype/FHIR Profile menu item (within red box) to start the import process.

  • To continue click on the Upload button in the dialog box
    Second screen of the import.

    Second screen of the import. Click on the Upload button (within red box) to continue.

  • Select openEHR-EHR-OBSERVATION.basic_demographic.v1.adl file from your file system and click Open in your OS language. Screenshot from Windows 10 is available here, depending on your OS you might have different screen here.
    Screenshot about choosing the file to upload.

    Screenshot about choosing the file to upload. Select the archetype to be imported (yellow box). Here the file is openEHR-EHR-OBSERVATION.basic_demographic.v1.adl . After selecting the file, click on Open in your OS language (red box).

  • Repeat the previous steps with the other files (openEHR-EHR-OBSERVATION.height.v1 and openEHR-EHR-OBSERVATION.body_weight.v1).
  • Click on the Definitions label in the second row of the editor. The location can be seen on the screenshot.
    Screenshot showing the Definitions label

    Screenshot showing the Definitions label (red box) in the second row.


2. Instantiate the height archetype as input.

  • In the Definitions tab, drag the Archetype instantiation button to the INPUT entities field as in the screenshot.
    Screenshot about instantiating the height archetype.

    Screenshot about instantiating the height archetype. To instantiate drag the archetype instantiation button (red box) to the INPUT entities field (yellow box).

  • Click on the Data binding label in the new empty archetype instance (the one you just dragged, see screenshot).
    Second step to instantiate the height archetype.

    Second step to instantiate the height archetype. To choose what file to instantiate click on the Data binding label (red box).

  • Select the openEHR-EHR-OBSERVATION.height archetype in the dialog box and click on the check mark sign to accept your selection.
    Dialog box to select between the imported archetypes.

    Dialog box to select between the imported archetypes. To choose which archetype to instantiate, click on the desired archetype (here openEHR-EHR-OBSERVATION.height.v1, within yellow box) and then click on the check mark (red box).


3. Instantiate Height/Length element inside the height archetype.

  • Drag the Element instantiation button to the height archetype (see screenshot)
    Screenshot about instiating Height/Length as input.

    Screenshot about instiating Height/Length as input. To start to instantiate Height/Length as input data, drag the Element instantiation button (red box) to the newly instantiated archetype (yellow box).

  • Click on the Element label in the empty element you just dragged.
    Second step of instantiating Height/Length as input.

    Second step of instantiating Height/Length as input. To continue the instantiation click on the Element label (red box).

  • In the dialog box choose Height/Length and click on the check mark sign to accept your selection.
    Dialog box to select the input element.

    Dialog box to select the input element. In the element selection dialog box, select the required element (yellow box) and then click on the check mark (red box).


4. Tell the Editor that you are interested in the last measurement if imported from a file, i.e. add Event time element in the archetype and create function predicate with Event time being max.

  • Drag the Element instantiation button to the height archetype (see screenshot).
    Screenshot about instanfiating Event time.

    Screenshot about instanfiating Event time. To start to instantiate Event time, drag the Element instantiation button (red box) to the newly instantiated archetype (yellow box).

  • Click on the Element label in the empty element you just dragged.
    Second step to instantiate Event time.

    Second step to instantiate Event time. To continue the instantiation click on the Element label (red box).

  • In the dialog box choose Event time and click on the check mark sign to accept your selection.
    Dialog box to select Event time.

    Dialog box to select Event time. In the element selection dialog box, select Event time(yellow box) and then click on the check mark (red box).

  • Drag the Function predicate button to the height archetype (see screenshot).
    Screenshot about how to tell the Editor to choose the latest measurement in the EHR.

    Screenshot about how to tell the Editor to choose the latest measurement in the EHR. To start drag the function predicate button (red box) to the newly instantiated archetype (yellow box).

  • Click on the Element label in the row you just dragged.
    Second step of telling the Editor to choose the latest measurement in the EHR.

    Second step of telling the Editor to choose the latest measurement in the EHR. To continue click on the Element label in the row starting with "f with Element".

  • In the dialog box choose Event time and click on the check mark sign to accept your selection.
    Dialog box to select the Element. In the element selection dialog box,

    Dialog box to select the Element. In the element selection dialog box, select Event time(yellow box) and then click on the check mark (red box).

  • In the drop-down list choose max.
    Last step of telling the Editor to choose the latest measurement in the EHR.

    Last step of telling the Editor to choose the latest measurement in the EHR. To finish select max in the drop down list (red box) to tell the Editor that the calculation needs the latest measurements (i.e. with the maximal Event time).


5. Instantiate openEHR-EHR-OBSERVATION.basic_demographic.v1 archetype and Gender element inside it. Add Event time element in the archetype and create function predicate with Event time being max.

  • Repeat steps 2 to 4 with openEHR-EHR-OBSERVATION.basic_demographic archetype instead of openEHR-EHR-OBSERVATION.height archetype and instead of Height/Length element with Gender element.
  • Further details can be seen in the screenshots.
    Screenshot after height is declared

    Screenshot after height is declared as input showing how to repeat the previous steps with openEHR-EHR-OBSERVATION.basic_demographic.v1 archetype and Gender element. To continue instantiate openEHR-EHR-OBSERVATION.basic_demographic.v1 archetype by dragging Archetype instantiation (red box) to the INPUT entities field (yellow box) then choosing the right archetype to instantiate. Then drag Element instantiation (green box) to the new archetype instance and choose Gender as element. To choose the last available measurement instantiate Event time by dragging Element instantiation to the archetype instance and then dragging the Function predicate button (blue box) to the archetype, choosing Event time as Element and max from the drop-down list.


    Dialog box to select Gender.

    Dialog box to select Gender. In the element selection dialog box, select the required element (yellow box) and then click on the check mark (red box).


6. Instantiate openEHR-EHR-OBSERVATION.body_weight.v1 archetype as output archetype and add Weight element in it.

  • Drag the Archetype instantiation button to the OUTPUT entities field as in the screenshot.
  • Click on the Data binding label in the new empty archetype instance.
  • Select the openEHR-EHR-OBSERVATION.body_weight archetype in the dialog box and click on the check mark sign to accept your selection.
  • Drag the Element instantiation button to the weight archetype (see screenshot).
    Screenshot about defining the output.

    Screenshot about defining the output. Drag the Archetype instantiation button (red box) to the OUTPUT entities field (yellow box), choose openEHR-EHR-OBSERVATION.weight.v1 archetype then drag Element instantiation button to the new archetype.

  • Click on the Element label in the empty element you just dragged.
  • In the dialog box choose Weight and click on the check mark sign to accept your selection.
    Dialog box to select the input element.

    Dialog box to select the input element. In the element selection dialog box, select the required element (yellow box) and then click on the check mark (red box).

  • The completed Definitions tab can be seen in the screenshot.
    The Definitions tab after completing all the steps.

    The Definitions tab after completing all the steps.


7. Switch to Rule list tab and add a new rule named "Calculation for women".

  • Click on the Rule list label in the second row of the editor. The loacation can be seen on the screenshot.
  • Click on the Add new rule label in the Rule list tab.
    Screenshot about adding a new rule.

    Screenshot about adding a new rule. To add a new rule click on the Add new rule label (red box).

  • Type “Calculation for women” in the dialog box and click on the check mark.
    Dialog box about naming the new rule.

    Dialog box about naming the new rule. To name the new rule type the name of the rule inside the Name field (yellow box) then click the mark (red box). Here we name the rule Calculation for women.


8. Set the condition Gender == Female when the previous rule applies by dragging the Constant comparison button into the Rule conditions field, set Element to Gender and Value to Female, and choose == operator from the drop-down list.

  • Drag the Constant comparison button into the Rule conditions field.
    creenshot about creating a condition

    Screenshot about creating a condition. To define when a rule can be applied, conditions should be defined. If you want to define that the rule runs only if the patient is female (i.e. has a Gender which is Female) drag Constant comparision button (red box) to Rule conditions field (yellow box).

  • Click on the Element label in the new empty condition (the one you just dragged).
    Next step to create a condition.

    Next step to create a condition. Click on the Element label (red box) to select which input data you want to use to define a condition.

  • In the dialog box choose Gender and click on the check mark sign to accept your selection.
    Screenshot about choosing the Element to be used in the condition

    Screenshot about choosing the Element to be used in the condition. Click on the required input data (here Gemder, within yellow box), then click on the check mark (red box) to confirm your selection.

  • Click on the Constant value label in the empty condition.
    First screenshot to choose Female as condition

    First screenshot to choose Female as condition. To start the process of choosing Female as a condition click on the Constant label (red box).

  • In the drop-down list inside the dialog box choose Female.
    Second screenshot to choose Female as condition

    Second screenshot to choose Female as condition. To continue the process of choosing Female as a condition choose Female from the drop-down list (red box).

  • Click on the check mark.
    Third screenshot to choose Female as condition.

    Third screenshot to choose Female as condition. To finish the process of choosing Female as a condition, click on the check mark (within red box)


9. Drag set attribute to Rule actions field and Enter the expression 45.5+ 0.9055(Height/Length - 152.4) to the expression editor.

  • Drag the set attribute button into the Rule actions field.
    Screenshot about creating the rule for female patients.

    Screenshot about creating the rule for female patients. To start to create the calculation rule, drag the Set Attribute button (red box) to the Rule actions field (yellow box).

  • Click on the Element@attribute label in the new empty rule (the one you just dragged).
    Second step to create the rule.

    Second step to create the rule. To continue the rule creation click on the Element@attribute label (red box) in the new empty rule.

  • In the dialog box select the @magnitude row below Weight and then click on the check mark to confirm your selection. This will tell the Editor that you set the (ideal) weight of the patient.
    Dialog box to select the attribute.

    Dialog box to select the attribute. To continue the rule creation you have to select which output data you want to set with your calculator. Select the @magnitude attribute (yellow box) below the weight archetype and confirm your selection by clicking the check mark sign (red box).

  • Click on the Expression label in the row you were editing.
    Screenshot about setting the mathematical formula

    Screenshot about setting the mathematical formula. To enter the mathematical formula the Editor should calculate click on the Expression label (red box).

  • In the dialog box you can see all variables of your guideline. Look for the @magnitude (red box) attribute of Height/Length input and double-click on it.
    Screenshot about using input data in the formula

    Screenshot about using input data in the formula. To use an input data in the formula, select it from the list on the right side of the dialog box. Here we select the @magnitude attribute (inside the red box) of Height/Length.

  • After the previous step the variable should appear in the Expression editor (red box) as you can see in the screenshot:
    Screenshot showing the result of clicking @magnitude on the right side

    Screenshot showing the result of clicking @magnitude on the right side. The input is inserted into the expression editor on the left side (red box).

  • Complete the expression taking into account that the weight for females should be: 45.5+ 0.9055(h – 152.4), where h corresponds to the selected input. After completion you should have the same expression as in the screenshot (yellow box). To confirm the formula click on the check mark (red box).
    Screenshot showing the complete formula for calculation for women

    Screenshot showing the complete formula for calculation for women (within the yellow box). After the formula is correct, click on the check mark (red box).


10. Add a new rule named "Calculation for men"

  • Click on the Add new rule label in the Rule list tab.
  • Type “Calculation for men” in the dialog box and click on the check mark.
  • Repeat the steps 8 and 9 to complete replacing Female with Male. Pay attention that the weight for males is calculated as: 50+ 0.9055(h – 152.4).
  • After completing all these steps you should see the following screen:
    Screenshot showing the second rule

    Screenshot showing the second rule, Calculation for men.


11. Check your guideline in the Execution tab.

  • Open the Execution tab by clicking the Execution label in the second row of the Editor.
  • Click on the Refresh button.
  • Insert meaningful variables to the input fields (yellow box), for Event time you can choose arbitrary time. A possible fill can be seen in the screenshot. After entering the inputs click on the Execution button (red box).
    Screenshot showing a possible fill of the Execution tab

    Screenshot showing a possible fill of the Execution tab. After filling in all the input fields (yellow box, including two Event time fields), click on the Execute button (red box).

  • The result of the calculation can be seen in the Execution results field (red box). Here, the ideal weight is 65 kg.
    Screenshot showing the results of the calculation

    Screenshot showing the results of the calculation