Attached is an example project which saves and loads annotation to a custom database through the MedicalWorkstationViewer. The "custom database" in this example is actually just a text file that gets created in C:\mockDatabase. The reason I implemented the example this way was to demonstrate (in a generic way) what information needs to be stored and retrieved from your database in order to use your own database with the WorkstationViewer.
Here is a general overview of what is going on:
*NOTE* the use of the word "annotations" (plural) in the context of this description is referring to annotation files (which can
contain multiple annotation objects) -- not individual annotation objects on the image.
The annotation load button of the workstation will not be activated if the workstation does not find that there are annotations to be
loaded. In order to notify the workstation that there are annotations to be loaded (when you are not using our default database), you must
implement the IWorkstationDataAccessAgent interface. This interface declares many methods (a bunch of which you do not need actually
implement for our purposes, but that you do need to declare in order for this to work). The methods from this interface that you do need
to implement are:
-StoreAnnotationObject()
---This is where you store the location of an annotation file to your database, along with the associated sopInstanceUID and a description
of the annotations.
-GetAnnotationFile()
---This is where you return the location of the annotation file associated with an AnnotationId. The AnnotationID object has 3 members:
a sopInstanceUID, a description, and an object number. The description is what is used to populate the list of available annotations
that can be loaded. The object number specifies that this AnnotationId is the "i'th" annotation for this sopInstanceUID. **NOTE** The
object number needs to be updated (incremented when saving and decremented when deleting from the middle or beginning) for each
sopInstanceUID whenever a save or delete is performed. Also note that this example does not implement the delete method (in your application you would want to implement the delete method such that it removes the specified entry from your custom database).
-GetAnnotationObjectCount()
---This method needs to return the number of annotations associated with sopInstanceUID (provided as an argument to the method).
-DeleteAnnotationObject()
---This is not implemented in the example. Therefore clicking "Delete" or "Delete All" in the annotations menu will result in
unexpected behavior. (To be precise, what will happen is the Workstation will delete the annotation file, but the entry in our textfile
based database will not be deleted). You will want to implement this method so that it removes the relevant information from your
database.
All of the other methods for this interface need to be declared.