@dcmjs-org/dcmjs 1.0.0-beta.23 → 1.0.0-beta.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/dcmjs.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dcmjs = require('./dcmjs.shared-Dkebpbbj.cjs');
5
+ var dcmjs = require('./dcmjs.shared-C91zk0xe.cjs');
6
6
  var core = require('@dcmjs-org/core');
7
7
 
8
8
 
package/build/dcmjs.es.js CHANGED
@@ -1,3 +1,3 @@
1
- export { D as DICOMWEB, j as adapters, k as anonymizer, l as async, m as constants, n as data, o as default, p as derivations, q as normalizers, s as sr, u as utilities } from './dcmjs.shared-DVqSe8G1.js';
1
+ export { D as DICOMWEB, j as adapters, k as anonymizer, l as async, m as constants, n as data, o as default, p as derivations, q as normalizers, s as sr, u as utilities } from './dcmjs.shared-D09Jzvkv.js';
2
2
  export { log } from '@dcmjs-org/core';
3
3
  //# sourceMappingURL=dcmjs.es.js.map
package/build/dcmjs.js CHANGED
@@ -12848,6 +12848,19 @@
12848
12848
  }
12849
12849
  var cache = new Map();
12850
12850
  var nameCache = new Map();
12851
+
12852
+ /** Set by DicomMetaDictionary at load: the entry of an existing keyword. */
12853
+ var keywordLookup = null;
12854
+
12855
+ /**
12856
+ * Set the lookup of existing keywords that registerTag() checks. Injected,
12857
+ * because DicomMetaDictionary imports this module.
12858
+ *
12859
+ * @param {(name: string) => { tag: string } | undefined} fn
12860
+ */
12861
+ function setKeywordLookup(fn) {
12862
+ keywordLookup = fn;
12863
+ }
12851
12864
  function isPrivateTagKey(prop) {
12852
12865
  return typeof prop === "string" && prop.length > 11 && prop.indexOf('"') !== -1;
12853
12866
  }
@@ -12855,6 +12868,79 @@
12855
12868
  // '(0008,0005)' -> '00080005'
12856
12869
  return k.slice(1, 5) + k.slice(6, 10);
12857
12870
  }
12871
+ function _toParenKeyFromHex8(hex8) {
12872
+ // '00080005' -> '(0008,0005)'
12873
+ return "(" + hex8.slice(0, 4) + "," + hex8.slice(4, 8) + ")";
12874
+ }
12875
+
12876
+ /**
12877
+ * Register a tag entry in the cache so it is returned by the dictionary for that tag.
12878
+ * Use for tags not in the standard or private dictionaries.
12879
+ * The tag is stored in upper case, the case that a reader makes, and lookups
12880
+ * accept both cases. The tag of the first argument wins over `entry.tag`.
12881
+ * Name rules (docs/specs/registries.md, REG-U-18 to REG-U-21):
12882
+ * - A name that is an existing keyword of a different tag throws.
12883
+ * - When two tags use one name, the first tag keeps the name and a warning
12884
+ * names both tags. The second tag gets its hex tag as its name, and keeps
12885
+ * its VR and VM.
12886
+ * - A new name for a registered tag replaces the old name.
12887
+ *
12888
+ * @param {string} tagOrHex - Tag as '(GGGG,EEEE)' or 'GGGGEEEE'
12889
+ * @param {{ name: string, vr: string, vm?: string, [key: string]: unknown }} entry - At least name and vr; vm and other fields optional
12890
+ * @returns {void}
12891
+ */
12892
+ function registerTag(tagOrHex, entry) {
12893
+ var _keywordLookup, _entry$version;
12894
+ if (typeof tagOrHex !== "string" || !entry || typeof entry.name !== "string" || typeof entry.vr !== "string") {
12895
+ return;
12896
+ }
12897
+ var parenKey;
12898
+ var hex8;
12899
+ if (tagOrHex.length === 11 && tagOrHex[0] === "(" && tagOrHex[5] === "," && tagOrHex[10] === ")") {
12900
+ parenKey = tagOrHex;
12901
+ hex8 = _toHex8FromParenKey(tagOrHex);
12902
+ } else if (tagOrHex.length === 8) {
12903
+ hex8 = tagOrHex;
12904
+ parenKey = _toParenKeyFromHex8(tagOrHex);
12905
+ } else {
12906
+ return;
12907
+ }
12908
+ var upperHex = hex8.toUpperCase();
12909
+ var lowerHex = hex8.toLowerCase();
12910
+ var tag = _toParenKeyFromHex8(upperHex);
12911
+ var keyword = (_keywordLookup = keywordLookup) === null || _keywordLookup === void 0 ? void 0 : _keywordLookup(entry.name);
12912
+ if (keyword && keyword.tag.toUpperCase() !== tag) {
12913
+ throw new Error("registerTag: name ".concat(entry.name, " is the keyword of ").concat(keyword.tag, "; ") + "".concat(tag, " cannot use it"));
12914
+ }
12915
+ var name = entry.name;
12916
+ var existing = nameCache.get(name);
12917
+ if (existing && existing.tag !== tag) {
12918
+ log.warn("registerTag: name ".concat(name, " already maps to ").concat(existing.tag, "; ") + "".concat(tag, " uses the name ").concat(upperHex));
12919
+ name = upperHex;
12920
+ }
12921
+ var previous = cache.get(upperHex);
12922
+ if (previous && nameCache.get(previous.name) === previous) {
12923
+ nameCache.delete(previous.name);
12924
+ }
12925
+ var cached = _objectSpread2(_objectSpread2({}, entry), {}, {
12926
+ name: name,
12927
+ tag: tag,
12928
+ version: (_entry$version = entry.version) !== null && _entry$version !== void 0 ? _entry$version : "User"
12929
+ });
12930
+ var _iterator = _createForOfIteratorHelper(new Set([upperHex, lowerHex, hex8, parenKey, _toParenKeyFromHex8(upperHex), _toParenKeyFromHex8(lowerHex)])),
12931
+ _step;
12932
+ try {
12933
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
12934
+ var key = _step.value;
12935
+ cache.set(key, cached);
12936
+ }
12937
+ } catch (err) {
12938
+ _iterator.e(err);
12939
+ } finally {
12940
+ _iterator.f();
12941
+ }
12942
+ nameCache.set(name, cached);
12943
+ }
12858
12944
 
