CallDetailRecord

public class CallDetailRecord

The call detail record is the object persisted for every call from and to MOTECH by the IVR module. It represents the details of the call, and is stored in the database for auditing purposes.

Fields

CALL_FAILED

public static final String CALL_FAILED

CALL_INITIATED

public static final String CALL_INITIATED

Constructors

CallDetailRecord

public CallDetailRecord()

Creates a new CallDetailRecord and sets the motechTimestamp value to the current datetime.

CallDetailRecord

public CallDetailRecord(String configName, String providerTimestamp, String from, String to, CallDirection callDirection, String callStatus, String templateName, String motechCallId, String providerCallId, Map<String, String> providerExtraData, String callDuration, String messagePercentListened)

Creates a new CallDetailRecord and sets the motechTimestamp value to the current datetime.

Parameters:
  • configName – the name of the IVR configuration used for the call this record corresponds to
  • providerTimestamp – the timestamp for this call from the IVR provider
  • from – the initiator of this call
  • to – the recipient of this call
  • callDirection – the direction of this call
  • callStatus – the status of this call
  • templateName – the name of the template associated with this call
  • motechCallId – the id for this call generated by MOTECH
  • providerCallId – the id for this call generated by the IVR provider
  • providerExtraData – the extra data coming from the provider

Methods

equals

public boolean equals(Object o)

getCallDirection

public CallDirection getCallDirection()
Returns:the direction of this call

See also: org.motechproject.ivr.domain.CallDirection

getCallDuration

public String getCallDuration()
Returns:the duration of this call

getCallStatus

public String getCallStatus()

Returns the status of this call, which is a string coming from the IVR provider.

Returns:the status of this call

getConfigName

public String getConfigName()
Returns:the name of the IVR configuration used for the call this record corresponds to

getCurrentTimestamp

public static String getCurrentTimestamp()

Returns the current datetime as a string formatted using the datetime formatter used for timestamps in call detail records. The format is yyyy-MM-dd HH:mm:ss.SSSS.

Returns:the current time in the call detail record timestamp format

getFrom

public String getFrom()

Returns the initiator of the call represented by this record. This usually will be the number of the phone that initiated the call.

Returns:the initiator of the call

getId

public long getId()
Returns:the id of the record (auto-generated)

getMessagePercentListened

public String getMessagePercentListened()
Returns:the percent listened of the message

getMotechCallId

public String getMotechCallId()

Returns the ID generated on the MOTECH side for this call. Motech will insert an UUID here.

Returns:the call ID generated by MOTECH

getMotechTimestamp

public String getMotechTimestamp()

Returns the timestamp for this record. The format is yyyy-MM-dd HH:mm:ss.SSSS.

Returns:the timestamp for this record

getProviderCallId

public String getProviderCallId()
Returns:the ID for this call coming from the provider

getProviderExtraData

public Map<String, String> getProviderExtraData()

Returns the extra data for this call detail record. Everything that comes from the provider and does not match any mapping to the fields of CallDetailRecord, will be put into the the provider extra data map.

Returns:the extra data from the provider

getProviderTimestamp

public String getProviderTimestamp()
Returns:the timestamp for this call from the IVR provider

getTemplateName

public String getTemplateName()
Returns:the name of the template associated with this call

getTo

public String getTo()

Returns the recipient of the call represented by this record. This usually will the phone number that was called.

Returns:the recipient of this call

hashCode

public int hashCode()

setConfigName

public void setConfigName(String configName)
Parameters:
  • configName – the name of the IVR configuration used for the call this record corresponds to

setField

public void setField(String key, String val, Map<String, String> callStatusMapping)

When receiving call detail information from an IVR provider the specific call details must be mapped from what the provider sends back to MOTECH and a CallDetailRecord object. This method will find which field on the given callDetailRecord matches the given key and set service to the given value. If there is no matching CallDetailRecord field, then the key/value pair is added to the providerExtraData map field.

Parameters:
  • key – the name of the field to set
  • val – the value to set
  • callStatusMapping – the map which contains mapping for call status. It is used to change status value in the cdr log.

setFrom

public void setFrom(String from)

Sets the initiator of the call represented by this record. This usually will be the phone number that initiated the call.

Parameters:
  • from – the initiator of the call

setMotechTimestamp

public void setMotechTimestamp(String motechTimestamp)

Sets the timestamp for this record. The expected format is yyyy-MM-dd HH:mm:ss.SSSS.

Parameters:
  • motechTimestamp – the timestamp for this record

setProviderTimestamp

public void setProviderTimestamp(String providerTimestamp)
Parameters:
  • providerTimestamp – the timestamp for this call from the IVR provider

setTemplateName

public void setTemplateName(String templateName)
Parameters:
  • templateName – the name of the template associated with this call

setTo

public void setTo(String to)

Sets the recipient of the call represented by this record. This usually will the phone number that was called.

Parameters:
  • to – the recipient of this call

toString

public String toString()