@atomic-ehr/codegen 0.0.1-canary.20250924114918.f41354b → 0.0.1-canary.20250925150012.6169b6d
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/dist/api/builder.d.ts +5 -5
- package/dist/api/builder.js +6 -6
- package/dist/api/generators/base/BaseGenerator.d.ts +5 -5
- package/dist/api/generators/base/BaseGenerator.js +4 -4
- package/dist/api/generators/base/FileManager.d.ts +2 -2
- package/dist/api/generators/base/FileManager.js +1 -1
- package/dist/api/generators/base/PythonTypeMapper.d.ts +3 -3
- package/dist/api/generators/base/PythonTypeMapper.js +1 -1
- package/dist/api/generators/base/TemplateEngine.d.ts +1 -1
- package/dist/api/generators/base/TemplateEngine.js +1 -1
- package/dist/api/generators/base/TypeMapper.d.ts +2 -2
- package/dist/api/generators/base/TypeScriptTypeMapper.d.ts +3 -3
- package/dist/api/generators/base/TypeScriptTypeMapper.js +1 -1
- package/dist/api/generators/base/builders/DirectoryBuilder.d.ts +4 -4
- package/dist/api/generators/base/builders/FileBuilder.d.ts +2 -2
- package/dist/api/generators/base/builders/IndexBuilder.d.ts +2 -2
- package/dist/api/generators/base/enhanced-errors.d.ts +2 -2
- package/dist/api/generators/base/enhanced-errors.js +1 -1
- package/dist/api/generators/base/error-handler.d.ts +2 -2
- package/dist/api/generators/base/error-handler.js +1 -1
- package/dist/api/generators/base/errors.d.ts +2 -2
- package/dist/api/generators/base/index.d.ts +22 -22
- package/dist/api/generators/base/index.js +11 -11
- package/dist/api/generators/base/types.d.ts +4 -4
- package/dist/api/generators/typescript.d.ts +6 -6
- package/dist/api/generators/typescript.js +54 -46
- package/dist/api/index.d.ts +8 -8
- package/dist/api/index.js +3 -3
- package/dist/cli/commands/generate/typescript.d.ts +1 -1
- package/dist/cli/commands/generate/typescript.js +2 -2
- package/dist/cli/commands/generate.d.ts +1 -1
- package/dist/cli/commands/generate.js +4 -4
- package/dist/cli/commands/index.js +3 -3
- package/dist/cli/commands/typeschema/generate.js +3 -3
- package/dist/cli/commands/typeschema.js +2 -2
- package/dist/cli/index.js +51 -51
- package/dist/cli/utils/log.d.ts +2 -2
- package/dist/cli/utils/log.js +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/config.js +5 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/typeschema/cache.d.ts +7 -7
- package/dist/typeschema/core/binding.d.ts +1 -1
- package/dist/typeschema/core/binding.js +6 -4
- package/dist/typeschema/core/field-builder.d.ts +3 -3
- package/dist/typeschema/core/field-builder.js +3 -3
- package/dist/typeschema/core/identifier.d.ts +5 -17
- package/dist/typeschema/core/identifier.js +15 -47
- package/dist/typeschema/core/nested-types.d.ts +2 -2
- package/dist/typeschema/core/nested-types.js +2 -2
- package/dist/typeschema/core/transformer.d.ts +3 -3
- package/dist/typeschema/core/transformer.js +20 -28
- package/dist/typeschema/generator.d.ts +3 -4
- package/dist/typeschema/generator.js +9 -8
- package/dist/typeschema/index.d.ts +4 -5
- package/dist/typeschema/index.js +4 -4
- package/dist/typeschema/parser.d.ts +5 -5
- package/dist/typeschema/profile/processor.d.ts +2 -3
- package/dist/typeschema/profile/processor.js +12 -10
- package/dist/typeschema/types.d.ts +64 -375
- package/dist/typeschema/types.js +14 -2
- package/dist/typeschema/value-set/processor.d.ts +1 -1
- package/dist/typeschema/value-set/processor.js +1 -1
- package/package.json +1 -1
- package/dist/typeschema/schema.d.ts +0 -485
- package/dist/typeschema/schema.js +0 -456
- package/dist/typeschema/type-schema.types.d.ts +0 -186
- package/dist/typeschema/type-schema.types.js +0 -39
- package/dist/typeschema/utils.d.ts +0 -6
- package/dist/typeschema/utils.js +0 -13
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
* This file is deprecated as profiles are not part of the core TypeSchema specification
|
|
6
6
|
*/
|
|
7
7
|
import type { CanonicalManager } from "@atomic-ehr/fhir-canonical-manager";
|
|
8
|
-
import type {
|
|
9
|
-
import type { PackageInfo, TypeSchemaForProfile } from "../types.js";
|
|
8
|
+
import type { TypeSchemaForProfile } from "../types";
|
|
10
9
|
/**
|
|
11
10
|
* Transform a FHIR profile to TypeSchema format
|
|
12
11
|
* Profiles are treated as specialized resources that extend base resources
|
|
13
12
|
*/
|
|
14
|
-
export declare function transformProfile(fhirSchema:
|
|
13
|
+
export declare function transformProfile(fhirSchema: RichFHIRSchema, manager: ReturnType<typeof CanonicalManager>): Promise<TypeSchemaForProfile>;
|
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
* Handles transformation of FHIR profiles to TypeSchema format
|
|
6
6
|
* This file is deprecated as profiles are not part of the core TypeSchema specification
|
|
7
7
|
*/
|
|
8
|
-
import { buildSchemaIdentifier } from "../core/identifier
|
|
9
|
-
import { transformElements } from "../core/transformer
|
|
8
|
+
import { buildSchemaIdentifier } from "../core/identifier";
|
|
9
|
+
import { transformElements } from "../core/transformer";
|
|
10
10
|
/**
|
|
11
11
|
* Transform a FHIR profile to TypeSchema format
|
|
12
12
|
* Profiles are treated as specialized resources that extend base resources
|
|
13
13
|
*/
|
|
14
|
-
export async function transformProfile(fhirSchema, manager
|
|
14
|
+
export async function transformProfile(fhirSchema, manager) {
|
|
15
15
|
// Build profile identifier
|
|
16
|
-
const identifier = buildSchemaIdentifier(fhirSchema
|
|
16
|
+
const identifier = buildSchemaIdentifier(fhirSchema);
|
|
17
|
+
const packageInfo = fhirSchema.package_meta;
|
|
17
18
|
// Ensure this is recognized as a profile
|
|
18
19
|
if (identifier.kind !== "profile") {
|
|
19
20
|
throw new Error(`Expected profile, got ${identifier.kind} for ${fhirSchema.name}`);
|
|
@@ -33,10 +34,10 @@ export async function transformProfile(fhirSchema, manager, packageInfo) {
|
|
|
33
34
|
kind: baseKind,
|
|
34
35
|
package: isStandardFhir
|
|
35
36
|
? "hl7.fhir.r4.core"
|
|
36
|
-
:
|
|
37
|
+
: fhirSchema.package_meta.name || "undefined",
|
|
37
38
|
version: isStandardFhir
|
|
38
39
|
? "4.0.1"
|
|
39
|
-
:
|
|
40
|
+
: fhirSchema.package_meta.version || "undefined",
|
|
40
41
|
name: baseName,
|
|
41
42
|
url: baseUrl,
|
|
42
43
|
};
|
|
@@ -52,7 +53,7 @@ export async function transformProfile(fhirSchema, manager, packageInfo) {
|
|
|
52
53
|
profileSchema.description = fhirSchema.description;
|
|
53
54
|
}
|
|
54
55
|
// Add profile-specific metadata
|
|
55
|
-
const metadata = extractProfileMetadata(fhirSchema
|
|
56
|
+
const metadata = extractProfileMetadata(fhirSchema);
|
|
56
57
|
if (Object.keys(metadata).length > 0) {
|
|
57
58
|
profileSchema.metadata = metadata;
|
|
58
59
|
}
|
|
@@ -117,8 +118,9 @@ async function determineBaseKind(baseUrl, manager) {
|
|
|
117
118
|
/**
|
|
118
119
|
* Extract profile metadata from FHIR schema
|
|
119
120
|
*/
|
|
120
|
-
function extractProfileMetadata(fhirSchema
|
|
121
|
+
function extractProfileMetadata(fhirSchema) {
|
|
121
122
|
const metadata = {};
|
|
123
|
+
const packageInfo = fhirSchema.package_meta;
|
|
122
124
|
// Add profile-specific metadata
|
|
123
125
|
// @ts-ignore
|
|
124
126
|
if (fhirSchema.publisher)
|
|
@@ -149,9 +151,9 @@ function extractProfileMetadata(fhirSchema, packageInfo) {
|
|
|
149
151
|
metadata.package = packageInfo.name;
|
|
150
152
|
// @ts-ignore
|
|
151
153
|
}
|
|
152
|
-
else if (fhirSchema.
|
|
154
|
+
else if (fhirSchema.package_meta.name) {
|
|
153
155
|
// @ts-ignore
|
|
154
|
-
metadata.package = fhirSchema.
|
|
156
|
+
metadata.package = fhirSchema.package_meta.name;
|
|
155
157
|
}
|
|
156
158
|
return metadata;
|
|
157
159
|
}
|
|
@@ -1,482 +1,178 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A code generation friendly representation of FHIR StructureDefinition and
|
|
2
|
+
* A code generation friendly representation of FHIR StructureDefinition and
|
|
3
|
+
* FHIR Schema designed to simplify SDK resource classes/types generation.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
+
import type * as FS from "@atomic-ehr/fhirschema";
|
|
6
|
+
export interface PackageInfo {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
}
|
|
10
|
+
export type RichFHIRSchema = Omit<FS.FHIRSchema, "package_meta"> & {
|
|
11
|
+
package_meta: PackageInfo;
|
|
12
|
+
};
|
|
13
|
+
export declare const enrichFHIRSchema: (schema: FS.FHIRSchema) => RichFHIRSchema;
|
|
14
|
+
type IdentifierBase = {
|
|
5
15
|
name: string;
|
|
6
16
|
package: string;
|
|
7
17
|
version: string;
|
|
8
18
|
url: string;
|
|
9
19
|
};
|
|
10
|
-
|
|
11
|
-
export type TypeSchemaIdentifier = TypeSchemaIdentifierBase & (WithProfileKind | WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind);
|
|
12
|
-
/**
|
|
13
|
-
* Schema for basic FHIR data types like string, boolean, decimal
|
|
14
|
-
*/
|
|
15
|
-
export interface TypeSchemaForPrimitiveType {
|
|
16
|
-
/**
|
|
17
|
-
* The unique identifier for this primitive type
|
|
18
|
-
*/
|
|
19
|
-
identifier: TypeSchemaIdentifier & WithPrimitiveTypeKind;
|
|
20
|
-
/**
|
|
21
|
-
* Human-readable description of the primitive type
|
|
22
|
-
*/
|
|
23
|
-
description?: string;
|
|
24
|
-
/**
|
|
25
|
-
* The base type this primitive type extends (typically Element)
|
|
26
|
-
*/
|
|
27
|
-
base: WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind;
|
|
28
|
-
/**
|
|
29
|
-
* Other types that this primitive type depends on
|
|
30
|
-
*/
|
|
31
|
-
dependencies?: TypeSchemaIdentifier[];
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Constraint helper to ensure the kind profile
|
|
35
|
-
*/
|
|
36
|
-
export interface WithProfileKind {
|
|
37
|
-
kind: "profile";
|
|
38
|
-
[k: string]: unknown;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Constraint helper to ensure the kind is primitive-type
|
|
42
|
-
*/
|
|
43
|
-
export interface WithPrimitiveTypeKind {
|
|
20
|
+
type PrimitiveIdentifier = {
|
|
44
21
|
kind: "primitive-type";
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Constraint helper to ensure the kind is value-set
|
|
49
|
-
*/
|
|
50
|
-
export interface WithValuesetKind {
|
|
51
|
-
kind: "value-set";
|
|
52
|
-
[k: string]: unknown;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Constraint helper to ensure the kind is complex-type
|
|
56
|
-
*/
|
|
57
|
-
export interface WithComplexTypeKind {
|
|
22
|
+
} & IdentifierBase;
|
|
23
|
+
type ComplexTypeIdentifier = {
|
|
58
24
|
kind: "complex-type";
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Constraint helper to ensure the kind is resource
|
|
63
|
-
*/
|
|
64
|
-
export interface WithResourceKind {
|
|
25
|
+
} & IdentifierBase;
|
|
26
|
+
type ResourceIdentifier = {
|
|
65
27
|
kind: "resource";
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export interface WithNestedKind {
|
|
28
|
+
} & IdentifierBase;
|
|
29
|
+
type ValueSetIdentifier = {
|
|
30
|
+
kind: "value-set";
|
|
31
|
+
} & IdentifierBase;
|
|
32
|
+
type NestedIdentifier = {
|
|
72
33
|
kind: "nested";
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Constraint helper to ensure the kind is logical
|
|
77
|
-
*/
|
|
78
|
-
export interface WithLogicalKind {
|
|
79
|
-
kind: "logical";
|
|
80
|
-
[k: string]: unknown;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Constraint helper to ensure the kind is value-set
|
|
84
|
-
*/
|
|
85
|
-
export interface WithBindingKind {
|
|
34
|
+
} & IdentifierBase;
|
|
35
|
+
type BindingIdentifier = {
|
|
86
36
|
kind: "binding";
|
|
87
|
-
|
|
37
|
+
} & IdentifierBase;
|
|
38
|
+
type ProfileIdentifier = {
|
|
39
|
+
kind: "profile";
|
|
40
|
+
} & IdentifierBase;
|
|
41
|
+
type LogicalIdentifier = {
|
|
42
|
+
kind: "logical";
|
|
43
|
+
} & IdentifierBase;
|
|
44
|
+
export type Identifier = PrimitiveIdentifier | ComplexTypeIdentifier | ResourceIdentifier | NestedIdentifier | BindingIdentifier | ValueSetIdentifier | ProfileIdentifier | LogicalIdentifier;
|
|
45
|
+
export type TypeSchema = TypeSchemaForPrimitiveType | TypeSchemaForResourceComplexTypeLogical | TypeSchemaForValueSet | TypeSchemaForBinding | TypeSchemaForProfile;
|
|
46
|
+
interface TypeSchemaForPrimitiveType {
|
|
47
|
+
identifier: PrimitiveIdentifier;
|
|
48
|
+
description?: string;
|
|
49
|
+
base: Identifier;
|
|
50
|
+
dependencies?: Identifier[];
|
|
88
51
|
}
|
|
89
|
-
|
|
90
|
-
identifier:
|
|
91
|
-
|
|
92
|
-
* The base resource or type this profile constrains
|
|
93
|
-
*/
|
|
94
|
-
base: TypeSchemaIdentifier;
|
|
95
|
-
/**
|
|
96
|
-
* Human-readable description of the profile
|
|
97
|
-
*/
|
|
52
|
+
interface TypeSchemaForProfile {
|
|
53
|
+
identifier: ProfileIdentifier;
|
|
54
|
+
base: Identifier;
|
|
98
55
|
description?: string;
|
|
99
|
-
/**
|
|
100
|
-
* Fields defined or constrained by this profile
|
|
101
|
-
*/
|
|
102
56
|
fields?: Record<string, TypeSchemaField>;
|
|
103
|
-
/**
|
|
104
|
-
* Profile-specific constraints on elements
|
|
105
|
-
*/
|
|
106
57
|
constraints?: Record<string, ProfileConstraint>;
|
|
107
|
-
/**
|
|
108
|
-
* Extensions used by this profile
|
|
109
|
-
*/
|
|
110
58
|
extensions?: ProfileExtension[];
|
|
111
|
-
/**
|
|
112
|
-
* Validation rules specific to this profile
|
|
113
|
-
*/
|
|
114
59
|
validation?: ValidationRule[];
|
|
115
|
-
|
|
116
|
-
* Other types that this profile depends on
|
|
117
|
-
*/
|
|
118
|
-
dependencies?: TypeSchemaIdentifier[];
|
|
119
|
-
/**
|
|
120
|
-
* Additional profile metadata
|
|
121
|
-
*/
|
|
60
|
+
dependencies?: Identifier[];
|
|
122
61
|
metadata?: ProfileMetadata;
|
|
123
|
-
/**
|
|
124
|
-
* Nested types if any
|
|
125
|
-
*/
|
|
126
62
|
nested?: any[];
|
|
127
63
|
}
|
|
128
|
-
|
|
129
|
-
* Profile constraint on a field
|
|
130
|
-
*/
|
|
131
|
-
export interface ProfileConstraint {
|
|
132
|
-
/**
|
|
133
|
-
* Minimum cardinality
|
|
134
|
-
*/
|
|
64
|
+
interface ProfileConstraint {
|
|
135
65
|
min?: number;
|
|
136
|
-
/**
|
|
137
|
-
* Maximum cardinality
|
|
138
|
-
*/
|
|
139
66
|
max?: string;
|
|
140
|
-
/**
|
|
141
|
-
* Must Support flag
|
|
142
|
-
*/
|
|
143
67
|
mustSupport?: boolean;
|
|
144
|
-
/**
|
|
145
|
-
* Fixed value constraint
|
|
146
|
-
*/
|
|
147
68
|
fixedValue?: any;
|
|
148
|
-
/**
|
|
149
|
-
* Pattern value constraint
|
|
150
|
-
*/
|
|
151
69
|
patternValue?: any;
|
|
152
|
-
/**
|
|
153
|
-
* Value set binding constraint
|
|
154
|
-
*/
|
|
155
70
|
binding?: {
|
|
156
71
|
strength: "required" | "extensible" | "preferred" | "example";
|
|
157
72
|
valueSet: string;
|
|
158
73
|
};
|
|
159
|
-
/**
|
|
160
|
-
* Type constraints
|
|
161
|
-
*/
|
|
162
74
|
types?: Array<{
|
|
163
75
|
code: string;
|
|
164
76
|
profile?: string[];
|
|
165
77
|
targetProfile?: string[];
|
|
166
78
|
}>;
|
|
167
|
-
/**
|
|
168
|
-
* Slicing information
|
|
169
|
-
*/
|
|
170
79
|
slicing?: {
|
|
171
80
|
discriminator: any[];
|
|
172
81
|
rules: string;
|
|
173
82
|
ordered?: boolean;
|
|
174
83
|
};
|
|
175
84
|
}
|
|
176
|
-
|
|
177
|
-
* Profile extension information
|
|
178
|
-
*/
|
|
179
|
-
export interface ProfileExtension {
|
|
180
|
-
/**
|
|
181
|
-
* Element path where extension applies
|
|
182
|
-
*/
|
|
85
|
+
interface ProfileExtension {
|
|
183
86
|
path: string;
|
|
184
|
-
/**
|
|
185
|
-
* Extension profile URL
|
|
186
|
-
*/
|
|
187
87
|
profile: string | string[];
|
|
188
|
-
/**
|
|
189
|
-
* Minimum cardinality
|
|
190
|
-
*/
|
|
191
88
|
min?: number;
|
|
192
|
-
/**
|
|
193
|
-
* Maximum cardinality
|
|
194
|
-
*/
|
|
195
89
|
max?: string;
|
|
196
|
-
/**
|
|
197
|
-
* Must Support flag
|
|
198
|
-
*/
|
|
199
90
|
mustSupport?: boolean;
|
|
200
91
|
}
|
|
201
|
-
|
|
202
|
-
* Profile validation rule
|
|
203
|
-
*/
|
|
204
|
-
export interface ValidationRule {
|
|
205
|
-
/**
|
|
206
|
-
* Element path this rule applies to
|
|
207
|
-
*/
|
|
92
|
+
interface ValidationRule {
|
|
208
93
|
path: string;
|
|
209
|
-
/**
|
|
210
|
-
* Rule key/identifier
|
|
211
|
-
*/
|
|
212
94
|
key: string;
|
|
213
|
-
/**
|
|
214
|
-
* Severity level
|
|
215
|
-
*/
|
|
216
95
|
severity: "error" | "warning" | "information";
|
|
217
|
-
/**
|
|
218
|
-
* Human readable description
|
|
219
|
-
*/
|
|
220
96
|
human: string;
|
|
221
|
-
/**
|
|
222
|
-
* FHIRPath expression
|
|
223
|
-
*/
|
|
224
97
|
expression?: string;
|
|
225
98
|
}
|
|
226
|
-
|
|
227
|
-
* Profile metadata
|
|
228
|
-
*/
|
|
229
|
-
export interface ProfileMetadata {
|
|
230
|
-
/**
|
|
231
|
-
* Publisher information
|
|
232
|
-
*/
|
|
99
|
+
interface ProfileMetadata {
|
|
233
100
|
publisher?: string;
|
|
234
|
-
/**
|
|
235
|
-
* Contact information
|
|
236
|
-
*/
|
|
237
101
|
contact?: any[];
|
|
238
|
-
/**
|
|
239
|
-
* Copyright notice
|
|
240
|
-
*/
|
|
241
102
|
copyright?: string;
|
|
242
|
-
/**
|
|
243
|
-
* Purpose statement
|
|
244
|
-
*/
|
|
245
103
|
purpose?: string;
|
|
246
|
-
/**
|
|
247
|
-
* Experimental flag
|
|
248
|
-
*/
|
|
249
104
|
experimental?: boolean;
|
|
250
|
-
/**
|
|
251
|
-
* Publication date
|
|
252
|
-
*/
|
|
253
105
|
date?: string;
|
|
254
|
-
/**
|
|
255
|
-
* Jurisdiction
|
|
256
|
-
*/
|
|
257
106
|
jurisdiction?: any[];
|
|
258
|
-
/**
|
|
259
|
-
* Package information
|
|
260
|
-
*/
|
|
261
107
|
package?: string;
|
|
262
108
|
}
|
|
263
|
-
/**
|
|
264
|
-
* Schema for FHIR resources, complex types, and logical types
|
|
265
|
-
*/
|
|
266
109
|
export interface TypeSchemaForResourceComplexTypeLogical {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
*/
|
|
270
|
-
identifier: TypeSchemaIdentifier & (WithResourceKind | WithComplexTypeKind | WithLogicalKind);
|
|
271
|
-
/**
|
|
272
|
-
* The base type this resource or type extends
|
|
273
|
-
*/
|
|
274
|
-
base?: TypeSchemaIdentifierBase & (WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind);
|
|
275
|
-
/**
|
|
276
|
-
* Human-readable description of the resource or type
|
|
277
|
-
*/
|
|
110
|
+
identifier: ResourceIdentifier | ComplexTypeIdentifier | LogicalIdentifier;
|
|
111
|
+
base?: Identifier;
|
|
278
112
|
description?: string;
|
|
279
|
-
/**
|
|
280
|
-
* The fields contained in this resource or type
|
|
281
|
-
*/
|
|
282
113
|
fields?: {
|
|
283
114
|
[k: string]: RegularField | PolymorphicValueXFieldDeclaration | PolymorphicValueXFieldInstance;
|
|
284
115
|
};
|
|
285
|
-
/**
|
|
286
|
-
* BackboneElement types nested within this resource or type
|
|
287
|
-
*/
|
|
288
116
|
nested?: {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
*/
|
|
292
|
-
identifier: TypeSchemaIdentifier & WithNestedKind;
|
|
293
|
-
/**
|
|
294
|
-
* The base type this nested type extends (typically BackboneElement)
|
|
295
|
-
*/
|
|
296
|
-
base: WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind;
|
|
297
|
-
/**
|
|
298
|
-
* The fields contained in this nested type
|
|
299
|
-
*/
|
|
117
|
+
identifier: NestedIdentifier;
|
|
118
|
+
base: Identifier;
|
|
300
119
|
fields?: {
|
|
301
120
|
[k: string]: RegularField | PolymorphicValueXFieldDeclaration | PolymorphicValueXFieldInstance;
|
|
302
121
|
};
|
|
303
122
|
}[];
|
|
304
|
-
|
|
305
|
-
* Other types that this resource or type depends on
|
|
306
|
-
*/
|
|
307
|
-
dependencies?: TypeSchemaIdentifier[];
|
|
123
|
+
dependencies?: Identifier[];
|
|
308
124
|
}
|
|
309
|
-
/**
|
|
310
|
-
* A standard field with a single type
|
|
311
|
-
*/
|
|
312
125
|
export interface RegularField {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
*/
|
|
316
|
-
type: TypeSchemaIdentifierBase & (WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind);
|
|
317
|
-
/**
|
|
318
|
-
* Reference to other types that this field can point to
|
|
319
|
-
*/
|
|
320
|
-
reference?: TypeSchemaIdentifier[];
|
|
321
|
-
/**
|
|
322
|
-
* Whether this field must be provided in valid instances
|
|
323
|
-
*/
|
|
126
|
+
type: Identifier;
|
|
127
|
+
reference?: Identifier[];
|
|
324
128
|
required?: boolean;
|
|
325
|
-
/**
|
|
326
|
-
* Whether this field is prohibited in valid instances
|
|
327
|
-
*/
|
|
328
129
|
excluded?: boolean;
|
|
329
|
-
/**
|
|
330
|
-
* Whether this field can contain multiple values (cardinality > 1)
|
|
331
|
-
*/
|
|
332
130
|
array?: boolean;
|
|
333
|
-
binding?:
|
|
334
|
-
/**
|
|
335
|
-
* For code fields, the set of valid values when bound to a required value set
|
|
336
|
-
*/
|
|
131
|
+
binding?: BindingIdentifier;
|
|
337
132
|
enum?: string[];
|
|
338
|
-
/**
|
|
339
|
-
* Minimum limit of items for an array
|
|
340
|
-
*/
|
|
341
133
|
min?: number;
|
|
342
|
-
/**
|
|
343
|
-
* Maximum limit of items for an array
|
|
344
|
-
*/
|
|
345
134
|
max?: number;
|
|
346
135
|
}
|
|
347
|
-
/**
|
|
348
|
-
* The base declaration for a FHIR choice type (e.g., value[x])
|
|
349
|
-
*/
|
|
350
136
|
export interface PolymorphicValueXFieldDeclaration {
|
|
351
|
-
/**
|
|
352
|
-
* The names of all concrete type options for this choice field
|
|
353
|
-
*/
|
|
354
137
|
choices: string[];
|
|
355
|
-
/**
|
|
356
|
-
* Whether at least one choice must be provided
|
|
357
|
-
*/
|
|
358
138
|
required?: boolean;
|
|
359
|
-
/**
|
|
360
|
-
* Whether all choices are prohibited
|
|
361
|
-
*/
|
|
362
139
|
excluded?: boolean;
|
|
363
|
-
/**
|
|
364
|
-
* Whether the selected choice can contain multiple values
|
|
365
|
-
*/
|
|
366
140
|
array?: boolean;
|
|
367
|
-
/**
|
|
368
|
-
* Minimum limit of items for an array
|
|
369
|
-
*/
|
|
370
141
|
min?: number;
|
|
371
|
-
/**
|
|
372
|
-
* Maximum limit of items for an array
|
|
373
|
-
*/
|
|
374
142
|
max?: number;
|
|
375
143
|
}
|
|
376
|
-
/**
|
|
377
|
-
* A specific type option for a FHIR choice type (e.g., valueString, valueInteger)
|
|
378
|
-
*/
|
|
379
144
|
export interface PolymorphicValueXFieldInstance {
|
|
380
|
-
/**
|
|
381
|
-
* The name of the choice field this instance belongs to (e.g., 'value' for valueString)
|
|
382
|
-
*/
|
|
383
145
|
choiceOf: string;
|
|
384
|
-
|
|
385
|
-
* The data type of this choice option
|
|
386
|
-
*/
|
|
387
|
-
type: TypeSchemaIdentifierBase & (WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind);
|
|
388
|
-
/**
|
|
389
|
-
* Whether this specific choice must be provided
|
|
390
|
-
*/
|
|
146
|
+
type: Identifier;
|
|
391
147
|
required?: boolean;
|
|
392
|
-
/**
|
|
393
|
-
* Whether this specific choice is prohibited
|
|
394
|
-
*/
|
|
395
148
|
excluded?: boolean;
|
|
396
|
-
/**
|
|
397
|
-
* Whether this choice can contain multiple values
|
|
398
|
-
*/
|
|
399
149
|
array?: boolean;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
*/
|
|
403
|
-
reference?: TypeSchemaIdentifier[];
|
|
404
|
-
/**
|
|
405
|
-
* For coded choices, information about the value set binding
|
|
406
|
-
*/
|
|
407
|
-
binding?: TypeSchemaIdentifier & WithBindingKind;
|
|
408
|
-
/**
|
|
409
|
-
* For code fields, the set of valid values when bound to a required value set
|
|
410
|
-
*/
|
|
150
|
+
reference?: Identifier[];
|
|
151
|
+
binding?: BindingIdentifier;
|
|
411
152
|
enum?: string[];
|
|
412
|
-
/**
|
|
413
|
-
* Minimum limit of items for an array
|
|
414
|
-
*/
|
|
415
153
|
min?: number;
|
|
416
|
-
/**
|
|
417
|
-
* Maximum limit of items for an array
|
|
418
|
-
*/
|
|
419
154
|
max?: number;
|
|
420
155
|
}
|
|
421
|
-
/**
|
|
422
|
-
* Schema for FHIR value sets that define terminology bindings
|
|
423
|
-
*/
|
|
424
156
|
export interface TypeSchemaForValueSet {
|
|
425
|
-
|
|
426
|
-
* The unique identifier for this value set
|
|
427
|
-
*/
|
|
428
|
-
identifier: TypeSchemaIdentifier & WithValuesetKind;
|
|
429
|
-
/**
|
|
430
|
-
* Human-readable description of the value set
|
|
431
|
-
*/
|
|
157
|
+
identifier: ValueSetIdentifier;
|
|
432
158
|
description?: string;
|
|
433
|
-
/**
|
|
434
|
-
* The list of coded concepts contained in this value set
|
|
435
|
-
*/
|
|
436
159
|
concept?: {
|
|
437
|
-
/**
|
|
438
|
-
* The code value
|
|
439
|
-
*/
|
|
440
160
|
code: string;
|
|
441
|
-
/**
|
|
442
|
-
* The human-readable display text for this code
|
|
443
|
-
*/
|
|
444
161
|
display?: string;
|
|
445
|
-
/**
|
|
446
|
-
* The code system URL that defines this code
|
|
447
|
-
*/
|
|
448
162
|
system?: string;
|
|
449
163
|
}[];
|
|
450
|
-
/**
|
|
451
|
-
* Complex value set composition rules when the value set is defined as a composition of other value sets
|
|
452
|
-
*/
|
|
453
164
|
compose?: {
|
|
454
165
|
[k: string]: unknown;
|
|
455
166
|
};
|
|
456
167
|
}
|
|
457
168
|
export interface TypeSchemaForBinding {
|
|
458
|
-
|
|
459
|
-
* The unique identifier for this value set
|
|
460
|
-
*/
|
|
461
|
-
identifier: TypeSchemaIdentifier & WithBindingKind;
|
|
462
|
-
/**
|
|
463
|
-
* Human-readable description of the value set
|
|
464
|
-
*/
|
|
169
|
+
identifier: BindingIdentifier;
|
|
465
170
|
description?: string;
|
|
466
|
-
type?:
|
|
467
|
-
/**
|
|
468
|
-
* The strength of the binding
|
|
469
|
-
*/
|
|
171
|
+
type?: Identifier;
|
|
470
172
|
strength?: string;
|
|
471
|
-
/**
|
|
472
|
-
* The enumeration of values for the binding
|
|
473
|
-
*/
|
|
474
173
|
enum?: string[];
|
|
475
|
-
valueset?:
|
|
476
|
-
|
|
477
|
-
* Other types that this resource or type depends on
|
|
478
|
-
*/
|
|
479
|
-
dependencies?: TypeSchemaIdentifier[];
|
|
174
|
+
valueset?: ValueSetIdentifier;
|
|
175
|
+
dependencies?: Identifier[];
|
|
480
176
|
}
|
|
481
177
|
export type TypeSchemaField = RegularField | PolymorphicValueXFieldDeclaration | PolymorphicValueXFieldInstance;
|
|
482
178
|
export interface TypeschemaGeneratorOptions {
|
|
@@ -484,12 +180,5 @@ export interface TypeschemaGeneratorOptions {
|
|
|
484
180
|
logger?: import("../utils/codegen-logger").CodegenLogger;
|
|
485
181
|
treeshake?: string[];
|
|
486
182
|
}
|
|
487
|
-
export
|
|
488
|
-
|
|
489
|
-
version: string;
|
|
490
|
-
}
|
|
491
|
-
export type TypeschemaParserOptions = {
|
|
492
|
-
format?: "auto" | "ndjson" | "json";
|
|
493
|
-
validate?: boolean;
|
|
494
|
-
strict?: boolean;
|
|
495
|
-
};
|
|
183
|
+
export declare function isBindingSchema(schema: TypeSchema): schema is TypeSchemaForBinding;
|
|
184
|
+
export {};
|
package/dist/typeschema/types.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A code generation friendly representation of FHIR StructureDefinition and
|
|
2
|
+
* A code generation friendly representation of FHIR StructureDefinition and
|
|
3
|
+
* FHIR Schema designed to simplify SDK resource classes/types generation.
|
|
3
4
|
*/
|
|
4
|
-
export {
|
|
5
|
+
export const enrichFHIRSchema = (schema) => {
|
|
6
|
+
return {
|
|
7
|
+
...schema,
|
|
8
|
+
package_meta: {
|
|
9
|
+
name: schema.package_name || schema.package_meta.name || "undefined",
|
|
10
|
+
version: schema.package_version || schema.package_meta.version || "undefined",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export function isBindingSchema(schema) {
|
|
15
|
+
return schema.identifier.kind === "binding";
|
|
16
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Functions for transforming FHIR ValueSets into TypeSchema format
|
|
5
5
|
*/
|
|
6
6
|
import type { CanonicalManager } from "@atomic-ehr/fhir-canonical-manager";
|
|
7
|
-
import type { PackageInfo, TypeSchemaForValueSet } from "../types
|
|
7
|
+
import type { PackageInfo, TypeSchemaForValueSet } from "../types";
|
|
8
8
|
/**
|
|
9
9
|
* Extract all concepts from a ValueSet
|
|
10
10
|
*/
|
package/package.json
CHANGED