/*******************************************************************************
 *  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.javadbhelper;



import cdac.medinfo.sdk.dcm30_04.baselibs.ExplicitDE;
import cdac.medinfo.sdk.dcm30_04.baselibs.ImplicitDE;
import cdac.medinfo.sdk.dcm30_04.baselibs.SQ;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataElement;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataTypeSQ;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomValue;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.services.dicomnetcommons.DataTypeConvertor;
import cdac.medinfo.sdk.dcm30_04.services.dimsecommons.EnumSequenceName;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.ICollectionIterator;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.SingleCollection;


/**
 * The class Study contains all attributes which are required to define a Study.
 */
public class Study  
{

	private String strPatientID;				//64 chars in DB
	private String strPatientAge;				//64 chars in DB
	private String strPatientWeight;				//64 chars in DB
	private String strStudyID;					//64 chars in DB
	private String strStudyInstanceUID;			//64 chars in DB
	private String strStudyDate;				//64 chars in DB
	private String strStudyTime;				//64 chars in DB
	private String strStudyDescription;			//64 chars in DB
	private String strReferringPhysiansName;	//64 chars in DB
	private String strAccessionNumber;			//64 chars in DB
	private String strModalitiesInStudy;		//64 chars in DB
	private ISingleCollection<Series> objSeriesList;
	private String strSOPClasses; //100 chars in DB
	private String strNameOfPhysicianReadingStudy; //100 chars in DB
	private String strAdmittingDiagnosesDescription; //100 chars in DB
	private String strIssuerOfPatientID; //64 chars in DB
	private String strPatientSize; //64 chars in DB
	private String strOccupation; //16 chars in DB
	private String strAdditionalPatientHistory; //100 chars in DB
	private String strOtherStudyNumbers; //100 chars in DB
	private String strNumberOfStudyRelatedSeries; //12 chars in DB
	private String strNumberOfStudyRelatedInstances; //12 chars in DB
	private String strInterpretationAuthor; //64 chars in DB
	private ISingleCollection<SQModel> objSQModelCollection = new SingleCollection< SQModel>();

	/** The i no series. */
	private int iNoSeries;

	private boolean bPatientID;
	private boolean bPatientAge;
	private boolean bPatientWeight;
	private boolean bStudyID;
	private boolean bStudyInstanceUID;
	private boolean bModalitesInStudy;
	private boolean bStudyDate;
	private boolean bStudyTime;
	private boolean bStudyDescription;
	private boolean bAccessionNumber;
	private boolean bReferringPhysiansName;

	private boolean bSOPClasses;
	private boolean bNameOfPhysicianReadingStudy;
	private boolean bAdmittingDiagnosesDescription;
	private boolean bIssuerOfPatientID;
	private boolean bPatientSize;
	private boolean bOccupation;
	private boolean bAdditionalPatientHistory;
	private boolean bOtherStudyNumbers;
	private boolean bNumberOfStudyRelatedSeries;
	private boolean bNumberOfStudyRelatedInstances;
	private boolean bInterpretationAuthor;

	/**
	 * Verifies whether Series Instance UID is already present or not and Retrieves that instance of Series.
	 * @param strSeriesInsUID value of Series Instance UID
	 * @return Series - instance of Series.
	 */
	public Series isSeriesInsUIDPresent(String strSeriesInsUID)
	{
		if(objSeriesList != null && strSeriesInsUID != null)
		{
			ICollectionIterator<Series> objSeriesListIterator = objSeriesList.iterator();
			Series objRsSeries = null;
			while(objSeriesListIterator.hasNext())
			{
				objRsSeries = objSeriesListIterator.next();
				if(strSeriesInsUID.equals(objRsSeries.getSeriesInstanceUID()))
				{
					return objRsSeries;
				}
			}
		}
		return null;
	}

	/**
	 * Retrieves the value of Accession Number.
	 * @return String - value of Accession Number.
	 */
	public String getAccessionNumber()
	{
		return strAccessionNumber;
	}

	/**
	 * Sets the value of Accession Number.
	 * @param strAccessionNumber value of Accession Number.
	 */
	public void setAccessionNumber(String strAccessionNumber)
	{
		this.strAccessionNumber = strAccessionNumber;
		bAccessionNumber = true;
	}

	/**
	 * Retrieves the Modalities in study.
	 * @return String[] - array of modalities in study
	 */
	public String[] getModalitiesInStudy() 
	{
		return DataTypeConvertor.stringToArray(strModalitiesInStudy);
	}

	/**
	 * Sets the Modalities in study.
	 * @param strModalitiesInStudy array of Modalities in study.
	 */
	public void setModalitiesInStudy(String[] strModalitiesInStudy) 
	{
		this.strModalitiesInStudy = DataTypeConvertor.arrayToString(strModalitiesInStudy);
		bModalitesInStudy = true;
	}

	/**
	 * Retrieves the value of Patient Age.
	 * @return String - value of Patient Age.
	 */
	public String getPatientAge()
	{
		return strPatientAge;
	}

	/**
	 * Sets the value of Patient Age.
	 * @param strPatientAge value of Patient Age.
	 */
	public void setPatientAge(String strPatientAge) 
	{
		this.strPatientAge = strPatientAge;
		bPatientAge = true;
	}

