gdc-common-utils-ts 1.0.4 → 1.0.7

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.
Files changed (202) hide show
  1. package/dist/AesManager.d.ts +27 -0
  2. package/dist/AesManager.js +62 -0
  3. package/dist/CryptographyService.d.ts +76 -0
  4. package/dist/CryptographyService.js +403 -0
  5. package/dist/constants/Schemas.d.ts +45 -0
  6. package/dist/constants/Schemas.js +48 -0
  7. package/dist/constants/index.js +1 -0
  8. package/{src/constants/schemaorg.ts → dist/constants/schemaorg.d.ts} +24 -116
  9. package/dist/constants/schemaorg.js +185 -0
  10. package/dist/cryptoDecode.d.ts +3 -0
  11. package/dist/cryptoDecode.js +90 -0
  12. package/dist/cryptoEncode.d.ts +1 -0
  13. package/dist/cryptoEncode.js +30 -0
  14. package/dist/cryptography.abstract.d.ts +13 -0
  15. package/{src/cryptography.abstract.ts → dist/cryptography.abstract.js} +6 -14
  16. package/dist/hmac.d.ts +2 -0
  17. package/{src/hmac.ts → dist/hmac.js} +4 -7
  18. package/dist/index.js +3 -0
  19. package/{src/interfaces/Cryptography.types.ts → dist/interfaces/Cryptography.types.d.ts} +71 -71
  20. package/dist/interfaces/Cryptography.types.js +8 -0
  21. package/dist/interfaces/ICryptoHelper.d.ts +28 -0
  22. package/dist/interfaces/ICryptoHelper.js +3 -0
  23. package/dist/interfaces/ICryptography.d.ts +154 -0
  24. package/dist/interfaces/ICryptography.js +3 -0
  25. package/dist/interfaces/IWallet.d.ts +55 -0
  26. package/dist/interfaces/IWallet.js +3 -0
  27. package/dist/interfaces/MlDsa.d.ts +9 -0
  28. package/{src/interfaces/MlDsa.ts → dist/interfaces/MlDsa.js} +1 -5
  29. package/dist/interfaces/MlKem.d.ts +11 -0
  30. package/{src/interfaces/MlKem.ts → dist/interfaces/MlKem.js} +0 -5
  31. package/dist/models/aes.d.ts +85 -0
  32. package/dist/models/aes.js +10 -0
  33. package/dist/models/auth.d.ts +35 -0
  34. package/dist/models/auth.js +3 -0
  35. package/{src/models/bundle.ts → dist/models/bundle.d.ts} +41 -63
  36. package/dist/models/bundle.js +26 -0
  37. package/dist/models/clinical-sections.d.ts +36 -0
  38. package/dist/models/clinical-sections.en.d.ts +75 -0
  39. package/dist/models/clinical-sections.en.js +81 -0
  40. package/dist/models/clinical-sections.js +32 -0
  41. package/dist/models/comm.d.ts +44 -0
  42. package/dist/models/comm.js +4 -0
  43. package/{src/models/confidential-job.ts → dist/models/confidential-job.d.ts} +23 -45
  44. package/dist/models/confidential-job.js +20 -0
  45. package/dist/models/confidential-message.d.ts +97 -0
  46. package/dist/models/confidential-message.js +4 -0
  47. package/{src/models/confidential-storage.ts → dist/models/confidential-storage.d.ts} +35 -56
  48. package/dist/models/confidential-storage.js +3 -0
  49. package/{src/models/consent-rule.ts → dist/models/consent-rule.d.ts} +22 -42
  50. package/dist/models/consent-rule.js +21 -0
  51. package/{src/models/crypto.ts → dist/models/crypto.d.ts} +5 -13
  52. package/dist/models/crypto.js +3 -0
  53. package/dist/models/device-license.d.ts +133 -0
  54. package/dist/models/device-license.js +3 -0
  55. package/{src/models/did.ts → dist/models/did.d.ts} +21 -30
  56. package/dist/models/did.js +3 -0
  57. package/dist/models/index.js +31 -0
  58. package/dist/models/indexing.d.ts +11 -0
  59. package/dist/models/indexing.js +18 -0
  60. package/dist/models/issue.d.ts +57 -0
  61. package/dist/models/issue.js +75 -0
  62. package/dist/models/jsonapi.d.ts +13 -0
  63. package/dist/models/jsonapi.js +3 -0
  64. package/{src/models/jwe.ts → dist/models/jwe.d.ts} +10 -22
  65. package/dist/models/jwe.js +3 -0
  66. package/{src/models/jwk.ts → dist/models/jwk.d.ts} +0 -11
  67. package/dist/models/jwk.js +3 -0
  68. package/{src/models/jws.ts → dist/models/jws.d.ts} +0 -7
  69. package/dist/models/jws.js +3 -0
  70. package/dist/models/jwt.d.ts +9 -0
  71. package/dist/models/jwt.js +3 -0
  72. package/dist/models/multibase58.d.ts +13 -0
  73. package/dist/models/multibase58.js +40 -0
  74. package/dist/models/oidc4ida.common.model.d.ts +33 -0
  75. package/dist/models/oidc4ida.common.model.js +3 -0
  76. package/dist/models/oidc4ida.document.model.d.ts +50 -0
  77. package/dist/models/oidc4ida.document.model.js +3 -0
  78. package/{src/models/oidc4ida.electronicRecord.model.ts → dist/models/oidc4ida.electronicRecord.model.d.ts} +18 -37
  79. package/dist/models/oidc4ida.electronicRecord.model.js +3 -0
  80. package/{src/models/oidc4ida.evidence.model.ts → dist/models/oidc4ida.evidence.model.d.ts} +17 -35
  81. package/dist/models/oidc4ida.evidence.model.js +5 -0
  82. package/dist/models/openid-device.d.ts +119 -0
  83. package/dist/models/openid-device.js +3 -0
  84. package/dist/models/operation-outcome.d.ts +26 -0
  85. package/dist/models/operation-outcome.js +3 -0
  86. package/{src/models/params.ts → dist/models/params.d.ts} +20 -29
  87. package/dist/models/params.js +3 -0
  88. package/dist/models/resource-document.d.ts +14 -0
  89. package/dist/models/resource-document.js +3 -0
  90. package/dist/models/response.d.ts +1 -0
  91. package/dist/models/response.js +3 -0
  92. package/dist/models/urlPath.d.ts +58 -0
  93. package/dist/models/urlPath.js +76 -0
  94. package/dist/models/verifiable-credential.d.ts +45 -0
  95. package/dist/models/verifiable-credential.js +8 -0
  96. package/dist/utils/actor.d.ts +18 -0
  97. package/dist/utils/actor.js +36 -0
  98. package/dist/utils/base-convert.d.ts +20 -0
  99. package/{src/utils/base-convert.ts → dist/utils/base-convert.js} +23 -36
  100. package/dist/utils/baseN.d.ts +35 -0
  101. package/dist/utils/baseN.js +174 -0
  102. package/dist/utils/bundle.d.ts +6 -0
  103. package/dist/utils/bundle.js +32 -0
  104. package/dist/utils/content.d.ts +55 -0
  105. package/{src/utils/content.ts → dist/utils/content.js} +4 -10
  106. package/dist/utils/did.d.ts +67 -0
  107. package/dist/utils/did.js +123 -0
  108. package/dist/utils/format-converter.d.ts +21 -0
  109. package/dist/utils/format-converter.js +109 -0
  110. package/dist/utils/index.js +13 -0
  111. package/dist/utils/jwt.d.ts +52 -0
  112. package/dist/utils/jwt.js +153 -0
  113. package/dist/utils/manager-error.d.ts +15 -0
  114. package/dist/utils/manager-error.js +23 -0
  115. package/dist/utils/multibase58.d.ts +13 -0
  116. package/dist/utils/multibase58.js +40 -0
  117. package/dist/utils/multibasehash.d.ts +8 -0
  118. package/{src/utils/multibasehash.ts → dist/utils/multibasehash.js} +8 -13
  119. package/dist/utils/normalize.d.ts +16 -0
  120. package/{src/utils/normalize.ts → dist/utils/normalize.js} +15 -18
  121. package/dist/utils/object-convert.d.ts +20 -0
  122. package/{src/utils/object-convert.ts → dist/utils/object-convert.js} +10 -16
  123. package/dist/utils/string-convert.d.ts +24 -0
  124. package/{src/utils/string-convert.ts → dist/utils/string-convert.js} +5 -14
  125. package/dist/utils/string-utils.d.ts +25 -0
  126. package/{src/utils/string-utils.ts → dist/utils/string-utils.js} +12 -16
  127. package/dist/utils/url.d.ts +27 -0
  128. package/{src/utils/url.ts → dist/utils/url.js} +6 -7
  129. package/package.json +56 -14
  130. package/PUBLISHING.md +0 -33
  131. package/__tests__/AesManager.test.ts +0 -53
  132. package/__tests__/CryptographyService.test.ts +0 -194
  133. package/__tests__/bundle.test.ts +0 -29
  134. package/__tests__/content.test.ts +0 -72
  135. package/__tests__/crypto-encode-decode.test.ts +0 -52
  136. package/__tests__/crypto-hmac.test.ts +0 -21
  137. package/__tests__/did-generateServiceId.errors.test.ts +0 -8
  138. package/__tests__/did-generateServiceId.test.ts +0 -18
  139. package/__tests__/models-clinical-sections.test.ts +0 -32
  140. package/__tests__/models-multibase58.test.ts +0 -33
  141. package/__tests__/multibase58.errors.test.ts +0 -7
  142. package/__tests__/multibase58.test.ts +0 -28
  143. package/__tests__/multibasehash.test.ts +0 -25
  144. package/__tests__/utils-actor.test.ts +0 -46
  145. package/__tests__/utils-base-convert.test.ts +0 -57
  146. package/__tests__/utils-baseN.test.ts +0 -40
  147. package/__tests__/utils-did-extra.test.ts +0 -33
  148. package/__tests__/utils-format-converter.test.ts +0 -87
  149. package/__tests__/utils-jwt.test.ts +0 -57
  150. package/__tests__/utils-manager-error.test.ts +0 -11
  151. package/__tests__/utils-normalize.test.ts +0 -15
  152. package/__tests__/utils-object-convert.test.ts +0 -38
  153. package/__tests__/utils-string-convert.test.ts +0 -20
  154. package/__tests__/utils-string-utils.test.ts +0 -25
  155. package/__tests__/utils-url.test.ts +0 -21
  156. package/babel.config.cjs +0 -5
  157. package/jest.config.ts +0 -47
  158. package/src/AesManager.ts +0 -82
  159. package/src/CryptographyService.ts +0 -461
  160. package/src/JweManager.ts.txt +0 -365
  161. package/src/KmsService.txt +0 -493
  162. package/src/constants/Schemas.ts +0 -61
  163. package/src/cryptoDecode.ts +0 -104
  164. package/src/cryptoEncode.ts +0 -36
  165. package/src/interfaces/ICryptoHelper.ts +0 -33
  166. package/src/interfaces/ICryptography.ts +0 -177
  167. package/src/interfaces/IWallet.ts +0 -62
  168. package/src/models/aes.ts +0 -93
  169. package/src/models/auth.ts +0 -38
  170. package/src/models/bundle.txt +0 -93
  171. package/src/models/clinical-sections.en.ts +0 -82
  172. package/src/models/clinical-sections.ts +0 -64
  173. package/src/models/comm.ts +0 -63
  174. package/src/models/confidential-message.ts +0 -137
  175. package/src/models/device-license.ts +0 -161
  176. package/src/models/indexing.ts +0 -20
  177. package/src/models/issue.ts +0 -85
  178. package/src/models/jsonapi.ts +0 -19
  179. package/src/models/jwt.ts +0 -15
  180. package/src/models/multibase58.ts +0 -46
  181. package/src/models/oidc4ida.common.model.ts +0 -39
  182. package/src/models/oidc4ida.document.model.ts +0 -61
  183. package/src/models/openid-device.ts +0 -146
  184. package/src/models/operation-outcome.ts +0 -34
  185. package/src/models/resource-document.ts +0 -21
  186. package/src/models/response.ts +0 -5
  187. package/src/models/urlPath.ts +0 -76
  188. package/src/models/verifiable-credential.ts +0 -52
  189. package/src/types/noble-hashes.d.ts +0 -4
  190. package/src/utils/actor.ts +0 -56
  191. package/src/utils/baseN.ts +0 -203
  192. package/src/utils/bundle.ts +0 -30
  193. package/src/utils/did.ts +0 -155
  194. package/src/utils/format-converter.ts +0 -119
  195. package/src/utils/jwt.ts +0 -165
  196. package/src/utils/manager-error.ts +0 -27
  197. package/src/utils/multibase58.ts +0 -46
  198. package/tsconfig.json +0 -15
  199. /package/{src/constants/index.ts → dist/constants/index.d.ts} +0 -0
  200. /package/{src/index.ts → dist/index.d.ts} +0 -0
  201. /package/{src/models/index.ts → dist/models/index.d.ts} +0 -0
  202. /package/{src/utils/index.ts → dist/utils/index.d.ts} +0 -0
