fw4spl
fwMedDataTools/src/fwMedDataTools/functions.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwMedDataTools/functions.hpp"
8 
9 // Skip this for now on Android, this allows us to get rid of GDCM
10 #ifndef ANDROID
11 
12 #include <gdcmUIDGenerator.h>
13 
14 #include <boost/date_time/posix_time/posix_time.hpp>
15 
16 #include <sstream>
17 #include <string>
18 
19 namespace fwMedDataTools
20 {
21 
22 std::string generatePatientId()
23 {
24  ::gdcm::UIDGenerator uid;
25  const char* id = uid.Generate();
26  return std::string(id);
27 }
28 
30 {
31  using namespace ::boost::posix_time;
32 
33  ptime now = microsec_clock::local_time();
34  time_facet* facet = new time_facet("%f%S%M%H%d%m");
35 
36  std::stringstream ss;
37  ss.imbue(std::locale(ss.getloc(), facet));
38  ss << now;
39 
40  return ss.str();
41 }
42 
43 } // namespace fwMedDataTools
44 
45 #endif // ANDROID
FWMEDDATATOOLS_API std::string generateStudyInstanceUid()
Generates a random Dicom Study Instance UID using current time. It must be 16 char long and may be nu...
FWMEDDATATOOLS_API std::string generatePatientId()
Generates a random Dicom Patient ID using GDCM. It must be at most 64 char long and non null...
Contains utilities dedicated to fwMedData.