12859
12945
  /**
12860
12946
  * Look up a registerTag() entry by its keyword name, so registration is
@@ -14237,7 +14323,7 @@
14237
14323
  /** The dictionary entry of a keyword, a registerTag() keyword or a hex tag. */
14238
14324
  function entryFor(key) {
14239
14325
  if (isHexTag(key)) return registeredTagEntry(key);
14240
- return DicomMetaDictionary.nameMap[key] || lookupRegisteredTagByName(key);
14326
+ return DicomMetaDictionary.entryForName(key);
14241
14327
  }
14242
14328
 
14243
14329
  /**
@@ -14404,6 +14490,11 @@
14404
14490
  // a list, as for VM > 1
14405
14491
  return ValueRepresentation$1.addValueAccessorsFor(data.vr, simpleValue(values, valueLength(entry)));
14406
14492
  }
14493
+
14494
+ /** The own entry of `name`, so `constructor` and other prototype keys miss. */
14495
+ function ownEntry(nameMap, name) {
14496
+ return Object.prototype.hasOwnProperty.call(nameMap, name) ? nameMap[name] : undefined;
14497
+ }
14407
14498
  var DicomMetaDictionary = /*#__PURE__*/function () {
14408
14499
  // intakes a custom dictionary that will be used to parse/denaturalize the dataset
14409
14500
  function DicomMetaDictionary(customDictionary) {
@@ -14454,10 +14545,26 @@
14454
14545
  var integerValue = parseInt("0x" + DicomMetaDictionary.unpunctuateTag(tag));
14455
14546
  return integerValue;
14456
14547
  }
14548
+
14549
+ /**
14550
+ * The dictionary entry of a keyword: a standard keyword from `nameMap`
14551
+ * first, then a registerTag() name. registerTag() names are kept out of
14552
+ * the shared nameMap, so a read never changes global state.
14553
+ *
14554
+ * @param {string} name - A keyword
14555
+ * @param {object} [nameMap] - The name map to search first
14556
+ * @returns {{ tag: string, name: string, vr: string } | undefined}
14557
+ */
14558
+ }, {
14559
+ key: "entryForName",
14560
+ value: function entryForName(name) {
14561
+ var nameMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DicomMetaDictionary.nameMap;
14562
+ return ownEntry(nameMap, name) || lookupRegisteredTagByName(name);
14563
+ }
14457
14564
  }, {
14458
14565
  key: "tagAsIntegerFromName",
14459
14566
  value: function tagAsIntegerFromName(name) {
14460
- var item = DicomMetaDictionary.nameMap[name];
14567
+ var item = DicomMetaDictionary.entryForName(name);
14461
14568
  if (item != undefined) {
14462
14569
  return this.parseIntFromTag(item.tag);
14463
14570
  } else {
@@ -14630,14 +14737,7 @@
14630
14737
  }
14631
14738
  // check if it's a sequence
14632
14739
  var name = naturalName;
14633
- var entry = nameMap[name];
14634
- if (!entry) {
14635
- // registerTag() names are kept in a registry-local index
14636
- // instead of being written into the shared nameMap, so a
14637
- // registered keyword denaturalizes symmetrically without
14638
- // naturalizeDataset ever mutating global state
14639
- entry = lookupRegisteredTagByName(name);
14640
- }
14740
+ var entry = DicomMetaDictionary.entryForName(name, nameMap);
14641
14741
  if (!entry && isHexTag(name) && dataset._vrMap && dataset._vrMap[name]) {
14642
14742
  // private/unknown element kept under its hex tag by
14643
14743
  // naturalizeDataset: rebuild it with the VR recorded in
@@ -14853,6 +14953,9 @@
14853
14953
  ValueRepresentation$1.setDicomMetaDictionary(DicomMetaDictionary);
14854
14954
  DicomMetaDictionary.dictionary = dictionary;
14855
14955
  DicomMetaDictionary._generateNameMap();
14956
+ setKeywordLookup(function (name) {
14957
+ return ownEntry(DicomMetaDictionary.nameMap, name);
14958
+ });
14856
14959
 
14857
14960
  // AUTO-GENERATED from dictionary.mjs by generate/pack_private.mjs
14858
14961
  // Private tags only (creator strings). Decoded on first use; use ensurePrivateLoaded() if needed.
@@ -31561,11 +31664,12 @@
31561
31664
  });
31562
31665
 
31563
31666
  // Every entry below must be a real dictionary keyword
31564
- // (DicomMetaDictionary.nameMap): cleanTags silently skips names that do not
31667
+ // (DicomMetaDictionary.entryForName()): cleanTags silently skips names that do not
31565
31668
  // resolve, so a misspelled entry means the data it was meant to scrub is
31566
31669
  // left in place (issue #345). Retired attributes use the dictionary's
31567
31670
  // RETIRED_ keyword prefix. All 103 previously non-resolving names were
31568
31671
  // mapped to their intended keywords; none had to be removed.
31672
+ // ResponsiblePersonRole was added to match 0.53.3.
31569
31673
  var tagNamesToEmpty = [
31570
31674
  // please override these in specificReplaceDefaults to have useful values
31571
31675
  "PatientID", "PatientName",
@@ -31578,7 +31682,7 @@
31578
31682
  // cat 2/3: CTP: set to increment dates
31579
31683
  "InstanceCreationDate", "StudyDate", "ContentDate", "DateOfSecondaryCapture", "DateOfLastCalibration", "DateOfLastDetectorCalibration", "FrameAcquisitionDateTime", "FrameReferenceDateTime", "RETIRED_StudyVerifiedDate", "RETIRED_StudyReadDate", "RETIRED_ScheduledStudyStartDate", "RETIRED_ScheduledStudyStopDate", "RETIRED_StudyArrivalDate", "RETIRED_StudyCompletionDate", "RETIRED_ScheduledAdmissionDate", "RETIRED_ScheduledDischargeDate", "RETIRED_DischargeDate", "ScheduledProcedureStepStartDate", "ScheduledProcedureStepEndDate", "PerformedProcedureStepStartDate", "PerformedProcedureStepEndDate", "IssueDateOfImagingServiceRequest", "VerificationDateTime", "ObservationDateTime", "DateTime", "Date", "ReferencedDateTime",
31580
31684
  // cat 3/3: CTP: set to remove using @remove
31581
- "AcquisitionDate", "RETIRED_OverlayDate", "RETIRED_CurveDate", "AcquisitionDateTime", "SeriesTime", "AcquisitionTime", "RETIRED_OverlayTime", "RETIRED_CurveTime", "InstitutionName", "InstitutionAddress", "ReferringPhysicianAddress", "ReferringPhysicianTelephoneNumbers", "ReferringPhysicianIdentificationSequence", "TimezoneOffsetFromUTC", "StationName", "StudyDescription", "InstitutionalDepartmentName", "PhysiciansOfRecord", "PhysiciansOfRecordIdentificationSequence", "PerformingPhysicianName", "PerformingPhysicianIdentificationSequence", "NameOfPhysiciansReadingStudy", "PhysiciansReadingStudyIdentificationSequence", "OperatorsName", "OperatorIdentificationSequence", "AdmittingDiagnosesDescription", "AdmittingDiagnosesCodeSequence", "ReferencedStudySequence", "ReferencedPerformedProcedureStepSequence", "ReferencedPatientSequence", "ReferencedImageSequence", "DerivationDescription", "SourceImageSequence", "RETIRED_IdentifyingComments", "IssuerOfPatientID", "PatientBirthTime", "PatientInsurancePlanCodeSequence", "PatientPrimaryLanguageCodeSequence", "PatientPrimaryLanguageModifierCodeSequence", "OtherPatientIDs", "OtherPatientNames", "OtherPatientIDsSequence", "PatientBirthName", "PatientAge", "PatientSize", "PatientWeight", "PatientAddress", "RETIRED_InsurancePlanIdentification", "PatientMotherBirthName", "MilitaryRank", "BranchOfService", "MedicalRecordLocator", "MedicalAlerts", "Allergies", "CountryOfResidence", "RegionOfResidence", "PatientTelephoneNumbers", "EthnicGroup", "Occupation", "SmokingStatus", "AdditionalPatientHistory", "PregnancyStatus", "LastMenstrualDate", "PatientReligiousPreference", "PatientSexNeutered", "ResponsiblePerson", "ResponsibleOrganization", "PatientComments", "DeviceSerialNumber", "PlateID", "GeneratorID", "CassetteID", "GantryID",
31685
+ "AcquisitionDate", "RETIRED_OverlayDate", "RETIRED_CurveDate", "AcquisitionDateTime", "SeriesTime", "AcquisitionTime", "RETIRED_OverlayTime", "RETIRED_CurveTime", "InstitutionName", "InstitutionAddress", "ReferringPhysicianAddress", "ReferringPhysicianTelephoneNumbers", "ReferringPhysicianIdentificationSequence", "TimezoneOffsetFromUTC", "StationName", "StudyDescription", "InstitutionalDepartmentName", "PhysiciansOfRecord", "PhysiciansOfRecordIdentificationSequence", "PerformingPhysicianName", "PerformingPhysicianIdentificationSequence", "NameOfPhysiciansReadingStudy", "PhysiciansReadingStudyIdentificationSequence", "OperatorsName", "OperatorIdentificationSequence", "AdmittingDiagnosesDescription", "AdmittingDiagnosesCodeSequence", "ReferencedStudySequence", "ReferencedPerformedProcedureStepSequence", "ReferencedPatientSequence", "ReferencedImageSequence", "DerivationDescription", "SourceImageSequence", "RETIRED_IdentifyingComments", "IssuerOfPatientID", "PatientBirthTime", "PatientInsurancePlanCodeSequence", "PatientPrimaryLanguageCodeSequence", "PatientPrimaryLanguageModifierCodeSequence", "OtherPatientIDs", "OtherPatientNames", "OtherPatientIDsSequence", "PatientBirthName", "PatientAge", "PatientSize", "PatientWeight", "PatientAddress", "RETIRED_InsurancePlanIdentification", "PatientMotherBirthName", "MilitaryRank", "BranchOfService", "MedicalRecordLocator", "MedicalAlerts", "Allergies", "CountryOfResidence", "RegionOfResidence", "PatientTelephoneNumbers", "EthnicGroup", "Occupation", "SmokingStatus", "AdditionalPatientHistory", "PregnancyStatus", "LastMenstrualDate", "PatientReligiousPreference", "PatientSexNeutered", "ResponsiblePerson", "ResponsiblePersonRole", "ResponsibleOrganization", "PatientComments", "DeviceSerialNumber", "PlateID", "GeneratorID", "CassetteID", "GantryID",
31582
31686
  // we keep - should be SoftwareVersions anyway
31583
31687
  // "SoftwareVersion",
31584
31688
  "ProtocolName", "AcquisitionDeviceProcessingDescription", "RETIRED_AcquisitionComments", "DetectorID", "AcquisitionProtocolDescription", "ContributionDescription", "RETIRED_ModifyingDeviceID", "RETIRED_ModifyingDeviceManufacturer", "RETIRED_ModifiedImageDescription", "ImageComments", "RETIRED_ImagePresentationComments", "RETIRED_StudyIDIssuer", "RETIRED_ScheduledStudyLocation", "RETIRED_ScheduledStudyLocationAETitle", "RETIRED_ReasonForStudy", "RequestingPhysician", "RequestingService", "RequestedProcedureDescription", "RequestedContrastAgent", "RETIRED_StudyComments", "AdmissionID", "RETIRED_IssuerOfAdmissionID", "RETIRED_ScheduledPatientInstitutionResidence", "AdmittingDate", "AdmittingTime", "RETIRED_DischargeDiagnosisDescription", "SpecialNeeds", "ServiceEpisodeID", "RETIRED_IssuerOfServiceEpisodeID", "ServiceEpisodeDescription", "CurrentPatientLocation", "PatientInstitutionResidence", "PatientState", "ReferencedPatientAliasSequence", "VisitComments", "ScheduledStationAETitle", "ScheduledPerformingPhysicianName", "ScheduledProcedureStepDescription", "ScheduledStationName", "ScheduledProcedureStepLocation", "PreMedication", "PerformedStationAETitle", "PerformedStationName", "PerformedLocation", "PerformedStationNameCodeSequence", "PerformedProcedureStepID", "PerformedProcedureStepDescription", "RequestAttributesSequence", "CommentsOnThePerformedProcedureStep", "AcquisitionContextSequence", "PatientTransportArrangements", "RequestedProcedureLocation", "NamesOfIntendedRecipientsOfResults", "IntendedRecipientsOfResultsIdentificationSequence", "PersonAddress", "PersonTelephoneNumbers", "RequestedProcedureComments", "RETIRED_ReasonForTheImagingServiceRequest", "OrderEnteredBy", "OrderEntererLocation", "OrderCallbackPhoneNumber", "ImagingServiceRequestComments", "ConfidentialityConstraintOnPatientDataDescription", "ScheduledStationNameCodeSequence", "ScheduledStationGeographicLocationCodeSequence", "PerformedStationGeographicLocationCodeSequence", "ScheduledHumanPerformersSequence", "ActualHumanPerformersSequence", "HumanPerformerOrganization", "HumanPerformerName", "VerifyingOrganization", "VerifyingObserverName", "AuthorObserverSequence", "ParticipantSequence", "CustodialOrganizationSequence", "VerifyingObserverIdentificationCodeSequence", "PersonName", "ContentSequence", "OverlayData", "RETIRED_OverlayComments", "IconImageSequence", "RETIRED_TopicSubject", "RETIRED_TopicAuthor", "RETIRED_TopicKeywords", "TextString", "RETIRED_Arbitrary", "RETIRED_TextComments", "RETIRED_ResultsIDIssuer", "RETIRED_InterpretationRecorder", "RETIRED_InterpretationTranscriber", "RETIRED_InterpretationText", "RETIRED_InterpretationAuthor", "RETIRED_InterpretationApproverSequence", "RETIRED_PhysicianApprovingInterpretation", "RETIRED_InterpretationDiagnosisDescription", "RETIRED_ResultsDistributionListSequence", "RETIRED_DistributionName", "RETIRED_DistributionAddress", "RETIRED_InterpretationIDIssuer", "RETIRED_Impressions", "RETIRED_ResultsComments", "DigitalSignaturesSequence", "DataSetTrailingPadding"];
@@ -31596,7 +31700,7 @@
31596
31700
  }
31597
31701
  var tags = customTagNamesToEmpty != undefined ? customTagNamesToEmpty : tagNamesToEmpty;
31598
31702
  tags.forEach(function (tag) {
31599
- var tagInfo = DicomMetaDictionary.nameMap[tag];
31703
+ var tagInfo = DicomMetaDictionary.entryForName(tag);
31600
31704
  if (tagInfo && tagInfo.version != "PrivateTag") {
31601
31705
  var tagNumber = tagInfo.tag,
31602
31706
  tagString = Tag.fromPString(tagNumber).toCleanString();
@@ -31633,6 +31737,8 @@
31633
31737
  datasetToDict: datasetToDict,
31634
31738
  datasetToBuffer: datasetToBuffer,
31635
31739
  datasetToBlob: datasetToBlob,
31740
+ dictionary: dictionary,
31741
+ registerTag: registerTag,
31636
31742
  // naturalized-dataset utilities (docs/specs/naturalized-dataset.md)
31637
31743
  setVr: setVr,
31638
31744
  setAttribute: setAttribute,