Skip to content

Commit

Permalink
Added New Class SeedIvrLanagMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Freduah committed Jul 25, 2013
1 parent 9334e96 commit 1e96439
Showing 1 changed file with 18 additions and 1 deletion.
@@ -1,6 +1,8 @@
package org.motechproject.ghana.national.web.ivr;


import org.joda.time.DateTime;
import org.joda.time.LocalTime;
import org.motechproject.ghana.national.builder.IVRCallbackUrlBuilder;
import org.motechproject.ghana.national.domain.IVRCallCenterNoMapping;
import org.motechproject.ghana.national.domain.IVRClipManager;
Expand All @@ -20,6 +22,7 @@
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.Calendar;
import java.util.List;

import static org.motechproject.ghana.national.domain.ivr.VerboiceDialStatus.BUSY;
Expand Down Expand Up @@ -56,7 +59,21 @@ public String handleCallStatus(@RequestParam("DialCallStatus") String dialCallSt
@RequestParam("nurseLine") boolean nurseLine) {
if (dialCallStatus != null) {
if (FAILED.getCode().equals(dialCallStatus)) {
return playTwiml(Arrays.asList(ivrClipManager.urlFor(AudioPrompts.CALL_CENTER_DIAL_FAILED.getFileName(), valueOf(language))));

Calendar cal = Calendar.getInstance();
DateTime dt = DateTime.now();
int day = cal.get(Calendar.DAY_OF_WEEK);
int hr = dt.getHourOfDay();
if(day >= Calendar.MONDAY && day <= Calendar.FRIDAY) {
if(hr >= 8 && hr <= 17){
return waitAndDial(language, callerPhoneNumber, nurseLine);
}
}
else
{
return playTwiml(Arrays.asList(ivrClipManager.urlFor(AudioPrompts.CALL_CENTER_DIAL_FAILED.getFileName(), valueOf(language))));
}

} else if (BUSY.getCode().equals(dialCallStatus) || "no-answer".equals(dialCallStatus)) {
return waitAndDial(language, callerPhoneNumber, nurseLine);
} else if (COMPLETED.getCode().equals(dialCallStatus)) {
Expand Down

0 comments on commit 1e96439

Please sign in to comment.