Repository navigation
feat(codemods): runnable codemods for the upgrade to dcmjs 1.0; fix(core): a single PN value is array-like - #646
Merged
Merged
Conversation
… 1.0 Phase 1: change the package name to @dcmjs/dcmjs (CM-1), and adapt the code to the naturalized values of 1.0 (CM-2). Phase 2: read Part 10 directly to a naturalized dataset (CM-3), and write a naturalized dataset directly to Part 10 (CM-4), with the event stream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A single PN value is the component object, and now also has a hidden [0] (the object), a length of 1 and an iterator (NAT-U-VAL-5, NAT-U-SQ-1). So the 0.x form ds.PatientName[0].Alphabetic keeps working, and ds.PatientName[0] === ds.PatientName. Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130
marked this pull request as ready for review
November 24, 2026 15:48
Replace the codemod descriptions in docs/codemods with packages of the Codemod registry, in the layout of the Cornerstone3D codemods. Each package has a codemod.yaml, a workflow.yaml, an ast-grep transform, the fixture tests and a README: - @dcmjs-org/dcmjs-1: runs the two packages below. - @dcmjs-org/dcmjs-1-package-name: package.json and the module name. - @dcmjs-org/dcmjs-1-naturalized-values: the naturalized values of 1.0. - @dcmjs-org/dcmjs-1-event-stream: optional, the read and the write with the event stream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
@sedghi - could you re-review with your requested change already applied? |
sedghi
approved these changes
Nov 24, 2026
sedghi
left a comment
Collaborator
There was a problem hiding this comment.
Please test it on an dcmjs 0.x repo i approved if it works
# Conflicts: # docs/MIGRATION.md
|
🎉 This PR is included in version 1.0.0-beta.15 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds runnable codemods for the upgrade from dcmjs 0.x to 1.0, in
packages/codemods/. The codemods use the format of the Codemod registry, with the same layout as the Cornerstone3D codemods (packages/codemods/registry/cornerstone3d/6). The PR also fixes the shape of a single PN value.Each package is self-contained. It has a
codemod.yaml, aworkflow.yaml, an ast-grep transform inscripts/, fixture tests intests/<language>/<case>/, and a README. The README gives what the codemod changes, what it reports, and what it cannot find.@dcmjs-org/dcmjs-1@dcmjs-org/dcmjs-1-package-namepackage.jsonand the module namedcmjsto@dcmjs-org/dcmjs. Reports a 0.x subpath and a jest configuration.@dcmjs-org/dcmjs-1-naturalized-valuesArray.from), a string compare or string method on a single PN value (String()), and removesaddTagAccessors. Reports a list-VM keyword that the code uses as a scalar, the private-data round trip,_vrMapiteration, hex-key patterns, andnameMapwrites.@dcmjs-org/dcmjs-1-event-streamreadFile+naturalizeDatasetandnew DicomDict+writewith the event stream, only in anasyncfunction or at the top level of an ES module, so that no caller changes. Reports the other sites, with the reason.The codemods write no comment into the code. A site that needs a person goes into the metric
dcmjs-1-manualordcmjs-1-review, with the rule, the file and the line.This PR removes the markdown descriptions
docs/codemods/*.mdof the first version of this PR. Their content moved into the package READMEs.docs/MIGRATION.mdlinks topackages/codemods.Fix: a single PN value is array-like
In 0.x,
ds.PatientName[0].Alphabeticworked. In the 1.0 beta,ds.PatientName[0]wasundefined. This PR applies the rule of a single-item sequence (NAT-U-SQ-1) to a single PN value:toPersonNameValueinpackages/core/src/utilities/personNameValue.jscalls the existingaddAccessorson a single component object.ds.PatientName[0] === ds.PatientName,ds.PatientName.lengthis 1, andfor...ofgives the name once.Array.isArray(ds.PatientName)isfalse.Object.keys,JSON.stringify,String()and denaturalize do not change.NAT-U-VAL-5 in
docs/specs/naturalized-dataset.mdand change 5 indocs/MIGRATION.mdrecord the rule.Test
pnpm run validateinpackages/codemodsrunscodemod workflow validateon the 4 packages, and then 13 fixture tests (JavaScript, TypeScript andpackage.json). Each fixture with a report has ametrics.json.npx codemod workflow run. The result was correct, and the report named the expected site.test/core/naturalizeDataset.test.jschecks the PN shape fornaturalizeDataset,NaturalizedListenerand an assigned string. The full jest suite passes: 1246 tests pass, and 12 tests are skipped.Open items
npx codemod, which the CI must download.npx codemod publish), the child packages before@dcmjs-org/dcmjs-1. Until then, thenpx codemod @dcmjs-org/dcmjs-1command does not work.npx codemod workflow run -w <package directory>works from a checkout.🤖 Generated with Claude Code