Metadata in BoxDicom - Microsoft Technologies, Azure and .net Tutorials

Latest

Sunday, April 2, 2023

Metadata in BoxDicom

 Metadata in BoxDicom

In BoxDICOM, metadata refers to additional information that can be associated with a file or folder. Metadata in BoxDICOM is used to provide context and additional information about the file or folder, such as the author, creation date, keywords, and other relevant details.

There are several uses for metadata in BoxDICOM:

Search: Metadata can be used to help users find specific files or folders by providing additional information about them. For example, a user can search for all files with a certain keyword or all files created by a specific author.

Organization: Metadata can be used to organize files and folders in BoxDICOM. For example, a user can group all files related to a specific patient or study by using metadata to tag them accordingly.

Collaboration: Metadata can be used to facilitate collaboration and communication between users. For example, a user can add comments or notes to a file or folder to provide additional context or instructions for other users.

Compliance: Metadata can be used to ensure compliance with regulatory or organizational requirements. For example, metadata can be used to track and document the use of certain types of data, such as personal health information.

BoxDICOM allows users to add custom metadata fields to files and folders, as well as to view and edit existing metadata. This enables users to tailor the metadata to their specific needs and workflows, and to ensure that the metadata accurately reflects the content and context of the files and folders.

Here we will see how to add Folder Metadata in BoxDciom

using Box.V2;

using Box.V2.Exceptions;

using Box.V2.Models;

using Box.V2.Models.Request;

string boxConfig; // read box config file and assign it

BoxJwt boxJwt = new BoxJwt(jsonString);

boxJwt.BoxUserClient = boxJwt.GetBoxUserClient(“UserId”); // UserId is               optional

BoxFolder folder;

try

{

  var boxFolderRequest = new BoxFolderRequest()

  {

      Name = FolderName,

      Parent = new BoxRequestEntity()

      {

       Id = ParentFolderId

      }, 

   }; 

boxFolder = await boxJwt.BoxUserClient.FoldersManager.CreateAsync(boxFolderRequest); 

}

catch (BoxConflictException<BoxFolder> ex)

{

  boxFolder = ex.ConflictingItems.FirstOrDefault(x => x.Name == FolderName);

} 


Here we will first check Folder Metadata present or not 


string sFolderId= boxFolder.Id; 

bool bMetadataFound = false;

try

{

var folderMetadata = await        boxJwt.BoxUserClient.MetadataManager.GetFolderMetadataAsync(sFolderId, "enterprise", "DICOM"); 

  if (folderMetadata != null)

  {

    bMetadataFound = true;

  }

}

catch (BoxException)

{

  bMetadataFound = false;

}

 

// If Metadata not found we will create the metadata of the Folder


if (bFound == false)

{

  Dictionary<string, object> metadatafields = new Dictionary<string, object>()

  {

      {"foldername", "TestFolder" },

      {"description", "Test" }

  };

 

var metadata = await     boxJwt.BoxUserClient.MetadataManager.CreateFolderMetadataAsync(sFolderId, metadatafields, "enterprise", "DICOM");

}


// If metadata found we will update the metadata of the folder


else

{

  Dictionary<string, object> updatemetadata = new Dictionary<string, object>()

  {

      {"foldername", "TestingFolder" },

      {"description", "Testing" },

{"purpose", "Testing" } 

  };

var updated = await boxJwt.BoxUserClient.MetadataManager.UpdateFolderMetadataAsync(sFolderId, updatemetadata, "enterprise", "DICOM"); 

} 


// How to delete folder metadata 


bool deleted = await boxJwt.BoxUserClient.MetadataManager.DeleteFolderMetadataAsync(sFolderId, "enterprise", "DICOM"); 


// how to search through Metadata 


var searchFolder = await boxJwt.BoxUserClient.SearchManager.SearchAsync(keyword: {"foldername", ancestorFolderIds: new List<string>() { parentFolderId }, type: "folder",mdFilters: new List<BoxMetadataFilterRequest>() { new BoxMetadataFilterRequest() { Filters = new { {"foldername" = "TestingFolder" }, Scope = "enterprise", TemplateKey = "DICOM" } });

No comments:

Post a Comment

Metadata in BoxDicom

  Metadata in BoxDicom In BoxDICOM, metadata refers to additional information that can be associated with a file or folder. Metadata in Bo...