fhir-data-utils-ts 0.6.1 → 0.6.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.6.2 - 2026-09-30
6
+
7
+ - Add strict FHIR `instant` to Unix epoch-second derivation while preserving
8
+ the boundary between clinical time, `Encounter.id`, provider business
9
+ identifiers and human display codes.
10
+
5
11
  ## 0.6.1 - 2026-09-30
6
12
 
7
13
  - Add canonical flat claims, a claims-first builder and native R5 projection
package/README.md CHANGED
@@ -92,6 +92,12 @@ metadata and protected endpoint references only. DICOM instances and pixel
92
92
  payloads remain outside this neutral package and are never embedded as flat
93
93
  claims.
94
94
 
95
+ FHIR instants, resource ids and provider business identifiers remain separate.
96
+ Use `fhirInstantToEpochSeconds(...)` only when a downstream convention needs a
97
+ derived whole-second value; retain the original timezone-bearing instant and
98
+ an independent `Encounter.id`. See
99
+ [`docs/ENCOUNTER_IDENTIFIERS_AND_TIME.md`](docs/ENCOUNTER_IDENTIFIERS_AND_TIME.md).
100
+
95
101
  No consumer should copy claim paths or rebuild these structures with literals.
96
102
  Use `fhir-data-utils-ts/claims`, `/converters`, `/fhir-bundle`,
97
103
  `/fhir-search-parameters`, `/clinical-terminology`, `/group-r5` or
@@ -6,6 +6,7 @@ export declare const FHIR_ENCOUNTER_TRANSFER_TEST_DATA: Readonly<{
6
6
  senderReference: "Organization/00000000-0000-4000-8000-000000000403";
7
7
  indexRecipientReference: "Organization/00000000-0000-4000-8000-000000000404";
8
8
  occurredAt: "2026-09-30T10:10:00Z";
9
+ invalidOccurredAtWithoutTimezone: "2026-09-30T10:10:00";
9
10
  class: Readonly<{
10
11
  system: "http://terminology.hl7.org/CodeSystem/v3-ActCode";
11
12
  code: "EMER";
@@ -6,6 +6,7 @@ export const FHIR_ENCOUNTER_TRANSFER_TEST_DATA = Object.freeze({
6
6
  senderReference: 'Organization/00000000-0000-4000-8000-000000000403',
7
7
  indexRecipientReference: 'Organization/00000000-0000-4000-8000-000000000404',
8
8
  occurredAt: '2026-09-30T10:10:00Z',
9
+ invalidOccurredAtWithoutTimezone: '2026-09-30T10:10:00',
9
10
  class: Object.freeze({ system: 'http://terminology.hl7.org/CodeSystem/v3-ActCode', code: 'EMER' }),
10
11
  source: Object.freeze({
11
12
  id: '00000000-0000-4000-8000-000000000405',
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Derives whole Unix epoch seconds from a valid FHIR `instant`.
3
+ *
4
+ * A FHIR instant remains the authoritative ISO 8601 value with a timezone.
5
+ * Epoch seconds are a derived numeric representation and must never replace
6
+ * `Encounter.id`, `Encounter.identifier`, or the original clinical time.
7
+ */
8
+ export declare function fhirInstantToEpochSeconds(instant: string): number;
@@ -0,0 +1,16 @@
1
+ const FHIR_INSTANT_PATTERN = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
2
+ /**
3
+ * Derives whole Unix epoch seconds from a valid FHIR `instant`.
4
+ *
5
+ * A FHIR instant remains the authoritative ISO 8601 value with a timezone.
6
+ * Epoch seconds are a derived numeric representation and must never replace
7
+ * `Encounter.id`, `Encounter.identifier`, or the original clinical time.
8
+ */
9
+ export function fhirInstantToEpochSeconds(instant) {
10
+ if (!FHIR_INSTANT_PATTERN.test(instant))
11
+ throw new TypeError('fhir_instant_invalid');
12
+ const epochMilliseconds = Date.parse(instant);
13
+ if (!Number.isFinite(epochMilliseconds))
14
+ throw new TypeError('fhir_instant_invalid');
15
+ return Math.floor(epochMilliseconds / 1000);
16
+ }
package/dist/index.d.ts CHANGED
@@ -27,3 +27,4 @@ export * from './subscription-r5.js';
27
27
  export * from './healthcare-service-specialty-map.js';
28
28
  export * from './appointment-communication-test-data.js';
29
29
  export * from './encounter-transfer-test-data.js';
30
+ export * from './fhir-instant.js';
package/dist/index.js CHANGED
@@ -27,3 +27,4 @@ export * from './subscription-r5.js';
27
27
  export * from './healthcare-service-specialty-map.js';
28
28
  export * from './appointment-communication-test-data.js';
29
29
  export * from './encounter-transfer-test-data.js';
30
+ export * from './fhir-instant.js';
@@ -0,0 +1,19 @@
1
+ # Encounter identifiers and time
2
+
3
+ FHIR time and encounter identity are separate concepts.
4
+
5
+ - A FHIR `instant` is an ISO 8601 date and time with at least second precision
6
+ and an explicit timezone. It is not a Unix timestamp.
7
+ - Unix epoch seconds may be derived for sorting, interoperability or a
8
+ provider-owned business identifier, but they never replace the original
9
+ instant.
10
+ - `Encounter.id` is the FHIR resource identifier.
11
+ - `Encounter.identifier` contains the business identifiers assigned by the
12
+ care provider. Their namespace and uniqueness belong to the assigning
13
+ organization.
14
+ - A display code is not sufficient authorization or subject resolution. An
15
+ authoritative lookup must also verify the assigner and exact subject.
16
+
17
+ Reusable test data lives in `FHIR_ENCOUNTER_TRANSFER_TEST_DATA`. Tests and
18
+ downstream documentation import its named fields instead of duplicating raw
19
+ identifiers, timestamps or references.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fhir-data-utils-ts",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "FHIR-version-neutral flat-claim and SearchParameter data utilities",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",