gdc-common-utils-ts 2.9.23 → 2.9.25
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/README.md +4 -2
- package/dist/examples/consent-access.d.ts +2 -0
- package/dist/examples/consent-access.js +2 -0
- package/dist/utils/bundle-editor-core.d.ts +9 -0
- package/dist/utils/bundle-editor-core.js +12 -0
- package/dist/utils/bundle-reader.d.ts +12 -1
- package/dist/utils/bundle-reader.js +19 -1
- package/dist/utils/consent.js +4 -1
- package/dist/utils/employee-entry-editor.d.ts +6 -0
- package/dist/utils/employee-entry-editor.js +12 -0
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -378,9 +378,11 @@ import { JweObject, JwtCompactParts } from 'gdc-common-utils-ts/models';
|
|
|
378
378
|
- [docs/101-CLINICAL-IPS.md](docs/101-CLINICAL-IPS.md)
|
|
379
379
|
- shortest high-level onboarding for `ipsBundleReader`, section summaries,
|
|
380
380
|
family queries, and UI-ready narrative helpers
|
|
381
|
+
- [docs/101-CLINICAL-ENTRY-GETTERS-SETTERS.md](docs/101-CLINICAL-ENTRY-GETTERS-SETTERS.md)
|
|
382
|
+
- complete typed getter/setter guide for creating entries and reopening
|
|
383
|
+
received `entry[]` or `data[]` Bundles through an editable clone
|
|
381
384
|
- [docs/REFERENCE-CLINICAL-IPS-API.md](docs/REFERENCE-CLINICAL-IPS-API.md)
|
|
382
|
-
- canonical claim/method matrix
|
|
383
|
-
`get...` / `set...` helpers
|
|
385
|
+
- canonical claim/method matrix and reader/query reference
|
|
384
386
|
|
|
385
387
|
## Dataspace Protocol And Discovery
|
|
386
388
|
|
|
@@ -5,6 +5,8 @@ export declare const EXAMPLE_PROVIDER_ORGANIZATION_DID_WEB: "did:web:hospital.ac
|
|
|
5
5
|
export { EXAMPLE_EMAIL_PROFESSIONAL, EXAMPLE_EMAIL_RELATED_PERSON };
|
|
6
6
|
export declare const EXAMPLE_CONSENT_ACCESS_JURISDICTION: "ES";
|
|
7
7
|
export declare const EXAMPLE_CONSENT_ACCESS_COUNTRY_ACTOR_IDENTIFIER: string;
|
|
8
|
+
export declare const EXAMPLE_CONSENT_ACCESS_SUBDIVISION = "CA-BC";
|
|
9
|
+
export declare const EXAMPLE_CONSENT_ACCESS_SUBDIVISION_ACTOR_IDENTIFIER = "urn:iso:3166-2:CA-BC";
|
|
8
10
|
/**
|
|
9
11
|
* Legacy compatibility aliases kept so older docs/tests/imports continue to work
|
|
10
12
|
* while the canonical variable names converge.
|
|
@@ -9,6 +9,8 @@ export const EXAMPLE_PROVIDER_ORGANIZATION_DID_WEB = EXAMPLE_PROVIDER_ORGANIZATI
|
|
|
9
9
|
export { EXAMPLE_EMAIL_PROFESSIONAL, EXAMPLE_EMAIL_RELATED_PERSON };
|
|
10
10
|
export const EXAMPLE_CONSENT_ACCESS_JURISDICTION = EXAMPLE_HEALTHCARE_JURISDICTION;
|
|
11
11
|
export const EXAMPLE_CONSENT_ACCESS_COUNTRY_ACTOR_IDENTIFIER = `urn:iso:3166:${EXAMPLE_CONSENT_ACCESS_JURISDICTION}`;
|
|
12
|
+
export const EXAMPLE_CONSENT_ACCESS_SUBDIVISION = 'CA-BC';
|
|
13
|
+
export const EXAMPLE_CONSENT_ACCESS_SUBDIVISION_ACTOR_IDENTIFIER = `urn:iso:3166-2:${EXAMPLE_CONSENT_ACCESS_SUBDIVISION}`;
|
|
12
14
|
/**
|
|
13
15
|
* Legacy compatibility aliases kept so older docs/tests/imports continue to work
|
|
14
16
|
* while the canonical variable names converge.
|
|
@@ -88,6 +88,15 @@ export declare class BundleEditor {
|
|
|
88
88
|
newEntryAs<T extends AllowedResourceType>(resourceType: T, resourceId?: string): ResourceTypeEntryEditor<T>;
|
|
89
89
|
/** Reopens one existing entry by `resource.id` or `fullUrl`. */
|
|
90
90
|
openEntry(resourceIdOrFullUrl: string): BundleEntryEditor;
|
|
91
|
+
/**
|
|
92
|
+
* Reopens one existing entry by its current array position.
|
|
93
|
+
*
|
|
94
|
+
* Prefer `openEntry(resourceIdOrFullUrl)` when a stable identifier is
|
|
95
|
+
* available. This positional form exists for the explicit
|
|
96
|
+
* `BundleReader.toBundleEditor()` handoff, where the reader has already
|
|
97
|
+
* selected one entry index and the received resource may not expose an id.
|
|
98
|
+
*/
|
|
99
|
+
openEntryByArrayIndex(index: number): BundleEntryEditor;
|
|
91
100
|
/** Returns cloned staged entries for inspection or debugging. */
|
|
92
101
|
getEntries(): readonly BuiltBundleEntry[];
|
|
93
102
|
/** Returns the current Composition-level claims used when building a document bundle. */
|
|
@@ -201,6 +201,18 @@ export class BundleEditor {
|
|
|
201
201
|
}
|
|
202
202
|
return new BundleEntryEditor(this, entryIndex);
|
|
203
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Reopens one existing entry by its current array position.
|
|
206
|
+
*
|
|
207
|
+
* Prefer `openEntry(resourceIdOrFullUrl)` when a stable identifier is
|
|
208
|
+
* available. This positional form exists for the explicit
|
|
209
|
+
* `BundleReader.toBundleEditor()` handoff, where the reader has already
|
|
210
|
+
* selected one entry index and the received resource may not expose an id.
|
|
211
|
+
*/
|
|
212
|
+
openEntryByArrayIndex(index) {
|
|
213
|
+
this.getMutableEntry(index);
|
|
214
|
+
return new BundleEntryEditor(this, index);
|
|
215
|
+
}
|
|
204
216
|
/** Returns cloned staged entries for inspection or debugging. */
|
|
205
217
|
getEntries() {
|
|
206
218
|
return this.entries.map((entry) => cloneEntry(entry));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type IssueSeverityCode } from '../models/issue.js';
|
|
2
|
+
import { BundleEditor } from './bundle-editor-core.js';
|
|
2
3
|
import { type BundleResourceIdFilters } from './bundle-query.js';
|
|
3
4
|
export type BundleReaderEntry = Record<string, unknown>;
|
|
4
5
|
export type BundleReaderEntrySummary = Readonly<{
|
|
@@ -65,13 +66,23 @@ export declare function getClaimsInFirstDataEntry(bundle: unknown): Record<strin
|
|
|
65
66
|
export declare class BundleReader {
|
|
66
67
|
private readonly bundle;
|
|
67
68
|
private activeEntryIndex;
|
|
68
|
-
constructor(bundle:
|
|
69
|
+
constructor(bundle: unknown);
|
|
69
70
|
/** Returns the current bundle resource type when present. */
|
|
70
71
|
getResourceType(): string | undefined;
|
|
71
72
|
/** Returns the current FHIR bundle type when present. */
|
|
72
73
|
getBundleType(): string | undefined;
|
|
73
74
|
/** Returns cloned bundle entries. */
|
|
74
75
|
getEntries(): readonly BundleReaderEntry[];
|
|
76
|
+
/**
|
|
77
|
+
* Creates a detached editable clone of this received Bundle.
|
|
78
|
+
*
|
|
79
|
+
* `BundleReader` remains the read-only navigation and response-analysis
|
|
80
|
+
* surface. Call this method when an application wants the typed
|
|
81
|
+
* `asAllergy()`, `asMedicationStatement()`, `asImmunization()`, and other
|
|
82
|
+
* entry getters/setters supplied by `BundleEditor`. Changes made through the
|
|
83
|
+
* returned editor never mutate the Bundle held by this reader.
|
|
84
|
+
*/
|
|
85
|
+
toBundleEditor(): BundleEditor;
|
|
75
86
|
/** Opens one entry by index. */
|
|
76
87
|
openEntry(index: number): this;
|
|
77
88
|
/** Returns the resolved identifier for one entry array index when present. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getHighestIssueSeverity, isIssueSeverityCode, IssueSeverity, } from '../models/issue.js';
|
|
2
|
+
import { BundleEditor } from './bundle-editor-core.js';
|
|
2
3
|
import { BundleQuery } from './bundle-query.js';
|
|
3
4
|
function cloneEntry(value) {
|
|
4
5
|
return JSON.parse(JSON.stringify(value));
|
|
@@ -60,7 +61,7 @@ export class BundleReader {
|
|
|
60
61
|
bundle;
|
|
61
62
|
activeEntryIndex = null;
|
|
62
63
|
constructor(bundle) {
|
|
63
|
-
this.bundle = cloneEntry(bundle);
|
|
64
|
+
this.bundle = cloneEntry(asRecord(bundle));
|
|
64
65
|
}
|
|
65
66
|
/** Returns the current bundle resource type when present. */
|
|
66
67
|
getResourceType() {
|
|
@@ -79,6 +80,23 @@ export class BundleReader {
|
|
|
79
80
|
: (Array.isArray(this.bundle.data) ? this.bundle.data : []);
|
|
80
81
|
return entries.map((entry) => cloneEntry(entry));
|
|
81
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a detached editable clone of this received Bundle.
|
|
85
|
+
*
|
|
86
|
+
* `BundleReader` remains the read-only navigation and response-analysis
|
|
87
|
+
* surface. Call this method when an application wants the typed
|
|
88
|
+
* `asAllergy()`, `asMedicationStatement()`, `asImmunization()`, and other
|
|
89
|
+
* entry getters/setters supplied by `BundleEditor`. Changes made through the
|
|
90
|
+
* returned editor never mutate the Bundle held by this reader.
|
|
91
|
+
*/
|
|
92
|
+
toBundleEditor() {
|
|
93
|
+
const bundle = {
|
|
94
|
+
resourceType: this.getResourceType(),
|
|
95
|
+
type: this.getBundleType(),
|
|
96
|
+
data: this.getEntries().map((entry) => cloneEntry(entry)),
|
|
97
|
+
};
|
|
98
|
+
return new BundleEditor().setBundle(bundle);
|
|
99
|
+
}
|
|
82
100
|
/** Opens one entry by index. */
|
|
83
101
|
openEntry(index) {
|
|
84
102
|
const entries = this.getEntries();
|
package/dist/utils/consent.js
CHANGED
|
@@ -245,6 +245,9 @@ function normalizeJurisdiction(value) {
|
|
|
245
245
|
const isoStd = trimmed.match(/^urn:iso:std:iso:3166\|([a-z]{2})$/i);
|
|
246
246
|
if (isoStd)
|
|
247
247
|
return isoStd[1].toUpperCase();
|
|
248
|
+
const isoSubdivision = trimmed.match(/^urn:iso:3166-2:([a-z]{2}-[a-z0-9]{1,3})$/i);
|
|
249
|
+
if (isoSubdivision)
|
|
250
|
+
return isoSubdivision[1].toUpperCase();
|
|
248
251
|
const iso = trimmed.match(/^urn:iso:3166(?:-2)?:([a-z]{2})(?:[-:].*)?$/i);
|
|
249
252
|
if (iso)
|
|
250
253
|
return iso[1].toUpperCase();
|
|
@@ -386,7 +389,7 @@ export function normalizeConsentTarget(input, options = {}) {
|
|
|
386
389
|
return {
|
|
387
390
|
raw,
|
|
388
391
|
kind: 'jurisdiction',
|
|
389
|
-
canonicalValue: parsed.value,
|
|
392
|
+
canonicalValue: normalizeJurisdiction(parsed.value),
|
|
390
393
|
isDirectTarget: false,
|
|
391
394
|
isOrganizationTarget: false,
|
|
392
395
|
isJurisdictionTarget: true,
|
|
@@ -29,8 +29,14 @@ export declare class EmployeeEntryEditor extends BundleEntryEditor {
|
|
|
29
29
|
getRole(): string | undefined;
|
|
30
30
|
/** Writes the canonical employee `worksFor` claim on this entry. */
|
|
31
31
|
setWorksFor(worksFor: string): this;
|
|
32
|
+
/** Reads the canonical organization for which the employee works. */
|
|
33
|
+
getWorksFor(): string | undefined;
|
|
32
34
|
/** Writes the canonical employee `memberOf` claim on this entry. */
|
|
33
35
|
setMemberOf(memberOf: string): this;
|
|
36
|
+
/** Reads the canonical organization membership reference. */
|
|
37
|
+
getMemberOf(): string | undefined;
|
|
34
38
|
/** Writes the canonical employee organization tax id claim on this entry. */
|
|
35
39
|
setMemberOfOrgTaxId(taxId: string): this;
|
|
40
|
+
/** Reads the canonical fiscal identifier attached to the membership. */
|
|
41
|
+
getMemberOfOrgTaxId(): string | undefined;
|
|
36
42
|
}
|
|
@@ -76,13 +76,25 @@ export class EmployeeEntryEditor extends BundleEntryEditor {
|
|
|
76
76
|
setWorksFor(worksFor) {
|
|
77
77
|
return this.setClaim(ClaimsPersonSchemaorg.worksFor, String(worksFor).trim());
|
|
78
78
|
}
|
|
79
|
+
/** Reads the canonical organization for which the employee works. */
|
|
80
|
+
getWorksFor() {
|
|
81
|
+
return normalizeOptionalIdentifier(this.getClaim(ClaimsPersonSchemaorg.worksFor));
|
|
82
|
+
}
|
|
79
83
|
/** Writes the canonical employee `memberOf` claim on this entry. */
|
|
80
84
|
setMemberOf(memberOf) {
|
|
81
85
|
return this.setClaim(ClaimsPersonSchemaorg.memberOf, String(memberOf).trim());
|
|
82
86
|
}
|
|
87
|
+
/** Reads the canonical organization membership reference. */
|
|
88
|
+
getMemberOf() {
|
|
89
|
+
return normalizeOptionalIdentifier(this.getClaim(ClaimsPersonSchemaorg.memberOf));
|
|
90
|
+
}
|
|
83
91
|
/** Writes the canonical employee organization tax id claim on this entry. */
|
|
84
92
|
setMemberOfOrgTaxId(taxId) {
|
|
85
93
|
return this.setClaim(ClaimsPersonSchemaorg.memberOfOrgTaxId, String(taxId).trim());
|
|
86
94
|
}
|
|
95
|
+
/** Reads the canonical fiscal identifier attached to the membership. */
|
|
96
|
+
getMemberOfOrgTaxId() {
|
|
97
|
+
return normalizeOptionalIdentifier(this.getClaim(ClaimsPersonSchemaorg.memberOfOrgTaxId));
|
|
98
|
+
}
|
|
87
99
|
}
|
|
88
100
|
registerBundleEntryEditor(BundleEditableResourceTypes.employee, EmployeeEntryEditor);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdc-common-utils-ts",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.25",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"@stablelib/base64": "^1.0.1",
|
|
12
12
|
"@stablelib/utf8": "^1.0.2",
|
|
13
13
|
"base-x": "^4.0.0",
|
|
14
|
-
"gdc-common-utils-ts": "^2.0.1",
|
|
15
14
|
"jose": "^4.15.9",
|
|
16
15
|
"pako": "^2.1.0"
|
|
17
16
|
},
|