{{{ readme }}} /** * The revision of the data dictionary spec, eg. "2014a". */ export const revision: string = '{{revision}}'; /** * Maps DICOM element keywords to their tag "(gggg,eeee)" */ export const tags: KeywordsMap = { {{#each tags}} {{ this.[0] }}: '{{ this.[1] }}', {{/each}} }; /** * Maps DICOM tags to DICOM element objects. */ export const elements: ElementsMap = { {{#each elements}} '{{ this.tag }}': { tag: `{{ this.tag }}`, name: `{{ this.name }}`, keyword: `{{ this.keyword }}`, vr: `{{ this.vr }}`, vm: `{{ this.vm }}`, note: `{{ this.note }}`, isRetired: {{ this.isRetired }}, }, {{/each}} }; /** * Get a DICOM Data Element either by tag or keyword. * * Tags in the following forms are accepted: * * (gggg,eeee) * gggg,eeee * (ggggeeee) * ggggeeee * * @param key {string} * * @returns the DICOM Data Element if it exists; undefined otherwise */ export const get_element = (key: string): DicomDataElement | undefined => { const fullTagRegex = /^\([0-9ABCDEFx]{4},[0-9ABCDEFx]{4}\)$/; const shortTagRegex = /([0-9ABCDEFx]{4})[,]?([0-9ABCDEFx]{4})/; if (fullTagRegex.test(key)) return elements[key]; else { const [, g, e] = shortTagRegex.exec(key) || []; if (g && e) return elements[`(${g},${e})`]; else { // Try to get tag from keyword const tag = tags[key]; if (tag) return elements[tag]; else return undefined; } } }; /** * "A Data Element Tag is represented as "(gggg,eeee)", where gggg equates to the Group Number and * eeee equates to the Element Number within that Group. Data Element Tags are represented in * hexadecimal notation as specified for each named Data Element in this Standard." */ export type DicomTag = string; /** * Maps a DICOM data element's keyword to its tag "(gggg,eeee)". */ export interface KeywordsMap { [key: string]: DicomTag; } /** * Maps DICOM tags "(gggg,eeee)" to full DICOM data elements. */ export interface ElementsMap { [key: string]: DicomDataElement; } /** * Represents a single DICOM Data Element as defined in DICOM PS3.6. */ export interface DicomDataElement { /** * See the Tag type for details. */ tag: DicomTag; /** * Full name of the DICOM element. */ name: string; /** * The element name with all whitespace removed. */ keyword: string; /** * Value Representation. */ vr: string; /** * Value Multiplicity. */ vm: string; /** * Miscellaneous notes about the element. */ note: string; /** * True if the element is considered retired; see the note for * the year that the element was retired (if applicable). */ isRetired: boolean; }