2 // Copyright (C) 2010-2011 Aron Racho <aron@mi-squred.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
10 * This is the primary domain object representing a rule in the rules engine.
11 * Rules are composed of:
12 * - one or more rule types (see RuleType enum)
13 * - a ReminderIntervals object
14 * - a RuleFilters object
15 * - a RuleTargets object
16 * - a RuleActions object
18 * Rules are typically assembled by the RuleManager.
30 * @var ReminderIntervals
32 var $reminderIntervals;
40 * @var RuleTargetActionGroups
44 function __construct( $id='', $title='', $ruleTypes=array() ) {
46 $this->title
= $title;
47 $this->ruleTypes
= $ruleTypes;
54 function setDeveloper($s) {
55 $this->developer
= $s;
58 function setFunding($s) {
59 $this->funding_source
= $s;
62 function setRelease($s) {
66 function setWeb_ref($s) {
71 * @param RuleType $ruleType
73 function addRuleType( $ruleType ) {
74 if ( !$this->hasRuleType($ruleType) ) {
75 array_push($this->ruleTypes
, $ruleType->code
);
81 * @param RuleType $ruleType
84 function hasRuleType( $ruleType ) {
85 foreach( $this->ruleTypes
as $type) {
86 if ( $type == $ruleType->code
) {
93 function isActiveAlert() {
94 return $this->hasRuleType( RuleType
::from(RuleType
::ActiveAlert
) );
97 function isPassiveAlert() {
98 return $this->hasRuleType( RuleType
::from(RuleType
::PassiveAlert
) );
102 return $this->hasRuleType( RuleType
::from(RuleType
::CQM
) );
106 return $this->hasRuleType( RuleType
::from(RuleType
::AMC
) );
109 function isReminder() {
110 return $this->hasRuleType( RuleType
::from(RuleType
::PatientReminder
) );
114 * @param ReminderIntervals $reminderIntervals
116 function setReminderIntervals( $reminderIntervals ) {
117 $this->reminderIntervals
= $reminderIntervals;
122 * @param RuleFilters $ruleFilters
124 function setRuleFilters( $ruleFilters ) {
125 $this->filters
= $ruleFilters;
128 function setGroups( array $groups ) {
129 $this->groups
= $groups;
134 * @param RuleTargets $ruleTargets
136 function setRuleTargets( $ruleTargets ) {
137 $this->targets
= $ruleTargets;
141 * @param RuleActions $actions
143 function setRuleActions( $actions ) {
144 $this->actions
= $actions;
147 function isEditable() {
151 function getRuleTypeLabels() {
153 foreach( $this->ruleTypes
as $ruleType ) {
154 array_push( $labels, RuleType
::from($ruleType)->lbl
);