ezmedicationinput 0.3.0-beta.1 → 0.3.1

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 (79) hide show
  1. package/README.md +155 -10
  2. package/dist/adapters/canonical-course.d.ts +7 -4
  3. package/dist/adapters/r5-course.d.ts +11 -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 +35 -3
  10. package/dist/canonical/compile.d.ts +22 -3
  11. package/dist/canonical/course.d.ts +43 -7
  12. package/dist/canonical/dosage-agreement.d.ts +84 -0
  13. package/dist/canonical/format-course.d.ts +4 -2
  14. package/dist/clause-tail-grammar.d.ts +2 -0
  15. package/dist/combine-multilingual-dosages.d.ts +32 -0
  16. package/dist/date-interpretation.d.ts +36 -2
  17. package/dist/dosage-course.d.ts +26 -17
  18. package/dist/event-timing-expression.d.ts +26 -1
  19. package/dist/execution/engine.d.ts +2 -1
  20. package/dist/fhir-quantity-operator.d.ts +37 -1
  21. package/dist/fhir-translations.d.ts +14 -1
  22. package/dist/fhir.d.ts +25 -5
  23. package/dist/format.d.ts +23 -24
  24. package/dist/hpsg/constructions.d.ts +27 -5
  25. package/dist/hpsg/lexical-classes.d.ts +94 -33
  26. package/dist/hpsg/method-lexicon.d.ts +3 -0
  27. package/dist/hpsg/procedural-context.d.ts +51 -3
  28. package/dist/hpsg/projection.d.ts +7 -3
  29. package/dist/hpsg/quantity-lexicon.d.ts +51 -0
  30. package/dist/hpsg/rule-context.d.ts +101 -33
  31. package/dist/hpsg/rules/clinical-quantity-rules.d.ts +1 -1
  32. package/dist/hpsg/rules/condition-rules.d.ts +13 -2
  33. package/dist/hpsg/rules/core-rules.d.ts +5 -2
  34. package/dist/hpsg/rules/prn-rules.d.ts +10 -1
  35. package/dist/hpsg/rules/site-rules.d.ts +10 -1
  36. package/dist/hpsg/rules/timing-rules.d.ts +108 -24
  37. package/dist/hpsg/segmenter.d.ts +2 -2
  38. package/dist/hpsg/signature.d.ts +50 -5
  39. package/dist/hpsg/timing-lexicon.d.ts +18 -2
  40. package/dist/i18n.d.ts +8 -7
  41. package/dist/index.cjs +84275 -66589
  42. package/dist/index.d.ts +13 -3
  43. package/dist/index.js +84263 -66588
  44. package/dist/instruction-action-locale-adapter.d.ts +69 -5
  45. package/dist/instruction-action-parser.d.ts +48 -0
  46. package/dist/instruction-action-terminology.d.ts +22 -1
  47. package/dist/instruction-concept-terminology.d.ts +14 -1
  48. package/dist/instruction-graph-fhir.d.ts +4 -2
  49. package/dist/instruction-graph-ownership.d.ts +96 -0
  50. package/dist/instruction-graph.d.ts +19 -42
  51. package/dist/lexer/lex.d.ts +5 -1
  52. package/dist/lexer/locale.d.ts +14 -0
  53. package/dist/lexer/locales/en.d.ts +11 -0
  54. package/dist/lexer/surface.d.ts +3 -1
  55. package/dist/lexer/token-types.d.ts +6 -0
  56. package/dist/locale-detection.d.ts +4 -2
  57. package/dist/locales/clause/en.d.ts +14 -0
  58. package/dist/locales/course/en.d.ts +5 -0
  59. package/dist/localization.d.ts +6 -0
  60. package/dist/localized-timing.d.ts +1 -1
  61. package/dist/maps.d.ts +38 -12
  62. package/dist/medication-condition.d.ts +105 -11
  63. package/dist/parser-state.d.ts +10 -0
  64. package/dist/parser.d.ts +5 -3
  65. package/dist/prn.d.ts +15 -2
  66. package/dist/regimen/coordination-scope.d.ts +13 -1
  67. package/dist/regimen/grammar.d.ts +7 -1
  68. package/dist/regimen/parallel-course.d.ts +6 -2
  69. package/dist/regimen/planner.d.ts +2 -3
  70. package/dist/regimen/regimen.d.ts +2 -0
  71. package/dist/schedule.d.ts +5 -2
  72. package/dist/snomed.d.ts +3 -0
  73. package/dist/suggest-locale-adapter.d.ts +15 -0
  74. package/dist/symptom-terminology.d.ts +5 -1
  75. package/dist/timing-summary.d.ts +43 -10
  76. package/dist/types.d.ts +213 -16
  77. package/dist/unit-lexicon.d.ts +2 -6
  78. package/dist/utils/units.d.ts +3 -0
  79. 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;
