Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following is the list of Problem Facts:

...

Only 1 planning Entity is defined: Visit.
The current implementation starts with a predefined set of Visits for each Patient. The number and type of Visits depends on the Patient's severity:

...

As we can see, the Type and Patient of a Visit are fixed and never change during the planning.
The planning variables in this case are VisitDate and Provider.

Moves

VisitDateChangeMoveFactory: Creates all the possible combinations of Visits and Dates.
VisitTimeSwapMoveFactory: Creates a permutation of all the Visits to swap their Dates. (It is not clear to me if all these moves are not already included in the previous factory)
AssignCareProviderMoveFactory: Creates a combination of all the Providers for the different Visits.

Hard Constraints

 

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

...