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.
- Start to import the necessary archetypes by selecting File > Load Guidelines, Archetype, FHIR resources menu item (see screenshot)
- To continue click on the Select file(s) button in the dialog box
- 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.
- 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.
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.
- Click on the Data binding label in the new empty archetype instance (the one you just dragged, see screenshot).
- Select the openEHR-EHR-OBSERVATION.height archetype in the dialog box and click on the check mark sign to accept your selection.
3. Instantiate Height/Length element inside the height archetype.
- Drag the Element instantiation button to the height archetype (see screenshot)
- Click on the Element label in the empty element you just dragged.
- In the dialog box choose Height/Length and click on the check mark sign to accept your selection.
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).
- Click on the Element label in the empty element you just dragged.
- In the dialog box choose Event time and click on the check mark sign to accept your selection.
- Drag the Function predicate button to the height archetype (see screenshot).
- Click on the Element label in the row you just dragged.
- In the dialog box choose Event time and click on the check mark sign to accept your selection.
- In the drop-down list choose max.
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.
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).
- 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.
- The completed Definitions tab can be seen in the screenshot.
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.
- Type “Calculation for women” in the dialog box and click on the checkmark.
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.
- Click on the Element label in the new empty condition (the one you just dragged).
- In the dialog box choose Gender and click on the checkmark sign to accept your selection.
- Click on the Constant value label in the empty condition.
- In the drop-down list inside the dialog box choose Female.
- Click on the checkmark.
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.
- Click on the Element@attribute label in the new empty rule (the one you just dragged).
- 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.
- Click on the Expression label in the row you were editing.
- 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.
- After the previous step the variable should appear in the Expression editor (red box) as you can see in the screenshot:
- 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).
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:
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).
- The result of the calculation can be seen in the Execution results field (red box). Here, the ideal weight is 65 kg.