+// ---- The user will never have to take any action on the following ----.
+ // new value for 'SOP Instance UID'
+ SetMandatoryEntry(0x0008,0x0018,Util::CreateUniqueUID());
+
+ // Instance Creation Date
+ CopyMandatoryEntry(0x0008,0x0012,Util::GetCurrentDate().c_str());
+
+ // Instance Creation Time
+ CopyMandatoryEntry(0x0008,0x0013,Util::GetCurrentTime().c_str());
+
+// ----- Add Mandatory Entries if missing ---
+// Entries whose type is 1 are mandatory, with a mandatory value
+// Entries whose type is 1c are mandatory-inside-a-Sequence
+// Entries whose type is 2 are mandatory, with a optional value
+// Entries whose type is 2c are mandatory-inside-a-Sequence
+// Entries whose type is 3 are optional
+
+ // 'Serie Instance UID'
+ // Keep the value if exists
+ // The user is allowed to create his own Series,
+ // keeping the same 'Serie Instance UID' for various images
+ // The user shouldn't add any image to a 'Manufacturer Serie'
+ // but there is no way no to allowed him to do that
+ CheckMandatoryEntry(0x0020,0x000e,Util::CreateUniqueUID());
+
+ // 'Study Instance UID'
+ // Keep the value if exists
+ // The user is allowed to create his own Study,
+ // keeping the same 'Study Instance UID' for various images
+ // The user may add images to a 'Manufacturer Study',
+ // adding new series to an already existing Study
+ CheckMandatoryEntry(0x0020,0x000d,Util::CreateUniqueUID());
+
+ // Modality : if missing we set it to 'OTher'
+ CheckMandatoryEntry(0x0008,0x0060,"OT");
+
+ // Manufacturer : if missing we set it to 'GDCM Factory'
+ CheckMandatoryEntry(0x0008,0x0070,"GDCM Factory");
+
+ // Institution Name : if missing we set it to 'GDCM Hospital'
+ CheckMandatoryEntry(0x0008,0x0080,"GDCM Hospital");
+
+ // Patient's Name : if missing, we set it to 'GDCM^Patient'
+ CheckMandatoryEntry(0x0010,0x0010,"GDCM^Patient");
+
+ // Patient's Birth Date : 'type 2' entry -> must exist, value not mandatory
+ CheckMandatoryEntry(0x0010,0x0030,"");
+
+ // Patient's Sex :'type 2' entry -> must exist, value not mandatory
+ CheckMandatoryEntry(0x0010,0x0040,"");
+
+ // Referring Physician's Name :'type 2' entry -> must exist, value not mandatory
+ CheckMandatoryEntry(0x0008,0x0090,"");
+
+ // Pixel Spacing : defaulted to 1.0\1.0
+ CheckMandatoryEntry(0x0028,0x0030,"1.0\\1.0");
+
+ // Remove some inconstencies (probably some more will be added)
+
+ // if (0028 0008)Number of Frames exists
+ // Push out (0020 0052),Frame of Reference UID
+ // (only meaningfull within a Serie)
+ DataEntry *e_0028_0008 = FileInternal->GetDataEntry(0x0028, 0x0008);
+ if ( !e_0028_0008 )
+ {
+ Archive->Push(0x0020, 0X0052);
+ }
+}
+
+void FileHelper::CheckMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+{
+ DataEntry *entry = FileInternal->GetDataEntry(group,elem);
+ if ( !entry )
+ {
+ entry = new DataEntry(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
+ entry->SetString(value);
+ Archive->Push(entry);
+ }
+}
+
+void FileHelper::SetMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+{
+ DataEntry *entry = new DataEntry(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
+ entry->SetString(value);
+ Archive->Push(entry);
+}
+
+void FileHelper::CopyMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+{
+ DataEntry *entry = CopyDataEntry(group,elem);
+ entry->SetString(value);
+ Archive->Push(entry);
+}
+
+/**
+ * \brief Restore in the File the initial group 0002
+ */
+void FileHelper::RestoreWriteMandatory()
+{
+ // group 0002 may be pushed out for ACR-NEMA writting purposes
+ Archive->Restore(0x0002,0x0000);
+ Archive->Restore(0x0002,0x0001);
+ Archive->Restore(0x0002,0x0002);
+ Archive->Restore(0x0002,0x0003);
+ Archive->Restore(0x0002,0x0010);
+ Archive->Restore(0x0002,0x0012);
+ Archive->Restore(0x0002,0x0013);
+ Archive->Restore(0x0002,0x0016);
+ Archive->Restore(0x0002,0x0100);
+ Archive->Restore(0x0002,0x0102);
+
+ Archive->Restore(0x0008,0x0012);
+ Archive->Restore(0x0008,0x0013);
+ Archive->Restore(0x0008,0x0016);
+ Archive->Restore(0x0008,0x0018);
+ Archive->Restore(0x0008,0x0060);
+ Archive->Restore(0x0008,0x0070);
+ Archive->Restore(0x0008,0x0080);
+ Archive->Restore(0x0008,0x0090);
+ Archive->Restore(0x0008,0x2112);
+
+ Archive->Restore(0x0010,0x0010);
+ Archive->Restore(0x0010,0x0030);
+ Archive->Restore(0x0010,0x0040);
+
+ Archive->Restore(0x0020,0x000d);
+ Archive->Restore(0x0020,0x000e);
+