interface DicomElementArray extends Array < DicomElement > { [ index ] : DicomElement ; } interface IDicomDatasetService { getElement ( tagValue ) : DicomElement ; getElements ( ) : DicomElement [ ] ; getSourceDataset ( ) ; } class DicomElementsCache { private elementsArray : { } ; private elements : Array < DicomElement > ; constructor ( ) { this . elementsArray = { } ; this . elements = [ ] ; } public addElement ( element ) { this . elementsArray [ element . Tag . StringValue ] = element ; } public getElement ( tagValue ) { var element = this . elementsArray [ DicomTag . getStringValue ( tagValue ) ] ; if ( element ) { return element ; } return null ; } public getAllElements ( ) { var vals = Object . keys ( this . elementsArray ) . map ( ( key ) => { return this . elementsArray [ key ] ; } ) ; return vals ; } } class DicomDatasetService { static fromDateString ( dateString ) { return new Date ( dateString ) ; } static fromDate ( date ) { return date . toString ( ) ; } } class JsonDicomDatasetService extends DicomDatasetService implements IDicomDatasetService { private _dataSource : { } ; private _cache : DicomElementsCache ; constructor ( ) { super ( ) ; this . _dataSource = { } ; this . _cache = new DicomElementsCache ( ) ; } public setModel ( jsonDicom ? ) { this . _dataSource = jsonDicom ; } public getElement ( tagValue ) { var element ; if ( ( element = this . _cache . getElement ( tagValue ) ) != null ) { return element ; } else { var dicomTag = new DicomTag ( tagValue ) ; var jsonElement = this . _dataSource [ dicomTag . StringValue ] ; element = new DicomElement ( ) ; if ( jsonElement ) { element . Value = jsonElement . Value ; element . VR = jsonElement . vr ; } element . Tag = dicomTag ; this . _cache . addElement ( element ) ; return element ; } } public getElements ( ) { for ( var tagValue in this . _dataSource ) { if ( ! this . _cache [ tagValue ] ) { this . _cache . addElement ( this . getElement ( parseInt ( tagValue , 16 ) ) ) ; } } return this . _cache . getAllElements ( ) ; } public getSourceDataset ( ) { return this . _dataSource ; } }