@atomic-ehr/codegen 0.0.5 → 0.0.6

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/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import * as FS from '@atomic-ehr/fhirschema';
2
+ import { FHIRSchema, StructureDefinition as StructureDefinition$1, FHIRSchemaElement } from '@atomic-ehr/fhirschema';
1
3
  import { CanonicalManager } from '@atomic-ehr/fhir-canonical-manager';
2
4
 
3
5
  /**
@@ -84,11 +86,44 @@ declare class CodegenLogger {
84
86
  setLevel(level: LogLevel): void;
85
87
  }
86
88
 
89
+ interface Extension extends Element {
90
+ url: string;
91
+ valueCode?: string;
92
+ valueUri?: string;
93
+ }
94
+
87
95
  interface Element {
96
+ extension?: Extension[];
88
97
  id?: string;
89
98
  }
90
99
 
91
- interface BackboneElement extends Element {
100
+ interface Period extends Element {
101
+ end?: string;
102
+ start?: string;
103
+ }
104
+
105
+ interface Address extends Element {
106
+ city?: string;
107
+ country?: string;
108
+ district?: string;
109
+ line?: string[];
110
+ period?: Period;
111
+ postalCode?: string;
112
+ state?: string;
113
+ text?: string;
114
+ type?: ("postal" | "physical" | "both");
115
+ use?: ("home" | "work" | "temp" | "old" | "billing");
116
+ }
117
+
118
+ interface Quantity extends Element {
119
+ code?: string;
120
+ comparator?: ("<" | "<=" | ">=" | ">");
121
+ system?: string;
122
+ unit?: string;
123
+ value?: number;
124
+ }
125
+
126
+ interface Age extends Quantity {
92
127
  }
93
128
 
94
129
  interface Coding extends Element {
@@ -99,6 +134,546 @@ interface Coding extends Element {
99
134
  version?: string;
100
135
  }
101
136
 
137
+ interface CodeableConcept extends Element {
138
+ coding?: Coding[];
139
+ text?: string;
140
+ }
141
+
142
+ interface Identifier extends Element {
143
+ assigner?: Reference<"Organization">;
144
+ period?: Period;
145
+ system?: string;
146
+ type?: CodeableConcept;
147
+ use?: ("usual" | "official" | "temp" | "secondary" | "old");
148
+ value?: string;
149
+ }
150
+
151
+ interface Reference<T extends string = string> extends Element {
152
+ display?: string;
153
+ identifier?: Identifier;
154
+ reference?: `${T}/${string}`;
155
+ type?: string;
156
+ }
157
+
158
+ interface Annotation extends Element {
159
+ authorReference?: Reference<"Organization" | "Patient" | "Practitioner" | "RelatedPerson">;
160
+ authorString?: string;
161
+ text: string;
162
+ time?: string;
163
+ }
164
+
165
+ interface Attachment extends Element {
166
+ contentType?: string;
167
+ creation?: string;
168
+ data?: string;
169
+ hash?: string;
170
+ language?: string;
171
+ size?: number;
172
+ title?: string;
173
+ url?: string;
174
+ }
175
+
176
+ interface BackboneElement extends Element {
177
+ modifierExtension?: Extension[];
178
+ }
179
+
180
+ interface ContactPoint extends Element {
181
+ period?: Period;
182
+ rank?: number;
183
+ system?: ("phone" | "fax" | "email" | "pager" | "url" | "sms" | "other");
184
+ use?: ("home" | "work" | "temp" | "old" | "mobile");
185
+ value?: string;
186
+ }
187
+
188
+ interface ContactDetail extends Element {
189
+ name?: string;
190
+ telecom?: ContactPoint[];
191
+ }
192
+
193
+ interface Narrative extends Element {
194
+ div: string;
195
+ status: ("generated" | "extensions" | "additional" | "empty");
196
+ }
197
+
198
+ interface Meta extends Element {
199
+ lastUpdated?: string;
200
+ profile?: string[];
201
+ security?: Coding[];
202
+ source?: string;
203
+ tag?: Coding[];
204
+ versionId?: string;
205
+ }
206
+
207
+ interface Resource {
208
+ resourceType: "CodeSystem" | "DomainResource" | "Resource" | "StructureDefinition" | "ValueSet";
209
+ id?: string;
210
+ implicitRules?: string;
211
+ language?: string;
212
+ meta?: Meta;
213
+ }
214
+
215
+ interface DomainResource extends Resource {
216
+ resourceType: "CodeSystem" | "DomainResource" | "StructureDefinition" | "ValueSet";
217
+ contained?: Resource[];
218
+ extension?: Extension[];
219
+ modifierExtension?: Extension[];
220
+ text?: Narrative;
221
+ }
222
+
223
+ interface Range extends Element {
224
+ high?: Quantity;
225
+ low?: Quantity;
226
+ }
227
+
228
+ interface UsageContext extends Element {
229
+ code: Coding;
230
+ valueCodeableConcept?: CodeableConcept;
231
+ valueQuantity?: Quantity;
232
+ valueRange?: Range;
233
+ valueReference?: Reference<"Group" | "HealthcareService" | "InsurancePlan" | "Location" | "Organization" | "PlanDefinition" | "ResearchStudy">;
234
+ }
235
+
236
+ interface CodeSystemConcept extends BackboneElement {
237
+ code: string;
238
+ concept?: CodeSystemConcept[];
239
+ definition?: string;
240
+ designation?: CodeSystemConceptDesignation[];
241
+ display?: string;
242
+ property?: CodeSystemConceptProperty[];
243
+ }
244
+ interface CodeSystemConceptDesignation extends BackboneElement {
245
+ language?: string;
246
+ use?: Coding;
247
+ value: string;
248
+ }
249
+ interface CodeSystemConceptProperty extends BackboneElement {
250
+ code: string;
251
+ valueBoolean?: boolean;
252
+ valueCode?: string;
253
+ valueCoding?: Coding;
254
+ valueDateTime?: string;
255
+ valueDecimal?: number;
256
+ valueInteger?: number;
257
+ valueString?: string;
258
+ }
259
+ interface CodeSystemFilter extends BackboneElement {
260
+ code: string;
261
+ description?: string;
262
+ operator: ("=" | "is-a" | "descendent-of" | "is-not-a" | "regex" | "in" | "not-in" | "generalizes" | "exists")[];
263
+ value: string;
264
+ }
265
+ interface CodeSystemProperty extends BackboneElement {
266
+ code: string;
267
+ description?: string;
268
+ type: ("code" | "Coding" | "string" | "integer" | "boolean" | "dateTime" | "decimal");
269
+ uri?: string;
270
+ }
271
+ interface CodeSystem extends DomainResource {
272
+ resourceType: "CodeSystem";
273
+ caseSensitive?: boolean;
274
+ compositional?: boolean;
275
+ concept?: CodeSystemConcept[];
276
+ contact?: ContactDetail[];
277
+ content: ("not-present" | "example" | "fragment" | "complete" | "supplement");
278
+ copyright?: string;
279
+ count?: number;
280
+ date?: string;
281
+ description?: string;
282
+ experimental?: boolean;
283
+ filter?: CodeSystemFilter[];
284
+ hierarchyMeaning?: ("grouped-by" | "is-a" | "part-of" | "classified-with");
285
+ identifier?: Identifier[];
286
+ jurisdiction?: CodeableConcept[];
287
+ name?: string;
288
+ property?: CodeSystemProperty[];
289
+ publisher?: string;
290
+ purpose?: string;
291
+ status: ("draft" | "active" | "retired" | "unknown");
292
+ supplements?: string;
293
+ title?: string;
294
+ url?: string;
295
+ useContext?: UsageContext[];
296
+ valueSet?: string;
297
+ version?: string;
298
+ versionNeeded?: boolean;
299
+ }
300
+
301
+ interface Contributor extends Element {
302
+ contact?: ContactDetail[];
303
+ name: string;
304
+ type: ("author" | "editor" | "reviewer" | "endorser");
305
+ }
306
+
307
+ interface Count extends Quantity {
308
+ }
309
+
310
+ interface Duration extends Quantity {
311
+ }
312
+
313
+ interface DataRequirement extends Element {
314
+ codeFilter?: Element[];
315
+ dateFilter?: Element[];
316
+ limit?: number;
317
+ mustSupport?: string[];
318
+ profile?: string[];
319
+ sort?: Element[];
320
+ subjectCodeableConcept?: CodeableConcept;
321
+ subjectReference?: Reference<"Group">;
322
+ type: string;
323
+ }
324
+
325
+ interface Distance extends Quantity {
326
+ }
327
+
328
+ interface Ratio extends Element {
329
+ denominator?: Quantity;
330
+ numerator?: Quantity;
331
+ }
332
+
333
+ interface Timing extends BackboneElement {
334
+ code?: CodeableConcept;
335
+ event?: string[];
336
+ repeat?: Element;
337
+ }
338
+
339
+ interface Dosage extends BackboneElement {
340
+ additionalInstruction?: CodeableConcept[];
341
+ asNeededBoolean?: boolean;
342
+ asNeededCodeableConcept?: CodeableConcept;
343
+ doseAndRate?: Element[];
344
+ maxDosePerAdministration?: Quantity;
345
+ maxDosePerLifetime?: Quantity;
346
+ maxDosePerPeriod?: Ratio;
347
+ method?: CodeableConcept;
348
+ patientInstruction?: string;
349
+ route?: CodeableConcept;
350
+ sequence?: number;
351
+ site?: CodeableConcept;
352
+ text?: string;
353
+ timing?: Timing;
354
+ }
355
+
356
+ interface Expression extends Element {
357
+ description?: string;
358
+ expression?: string;
359
+ language: string;
360
+ name?: string;
361
+ reference?: string;
362
+ }
363
+
364
+ interface HumanName extends Element {
365
+ family?: string;
366
+ given?: string[];
367
+ period?: Period;
368
+ prefix?: string[];
369
+ suffix?: string[];
370
+ text?: string;
371
+ use?: ("usual" | "official" | "temp" | "nickname" | "anonymous" | "old" | "maiden");
372
+ }
373
+
374
+ interface Money extends Element {
375
+ currency?: string;
376
+ value?: number;
377
+ }
378
+
379
+ interface ParameterDefinition extends Element {
380
+ documentation?: string;
381
+ max?: string;
382
+ min?: number;
383
+ name?: string;
384
+ profile?: string;
385
+ type: string;
386
+ use: ("in" | "out");
387
+ }
388
+
389
+ interface RelatedArtifact extends Element {
390
+ citation?: string;
391
+ display?: string;
392
+ document?: Attachment;
393
+ label?: string;
394
+ resource?: string;
395
+ type: ("documentation" | "justification" | "citation" | "predecessor" | "successor" | "derived-from" | "depends-on" | "composed-of");
396
+ url?: string;
397
+ }
398
+
399
+ interface SampledData extends Element {
400
+ data?: string;
401
+ dimensions: number;
402
+ factor?: number;
403
+ lowerLimit?: number;
404
+ origin: Quantity;
405
+ period: number;
406
+ upperLimit?: number;
407
+ }
408
+
409
+ interface Signature extends Element {
410
+ data?: string;
411
+ onBehalfOf?: Reference<"Device" | "Organization" | "Patient" | "Practitioner" | "PractitionerRole" | "RelatedPerson">;
412
+ sigFormat?: string;
413
+ targetFormat?: string;
414
+ type: Coding[];
415
+ when: string;
416
+ who: Reference<"Device" | "Organization" | "Patient" | "Practitioner" | "PractitionerRole" | "RelatedPerson">;
417
+ }
418
+
419
+ interface TriggerDefinition extends Element {
420
+ condition?: Expression;
421
+ data?: DataRequirement[];
422
+ name?: string;
423
+ timingDate?: string;
424
+ timingDateTime?: string;
425
+ timingReference?: Reference<"Schedule">;
426
+ timingTiming?: Timing;
427
+ type: ("named-event" | "periodic" | "data-changed" | "data-added" | "data-modified" | "data-removed" | "data-accessed" | "data-access-ended");
428
+ }
429
+
430
+ interface ElementDefinition extends BackboneElement {
431
+ alias?: string[];
432
+ base?: Element;
433
+ binding?: Element;
434
+ code?: Coding[];
435
+ comment?: string;
436
+ condition?: string[];
437
+ constraint?: Element[];
438
+ contentReference?: string;
439
+ defaultValueAddress?: Address;
440
+ defaultValueAge?: Age;
441
+ defaultValueAnnotation?: Annotation;
442
+ defaultValueAttachment?: Attachment;
443
+ defaultValueBase64Binary?: string;
444
+ defaultValueBoolean?: boolean;
445
+ defaultValueCanonical?: string;
446
+ defaultValueCode?: string;
447
+ defaultValueCodeableConcept?: CodeableConcept;
448
+ defaultValueCoding?: Coding;
449
+ defaultValueContactDetail?: ContactDetail;
450
+ defaultValueContactPoint?: ContactPoint;
451
+ defaultValueContributor?: Contributor;
452
+ defaultValueCount?: Count;
453
+ defaultValueDataRequirement?: DataRequirement;
454
+ defaultValueDate?: string;
455
+ defaultValueDateTime?: string;
456
+ defaultValueDecimal?: number;
457
+ defaultValueDistance?: Distance;
458
+ defaultValueDosage?: Dosage;
459
+ defaultValueDuration?: Duration;
460
+ defaultValueExpression?: Expression;
461
+ defaultValueHumanName?: HumanName;
462
+ defaultValueId?: string;
463
+ defaultValueIdentifier?: Identifier;
464
+ defaultValueInstant?: string;
465
+ defaultValueInteger?: number;
466
+ defaultValueMarkdown?: string;
467
+ defaultValueMeta?: Meta;
468
+ defaultValueMoney?: Money;
469
+ defaultValueOid?: string;
470
+ defaultValueParameterDefinition?: ParameterDefinition;
471
+ defaultValuePeriod?: Period;
472
+ defaultValuePositiveInt?: number;
473
+ defaultValueQuantity?: Quantity;
474
+ defaultValueRange?: Range;
475
+ defaultValueRatio?: Ratio;
476
+ defaultValueReference?: Reference;
477
+ defaultValueRelatedArtifact?: RelatedArtifact;
478
+ defaultValueSampledData?: SampledData;
479
+ defaultValueSignature?: Signature;
480
+ defaultValueString?: string;
481
+ defaultValueTime?: string;
482
+ defaultValueTiming?: Timing;
483
+ defaultValueTriggerDefinition?: TriggerDefinition;
484
+ defaultValueUnsignedInt?: number;
485
+ defaultValueUri?: string;
486
+ defaultValueUrl?: string;
487
+ defaultValueUsageContext?: UsageContext;
488
+ defaultValueUuid?: string;
489
+ definition?: string;
490
+ example?: Element[];
491
+ fixedAddress?: Address;
492
+ fixedAge?: Age;
493
+ fixedAnnotation?: Annotation;
494
+ fixedAttachment?: Attachment;
495
+ fixedBase64Binary?: string;
496
+ fixedBoolean?: boolean;
497
+ fixedCanonical?: string;
498
+ fixedCode?: string;
499
+ fixedCodeableConcept?: CodeableConcept;
500
+ fixedCoding?: Coding;
501
+ fixedContactDetail?: ContactDetail;
502
+ fixedContactPoint?: ContactPoint;
503
+ fixedContributor?: Contributor;
504
+ fixedCount?: Count;
505
+ fixedDataRequirement?: DataRequirement;
506
+ fixedDate?: string;
507
+ fixedDateTime?: string;
508
+ fixedDecimal?: number;
509
+ fixedDistance?: Distance;
510
+ fixedDosage?: Dosage;
511
+ fixedDuration?: Duration;
512
+ fixedExpression?: Expression;
513
+ fixedHumanName?: HumanName;
514
+ fixedId?: string;
515
+ fixedIdentifier?: Identifier;
516
+ fixedInstant?: string;
517
+ fixedInteger?: number;
518
+ fixedMarkdown?: string;
519
+ fixedMeta?: Meta;
520
+ fixedMoney?: Money;
521
+ fixedOid?: string;
522
+ fixedParameterDefinition?: ParameterDefinition;
523
+ fixedPeriod?: Period;
524
+ fixedPositiveInt?: number;
525
+ fixedQuantity?: Quantity;
526
+ fixedRange?: Range;
527
+ fixedRatio?: Ratio;
528
+ fixedReference?: Reference;
529
+ fixedRelatedArtifact?: RelatedArtifact;
530
+ fixedSampledData?: SampledData;
531
+ fixedSignature?: Signature;
532
+ fixedString?: string;
533
+ fixedTime?: string;
534
+ fixedTiming?: Timing;
535
+ fixedTriggerDefinition?: TriggerDefinition;
536
+ fixedUnsignedInt?: number;
537
+ fixedUri?: string;
538
+ fixedUrl?: string;
539
+ fixedUsageContext?: UsageContext;
540
+ fixedUuid?: string;
541
+ isModifier?: boolean;
542
+ isModifierReason?: string;
543
+ isSummary?: boolean;
544
+ label?: string;
545
+ mapping?: Element[];
546
+ max?: string;
547
+ maxLength?: number;
548
+ maxValueDate?: string;
549
+ maxValueDateTime?: string;
550
+ maxValueDecimal?: number;
551
+ maxValueInstant?: string;
552
+ maxValueInteger?: number;
553
+ maxValuePositiveInt?: number;
554
+ maxValueQuantity?: Quantity;
555
+ maxValueTime?: string;
556
+ maxValueUnsignedInt?: number;
557
+ meaningWhenMissing?: string;
558
+ min?: number;
559
+ minValueDate?: string;
560
+ minValueDateTime?: string;
561
+ minValueDecimal?: number;
562
+ minValueInstant?: string;
563
+ minValueInteger?: number;
564
+ minValuePositiveInt?: number;
565
+ minValueQuantity?: Quantity;
566
+ minValueTime?: string;
567
+ minValueUnsignedInt?: number;
568
+ mustSupport?: boolean;
569
+ orderMeaning?: string;
570
+ path: string;
571
+ patternAddress?: Address;
572
+ patternAge?: Age;
573
+ patternAnnotation?: Annotation;
574
+ patternAttachment?: Attachment;
575
+ patternBase64Binary?: string;
576
+ patternBoolean?: boolean;
577
+ patternCanonical?: string;
578
+ patternCode?: string;
579
+ patternCodeableConcept?: CodeableConcept;
580
+ patternCoding?: Coding;
581
+ patternContactDetail?: ContactDetail;
582
+ patternContactPoint?: ContactPoint;
583
+ patternContributor?: Contributor;
584
+ patternCount?: Count;
585
+ patternDataRequirement?: DataRequirement;
586
+ patternDate?: string;
587
+ patternDateTime?: string;
588
+ patternDecimal?: number;
589
+ patternDistance?: Distance;
590
+ patternDosage?: Dosage;
591
+ patternDuration?: Duration;
592
+ patternExpression?: Expression;
593
+ patternHumanName?: HumanName;
594
+ patternId?: string;
595
+ patternIdentifier?: Identifier;
596
+ patternInstant?: string;
597
+ patternInteger?: number;
598
+ patternMarkdown?: string;
599
+ patternMeta?: Meta;
600
+ patternMoney?: Money;
601
+ patternOid?: string;
602
+ patternParameterDefinition?: ParameterDefinition;
603
+ patternPeriod?: Period;
604
+ patternPositiveInt?: number;
605
+ patternQuantity?: Quantity;
606
+ patternRange?: Range;
607
+ patternRatio?: Ratio;
608
+ patternReference?: Reference;
609
+ patternRelatedArtifact?: RelatedArtifact;
610
+ patternSampledData?: SampledData;
611
+ patternSignature?: Signature;
612
+ patternString?: string;
613
+ patternTime?: string;
614
+ patternTiming?: Timing;
615
+ patternTriggerDefinition?: TriggerDefinition;
616
+ patternUnsignedInt?: number;
617
+ patternUri?: string;
618
+ patternUrl?: string;
619
+ patternUsageContext?: UsageContext;
620
+ patternUuid?: string;
621
+ representation?: ("xmlAttr" | "xmlText" | "typeAttr" | "cdaText" | "xhtml")[];
622
+ requirements?: string;
623
+ short?: string;
624
+ sliceIsConstraining?: boolean;
625
+ sliceName?: string;
626
+ slicing?: Element;
627
+ type?: Element[];
628
+ }
629
+
630
+ interface StructureDefinitionContext extends BackboneElement {
631
+ expression: string;
632
+ type: ("fhirpath" | "element" | "extension");
633
+ }
634
+ interface StructureDefinitionDifferential extends BackboneElement {
635
+ element: ElementDefinition[];
636
+ }
637
+ interface StructureDefinitionMapping extends BackboneElement {
638
+ comment?: string;
639
+ identity: string;
640
+ name?: string;
641
+ uri?: string;
642
+ }
643
+ interface StructureDefinitionSnapshot extends BackboneElement {
644
+ element: ElementDefinition[];
645
+ }
646
+ interface StructureDefinition extends DomainResource {
647
+ resourceType: "StructureDefinition";
648
+ abstract: boolean;
649
+ baseDefinition?: string;
650
+ contact?: ContactDetail[];
651
+ context?: StructureDefinitionContext[];
652
+ contextInvariant?: string[];
653
+ copyright?: string;
654
+ date?: string;
655
+ derivation?: ("specialization" | "constraint");
656
+ description?: string;
657
+ differential?: StructureDefinitionDifferential;
658
+ experimental?: boolean;
659
+ fhirVersion?: ("0.01" | "0.05" | "0.06" | "0.11" | "0.0.80" | "0.0.81" | "0.0.82" | "0.4.0" | "0.5.0" | "1.0.0" | "1.0.1" | "1.0.2" | "1.1.0" | "1.4.0" | "1.6.0" | "1.8.0" | "3.0.0" | "3.0.1" | "3.3.0" | "3.5.0" | "4.0.0" | "4.0.1");
660
+ identifier?: Identifier[];
661
+ jurisdiction?: CodeableConcept[];
662
+ keyword?: Coding[];
663
+ kind: ("primitive-type" | "complex-type" | "resource" | "logical");
664
+ mapping?: StructureDefinitionMapping[];
665
+ name: string;
666
+ publisher?: string;
667
+ purpose?: string;
668
+ snapshot?: StructureDefinitionSnapshot;
669
+ status: ("draft" | "active" | "retired" | "unknown");
670
+ title?: string;
671
+ type: string;
672
+ url: string;
673
+ useContext?: UsageContext[];
674
+ version?: string;
675
+ }
676
+
102
677
  interface ValueSetCompose extends BackboneElement {
103
678
  exclude?: ValueSetComposeInclude[];
104
679
  inactive?: boolean;
@@ -127,6 +702,55 @@ interface ValueSetComposeIncludeFilter extends BackboneElement {
127
702
  property: string;
128
703
  value: string;
129
704
  }
705
+ interface ValueSetExpansion extends BackboneElement {
706
+ contains?: ValueSetExpansionContains[];
707
+ identifier?: string;
708
+ offset?: number;
709
+ parameter?: ValueSetExpansionParameter[];
710
+ timestamp: string;
711
+ total?: number;
712
+ }
713
+ interface ValueSetExpansionContains extends BackboneElement {
714
+ abstract?: boolean;
715
+ code?: string;
716
+ contains?: ValueSetExpansionContains[];
717
+ designation?: ValueSetComposeIncludeConceptDesignation[];
718
+ display?: string;
719
+ inactive?: boolean;
720
+ system?: string;
721
+ version?: string;
722
+ }
723
+ interface ValueSetExpansionParameter extends BackboneElement {
724
+ name: string;
725
+ valueBoolean?: boolean;
726
+ valueCode?: string;
727
+ valueDateTime?: string;
728
+ valueDecimal?: number;
729
+ valueInteger?: number;
730
+ valueString?: string;
731
+ valueUri?: string;
732
+ }
733
+ interface ValueSet extends DomainResource {
734
+ resourceType: "ValueSet";
735
+ compose?: ValueSetCompose;
736
+ contact?: ContactDetail[];
737
+ copyright?: string;
738
+ date?: string;
739
+ description?: string;
740
+ expansion?: ValueSetExpansion;
741
+ experimental?: boolean;
742
+ identifier?: Identifier[];
743
+ immutable?: boolean;
744
+ jurisdiction?: CodeableConcept[];
745
+ name?: string;
746
+ publisher?: string;
747
+ purpose?: string;
748
+ status: ("draft" | "active" | "retired" | "unknown");
749
+ title?: string;
750
+ url?: string;
751
+ useContext?: UsageContext[];
752
+ version?: string;
753
+ }
130
754
 
131
755
  type Name = string & {
132
756
  readonly __brand: unique symbol;
@@ -134,172 +758,78 @@ type Name = string & {
134
758
  type CanonicalUrl = string & {
135
759
  readonly __brand: unique symbol;
136
760
  };
761
+ type PkgName$1 = string;
762
+ type PkgVersion = string;
137
763
  interface PackageMeta {
138
- name: string;
139
- version: string;
764
+ name: PkgName$1;
765
+ version: PkgVersion;
140
766
  }
141
- type IdentifierBase = {
767
+ type RichStructureDefinition = Omit<StructureDefinition, "url"> & {
768
+ package_name: PkgName$1;
769
+ package_version: PkgVersion;
770
+ url: CanonicalUrl;
771
+ };
772
+ type RichFHIRSchema = Omit<FS.FHIRSchema, "package_meta" | "base" | "name" | "url"> & {
773
+ package_meta: PackageMeta;
142
774
  name: Name;
143
775
  url: CanonicalUrl;
144
- package: string;
145
- version: string;
776
+ base: CanonicalUrl;
146
777
  };
147
- type PrimitiveIdentifier = {
148
- kind: "primitive-type";
149
- } & IdentifierBase;
150
- type ComplexTypeIdentifier = {
151
- kind: "complex-type";
152
- } & IdentifierBase;
153
- type ResourceIdentifier = {
154
- kind: "resource";
155
- } & IdentifierBase;
156
- type ValueSetIdentifier = {
157
- kind: "value-set";
158
- } & IdentifierBase;
159
- type NestedIdentifier = {
160
- kind: "nested";
161
- } & IdentifierBase;
162
- type BindingIdentifier = {
163
- kind: "binding";
164
- } & IdentifierBase;
165
- type ProfileIdentifier = {
166
- kind: "profile";
167
- } & IdentifierBase;
168
- type LogicalIdentifier = {
169
- kind: "logical";
170
- } & IdentifierBase;
171
- type Identifier = PrimitiveIdentifier | ComplexTypeIdentifier | ResourceIdentifier | NestedIdentifier | BindingIdentifier | ValueSetIdentifier | ProfileIdentifier | LogicalIdentifier;
172
- type TypeSchema = RegularTypeSchema | PrimitiveTypeSchema | ValueSetTypeSchema | BindingTypeSchema | ProfileTypeSchema;
173
- interface PrimitiveTypeSchema {
174
- identifier: PrimitiveIdentifier;
175
- description?: string;
176
- base: Identifier;
177
- dependencies?: Identifier[];
178
- }
179
- interface NestedType {
180
- identifier: NestedIdentifier;
181
- base: Identifier;
182
- fields: Record<string, Field>;
183
- }
184
- interface ProfileTypeSchema {
185
- identifier: ProfileIdentifier;
186
- base: Identifier;
187
- description?: string;
188
- fields?: Record<string, Field>;
189
- constraints?: Record<string, ProfileConstraint>;
190
- extensions?: ProfileExtension[];
191
- validation?: ValidationRule[];
192
- dependencies?: Identifier[];
193
- metadata?: ProfileMetadata;
194
- nested?: NestedType[];
195
- }
196
- interface ProfileConstraint {
197
- min?: number;
198
- max?: string;
199
- mustSupport?: boolean;
200
- fixedValue?: any;
201
- patternValue?: any;
202
- binding?: {
203
- strength: "required" | "extensible" | "preferred" | "example";
204
- valueSet: string;
205
- };
206
- types?: Array<{
207
- code: string;
208
- profile?: string[];
209
- targetProfile?: string[];
210
- }>;
211
- slicing?: {
212
- discriminator: any[];
213
- rules: string;
214
- ordered?: boolean;
215
- };
216
- }
217
- interface ProfileExtension {
218
- path: string;
219
- profile: string | string[];
220
- min?: number;
221
- max?: string;
222
- mustSupport?: boolean;
223
- }
224
- interface ValidationRule {
225
- path: string;
226
- key: string;
227
- severity: "error" | "warning" | "information";
228
- human: string;
229
- expression?: string;
230
- }
231
- interface ProfileMetadata {
232
- publisher?: string;
233
- contact?: any[];
234
- copyright?: string;
235
- purpose?: string;
236
- experimental?: boolean;
237
- date?: string;
238
- jurisdiction?: any[];
239
- package?: string;
240
- }
241
- interface RegularTypeSchema {
242
- identifier: Identifier;
243
- base?: Identifier;
244
- description?: string;
245
- fields?: {
246
- [k: string]: Field;
247
- };
248
- nested?: NestedType[];
249
- dependencies?: Identifier[];
250
- }
251
- interface RegularField {
252
- type: Identifier;
253
- reference?: Identifier[];
254
- required?: boolean;
255
- excluded?: boolean;
256
- array?: boolean;
257
- binding?: BindingIdentifier;
258
- enum?: string[];
259
- min?: number;
260
- max?: number;
261
- }
262
- interface ChoiceFieldDeclaration {
263
- choices: string[];
264
- required?: boolean;
265
- excluded?: boolean;
266
- array?: boolean;
267
- min?: number;
268
- max?: number;
269
- }
270
- interface ChoiceFieldInstance {
271
- choiceOf: string;
272
- type: Identifier;
273
- required?: boolean;
274
- excluded?: boolean;
275
- array?: boolean;
276
- reference?: Identifier[];
277
- binding?: BindingIdentifier;
278
- enum?: string[];
279
- min?: number;
280
- max?: number;
281
- }
282
- type Concept = {
283
- code: string;
284
- display?: string;
285
- system?: string;
778
+ type RichValueSet = Omit<ValueSet, "name" | "url"> & {
779
+ package_meta: PackageMeta;
780
+ name: Name;
781
+ url: CanonicalUrl;
782
+ };
783
+
784
+ type IrConf = {
785
+ treeShake?: TreeShakeConf;
786
+ promoteLogical?: LogicalPromotionConf;
787
+ };
788
+ type LogicalPromotionConf = Record<PkgName$1, CanonicalUrl[]>;
789
+ type TreeShakeConf = Record<string, Record<string, TreeShakeRule>>;
790
+ type TreeShakeRule = {
791
+ ignoreFields?: string[];
792
+ selectFields?: string[];
286
793
  };
287
- interface ValueSetTypeSchema {
288
- identifier: ValueSetIdentifier;
289
- description?: string;
290
- concept?: Concept[];
291
- compose?: ValueSetCompose;
292
- }
293
- interface BindingTypeSchema {
294
- identifier: BindingIdentifier;
295
- description?: string;
296
- type?: Identifier;
297
- strength?: string;
298
- enum?: string[];
299
- valueset?: ValueSetIdentifier;
300
- dependencies?: Identifier[];
301
- }
302
- type Field = RegularField | ChoiceFieldDeclaration | ChoiceFieldInstance;
794
+
795
+ type Register = {
796
+ testAppendFs(fs: FHIRSchema): void;
797
+ ensureSpecializationCanonicalUrl(name: string | Name | CanonicalUrl): CanonicalUrl;
798
+ resolveSd(pkg: PackageMeta, canonicalUrl: CanonicalUrl): StructureDefinition$1 | undefined;
799
+ resolveFs(pkg: PackageMeta, canonicalUrl: CanonicalUrl): RichFHIRSchema | undefined;
800
+ resolveFsGenealogy(pkg: PackageMeta, canonicalUrl: CanonicalUrl): RichFHIRSchema[];
801
+ resolveFsSpecializations(pkg: PackageMeta, canonicalUrl: CanonicalUrl): RichFHIRSchema[];
802
+ allSd(): RichStructureDefinition[];
803
+ patchSd(fn: (pkg: PackageMeta, sd: StructureDefinition$1) => StructureDefinition$1): void;
804
+ allFs(): RichFHIRSchema[];
805
+ allVs(): RichValueSet[];
806
+ resolveVs(_pkg: PackageMeta, canonicalUrl: CanonicalUrl): RichValueSet | undefined;
807
+ resolveAny(canonicalUrl: CanonicalUrl): any | undefined;
808
+ resolveElementSnapshot(fhirSchema: RichFHIRSchema, path: string[]): FHIRSchemaElement;
809
+ getAllElementKeys(elems: Record<string, FHIRSchemaElement>): string[];
810
+ resolver: PackageAwareResolver;
811
+ resolutionTree: () => ResolutionTree;
812
+ };
813
+ type PkgId = string;
814
+ type PkgName = string;
815
+ type FocusedResource = StructureDefinition$1 | ValueSet | CodeSystem;
816
+ type CanonicalResolution<T> = {
817
+ deep: number;
818
+ pkg: PackageMeta;
819
+ pkgId: PkgId;
820
+ resource: T;
821
+ };
822
+ type PackageIndex = {
823
+ pkg: PackageMeta;
824
+ canonicalResolution: Record<CanonicalUrl, CanonicalResolution<FocusedResource>[]>;
825
+ fhirSchemas: Record<CanonicalUrl, RichFHIRSchema>;
826
+ valueSets: Record<CanonicalUrl, RichValueSet>;
827
+ };
828
+ type PackageAwareResolver = Record<PkgId, PackageIndex>;
829
+ type ResolutionTree = Record<PkgName, Record<CanonicalUrl, {
830
+ deep: number;
831
+ pkg: PackageMeta;
832
+ }[]>>;
303
833
 
304
834
  type FileSystemWriterOptions = {
305
835
  outputDir: string;
@@ -323,237 +853,21 @@ type CSharpGeneratorOptions = WriterOptions & {
323
853
  type StringFormatKey = "snake_case" | "PascalCase" | "camelCase";
324
854
  interface PythonGeneratorOptions extends WriterOptions {
325
855
  allowExtraFields?: boolean;
326
- staticDir?: string;
327
856
  rootPackageName: string;
328
857
  fieldFormat: StringFormatKey;
858
+ fhirpyClient?: boolean;
329
859
  }
330
860
 
331
- type TreeShake = Record<string, Record<string, TreeShakeRule>>;
332
- type TreeShakeRule = {
333
- ignoreFields?: string[];
334
- selectFields?: string[];
335
- };
336
-
337
- /**
338
- * New Config Schema for High-Level API
339
- *
340
- * Simple configuration system compatible ONLY with the new high-level APIBuilder.
341
- * All legacy config functionality has been removed.
342
- */
343
- /**
344
- * TypeScript generator configuration options
345
- */
346
- interface TypeScriptGeneratorConfig {
347
- moduleFormat?: "esm" | "cjs";
348
- generateIndex?: boolean;
349
- includeDocuments?: boolean;
350
- namingConvention?: "PascalCase" | "camelCase";
351
- strictMode?: boolean;
352
- includeProfiles?: boolean;
353
- includeExtensions?: boolean;
354
- includeCodeSystems?: boolean;
355
- includeOperations?: boolean;
356
- /** Generate individual TypeScript files for value sets (default: false) */
357
- generateValueSets?: boolean;
358
- /** Include helper validation functions in value set files (default: false) */
359
- includeValueSetHelpers?: boolean;
360
- /** Which binding strengths to generate value sets for (default: ['required']) */
361
- valueSetStrengths?: ("required" | "preferred" | "extensible" | "example")[];
362
- /** Directory name for value set files (relative to outputDir) (default: 'valuesets') */
363
- valueSetDirectory?: string;
364
- /** Value set generation mode (default: 'required-only') */
365
- valueSetMode?: "all" | "required-only" | "custom";
366
- fhirVersion?: "R4" | "R5";
367
- resourceTypes?: string[];
368
- maxDepth?: number;
369
- profileOptions?: {
370
- generateKind?: "interface" | "type" | "both";
371
- includeConstraints?: boolean;
372
- includeDocumentation?: boolean;
373
- strictMode?: boolean;
374
- subfolder?: string;
375
- };
376
- generateBuilders?: boolean;
377
- builderOptions?: {
378
- includeValidation?: boolean;
379
- includeFactoryMethods?: boolean;
380
- includeInterfaces?: boolean;
381
- generateNestedBuilders?: boolean;
382
- includeHelperMethods?: boolean;
383
- supportPartialBuild?: boolean;
384
- includeJSDoc?: boolean;
385
- generateFactories?: boolean;
386
- includeTypeGuards?: boolean;
387
- handleChoiceTypes?: boolean;
388
- generateArrayHelpers?: boolean;
389
- };
390
- validatorOptions?: {
391
- includeCardinality?: boolean;
392
- includeTypes?: boolean;
393
- includeConstraints?: boolean;
394
- includeInvariants?: boolean;
395
- validateRequired?: boolean;
396
- allowAdditional?: boolean;
397
- strictValidation?: boolean;
398
- collectMetrics?: boolean;
399
- generateAssertions?: boolean;
400
- generatePartialValidators?: boolean;
401
- optimizePerformance?: boolean;
402
- includeJSDoc?: boolean;
403
- generateCompositeValidators?: boolean;
404
- };
405
- guardOptions?: {
406
- includeRuntimeValidation?: boolean;
407
- includeErrorMessages?: boolean;
408
- treeShakeable?: boolean;
409
- targetTSVersion?: "3.8" | "4.0" | "4.5" | "5.0";
410
- strictGuards?: boolean;
411
- includeNullChecks?: boolean;
412
- verbose?: boolean;
413
- };
414
- }
415
- /**
416
- * TypeSchema Configuration
417
- * Controls TypeSchema generation and caching behavior
418
- */
419
- interface TypeSchemaConfig {
420
- /** Enable persistent caching of generated TypeSchemas */
421
- enablePersistence?: boolean;
422
- /** Directory to store cached TypeSchemas (relative to outputDir) */
423
- cacheDir?: string;
424
- /** Maximum age of cached schemas in milliseconds before regeneration */
425
- maxAge?: number;
426
- /** Whether to validate cached schemas before reuse */
427
- validateCached?: boolean;
428
- /** Force regeneration of schemas even if cached */
429
- forceRegenerate?: boolean;
430
- /** Share cache across multiple codegen runs */
431
- shareCache?: boolean;
432
- /** Cache key prefix for namespacing */
433
- cacheKeyPrefix?: string;
434
- /** Only generate TypeSchemas for specific ResourceTypes (treeshaking) */
435
- treeshake?: string[];
436
- /** Generate single TypeSchema file instead of multiple files */
437
- singleFile?: boolean;
438
- /** Profile packages configuration */
439
- profiles?: {
440
- /** Auto-detect profiles in packages */
441
- autoDetect?: boolean;
442
- };
443
- }
444
- /**
445
- * Main configuration schema for the new high-level API
446
- */
447
- interface Config {
448
- outputDir?: string;
449
- verbose?: boolean;
450
- overwrite?: boolean;
451
- validate?: boolean;
452
- cache?: boolean;
453
- cleanOutput?: boolean;
454
- typescript?: TypeScriptGeneratorConfig;
455
- typeSchema?: TypeSchemaConfig;
456
- packages?: string[];
457
- files?: string[];
458
- /** Custom FHIR package registry URL (default: https://fs.get-ig.org/pkgs/) */
459
- registry?: string;
460
- $schema?: string;
461
- }
462
- /**
463
- * Default configuration values
464
- */
465
- declare const DEFAULT_CONFIG: Required<Config>;
466
- /**
467
- * Configuration file names to search for
468
- */
469
- declare const CONFIG_FILE_NAMES: string[];
470
- /**
471
- * Validation error interface
472
- */
473
- interface ConfigValidationError {
474
- path: string;
475
- message: string;
476
- value?: unknown;
477
- }
478
- /**
479
- * Configuration validation result
480
- */
481
- interface ConfigValidationResult {
482
- valid: boolean;
483
- errors: ConfigValidationError[];
484
- warnings: string[];
485
- config?: Config;
486
- }
487
- /**
488
- * Simple configuration validator
489
- */
490
- declare class ConfigValidator {
491
- /**
492
- * Validate a configuration object
493
- */
494
- validate(config: unknown): ConfigValidationResult;
495
- private validateTypeScriptConfig;
496
- private validateValidatorOptions;
497
- private validateGuardOptions;
498
- private validateProfileOptions;
499
- private validateTypeSchemaConfig;
861
+ interface IntrospectionWriterOptions extends FileSystemWriterOptions {
862
+ typeSchemas?: string /** if .ndjson -- put in one file, else -- split into separated files*/;
863
+ typeTree?: string /** .json or .yaml file */;
864
+ fhirSchemas?: string /** if .ndjson -- put in one file, else -- split into separated files*/;
865
+ structureDefinitions?: string /** if .ndjson -- put in one file, else -- split into separated files*/;
500
866
  }
501
- /**
502
- * Configuration loader with autoloading capabilities
503
- */
504
- declare class ConfigLoader {
505
- private validator;
506
- /**
507
- * Auto-load configuration from the current working directory
508
- */
509
- autoload(workingDir?: string): Promise<Config>;
510
- /**
511
- * Load configuration from a specific file
512
- */
513
- loadFromFile(filePath: string): Promise<Config>;
514
- /**
515
- * Find configuration file in the given directory
516
- */
517
- private findConfigFile;
518
- /**
519
- * Merge user config with defaults
520
- */
521
- private mergeWithDefaults;
867
+
868
+ interface IrReportWriterWriterOptions extends FileSystemWriterOptions {
869
+ rootReadmeFileName: string;
522
870
  }
523
- /**
524
- * Global config loader instance
525
- */
526
- declare const configLoader: ConfigLoader;
527
- /**
528
- * Convenience function to auto-load configuration
529
- */
530
- declare function loadConfig(workingDir?: string): Promise<Config>;
531
- /**
532
- * Type guard to check if an object is a valid Config
533
- */
534
- declare function isConfig(obj: unknown): obj is Config;
535
- /**
536
- * Define configuration with type safety and IntelliSense support.
537
- * Similar to Vite's defineConfig function pattern.
538
- *
539
- * @example
540
- * ```typescript
541
- * import { defineConfig } from "@atomic-ehr/codegen";
542
- *
543
- * export default defineConfig({
544
- * outputDir: "./generated",
545
- * packages: [
546
- * "hl7.fhir.r4.core@4.0.1",
547
- * "hl7.fhir.us.core@6.1.0"
548
- * ],
549
- * typescript: {
550
- * generateIndex: true,
551
- * strictMode: true
552
- * }
553
- * });
554
- * ```
555
- */
556
- declare function defineConfig(config: Config): Config;
557
871
 
558
872
  type NameTransformation = {
559
873
  pattern: RegExp | string;
@@ -626,26 +940,16 @@ type TypeScriptOptions = {
626
940
  * Configuration options for the API builder
627
941
  */
628
942
  interface APIBuilderOptions {
629
- outputDir?: string;
630
- overwrite?: boolean;
631
- cache?: boolean;
632
- cleanOutput?: boolean;
633
- typeSchemaConfig?: TypeSchemaConfig;
634
- logger?: CodegenLogger;
635
- manager?: ReturnType<typeof CanonicalManager> | null;
636
- typeSchemaOutputDir?: string /** if .ndjson -- put in one file, else -- split into separated files*/;
637
- throwException?: boolean;
638
- exportTypeTree?: string;
639
- treeShake?: TreeShake;
943
+ outputDir: string;
944
+ cleanOutput: boolean;
945
+ throwException: boolean;
946
+ treeShake: TreeShakeConf | undefined;
947
+ promoteLogical: LogicalPromotionConf | undefined;
640
948
  /** Log level for the logger. Default: INFO */
641
- logLevel?: LogLevel;
949
+ logLevel: LogLevel;
642
950
  /** Custom FHIR package registry URL (default: https://fs.get-ig.org/pkgs/) */
643
- registry?: string;
951
+ registry: string | undefined;
644
952
  }
645
- /**
646
- * Progress callback for long-running operations
647
- */
648
- type ProgressCallback = (phase: string, current: number, total: number, message?: string) => void;
649
953
  type GenerationReport = {
650
954
  success: boolean;
651
955
  outputDir: string;
@@ -667,16 +971,17 @@ interface LocalStructureDefinitionConfig {
667
971
  * from FHIR packages or TypeSchema documents.
668
972
  */
669
973
  declare class APIBuilder {
670
- private schemas;
671
974
  private options;
672
- private generators;
975
+ private manager;
976
+ private prebuiltRegister;
977
+ private managerInput;
673
978
  private logger;
674
- private packages;
675
- private localStructurePackages;
676
- private localTgzArchives;
677
- progressCallback: any;
678
- private typeSchemaConfig?;
679
- constructor(options?: APIBuilderOptions);
979
+ private generators;
980
+ constructor(userOpts?: Partial<APIBuilderOptions> & {
981
+ manager?: ReturnType<typeof CanonicalManager>;
982
+ register?: Register;
983
+ logger?: CodegenLogger;
984
+ });
680
985
  fromPackage(packageName: string, version?: string): APIBuilder;
681
986
  fromPackageRef(packageRef: string): APIBuilder;
682
987
  /**
@@ -686,15 +991,11 @@ declare class APIBuilder {
686
991
  registry(url: string): APIBuilder;
687
992
  localStructureDefinitions(config: LocalStructureDefinitionConfig): APIBuilder;
688
993
  localTgzPackage(archivePath: string): APIBuilder;
689
- fromSchemas(schemas: TypeSchema[]): APIBuilder;
994
+ introspection(userOpts?: Partial<IntrospectionWriterOptions>): APIBuilder;
690
995
  typescript(userOpts: Partial<TypeScriptOptions>): this;
691
996
  python(userOptions: Partial<PythonGeneratorOptions>): APIBuilder;
692
997
  mustache(templatePath: string, userOpts: Partial<FileSystemWriterOptions & FileBasedMustacheGeneratorOptions>): this;
693
998
  csharp(userOptions: Partial<CSharpGeneratorOptions>): APIBuilder;
694
- /**
695
- * Set a progress callback for monitoring generation
696
- */
697
- onProgress(callback: ProgressCallback): APIBuilder;
698
999
  /**
699
1000
  * Set the output directory for all generators
700
1001
  */
@@ -702,18 +1003,13 @@ declare class APIBuilder {
702
1003
  setLogLevel(level: LogLevel | LogLevelString): APIBuilder;
703
1004
  throwException(enabled?: boolean): APIBuilder;
704
1005
  cleanOutput(enabled?: boolean): APIBuilder;
705
- writeTypeTree(filename: string): this;
706
- treeShake(tree: TreeShake): this;
707
- writeTypeSchemas(target: string): this;
1006
+ typeSchema(cfg: IrConf): this;
1007
+ irReport(userOpts: Partial<IrReportWriterWriterOptions>): this;
708
1008
  generate(): Promise<GenerationReport>;
709
1009
  /**
710
1010
  * Clear all configuration and start fresh
711
1011
  */
712
1012
  reset(): APIBuilder;
713
- /**
714
- * Get loaded schemas (for inspection)
715
- */
716
- getSchemas(): TypeSchema[];
717
1013
  /**
718
1014
  * Get configured generators (for inspection)
719
1015
  */
@@ -721,4 +1017,4 @@ declare class APIBuilder {
721
1017
  private executeGenerators;
722
1018
  }
723
1019
 
724
- export { APIBuilder, type APIBuilderOptions, CONFIG_FILE_NAMES, type CSharpGeneratorOptions, type Config, ConfigLoader, type ConfigValidationError, type ConfigValidationResult, ConfigValidator, DEFAULT_CONFIG, type LocalStructureDefinitionConfig, LogLevel, type TypeSchemaConfig, type TypeScriptGeneratorConfig, type TypeScriptOptions, configLoader, defineConfig, isConfig, loadConfig, prettyReport };
1020
+ export { APIBuilder, type APIBuilderOptions, type CSharpGeneratorOptions, type IrConf, type LocalStructureDefinitionConfig, LogLevel, type LogicalPromotionConf, type TreeShakeConf, type TypeScriptOptions, prettyReport };