package com.agilex.healthcare.schedulingmanager.datalayer.preference;

import com.agilex.healthcare.mobilehealthplatform.domain.PatientIdentifier;
import com.agilex.healthcare.schedulingmanager.domain.SMPatientPreference;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class PatientPreferenceDataLayerRepo implements PatientPreferenceDataLayer {

	@Resource
    NotificationPreferenceDao notificationPreferenceDao;

	public SMPatientPreference fetchPatientPreference(PatientIdentifier patientId){
		NotificationPreferencePo notificationPreference = notificationPreferenceDao.get(patientId.getUniqueId());		
		SMPatientPreference preference = notificationPreference.create();
		preference.setPatientIdentifier(patientId);
		return preference;
	}
	
	public SMPatientPreference updatePatientPreference(SMPatientPreference SMPatientPreference){
		NotificationPreferencePo notificationPreference = notificationPreferenceDao.update(SMPatientPreference);
		SMPatientPreference preference = notificationPreference.create();
		preference.setPatientIdentifier(SMPatientPreference.getPatientIdentifier());
		return preference;
	}
	
	public void deletePatientPreference(SMPatientPreference SMPatientPreference){
		notificationPreferenceDao.delete(SMPatientPreference);
	}
	

}
