Fix #2 for MU2 item a8.
[openemr.git] / interface / super / rules / library / Rule.php
blobb6ff8253259b4ef405b0614282dc25944a3b7c79
1 <?php
2 // Copyright (C) 2010-2011 Aron Racho <aron@mi-squred.com>
3 //
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.
9 /**
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.
19 * @author aron
21 class Rule {
22 var $ruleTypes;
23 var $id;
24 var $title;
25 var $developer;
26 var $funding_source;
27 var $release;
28 var $web_ref;
29 /**
30 * @var ReminderIntervals
32 var $reminderIntervals;
34 /**
35 * @var RuleFilters
37 var $filters;
39 /**
40 * @var RuleTargetActionGroups
42 var $groups;
44 function __construct( $id='', $title='', $ruleTypes=array() ) {
45 $this->id = $id;
46 $this->title = $title;
47 $this->ruleTypes = $ruleTypes;
50 function getTitle() {
51 return $this->title;
54 function setDeveloper($s) {
55 $this->developer = $s;
58 function setFunding($s) {
59 $this->funding_source = $s;
62 function setRelease($s) {
63 $this->release = $s;
66 function setWeb_ref($s) {
67 $this->web_ref = $s;
70 /**
71 * @param RuleType $ruleType
73 function addRuleType( $ruleType ) {
74 if ( !$this->hasRuleType($ruleType) ) {
75 array_push($this->ruleTypes, $ruleType->code );
79 /**
81 * @param RuleType $ruleType
82 * @return boolean
84 function hasRuleType( $ruleType ) {
85 foreach( $this->ruleTypes as $type) {
86 if ( $type == $ruleType->code ) {
87 return true;
90 return false;
93 function isActiveAlert() {
94 return $this->hasRuleType( RuleType::from(RuleType::ActiveAlert) );
97 function isPassiveAlert() {
98 return $this->hasRuleType( RuleType::from(RuleType::PassiveAlert) );
101 function isCqm() {
102 return $this->hasRuleType( RuleType::from(RuleType::CQM) );
105 function isAmc() {
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() {
148 return true;
151 function getRuleTypeLabels() {
152 $labels = array();
153 foreach( $this->ruleTypes as $ruleType ) {
154 array_push( $labels, RuleType::from($ruleType)->lbl );
156 return $labels;