Repository navigation
feat(fhir): scaffold @dcmjs-org/fhir and port the Patient mappers (finding 19) - #574
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5 <[email protected]>
…elopment helpers.js, patient.js and patientToDataset.js come over verbatim from the v2 packages/fhir sources (prettier-normalized to this repo's config). The test imports are rewired to the concrete modules because the package index lands in a later slice. Co-Authored-By: Claude Fable 5 <[email protected]>
…exist A text-only HumanName used to map to null, and patientToDataset's deterministic overwrite then erased the patient's name entirely (review finding 19 on PR #512). When family/given/prefix/suffix are all absent, the free-text form now survives as a single-component PN. Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Oct 2, 2026
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.
This starts the
@dcmjs-org/fhirpackage: the scaffold plus the Patient direction of the DICOM ↔ FHIR mapping, with review finding 19 fixed inside the port. The package comes from the v2 branch'spackages/fhir/, which is fully self-contained — six source files, zero imports from the rest of the tree — so the port is mechanical: the scope renames to@dcmjs-org/fhir, the package-local.babelrcis dropped (the rootbabel.config.jscovers workspace packages now), and the sources are prettier-normalized to this repo's config. This first slice carrieshelpers.js(the shared value mappers: PN parsing, UID urns, DA/TM ↔ ISO dates, the administrative-gender tables),patient.js(naturalized dataset → FHIR Patient) andpatientToDataset.js(the inverse: Patient → the four patient-module attributes, deterministic overwrite by design). The ImagingStudy and DocumentReference mappers follow in the next two slices, and the event-stream integration (fromFhirand the facade methods) is deferred until the pdfs/video/media waves land, because it depends on both.Everything here except the fix is a verbatim port: the three source files and the 13-test
patientToDatasetsuite come over unchanged apart from formatting and the test imports, which now point at the concrete modules because the package index (with thetoFhirsurface it exports) arrives in slice two. The hand-written portion is the scaffoldpackage.json, the finding fix, and its regression tests.The finding, with its regression written against the ported-but-unfixed code and observed failing before the fix:
humanNameToPersonNameread onlyfamily,given,prefixandsuffix, neverHumanName.text, and returned null when all four were absent. SincepatientToDatasetdeterministically overwrites the whole patient module, a text-only name — common in real FHIR feeds — erased the existingPatientNameoutright:{name: [{text: "Jane Doe"}]}came back asPatientName: "". The fix falls back totextas a single-component PN when no structured part exists. I considered splitting a"Family, Given"shape out of the text and decided against fabricating structure the resource never asserted — the text goes in whole. If reviewers prefer the split, it is a small follow-up.The mapping in its current shape:
26 tests in the new suite — the 13 ported ones (the JANE FOX identity, name-use preference, the exhaustive
genderToSextable, round trips with the sink direction) plus the finding-19 regressions. 870 passing overall on this branch, andpnpm run buildis green.🤖 Generated with Claude Code