@@ -23,70 +23,55 @@
23
23
  * contains the structured data derived from the claims.
24
24
  * - `request`/`response`: Contextual objects indicating the operation's details or result.
25
25
  */
26
-
27
26
  import { OperationOutcome } from "./operation-outcome";
28
-
29
- // ===================================================================================
30
- // BUNDLE ENTRY COMPONENTS
31
- // ===================================================================================
32
-
33
27
  /**
34
28
  * Defines the `request` property for an entry in a request Bundle.
35
29
  * This indicates the intended action for the entry.
36
30
  */
37
31
  export interface BundleRequest {
38
- method: 'POST' | 'PUT' | 'DELETE' | 'GET';
39
- url: string;
32
+ method: 'POST' | 'PUT' | 'DELETE' | 'GET';
33
+ url: string;
40
34
  }
41
-
42
35
  /**
43
36
  * Defines the `response` property for an entry in a response Bundle.
44
37
  * This indicates the outcome of the action for the entry.
45
38
  */
46
39
  export interface BundleResponse {
47
- /** The HTTP status code as a string (e.g., "201", "404"). */
48
- status: string;
49
- [key: string]: any;
40
+ /** The HTTP status code as a string (e.g., "201", "404"). */
41
+ status: string;
42
+ [key: string]: any;
50
43
  }
