package com.agilex.healthcare.schedulingmanager.datalayer;

import com.agilex.healthcare.mobilehealthplatform.domain.Patients;
import com.agilex.healthcare.schedulingmanager.mdws.MdwsResponseValidator;
import com.agilex.healthcare.schedulingmanager.mdws.MdwsSchedulingDataLayer;
import com.agilex.healthcare.schedulingmanager.mdws.connection.MdwsConfiguration;
import com.agilex.healthcare.schedulingmanager.mdws.connection.SchedulingConnection;
import com.agilex.healthcare.schedulingmanager.mdws.generatedwsdl.schedulingservice.PatientArray;
import com.agilex.healthcare.schedulingmanager.mdws.translator.PatientArrayTranslator;

public class SchedulingClinicsDataLayerMdws extends MdwsSchedulingDataLayer {
	public SchedulingClinicsDataLayerMdws(MdwsConfiguration mdwsConfiguration) {
        super(mdwsConfiguration);
    }


	/**
	 * Calls the MDWS service SchedulingSvc.getPatientsByClinic for the given patient
	 */
	public Patients getPatientsByClinic(String siteCode, String clinicId, String startDate, String stopDate) {
        SchedulingConnection authenticatedConnection = super.getAuthenticatedConnection(siteCode);
        PatientArray patientArray = authenticatedConnection.getPort().getPatientsByClinic(clinicId, startDate, stopDate);
        MdwsResponseValidator.validateMdwsObject(patientArray);
        Patients retValue = PatientArrayTranslator.translate(patientArray, siteCode);
        return retValue;
    }
}
