@dcmjs-org/fhir 0.0.0-bootstrap.0 → 1.0.0-beta.10

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/License.txt ADDED
@@ -0,0 +1,22 @@
1
+
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2017 Steve Pieper
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md CHANGED
@@ -1 +1,104 @@
1
1
  # @dcmjs-org/fhir
2
+
3
+ > **Status: preliminary.** The API of this package can change in a minor
4
+ > release while this notice is here. Such a change is not a breaking change for
5
+ > semantic versioning; the release notes name it. Pin an exact version if you
6
+ > depend on the current shape.
7
+
8
+ DICOM to FHIR R4/R4B mapping for naturalized dcmjs datasets, and the reverse
9
+ mapping of patient demographics.
10
+
11
+ - `toFhir(dataset, options)` — `{ patient, imagingStudy, documentReference }`
12
+ for one instance.
13
+ - `toBundle(datasets, options)` — a `collection` Bundle: one Patient, a
14
+ DocumentReference for each encapsulated document, and one ImagingStudy
15
+ for the images.
16
+ - `patientFromDataset`, `imagingStudyFromDatasets`,
17
+ `documentReferenceFromDataset` — the single mappers.
18
+ - `patientToDataset(patient)` — a FHIR Patient to the DICOM patient-module
19
+ attributes (`PatientName`, `PatientID`, `PatientBirthDate`, `PatientSex`).
20
+
21
+ The wrapper `@dcmjs-org/dcmjs` does not depend on this package. An
22
+ event stream gives the naturalized dataset for `toFhir`:
23
+
24
+ ```js
25
+ import { toFhir } from "@dcmjs-org/fhir";
26
+
27
+ const { patient, imagingStudy } = toFhir(await events.toNaturalized());
28
+ ```
29
+
30
+ ## Scope and change rule
31
+
32
+ This README holds the requirements of `@dcmjs-org/fhir`.
33
+
34
+ An earlier beta had `DicomEventStream.fromFhir()` and `toFhir()` in the
35
+ wrapper. The 1.0 wrapper removed them, because the FHIR mapping is
36
+ preliminary. FHIR-USR-7, FHIR-USR-8, FHIR-USR-9, FHIR-IMP-3, and FHIR-IMP-4
37
+ held the requirements of `fromFhir`. These identifiers are withdrawn, and
38
+ the git history keeps the old text and the old code.
39
+
40
+ While the status is preliminary, a user requirement (FHIR-USR-n) can change
41
+ in a minor release. After that, change a user requirement only when it
42
+ describes the behaviour wrongly, or when the intended user-facing behaviour
43
+ changes, and name the change in the pull request. The implementation
44
+ requirements (FHIR-IMP-n) describe the current approach, and can change
45
+ freely. Do not renumber an identifier.
46
+
47
+ ## § User requirements
48
+
49
+ - **FHIR-USR-1** The output is standard FHIR R4/R4B only, with no profile
50
+ extensions: no resource `id`, no `meta.tags`, and no storage references.
51
+ The consumer assigns these. An unsupported `fhirVersion` throws an
52
+ error. The relative references of FHIR-USR-10 are the one exception.
53
+ - **FHIR-USR-2** `toFhir` maps an encapsulated document to a
54
+ DocumentReference and no ImagingStudy, and an image to an ImagingStudy
55
+ and no DocumentReference.
56
+ - **FHIR-USR-3** The mapper never fabricates a value that DICOM does not
57
+ give, and never mixes two patients or two studies.
58
+ - It skips, with a `validationLog` warning: an instance with no
59
+ SOPClassUID; a dataset with no SeriesInstanceUID or no Modality; a
60
+ dataset of another study than the first. `toBundle` also skips a
61
+ dataset with another PatientID than the Patient of the Bundle.
62
+ - `Patient.gender` comes from the administrative `PatientSex`. The
63
+ Patient gets no birth-sex or clinical-sex extension.
64
+ - A number (`series.number`, `instance.number`, `numberOfFrames`) is
65
+ written only for a non-negative integer.
66
+ - `BodyPartExamined` is a display with no code system. `Laterality`
67
+ L, R, and B are SNOMED CT codes (CID 244); another value is a
68
+ display with no code system.
69
+ - **FHIR-USR-4** A FHIR `dateTime` gets a time only when the dataset has
70
+ `TimezoneOffsetFromUTC (0008,0201)`; otherwise it is the date only.
71
+ `DocumentReference.date` (an `instant`) is written only with the date,
72
+ the time, and the timezone. The date must be `YYYYMMDD` (or the legacy
73
+ `YYYY.MM.DD`), else there is no date; a time that is not `HHMMSS` (or the
74
+ legacy `HH:MM:SS`) gives the date only.
75
+ - **FHIR-USR-5** The DocumentReference attachment holds the document bytes
76
+ exactly: `EncapsulatedDocumentLength (0042,0015)` gives the length when
77
+ present, and each naturalized payload shape (including
78
+ `{ InlineBinary }`) gives the same bytes. A `{ BulkDataURI }` payload
79
+ gives `attachment.url`, and no `size` or `data`.
80
+ - **FHIR-USR-6** `patientToDataset` writes all four attributes, with an
81
+ empty string for an absent value. A text-only HumanName becomes a
82
+ single-component PN. A partial FHIR `birthDate` becomes empty, and never
83
+ a fabricated day.
84
+ - **FHIR-USR-7**, **FHIR-USR-8**, **FHIR-USR-9** Withdrawn (see the
85
+ scope section).
86
+ - **FHIR-USR-10** The output links its resources without server ids.
87
+ Without `options.subject`, `toFhir` gives the ImagingStudy or the
88
+ DocumentReference `subject: { reference: "./patient" }`, a path relative
89
+ to the returned object. `toBundle` gives each entry
90
+ `fullUrl: "./entry/<index>"`, and the ImagingStudy and the
91
+ DocumentReferences reference the Patient entry by its `fullUrl`. These
92
+ relative references are not FHIR server references; the consumer
93
+ replaces them when it stores the resources.
94
+
95
+ ## § Implementation requirements
96
+
97
+ - **FHIR-IMP-1** The package depends at run time only on `@dcmjs-org/core`
98
+ and `@dcmjs-org/encapsulated`; the tests can use `@dcmjs-org/parser` and
99
+ `@dcmjs-org/legacy`.
100
+ - **FHIR-IMP-2** The document bytes come from `extractEncapsulated` of
101
+ `@dcmjs-org/encapsulated`. The value readers (`toStringFirst`,
102
+ `toFloatFirst`), `encodeBase64`, and `MODALITY_DISPLAY` come from
103
+ `@dcmjs-org/core`.
104
+ - **FHIR-IMP-3**, **FHIR-IMP-4** Withdrawn (see the scope section).