/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.dcm30_04.services.mwl.mwlsourceimpl;

import cdac.medinfo.sdk.dcm30_04.baselibs.DicomV3Factory;
import cdac.medinfo.sdk.dcm30_04.baselibs.ScheduledProcedureStepSequence;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;

/**
 *  This class contains the Attributes required for Query Model. Also contains methods to populate and fill data set of Query Model.
 */
public class ScheduledProcedureStepAttributes extends Attributes
{
	public ScheduledProcedureStepSequence getScheduledProcedureStepSequence()
	{
		ScheduledProcedureStepSequence objScheduledProcedureStepSequence = (ScheduledProcedureStepSequence)getDicomValue(0x0040,0x0100);
		if(objScheduledProcedureStepSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			
			ITransferSyntax objITransferSyntax = getDataSet().getTransferSyntax();
			IDictionaryReader objIDictionaryReader = getDataSet().getDictionaryReader();
			
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objScheduledProcedureStepSequence = (ScheduledProcedureStepSequence)objDicomV3Factory.createSequence(0x0040,0x0100, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0040,0x0100, DicomConstants.DCM_DT_SQ, objScheduledProcedureStepSequence.getValue());
		}
		return objScheduledProcedureStepSequence;
	}
	
	/**
	 * Populates the query Model using filled data set.
	 */
	public void populate(IDataSet objIDataSet)
	{
		super.populate(objIDataSet);
	}	
	
	/**
	 * Fills the data set using already populated Query Model.
	 */
	public void fill(IDataSet objIDataSet)
	{
		super.fill(objIDataSet);
	}
}
