package com.agilex.healthcare.schedulingmanager.notification.appointmentrequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.agilex.healthcare.mobilehealthplatform.domain.PatientIdentifier;
import com.agilex.healthcare.schedulingmanager.domain.SMAppointmentRequestMessage;

/**
 * Created with IntelliJ IDEA.
 * User: clarkee
 * Date: 2/19/13
 * Time: 3:40 PM
 * To change this template use File | Settings | File Templates.
 */
public class AppointmentRequestMessageNotificationGateway extends MessagingGateway {

    private final static Log logger = LogFactory.getLog(AppointmentRequestMessageNotificationGateway.class);

    public AppointmentRequestMessageNotificationGateway(HaMessagingConfiguration configuration) {
        super(configuration);
    }

    public void sendMessageToPatient(SMAppointmentRequestMessage smAppointmentRequestMessage) throws MessagePublishException {

        sendMessageToPatient(smAppointmentRequestMessage.getPatientIdentifier(), null);
    }
    
    public void sendMessageToPatient(PatientIdentifier patientIdentifier, String detailCode) throws MessagePublishException {

        logger.debug("Notification message received for " + patientIdentifier.getAssigningAuthority() + "/" + patientIdentifier.getUniqueId());

        AppointmentRequestMessageCreatedMessage message = new AppointmentRequestMessageCreatedMessage(patientIdentifier, detailCode);

        publishMessage(message);
    }
}



