ezmedicationinput 0.3.0-beta.1 → 0.3.0

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 (75) hide show
  1. package/README.md +17 -10
  2. package/dist/adapters/canonical-course.d.ts +7 -4
  3. package/dist/adapters/r5-course.d.ts +5 -2
  4. package/dist/advice-locale-adapter.d.ts +24 -0
  5. package/dist/advice.d.ts +39 -3
  6. package/dist/body-site-grammar.d.ts +21 -2
  7. package/dist/body-site-lookup.d.ts +6 -1
  8. package/dist/body-site-spatial.d.ts +7 -1
  9. package/dist/body-site-target.d.ts +32 -3
  10. package/dist/canonical/compile.d.ts +22 -3
  11. package/dist/canonical/course.d.ts +43 -7
  12. package/dist/canonical/format-course.d.ts +4 -2
  13. package/dist/clause-tail-grammar.d.ts +2 -0
  14. package/dist/date-interpretation.d.ts +36 -2
  15. package/dist/dosage-course.d.ts +26 -17
  16. package/dist/event-timing-expression.d.ts +26 -1
  17. package/dist/fhir-quantity-operator.d.ts +37 -1
  18. package/dist/fhir-translations.d.ts +1 -1
  19. package/dist/fhir.d.ts +24 -4
  20. package/dist/format.d.ts +23 -24
  21. package/dist/hpsg/constructions.d.ts +24 -5
  22. package/dist/hpsg/lexical-classes.d.ts +94 -33
  23. package/dist/hpsg/method-lexicon.d.ts +3 -0
  24. package/dist/hpsg/procedural-context.d.ts +46 -3
  25. package/dist/hpsg/projection.d.ts +7 -3
  26. package/dist/hpsg/quantity-lexicon.d.ts +51 -0
  27. package/dist/hpsg/rule-context.d.ts +101 -33
  28. package/dist/hpsg/rules/clinical-quantity-rules.d.ts +1 -1
  29. package/dist/hpsg/rules/condition-rules.d.ts +13 -2
  30. package/dist/hpsg/rules/core-rules.d.ts +5 -2
  31. package/dist/hpsg/rules/prn-rules.d.ts +10 -1
  32. package/dist/hpsg/rules/site-rules.d.ts +10 -1
  33. package/dist/hpsg/rules/timing-rules.d.ts +102 -24
  34. package/dist/hpsg/segmenter.d.ts +2 -2
  35. package/dist/hpsg/signature.d.ts +41 -4
  36. package/dist/hpsg/timing-lexicon.d.ts +18 -2
  37. package/dist/i18n.d.ts +7 -7
  38. package/dist/index.cjs +75606 -61766
  39. package/dist/index.d.ts +7 -2
  40. package/dist/index.js +75606 -61766
  41. package/dist/instruction-action-locale-adapter.d.ts +63 -4
  42. package/dist/instruction-action-parser.d.ts +43 -0
  43. package/dist/instruction-action-terminology.d.ts +22 -1
  44. package/dist/instruction-concept-terminology.d.ts +13 -1
  45. package/dist/instruction-graph-fhir.d.ts +4 -2
  46. package/dist/instruction-graph-ownership.d.ts +96 -0
  47. package/dist/instruction-graph.d.ts +19 -42
  48. package/dist/lexer/lex.d.ts +5 -1
  49. package/dist/lexer/locale.d.ts +14 -0
  50. package/dist/lexer/locales/en.d.ts +11 -0
  51. package/dist/lexer/surface.d.ts +3 -1
  52. package/dist/lexer/token-types.d.ts +6 -0
  53. package/dist/locale-detection.d.ts +4 -2
  54. package/dist/locales/clause/en.d.ts +14 -0
  55. package/dist/locales/course/en.d.ts +5 -0
  56. package/dist/localization.d.ts +3 -0
  57. package/dist/localized-timing.d.ts +1 -1
  58. package/dist/maps.d.ts +38 -12
  59. package/dist/medication-condition.d.ts +72 -11
  60. package/dist/parser-state.d.ts +10 -0
  61. package/dist/parser.d.ts +5 -3
  62. package/dist/prn.d.ts +13 -2
  63. package/dist/regimen/coordination-scope.d.ts +13 -1
  64. package/dist/regimen/grammar.d.ts +7 -1
  65. package/dist/regimen/parallel-course.d.ts +6 -2
  66. package/dist/regimen/planner.d.ts +2 -3
  67. package/dist/regimen/regimen.d.ts +2 -0
  68. package/dist/snomed.d.ts +3 -0
  69. package/dist/suggest-locale-adapter.d.ts +15 -0
  70. package/dist/symptom-terminology.d.ts +5 -1
  71. package/dist/timing-summary.d.ts +41 -9
  72. package/dist/types.d.ts +127 -15
  73. package/dist/unit-lexicon.d.ts +2 -6
  74. package/dist/utils/units.d.ts +3 -0
  75. package/package.json +1 -1
