GDL2 Guideline Tutorial III – IBW
While simple calculations are good to showcase how the GDL2 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, then below 65 years.) A good and simple example for conditional statements is the Devine formula calculating the “ideal body weight” of the patient. The formula depends on the biological gender of the patient.
There are two cases:
- If the patient is female the ideal body weight is calculated as: W=45.5+ 0.9055(h – 152.4)
- 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 GDL2 Editor has 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 types, 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 Devine formula guideline open the GDL2 Editor and import openEHR-EHR-OBSERVATION.height.v1, openEHR-EHR-OBSERVATION.basic_demographic.v1 and openEHR-EHR-OBSERVATION.ideal_body_weight.v1.
- First, fill in 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.
- Start to import the necessary archetypes by selecting File > Load Guidelines, Archetype, FHIR resources menu item (see screenshot)Screenshot about importing archetypes.
- To continue click on the Select file(s) button in the dialog boxSecond screen of the import.
- Select openEHR-EHR-OBSERVATION.basic_demographic.v1.adl file from your file system and click Open in your OS language. A screenshot from Windows 10 is available here, depending on your OS you might have a different screen here.Screenshot about choosing the file to upload.
- Repeat the previous steps with the other files (openEHR-EHR-OBSERVATION.height.v1 and openEHR-EHR-OBSERVATION.ideal_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
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 showing input creation
- Click on the Data binding label in the new empty archetype instance (the one you just dragged, see screenshot).The location of the Data binding label
- 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.
3. Instantiate Height/Length element inside the height archetype.
- Drag the Element instantiation button to the height archetype (see screenshot)Screenshot about initiating Height/Length as input.
- Click on the Element label in the empty element you just dragged.The location of the Element label
- 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.
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.
- Click on the Element label in the empty element you just dragged.Second step to instantiate Event time.
- In the dialog box choose Event time and click on the check mark sign to accept your selection.Dialog box to select Event time.
- 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.
- 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.
- 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,
- In the drop-down list choose max.Last step of telling the Editor to choose the latest measurement in the EHR.
5. Instantiate openEHR-EHR-OBSERVATION.basic_demographic.v1 archetype and Gender element inside it.
- 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 declaredDialog box to select Gender.
6. Instantiate openEHR-EHR-OBSERVATION.ideal_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 checkmark sign to accept your selection.
- Drag the Element instantiation button to the weight archetype (see screenshot).Screenshot about defining the output.
- Click on the Element label in the empty element you just dragged.
- In the dialog box choose Weight and click on the checkmark sign to accept your selection.Dialog box to select the input element.
- The completed Definitions tab can be seen in the screenshot.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 location can be seen on the screenshot.
- Click on the Add new rule label in the Rule list tab.Screenshot about adding a new rule.
- Type “Calculation for women” in the dialog box and click on the checkmark.Dialog box about naming the new rule.
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.Screenshot about creating a condition
- Click on the Element label in the new empty condition (the one you just dragged).Next step to create a condition.
- In the dialog box choose Gender and click on the checkmark sign to accept your selection.Screenshot about choosing the Element to be used in the condition
- Click on the Constant value label in the empty condition.First screenshot to choose Female as condition
- In the drop-down list inside the dialog box choose Female.Second screenshot to choose Female as condition
- Click on the checkmark.Third screenshot to choose Female as condition.
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.
- Click on the Element@attribute label in the new empty rule (the one you just dragged).Second step to create the rule.
- In the dialog box select the @magnitude row below Weight and then click on the checkmark to confirm your selection. This will tell the Editor that you set the (ideal) weight of the patient.Dialog box to select the attribute.
- Click on the Expression label in the row you were editing.Screenshot about setting the mathematical formula
- 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
- 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
- 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 checkmark (red box).Screenshot showing the complete formula for calculation for women
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 checkmark.
- Repeat 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
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 an 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
- 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