51
-
52
44
  /**
53
45
  * Defines the `meta` property that holds the original, unprocessed claims for a BundleEntry.
54
46
  * This ensures that the complete context of a request is preserved through the entire
55
47
  * asynchronous workflow and is available for error reporting.
56
48
  */
57
49
  export interface BundleEntryMeta {
58
- /** The original, flattened claims record for this specific entry. */
59
- claims?: Record<string, any>;
50
+ /** The original, flattened claims record for this specific entry. */
51
+ claims?: Record<string, any>;
60
52
  }
61
-
62
- // ===================================================================================
63
- // BUNDLE ENTRY TYPES
64
- // ===================================================================================
65
-
66
53
  /**
67
54
  * @deprecated Use `BundleEntry` instead. This will be removed in a future version.
68
55
  * Represents a single entry in an INCOMING request Bundle.
69
56
  */
70
57
  export interface BundleEntryRequest {
71
- id?: string;
72
- type: string;
73
- request: BundleRequest;
74
- resource?: Record<string, any>;
75
- meta?: BundleEntryMeta;
58
+ id?: string;
59
+ type: string;
60
+ request: BundleRequest;
61
+ resource?: Record<string, any>;
62
+ meta?: BundleEntryMeta;
76
63
  }
77
-
78
64
  /**
79
65
  * @deprecated Use `BundleEntry` instead. This will be removed in a future version.
80
66
  * Represents a single successful entry in an OUTGOING response Bundle.
81
67
  */