package/dist/types.d.ts CHANGED
@@ -33,7 +33,10 @@ export interface FhirR6CodeableConcept extends Omit<FhirCodeableConcept, "extens
33
33
  coding?: FhirR6Coding[];
34
34
  _text?: FhirR6PrimitiveElement;
35
35
  }
36
- export interface FhirExtension {
36
+ /** Valid wire choices outside medication semantics are retained as opaque data.
37
+ * Declared interpreted choices below keep their destination-specific types. */
38
+ type FhirOpaqueExtensionValues = Partial<Record<"valueBase64Binary" | "valueId" | "valueInteger64" | "valueOid" | "valueUuid" | "valueAddress" | "valueAnnotation" | "valueAttachment" | "valueHumanName" | "valueMoney" | "valueRatioRange" | "valueSampledData" | "valueSignature" | "valueContactDetail" | "valueDataRequirement" | "valueParameterDefinition" | "valueRelatedArtifact" | "valueTriggerDefinition" | "valueUsageContext" | "valueAvailability" | "valueExtendedContactDetail" | "valueDosage" | "valueMeta", unknown>>;
39
+ export interface FhirExtension extends FhirOpaqueExtensionValues {
37
40
  id?: string;
38
41
  url: string;
39
42
  extension?: FhirExtension[];
@@ -44,6 +47,7 @@ export interface FhirExtension {
44
47
  valueMarkdown?: string;
45
48
  _valueMarkdown?: FhirPrimitiveElement;
46
49
  valueDate?: string;
50
+ _valueDate?: FhirPrimitiveElement;
47
51
  valueBoolean?: boolean;
48
52
  _valueBoolean?: FhirPrimitiveElement;
49
53
  valueInteger?: number;
@@ -51,15 +55,33 @@ export interface FhirExtension {
51
55
  valueDecimal?: number;
52
56
  _valueDecimal?: FhirPrimitiveElement;
53
57
  valueQuantity?: FhirQuantity;
58
+ valueAge?: FhirQuantity;
59
+ valueCount?: FhirQuantity;
60
+ valueDistance?: FhirQuantity;
61
+ valueDuration?: FhirQuantity;
54
62
  valueCoding?: FhirCoding;
55
63
  valueCodeableConcept?: FhirCodeableConcept;
56
64
  valueUri?: string;
65
+ _valueUri?: FhirPrimitiveElement;
66
+ valueUrl?: string;
67
+ _valueUrl?: FhirPrimitiveElement;
57
68
  valueCanonical?: string;
69
+ _valueCanonical?: FhirPrimitiveElement;
58
70
  valueDateTime?: string;
71
+ _valueDateTime?: FhirPrimitiveElement;
72
+ valueInstant?: string;
73
+ _valueInstant?: FhirPrimitiveElement;
59
74
  valueTime?: string;
60
75
  _valueTime?: FhirPrimitiveElement;
61
76
  valuePositiveInt?: number;
77
+ _valuePositiveInt?: FhirPrimitiveElement;
62
78
  valueUnsignedInt?: number;
79
+ _valueUnsignedInt?: FhirPrimitiveElement;
80
+ _valueBase64Binary?: FhirPrimitiveElement;
81
+ _valueId?: FhirPrimitiveElement;
82
+ _valueInteger64?: FhirPrimitiveElement;
83
+ _valueOid?: FhirPrimitiveElement;
84
+ _valueUuid?: FhirPrimitiveElement;
63
85
  valueRange?: FhirRange;
64
86
  valueRatio?: FhirRatio;
65
87
  valuePeriod?: FhirPeriod;
@@ -67,18 +89,38 @@ export interface FhirExtension {
67
89
  valueReference?: NonNullable<FhirCodeableReference["reference"]>;
68
90
  valueCodeableReference?: FhirCodeableReference;
69
91
  valueTiming?: FhirTiming;
92
+ valueIdentifier?: FhirReference["identifier"];
93
+ /** Retained ContactPoint content is opaque to medication semantics. */
94
+ valueContactPoint?: Record<string, unknown>;
70
95
  }
71
96
  /** R6 Extension values retain their native datatype contracts. */
72
- export interface FhirR6Extension extends Omit<FhirExtension, "extension" | "valueQuantity" | "valueRatio" | "valueTiming" | "valueReference" | "valueCodeableReference" | "valueCoding" | "valueCodeableConcept" | "valueRange" | "valueExpression" | "valuePeriod" | "_valueCode" | "_valueString" | "_valueMarkdown" | "_valueDecimal" | "_valueTime" | "_valueInteger" | "_valueBoolean"> {
97
+ export interface FhirR6Extension extends Omit<FhirExtension, "extension" | "valueQuantity" | "valueAge" | "valueCount" | "valueDistance" | "valueDuration" | "valueRatio" | "valueTiming" | "valueReference" | "valueCodeableReference" | "valueCoding" | "valueCodeableConcept" | "valueRange" | "valueExpression" | "valuePeriod" | "valueIdentifier" | "_valueCode" | "_valueString" | "_valueMarkdown" | "_valueDecimal" | "_valueDate" | "_valueTime" | "_valueInteger" | "_valueBoolean" | "_valueUri" | "_valueUrl" | "_valueCanonical" | "_valueDateTime" | "_valueInstant" | "_valuePositiveInt" | "_valueUnsignedInt" | "_valueBase64Binary" | "_valueId" | "_valueInteger64" | "_valueOid" | "_valueUuid"> {
73
98
  _valueBoolean?: FhirR6PrimitiveElement;
74
99
  _valueCode?: FhirR6PrimitiveElement;
75
100
  _valueString?: FhirR6PrimitiveElement;
76
101
  _valueMarkdown?: FhirR6PrimitiveElement;
77
102
  _valueDecimal?: FhirR6PrimitiveElement;
103
+ _valueDate?: FhirR6PrimitiveElement;
78
104
  _valueTime?: FhirR6PrimitiveElement;
79
105
  _valueInteger?: FhirR6PrimitiveElement;
106
+ _valueUri?: FhirR6PrimitiveElement;
107
+ _valueUrl?: FhirR6PrimitiveElement;
108
+ _valueCanonical?: FhirR6PrimitiveElement;
109
+ _valueDateTime?: FhirR6PrimitiveElement;
110
+ _valueInstant?: FhirR6PrimitiveElement;
111
+ _valuePositiveInt?: FhirR6PrimitiveElement;
112
+ _valueUnsignedInt?: FhirR6PrimitiveElement;
113
+ _valueBase64Binary?: FhirR6PrimitiveElement;
114
+ _valueId?: FhirR6PrimitiveElement;
115
+ _valueInteger64?: FhirR6PrimitiveElement;
116
+ _valueOid?: FhirR6PrimitiveElement;
117
+ _valueUuid?: FhirR6PrimitiveElement;
80
118
  extension?: FhirR6Extension[];
81
119
  valueQuantity?: FhirR6Quantity;
120
+ valueAge?: FhirR6Quantity;
121
+ valueCount?: FhirR6Quantity;
122
+ valueDistance?: FhirR6Quantity;
123
+ valueDuration?: FhirR6Quantity;
82
124
  valueCoding?: FhirR6Coding;
83
125
  valueCodeableConcept?: FhirR6CodeableConcept;
84
126
  valueRange?: FhirR6Range;
@@ -87,7 +129,12 @@ export interface FhirR6Extension extends Omit<FhirExtension, "extension" | "valu
87
129
  valuePeriod?: FhirR6Period;
88
130
  valueTiming?: FhirR6Timing;
89
131
  valueReference?: FhirR6Reference;
132
+ valueIdentifier?: FhirR6Reference["identifier"];
90
133
  valueCodeableReference?: FhirR6CodeableReference;
134
+ /** R6-only content retained without interpreting virtual service metadata. */
135
+ valueVirtualServiceDetail?: unknown;
136
+ /** Retained ContactPoint content is opaque to medication semantics. */
137
+ valueContactPoint?: Record<string, unknown>;
91
138
  }
92
139
  export interface FhirR6Element extends Omit<FhirElement, "extension"> {
93
140
  extension?: FhirR6Extension[];
@@ -446,13 +493,13 @@ export interface FhirTimingRepeat extends FhirElement {
446
493
  _periodMax?: FhirPrimitiveElement;
447
494
  periodUnit?: FhirPeriodUnit;
448
495
  _periodUnit?: FhirPrimitiveElement;
449
- dayOfWeek?: Array<FhirDayOfWeek | null>;
496
+ dayOfWeek?: Array<`${FhirDayOfWeek}` | null>;
450
497
  /** Primitive metadata corresponding positionally to dayOfWeek. */
451
498
  _dayOfWeek?: Array<FhirPrimitiveElement | null>;
452
499
  timeOfDay?: Array<string | null>;
453
500
  /** Primitive metadata corresponding positionally to timeOfDay. */
454
501
  _timeOfDay?: Array<FhirPrimitiveElement | null>;
455
- when?: Array<EventTiming | null>;
502
+ when?: Array<`${EventTiming}` | null>;
456
503
  /** Primitive metadata corresponding positionally to when. */
457
504
  _when?: Array<FhirPrimitiveElement | null>;
458
505
  /** Exact event offset in minutes. */
@@ -461,7 +508,10 @@ export interface FhirTimingRepeat extends FhirElement {
461
508
  }
462
509
  /** R6 Snapshot 1 adds period-local interlacing windows to Timing.repeat.
463
510
  * These are not R5 Timing fields and must remain confined to the R6 wire type. */
464
- export interface FhirR6TimingRepeat extends Omit<FhirTimingRepeat, "boundsDuration" | "boundsRange" | "boundsPeriod" | "extension" | "_count" | "_countMax" | "_frequency" | "_frequencyMax" | "_duration" | "_durationMax" | "_durationUnit" | "_period" | "_periodMax" | "_periodUnit" | "_dayOfWeek" | "_timeOfDay" | "_when" | "_offset">, FhirR6Element {
511
+ export interface FhirR6TimingRepeat extends Omit<FhirTimingRepeat, "boundsDuration" | "boundsRange" | "boundsPeriod" | "extension" | "durationUnit" | "periodUnit" | "_count" | "_countMax" | "_frequency" | "_frequencyMax" | "_duration" | "_durationMax" | "_durationUnit" | "_period" | "_periodMax" | "_periodUnit" | "_dayOfWeek" | "_timeOfDay" | "_when" | "_offset">, FhirR6Element {
512
+ /** Bounded wire codes accept JSON literals as well as the exported enum. */
513
+ durationUnit?: `${FhirPeriodUnit}`;
514
+ periodUnit?: `${FhirPeriodUnit}`;
465
515
  _count?: FhirR6PrimitiveElement;
466
516
  _countMax?: FhirR6PrimitiveElement;
467
517
  _durationMax?: FhirR6PrimitiveElement;
@@ -643,7 +693,7 @@ interface FhirR6DosageConditionValues {
643
693
  valueParameterDefinition?: Record<string, unknown>;
644
694
  valueRelatedArtifact?: Record<string, unknown>;
645
695
  valueTriggerDefinition?: Record<string, unknown>;
646
- valueUsageContext?: Record<string, unknown>;
696
+ valueUsageContext?: object;
647
697
  valueAvailability?: Record<string, unknown>;
648
698
  valueExtendedContactDetail?: Record<string, unknown>;
649
699
  valueVirtualServiceDetail?: Record<string, unknown>;
@@ -664,12 +714,16 @@ export type FhirR6DosageCondition = FhirR6BackboneElement & {
664
714
  } & DosageConditionValue;
665
715
  /** FHIR R6 DosageSafety.doseLimit.value[x] is a required choice. */
666
716
  export type FhirR6DoseLimit = FhirR6Element & {
667
- scope: "dosage" | "period" | "administration" | "lifetime";
668
- _scope?: FhirR6PrimitiveElement;
669
717
  period?: FhirR6Quantity;
670
718
  text?: string;
671
719
  _text?: FhirR6PrimitiveElement;
672
720
  } & ({
721
+ scope: "dosage" | "period" | "administration" | "lifetime";
722
+ _scope?: FhirR6PrimitiveElement;
723
+ } | {
724
+ scope?: never;
725
+ _scope: FhirR6PrimitiveElement;
726
+ }) & ({
673
727
  valueQuantity: FhirR6Quantity;
674
728
  valueInteger?: never;
675
729
  _valueInteger?: never;
@@ -782,6 +836,7 @@ export interface FhirR6DosageStep extends FhirR6Element {
782
836
  export interface FhirR6DosageInstruction extends FhirR6BackboneElement {
783
837
  renderedInstruction?: string;
784
838
  _renderedInstruction?: FhirR6PrimitiveElement;
839
+ /** FHIR Duration: numeric values use UCUM time coding. */
785
840
  repeatCycle?: FhirR6Quantity;
786
841
  step?: FhirR6DosageStep[];
787
842
  safety?: FhirR6DosageSafety;
@@ -823,7 +878,7 @@ export interface EzDosage extends Omit<FhirDosage, "doseAndRate"> {
823
878
  /** FHIR R6 Dosage.safety, alongside the R5 maximum fields. */
824
879
  safety?: FhirR6DosageSafety;
825
880
  /** FHIR R6 Dosage.site.reference, while site remains R5 CodeableConcept. */
826
- siteReference?: FhirCodeableReference["reference"];
881
+ siteReference?: FhirR6Reference;
827
882
  /** EZMED-specific dates omitted from a repeating schedule; not an HL7 core field. */
828
883
  excludedDates?: string[];
829
884
  }
@@ -924,11 +979,21 @@ export interface BodySiteCode {
924
979
  export interface BodySiteSpatialRelation {
925
980
  relationText: string;
926
981
  relationCoding?: FhirCoding;
982
+ /** Annotations on the supplied relation Extension, separate from its Coding. */
983
+ relationSource?: FhirR6Extension;
927
984
  targetText?: string;
928
985
  targetCoding?: BodySiteCode;
929
986
  /** Complete supplied concept when one selected Coding cannot carry all its data. */
930
987
  targetConcept?: FhirR6CodeableConcept;
988
+ /** Annotations on the supplied target Extension, separate from its concept. */
989
+ targetSource?: FhirR6Extension;
931
990
  sourceText?: string;
991
+ /** Supplied annotated string carriers, kept separate from selected display text. */
992
+ relationTextSource?: FhirR6Extension;
993
+ targetTextSource?: FhirR6Extension;
994
+ sourceTextSource?: FhirR6Extension;
995
+ /** Original wrapper annotations and unrecognized children remain opaque. */
996
+ retainedExtension?: FhirR6Extension;
932
997
  }
933
998
  export type BodySiteRestrictionPredicateForm = "state" | "existential" | "raw";
934
999
  /**
@@ -952,6 +1017,11 @@ export interface BodySiteRestriction {
952
1017
  predicate: BodySiteRestrictionPredicate;
953
1018
  }
954
1019
  export interface BodySiteDefinition {
1020
+ /** A named treatment locus may supply the omitted recipient of an immediately
1021
+ * following application after local cleansing; ordinary anatomy alone may not. */
1022
+ treatmentLocus?: true;
1023
+ /** A complete unqualified nominal refers to the administration's selected site. */
1024
+ administrationSiteReference?: true;
955
1025
  coding?: BodySiteCode;
956
1026
  text?: string;
957
1027
  spatialRelation?: BodySiteSpatialRelation;
@@ -1018,6 +1088,7 @@ export declare enum AdviceRelation {
1018
1088
  Between = "between",
1019
1089
  Then = "then",
1020
1090
  Until = "until",
1091
+ Within = "within",
1021
1092
  For = "for",
1022
1093
  In = "in",
1023
1094
  Into = "into",
@@ -1139,6 +1210,8 @@ export interface TextRange {
1139
1210
  end: number;
1140
1211
  }
1141
1212
  export interface SiteCodeLookupRequest {
1213
+ /** Grammar-owned modifiers outside the anatomical lookup head. */
1214
+ nominalModifiers?: readonly string[];
1142
1215
  /** Original site text preserved for debugging or auditing. */
1143
1216
  originalText: string;
1144
1217
  /**
@@ -1312,6 +1385,10 @@ export interface MedicationInstructionActionDefinition {
1312
1385
  roundtripI18n?: Record<string, string>;
1313
1386
  /** Surface forms that should resolve to this action. */
1314
1387
  aliases?: string[];
1388
+ /** Already registered action forms licensed as a subordinate Activity after coordination. */
1389
+ activityAliases?: string[];
1390
+ /** Activity forms that also license finite directives when a local complement completes them. */
1391
+ dualUseActivityAliases?: string[];
1315
1392
  /** Ambiguous aliases licensed only at a directive boundary or after an explicit directive. */
1316
1393
  directiveOnlyAliases?: string[];
1317
1394
  /** Surface forms licensed only when immediately sequence-scoped (e.g. `then off`). */
@@ -1344,6 +1421,8 @@ export interface MedicationInstructionActionDefinition {
1344
1421
  secondaryConcepts?: string[];
1345
1422
  implicitMatchedConcept?: string;
1346
1423
  implicitMatchedRole?: AdviceArgumentRole;
1424
+ /** The registered predicate already includes its own nominal complement. */
1425
+ implicitComplement?: boolean;
1347
1426
  };
1348
1427
  realizerConfig?: MedicationInstructionActionRealizerConfig;
1349
1428
  /** Typed manner concepts tied to this administration method. An edited
@@ -1358,6 +1437,8 @@ export interface MedicationInstructionActionDefinition {
1358
1437
  continuationAfterRelations?: string[];
1359
1438
  /** Surface introducers that make a parsed duration describe each administration occurrence. */
1360
1439
  administrationDurationIntroducers?: string[];
1440
+ /** Optional canonical-unit restrictions on an already licensed occurrence-duration introducer. */
1441
+ administrationDurationUnitsByIntroducer?: Record<string, FhirPeriodUnit[]>;
1361
1442
  /** Preferred relation semantic classes used to resolve lexically ambiguous relation surfaces. */
1362
1443
  preferredRelationSemanticClasses?: string[];
1363
1444
  /** Exact coding for FHIR Dosage.method when this action can head administration. */
@@ -1396,6 +1477,8 @@ export interface MedicationInstructionActionInput extends Partial<MedicationInst
1396
1477
  export interface MedicationInstructionConceptDefinition {
1397
1478
  code: string;
1398
1479
  role: AdviceArgumentRole;
1480
+ /** A complete unqualified nominal refers to the administration's selected site. */
1481
+ administrationSiteReference?: true;
1399
1482
  /** A registered compound noun may entail a second independently typed
1400
1483
  * argument, e.g. a temporal material "before first use" also supplies
1401
1484
  * its explicit first-use event. Not a free-form text rewrite. */
@@ -1407,6 +1490,8 @@ export interface MedicationInstructionConceptDefinition {
1407
1490
  display: string;
1408
1491
  i18n?: Record<string, string>;
1409
1492
  aliases?: string[];
1493
+ /** Existing activity aliases that can head an independent command after coordination. */
1494
+ verbalAliases?: string[];
1410
1495
  /** Locale-specific parser lexemes; display translations are not implicitly grammar-active. */
1411
1496
  localeAliases?: Record<string, string[]>;
1412
1497
  coding?: FhirCoding;
@@ -1642,6 +1727,8 @@ export interface CanonicalDoseRange {
1642
1727
  high?: number;
1643
1728
  }
1644
1729
  export interface CanonicalDoseExpr {
1730
+ /** Counted dose allocation, distinct from the number of anatomical targets. */
1731
+ allocation?: "total" | "per-target";
1645
1732
  /** Explicitly assumed one discrete dose from caller policy, not source
1646
1733
  * evidence. Roundtrip source wording can remain unchanged for this case. */
1647
1734
  defaulted?: boolean;
@@ -1658,7 +1745,7 @@ export interface CanonicalDoseExpr {
1658
1745
  /** Resolved Quantity unit identity for clinical scope in the compact display
1659
1746
  * view. The authored unit label and complete native quantity stay unchanged. */
1660
1747
  unitIdentity?: string;
1661
- /** Exact authored Quantity comparator; R5 uses the EMA extension, R6 native. */
1748
+ /** Exact authored comparator; scalar doseQuantity uses the EMA extension in both R5 and R6. */
1662
1749
  comparator?: FhirR6Quantity["comparator"];
1663
1750
  evidence?: CanonicalEvidence[];
1664
1751
  }
@@ -1795,12 +1882,14 @@ export interface CanonicalScheduleExpr {
1795
1882
  timingTextIsLiteral?: true;
1796
1883
  count?: number;
1797
1884
  countMax?: number;
1798
- /** Original occurrence allowance shared only by a partition's anchor daughters.
1799
- * Existing period caps retain this same owner; a finite total is optional. */
1885
+ /** Explicit shared administration allowance; a finite total is optional.
1886
+ * Independently authored members retain their own cap policies. */
1800
1887
  sharedCount?: {
1801
1888
  groupId: string;
1802
1889
  count?: number;
1803
1890
  countMax?: number;
1891
+ /** Clock partitions of one authored administration retain its complete cap policy. */
1892
+ sameAdministration?: true;
1804
1893
  };
1805
1894
  duration?: number;
1806
1895
  durationMax?: number;
@@ -1830,6 +1919,8 @@ export interface CanonicalScheduleExpr {
1830
1919
  /** Independently authored occurrence endpoints, distinct from scalar duration. */
1831
1920
  administrationDurationRange?: import("./canonical/course").CanonicalRange;
1832
1921
  frequency?: number;
1922
+ /** All divided administrations occur on the first day of each whole civil-day interval. */
1923
+ frequencyWithinDay?: true;
1833
1924
  frequencyMax?: number;
1834
1925
  period?: number;
1835
1926
  periodMax?: number;
@@ -1853,10 +1944,12 @@ export interface CanonicalScheduleExpr {
1853
1944
  occurrenceCap?: CanonicalOccurrenceCapExpr;
1854
1945
  /** Quantity cap, distinct from occurrenceCap's maximum administration count. */
1855
1946
  maxDosePerPeriod?: CanonicalDosePeriodMaximumExpr[];
1947
+ /** Quantity ceiling for each administration, independent of a time period. */
1948
+ maxDosePerAdministration?: Pick<CanonicalDosePeriodMaximumExpr, "amount" | "unit" | "amountComparator">[];
1856
1949
  evidence?: CanonicalEvidence[];
1857
1950
  }
1858
1951
  /** Schedule fields explicitly contributed by typed grammar evidence. */
1859
- export type CanonicalScheduleSemanticField = Exclude<keyof CanonicalScheduleExpr, "evidence" | "timingTextIsLiteral">;
1952
+ export type CanonicalScheduleSemanticField = Exclude<keyof CanonicalScheduleExpr, "evidence" | "timingTextIsLiteral" | "openEndedStart">;
1860
1953
  export interface CanonicalPrnReasonExpr {
1861
1954
  text?: string;
1862
1955
  i18n?: Record<string, string>;
@@ -1872,6 +1965,11 @@ export interface CanonicalPrnExpr {
1872
1965
  evidence?: CanonicalEvidence[];
1873
1966
  }
1874
1967
  export interface CanonicalAdditionalInstructionExpr {
1968
+ /** Recognized occurrence maximum whose authored window has no numeric execution policy. */
1969
+ unresolvedMaximum?: {
1970
+ count: number;
1971
+ scope: "period" | "administration";
1972
+ };
1875
1973
  text?: string;
1876
1974
  i18n?: Record<string, string>;
1877
1975
  coding?: FhirCoding;
@@ -1919,6 +2017,9 @@ export interface CanonicalInstructionGraph {
1919
2017
  sourceId?: string;
1920
2018
  sourceExtensions?: FhirExtension[];
1921
2019
  };
2020
+ /** Structural source daughters selected by HPSG. Retained independently of
2021
+ * locale wording so fresh wire consumers do not reinterpret patient text. */
2022
+ connectorSpans?: CanonicalSourceSpan[];
1922
2023
  /** Source fragments the parser deliberately did not assign semantics to. */
1923
2024
  opaqueSpans?: CanonicalSourceSpan[];
1924
2025
  coverage?: CanonicalInstructionCoverage;
@@ -1926,6 +2027,9 @@ export interface CanonicalInstructionGraph {
1926
2027
  sourceId?: string;
1927
2028
  /** Unrecognized graph children retained at their original FHIR owner. */
1928
2029
  sourceExtensions?: FhirExtension[];
2030
+ /** Whole-source replay was rejected because this graph includes another
2031
+ * administration's source. Its actions and original text remain retained. */
2032
+ sourceProjectionVerified?: false;
1929
2033
  /** Exact original source represented by this graph. */
1930
2034
  sourceText: string;
1931
2035
  /** Source language when it can be determined without guessing. */
@@ -1945,6 +2049,9 @@ export interface CanonicalEvidence {
1945
2049
  rule: string;
1946
2050
  /** Role of the actual lexical sign, independent of the grammar-rule label. */
1947
2051
  lexicalCategory?: CanonicalLexicalCategory;
2052
+ /** Clinical role supplied by the typed sign. For conditions, the first span
2053
+ * owns the antecedent; later spans may retain ancillary no-dose branches. */
2054
+ clinicalKind?: "condition" | "calendar-exclusion" | "treatment-pause" | "unresolved";
1948
2055
  spans: CanonicalSourceSpan[];
1949
2056
  /** Exact schedule semantics owned by this evidence, independent of rule names. */
1950
2057
  scheduleFields?: CanonicalScheduleSemanticField[];
@@ -1968,6 +2075,11 @@ export interface CanonicalClinicalAdjuncts {
1968
2075
  /** Typed nominal reference of a conditional administration instruction.
1969
2076
  * Resolved across related regimen daughters before any FHIR lowering. */
1970
2077
  conditionTarget?: {
2078
+ /** A selective condition has no authored share of a common metric total. */
2079
+ allocationUnresolved?: true;
2080
+ /** A recognized guard retained on an unresolved nominal reference, never
2081
+ * executed against an unrelated administration. */
2082
+ condition?: MedicationCondition;
1971
2083
  /** Quantified prohibition binds only to the same existing administration dose. */
1972
2084
  dose?: CanonicalDoseExpr;
1973
2085
  /** A named administration site narrows this target independently of its dose. */
@@ -1976,10 +2088,10 @@ export interface CanonicalClinicalAdjuncts {
1976
2088
  /** Explicit existing clock slots selected by the nominal dose object. */
1977
2089
  timeOfDay?: string[];
1978
2090
  /** Lexical daypart membership over already stated clocks; creates no times. */
1979
- clockRange?: {
2091
+ clockRanges?: {
1980
2092
  startHour: number;
1981
2093
  endHour: number;
1982
- };
2094
+ }[];
1983
2095
  quantifier?: "all" | "both";
1984
2096
  /** Coordinated targets retain each independently qualified dose and slot. */
1985
2097
  members?: NonNullable<CanonicalClinicalAdjuncts["conditionTarget"]>[];
@@ -1,5 +1,5 @@
1
1
  import { FhirPeriodUnit } from "./types";
2
- import type { DoseUnitApproximation, DoseUnitKind, DoseUnitSemantics, DoseUnitTerminologyEntry, MedicationContext, ParseOptions } from "./types";
2
+ import type { DoseUnitApproximation, DoseUnitKind, DoseUnitSemantics, DoseUnitTerminologyEntry, FhirR6Quantity, MedicationContext, ParseOptions } from "./types";
3
3
  export declare function normalizeUnit(token: string, options?: ParseOptions): string | undefined;
4
4
  export declare function getDoseUnitKind(unit: string | undefined): DoseUnitKind | undefined;
5
5
  export declare function getDoseUnitApproximation(unit: string | undefined, context?: MedicationContext | null): DoseUnitApproximation | undefined;
@@ -8,8 +8,4 @@ export declare function listDoseUnitTerminology(): DoseUnitTerminologyEntry[];
8
8
  export declare function enforceHouseholdUnitPolicy(unit: string | undefined, options?: ParseOptions): string | undefined;
9
9
  export declare function isDiscreteUnit(unit: string): boolean;
10
10
  /** Interpret a quantity's time unit without changing its authored representation. */
11
- export declare function getQuantityDurationUnit(quantity: {
12
- code?: string;
13
- unit?: string;
14
- system?: string;
15
- } | undefined): FhirPeriodUnit | undefined;
11
+ export declare function getQuantityDurationUnit(quantity: Pick<FhirR6Quantity, "code" | "unit" | "system" | "_system"> | undefined): FhirPeriodUnit | undefined;
@@ -30,4 +30,7 @@ export declare function getQuantityComparisonUnit(quantity: QuantityUnit | undef
30
30
  /** Compare quantity identities before resolving their supported dimensional or
31
31
  * plain-label units. Missing labels never make distinct coded quantities equal. */
32
32
  export declare function convertQuantityValue(value: number, from: QuantityUnit | undefined, to: QuantityUnit | undefined, strength?: Parameters<typeof convertValue>[3]): number | null;
33
+ /** Dimensional multiplication/division can perturb an equal converted value.
34
+ * Same-scale and exact coded identities retain exact numeric comparison. */
35
+ export declare function sameConvertedQuantityValue(value: number | null, expected: number, from: QuantityUnit | undefined, to: QuantityUnit | undefined, strength?: Parameters<typeof convertQuantityValue>[3]): boolean;
33
36
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezmedicationinput",
3
- "version": "0.3.0-beta.1",
3
+ "version": "0.3.0",
4
4
  "description": "Parse clinician SIGs into extended R5-style dosages with strict R5 and R6 projections",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",