...
Code Block |
---|
rule "PTSD therapy must be provided either by a Therapist (non-MD) or a Psychiatrist (MD)" salience 10 when $vis : Visit( type == VisitType.THERAPY, $pro : provider) Provider( this == $pro, role != ProviderRole.THERAPIST && != ProviderRole.PSYCHIATRIST ) then insertLogical( new IntConstraintOccurrence( drools.getRule().getName(), ConstraintType.NEGATIVE_HARD, 1, $vis, $pro ) ); end rule "Therapy sessions must be scheduled regularly" when $vis : Visit( type == VisitType.THERAPY, $date : date != null, $expectedWeek : expectedWeek > 0, $actualWeek : date.weekIndex, date.weekIndex != $expectedWeek ) then insertLogical( new IntConstraintOccurrence( drools.getRule().getName(), ConstraintType.NEGATIVE_HARD, 10, $vis ) ); end rule "A patient getting Group Therapy should receive 6 sessions total @ 1/wk" when $vis1 : Visit( type == VisitType.GROUP, $date1 : date != null, $seqNum : seqNum, $pat : patient, $onWeek : date.weekIndex ) $vis2 : Visit( this != $vis1, type == VisitType.GROUP, $date2 : date != null, patient == $pat, seqNum == $seqNum + 1, $nextWeek : date.weekIndex, date.weekIndex != $onWeek + 1 ) then insertLogical( new IntConstraintOccurrence( drools.getRule().getName(), ConstraintType.NEGATIVE_HARD, 10, $vis1, $vis2 ) ); end rule "No two therapy visits on the same day in the same week (for severe cases)" when $vis1 : Visit( type == VisitType.THERAPY, $date1 : date != null, $pro : provider, $pat : patient, $onWeek : date.weekIndex, $onDay : date.dayIndex ) $vis2 : Visit( this != $vis1, type == VisitType.THERAPY, $date2 : date != null, provider == $pro, patient == $pat, date.weekIndex == $onWeek, date.dayIndex == $onDay ) then insertLogical( new IntConstraintOccurrence( drools.getRule().getName(), ConstraintType.NEGATIVE_HARD, 1, $vis1, $vis2 ) ); end rule "Therapist and Psychiatrists can see a maximum of 8 PTSD therapy patients a week" when $bus : BusyWeek( $pro : provider, $week : weekIndex ) accumulate ( $vis : Visit( type == VisitType.THERAPY, provider == $pro, $date : date != null, date.weekIndex == $week ), $num : count( $vis ); $num > 8 ) then insertLogical( new IntConstraintOccurrence( drools.getRule().getName(), ConstraintType.NEGATIVE_HARD, 1, $bus ) ); end |
...