ezmedicationinput 0.1.62 → 0.1.64

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/types.d.ts CHANGED
@@ -313,6 +313,10 @@ export interface FhirTimingRepeat extends FhirElement {
313
313
  boundsRange?: FhirRange;
314
314
  frequency?: number;
315
315
  frequencyMax?: number;
316
+ /** Duration of each administration occurrence. */
317
+ duration?: number;
318
+ durationMax?: number;
319
+ durationUnit?: FhirPeriodUnit;
316
320
  period?: number;
317
321
  periodMax?: number;
318
322
  periodUnit?: FhirPeriodUnit;
@@ -322,8 +326,10 @@ export interface FhirTimingRepeat extends FhirElement {
322
326
  /** Exact event offset in minutes. */
323
327
  offset?: number;
324
328
  }
325
- export interface FhirTiming {
329
+ export interface FhirTiming extends FhirElement {
326
330
  event?: string[];
331
+ /** Primitive metadata corresponding positionally to event. */
332
+ _event?: FhirPrimitiveElement[];
327
333
  repeat?: FhirTimingRepeat;
328
334
  code?: FhirCodeableConcept;
329
335
  }
@@ -706,6 +712,12 @@ export interface MedicationInstructionActionLocaleRealizerConfig {
706
712
  suppressSiteConcepts?: string[];
707
713
  implicitMedicationObject?: boolean;
708
714
  directSiteObject?: boolean;
715
+ /** Realize the dose as a direct amount instead of adding a locale-default per-dose prefix. */
716
+ directDose?: boolean;
717
+ /** Route-specific phrase overrides keyed by canonical RouteCode value. */
718
+ routePhrases?: Record<string, string>;
719
+ /** Prefix for the duration of each administration occurrence. */
720
+ administrationDurationPrefix?: string;
709
721
  }
710
722
  export interface MedicationInstructionActionRealizerConfig {
711
723
  /** Locale-specific realization behavior keyed by BCP-47-ish language tag. */
@@ -751,6 +763,8 @@ export interface MedicationInstructionActionDefinition {
751
763
  nextConcepts?: string[];
752
764
  }>;
753
765
  continuationAfterRelations?: string[];
766
+ /** Surface introducers that make a parsed duration describe each administration occurrence. */
767
+ administrationDurationIntroducers?: string[];
754
768
  /** Preferred relation semantic classes used to resolve lexically ambiguous relation surfaces. */
755
769
  preferredRelationSemanticClasses?: string[];
756
770
  /** Exact coding for FHIR Dosage.method when this action can head administration. */
@@ -835,12 +849,58 @@ export interface InstructionSemanticResolverRequest {
835
849
  existingGraph: CanonicalInstructionGraph;
836
850
  }
837
851
  export type InstructionSemanticResolver = (request: InstructionSemanticResolverRequest) => InstructionSemanticResolution | null | undefined | Promise<InstructionSemanticResolution | null | undefined>;
852
+ export type MedicationDateOrder = "DMY" | "MDY";
853
+ export interface MedicationDatePlausibleWindow {
854
+ /** Maximum inferred-year distance into the past. Defaults to 5 years. */
855
+ pastYears?: number;
856
+ /** Maximum inferred-year distance into the future. Defaults to 10 years. */
857
+ futureYears?: number;
858
+ }
859
+ export interface MedicationDatePolicy {
860
+ /** Enabled calendar resolver ids, in preference order. Defaults by detected locale. */
861
+ calendars?: string[];
862
+ /** Numeric date field order. Defaults to DMY for Thai and MDY for en-US. */
863
+ dateOrder?: MedicationDateOrder;
864
+ /** ISO date used to resolve two-digit years. Defaults to the current date. */
865
+ referenceDate?: string;
866
+ /** Plausibility window applied only to inferred two-digit years. */
867
+ plausibleWindow?: MedicationDatePlausibleWindow;
868
+ /** How to handle multiple valid calendar interpretations. Defaults to prefer-first. */
869
+ ambiguity?: "prefer-first" | "reject";
870
+ }
871
+ export interface MedicationDateResolverContext {
872
+ locale: string;
873
+ referenceDate: string;
874
+ }
875
+ export interface MedicationDateResolverResult {
876
+ /** Gregorian year used in the normalized ISO date. */
877
+ isoYear: number;
878
+ /** Full year in the resolver's source calendar. */
879
+ calendarYear: number;
880
+ /** Whether a two-digit source year was expanded. */
881
+ inferredYear: boolean;
882
+ }
883
+ export interface MedicationDateResolver {
884
+ /** Stable resolver/calendar id, e.g. gregory or buddhist. */
885
+ id: string;
886
+ resolveYear(sourceYear: number, sourceYearDigits: number, context: MedicationDateResolverContext): MedicationDateResolverResult | undefined;
887
+ /**
888
+ * Optional reverse mapping used when the source omitted a year and the
889
+ * parser inferred an ISO year from the reference date.
890
+ */
891
+ calendarYearFromIsoYear?(isoYear: number): number | undefined;
892
+ }
838
893
  export interface ParseOptions extends FormatOptions {
839
894
  /**
840
895
  * Optional medication context that assists with default unit inference.
841
896
  * May be omitted or explicitly set to null when no contextual clues exist.
842
897
  */
843
898
  context?: MedicationContext | null;
899
+ /**
900
+ * Advanced date interpretation overrides. Ordinary callers can omit this:
901
+ * locale-relevant calendar resolvers are enabled automatically.
902
+ */
903
+ datePolicy?: MedicationDatePolicy;
844
904
  routeMap?: Record<string, RouteCode>;
845
905
  unitMap?: Record<string, string>;
846
906
  /**
@@ -1017,6 +1077,22 @@ export interface CanonicalActivityTimingExpr {
1017
1077
  /** Maximum offset from the activity in minutes. */
1018
1078
  offsetMax?: number;
1019
1079
  }
1080
+ export interface CanonicalCalendarEventExpr {
1081
+ /** Gregorian ISO calendar date used for date-only FHIR Timing.event values and display. */
1082
+ isoDate: string;
1083
+ /** Original timestamp-valued FHIR Timing.event value, retained losslessly when present. */
1084
+ fhirDateTime?: string;
1085
+ /** Resolver/calendar that interpreted the source year. */
1086
+ calendar: string;
1087
+ /** Full source-calendar year after any two-digit expansion. */
1088
+ calendarYear: number;
1089
+ month: number;
1090
+ day: number;
1091
+ /** Exact source fragment representing this event or inherited day. */
1092
+ sourceText: string;
1093
+ /** True when a two-digit source year was expanded using the reference date. */
1094
+ inferredYear?: boolean;
1095
+ }
1020
1096
  export interface CanonicalScheduleExpr {
1021
1097
  timingCode?: string;
1022
1098
  count?: number;
@@ -1024,6 +1100,14 @@ export interface CanonicalScheduleExpr {
1024
1100
  duration?: number;
1025
1101
  durationMax?: number;
1026
1102
  durationUnit?: FhirPeriodUnit;
1103
+ /** Earliest calendar date/time on which this schedule becomes active. */
1104
+ boundsStart?: string;
1105
+ /** Latest inclusive calendar date/time on which this schedule remains active. */
1106
+ boundsEnd?: string;
1107
+ /** Duration of each administration occurrence, distinct from regimen bounds duration. */
1108
+ administrationDuration?: number;
1109
+ administrationDurationMax?: number;
1110
+ administrationDurationUnit?: FhirPeriodUnit;
1027
1111
  frequency?: number;
1028
1112
  frequencyMax?: number;
1029
1113
  period?: number;
@@ -1038,6 +1122,8 @@ export interface CanonicalScheduleExpr {
1038
1122
  dayOfWeek?: FhirDayOfWeek[];
1039
1123
  when?: EventTiming[];
1040
1124
  timeOfDay?: string[];
1125
+ /** Explicit calendar occurrences, projected to FHIR Timing.event. */
1126
+ calendarEvents?: CanonicalCalendarEventExpr[];
1041
1127
  activityTiming?: CanonicalActivityTimingExpr[];
1042
1128
  occurrenceCap?: CanonicalOccurrenceCapExpr;
1043
1129
  evidence?: CanonicalEvidence[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezmedicationinput",
3
- "version": "0.1.62",
3
+ "version": "0.1.64",
4
4
  "description": "Parse concise medication sigs into FHIR R5 Dosage JSON",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -14,6 +14,15 @@
14
14
  "default": "./dist/index.js"
15
15
  }
16
16
  },
17
+ "scripts": {
18
+ "test:dist": "npm run build && vitest run test-dist",
19
+ "build": "tsup && tsc -p tsconfig.types.json",
20
+ "test": "vitest run --dir test",
21
+ "bench:torture": "npm run build && node bench/real-world-torture.mjs",
22
+ "bench:adversarial": "npm run build && node bench/adversarial.mjs",
23
+ "bench:roundtrip": "npm run build && node bench/roundtrip.mjs",
24
+ "bench:suggest": "npm run build && node --expose-gc bench/suggest.mjs"
25
+ },
17
26
  "files": [
18
27
  "dist"
19
28
  ],
@@ -34,14 +43,5 @@
34
43
  "tsup": "^8.5.1",
35
44
  "typescript": "^5.4.0",
36
45
  "vitest": "^1.5.0"
37
- },
38
- "scripts": {
39
- "test:dist": "npm run build && vitest run test-dist",
40
- "build": "tsup && tsc -p tsconfig.types.json",
41
- "test": "vitest run --dir test",
42
- "bench:torture": "npm run build && node bench/real-world-torture.mjs",
43
- "bench:adversarial": "npm run build && node bench/adversarial.mjs",
44
- "bench:roundtrip": "npm run build && node bench/roundtrip.mjs",
45
- "bench:suggest": "npm run build && node --expose-gc bench/suggest.mjs"
46
46
  }
47
- }
47
+ }