@@ -560,6 +610,12 @@ export type MedicationCondition = {
560
610
  name: string;
561
611
  text: string;
562
612
  expected: boolean;
613
+ finding?: {
614
+ system: string;
615
+ code: string;
616
+ version?: string;
617
+ display?: string;
618
+ };
563
619
  } | {
564
620
  kind: "text";
565
621
  text: string;
@@ -643,7 +699,7 @@ interface FhirR6DosageConditionValues {
643
699
  valueParameterDefinition?: Record<string, unknown>;
644
700
  valueRelatedArtifact?: Record<string, unknown>;
645
701
  valueTriggerDefinition?: Record<string, unknown>;
646
- valueUsageContext?: Record<string, unknown>;
702
+ valueUsageContext?: object;
647
703
  valueAvailability?: Record<string, unknown>;
648
704
  valueExtendedContactDetail?: Record<string, unknown>;
649
705
  valueVirtualServiceDetail?: Record<string, unknown>;
@@ -664,12 +720,16 @@ export type FhirR6DosageCondition = FhirR6BackboneElement & {
664
720
  } & DosageConditionValue;
665
721
  /** FHIR R6 DosageSafety.doseLimit.value[x] is a required choice. */
666
722
  export type FhirR6DoseLimit = FhirR6Element & {
667
- scope: "dosage" | "period" | "administration" | "lifetime";
668
- _scope?: FhirR6PrimitiveElement;
669
723
  period?: FhirR6Quantity;
670
724
  text?: string;
671
725
  _text?: FhirR6PrimitiveElement;
672
726
  } & ({
727
+ scope: "dosage" | "period" | "administration" | "lifetime";
728
+ _scope?: FhirR6PrimitiveElement;
729
+ } | {
730
+ scope?: never;
731
+ _scope: FhirR6PrimitiveElement;
732
+ }) & ({
673
733
  valueQuantity: FhirR6Quantity;
674
734
  valueInteger?: never;
675
735
  _valueInteger?: never;
@@ -782,6 +842,7 @@ export interface FhirR6DosageStep extends FhirR6Element {
782
842
  export interface FhirR6DosageInstruction extends FhirR6BackboneElement {
783
843
  renderedInstruction?: string;
784
844
  _renderedInstruction?: FhirR6PrimitiveElement;
845
+ /** FHIR Duration: numeric values use UCUM time coding. */
785
846
  repeatCycle?: FhirR6Quantity;
786
847
  step?: FhirR6DosageStep[];
787
848
  safety?: FhirR6DosageSafety;
@@ -823,7 +884,7 @@ export interface EzDosage extends Omit<FhirDosage, "doseAndRate"> {
823
884
  /** FHIR R6 Dosage.safety, alongside the R5 maximum fields. */
824
885
  safety?: FhirR6DosageSafety;
825
886
  /** FHIR R6 Dosage.site.reference, while site remains R5 CodeableConcept. */
826
- siteReference?: FhirCodeableReference["reference"];
887
+ siteReference?: FhirR6Reference;
827
888
  /** EZMED-specific dates omitted from a repeating schedule; not an HL7 core field. */
828
889
  excludedDates?: string[];
829
890
  }
@@ -907,6 +968,8 @@ export interface FormatOptions {
907
968
  includeTimesPerDaySummary?: boolean;
908
969
  /** Thai long-text site placement. `natural` uses route-sensitive Thai word order; `trailing` preserves the legacy trailing site phrase. */
909
970
  sitePlacement?: "natural" | "trailing";
971
+ /** In normalized long text, name both paired sites while retaining the per-target dose. Defaults to `each`. */
972
+ pairedSiteWording?: "each" | "both";
910
973
  }
911
974
  export interface FormatBatchOptions extends FormatOptions {
912
975
  /**
@@ -924,11 +987,21 @@ export interface BodySiteCode {
924
987
  export interface BodySiteSpatialRelation {
925
988
  relationText: string;
926
989
  relationCoding?: FhirCoding;
990
+ /** Annotations on the supplied relation Extension, separate from its Coding. */
991
+ relationSource?: FhirR6Extension;
927
992
  targetText?: string;
928
993
  targetCoding?: BodySiteCode;
929
994
  /** Complete supplied concept when one selected Coding cannot carry all its data. */
930
995
  targetConcept?: FhirR6CodeableConcept;
996
+ /** Annotations on the supplied target Extension, separate from its concept. */
997
+ targetSource?: FhirR6Extension;
931
998
  sourceText?: string;
999
+ /** Supplied annotated string carriers, kept separate from selected display text. */
1000
+ relationTextSource?: FhirR6Extension;
1001
+ targetTextSource?: FhirR6Extension;
1002
+ sourceTextSource?: FhirR6Extension;
1003
+ /** Original wrapper annotations and unrecognized children remain opaque. */
1004
+ retainedExtension?: FhirR6Extension;
932
1005
  }
933
1006
  export type BodySiteRestrictionPredicateForm = "state" | "existential" | "raw";
934
1007
  /**
@@ -952,6 +1025,11 @@ export interface BodySiteRestriction {
952
1025
  predicate: BodySiteRestrictionPredicate;
953
1026
  }
954
1027
  export interface BodySiteDefinition {
1028
+ /** A named treatment locus may supply the omitted recipient of an immediately
1029
+ * following application after local cleansing; ordinary anatomy alone may not. */
1030
+ treatmentLocus?: true;
1031
+ /** A complete unqualified nominal refers to the administration's selected site. */
1032
+ administrationSiteReference?: true;
955
1033
  coding?: BodySiteCode;
956
1034
  text?: string;
957
1035
  spatialRelation?: BodySiteSpatialRelation;
@@ -964,6 +1042,8 @@ export interface BodySiteDefinition {
964
1042
  perTargetText?: string;
965
1043
  /** Locale-specific per-target surface, e.g. Thai `รูจมูกข้างละ`. */
966
1044
  perTargetI18n?: Record<string, string>;
1045
+ /** Localized qualifier in the explicit-pair form, e.g. `per eye` or `ทั้งสองข้าง`. */
1046
+ pairedDoseScopeI18n?: Record<string, string>;
967
1047
  /** Optional translations for different locales (e.g., { "th": "ตา" }) */
968
1048
  i18n?: Record<string, string>;
969
1049
  /**
@@ -1007,7 +1087,8 @@ export declare enum AdviceModality {
1007
1087
  Might = "might",
1008
1088
  Could = "could",
1009
1089
  Should = "should",
1010
- Must = "must"
1090
+ Must = "must",
1091
+ Need = "need"
1011
1092
  }
1012
1093
  export declare enum AdviceRelation {
1013
1094
  With = "with",
@@ -1018,12 +1099,14 @@ export declare enum AdviceRelation {
1018
1099
  Between = "between",
1019
1100
  Then = "then",
1020
1101
  Until = "until",
1102
+ Within = "within",
1021
1103
  For = "for",
1022
1104
  In = "in",
1023
1105
  Into = "into",
1024
1106
  On = "on",
1025
1107
  To = "to",
1026
1108
  If = "if",
1109
+ EvenIf = "even-if",
1027
1110
  Unless = "unless",
1028
1111
  When = "when",
1029
1112
  While = "while"
@@ -1043,6 +1126,7 @@ export declare enum AdviceArgumentRole {
1043
1126
  Amount = "amount",
1044
1127
  Duration = "duration",
1045
1128
  Time = "time",
1129
+ Condition = "condition",
1046
1130
  Free = "free"
1047
1131
  }
1048
1132
  /** A constituent of a compound meaning, not an alternative coding of that whole meaning. */
@@ -1139,6 +1223,8 @@ export interface TextRange {
1139
1223
  end: number;
1140
1224
  }
1141
1225
  export interface SiteCodeLookupRequest {
1226
+ /** Grammar-owned modifiers outside the anatomical lookup head. */
1227
+ nominalModifiers?: readonly string[];
1142
1228
  /** Original site text preserved for debugging or auditing. */
1143
1229
  originalText: string;
1144
1230
  /**
@@ -1296,6 +1382,8 @@ export interface MedicationInstructionActionLocaleRealizerConfig {
1296
1382
  routePhrases?: Record<string, string>;
1297
1383
  /** Prefix for the duration of each administration occurrence. */
1298
1384
  administrationDurationPrefix?: string;
1385
+ /** Locale wording for a selected procedural duration. */
1386
+ proceduralDurationPrefix?: string;
1299
1387
  }
1300
1388
  export interface MedicationInstructionActionRealizerConfig {
1301
1389
  /** Locale-specific realization behavior keyed by BCP-47-ish language tag. */
@@ -1312,6 +1400,10 @@ export interface MedicationInstructionActionDefinition {
1312
1400
  roundtripI18n?: Record<string, string>;
1313
1401
  /** Surface forms that should resolve to this action. */
1314
1402
  aliases?: string[];
1403
+ /** Already registered action forms licensed as a subordinate Activity after coordination. */
1404
+ activityAliases?: string[];
1405
+ /** Activity forms that also license finite directives when a local complement completes them. */
1406
+ dualUseActivityAliases?: string[];
1315
1407
  /** Ambiguous aliases licensed only at a directive boundary or after an explicit directive. */
1316
1408
  directiveOnlyAliases?: string[];
1317
1409
  /** Surface forms licensed only when immediately sequence-scoped (e.g. `then off`). */
@@ -1340,10 +1432,14 @@ export interface MedicationInstructionActionDefinition {
1340
1432
  * The selected-dose form requires an explicit medication object or a typed dose-slot target;
1341
1433
  * it never treats a bare avoidance verb, food object, or negation as withholding. */
1342
1434
  medicationConditionEffect?: "withhold" | "withhold-selected-dose";
1435
+ /** Registered lexical governors of a local procedural duration. */
1436
+ durationArgumentIntroducers?: string[];
1343
1437
  primaryConcepts?: string[];
1344
1438
  secondaryConcepts?: string[];
1345
1439
  implicitMatchedConcept?: string;
1346
1440
  implicitMatchedRole?: AdviceArgumentRole;
1441
+ /** The registered predicate already includes its own nominal complement. */
1442
+ implicitComplement?: boolean;
1347
1443
  };
1348
1444
  realizerConfig?: MedicationInstructionActionRealizerConfig;
1349
1445
  /** Typed manner concepts tied to this administration method. An edited
@@ -1358,6 +1454,8 @@ export interface MedicationInstructionActionDefinition {
1358
1454
  continuationAfterRelations?: string[];
1359
1455
  /** Surface introducers that make a parsed duration describe each administration occurrence. */
1360
1456
  administrationDurationIntroducers?: string[];
1457
+ /** Optional canonical-unit restrictions on an already licensed occurrence-duration introducer. */
1458
+ administrationDurationUnitsByIntroducer?: Record<string, FhirPeriodUnit[]>;
1361
1459
  /** Preferred relation semantic classes used to resolve lexically ambiguous relation surfaces. */
1362
1460
  preferredRelationSemanticClasses?: string[];
1363
1461
  /** Exact coding for FHIR Dosage.method when this action can head administration. */
@@ -1394,8 +1492,16 @@ export interface MedicationInstructionActionInput extends Partial<MedicationInst
1394
1492
  semanticClass?: string;
1395
1493
  }
1396
1494
  export interface MedicationInstructionConceptDefinition {
1495
+ /** An instruction-owned Object retains its own temporal complements. */
1496
+ localInstructionObject?: true;
1397
1497
  code: string;
1398
1498
  role: AdviceArgumentRole;
1499
+ /** The registered activity can itself close an instruction predicate. */
1500
+ conditionEvent?: true;
1501
+ /** An authored following duration measures this selected activity. */
1502
+ measuredActivity?: true;
1503
+ /** A complete unqualified nominal refers to the administration's selected site. */
1504
+ administrationSiteReference?: true;
1399
1505
  /** A registered compound noun may entail a second independently typed
1400
1506
  * argument, e.g. a temporal material "before first use" also supplies
1401
1507
  * its explicit first-use event. Not a free-form text rewrite. */
@@ -1407,6 +1513,8 @@ export interface MedicationInstructionConceptDefinition {
1407
1513
  display: string;
1408
1514
  i18n?: Record<string, string>;
1409
1515
  aliases?: string[];
1516
+ /** Existing activity aliases that can head an independent command after coordination. */
1517
+ verbalAliases?: string[];
1410
1518
  /** Locale-specific parser lexemes; display translations are not implicitly grammar-active. */
1411
1519
  localeAliases?: Record<string, string[]>;
1412
1520
  coding?: FhirCoding;
@@ -1642,6 +1750,8 @@ export interface CanonicalDoseRange {
1642
1750
  high?: number;
1643
1751
  }
1644
1752
  export interface CanonicalDoseExpr {
1753
+ /** Counted dose allocation, distinct from the number of anatomical targets. */
1754
+ allocation?: "total" | "per-target";
1645
1755
  /** Explicitly assumed one discrete dose from caller policy, not source
1646
1756
  * evidence. Roundtrip source wording can remain unchanged for this case. */
1647
1757
  defaulted?: boolean;
@@ -1658,7 +1768,7 @@ export interface CanonicalDoseExpr {
1658
1768
  /** Resolved Quantity unit identity for clinical scope in the compact display
1659
1769
  * view. The authored unit label and complete native quantity stay unchanged. */
1660
1770
  unitIdentity?: string;
1661
- /** Exact authored Quantity comparator; R5 uses the EMA extension, R6 native. */
1771
+ /** Exact authored comparator; scalar doseQuantity uses the EMA extension in both R5 and R6. */
1662
1772
  comparator?: FhirR6Quantity["comparator"];
1663
1773
  evidence?: CanonicalEvidence[];
1664
1774
  }
@@ -1756,6 +1866,14 @@ export interface CanonicalCalendarEventExpr {
1756
1866
  */
1757
1867
  export interface CanonicalCycleDayConstraint {
1758
1868
  days: number[];
1869
+ cycleConcept?: FhirR6Coding;
1870
+ /** An authored treatment start ordinal, distinct from a day of eligibility. */
1871
+ startDay?: number;
1872
+ /** Maximum number of treatment days in one cycle. */
1873
+ maxTreatmentDays?: number;
1874
+ /** Authored event defining day one. */
1875
+ dayOneEvent?: FhirR6Coding;
1876
+ dayOneSourceText?: string;
1759
1877
  periodDays?: number;
1760
1878
  cycles?: number;
1761
1879
  anchor?: string;
@@ -1795,12 +1913,14 @@ export interface CanonicalScheduleExpr {
1795
1913
  timingTextIsLiteral?: true;
1796
1914
  count?: number;
1797
1915
  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. */
1916
+ /** Explicit shared administration allowance; a finite total is optional.
1917
+ * Independently authored members retain their own cap policies. */
1800
1918
  sharedCount?: {
1801
1919
  groupId: string;
1802
1920
  count?: number;
1803
1921
  countMax?: number;
1922
+ /** Clock partitions of one authored administration retain its complete cap policy. */
1923
+ sameAdministration?: true;
1804
1924
  };
1805
1925
  duration?: number;
1806
1926
  durationMax?: number;
@@ -1830,6 +1950,8 @@ export interface CanonicalScheduleExpr {
1830
1950
  /** Independently authored occurrence endpoints, distinct from scalar duration. */
1831
1951
  administrationDurationRange?: import("./canonical/course").CanonicalRange;
1832
1952
  frequency?: number;
1953
+ /** All divided administrations occur on the first day of each whole civil-day interval. */
1954
+ frequencyWithinDay?: true;
1833
1955
  frequencyMax?: number;
1834
1956
  period?: number;
1835
1957
  periodMax?: number;
@@ -1853,10 +1975,12 @@ export interface CanonicalScheduleExpr {
1853
1975
  occurrenceCap?: CanonicalOccurrenceCapExpr;
1854
1976
  /** Quantity cap, distinct from occurrenceCap's maximum administration count. */
1855
1977
  maxDosePerPeriod?: CanonicalDosePeriodMaximumExpr[];
1978
+ /** Quantity ceiling for each administration, independent of a time period. */
1979
+ maxDosePerAdministration?: Pick<CanonicalDosePeriodMaximumExpr, "amount" | "unit" | "amountComparator">[];
1856
1980
  evidence?: CanonicalEvidence[];
1857
1981
  }
1858
1982
  /** Schedule fields explicitly contributed by typed grammar evidence. */
1859
- export type CanonicalScheduleSemanticField = Exclude<keyof CanonicalScheduleExpr, "evidence" | "timingTextIsLiteral">;
1983
+ export type CanonicalScheduleSemanticField = Exclude<keyof CanonicalScheduleExpr, "evidence" | "timingTextIsLiteral" | "openEndedStart">;
1860
1984
  export interface CanonicalPrnReasonExpr {
1861
1985
  text?: string;
1862
1986
  i18n?: Record<string, string>;
@@ -1872,12 +1996,28 @@ export interface CanonicalPrnExpr {
1872
1996
  evidence?: CanonicalEvidence[];
1873
1997
  }
1874
1998
  export interface CanonicalAdditionalInstructionExpr {
1999
+ /** Recognized occurrence maximum whose authored window has no numeric execution policy. */
2000
+ unresolvedMaximum?: {
2001
+ count: number;
2002
+ scope: "period" | "administration";
2003
+ };
1875
2004
  text?: string;
1876
2005
  i18n?: Record<string, string>;
1877
2006
  coding?: FhirCoding;
1878
2007
  frames?: AdviceFrame[];
1879
2008
  evidence?: CanonicalEvidence[];
1880
2009
  }
2010
+ /** A procedural condition reuses the existing coded argument at its leaves.
2011
+ * Boolean scope is distinct from medication administration eligibility. */
2012
+ export type CanonicalInstructionCondition = (AdviceArgument & {
2013
+ aspect?: "persists" | "worsens";
2014
+ }) | {
2015
+ operator: "all" | "any";
2016
+ operands: CanonicalInstructionCondition[];
2017
+ } | {
2018
+ operator: "not";
2019
+ operands: [CanonicalInstructionCondition];
2020
+ };
1881
2021
  export interface CanonicalInstructionRelation {
1882
2022
  /** Retained wire annotations are source data, never relationship semantics. */
1883
2023
  sourceId?: string;
@@ -1888,6 +2028,10 @@ export interface CanonicalInstructionRelation {
1888
2028
  fromActionIndex?: number;
1889
2029
  toActionIndex: number;
1890
2030
  text?: string;
2031
+ /** A complete registered predicate selected for this instruction scope. */
2032
+ condition?: CanonicalInstructionCondition;
2033
+ /** Temporal adjunct of the complete predicate, separate from its action. */
2034
+ conditionTiming?: AdviceArgument;
1891
2035
  span?: TextRange;
1892
2036
  }
1893
2037
  export interface CanonicalInstructionCoverage {
@@ -1919,6 +2063,9 @@ export interface CanonicalInstructionGraph {
1919
2063
  sourceId?: string;
1920
2064
  sourceExtensions?: FhirExtension[];
1921
2065
  };
2066
+ /** Structural source daughters selected by HPSG. Retained independently of
2067
+ * locale wording so fresh wire consumers do not reinterpret patient text. */
2068
+ connectorSpans?: CanonicalSourceSpan[];
1922
2069
  /** Source fragments the parser deliberately did not assign semantics to. */
1923
2070
  opaqueSpans?: CanonicalSourceSpan[];
1924
2071
  coverage?: CanonicalInstructionCoverage;
@@ -1926,6 +2073,9 @@ export interface CanonicalInstructionGraph {
1926
2073
  sourceId?: string;
1927
2074
  /** Unrecognized graph children retained at their original FHIR owner. */
1928
2075
  sourceExtensions?: FhirExtension[];
2076
+ /** Whole-source replay was rejected because this graph includes another
2077
+ * administration's source. Its actions and original text remain retained. */
2078
+ sourceProjectionVerified?: false;
1929
2079
  /** Exact original source represented by this graph. */
1930
2080
  sourceText: string;
1931
2081
  /** Source language when it can be determined without guessing. */
@@ -1945,6 +2095,9 @@ export interface CanonicalEvidence {
1945
2095
  rule: string;
1946
2096
  /** Role of the actual lexical sign, independent of the grammar-rule label. */
1947
2097
  lexicalCategory?: CanonicalLexicalCategory;
2098
+ /** Clinical role supplied by the typed sign. For conditions, the first span
2099
+ * owns the antecedent; later spans may retain ancillary no-dose branches. */
2100
+ clinicalKind?: "condition" | "calendar-exclusion" | "treatment-pause" | "unresolved";
1948
2101
  spans: CanonicalSourceSpan[];
1949
2102
  /** Exact schedule semantics owned by this evidence, independent of rule names. */
1950
2103
  scheduleFields?: CanonicalScheduleSemanticField[];
@@ -1968,6 +2121,11 @@ export interface CanonicalClinicalAdjuncts {
1968
2121
  /** Typed nominal reference of a conditional administration instruction.
1969
2122
  * Resolved across related regimen daughters before any FHIR lowering. */
1970
2123
  conditionTarget?: {
2124
+ /** A selective condition has no authored share of a common metric total. */
2125
+ allocationUnresolved?: true;
2126
+ /** A recognized guard retained on an unresolved nominal reference, never
2127
+ * executed against an unrelated administration. */
2128
+ condition?: MedicationCondition;
1971
2129
  /** Quantified prohibition binds only to the same existing administration dose. */
1972
2130
  dose?: CanonicalDoseExpr;
1973
2131
  /** A named administration site narrows this target independently of its dose. */
@@ -1976,10 +2134,10 @@ export interface CanonicalClinicalAdjuncts {
1976
2134
  /** Explicit existing clock slots selected by the nominal dose object. */
1977
2135
  timeOfDay?: string[];
1978
2136
  /** Lexical daypart membership over already stated clocks; creates no times. */
1979
- clockRange?: {
2137
+ clockRanges?: {
1980
2138
  startHour: number;
1981
2139
  endHour: number;
1982
- };
2140
+ }[];
1983
2141
  quantifier?: "all" | "both";
1984
2142
  /** Coordinated targets retain each independently qualified dose and slot. */
1985
2143
  members?: NonNullable<CanonicalClinicalAdjuncts["conditionTarget"]>[];
@@ -2029,8 +2187,12 @@ export interface CanonicalSigClause {
2029
2187
  kind: AdviceRelation;
2030
2188
  span: TextRange;
2031
2189
  target: TextRange;
2190
+ condition?: CanonicalInstructionCondition;
2191
+ conditionTiming?: AdviceArgument;
2032
2192
  }>;
2033
2193
  patientInstruction?: string;
2194
+ /** Explicit wording supplied on the FHIR patientInstruction primitive. */
2195
+ patientInstructionI18n?: Record<string, string>;
2034
2196
  instructionGraph?: CanonicalInstructionGraph;
2035
2197
  additionalInstructions?: CanonicalAdditionalInstructionExpr[];
2036
2198
  leftovers: CanonicalSourceSpan[];
@@ -2220,6 +2382,41 @@ export interface NextDueDoseOptions {
2220
2382
  frequencyDefaults?: FrequencyFallbackTimes;
2221
2383
  config?: NextDueDoseConfig;
2222
2384
  }
2385
+ /** Authored selectors that contributed to this occurrence. An anchor can
2386
+ * resolve to a specific meal when the schedule names a generic meal. */
2387
+ export type DueDoseOrigin = {
2388
+ readonly kind: "anchor";
2389
+ readonly code: string;
2390
+ readonly event?: string;
2391
+ } | {
2392
+ readonly kind: "clock" | "configured-clock";
2393
+ readonly clock: string;
2394
+ } | {
2395
+ readonly kind: "date";
2396
+ readonly value: string;
2397
+ };
2398
+ /** Zero-based positions within the normalized input course, when known.
2399
+ * Source member and authored track identities are retained independently. */
2400
+ export interface DueDoseSource {
2401
+ readonly stageIndex?: number;
2402
+ readonly administrationIndex?: number;
2403
+ readonly sourceMember?: number;
2404
+ readonly trackIndex?: number;
2405
+ }
2406
+ type ReadonlyClinicalFacts<T> = {
2407
+ readonly [Key in keyof T]: ReadonlyClinicalFacts<T[Key]>;
2408
+ };
2409
+ /** One accepted scheduled opportunity. Its authored quantities may be
2410
+ * ranged, rates, or otherwise dependent on clinical information. */
2411
+ export interface DueDose {
2412
+ readonly time: string;
2413
+ readonly administration: ReadonlyClinicalFacts<import("./canonical/course").CanonicalAdministration>;
2414
+ readonly source?: DueDoseSource;
2415
+ readonly origins?: readonly DueDoseOrigin[];
2416
+ readonly asNeeded: boolean;
2417
+ /** Whether a clinical condition was absent, assumed, or admitted by the evaluator. */
2418
+ readonly condition: "none" | "assumed" | "evaluated";
2419
+ }
2223
2420
  /** Due times calculated with each ordered medication-instruction phase respected. */
2224
2421
  export interface RegimenDueTimes {
2225
2422
  dosageIndex: number;
@@ -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.1",
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",