	/**
	 * Retrieves the value of Patient ID.
	 * @return String - value of Patient ID.
	 */
	public String getPatientID()
	{
		return strPatientID;
	}

	/**
	 * Sets the value of Patient ID.
	 * @param strPatientID value of Patient ID.
	 */
	public void setPatientID(String strPatientID) 
	{
		this.strPatientID = strPatientID;
		bPatientID = true;
	}

	/**
	 * Retrieves the value of Patient weight.
	 * @return String - value of Patient weight.
	 */
	public String getPatientWeight() 
	{
		return strPatientWeight;
	}

	/**
	 * Sets the value of Patient weight.
	 * @param strPatientWeight value of Patient weight.
	 */
	public void setPatientWeight(String strPatientWeight) 
	{
		this.strPatientWeight = strPatientWeight;
		bPatientWeight = true;
	}

	/**
	 * Retrieves the value of Referring physician Name.
	 * @return String - value of Referring physician Name.
	 */
	public String getReferringPhysiansName() 
	{
		return strReferringPhysiansName;
	}

	/**
	 * Sets the value of Referring physician Name.
	 * @param strReferringPhysiansName value of Referring physician Name.
	 */
	public void setReferringPhysiansName(String strReferringPhysiansName)
	{
		this.strReferringPhysiansName = strReferringPhysiansName;
		bReferringPhysiansName = true;
	}

	/**
	 * Retrieves the value of Study Date.
	 * @return String - value of Study Date.
	 */
	public String getStudyDate() 
	{
		return strStudyDate;
	}

	/**
	 * Sets the value of Study Date.
	 * @param strStudyDate value of Study Date.
	 */
	public void setStudyDate(String strStudyDate) 
	{
		this.strStudyDate = strStudyDate;
		bStudyDate = true;
	}

	/**
	 * Retrieves the value of  Study Description.
	 * @return String - value of  Study Description.
	 */
	public String getStudyDescription() 
	{
		return strStudyDescription;
	}

	/**
	 * Sets the value of  Study Description.
	 * @param strStudyDescription value of  Study Description.
	 */
	public void setStudyDescription(String strStudyDescription) 
	{
		this.strStudyDescription = strStudyDescription;
		bStudyDescription = true;
	}

	/**
	 * Retrieves the value of Study ID
	 * @return String - value of Study ID
	 */
	public String getStudyID() 
	{
		return strStudyID;
	}

	/**
	 * Sets the value of Study ID
	 * @param strStudyID value of Study ID
	 */
	public void setStudyID(String strStudyID) 
	{
		this.strStudyID = strStudyID;
		bStudyID = true;
	}

	/**
	 * Retrieves the value of Study Instance UID.
	 * @return String - value of Study Instance UID.
	 */
	public String getStudyInstanceUID()
	{
		return strStudyInstanceUID;
	}

	/**
	 * Sets the value of Study Instance UID.
	 * @param strStudyInstanceUID value of Study Instance UID.
	 */
	public void setStudyInstanceUID(String strStudyInstanceUID)
	{
		this.strStudyInstanceUID = strStudyInstanceUID;
		bStudyInstanceUID = true;
	}

	/**
	 * Retrieves the value of Study Time.
	 * @return String - value of Study Time.
	 */
	public String getStudyTime()
	{
		return strStudyTime;
	}

	/**
	 * Sets the value of Study Time.
	 * @param strStudyTime value of Study Time.
	 */
	public void setStudyTime(String strStudyTime) 
	{
		this.strStudyTime = strStudyTime;
		bStudyTime = true;
	}

	/**
	 * Retrieves Number of Series.
	 * @return int - Number of Series.
	 */
	public int getNumberOfSeries() 
	{
		return iNoSeries;
	}

	/**
	 * Sets Number of Series.
	 * @param noSeries Number of Series.
	 */
	public void setNumberOfSeries(int noSeries)
	{
		iNoSeries = noSeries;
	}

	/**
	 * Retrieves the value of AdditionalPatientHistory.
	 * @return String - value of AdditionalPatientHistory.
	 */
	public String getAdditionalPatientHistory() 
	{
		return strAdditionalPatientHistory;
	}

	/**
	 * Sets the value of AdditionalPatientHistory.
	 * @param strAdditionalPatientHistory value of AdditionalPatientHistory.
	 */
	public void setAdditionalPatientHistory(String strAdditionalPatientHistory) 
	{
		this.strAdditionalPatientHistory = strAdditionalPatientHistory;
		bAdditionalPatientHistory = true;
	}

	/**
	 * Retrieves the value of AdmittingDiagnosesDescription.
	 * @return String - value of AdmittingDiagnosesDescription.
	 */
	public String[] getAdmittingDiagnosesDescription() 
	{
		return DataTypeConvertor.stringToArray(strAdmittingDiagnosesDescription);
	}

	/**
	 * Sets the value of AdmittingDiagnosesDescription.
	 * @param arrstrAdmittingDiagnosesDescription value of AdmittingDiagnosesDescription.
	 */
	public void setAdmittingDiagnosesDescription(String[] arrstrAdmittingDiagnosesDescription) 
	{
		this.strAdmittingDiagnosesDescription =DataTypeConvertor.arrayToString(arrstrAdmittingDiagnosesDescription);
		bAdmittingDiagnosesDescription = true;
	}