82
68
  export interface BundleEntryResponse {
83
- id?: string;
84
- type: string;
85
- response: BundleResponse;
86
- resource?: Record<string, any>;
87
- meta?: BundleEntryMeta;
69
+ id?: string;
70
+ type: string;
71
+ response: BundleResponse;
72
+ resource?: Record<string, any>;
73
+ meta?: BundleEntryMeta;
88
74
  }
89
-
90
75
  /**
91
76
  * Represents a single error entry in a response Bundle.
92
77
  *
@@ -96,21 +81,20 @@ export interface BundleEntryResponse {
96
81
  * request entry. This allows the client to correlate the exact input that caused the failure.
97
82
  */
98
83
  export interface ErrorEntry {
99
- /** An optional unique identifier for this entry. */
100
- id?: string;
101
- /** The `type` of the original request entry that failed. */
102
- type: string;
103
- /** The original, unprocessed `meta` object from the request entry that failed. */
104
- meta?: BundleEntryMeta;
105
- /** The details of the error that occurred. */
106
- response: {
107
- /** The HTTP status code reflecting the error (e.g., "400", "500"). */
108
- status: string;
109
- /** A FHIR OperationOutcome resource providing detailed error diagnostics. */
110
- outcome: OperationOutcome;
111
- };
84
+ /** An optional unique identifier for this entry. */
85
+ id?: string;
86
+ /** The `type` of the original request entry that failed. */
87
+ type: string;
88
+ /** The original, unprocessed `meta` object from the request entry that failed. */
89
+ meta?: BundleEntryMeta;
90
+ /** The details of the error that occurred. */
91
+ response: {
92
+ /** The HTTP status code reflecting the error (e.g., "400", "500"). */
93
+ status: string;
94
+ /** A FHIR OperationOutcome resource providing detailed error diagnostics. */
95
+ outcome: OperationOutcome;
96
+ };
112
97
  }
113
-
114
98
  /**
115
99
  * Represents a single, canonical entry within a `BundleJsonApi`.
116
100
  * This structure is used for both requests and successful responses.
@@ -122,18 +106,13 @@ export interface ErrorEntry {
122
106
  * @property {BundleResponse} [response] - Details of the operation outcome (for response bundles).
123
107
  */
124
108
  export type BundleEntry = {
125
- id?: string;
126
- type: string;
127
- meta?: BundleEntryMeta;
128
- resource?: Record<string, any>;
129
- request?: BundleRequest;
130
- response?: BundleResponse;
131
- }
132
-
133
- // ===================================================================================
134
- // BUNDLE DEFINITION
135
- // ===================================================================================
136
-
109
+ id?: string;
110
+ type: string;
111
+ meta?: BundleEntryMeta;
112
+ resource?: Record<string, any>;
113
+ request?: BundleRequest;
114
+ response?: BundleResponse;
115
+ };
137
116
  /**
138
117
  * Represents the canonical Bundle structure used as the `body` of a request or response.
139
118
  * The generic type `T` allows for specifying whether the `data` array contains request
@@ -144,9 +123,8 @@ export type BundleEntry = {
144
123
  * const responseBundle: BundleJsonApi<BundleEntry | ErrorEntry> = { ... };
145
124
  */
146
125
  export interface BundleJsonApi<T = BundleEntry | ErrorEntry> {
147
- data: T[];
148
- resourceType: 'Bundle';
149
- total?: number;
150
- type: string;
126
+ data: T[];
127
+ resourceType: 'Bundle';
128
+ total?: number;
129
+ type: string;
151
130
  }
