EnrollmentService

public interface EnrollmentService

Enrollment Service interface provides methods for enrolling and unenrolling enrollments, fulfilling milestones and for retrieving alert timings.

Methods

enroll

Long enroll(String externalId, String scheduleName, String startingMilestoneName, DateTime referenceDateTime, DateTime enrollmentDateTime, Time preferredAlertTime, Map<String, String> metadata)

Creates the enrolment from the given parameters and schedule alerts jobs. This method also sends org.motechproject.scheduletracking.events.EnrolledUserEvent if there is no active enrolment for the client external id and the schedule name. If the client has already enrolled for the same schedule which is currently active, then enrollment is updated and alerts are rescheduled.

Parameters:
  • externalId – the client external id
  • scheduleName – the name of the schedule
  • startingMilestoneName – the starting milestone name
  • referenceDateTime – the reference date and time on which the schedule will start
  • enrollmentDateTime – the enrollment date and time on which the client is enrolled into the schedule
  • preferredAlertTime – the time of day to send alerts to client
  • metadata – the metadata
Returns:

the id of the created enrollment

fulfillCurrentMilestone

void fulfillCurrentMilestone(Enrollment enrollment, DateTime fulfillmentDateTime)

Fulfills the current milestone of the enrollment(with fulfillment date and time as the the given date and time).

Parameters:
  • enrollment – the enrollment with milestone to fulfill
  • fulfillmentDateTime – the fulfillment date and time

getAlertTimings

MilestoneAlerts getAlertTimings(String externalId, String scheduleName, String milestoneName, DateTime referenceDateTime, DateTime enrollmentDateTime, Time preferredAlertTime)

Returns the alert timings for the given parameters. Enrollment is build from the parameters and then alerts timing are retrieved.

Parameters:
  • externalId – the client external id
  • scheduleName – the name of the schedule
  • milestoneName – the current milestone name
  • referenceDateTime – the reference date and time on which the schedule will start
  • enrollmentDateTime – the enrollment date and time on which the client is enrolled into the schedule
  • preferredAlertTime – the time of day to send alerts to client
Returns:

the alert timings

unenroll

void unenroll(Enrollment enrollment)

Unenrolls the given enrollment and unschedules all alerts job of the enrollment. This method also sends org.motechproject.scheduletracking.events.UnenrolledUserEvent.

Parameters:
  • enrollment – the enrollment to unenroll