	/**
	 * Retrieves the value of InterpretationAuthor.
	 * @return String - value of InterpretationAuthor.
	 */
	public String getInterpretationAuthor() 
	{
		return strInterpretationAuthor;
	}

	/**
	 * Sets the value of InterpretationAuthor.
	 * @param strInterpretationAuthor value of InterpretationAuthor.
	 */
	public void setInterpretationAuthor(String strInterpretationAuthor) 
	{
		this.strInterpretationAuthor = strInterpretationAuthor;
		bInterpretationAuthor = true;
	}

	/**
	 * Retrieves the value of IssuerOfPatientID.
	 * @return String - value of IssuerOfPatientID.
	 */
	public String getIssuerOfPatientID()
	{
		return strIssuerOfPatientID;
	}

	/**
	 * Sets the value of IssuerOfPatientID.
	 * @param strIssuerOfPatientID value of IssuerOfPatientID.
	 */
	public void setIssuerOfPatientID(String strIssuerOfPatientID) 
	{
		this.strIssuerOfPatientID = strIssuerOfPatientID;
		bIssuerOfPatientID = true;
	}

	/**
	 * Retrieves the value of NameOfPhysicianReadingStudy.
	 * @return String - value of NameOfPhysicianReadingStudy.
	 */
	public String[] getNameOfPhysicianReadingStudy() 
	{
		return DataTypeConvertor.stringToArray(strNameOfPhysicianReadingStudy);
	}	

	/**
	 * Sets the value of NameOfPhysicianReadingStudy.
	 * @param arrstrNameOfPhysicianReadingStudy value of NameOfPhysicianReadingStudy.
	 */
	public void setNameOfPhysicianReadingStudy(String[] arrstrNameOfPhysicianReadingStudy) 
	{
		this.strNameOfPhysicianReadingStudy =DataTypeConvertor.arrayToString(arrstrNameOfPhysicianReadingStudy);
		bNameOfPhysicianReadingStudy = true;
	}

	/**
	 * Retrieves the value of NumberOfStudyRelatedInstances.
	 * @return String - value of NumberOfStudyRelatedInstances.
	 */
	public String getNumberOfStudyRelatedInstances() 
	{
		return strNumberOfStudyRelatedInstances;
	}

	/**
	 * Sets the value of NumberOfStudyRelatedInstances.
	 * @param strNumberOfStudyRelatedInstances value of NumberOfStudyRelatedInstances.
	 */
	public void setNumberOfStudyRelatedInstances(String strNumberOfStudyRelatedInstances) 
	{
		this.strNumberOfStudyRelatedInstances = strNumberOfStudyRelatedInstances;
		bNumberOfStudyRelatedInstances = true;
	}

	/**
	 * Retrieves the value of NumberOfStudyRelatedSeries.
	 * @return String - value of NumberOfStudyRelatedSeries.
	 */
	public String getNumberOfStudyRelatedSeries() 
	{
		return strNumberOfStudyRelatedSeries;
	}

	/**
	 * Sets the value of NumberOfStudyRelatedSeries.
	 * @param strNumberOfStudyRelatedSeries value of NumberOfStudyRelatedSeries.
	 */
	public void setNumberOfStudyRelatedSeries(String strNumberOfStudyRelatedSeries) 
	{
		this.strNumberOfStudyRelatedSeries = strNumberOfStudyRelatedSeries;
		bNumberOfStudyRelatedSeries = true;
	}

	/**
	 * Retrieves the value of Occupation.
	 * @return String - value of Occupation.
	 */
	public String getOccupation() 
	{
		return strOccupation;
	}

	/**
	 * Sets the value of Occupation.
	 * @param strOccupation value of Occupation.
	 */
	public void setOccupation(String strOccupation) 
	{
		this.strOccupation = strOccupation;
		bOccupation = true;
	}

	/**
	 * Retrieves the value of OtherStudyNumbers.
	 * @return String[] - value of OtherStudyNumbers.
	 */
	public String[] getOtherStudyNumbers() 
	{
		return DataTypeConvertor.stringToArray(strOtherStudyNumbers);
	}

	/**
	 * Sets the value of OtherStudyNumbers
	 * @param arrstrOtherStudyNumbers value of OtherStudyNumbers.
	 */
	public void setOtherStudyNumbers(String[] arrstrOtherStudyNumbers)
	{
		this.strOtherStudyNumbers = DataTypeConvertor.arrayToString(arrstrOtherStudyNumbers);
		bOtherStudyNumbers = true;
	}

	/**
	 * Retrieves the value of PatientSize
	 * @return String - value of PatientSize
	 */
	public String getPatientSize() 
	{
		return strPatientSize;
	}

	/**
	 * Sets the value of PatientSize
	 * @param strPatientSize value of PatientSize
	 */
	public void setPatientSize(String strPatientSize) 
	{
		this.strPatientSize = strPatientSize;
		bPatientSize = true;
	}

	/**
	 * Retrieves the value of SOPClasses.
	 * @return String[] - value of SOPClasses.
	 */
	public String[] getSOPClasses()
	{
		return DataTypeConvertor.stringToArray(strSOPClasses);
	}

