OHIF-v3: How do I use hanging protocol addCustomAttribute()

Has anyone successfully added a custom attribute using addCustomAttribute()?

Describe Your Question

  • The init() fails to complete running when trying to add a custom attribute. As seen here: Hanging Protocol Service | OHIF

  • Which OHIF version you are using? OHIV-v3 (v3-stable branch)

What steps can we follow to reproduce the bug?

  1. Add init() function to modeFactory()
  2. Add code to addCustomAttribute in the init()
  3. Reload OHIF

I’ve added the following code to an init.js file and include it in my init() in index.js that runs the modeFactory() function:

export default async function init({
  DicomMetadataStore,
  HangingProtocolService,
 
}) {
   
  const onSeriesAdded = ({ StudyInstanceUID }) => {
    const studyMetadata = DicomMetadataStore.getStudy(StudyInstanceUID);

    // Adding custom attribute to the hangingprotocol
    HangingProtocolService.addCustomAttribute(
      'timepointId',
      'timepointName',
      studyMetadata => studyMetadata.StudyDate
    );
 
    HangingProtocolService.run(studyMetadata);
  };

  DicomMetadataStore.subscribe(
    DicomMetadataStore.EVENTS.SERIES_ADDED,
    onSeriesAdded
  );
}

Here is the above function being called in the modeFactory():

  init: async ({ servicesManager }) => {
          const {
            DicomMetadataStore,
            HangingProtocolService,
          } = servicesManager.services;
 
          await init({
            DicomMetadataStore,
            HangingProtocolService,
          });
},

However the init() fails to complete running. I don’t get an error in the console either.

Has anyone successfully added a custom attribute using addCustomAttribute()?

I’ve read the docs and it is of very little help - I’m using the code snippet that was provided on the page and tested that there are no syntax or copy-paste error and it still won’t run correctly.

Here are the docs I’m using: