private void UpdateEntity(ServerEntity entity)
{
EntityDicomMap entityMap = EntityDicomMapManager.Get(entity.GetType());
foreach (BaseImageLevelUpdateCommand command in _commands)
{
ImageLevelUpdateEntry entry = command.UpdateEntry;
if (!entityMap.ContainsKey(entry.TagPath.Tag))
continue;
string value = entry.GetStringValue();
DicomTag tag = entry.TagPath.Tag;
if (tag.TagValue == DicomTags.PatientsSex)
{
// Valid Patient's Sex value : "M", "F" or "O"
if (!String.IsNullOrEmpty(value) && !value.ToUpper().Equals("M") && !value.ToUpper().Equals("F"))
value = "O";
}
int maxLength = tag.VR.Equals(DicomVr.PNvr) ? 64 : (int)tag.VR.MaximumLength;
if (value != null && value.Length > maxLength)
{
Platform.Log(LogLevel.Warn, "Truncating value to VR Length: {0}: {1}", tag.VR.Name, value);
if (!entityMap.Populate(entity, entry.TagPath.Tag, value.Substring(0, maxLength)))
throw new ApplicationException(String.Format("Unable to update {0}. See log file for details.", entity.Name));
}
else
{
if (!entityMap.Populate(entity, entry.TagPath.Tag, value))
throw new ApplicationException(String.Format("Unable to update {0}. See log file for details.", entity.Name));
}
}
}