	/**
	 * Sets the value of SOPClasses.
	 * @param arrstrSOPClasses value of SOPClasses.
	 */
	public void setSOPClasses(String[] arrstrSOPClasses)
	{
		this.strSOPClasses = DataTypeConvertor.arrayToString(arrstrSOPClasses);
		bSOPClasses = true;
	}

	/**
	 * Retrieves the collection of Series
	 * @return ISingleCollection<Series> - collection of Series
	 */
	public ISingleCollection<Series> getSeriesList()
	{
		return objSeriesList;
	}

	/**
	 * Specifies the presence of AccessionNumber
	 * @return boolean - shows status True if present else False
	 */
	public boolean isAccessionNumber() 
	{
		return bAccessionNumber;
	}

	/**
	 * Sets the presence of AccessionNumber
	 * @param accessionNumber shows status True if present else False
	 */
	public void setBAccessionNumber(boolean accessionNumber) 
	{
		bAccessionNumber = accessionNumber;
	}

	/**
	 * Specifies the presence of ModalitesInStudy
	 * @return boolean - shows status True if present else False
	 */
	public boolean isModalitesInStudy() {
		return bModalitesInStudy;
	}

	/**
	 * Sets the presence of ModalitesInStudy
	 * @param modalitesInStudy shows status True if present else False
	 */
	public void setBModalitesInStudy(boolean modalitesInStudy) 
	{
		bModalitesInStudy = modalitesInStudy;
	}

	/**
	 * Specifies the presence of PatientAge
	 * @return boolean - shows status True if present else False
	 */
	public boolean isPatientAge() {
		return bPatientAge;
	}

	/**
	 * Sets the presence of PatientAge
	 * @param patientAge shows status True if present else False
	 */
	public void setBPatientAge(boolean patientAge) 
	{
		bPatientAge = patientAge;
	}

	/**
	 * Specifies the presence of PatientID
	 * @return boolean - shows status True if present else False
	 */
	public boolean isPatientID() {
		return bPatientID;
	}

	/**
	 * Sets the presence of PatientID
	 * @param patientID shows status True if present else False
	 */
	public void setBPatientID(boolean patientID) {
		bPatientID = patientID;
	}

	/**
	 * Specifies the presence of PatienWeight
	 * @return boolean - shows status True if present else False
	 */
	public boolean isPatientWeight() {
		return bPatientWeight;
	}

	/**
	 * Sets the presence of PatienWeight
	 * @param patienWeight shows status True if present else False
	 */
	public void setBPatientWeight(boolean patienWeight) {
		bPatientWeight = patienWeight;
	}

	/**
	 * Specifies the presence of ReferringPhysiansName
	 * @return boolean - shows status True if present else False
	 */
	public boolean isReferringPhysiansName() {
		return bReferringPhysiansName;
	}

	/**
	 * Sets the presence of ReferringPhysiansName
	 * @param referringPhysiansName shows status True if present else False
	 */
	public void setBReferringPhysiansName(boolean referringPhysiansName) {
		bReferringPhysiansName = referringPhysiansName;
	}

	/**
	 * Specifies the presence of StudyDate
	 * @return boolean - shows status True if present else False
	 */
	public boolean isStudyDate() {
		return bStudyDate;
	}

	/**
	 * Sets the presence of StudyDate
	 * @param studyDate shows status True if present else False
	 */
	public void setBStudyDate(boolean studyDate) {
		bStudyDate = studyDate;
	}

	/**
	 * Specifies the presence of StudyDescription
	 * @return boolean - shows status True if present else False
	 */
	public boolean isStudyDescription() {
		return bStudyDescription;
	}

	/**
	 * Sets the presence of StudyDescription
	 * @param studyDescription shows status True if present else False
	 */
	public void setBStudyDescription(boolean studyDescription) {
		bStudyDescription = studyDescription;
	}

	/**
	 * Specifies the presence of StudyID
	 * @return boolean - shows status True if present else False
	 */
	public boolean isStudyID() {
		return bStudyID;
	}

	/**
	 * Sets the presence of StudyID
	 * @param studyID shows status True if present else False
	 */
	public void setBStudyID(boolean studyID) {
		bStudyID = studyID;
	}

	/**
	 * Specifies the presence of StudyInstanceUID
	 * @return boolean - shows status True if present else False
	 */
	public boolean isStudyInstanceUID() {
		return bStudyInstanceUID;
	}

	/**
	 * Sets the presence of StudyInstanceUID
	 * @param studyInstanceUID shows status True if present else False
	 */
	public void setBStudyInstanceUID(boolean studyInstanceUID) {
		bStudyInstanceUID = studyInstanceUID;
	}

	/**
	 * Specifies the presence of StudyTime
	 * @return boolean - shows status True if present else False
	 */
	public boolean isStudyTime() {
		return bStudyTime;
	}

	/**
	 * Sets the presence of StudyTime
	 * @param studyTime shows status True if present else False
	 */
	public void setBStudyTime(boolean studyTime) {
		bStudyTime = studyTime;
	}

	/**
	 * Sets the collection of Series
	 * @param objSeriesList collection of Series
	 */
	public void setSeriesList(ISingleCollection<Series> objSeriesList) 
	{
		this.objSeriesList = objSeriesList;
	}

	/**
	 * Specifies the presence of AdditionalPatientHistory
	 * @return boolean - shows status True if present else False
	 */
	public boolean isAdditionalPatientHistory() 
	{
		return bAdditionalPatientHistory;
	}

	/**
	 * Sets the presence of AdditionalPatientHistory
	 * @param additionalPatientHistory shows status True if present else False
	 */
	public void setBAdditionalPatientHistory(boolean additionalPatientHistory) 
	{
		bAdditionalPatientHistory = additionalPatientHistory;
	}

	/**
	 * Specifies the presence of AdmittingDiagnosesDescription
	 * @return boolean - shows status True if present else False
	 */
	public boolean isAdmittingDiagnosesDescription() 
	{
		return bAdmittingDiagnosesDescription;
	}

	/**
	 * Sets the presence of AdmittingDiagnosesDescription
	 * @param admittingDiagnosesDescription shows status True if present else False
	 */
	public void setBAdmittingDiagnosesDescription(boolean admittingDiagnosesDescription) 
	{
		bAdmittingDiagnosesDescription = admittingDiagnosesDescription;
	}

	/**
	 * Specifies the presence of InterpretationAuthor
	 * @return boolean - shows status True if present else False
	 */
	public boolean isInterpretationAuthor() 
	{
		return bInterpretationAuthor;
	}

	/**
	 * Sets the presence of InterpretationAuthor
	 * @param interpretationAuthor shows status True if present else False
	 */
	public void setBInterpretationAuthor(boolean interpretationAuthor) 
	{
		bInterpretationAuthor = interpretationAuthor;
	}

	/**
	 * Specifies the presence of IssuerOfPatientID
	 * @return boolean - shows status True if present else False
	 */
	public boolean isIssuerOfPatientID() 
	{
		return bIssuerOfPatientID;
	}

	/**
	 * Sets the presence of IssuerOfPatientID
	 * @param issuerOfPatientID shows status True if present else False
	 */
	public void setBIssuerOfPatientID(boolean issuerOfPatientID) 
	{
		bIssuerOfPatientID = issuerOfPatientID;
	}

	/**
	 * Specifies the presence of NameOfPhysicianReadingStudy
	 * @return boolean - shows status True if present else False
	 */
	public boolean isNameOfPhysicianReadingStudy() 
	{
		return bNameOfPhysicianReadingStudy;
	}

	/**
	 * Sets the presence of NameOfPhysicianReadingStudy
	 * @param nameOfPhysicianReadingStudy shows status True if present else False
	 */
	public void setBNameOfPhysicianReadingStudy(boolean nameOfPhysicianReadingStudy) 
	{
		bNameOfPhysicianReadingStudy = nameOfPhysicianReadingStudy;
	}

	/**
	 * Specifies the presence of NumberOfStudyRelatedInstances
	 * @return boolean - shows status True if present else False
	 */
	public boolean isNumberOfStudyRelatedInstances() 
	{
		return bNumberOfStudyRelatedInstances;
	}

	/**
	 * Sets the presence of NumberOfStudyRelatedInstances
	 * @param numberOfStudyRelatedInstances shows status True if present else False
	 */
	public void setBNumberOfStudyRelatedInstances(boolean numberOfStudyRelatedInstances) 
	{
		bNumberOfStudyRelatedInstances = numberOfStudyRelatedInstances;
	}

	/**
	 * Specifies the presence of NumberOfStudyRelatedSeries
	 * @return boolean - shows status True if present else False
	 */
	public boolean isNumberOfStudyRelatedSeries() 
	{
		return bNumberOfStudyRelatedSeries;
	}

	/**
	 * Sets the presence of NumberOfStudyRelatedSeries
	 * @param numberOfStudyRelatedSeries shows status True if present else False
	 */
	public void setBNumberOfStudyRelatedSeries(boolean numberOfStudyRelatedSeries)
	{
		bNumberOfStudyRelatedSeries = numberOfStudyRelatedSeries;
	}

	/**
	 * Specifies the presence of Occupation
	 * @return boolean - shows status True if present else False
	 */
	public boolean isOccupation() 
	{
		return bOccupation;
	}

	/**
	 * Sets the presence of Occupation
	 * @param occupation shows status True if present else False
	 */
	public void setBOccupation(boolean occupation) 
	{
		bOccupation = occupation;
	}

	/**
	 * Specifies the presence of OtherStudyNumbers
	 * @return boolean - shows status True if present else False
	 */
	public boolean isOtherStudyNumbers() 
	{
		return bOtherStudyNumbers;
	}

	/**
	 * Sets the presence of OtherStudyNumbers
	 * @param otherStudyNumbers shows status True if present else False
	 */
	public void setBOtherStudyNumbers(boolean otherStudyNumbers) 
	{
		bOtherStudyNumbers = otherStudyNumbers;
	}

	/**
	 * Specifies the presence of PatientSize
	 * @return boolean - shows status True if present else False
	 */
	public boolean isPatientSize() 
	{
		return bPatientSize;
	}

	/**
	 * Sets the presence of PatientSize
	 * @param patientSize shows status True if present else False
	 */
	public void setBPatientSize(boolean patientSize) 
	{
		bPatientSize = patientSize;
	}

