Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(date formatting): Show study date as a fallback for an empty series date and show 'No Study Date' as a back up for both #3483

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import PropTypes from 'prop-types';
import { utils } from '@ohif/core';
import {
Expand Down Expand Up @@ -31,6 +32,8 @@ function PanelStudyBrowserTracking({
uiNotificationService,
} = servicesManager.services;

const { t } = useTranslation('Common');

// Normally you nest the components so the tree isn't so deep, and the data
// doesn't have to have such an intense shape. This works well enough for now.
// Tabs --> Studies --> DisplaySets --> Thumbnails
Expand Down Expand Up @@ -134,7 +137,7 @@ function PanelStudyBrowserTracking({
const actuallyMappedStudies = mappedStudies.map(qidoStudy => {
return {
studyInstanceUid: qidoStudy.StudyInstanceUID,
date: formatDate(qidoStudy.StudyDate),
date: formatDate(qidoStudy.StudyDate) || t('NoStudyDate'),
description: qidoStudy.StudyDescription,
modalities: qidoStudy.ModalitiesInStudy,
numInstances: qidoStudy.NumInstances,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function TrackedCornerstoneViewport(props) {
viewportOptions,
} = props;

const { t } = useTranslation('TrackedViewport');
const { t } = useTranslation('Common');

const {
measurementService,
Expand Down Expand Up @@ -54,6 +54,7 @@ function TrackedCornerstoneViewport(props) {
PatientAge,
SliceThickness,
SpacingBetweenSlices,
StudyDate,
ManufacturerModelName,
} = displaySet.images[0];

Expand Down Expand Up @@ -194,7 +195,8 @@ function TrackedCornerstoneViewport(props) {
getStatusComponent={() => _getStatusComponent(isTracked)}
studyData={{
label: viewportLabel,
studyDate: formatDate(SeriesDate), // TODO: This is series date. Is that ok?
studyDate:
formatDate(SeriesDate) || formatDate(StudyDate) || t('NoStudyDate'),
currentSeries: SeriesNumber, // TODO - switch entire currentSeries to be UID based or actual position based
seriesDescription: SeriesDescription,
patientInformation: {
Expand Down
3 changes: 2 additions & 1 deletion platform/core/src/utils/formatDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ import moment from 'moment';
* @returns {string} Formatted date
*/
export default (date, format = 'DD-MMM-YYYY') => {
return moment(date).format(format);
// moment(undefined) returns the current date, so return the empty string instead
return date ? moment(date).format(format) : '';
wayfarer3130 marked this conversation as resolved.
Show resolved Hide resolved
};
1 change: 1 addition & 0 deletions platform/i18n/src/locales/en-US/Common.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"Measurements": "Measurements",
"More": "More",
"Next": "Next",
"NoStudyDate": "No Study Date",
"Play": "Play",
"Previous": "Previous",
"Reset": "Reset",
Expand Down