diff --git a/Packages/ohif-studies/imports/client/components/browser/item.html b/Packages/ohif-studies/imports/client/components/browser/item.html index 03bb520c6..daf45dd69 100644 --- a/Packages/ohif-studies/imports/client/components/browser/item.html +++ b/Packages/ohif-studies/imports/client/components/browser/item.html @@ -10,8 +10,12 @@
{{studyData.modalities}}
-
{{formatDA studyData.studyDate 'D-MMM-YYYY'}}
-
{{studyData.studyDescription}}
+ {{#if (or isLoaded hasDescriptionAndDate)}} +
{{formatDA studyData.studyDate 'D-MMM-YYYY'}}
+
{{studyData.studyDescription}}
+ {{else}} +
{{#if eq studyAvailable false}}N/A{{else}}Click to load{{/if}}
+ {{/if}}
{{/let}} diff --git a/Packages/ohif-studies/imports/client/components/browser/item.js b/Packages/ohif-studies/imports/client/components/browser/item.js index b9fcbf39f..addbfaac3 100644 --- a/Packages/ohif-studies/imports/client/components/browser/item.js +++ b/Packages/ohif-studies/imports/client/components/browser/item.js @@ -15,6 +15,15 @@ Template.studyBrowserItem.onCreated(() => { instance.studyData = new ReactiveVar(studyInformation); + // Try to load the study data from an external source if available + if (OHIF.studies.getStudyBoxData) { + OHIF.studies.getStudyBoxData(studyInformation).then(studyData => { + if (!instance.loaded.get()) { + instance.studyData.set(studyData); + } + }); + } + instance.studyMetadata = null; instance.getStudyMetadata = () => { instance.loading.dep.depend(); @@ -90,6 +99,11 @@ Template.studyBrowserItem.helpers({ return Template.instance().loaded.get(); }, + hasDescriptionAndDate() { + const studyData = Template.instance().studyData.get(); + return studyData.studyDescription && studyData.studyDate; + }, + isLoading() { return Template.instance().loading.get(); }, diff --git a/Packages/ohif-studies/imports/client/lib/getStudyBoxData.js b/Packages/ohif-studies/imports/client/lib/getStudyBoxData.js new file mode 100644 index 000000000..a82b02e31 --- /dev/null +++ b/Packages/ohif-studies/imports/client/lib/getStudyBoxData.js @@ -0,0 +1,15 @@ +import { OHIF } from 'meteor/ohif:core'; + +/** + * Overridable namespace to allow getting study boxes data externally. + * + * The function must handle the first parameter as a studyInformation object containing at least the + * studyInstanceUid attribute. + * + * Shall return a promise that will be resolved with an object containing those attributes: + * - studyInstanceUid {String}: copy of studyInformation.studyInstanceUid + * - modalities {String}: 2 uppercase letters for each modality split by any non-alphabetical char(s) + * - studyDate {String}: date formatted as YYYYMMDD + * - studyDescription {String}: study description string + */ +OHIF.studies.getStudyBoxData = false; diff --git a/Packages/ohif-studies/imports/client/lib/index.js b/Packages/ohif-studies/imports/client/lib/index.js index 4eb1ddf11..41d2f9f6b 100644 --- a/Packages/ohif-studies/imports/client/lib/index.js +++ b/Packages/ohif-studies/imports/client/lib/index.js @@ -1,4 +1,5 @@ import './classes'; +import './getStudyBoxData'; import './loadStudy'; import './retrieveStudiesMetadata'; import './retrieveStudyMetadata';