	/**
	 * Specifies the presence of SOPClasses
	 * @return boolean - shows status True if present else False
	 */
	public boolean isSOPClasses() 
	{
		return bSOPClasses;
	}

	/**
	 * Sets the presence of SOPClasses
	 * @param classes shows status True if present else False
	 */
	public void setBSOPClasses(boolean classes) 
	{
		bSOPClasses = classes;
	}

	/**
	 * This method adds the Sequence Model to the current study.
	 * @param objSQModel instance of sequence model
	 */
	public void addSequenceModel(SQModel objSQModel)
	{
		objSQModelCollection.add(objSQModel);
	}

	/**
	 * This method gets all the Sequence Model of Study. 
	 * @return ISingleCOllection<SQModel> - collection of sequence Model
	 */
	public  ISingleCollection<SQModel> getSequenceModel()
	{
		return objSQModelCollection;
	}

	/**
	 * It populates the DataSet with all attributes which are present in a Study.
	 * @param objIDataSet instance of IDataSet.
	 */
	public void fill(IDataSet objIDataSet)
	{
		if(this.isAccessionNumber())
			setValue(this.getAccessionNumber(),0x0008,0x0050, DicomConstants.DCM_DT_SH,objIDataSet);
		if(this.isModalitesInStudy())
			setValue(this.getModalitiesInStudy(),0x0008,0x0061,DicomConstants.DCM_DT_CS,objIDataSet);
		if(this.isPatientAge())
			setValue(this.getPatientAge(),0x0010,0x1010, DicomConstants.DCM_DT_AS,objIDataSet);
		if(this.isPatientID())
			setValue(this.getPatientID(),0x0010,0x0020,DicomConstants.DCM_DT_LO,objIDataSet);
		if(this.isPatientWeight())
			setValue(this.getPatientWeight(),0x0010,0x1030, DicomConstants.DCM_DT_DS,objIDataSet);
		if(this.isReferringPhysiansName())
			setValue(this.getReferringPhysiansName(),0x0008,0x0090,DicomConstants.DCM_DT_PN,objIDataSet);
		if(this.isStudyDate())
			setValue(this.getStudyDate(),0x0008,0x0020, DicomConstants.DCM_DT_DA,objIDataSet);
		if(this.isStudyDescription())
			setValue(this.getStudyDescription(),0x0008,0x1030,DicomConstants.DCM_DT_LO,objIDataSet);
		if(this.isStudyID())
			setValue(this.getStudyID(),0x0020,0x0010,DicomConstants.DCM_DT_SH,objIDataSet);
		if(this.isStudyInstanceUID())
			setValue(this.getStudyInstanceUID(),0x0020,0x000D, DicomConstants.DCM_DT_UI,objIDataSet);
		if(this.isStudyTime())
			setValue(this.getStudyTime(),0x0008,0x0030,DicomConstants.DCM_DT_TM,objIDataSet);

		if(this.isSOPClasses())
			setValue(this.getSOPClasses(),0x0008,0x0062,DicomConstants.DCM_DT_UI,objIDataSet);

		if(this.isNameOfPhysicianReadingStudy())
			setValue(this.getNameOfPhysicianReadingStudy(),0x0008,0x1060,DicomConstants.DCM_DT_PN,objIDataSet);
		if(this.isAdmittingDiagnosesDescription())
			setValue(this.getAdmittingDiagnosesDescription(),0x0008,0x1080,DicomConstants.DCM_DT_LO,objIDataSet);

		if(this.isPatientAge())
			setValue(this.getPatientAge(),0x0010,0x1010,DicomConstants.DCM_DT_AS,objIDataSet);
		if(this.isOccupation())
			setValue(this.getOccupation(),0x0010,0x2180,DicomConstants.DCM_DT_SH,objIDataSet);
		if(this.isAdditionalPatientHistory())
			setValue(this.getAdditionalPatientHistory(),0x0010,0x21B0,DicomConstants.DCM_DT_LT,objIDataSet);
		if(this.isOtherStudyNumbers())
			setValue(this.getOtherStudyNumbers(),0x0020,0x1070,DicomConstants.DCM_DT_IS,objIDataSet);
		if(this.isNumberOfStudyRelatedSeries())
			setValue(this.getNumberOfStudyRelatedSeries(),0x0020,0x1206,DicomConstants.DCM_DT_IS,objIDataSet);
		if(this.isNumberOfStudyRelatedInstances())
			setValue(this.getNumberOfStudyRelatedInstances(),0x0020,0x1208,DicomConstants.DCM_DT_IS,objIDataSet);
		if(this.isInterpretationAuthor())
			setValue(this.getInterpretationAuthor(),0x4008,0x010C,DicomConstants.DCM_DT_PN,objIDataSet);
		if(this.isIssuerOfPatientID())
			setValue(this.getIssuerOfPatientID(),0x0010,0x0021,DicomConstants.DCM_DT_LO,objIDataSet);
		if(objSQModelCollection.size() >0)
		{
			for(SQModel objSQModel : objSQModelCollection)
			{
				if(!objSQModel.isEmpty())
				{
					IDataTypeSQ objIDataTypeSQ = new SQ(objIDataSet.getTransferSyntax(),objIDataSet.getDictionaryReader());
					objSQModel.fill(objIDataTypeSQ);
					short[] shTag = null;
					if(objSQModel.getSQName().equals(EnumSequenceName.ProcedureCodeSequence.getValue()))
					{
						shTag = objIDataSet.getDictionaryReader().getTag(EnumSequenceName.ProcedureCodeSequence.getValue());
					}
					else if(objSQModel.getSQName().equals(EnumSequenceName.ReferencedStudySequence.getValue()))
					{
						shTag = objIDataSet.getDictionaryReader().getTag(EnumSequenceName.ReferencedStudySequence.getValue());
					}
					setValue(objIDataTypeSQ.getValue(), shTag[0], shTag[1], DicomConstants.DCM_DT_SQ, objIDataSet);
				}
			}
		}
	}

	/**
	 * Initializes the Study according to the presence of DataElements in passed DataSet.
	 * @param objIDataSet instance of IDataSet
	 */
	public void populate(IDataSet objIDataSet)
	{
		if(objIDataSet.isPresent(0x0010,0x0020))
		{
			Object objVal = getValue(objIDataSet, 0x0010,0x0020);
			if(objVal != null)
				setPatientID(objVal.toString());
			setBPatientID(true);
		}
		if(objIDataSet.isPresent(0x0010,0x1010))
		{
			Object objVal = getValue(objIDataSet, 0x0010,0x0010);
			if(objVal != null)
				setPatientAge(objVal.toString());
			setBPatientAge(true);
		}
		if(objIDataSet.isPresent(0x0010,0x1030))
		{
			Object objVal = getValue(objIDataSet, 0x0010,0x0030);
			if(objVal != null)
				setPatientWeight(objVal.toString());
			setBPatientWeight(true);
		}
		if(objIDataSet.isPresent(0x0020,0x0010))
		{
			Object objVal = getValue(objIDataSet, 0x0020,0x0010);
			if(objVal != null)
				setStudyID(objVal.toString());
			setBStudyID(true);
		}
		if(objIDataSet.isPresent(0x0020,0x000D))
		{
			Object objVal = getValue(objIDataSet, 0x0020,0x000D);
			if(objVal != null)
				setStudyInstanceUID(objVal.toString());
			setBStudyInstanceUID(true);
		}
		if(objIDataSet.isPresent(0x0008,0x0020))
		{
			Object objVal = getValue(objIDataSet, 0x0008,0x0020);
			if(objVal != null)
				setStudyDate(objVal.toString());
			setBStudyDate(true);
		}
		if(objIDataSet.isPresent(0x0008,0x0030))
		{
			Object objVal = getValue(objIDataSet, 0x0008,0x0030);
			if(objVal != null)
				setStudyTime(objVal.toString());
			setBStudyTime(true);
		}
		if(objIDataSet.isPresent(0x0008,0x1030))
		{
			Object objVal = getValue(objIDataSet, 0x0008,0x1030);
			if(objVal != null)
				setStudyDescription(objVal.toString());
			setBStudyDescription(true);
		}
		if(objIDataSet.isPresent(0x0008,0x0090))
		{
			Object objVal = getValue(objIDataSet, 0x0008,0x0090);
			if(objVal != null)
				setReferringPhysiansName(objVal.toString());
			setBReferringPhysiansName(true);
		}
		if(objIDataSet.isPresent(0x0008,0x0050))
		{
			Object objVal = getValue(objIDataSet, 0x0008,0x0050);
			if(objVal != null)
				setAccessionNumber(objVal.toString());
			setBAccessionNumber(true);
		}
		if(objIDataSet.isPresent(0x0008,0x0061))
		{
			Object objVal = getValue(objIDataSet, 0x0008,0x0061);
			if(objVal != null)
			{
				if (objVal instanceof String) 
				{
					setModalitiesInStudy(DataTypeConvertor.stringToArray(objVal.toString()));
				}
				else if (objVal instanceof String[] ) 
				{
					setModalitiesInStudy((String[])objVal);
				}
			}
			setBModalitesInStudy(true);
		}

		if(objIDataSet.isPresent(0x0008,0x0062))
		{
			Object objVal = getValue(objIDataSet, 0x0008,0x0062);
			if(objVal != null)
			{
				if (objVal instanceof String) 
				{
					setSOPClasses(DataTypeConvertor.stringToArray(objVal.toString()));
				}
				else if (objVal instanceof String[] ) 
				{
					setSOPClasses((String[])objVal);
				}
			}
			setBSOPClasses(true);
		}

		if(objIDataSet.isPresent(0x0008,0x1060))
		{
			Object objVal = getValue(objIDataSet, 0x0008,0x1060);
			if(objVal != null)
			{
				if (objVal instanceof String) 
				{
					setNameOfPhysicianReadingStudy(DataTypeConvertor.stringToArray(objVal.toString()));
				}
				else if (objVal instanceof String[] ) 
				{
					setNameOfPhysicianReadingStudy((String[])objVal);
				}
			}
			setBNameOfPhysicianReadingStudy(true);
		}

		if(objIDataSet.isPresent(0x0008,0x1080))
		{
			Object objVal = getValue(objIDataSet, 0x0008,0x1080);
			if(objVal != null)
			{
				if (objVal instanceof String) 
				{
					setAdmittingDiagnosesDescription(DataTypeConvertor.stringToArray(objVal.toString()));
				}
				else if (objVal instanceof String[] ) 
				{
					setAdmittingDiagnosesDescription((String[])objVal);
				}
			}
			setBAdmittingDiagnosesDescription(true);
		}

		if(objIDataSet.isPresent(0x0020,0x1070))
		{
			Object objVal = getValue(objIDataSet, 0x0020,0x1070);
			if(objVal != null)
			{
				if (objVal instanceof String) 
				{
					setOtherStudyNumbers(DataTypeConvertor.stringToArray(objVal.toString()));
				}
				else if (objVal instanceof String[] ) 
				{
					setOtherStudyNumbers((String[])objVal);
				}
			}
			setBOtherStudyNumbers(true);
		}				

		if(objIDataSet.isPresent(0x0010,0x0021))
		{
			Object objVal = getValue(objIDataSet, 0x0010,0x0021);
			if(objVal != null)
				setIssuerOfPatientID(objVal.toString());
			setBIssuerOfPatientID(true);
		}

		if(objIDataSet.isPresent(0x0010,0x1020))
		{
			Object objVal = getValue(objIDataSet, 0x0010,0x1020);
			if(objVal != null)
				setPatientSize(objVal.toString());
			setBPatientSize(true);
		}
		if(objIDataSet.isPresent(0x0010,0x2180))
		{
			Object objVal = getValue(objIDataSet, 0x0010,0x2180);
			if(objVal != null)
				setOccupation(objVal.toString());
			setBOccupation(true);
		}
		if(objIDataSet.isPresent(0x0010,0x21B0))
		{
			Object objVal = getValue(objIDataSet, 0x0010,0x21B0);
			if(objVal != null)
				setAdditionalPatientHistory(objVal.toString());
			setBAdditionalPatientHistory(true);
		}
		if(objIDataSet.isPresent(0x0020,0x1206))
		{
			Object objVal = getValue(objIDataSet, 0x0020,0x1206);
			if(objVal != null)
				setNumberOfStudyRelatedSeries(objVal.toString());
			setBPatientSize(true);
		}
		if(objIDataSet.isPresent(0x0020,0x1208))
		{
			Object objVal = getValue(objIDataSet,0x0020,0x1208);
			if(objVal != null)
				setNumberOfStudyRelatedInstances(objVal.toString());
			setBNumberOfStudyRelatedInstances(true);
		}
		if(objIDataSet.isPresent(0x4008,0x010C))
		{
			Object objVal = getValue(objIDataSet, 0x4008,0x010C);
			if(objVal != null)
				setInterpretationAuthor(objVal.toString());
			setBInterpretationAuthor(true);
		}
		if(objIDataSet.isPresent(0x0008,0x1032))
		{
			IDataTypeSQ objSQ = (IDataTypeSQ)objIDataSet.getDataForTag(0x0008,0x1032).getDicomValue();
			SQModel objSQModel = new SQModel(EnumSequenceName.ProcedureCodeSequence.getValue());
			objSQModel.populate(objSQ);
			objSQModelCollection.add(objSQModel);
		}
		if(objIDataSet.isPresent(0x0008,0x1110))
		{
			IDataTypeSQ objSQ = (IDataTypeSQ)objIDataSet.getDataForTag(0x0008,0x1110).getDicomValue();
			SQModel objSQModel = new SQModel(EnumSequenceName.ReferencedStudySequence.getValue());
			objSQModel.populate(objSQ);
			objSQModelCollection.add(objSQModel);
		}
	}