152
-
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @file src/models/bundle.ts
3
+ * @copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
4
+ *
5
+ * @summary
6
+ * This file defines the canonical data structures for "Bundles" and their "Entries"
7
+ * within this system, following a hybrid FHIR / JSON:API pattern. It is the single
8
+ * source of truth for the shape of request and response bodies.
9
+ *
10
+ * @architecture
11
+ * The models herein are critical for maintaining architectural consistency.
12
+ *
13
+ * 1. **`BundleJsonApi`**: The top-level container for all batch operations. Corresponds
14
+ * to the `body` of a DIDComm message or a standard API request.
15
+ *
16
+ * 2. **`BundleEntry`**: The core component of a Bundle. Represents a single unit of work,
17
+ * such as registering one organization or creating one employee. It has a strict
18
+ * structure:
19
+ * - `type`: A string that defines the business action (e.g., 'Organization-registration-offer-v1.0').
20
+ * - `meta`: A **TOP-LEVEL** property containing the original `claims` for the operation.
21
+ * This is crucial for both processing and error reporting.
22
+ * - `resource`: A FHIR-like resource object that is the subject of the action. It
23
+ * contains the structured data derived from the claims.
24
+ * - `request`/`response`: Contextual objects indicating the operation's details or result.
25
+ */
26
+ export {};
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Canonical registry of supported clinical document sections (e.g., IPS Composition sections).
3
+ *
4
+ * Design goals:
5
+ * - Use stable codes (LOINC) for interoperability.
6
+ * - Provide a reverse-DNS i18n key for consistent UI translations across apps.
7
+ * - Keep this in `gdc-common-utils-ts` so both backend and frontend can share it.
8
+ */
9
+ import { clinicalSectionTitleEn } from './clinical-sections.en';
10
+ export declare const LOINC_SYSTEM_URL: "http://loinc.org";
11
+ export declare const LOINC_SYSTEM_REVERSE_DNS: "org.loinc";
12
+ export type ClinicalSectionDescriptor = {
13
+ /** Canonical coding system URL (FHIR-style). */
14
+ system: string;
15
+ /** Code within the coding system (e.g., a LOINC code). */
16
+ code: string;
17
+ /**
18
+ * Reverse-DNS translation key, intended for i18n resources.
19
+ * Example: `org.loinc.48765-2`.
20
+ */
21
+ i18nKey: string;
22
+ /**
23
+ * English fallback label (documentation/UI fallback).
24
+ *
25
+ * Prefer rendering a UI label via `i18nKey` (e.g., `org.loinc.<CODE>`) rather than relying on this.
26
+ */
27
+ titleEn?: string;
28
+ /** True when this is an IPS-aligned section code. */
29
+ ips?: boolean;
30
+ };
31
+ export declare function loincI18nKey(code: string): string;
32
+ export type SupportedClinicalSectionCode = keyof typeof clinicalSectionTitleEn;
33
+ export declare const supportedClinicalSectionCodes: readonly ("10154-3" | "10157-6" | "10160-0" | "10164-2" | "10183-2" | "10184-0" | "10187-3" | "10210-3" | "10216-0" | "10218-6" | "10222-8" | "10223-6" | "11329-0" | "11348-0" | "11369-6" | "11493-4" | "11535-2" | "11537-8" | "18776-5" | "18841-7" | "29299-5" | "29545-1" | "29549-3" | "29554-3" | "29762-2" | "30954-2" | "42344-2" | "42346-7" | "42348-3" | "42349-1" | "46240-8" | "46241-6" | "46264-8" | "47420-5" | "47519-4" | "48765-2" | "48768-6" | "51848-0" | "55109-3" | "55122-6" | "57852-6" | "59768-2" | "59769-0" | "59770-8" | "59771-6" | "59772-4" | "59773-2" | "59775-7" | "59776-5" | "61149-1" | "61150-9" | "69730-0" | "8648-8" | "8653-8" | "8716-3" | "60591-5" | "11450-4" | "61144-2" | "82810-3" | "87520-3" | "10190-7" | "18726-0" | "11503-0" | "56796-6")[];
34
+ export declare const clinicalSectionRegistry: Readonly<Record<string, ClinicalSectionDescriptor>>;
35
+ export { clinicalSectionTitleEn };
36
+ export declare function getClinicalSectionByCode(code: string): ClinicalSectionDescriptor | undefined;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * English display labels for supported clinical document section codes.
3
+ *
4
+ * Notes:
5
+ * - This file is intentionally separate from the section registry so apps can:
6
+ * - use these labels as a default (e.g., server-side rendering), and/or
7
+ * - override them via i18n resources keyed by `org.loinc.<CODE>`.
8
+ * - Sources: HL7 FHIR doc-section-codes + project-specific additions.
9
+ */
10
+ export declare const clinicalSectionTitleEn: {
11
+ readonly '10154-3': "Chief complaint Narrative - Reported";
12
+ readonly '10157-6': "History of family member diseases Narrative";
13
+ readonly '10160-0': "History of Medication use Narrative";
14
+ readonly '10164-2': "History of Present illness Narrative";
15
+ readonly '10183-2': "Hospital discharge medications Narrative";
16
+ readonly '10184-0': "Hospital discharge physical findings Narrative";
17
+ readonly '10187-3': "Review of systems Narrative - Reported";
18
+ readonly '10210-3': "Physical findings of General status Narrative";
19
+ readonly '10216-0': "Surgical operation note fluids Narrative";
20
+ readonly '10218-6': "Surgical operation note postoperative diagnosis Narrative";
21
+ readonly '10222-8': "Surgical operation note surgical complications [Interpretation] Narrative";
22
+ readonly '10223-6': "Surgical operation note surgical procedure Narrative";
23
+ readonly '11329-0': "History general Narrative - Reported";
24
+ readonly '11348-0': "History of Past illness Narrative";
25
+ readonly '11369-6': "History of Immunization Narrative";
26
+ readonly '11493-4': "Hospital discharge studies summary Narrative";
27
+ readonly '11535-2': "Hospital discharge Dx Narrative";
28
+ readonly '11537-8': "Surgical drains Narrative";
29
+ readonly '18776-5': "Plan of care note";
30
+ readonly '18841-7': "Hospital consultations Document";
31
+ readonly '29299-5': "Reason for visit Narrative";
32
+ readonly '29545-1': "Physical findings Narrative";
33
+ readonly '29549-3': "Medication administered Narrative";
34
+ readonly '29554-3': "Procedure Narrative";
35
+ readonly '29762-2': "Social history Narrative";
36
+ readonly '30954-2': "Relevant diagnostic tests/laboratory data Narrative";
37
+ readonly '42344-2': "Discharge diet (narrative)";
38
+ readonly '42346-7': "Medications on admission (narrative)";
39
+ readonly '42348-3': "Advance directives";
40
+ readonly '42349-1': "Reason for referral (narrative)";
41
+ readonly '46240-8': "History of Hospitalizations+Outpatient visits Narrative";
42
+ readonly '46241-6': "Hospital admission diagnosis Narrative - Reported";
43
+ readonly '46264-8': "History of medical device use";
44
+ readonly '47420-5': "Functional status assessment note";
45
+ readonly '47519-4': "History of Procedures Document";
46
+ readonly '48765-2': "Allergies and adverse reactions Document";
47
+ readonly '48768-6': "Payment sources Document";
48
+ readonly '51848-0': "Evaluation note";
49
+ readonly '55109-3': "Complications Document";
50
+ readonly '55122-6': "Surgical operation note implants Narrative";
51
+ readonly '57852-6': "Problem list Narrative - Reported";
52
+ readonly '59768-2': "Procedure indications [Interpretation] Narrative";
53
+ readonly '59769-0': "Postprocedure diagnosis Narrative";
54
+ readonly '59770-8': "Procedure estimated blood loss Narrative";
55
+ readonly '59771-6': "Procedure implants Narrative";
56
+ readonly '59772-4': "Planned procedure Narrative";
57
+ readonly '59773-2': "Procedure specimens taken Narrative";
58
+ readonly '59775-7': "Procedure disposition Narrative";
59
+ readonly '59776-5': "Procedure findings Narrative";
60
+ readonly '61149-1': "Objective Narrative";
61
+ readonly '61150-9': "Subjective Narrative";
62
+ readonly '69730-0': "Instructions";
63
+ readonly '8648-8': "Hospital course Narrative";
64
+ readonly '8653-8': "Hospital Discharge instructions";
65
+ readonly '8716-3': "Vital signs";
66
+ readonly '60591-5': "Patient summary";
67
+ readonly '11450-4': "Problem list";
68
+ readonly '61144-2': "Diet";
69
+ readonly '82810-3': "History of pregnancy";
70
+ readonly '87520-3': "Health insurance coverage";
71
+ readonly '10190-7': "Mental status";
72
+ readonly '18726-0': "Radiology studies";
73
+ readonly '11503-0': "Medical records (generic)";
74
+ readonly '56796-6': "Healthcare (general)";
75
+ };
@@ -0,0 +1,81 @@
1
+ /**
2
+ * English display labels for supported clinical document section codes.
3
+ *
4
+ * Notes:
5
+ * - This file is intentionally separate from the section registry so apps can:
6
+ * - use these labels as a default (e.g., server-side rendering), and/or
7
+ * - override them via i18n resources keyed by `org.loinc.<CODE>`.
8
+ * - Sources: HL7 FHIR doc-section-codes + project-specific additions.
9
+ */
10
+ export const clinicalSectionTitleEn = {
11
+ // ---------------------------------------------------------------------------
12
+ // HL7 FHIR doc-section-codes (LOINC) — subset used by the platform/docs
13
+ // ---------------------------------------------------------------------------
14
+ '10154-3': 'Chief complaint Narrative - Reported',
15
+ '10157-6': 'History of family member diseases Narrative',
16
+ '10160-0': 'History of Medication use Narrative',
17
+ '10164-2': 'History of Present illness Narrative',
18
+ '10183-2': 'Hospital discharge medications Narrative',
19
+ '10184-0': 'Hospital discharge physical findings Narrative',
20
+ '10187-3': 'Review of systems Narrative - Reported',
21
+ '10210-3': 'Physical findings of General status Narrative',
22
+ '10216-0': 'Surgical operation note fluids Narrative',
23
+ '10218-6': 'Surgical operation note postoperative diagnosis Narrative',
24
+ '10222-8': 'Surgical operation note surgical complications [Interpretation] Narrative',
25
+ '10223-6': 'Surgical operation note surgical procedure Narrative',
26
+ '11329-0': 'History general Narrative - Reported',
27
+ '11348-0': 'History of Past illness Narrative',
28
+ '11369-6': 'History of Immunization Narrative',
29
+ '11493-4': 'Hospital discharge studies summary Narrative',
30
+ '11535-2': 'Hospital discharge Dx Narrative',
31
+ '11537-8': 'Surgical drains Narrative',
32
+ '18776-5': 'Plan of care note',
33
+ '18841-7': 'Hospital consultations Document',
34
+ '29299-5': 'Reason for visit Narrative',
35
+ '29545-1': 'Physical findings Narrative',
36
+ '29549-3': 'Medication administered Narrative',
37
+ '29554-3': 'Procedure Narrative',
38
+ '29762-2': 'Social history Narrative',
39
+ '30954-2': 'Relevant diagnostic tests/laboratory data Narrative',
40
+ '42344-2': 'Discharge diet (narrative)',
41
+ '42346-7': 'Medications on admission (narrative)',
42
+ '42348-3': 'Advance directives',
43
+ '42349-1': 'Reason for referral (narrative)',
44
+ '46240-8': 'History of Hospitalizations+Outpatient visits Narrative',
45
+ '46241-6': 'Hospital admission diagnosis Narrative - Reported',
46
+ '46264-8': 'History of medical device use',
47
+ '47420-5': 'Functional status assessment note',
48
+ '47519-4': 'History of Procedures Document',
49
+ '48765-2': 'Allergies and adverse reactions Document',
50
+ '48768-6': 'Payment sources Document',
51
+ '51848-0': 'Evaluation note',
52
+ '55109-3': 'Complications Document',
53
+ '55122-6': 'Surgical operation note implants Narrative',
54
+ '57852-6': 'Problem list Narrative - Reported',
55
+ '59768-2': 'Procedure indications [Interpretation] Narrative',
56
+ '59769-0': 'Postprocedure diagnosis Narrative',
57
+ '59770-8': 'Procedure estimated blood loss Narrative',
58
+ '59771-6': 'Procedure implants Narrative',
59
+ '59772-4': 'Planned procedure Narrative',
60
+ '59773-2': 'Procedure specimens taken Narrative',
61
+ '59775-7': 'Procedure disposition Narrative',
62
+ '59776-5': 'Procedure findings Narrative',
63
+ '61149-1': 'Objective Narrative',
64
+ '61150-9': 'Subjective Narrative',
65
+ '69730-0': 'Instructions',
66
+ '8648-8': 'Hospital course Narrative',
67
+ '8653-8': 'Hospital Discharge instructions',
68
+ '8716-3': 'Vital signs',
69
+ // ---------------------------------------------------------------------------
70
+ // Project additions (not part of doc-section-codes, but used by clients)
71
+ // ---------------------------------------------------------------------------
72
+ '60591-5': 'Patient summary',
73
+ '11450-4': 'Problem list',
74
+ '61144-2': 'Diet',
75
+ '82810-3': 'History of pregnancy',
76
+ '87520-3': 'Health insurance coverage',
77
+ '10190-7': 'Mental status',
78
+ '18726-0': 'Radiology studies',
79
+ '11503-0': 'Medical records (generic)',
80
+ '56796-6': 'Healthcare (general)',
81
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Canonical registry of supported clinical document sections (e.g., IPS Composition sections).
3
+ *
4
+ * Design goals:
5
+ * - Use stable codes (LOINC) for interoperability.
6
+ * - Provide a reverse-DNS i18n key for consistent UI translations across apps.
7
+ * - Keep this in `gdc-common-utils-ts` so both backend and frontend can share it.
8
+ */
9
+ import { clinicalSectionTitleEn } from './clinical-sections.en.js';
10
+ export const LOINC_SYSTEM_URL = 'http://loinc.org';
11
+ export const LOINC_SYSTEM_REVERSE_DNS = 'org.loinc';
12
+ export function loincI18nKey(code) {
13
+ return `${LOINC_SYSTEM_REVERSE_DNS}.${code}`;
14
+ }
15
+ export const supportedClinicalSectionCodes = Object.freeze(Object.keys(clinicalSectionTitleEn));
16
+ export const clinicalSectionRegistry = (() => {
17
+ const entries = Object.entries(clinicalSectionTitleEn).map(([code, titleEn]) => {
18
+ const descriptor = {
19
+ system: LOINC_SYSTEM_URL,
20
+ code,
21
+ i18nKey: loincI18nKey(code),
22
+ titleEn,
23
+ ips: true,
24
+ };
25
+ return [code, descriptor];
26
+ });
27
+ return Object.freeze(Object.fromEntries(entries));
28
+ })();
29
+ export { clinicalSectionTitleEn };
30
+ export function getClinicalSectionByCode(code) {
31
+ return clinicalSectionRegistry[code];
32
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Represents the standard payload of a DIDComm v2 message.
3
+ * @see https://identity.foundation/didcomm-messaging/spec/v2.0/#plaintext-message-structure
4
+ */
5
+ export interface DidCommPayload {
6
+ id: string;
7
+ type: string;
8
+ from?: string;
9
+ to?: string[];
10
+ thid?: string;
11
+ pthid?: string;
12
+ created_time?: number;
13
+ expires_time?: number;
14
+ body: {
15
+ [key: string]: any;
16
+ };
17
+ }
18
+ /**
19
+ * Represents a data entry in the `body` of a CommMsgExtended,
20
+ * following a hybrid JSON:API and FHIR structure.
21
+ */
22
+ export interface DataEntry {
23
+ id: string;
24
+ type: 'Annotation' | 'Reference' | 'Attachment' | 'CodeableConcept' | string;
25
+ resource: {
26
+ [key: string]: any;
27
+ };
28
+ meta?: {
29
+ claims: any;
30
+ };
31
+ }
32
+ /**
33
+ * The canonical, internal representation of a secure message, extending
34
+ * the standard DIDComm payload with FHIR-specific, flattened metadata.
35
+ */
36
+ export interface CommMsgExtended extends DidCommPayload {
37
+ body: {
38
+ data: DataEntry[];
39
+ };
40
+ }
41
+ /**
42
+ * A type placeholder for a FHIR Communication resource.
43
+ */
44
+ export type FhirCommunication = any;
@@ -0,0 +1,4 @@
1
+ // Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ // File: src/models/comm.ts
3
+ // Description: Defines the core communication and data structures based on DIDComm and FHIR.
4
+ export {};
@@ -1,50 +1,43 @@
1
- // Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
2
- // File: crypto-ts/models/confidential-job.ts
3
-
4
1
  /**
5
2
  * @file This file contains the core data models for the job processing system.
6
3
  * These models are platform-agnostic and are part of the core SDK.
7
4
  * @sdk
8
5
  */
9
-
10
6
  import { IDecodedDidcommPayload as DecodedDidcommPayload } from "./confidential-message";
11
7
  import { ConfidentialStorageDoc, IndexedData } from "./confidential-storage";
12
8
  import { ServiceEndpointSelector } from "./did";
13
-
14
9
  /** When the organization has its own domain for the connector do not appear in the path:
15
10
  * - the tenantId and jurisdiction, and
16
- * - the apiVersion and sector;
11
+ * - the apiVersion and sector;
17
12
  */
18
13
  export interface JobRequestInfo extends ServiceEndpointSelector {
19
- /** When the organization has its own domain for the connector the tenantId and jurisdiction do not appear in the path */
20
- tenantId?: string;
21
- jurisdiction?: string;
22
- /** The Unix epoch timestamp (in milliseconds) of when the job record was created. */
23
- createdAtTimestamp: number;
24
- requestUrl?: string;
25
- httpMethod?: string;
26
- contentType?: string;
27
- language?: string;
14
+ /** When the organization has its own domain for the connector the tenantId and jurisdiction do not appear in the path */
15
+ tenantId?: string;
16
+ jurisdiction?: string;
17
+ /** The Unix epoch timestamp (in milliseconds) of when the job record was created. */
18
+ createdAtTimestamp: number;
19
+ requestUrl?: string;
20
+ httpMethod?: string;
21
+ contentType?: string;
22
+ language?: string;
28
23
  }
29
-
30
24
  /**
31
25
  * Defines the possible statuses of a job throughout its lifecycle.
32
26
  */
33
- export enum JobStatus {
34
- /** The job has been created locally but not yet submitted. */
35
- DRAFT = 'DRAFT',
36
- /** The job is in the process of being submitted to the server. */
37
- SUBMITTING = 'SUBMITTING',
38
- /** The job was successfully submitted and is awaiting asynchronous processing. */
39
- SENT = 'SENT',
40
- /** The server has finished processing the job and returned a final result. This is a terminal state. */
41
- COMPLETED = 'COMPLETED',
42
- /** The job failed due to a transport-level error and will not be retried. This is a terminal state. */
43
- FAILED = 'FAILED',
44
- /** The job failed due to a transient error and may be retried. */
45
- ERROR_RETRYABLE = 'ERROR_RETRYABLE',
27
+ export declare enum JobStatus {
28
+ /** The job has been created locally but not yet submitted. */
29
+ DRAFT = "DRAFT",
30
+ /** The job is in the process of being submitted to the server. */
31
+ SUBMITTING = "SUBMITTING",
32
+ /** The job was successfully submitted and is awaiting asynchronous processing. */
33
+ SENT = "SENT",
34
+ /** The server has finished processing the job and returned a final result. This is a terminal state. */
35
+ COMPLETED = "COMPLETED",
36
+ /** The job failed due to a transport-level error and will not be retried. This is a terminal state. */
37
+ FAILED = "FAILED",
38
+ /** The job failed due to a transient error and may be retried. */
39
+ ERROR_RETRYABLE = "ERROR_RETRYABLE"
46
40
  }
47
-
48
41
  /**
49
42
  * Represents the entire data package for a single job ready for processing.
50
43
  * It combines the HTTP request context with the unprotected message and its security context.
@@ -52,7 +45,6 @@ export enum JobStatus {
52
45
  * The external URL has this structure: `https://<organization-domain>/:section/:format/:resourceType/:action`
53
46
  */
54
47
  export interface JobRequest extends ConfidentialStorageDoc, JobRequestInfo {
55
- // 'id' serves as the primary key in the vault.
56
48
  id: string;
57
49
  /**
58
50
  * DIDComm thread ID for correlating async jobs.
@@ -63,38 +55,24 @@ export interface JobRequest extends ConfidentialStorageDoc, JobRequestInfo {
63
55
  versionId?: string;
64
56
  vaultId?: string;
65
57
  chunks?: number;
66
-
67
- // From ConfidentialStorageDoc
68
-
69
58
  /** A number that MUST be incremented each time the document is updated. */
70
59
  sequence: number;
71
-
72
60
  /** Previous sequence being replaced by the update */
73
61
  previousSequence?: number;
74
-
75
62
  /** Contains an array of indexed attributes protected with HMAC for blind queries. */
76
63
  indexed?: IndexedData;
77
-
78
64
  /** The decoded DIDComm message. Present when the job is unprotected. */
79
65
  content?: DecodedDidcommPayload;
80
-
81
66
  /** The JWE representation of the encrypted content. Present when the job is protected. */
82
67
  jwe?: Record<string, any>;
83
-
84
- // Additional information for job processing
85
-
86
68
  /** Addtional information from HTTP header */
87
69
  onBehalfOf?: string;
88
-
89
70
  /** The URL provided by the server to poll for the job's status. */
90
71
  locationUrl?: string;
91
-
92
72
  /** A counter for the number of retry attempts. */
93
73
  retryCount?: number;
94
-
95
74
  /** The ID of the corresponding response message stored in the vault, once the job is COMPLETED. */
96
75
  responseMessageId?: string;
97
-
98
76
  /** CAUTION: Only for debugging purposes. It is the last error message, o*/
99
77
  errorMessage?: string;
100
78
  }
@@ -0,0 +1,20 @@
1
+ // Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ // File: crypto-ts/models/confidential-job.ts
3
+ /**
4
+ * Defines the possible statuses of a job throughout its lifecycle.
5
+ */
6
+ export var JobStatus;
7
+ (function (JobStatus) {
8
+ /** The job has been created locally but not yet submitted. */
9
+ JobStatus["DRAFT"] = "DRAFT";
10
+ /** The job is in the process of being submitted to the server. */
11
+ JobStatus["SUBMITTING"] = "SUBMITTING";
12
+ /** The job was successfully submitted and is awaiting asynchronous processing. */
13
+ JobStatus["SENT"] = "SENT";
14
+ /** The server has finished processing the job and returned a final result. This is a terminal state. */
15
+ JobStatus["COMPLETED"] = "COMPLETED";
16
+ /** The job failed due to a transport-level error and will not be retried. This is a terminal state. */
17
+ JobStatus["FAILED"] = "FAILED";
18
+ /** The job failed due to a transient error and may be retried. */
19
+ JobStatus["ERROR_RETRYABLE"] = "ERROR_RETRYABLE";
20
+ })(JobStatus || (JobStatus = {}));