00001 /* 00002 * 00003 * Copyright (C) 2003-2005, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmdata 00019 * 00020 * Author: Michael Onken 00021 * 00022 * Purpose: Class for modifying DICOM files 00023 * 00024 * Last Update: $Author: meichel $ 00025 * Update Date: $Date: 2005/12/08 15:46:50 $ 00026 * CVS/RCS Revision: $Revision: 1.16 $ 00027 * Status: $State: Exp $ 00028 * 00029 * CVS/RCS Log at end of file 00030 * 00031 */ 00032 00033 #ifndef MDFDSMAN_H 00034 #define MDFDSMAN_H 00035 00036 #include "dcmtk/config/osconfig.h" // make sure OS specific configuration is included first 00037 #include "dcmtk/dcmdata/dctagkey.h" 00038 #include "dcmtk/dcmdata/dcfilefo.h" 00039 #include "dcmtk/ofstd/ofcond.h" 00040 #include "dcmtk/ofstd/oflist.h" 00041 #include "dcmtk/ofstd/ofcmdln.h" 00042 #include "dcmtk/dcmdata/dcvrat.h" 00043 00048 class MdfDatasetManager 00049 { 00050 public: 00054 MdfDatasetManager(const OFBool debug=OFFalse); 00055 00058 ~MdfDatasetManager(); 00059 00066 OFCondition loadFile(const char *file_name, 00067 const E_FileReadMode readMode=ERM_autoDetect, 00068 const E_TransferSyntax xfer=EXS_Unknown); 00069 00079 OFCondition modifyOrInsertTag(OFString tag_path, 00080 const OFString &value, 00081 const OFBool &only_modify, 00082 const OFBool update_metaheader=OFTrue); 00083 00092 OFCondition modifyAllTags(OFString tag_path, 00093 const OFString &value, 00094 const OFBool update_metaheader, 00095 int &count); 00096 00103 OFCondition deleteTag(OFString tag_path, 00104 const OFBool &all_tags); 00105 00109 OFCondition generateNewStudyUID(); 00110 00114 OFCondition generateNewSeriesUID(); 00115 00121 OFCondition generateNewInstanceUID(); 00122 00135 OFCondition saveFile(const char *file_name, 00136 E_TransferSyntax opt_xfer = EXS_Unknown, 00137 E_EncodingType opt_enctype = EET_UndefinedLength, 00138 E_GrpLenEncoding opt_glenc = EGL_recalcGL, 00139 E_PaddingEncoding opt_padenc = EPD_noChange, 00140 OFCmdUnsignedInt opt_filepad = 0, 00141 OFCmdUnsignedInt opt_itempad = 0, 00142 OFBool opt_dataset = OFFalse); 00143 00148 OFCondition saveFile(); 00149 00156 DcmDataset* getDataset(); 00157 00158 00165 DcmFileFormat* getFileFormat(); 00166 00170 OFString getFilename() const; 00171 00172 00173 protected: 00174 00180 OFCondition startModify(DcmElement *elem, const OFString &value); 00181 00188 OFCondition startInsert(DcmItem *item, DcmTagKey &search_key, 00189 const OFString &value); 00190 00197 void deleteRelatedMetaheaderTag(const DcmTagKey &key); 00198 00205 OFCondition hasValidGroupNumber(const DcmTagKey &key); 00206 00211 OFBool isPrivateTag(const DcmTagKey &tag_key); 00212 00218 OFBool isPrivateReservationTag(const DcmTagKey &tag_key); 00219 00227 OFBool hasPrivateReservationContext(const DcmTagKey &tag_key, 00228 DcmItem *item, 00229 OFString &priv_creator); 00230 00236 DcmTagKey calcPrivateReservationTag(const DcmTagKey &tag_key); 00237 00242 OFBool isTagInDictionary(const DcmTagKey &search_key); 00243 00251 void debugMsg(const OFBool &condition, 00252 const OFString &s1, 00253 const OFString &s2, 00254 const OFString &s3); 00255 00257 OFString act_file; 00259 DcmFileFormat *dfile; 00261 DcmDataset *dset; 00263 OFBool debug_option; 00264 00265 private: 00266 00269 MdfDatasetManager &operator=(const MdfDatasetManager &); 00270 00273 MdfDatasetManager(const MdfDatasetManager &); 00274 00275 }; 00276 00277 #endif //MDFDSMAN_H 00278 00279 /* 00280 ** CVS/RCS Log: 00281 ** $Log: mdfdsman.h,v $ 00282 ** Revision 1.16 2005/12/08 15:46:50 meichel 00283 ** Updated Makefiles to correctly install header files 00284 ** 00285 ** Revision 1.15 2005/12/02 09:21:47 joergr 00286 ** Added new file read mode that makes it possible to distinguish between DICOM 00287 ** files, datasets and other non-DICOM files. For this reason, the last 00288 ** parameter of method loadFile() changed from OFBool to E_FileReadMode. 00289 ** 00290 ** Revision 1.14 2005/11/30 16:41:41 onken 00291 ** Added standard parameter values for saveFile() 00292 ** 00293 ** Revision 1.13 2005/11/14 15:00:14 joergr 00294 ** Made method getFilename() const. 00295 ** 00296 ** Revision 1.12 2004/11/05 17:17:24 onken 00297 ** Added input and output options for dcmodify. minor code enhancements. 00298 ** 00299 ** Revision 1.11 2004/10/22 16:53:26 onken 00300 ** - fixed ignore-errors-option 00301 ** - major enhancements for supporting private tags 00302 ** - removed '0 Errors' output 00303 ** - modifications to groups 0000,0001,0002,0003,0005 and 0007 are blocked, 00304 ** removing tags with group 0001,0003,0005 and 0007 is still possible 00305 ** - UID options: 00306 ** - generate new study, series and instance UIDs 00307 ** - When changing UIDs in dataset, related metaheader tags are updated 00308 ** automatically 00309 ** - minor code improvements 00310 ** 00311 ** Revision 1.10 2004/05/14 12:08:36 onken 00312 ** Additional documentation added. 00313 ** 00314 ** Revision 1.9 2004/04/19 14:45:07 onken 00315 ** Restructured code to avoid default parameter values for "complex types" like 00316 ** OFString. Required for Sun CC 2.0.1. 00317 ** 00318 ** Revision 1.8 2003/12/17 17:07:22 onken 00319 ** MdfDatasetManager now remembers loaded filename. Additional save function 00320 ** added. 00321 ** 00322 ** Revision 1.7 2003/12/10 16:19:20 onken 00323 ** Changed API of MdfDatasetManager, so that its transparent for user, whether 00324 ** he wants to modify itemtags or tags at 1. level. 00325 ** 00326 ** Complete rewrite of MdfConsoleEngine. It doesn't support a batchfile any more, 00327 ** but now a user can give different modify-options at the same time on 00328 ** commandline. Other purifications and simplifications were made. 00329 ** 00330 ** Revision 1.6 2003/11/11 10:55:51 onken 00331 ** - debug-mechanism doesn't use debug(..) any more 00332 ** - comments purified 00333 ** - headers adjustet to debug-modifications 00334 ** 00335 ** Revision 1.5 2003/10/13 14:46:50 onken 00336 ** startModify(...) simplified (uses only putString to put element-values), 00337 ** this also allows now inserting and modifying of elements with VRM>1. 00338 ** Method getDataset() added. 00339 ** 00340 ** Revision 1.4 2003/10/01 14:04:03 onken 00341 ** Corrected doxygen-information in headerfiles 00342 ** 00343 ** Revision 1.3 2003/09/19 12:41:11 onken 00344 ** major bugfixes, new code structure, better error-handling, corrections for "dcmtk-coding-style",Handling of VR's corrected 00345 ** 00346 ** Revision 1.2 2003/07/09 12:13:13 meichel 00347 ** Included dcmodify in MSVC build system, updated headers 00348 ** 00349 ** Revision 1.1 2003/06/26 09:17:18 onken 00350 ** Added commandline-application dcmodify. 00351 ** 00352 ** 00353 */