	/**
	 * This method returns value of DicomValue from passed DataSet.
	 * @param objIDataSet instance of DataSet
	 * @param iGroupNumber Group Number of the DataElement
	 * @param iElementNumber Element Number of the DataElement
	 * @return Object - instance of IDicomValue.
	 */
	private Object getValue(IDataSet objIDataSet, int iGroupNumber, int iElementNumber)
	{
		IDataElement objIDataElement =  objIDataSet.getDataForTag(iGroupNumber,iElementNumber);
		if(objIDataElement == null)
			return null;
		IDicomValue objIDicomValue = objIDataElement.getDicomValue();
		if(objIDicomValue == null)
			return null;
		return objIDicomValue.getValue();
	}

	/**
	 * Sets value in dataElement and adds it to passed DataSet.
	 * @param objValue Object value 
	 * @param iGroupNumber Group Number of the DataElement
	 * @param iElementNumber Element Number of the DataElement
	 * @param iVR VR type for DataElement.
	 * @param objIDataSet instance of DataSet
	 */
	private void setValue(Object objValue,int iGroupNumber,int iElementNumber,int iVR,IDataSet objIDataSet)
	{
		/* 
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		IDataElement objIDataElement = null;
		IDictionaryReader objIDictionaryReader = objIDataSet.getDictionaryReader();
		ITransferSyntax objITransferSyntax = objIDataSet.getTransferSyntax();

		if(objITransferSyntax.getVRTransferSyntax()==DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(iGroupNumber,iElementNumber,objValue,objITransferSyntax,objIDictionaryReader);
		else
			objIDataElement = new ExplicitDE(iGroupNumber,iElementNumber,iVR,objValue,objITransferSyntax,objIDictionaryReader);
		objIDataSet.addDataElement(objIDataElement);
	}
}
