ezmedicationinput 0.1.55 → 0.1.57

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/advice.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface AdviceParseContext {
11
11
  defaultForce?: AdviceForce;
12
12
  allowFreeTextFallback?: boolean;
13
13
  }
14
+ export declare function realizeAdviceFramesText(frames: AdviceFrame[], locale?: string): string | undefined;
14
15
  export declare function parseAdditionalInstructions(sourceText: string, span: TextRange, context?: AdviceParseContext): ParsedAdditionalInstruction[];
15
16
  export declare function findAdditionalInstructionDefinitionByCoding(system: string, code: string): AdditionalInstructionDefinition | undefined;
16
17
  export declare const __test__: {
@@ -1,6 +1,7 @@
1
1
  import { BodySiteDefinition, BodySiteSpatialRelation, FhirCoding } from "./types";
2
+ import type { BodySiteLocativeRelation } from "./relation-terminology";
2
3
  export type BodySiteGrammarKind = "nominal" | "partitive" | "locative";
3
- export type BodySiteLocativeRelation = "behind" | "around" | "under" | "above" | "below" | "beneath" | "near" | "outside" | "inside" | "between";
4
+ export type { BodySiteLocativeRelation };
4
5
  export interface BodySiteNominalFeatures {
5
6
  kind: "nominal";
6
7
  text: string;
package/dist/fhir.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  import { ParserState } from "./parser-state";
2
- import { CanonicalSigClause, FhirDosage, FhirTimingRepeat } from "./types";
2
+ import { CanonicalOccurrenceCapExpr, CanonicalSigClause, FhirDosage, FhirTimingRepeat } from "./types";
3
3
  export declare const TIMING_FREQUENCY_MIN_EXTENSION_URL = "https://solublelabs.com/fhir/StructureDefinition/medication-timing-frequency-min";
4
4
  export declare const TIMING_OFFSET_MIN_EXTENSION_URL = "https://solublelabs.com/fhir/StructureDefinition/medication-timing-offset-min";
5
5
  export declare const TIMING_OFFSET_MAX_EXTENSION_URL = "https://solublelabs.com/fhir/StructureDefinition/medication-timing-offset-max";
6
6
  export declare const TIMING_OFFSET_EXACT_EXTENSION_URL = "https://solublelabs.com/fhir/StructureDefinition/medication-timing-offset-exact";
7
+ export declare const TIMING_ACTIVITY_WINDOW_EXTENSION_URL = "https://solublelabs.com/fhir/StructureDefinition/medication-timing-activity-window";
8
+ export declare const TIMING_OCCURRENCE_CAP_EXTENSION_URL = "https://solublelabs.com/fhir/StructureDefinition/medication-timing-occurrence-cap";
9
+ export declare const PRN_TRIGGER_PHASE_EXTENSION_URL = "https://solublelabs.com/fhir/StructureDefinition/medication-prn-trigger-phase";
7
10
  export declare function getExactTimingOffsetMinutes(repeat: FhirTimingRepeat | undefined): number | undefined;
11
+ export declare function getTimingOccurrenceCap(repeat: FhirTimingRepeat | undefined): CanonicalOccurrenceCapExpr | undefined;
8
12
  export interface FhirProjectionOptions {
9
13
  /**
10
14
  * Defaults to true. When true, structured spatial body-site phrases such as
@@ -1,4 +1,5 @@
1
- import { AdviceModality, AdvicePolarity, AdviceRelation, EventTiming, FhirCoding } from "../types";
1
+ import { AdviceModality, AdvicePolarity, EventTiming } from "../types";
2
+ export { ACTION_SEQUENCE_MARKERS } from "../relation-terminology";
2
3
  type MealRelation = "before" | "after" | "with";
3
4
  type MealTimingByRelation = Map<MealRelation, Map<EventTiming, EventTiming>>;
4
5
  type BodySiteFeatureKind = "nominal" | "partitive" | "locative";
@@ -22,9 +23,6 @@ type InstructionQuantityUnitLabel = {
22
23
  export declare const SITE_ANCHORS: Set<string>;
23
24
  export declare const SITE_SELF_DISPLAY_ANCHORS: Set<string>;
24
25
  export declare const SITE_FILLERS: Set<string>;
25
- export declare const BODY_SITE_LOCATIVE_RELATIONS: Set<string>;
26
- export declare const BODY_SITE_LOCATIVE_RENDER_PREPOSITIONS: Map<string, string>;
27
- export declare const BODY_SITE_SPATIAL_RELATION_CODINGS: Map<string, FhirCoding>;
28
26
  export declare const BODY_SITE_PARTITIVE_HEADS: Set<string>;
29
27
  export declare const BODY_SITE_PARTITIVE_MODIFIERS: Set<string>;
30
28
  export declare const BODY_SITE_PARTITIVE_CONNECTORS: Set<string>;
@@ -45,9 +43,14 @@ export declare const ROUTE_SITE_PREPOSITIONS: Set<string>;
45
43
  export declare const SITE_DISPLAY_FILLERS: Set<string>;
46
44
  export declare const SITE_MULTIPLICITY_WORDS: Set<string>;
47
45
  export declare const NON_SITE_ANCHORED_PHRASES: Set<string>;
48
- export declare const EXTERNAL_SITE_LOCATIVE_PREFIXES: Set<string>;
46
+ export declare const EXTERNAL_SITE_LOCATIVE_PREFIXES: ReadonlySet<string>;
49
47
  export declare const ROUTE_BLOCKED_BY_FOLLOWING_PARTITIVE_HEADS: Set<string>;
50
48
  export declare const PRN_LEADS: Set<string>;
49
+ export declare const SYMPTOM_ONSET_PREFIX_PATTERNS: string[][];
50
+ export declare const SYMPTOM_ONSET_SUFFIX_PATTERNS: {
51
+ lead: string[];
52
+ suffix: string[];
53
+ }[];
51
54
  export declare const PRN_REASON_LEAD_INS: Set<string>;
52
55
  export declare const PRN_STANDALONE_REASON_LEADS: Set<string>;
53
56
  export declare const PRN_CONTEXTUAL_REASON_LEADS: ContextualPrnReasonLead[];
@@ -76,6 +79,14 @@ export declare const COMPACT_LIST_SEPARATORS: Set<string>;
76
79
  export declare const EVERY_INTERVAL_TOKENS_DATA: Set<string>;
77
80
  export declare const COUNT_MARKER_TOKENS_DATA: Set<string>;
78
81
  export declare const COUNT_CONNECTOR_WORDS_DATA: Set<string>;
82
+ export declare const MAXIMUM_COUNT_LEAD_TOKENS: Set<string>;
83
+ export declare const MAXIMUM_COUNT_LEAD_SEQUENCES: string[][];
84
+ export declare const OCCURRENCE_COUNT_WORDS: Set<string>;
85
+ export declare const OCCURRENCE_CAP_PERIOD_PHRASES: {
86
+ parts: string[];
87
+ period: number;
88
+ periodUnit: string;
89
+ }[];
79
90
  export declare const FREQUENCY_SIMPLE_WORDS_DATA: Record<string, number>;
80
91
  export declare const FREQUENCY_NUMBER_WORDS_DATA: Record<string, number>;
81
92
  export declare const FREQUENCY_TIMES_WORDS_DATA: Set<string>;
@@ -100,7 +111,7 @@ export declare const WAKE_EVENT_ALIASES: Set<string>;
100
111
  export declare const FOOD_EVENT_ALIASES: Set<string>;
101
112
  export declare const DAY_RANGE_CONNECTORS: Set<string>;
102
113
  export declare const RANGE_CONNECTORS: Set<string>;
103
- export declare const DURATION_LEAD_TOKENS: Set<string>;
114
+ export declare const DURATION_LEAD_TOKENS: ReadonlySet<string>;
104
115
  export declare const EVENT_OFFSET_MINIMUM_LEAD_SEQUENCES: string[][];
105
116
  export declare const EVENT_OFFSET_MAXIMUM_LEAD_SEQUENCES: string[][];
106
117
  export declare const EVENT_OFFSET_FRACTIONS: Map<string, number>;
@@ -113,18 +124,31 @@ export declare const ACTION_DIRECTIVE_PREFIXES: {
113
124
  polarity: AdvicePolarity | undefined;
114
125
  modality: AdviceModality | undefined;
115
126
  }[];
116
- export declare const ACTION_RELATION_BY_TOKEN: Map<string, AdviceRelation>;
117
- export declare const ACTION_SEQUENCE_MARKERS: Set<string>;
118
127
  export declare const ACTION_COORDINATION_CONNECTORS: Set<string>;
119
- export declare const ACTION_SEQUENCE_RELATION_TOKENS: Set<string>;
128
+ export declare const ACTION_SEQUENCE_RELATION_TOKENS: ReadonlySet<string>;
120
129
  export declare const INSTRUCTION_DURATION_UNITS: Map<string, string>;
121
130
  export declare const INSTRUCTION_DURATION_APPROXIMATION_LEADS: Set<string>;
122
131
  export declare const INSTRUCTION_QUANTITY_UNIT_LABELS: Map<string, InstructionQuantityUnitLabel>;
123
132
  export declare const FREE_TEXT_DIRECTIVE_STARTS: Set<string>;
124
- export declare const CONDITIONAL_INSTRUCTION_EXCLUSIVE_LEADS: Set<string>;
133
+ export declare const CONDITIONAL_INSTRUCTION_EXCLUSIVE_LEADS: ReadonlySet<string>;
134
+ export declare const ALTERNATE_EVENT_CADENCES: {
135
+ parts: string[];
136
+ when: EventTiming;
137
+ period: number;
138
+ periodUnit: string;
139
+ }[];
140
+ export declare const ADMINISTRATION_WINDOW_INSTRUCTIONS: {
141
+ parts: string[];
142
+ text: string;
143
+ i18n: {
144
+ th: string;
145
+ } | undefined;
146
+ relation: "before" | "after" | undefined;
147
+ activity: string | undefined;
148
+ }[];
125
149
  export declare const SITE_TRAILING_INSTRUCTION_WORDS: Set<string>;
126
150
  export declare const WORKFLOW_CONTINUATION_LICENSES: Set<string>;
127
- export declare const WORKFLOW_ACTION_RELATION_LEADS: Set<string>;
151
+ export declare const WORKFLOW_ACTION_RELATION_LEADS: ReadonlySet<string>;
128
152
  export declare const AS_NEEDED_LEAD_PHRASES: Set<string>;
129
153
  export declare const PRN_BREAKING_COORDINATORS: Set<string>;
130
154
  export declare const SYMPTOM_ADJUSTMENT_LEADS: Set<string>;
@@ -136,4 +160,3 @@ export declare const OCULAR_ROUTE_CODES: Set<import("../types").SNOMEDCTRouteCod
136
160
  export declare const HARD_SEGMENT_BOUNDARY_TOKENS: Set<string>;
137
161
  export declare const CLAUSE_LEAD_WORDS: Set<string>;
138
162
  export declare const LATERAL_MODIFIER_WORDS: Set<string>;
139
- export {};
@@ -5,5 +5,6 @@ export declare function methodLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
5
5
  export declare function routeLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
6
6
  export declare function fillerLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
7
7
  export declare function productLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
8
+ export declare function perTargetCountDoseRule(): HpsgLexicalRule<HpsgClauseContext>;
8
9
  export declare function doseLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
9
10
  export declare function connectorLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
@@ -1,6 +1,7 @@
1
1
  import { Token } from "../../parser-state";
2
2
  import { HpsgClauseContext } from "../rule-context";
3
3
  import { HpsgLexicalRule } from "../signature";
4
+ export declare function startsMaximumCountLead(context: HpsgClauseContext, start: number): boolean;
4
5
  export declare function symptomAdjustmentLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
5
6
  export declare function matchContextualPrnReasonLead(context: HpsgClauseContext, start: number): {
6
7
  tokens: Token[];
@@ -8,4 +9,6 @@ export declare function matchContextualPrnReasonLead(context: HpsgClauseContext,
8
9
  next: number;
9
10
  } | undefined;
10
11
  export declare function tokenBelongsToContextualPrnReasonLead(context: HpsgClauseContext, tokenIndex: number): boolean;
12
+ export declare function hasSymptomOnsetPrnAt(context: HpsgClauseContext, start: number): boolean;
13
+ export declare function symptomOnsetPrnRule(): HpsgLexicalRule<HpsgClauseContext>;
11
14
  export declare function prnLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
@@ -18,7 +18,16 @@ export declare function cadenceFirstImplicitSingleDoseRule(): HpsgLexicalRule<Hp
18
18
  */
19
19
  export declare function cadenceFirstFrequencyRule(): HpsgLexicalRule<HpsgClauseContext>;
20
20
  export declare function countFrequencyRule(): HpsgLexicalRule<HpsgClauseContext>;
21
+ export declare function alternateEventCadenceRule(): HpsgLexicalRule<HpsgClauseContext>;
21
22
  export declare function timingLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
23
+ export declare function quantityFirstActivityTimingRule(): HpsgLexicalRule<HpsgClauseContext>;
24
+ /**
25
+ * Quantity-first event offsets are the ordinary English inverse of
26
+ * relation-first forms: `30 min before breakfast`, `half an hour after food`.
27
+ * They project to the same canonical event-offset feature as `before meals
28
+ * 30 minutes`, so ordering is grammar rather than a separate semantic model.
29
+ */
30
+ export declare function quantityFirstEventOffsetRule(): HpsgLexicalRule<HpsgClauseContext>;
22
31
  /**
23
32
  * Relative event offsets are timing semantics, not treatment duration.
24
33
  * `ก่อนอาหารอย่างน้อยครึ่งชั่วโมง` becomes Before Meal + offsetMin 30 min.
@@ -1,10 +1,12 @@
1
- import { AdviceFrame, AdviceRelation, CanonicalDoseRange, CanonicalAdditionalInstructionExpr, BodySiteSpatialRelation, EventTiming, FhirCoding, FhirDayOfWeek, FhirPeriodUnit, FhirPrimitiveElement, RouteCode, PrnReasonLookupRequest, SiteCodeLookupRequest } from "../types";
1
+ import { AdviceFrame, AdviceRelation, CanonicalDoseRange, CanonicalAdditionalInstructionExpr, CanonicalActivityTimingExpr, CanonicalOccurrenceCapExpr, BodySiteSpatialRelation, EventTiming, FhirCoding, FhirDayOfWeek, FhirPeriodUnit, FhirPrimitiveElement, RouteCode, PrnReasonLookupRequest, SiteCodeLookupRequest } from "../types";
2
2
  import { Token } from "../parser-state";
3
3
  import type { HpsgFeatureNode } from "./type-system";
4
4
  export type HpsgType = "sign" | "word-sign" | "phrase-sign" | "headed-phrase" | "head-complement-phrase" | "head-adjunct-phrase" | "head-marker-phrase" | "procedure-sequence-phrase" | "conditional-instruction-phrase" | "coordination-phrase" | "clause-sign" | "administration-clause" | "method-sign" | "route-sign" | "site-sign" | "dose-sign" | "schedule-sign" | "prn-sign" | "instruction-sign" | "conditional-sign" | "adjustment-sign" | "connector-sign";
5
5
  export interface HpsgEvidence {
6
6
  rule: string;
7
7
  tokenIndices: number[];
8
+ /** Lexical evidence that a schedule field is an inferred, construction-local default. */
9
+ scheduleDefault?: "daily-frequency";
8
10
  }
9
11
  export type HpsgConstructionKind = "head-complement" | "head-adjunct" | "head-marker" | "procedure-sequence" | "conditional-instruction" | "coordination" | "administration-clause" | "generic";
10
12
  export type HpsgConstructionOperation = "unify" | "scope";
@@ -39,9 +41,11 @@ export interface HpsgSiteFeature {
39
41
  export interface HpsgPrnFeature {
40
42
  enabled: true;
41
43
  reasonText?: string;
44
+ triggerPhase?: "onset";
42
45
  lookupRequest?: PrnReasonLookupRequest;
43
46
  reasons?: Array<{
44
47
  text: string;
48
+ triggerPhase?: "onset";
45
49
  lookupRequest?: PrnReasonLookupRequest;
46
50
  }>;
47
51
  lookupRequests?: PrnReasonLookupRequest[];
@@ -80,6 +84,7 @@ export interface HpsgScheduleFeature {
80
84
  attachmentClass?: "administration" | "procedure";
81
85
  timingCode?: string;
82
86
  count?: number;
87
+ countMax?: number;
83
88
  duration?: number;
84
89
  durationMax?: number;
85
90
  durationUnit?: FhirPeriodUnit;
@@ -94,6 +99,8 @@ export interface HpsgScheduleFeature {
94
99
  when?: EventTiming[];
95
100
  dayOfWeek?: FhirDayOfWeek[];
96
101
  timeOfDay?: string[];
102
+ activityTiming?: CanonicalActivityTimingExpr[];
103
+ occurrenceCap?: CanonicalOccurrenceCapExpr;
97
104
  }
98
105
  export interface HpsgSynsem {
99
106
  head: {
@@ -161,4 +168,5 @@ export declare function lexicalSign(args: {
161
168
  siteTokenIndices?: number[];
162
169
  warnings?: string[];
163
170
  score?: number;
171
+ scheduleDefault?: HpsgEvidence["scheduleDefault"];
164
172
  }): HpsgSign;