#pragma once



#include "common.h"
#include "SDCMCommonStructure.h"

#include "dcmtk/dcmdata/dcdatset.h"


class CSDCMImage
{
public:
	CSDCMImage(void);
	virtual ~CSDCMImage(void);

    virtual int WriteDCM(OFString strInputImageFile, OFString strDcmFilename, WorklistResponseData* pWorklistData, int nSeriesNumber, int nImageNumber, BOOL bChangeUID, OFString strNewStudyInstanceUID);
    virtual int WriteDCM(QString strInputImageFile, QString strDcmFilename, WorklistResponseData* pWorklistData, int nSeriesNumber, int nImageNumber, BOOL bChangeUID, QString strNewStudyInstanceUID);

    virtual int WriteDCM(OFString strInputImageFile, OFString strDcmFilename, WorklistResponseData* pWorklistData, int nSeriesNumber, int nImageNumber, BOOL bChangeUID, OFString strNewStudyInstanceUID, BOOL bUsePDFCompress);


    virtual int WriteDCM(OFString strInputImageFile, OFString strDcmFilename, OFString strContentDate, OFString strContentTime, WorklistResponseData* pWorklistData, int nSeriesNumber, int nImageNumber, BOOL bChangeUID, OFString strNewStudyInstanceUID);

    virtual int WriteDCM(QString strInputImageFile, QString strDcmFilename, QString strContentDate, QString strContentTime, WorklistResponseData* pWorklistData, int nSeriesNumber, int nImageNumber, BOOL bChangeUID, QString strNewStudyInstanceUID);

	void SetTransferSyntax(E_TransferSyntax nTransferSyntax);	

    static SDCM_AGE ComputeAge(QString strBirthdate);

    void LoadImage(OFString strFilename, BOOL bGray);
    void LoadImage(QString strFilename, BOOL bGray);

    int LoadDCMFile(OFString strFilename);

	void RegisterPrivateTags();
	void AddPrivateElements(DcmItem &item, OFString strFileLocation);

    OFCondition PutAndInsertString(DcmDataset* pDcmDataset, const DcmTag &tag, QString strValue);
	OFCondition PutAndInsertString(DcmDataset* pDcmDataset, const DcmTag &tag, const char *value);
	OFCondition PutAndInsertString(DcmDataset* pDcmDataset, const DcmTag &tag, OFString strValue);	
	
	

	void InsertCreationDate(DcmDataset* pDcmDataset);
	void InsertCreationTime(DcmDataset* pDcmDataset);

    QString GetCurrentDate();
    QString GetCurrentTime();

	virtual void WritePatientInfo(DcmDataset* pDcmDataset, WorklistResponseData* pWorklistData);
    virtual void WriteStudyInfo(DcmDataset* pDcmDataset, WorklistResponseData* pWorklistData, int nSeriesNumber, int nImageNumber, BOOL bChangeUID=FALSE, OFString strNewStudyInstanceUID="");
    virtual void WriteStudyInfo(DcmDataset* pDcmDataset, WorklistResponseData* pWorklistData, int nSeriesNumber, int nImageNumber, BOOL bChangeUID=FALSE, QString strNewStudyInstanceUID="");
	virtual void WriteLaterality(DcmDataset* pDcmDataset, OFString strLaterality, OFString strImageLaterality);
    virtual void WriteLaterality(DcmDataset* pDcmDataset, QString strLaterality, QString strImageLaterality);
	virtual void WriteImageType(DcmDataset* pDcmDataset, OFString strImageType="");
    virtual void WriteImageType(DcmDataset* pDcmDataset, QString strImageType="");
	virtual void WriteImageInfo(DcmDataset* pDcmDataset, WorklistResponseData* pWorklistData, int nImageNumber);
    virtual void WriteImageInfo(DcmDataset* pDcmDataset, OFString strContentDate, OFString strContentTime, WorklistResponseData* pWorklistData, int nImageNumber);
    virtual void WriteImageInfo(DcmDataset* pDcmDataset, QString strContentDate, QString strContentTime, WorklistResponseData* pWorklistData, int nImageNumber);
    virtual void WriteScheduledProcedureStep(DcmDataset* pDcmDataset, WorklistResponseData* pWorklistData);

	virtual void WriteDeviceInfo(DcmDataset* pDcmDataset);

	virtual void WriteDateTime(DcmDataset* pDcmDataset, WorklistResponseData* pWorklistData);

    OFString CreateStudyInstanceUID();

	//void SetStrEncType(STRENC_TYPE strEnc);

	void CharacterSetConversion(DcmDataset* pDcmDataset);

    list<OFString>* GetListInputFile();

public:
    list<OFString>* m_pListInputFile;
    OFString m_strDcmOutputFilename;
	WorklistResponseData* m_pWorklistData;
	int m_nSeriesNumber;
	int m_nImageNumber;
	BOOL m_bChangeUID;
    OFString m_strNewStudyInstanceUID;
	BOOL m_bUsePDFCompress;

    OFString m_strImplementationClassUID;
    OFString m_strImplementationVersionName;

	//STRENC_TYPE m_StrEncType;

protected:	
	int m_nWidth;
	int m_nHeight;
    uint8_t* m_pData;

	int m_nWindowWidth;
	int m_nWindowLevel;
    OFString m_strFilename;

	int m_nInputFileFormat;
	int m_nOutputFileFormat;

    OFString m_strLoadFilename;

	E_TransferSyntax m_TransferSyntaxOutput;




	
};

