Saving and retrieval of annotation/measurement data in json format

How can i save annotation/measurements to my backend and and retrieve it (in json preferrably) to be rendered back on the dicom in the viewer? Is there any better or easier way to achieve this?

  • I am able to save the annotation data to my backend from the MeasurementService.ts file. But when i load this json back and pass the params to the annotationToMeasurement() method in MeasurementService, it throws errors like - source undefined and no mappings present. Any pointers or references to make this work would be really appreciated.

  • Version : Viewers-3.8.0-beta.81

  • Below is how the code hydrateAnnotations looks like.

 hydrateAnnotations(): void {
  
    axios
      .get('http://localhost:9191/dicom/get-measurement')
      .then(response => {
        const annotations = response.data;
        log.info('json: ', response.data);

        annotations.measurementList.forEach(annotation => {
          try {
            this.annotationToMeasurement(
              annotation.source,
              // this.createSource(annotation.source.name, annotation.source.version),
              annotation.toolName,
              annotation,
              false
            );
          } catch (error) {
            console.error('Failed to add annotation to viewer:', error);
          }
        });
      })
      .catch(error => {
        console.error('Error fetching data:', error);
      });
  }