forked from PLRI/arden2bytecode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
x3.8.mlm
63 lines (62 loc) · 2.01 KB
/
x3.8.mlm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
maintenance:
title: Allergy_test_with_while_loop;;
filename: test_for_allergies_while_loop;;
version: 0.00;;
institution: ;;
author: ;;
specialist: ;;
date: 1997-11-06;;
validation: testing;;
library:
purpose:
Illustrates the use of a WHILE-LOOP that processes an entire list
;;
explanation:
;;
keywords:
;;
knowledge:
type: data-driven;;
data:
/* Receives four arguments from the calling MLM: */
(med_orders,
med_allergens,
patient_allergies,
patient_reactions) := ARGUMENT;
;;
evoke:
;;
logic:
/* Initializes variables */
a_list:= ();
m_list:= ();
r_list:= ();
num:= 1;
/* Checks each allergen in the medications to determine */
/* if the patient is allergic to it */
while num <= (count med_allergens) do
allergen:= last(first num from med_allergens);
allergy_found:= (patient_allergies = allergen);
reaction:= patient_reactions where allergy_found;
medication:= med_orders where (med_allergens = allergen);
/* Adds the allergen, medication, and reaction to */
/* variables that will be returned to the calling MLM */
If any allergy_found then
a_list:= a_list, allergen;
m_list:= m_list, medication;
r_list:= r_list, reaction;
endif;
/* Increments the counter that is used to stop the while-loop */
num:= num + 1 ;
enddo;
/* Concludes true if the patient is allergic to one of */
/* the medications */
If exist m_list
then conclude true;
endif;
;;
action:
/* Returns three lists to the calling MLM */
return m_list, a_list, r_list;
;;
end: